You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rather than draw the sprites directly to the LCD, you should draw them to what is called the graphbuffer (or gbuf or plotSScreen). Drawing directly to the LCD isn't that common on the 83+. To copy the data in the gbuf, you can use a routine like ionFastCopy. Get some ideas from here: http://wikiti.brandonw.net/index.php?title=Z80_Routines:Graphic:Fastcopy
To draw the actual sprites, each byte on the LCD corresponds to 8 pixels and each row in the LCD has 12 bytes worth of pixels. 12 bytes of 8 pixels each = a total of 96 pixels.
If you want to draw an 8x8 sprite at the position 0x0, you draw the first byte of the sprite at the first byte of the gbuf. The second byte of the sprite gets drawn in the second row of the graph buffer. To move down one row, we need to add the width of the graph buffer. Since the LCD is 12 bytes wide, the second byte gets drawn at (gbuf+12). The third byte at (gbuf+12_2), the fourth at (gbuf+12_3), etc.
If you want to draw at pixel 8, you just add one to the graph buffer pointer. So instead of drawing the first pixel to (gbuf) you draw it to (gbuf+1). The second byte in your sprite gets drawn to (gbuf+1+12). The third to (gbuf+1+12*2) and so on. If you want to draw to a pixel that isn't aligned to a byte, for example to pixel 4, it gets much more complicated. I recommend just drawing to aligned X values for now.
EDIT: To start with, for practice use one of the fastcopy routines in the link i gave you. Then try copying some random values into the graphbuffer, using fastcopy to display it, then pause the program. If you are in an emulator, using the instruction "jr $" will pause your program. If you test it on your calculator, however, it will put your program into an infinite loop and you'll have to remove the batteries. Otherwise, you can use this pause routine i wrote (to use, put it in your source file and do "call pause", it will wait for you to press and release a key before continuing execution):
;######################
getKey:
;# input:
;# - a = key group to read from
;# output:
;# - a = keys pressed ($FF = no keys pressed)
;######################
out (1), a ; opens the key group we want to read from
push af ; a delay for 84+/SE calcs
pop af ; (unnecessary for 83+/SE calcs)
in a, (1) ; read value from key port
ret
; a should hold the value of the key you pressed +1
pause:
call releaseKeys
pause_loop:
xor a
call getKey
ld b, a
inc a
jr z, pause_loop
releaseKeys:
xor a
call getKey
inc a
jr nz, releaseKeys
ret
The text was updated successfully, but these errors were encountered: