[A83] 83p Problem with moving a sprite


[Prev][Next][Index][Thread]

[A83] 83p Problem with moving a sprite




Hi.  I wrote this sprite routine that displays an 8x8 sprite, checks for
input, clears that sprite, jumps to input commans (ex. if the left key was
pressed) and then draws the second sprite in the series.  It switches
between the two two sprites everytime it loops.  Now here is my problem, it
moves to the right just fine, but on certain spots when you move to the left
it gets stuck.  The getting stuck is always in the same place, and I cannot
figure out why.  PLEASE HELP ME!  Thanks in advance.


;Source to sprite routine
;NumCardsLeft = 5
;Gnome = 8x16 sprite (First half is the first sprite, second half is the
socond sprite)
SelectGnome:
	  xor a
        ld (Temp7),a
        ld a,1
        ld (Temp6),a
GnomeLoop:
        ld a,(Temp7)
        inc a
        and %00000001
        ld (Temp7),a
        ld ix,Gnome0
        cp 1
        jr z,FirstGnome
        ld b,8
SecondGnome:
        inc ix
        djnz SecondGnome
FirstGnome:
        ld b,8
        ld a,(Temp6)
        dec a
        add a,a
        add a,a
        add a,a
        add a,32
        ld l,56
        push ix
	  push af
	  push hl
        push bc
	  call isprite
	  call ifastcopy
	  call GnomeWait
	  pop bc
	  pop hl
	  pop af
	  pop ix
	  call isprite
	  call ifastcopy
        ld a,(Temp8)
	  ld b,a
	  xor a
        ld (Temp8),a
	  ld a,b
	  cp 0
	  jr z,GnomeLoop
	  cp skLeft
        call z,GnomeLeft
        cp skDown
        call z,GnomeRight
        cp skEnter
	  jr z,GnomeSelect
	  cp sk2nd
	  jr z,GnomeSelect
	  jr GnomeLoop
GnomeWait:
        ld b,90
GnomeHalt:
        push bc
        Halt
        bcall(_GetCSC)
        ld (Temp8),a
        pop bc
        cp 0
        ret nz
        djnz GnomeHalt
	  ret
GnomeLeft:
        ld a,(Temp6)
        dec a
        ld (Temp6),a
        cp 0
        jr z,GnomeEnd
	  ret
GnomeRight:
        ld a,(Temp6)
        inc a
        ld (Temp6),a
        ld b,a
        ld a,(NumCardsLeft)
	  inc a
	  cp b
        jr z,GnomeHome
	  ret
GnomeHome:
        ld a,(Temp6)
        ld a,1
        ld (Temp6),a
        ret
GnomeEnd:
        ld a,(NumCardsLeft)
        ld (Temp6),a
        ret
GnomeSelect:
        ret





Follow-Ups: