I am having some problems having more than one sprite display at the same time. I have no problem displaying the first one, but as soon as I attempt to display more than one, none of the sprites are displayed.
Is there anything in my code that is outright wrong? Any help to point me in the right direction or figure out why I can not display more than one sprite would be appreciated.
If I comment out the second part of the drawsprite routine - one sprite will appear.
However, with that code not-commented out, neither of the sprites will show. I am new to NES development so I'm sorry if the answer to my problem is obvious.
Thanks
Code:
.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0
.bank 1
.org $FFFA
.dw 0
.dw start
.dw 0
.bank 0
.org $8000
start:
lda #%00001000
sta $2000
lda #%00011110
sta $2001
jsr waitblank
jsr waitblank
lda #$3F
sta $2006
lda #$00
sta $2006
ldx #$00
loadpal:
lda tilepal, x
sta $2007
inx
cpx #32
bne loadpal
ldx #$00
mainloop:
jsr waitblank
jsr drawsprite
;jsr joystick
jmp mainloop
waitblank:
lda $2002 ; load A with value at location $2002
bpl waitblank ; if bit 7 is not set (not VBlank) keep checking
rts
drawsprite:
lda #$00
sta $2003
sta $2003
lda #$50
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$50
sta $2004
lda #$08
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$18
sta $2004
rts
tilepal: ;.incbin "test.pal"
.db $3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30
.db $3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30
.bank 2
.org $0000
.incbin "testbkg.chr"
.incbin "testspr.chr"
.ineschr 1
.inesmir 1
.inesmap 0
.bank 1
.org $FFFA
.dw 0
.dw start
.dw 0
.bank 0
.org $8000
start:
lda #%00001000
sta $2000
lda #%00011110
sta $2001
jsr waitblank
jsr waitblank
lda #$3F
sta $2006
lda #$00
sta $2006
ldx #$00
loadpal:
lda tilepal, x
sta $2007
inx
cpx #32
bne loadpal
ldx #$00
mainloop:
jsr waitblank
jsr drawsprite
;jsr joystick
jmp mainloop
waitblank:
lda $2002 ; load A with value at location $2002
bpl waitblank ; if bit 7 is not set (not VBlank) keep checking
rts
drawsprite:
lda #$00
sta $2003
sta $2003
lda #$50
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$50
sta $2004
lda #$08
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$18
sta $2004
rts
tilepal: ;.incbin "test.pal"
.db $3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30
.db $3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30,$3F,$00,$10,$30
.bank 2
.org $0000
.incbin "testbkg.chr"
.incbin "testspr.chr"
Is there anything in my code that is outright wrong? Any help to point me in the right direction or figure out why I can not display more than one sprite would be appreciated.
If I comment out the second part of the drawsprite routine - one sprite will appear.
Code:
lda #$08
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$18
sta $2004
sta $2004
lda #$00
sta $2004
lda #%00000000
sta $2004
lda #$18
sta $2004
However, with that code not-commented out, neither of the sprites will show. I am new to NES development so I'm sorry if the answer to my problem is obvious.
Thanks