notLeft:
cp skRight ;was it the right key?
jr nz,notRight ;if it wasn't, we don't want to run this
ld a,(hl)
cp 21
jr z,choosepieces
inc (hl)
inc (hl)
inc (hl)
notRight:
It only does that when I try to go past the last sprite. If I quit from any of the other ones, it exits just fine.
Here's the rest of the code for that section:
Code: Select all
choosepieces:
bcall(_cleargbuf) ;clear the gbuf
call putthesprite
ld de,45*256+40
ld (pencol),de
ld hl,tile_data ;I stored the '<' character in the first byte and the '>' character in the 3rd
bcall(_vputs)
ld a,53
ld (pencol),a
bcall(_vputs)
call ionfastcopy
ld hl,select_character
bcall(_homeup)
bcall(_puts)
;;;;TRY TO SIMULATE INGAME DELAY
ei
halt
halt
halt
di
bcall(_getcsc)
push af ;we mess with 'a' down below (ld a,(hl)), so save it for lower keypresses
ld hl,playerdata+6
call determineplayer
cp skLeft ;Was it the left key?
jr nz,notLeft
ld a,(hl)
or a
jr z,choosepieces
dec (hl)
dec (hl)
dec (hl)
xor a ;the getcsc value for the right arrow is 03h. Therefore, if we loaded
;playerdata+6 and it pointed to 3 (the second character) it would be tricked
;into thinking that the right key was pressed with cp skRight. I can't explain it,
;try taking out the xor a and see what happens.
notLeft:
cp skRight ;was it the right key?
jr nz,notRight ;if it wasn't, we don't want to run this
ld a,(hl)
cp 21
jr z,choosepieces
inc (hl)
inc (hl)
inc (hl)
notRight:
pop af ;when the playerdata+6 variable equals nine, well actually 12, but the previous value was nine (the value of skEnter) it will think enter was pressed and select that character. thus we pop af
cp skEnter ;was enter pressed?
jr z,play2 ;if so, then go to label second
cp skMode ;was mode pressed?
jp z,quitter ;if so, quit
jr choosepieces ;go to label start