I can't seem to figure out what's wrong with my input routine. I'm trying to move a single sprite, to no avail. The sprite is displayed, though, so it must be something with how my program handles input. Here's the relevant part of the program:
SetSpr:
lda #$00
ldx X_Pos
ldy Y_Pos
sta $2003 ;Set SPR-RAM to $0000
sta $2003
sty $2004 ;Set y-value for Sprite 0
sta $2004 ;Use Tile #0
sta $2004 ;Use Color #0
stx $2004 ;Set x-value for Sprite 0
ReadPad1:
lda #$01
ldx #$00 ;Strobe joypad
sta $4016
stx $4016
sta $4016
stx $4016
lda $4016 ;A
lda $4016 ;B
lda $4016 ;Select
lda $4016 ;Start
lda $4016 ;Up
sta Up
lda $4016 ;Down
sta Down
lda $4016 ;Left
sta Left
lda $4016 ;Right
sta Right
UpTest:
lda Y_Pos ;Test upper boundary
cmp #$07
beq DownTest
lda Up ;Test if Up pressed
cmp #$01
bne DownTest
inc Y_Pos ;If so, increase Y position
DownTest:
lda Y_Pos
cmp #223
beq LeftTest
lda Down
cmp #$01
bne LeftTest
dec Y_Pos
LeftTest:
lda X_Pos
cmp #$00
beq RightTest
lda Left
cmp #$01
bne RightTest
dec X_Pos
RightTest:
lda X_Pos
cmp #248
beq InfiniteLoop
lda RightTest
cmp #$01
bne InfiniteLoop
inc X_Pos
InfiniteLoop
jmp InfiniteLoop
Code:
SetSpr:
lda #$00
ldx X_Pos
ldy Y_Pos
sta $2003 ;Set SPR-RAM to $0000
sta $2003
sty $2004 ;Set y-value for Sprite 0
sta $2004 ;Use Tile #0
sta $2004 ;Use Color #0
stx $2004 ;Set x-value for Sprite 0
ReadPad1:
lda #$01
ldx #$00 ;Strobe joypad
sta $4016
stx $4016
sta $4016
stx $4016
lda $4016 ;A
lda $4016 ;B
lda $4016 ;Select
lda $4016 ;Start
lda $4016 ;Up
sta Up
lda $4016 ;Down
sta Down
lda $4016 ;Left
sta Left
lda $4016 ;Right
sta Right
UpTest:
lda Y_Pos ;Test upper boundary
cmp #$07
beq DownTest
lda Up ;Test if Up pressed
cmp #$01
bne DownTest
inc Y_Pos ;If so, increase Y position
DownTest:
lda Y_Pos
cmp #223
beq LeftTest
lda Down
cmp #$01
bne LeftTest
dec Y_Pos
LeftTest:
lda X_Pos
cmp #$00
beq RightTest
lda Left
cmp #$01
bne RightTest
dec X_Pos
RightTest:
lda X_Pos
cmp #248
beq InfiniteLoop
lda RightTest
cmp #$01
bne InfiniteLoop
inc X_Pos
InfiniteLoop
jmp InfiniteLoop