Create macro for advancing sprite array pointers.

This commit is contained in:
Colin McMillen 2015-06-07 10:36:56 -04:00
parent 52ac6e0cbe
commit bb674fced2

View File

@ -47,6 +47,15 @@ rep #%00010000 ; 16-bit X/Y.
; Modifies X and Y to move to the next elements in the sprite tables.
.MACRO AdvanceSpritePointers
.rept 4
inx
.endr
iny
.ENDM
.BANK 0 SLOT 0 .BANK 0 SLOT 0
.ORG 0 .ORG 0
.SECTION "MainCode" .SECTION "MainCode"
@ -958,11 +967,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%11000000 ; Enable large sprite. lda #%11000000 ; Enable large sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
AdvanceSpritePointers
.rept 4
inx
.endr
iny
; Now add enemy ships. ; Now add enemy ships.
sty $00 ; Save sprite table 2 index. sty $00 ; Save sprite table 2 index.
@ -984,14 +989,10 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
ldy $00 ldy $00
lda #%11000000 ; Enable large sprite. lda #%11000000 ; Enable large sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
iny AdvanceSpritePointers
sty $00 sty $00
ply ; Restore enemyShipArray index. ply ; Restore enemyShipArray index.
.rept 4
inx
.endr
+ +
.rept enemyShipSize .rept enemyShipSize
iny iny
@ -1018,13 +1019,10 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
ldy $00 ldy $00
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
iny AdvanceSpritePointers
sty $00 sty $00
ply ; Restore playerShotArray index. ply ; Restore playerShotArray index.
.rept 4
inx
.endr
+ +
.rept shotSize .rept shotSize
iny iny
@ -1056,10 +1054,8 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
.rept 4 AdvanceSpritePointers
inx
.endr
iny
inc $01 inc $01
bra - bra -
+ +
@ -1083,10 +1079,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
.rept 4 AdvanceSpritePointers
inx
.endr
iny
; Second digit. ; Second digit.
lda playerScore lda playerScore
@ -1107,10 +1100,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
.rept 4 AdvanceSpritePointers
inx
.endr
iny
; Third digit. ; Third digit.
lda playerScore + 1 lda playerScore + 1
@ -1129,10 +1119,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
.rept 4 AdvanceSpritePointers
inx
.endr
iny
; Fourth digit. ; Fourth digit.
lda playerScore + 1 lda playerScore + 1
@ -1153,11 +1140,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
sta spriteTableStart + 3, X sta spriteTableStart + 3, X
lda #%01000000 ; Enable small sprite. lda #%01000000 ; Enable small sprite.
sta spriteTableScratchStart, Y sta spriteTableScratchStart, Y
.rept 4 AdvanceSpritePointers
inx
.endr
iny
; Now clear out the unused entries in the sprite table. ; Now clear out the unused entries in the sprite table.
- -
@ -1165,9 +1148,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces.
beq + beq +
lda #1 lda #1
sta spriteTableStart, X sta spriteTableStart, X
.rept 4 AdvanceSpritePointers
inx
.endr
bra - bra -
+ +
rts rts