This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 18 Apr 2010 10:25:43 am    Post subject:

Hi,

are there any routines for drawing operations in assembler?
Or can I use ROM-Calls? If yes, how are these ROM-Calls called?
Something like Line(... in TI's BASIC.

greets
Back to top
thepenguin77


Advanced Newbie


Joined: 17 Jul 2009
Posts: 72

Posted: 18 Apr 2010 10:52:47 am    Post subject:

There are multiple ways to draw stuff in assembly.

There are the low level options where you actually plot picture or whatever pixel by pixel in memory. Some good examples from the Learn TI-83 Plus Assembly in 28 Days are Monochrome Graphics and Sprites.

For the higher level routines where you just type in coordinates, there's bcall(_darkLine) and if you are using Mirage, you can use call fastLine (a = 0 white, 1 black, 2 xor, DE = xy, HL = xy).

DarkLine will be slow for games and such, but all of the rest of these are really fast.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 18 Apr 2010 02:38:17 pm    Post subject:

OK, thank you, that's what I wanted to know.

greets
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 21 Apr 2010 08:50:39 pm    Post subject:

Splinter wrote:

OK, thank you, that's what I wanted to know.

greets

There's a lot of drawing routines already written such as Fastline, XOR sprite and what not. Sprites are probably the most commomly used form of displaying a monochrome image because of its relative simplicity. Lines come in handy too. Very Happy


Last edited by Guest on 21 Apr 2010 08:52:24 pm; edited 1 time in total
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 23 Apr 2010 12:16:56 pm    Post subject:

I just searched TIcalc.org for "Fastline" and I finally found something: click here!
The category says: "TI-86 Assembly Routines".
Has the TI-86 also a Z80 Processor?
And can I use this Routine also for a TI-83 (TI-82 STATS)?

greets

[EDIT]

OK, now I'm using the routine LineDraw from Badja and it's working pretty good so far.


Last edited by Guest on 23 Apr 2010 01:15:49 pm; edited 1 time in total
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 23 Apr 2010 07:01:00 pm    Post subject:

You need to change a couple of small things to port an 86 routine to the 83+ but its nothing serious.

Also i believe CoBB's line routine http://www.ticalc.org/archives/files/fileinfo/234/23429.html is worth checking out.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 24 Apr 2010 05:29:33 am    Post subject:

tr1p1ea wrote:

You need to change a couple of small things to port an 86 routine to the 83+ but its nothing serious.

Also i believe CoBB's line routine http://www.ticalc.org/archives/files/fileinfo/234/23429.html is worth checking out.


OK, thanks!
I'll check it out.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 12 May 2010 03:59:15 pm    Post subject:

Hi,
It's me again.
I read some stuff about the GraphBuffer where I can plot pixels.
At z80-Heaven I read that the GraphBuffer is defined by the programmer (in this case this must be me).
But how to define (and where to locate) this? And how to tell the "GrBufCpy"-Function where the buffer is located?
I can't locate it from any address to $FFFF because the stack is already located there, am i right?

You may ask why I want to use this methode. I want to draw AND erase pixels (Well there must be some routines wich allow also erasing pixels but I don't understand them at all).
I tried to edit some drawing routines but reading source code of these routines is quite confusing (Syntax such as C++ ones would be more "human friendly").


greets
Back to top
calcdude84se


Member


Joined: 09 Aug 2009
Posts: 207

Posted: 12 May 2010 05:41:04 pm    Post subject:

I'm not completely sure what you're trying to say, but the graph buffer is PlotSScreen, which should be defined in ti83plus.inc as $9340 (this happens to be about the only hex addr I know Smile).
BCALL(_GrBufCpy) displays the contents of the buffer on the display. What drawing routines are you talking about? I might be able to help you understand how to use them.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 13 May 2010 09:20:04 am    Post subject:

Ah, OK thanks.
I didn't konw that "PlotSScreen" is the graph buffer.

So let's say I want to plot a Pixel at X=1; Y=1
This should work like this:


Code:

   ld HL, $0101
   ld (PlotSScreen), HL
   bcall(_GrBufCpy)


By the way: does anyone know if theres any difference between "bcall(...)" and "b_call(...)" ?

greets

[EDIT]

AWESOME! I can plot Pixels!
Well, the only problem is, I don't know what values I have to load into PlotSScreen.
Maybe it coheres with the pencol and pencur things.
Anyway, thanks guys! Now I will write a Tic-Tac-Toe game Very Happy .


Last edited by Guest on 13 May 2010 09:33:57 am; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 13 May 2010 12:11:39 pm    Post subject:

Splinter wrote:

Ah, OK thanks.
I didn't konw that "PlotSScreen" is the graph buffer.

So let's say I want to plot a Pixel at X=1; Y=1
This should work like this:


Code:

   ld HL, $0101
   ld (PlotSScreen), HL
   bcall(_GrBufCpy)


By the way: does anyone know if theres any difference between "bcall(...)" and "b_call(...)" ?

greets

[EDIT]

AWESOME! I can plot Pixels!
Well, the only problem is, I don't know what values I have to load into PlotSScreen.
Maybe it coheres with the pencol and pencur things.
Anyway, thanks guys! Now I will write a Tic-Tac-Toe game Very Happy .


It doesn't work that way at all. PlotSScreen is the start of a 768-byte area of memory, and each byte holds 8 pixels (each bit is a pixel, where white=0 and black=1). So each row of the screen is 12 bytes (96 pixels) long. To set pixel (1,1), you can do:

Code:
ld hl,PlotSScreen + 12 ;first byte of row 1
ld a,(hl)
or %01000000 ;Set the second bit from the left
ld (hl),a


Of course, more generalized routines exist. I would recommend looking up the getPixel routine from ION.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 14 May 2010 09:43:55 am    Post subject:

Ah! Thanks dude!
Now I understand.
By adding 12 (hexadecimal: 0C) to $9340 (As you said before, $9340 is the first byte in the first row of PlotSScreen) I get the first byte of the second row.
I load this address in HL. Then I load the content of $934C into the accumulator. Now the accumulator is 000000, right?
or %01000000 will set the 6th bit like this: %01000000.
I put this value back into the address stored in HL.
And finally by calling _GrBufCpy the pixel will be displayd on the screen. Awesome!
Maybe I will make my own Line Draw routine. Well I don't yet know how but I will :)

Thanks!
greets
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 15 May 2010 11:48:08 am    Post subject:

Hi,

how to shift a bit from a bit one position? For example: %10000000 to %01000000.
I thought i could use "SRA" but it does the following: %10000000 to %11000000.

I need that, because I want to detect the pixel within a byte.

greets


Last edited by Guest on 16 May 2010 09:23:14 am; edited 1 time in total
Back to top
calcdude84se


Member


Joined: 09 Aug 2009
Posts: 207

Posted: 15 May 2010 02:21:35 pm    Post subject:

SRL should do the trick. However, if you need to detect a pixel, the command 'bit' (used like bit 7,a or bit 4,b or even bit 6,(hl)) would be more efficient. The zero flag contains the result.
For example, if the byte you wanted to test was at (PlotSScreen+21) and the fifth bit (bit are numbered from 0 to 7, 0 being the bit that determines whether the number is even or odd) you would use

Code:
ld hl,PlotSScreen+21
bit 5,(hl)
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 15 May 2010 06:46:58 pm    Post subject:

For this purpose, you could also use RRCA. It rotates the value of A to the right, and it's smaller and faster than most shifts (one byte and 4 t-states). By rotate, I mean that the bit that is shifted out of bit 0 will be shifted back into bit 7.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 16 May 2010 09:19:01 am    Post subject:

Thanks for these suggestions, I chose "RRCA" because the "BIT"-instruction could not set the bit, which is in a 8-bit register, to another register.
For example I have $05 in the accumulator then I can't do it like this: bit A, (HL).


Anyway, I have now my own get-pixel routine:


Code:
getPixel:
   ld HL,PlotSScreen

   push DE
   ld D, 0
   ld A, 0
multiply12:
   inc A
   add HL, DE
   cp 12
   jp nz, multiply12
   pop DE

   ld A, D
   ld B, 0
modulo8:
   inc B
   ld C, A
   sub 8
   jp p, modulo8
   ld A, B
   sub 1
   
   ld E, A
   ld D, 0
   add HL, DE

   ld A, C
   ld C, %10000000
   cp 1
   jp z, endShift
   cp 1
   jp m, noRest
   sub 1
   ld B, A
   inc B
   ld A, 0
   jp startShift
noRest:   
   dec HL
   ld C, %00000001
   jp endShift
startShift:
   inc A
   push AF
   ld A, C
   rrca
   ld C, A
   pop AF
   cp B
   jp nz, startShift
endShift:
   
   ld A, (HL)
   or C
   ld (HL), A


The input is DE (where D=X; E=Y)
For example D is $5F (95 in decimal) and E is $3F (which is 63 in decimal). So the pixel is plotted in the lower right corner of the display.
Well you have to call "_GrBufCpy" to display the pixel.

If you have some improvements or any smarter ways, let me know.

Anyway thanks a lot for your support!

greets


Last edited by Guest on 16 May 2010 09:21:21 am; edited 1 time in total
Back to top
thepenguin77


Advanced Newbie


Joined: 17 Jul 2009
Posts: 72

Posted: 16 May 2010 12:01:14 pm    Post subject:

That will work, although there is a much more optimized way to do it.


Code:
getPixel:
   ld   l, e
   ld   a, d
   ld   h, 0
   ld   d, h

;multiply by 12

   add   hl, hl   ;2
   add   hl, de   ;3
   add   hl, hl   ;6
   add   hl, hl   ;12

;divide by 8

   ld   e, a
   srl   e
   srl   e
   srl   e

   add   hl, de


   ld   de, plotSScreen
   add   hl, de

;I usually quit here

   and   7   ;same as modulo 8
   
   ld   a, %10000000

   jr   z, plot

   ld   b, a
shiftLoop:
   rrca
   djnz   shifLoop

plot:
   xor   (hl)      ;I use xor so it can toggle
   ld   (hl), a
   ret


This routine is actually more of a toggle pixel. For typical getPixel, it just returns the destination as almost all cases need to do more than toggle a pixel.
Back to top
splinter


Newbie


Joined: 04 Apr 2010
Posts: 21

Posted: 17 May 2010 08:02:54 am    Post subject:

Thanks, your routine looks really beatiful Smile
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement