Quantcast
Channel: Cemetech
Viewing all articles
Browse latest Browse all 75370

z80 Assembly :: RE: Baby Steps in Drawing Sprites

$
0
0
Author: shundra9
Posted: 29 Nov 2012 12:12:47 am (GMT -5)

Dammit I really wish I could program something substantial without having to ask for help every other line...but I'm totally stuck. Following Kerm's advice I can now place the smileyFace sprite in different locations according to the contents of an X_COORD and Y_COORD variable, but I cannot for the life of me change this variable according to keypresses. It was easy to move a point around the screen so I have no idea why this situation is so much more difficult. Below is my source code:


Code:

#include    "ti83plus.inc"
.org    $9D93
.db    $BB, $6D

start:       
   bcall(_clrLCDfull)
   bcall(_grbufclr)
   set fullScrnDraw, (IY + apiFlg4)
   ld a,skDown

loop:            ;Wait for user input
   jp nz,checkInput
   bcall(_getCSC)
   jp loop
checkInput:         ;Check user input
   cp skEnter
   jp z,End
   cp skClear
   jp z,End
   cp skLeft
   jp z,Left
   cp skRight
   jp z,Right
   cp skUp
   jp z,Up
   cp skDown
   jp z,Down
   ld a,0
   jp loop
Disp:
   ld b,8         ;Display the sprite at (X_COORD, Y_COORD)
   ld a,(Y_COORD)
   ld l,a
   ld a,(X_COORD)
   ld ix,smileyFace
   call ionPutSprite
   call ionFastCopy
   ld a,0
   jp loop

Left:
   ld a,(X_COORD)
   dec a
   ld (X_COORD),a
   jp Disp
Right:
   ld a,(X_COORD)
   inc a
   ld (X_COORD),a
   jp Disp
Up:
   ld a,(Y_COORD)
   dec a
   ld (Y_COORD),a
   jp Disp
Down:
   ld a,(Y_COORD)
   inc a
   ld (Y_COORD),a
   jp Disp
End:
   bcall(_clrLCDfull)
   ret

X_COORD:
   .db 17
Y_COORD:
   .db 0

smileyFace:
  .db %00000000
  .db %01100110
  .db %01100110
  .db %00000000
  .db %00000000
  .db %10000001
  .db %01000010
  .db %00111100

.end


Yes I know that there is no bounds checking to make sure the sprite doesn't go off the screen, and yes I know that the sprite keeps getting redrawn without erasing the last one... What I can NOT figure out is why the program doesn't seem to be responding to any key presses at all. It displays the smileyFace once, as intended, but then it gets stuck in some infinite loop from which I cannot escape. From debugging, I believe that this is occurring inside the loop label, seemingly because the program isn't recognizing when a new key is pressed and a is made nonzero. But I really have no idea. I just wanna make my smileyFace move, help!!
Also, you know how in Basic you can make a program be run through MirageOS by putting two colons on the first line of code? What is the equivalent thing that must be written in asm code to make a program be run by Mirage?


Viewing all articles
Browse latest Browse all 75370

Trending Articles