Pointers working for the NMI OAM copy, thanks Ophis

This commit is contained in:
2012-11-04 12:25:10 -05:00
parent ff7579cdfe
commit 7ea451361a
2 changed files with 24 additions and 16 deletions

View File

@@ -1 +1,2 @@
.alias curSpriteData curSpriteDataHi .alias curSpriteDataRead curSpriteDataLo
.alias curSpriteDataWrite curSpriteDataHi

View File

@@ -199,34 +199,41 @@ _MAIN_loop:
NMI: NMI:
LDX #$0 LDX #$0
LDY #$0 LDY #$0
;; This is almost a reusable function ... store 'sprMario' as our
;; current sprite that we're about to draw
LDA sprMario LDA sprMario
STA curSpriteLen STA curSpriteLen
LDA #>sprMarioData
STA curSpriteDataHi
LDA #<sprMarioData
STA curSpriteDataLo
;; ----
_NMI_CopyMarioToOAM: _NMI_CopyMarioToOAM:
LDA playery ; set Y position LDA playery ; set Y position
CLC CLC
ADC sprMarioData, x ADC (curSpriteDataLo), y
STA $0200, x STA $0200, y
INX INY
LDA sprMarioData, x ; set tile number LDA (curSpriteDataLo), y ; set tile number
STA $0200, x STA $0200, y
INX INY
LDA pad1a LDA pad1a
AND #%00000001 AND #%00000001
BNE _NMI_CopyMarioToOAM_padup BNE _NMI_CopyMarioToOAM_padup
LDA sprMarioData, x LDA (curSpriteDataLo), y
JMP _NMI_CopyMarioToOAM_paddone JMP _NMI_CopyMarioToOAM_paddone
_NMI_CopyMarioToOAM_padup: _NMI_CopyMarioToOAM_padup:
LDA sprMarioData, x ; set attributes LDA sprMarioData, y ; set attributes
_NMI_CopyMarioToOAM_paddone: _NMI_CopyMarioToOAM_paddone:
STA $0200, x STA $0200, y
INX INY
LDA playerx ; set X position LDA playerx ; set X position
CLC CLC
ADC sprMarioData, x ADC (curSpriteDataLo), y
STA $0200, x STA $0200, y
INX INY
INY ; increment the sprite counter INX ; increment the sprite counter
CPY curSpriteLen ; any more sprites in the current multisprite? CPX curSpriteLen ; any more sprites in the current multisprite?
BNE _NMI_CopyMarioToOAM BNE _NMI_CopyMarioToOAM
;; We need to copy all our OAM data to put sprites on screen during ;; We need to copy all our OAM data to put sprites on screen during