Add specialized erase routines for different sprite sizes

This commit is contained in:
Lucas Scharenbroich 2022-02-03 08:59:10 -06:00
parent d3b61f8de6
commit 525f6d9c67

View File

@ -133,16 +133,9 @@ _ClearSpriteFromTileStore
; drawn in the next phase (since a portion of their content may have been erased if they overlap) ; drawn in the next phase (since a portion of their content may have been erased if they overlap)
; ;
; In the second phase, the sprite is re-drawn into the sprite plane buffers and the appropriate ; In the second phase, the sprite is re-drawn into the sprite plane buffers and the appropriate
<<<<<<< HEAD
; Tile Store locations are marked as dirty
;
; IF a sprite is marked as FREE, it is transitioned to a free slot after being erased from the
; the scene and its slot index is returned to the open list.
=======
; Tile Store locations are marked as dirty. It is important to recognize that the sprites themselves ; Tile Store locations are marked as dirty. It is important to recognize that the sprites themselves
; can be marked dirty, and the underlying tiles in the tile store are independently marked dirty. ; can be marked dirty, and the underlying tiles in the tile store are independently marked dirty.
>>>>>>> toolbox-conversion
forceSpriteFlag ds 2 forceSpriteFlag ds 2
_RenderSprites _RenderSprites
@ -305,48 +298,19 @@ _EraseSpriteY
erase_8x8 erase_8x8
ldx _Sprites+OLD_VBUFF_ADDR,y ldx _Sprites+OLD_VBUFF_ADDR,y
jmp _EraseTileSprite ; erase from the old position jmp _EraseTileSprite8x8 ; erase from the old position
erase_8x16 erase_8x16
clc
ldx _Sprites+OLD_VBUFF_ADDR,y ldx _Sprites+OLD_VBUFF_ADDR,y
jsr _EraseTileSprite jmp _EraseTileSprite8x16
txa
adc #{8*SPRITE_PLANE_SPAN}
tax
jmp _EraseTileSprite
erase_16x8 erase_16x8
clc
ldx _Sprites+OLD_VBUFF_ADDR,y ldx _Sprites+OLD_VBUFF_ADDR,y
jsr _EraseTileSprite jmp _EraseTileSprite16x8
txa
adc #4
tax
jmp _EraseTileSprite
erase_16x16 erase_16x16
clc
ldx _Sprites+OLD_VBUFF_ADDR,y ldx _Sprites+OLD_VBUFF_ADDR,y
jmp _EraseTileSprite16x16 jmp _EraseTileSprite16x16
; jsr _EraseTileSprite
txa
adc #4
tax
jsr _EraseTileSprite
txa
adc #{8*SPRITE_PLANE_SPAN}-4
tax
jsr _EraseTileSprite
txa
adc #4
tax
jmp _EraseTileSprite
; X = _Sprites array offset ; X = _Sprites array offset
_DrawSprite _DrawSprite
@ -770,49 +734,82 @@ _CacheSpriteBanks
SPRITE_PLANE_SPAN equ 256 SPRITE_PLANE_SPAN equ 256
_EraseTileSprite ; X = bank address
_EraseTileSprite8x8
phb ; Save the bank to switch to the sprite plane phb ; Save the bank to switch to the sprite plane
pei SpriteBanks pei SpriteBanks
plb ; pop the data bank (low byte) plb ; pop the data bank (low byte)
lda #0 ]line equ 0
sta: {0*SPRITE_PLANE_SPAN}+0,x lup 8
sta: {0*SPRITE_PLANE_SPAN}+2,x stz: {]line*SPRITE_PLANE_SPAN}+0,x
sta: {1*SPRITE_PLANE_SPAN}+0,x stz: {]line*SPRITE_PLANE_SPAN}+2,x
sta: {1*SPRITE_PLANE_SPAN}+2,x ]line equ ]line+1
sta: {2*SPRITE_PLANE_SPAN}+0,x --^
sta: {2*SPRITE_PLANE_SPAN}+2,x
sta: {3*SPRITE_PLANE_SPAN}+0,x
sta: {3*SPRITE_PLANE_SPAN}+2,x
sta: {4*SPRITE_PLANE_SPAN}+0,x
sta: {4*SPRITE_PLANE_SPAN}+2,x
sta: {5*SPRITE_PLANE_SPAN}+0,x
sta: {5*SPRITE_PLANE_SPAN}+2,x
sta: {6*SPRITE_PLANE_SPAN}+0,x
sta: {6*SPRITE_PLANE_SPAN}+2,x
sta: {7*SPRITE_PLANE_SPAN}+0,x
sta: {7*SPRITE_PLANE_SPAN}+2,x
plb ; pop the mask bank (high byte) plb ; pop the mask bank (high byte)
lda #$FFFF lda #$FFFF
sta: {0*SPRITE_PLANE_SPAN}+0,x ]line equ 0
sta: {0*SPRITE_PLANE_SPAN}+2,x lup 8
sta: {1*SPRITE_PLANE_SPAN}+0,x sta: {]line*SPRITE_PLANE_SPAN}+0,x
sta: {1*SPRITE_PLANE_SPAN}+2,x sta: {]line*SPRITE_PLANE_SPAN}+2,x
sta: {2*SPRITE_PLANE_SPAN}+0,x ]line equ ]line+1
sta: {2*SPRITE_PLANE_SPAN}+2,x --^
sta: {3*SPRITE_PLANE_SPAN}+0,x
sta: {3*SPRITE_PLANE_SPAN}+2,x plb
sta: {4*SPRITE_PLANE_SPAN}+0,x rts
sta: {4*SPRITE_PLANE_SPAN}+2,x
sta: {5*SPRITE_PLANE_SPAN}+0,x _EraseTileSprite8x16
sta: {5*SPRITE_PLANE_SPAN}+2,x phb ; Save the bank to switch to the sprite plane
sta: {6*SPRITE_PLANE_SPAN}+0,x
sta: {6*SPRITE_PLANE_SPAN}+2,x pei SpriteBanks
sta: {7*SPRITE_PLANE_SPAN}+0,x plb ; pop the data bank (low byte)
sta: {7*SPRITE_PLANE_SPAN}+2,x
]line equ 0
lup 16
stz: {]line*SPRITE_PLANE_SPAN}+0,x
stz: {]line*SPRITE_PLANE_SPAN}+2,x
]line equ ]line+1
--^
plb ; pop the mask bank (high byte)
lda #$FFFF
]line equ 0
lup 16
sta: {]line*SPRITE_PLANE_SPAN}+0,x
sta: {]line*SPRITE_PLANE_SPAN}+2,x
]line equ ]line+1
--^
plb
rts
_EraseTileSprite16x8
phb ; Save the bank to switch to the sprite plane
pei SpriteBanks
plb ; pop the data bank (low byte)
]line equ 0
lup 8
stz: {]line*SPRITE_PLANE_SPAN}+0,x
stz: {]line*SPRITE_PLANE_SPAN}+2,x
stz: {]line*SPRITE_PLANE_SPAN}+4,x
stz: {]line*SPRITE_PLANE_SPAN}+6,x
]line equ ]line+1
--^
plb ; pop the mask bank (high byte)
lda #$FFFF
]line equ 0
lup 8
sta: {]line*SPRITE_PLANE_SPAN}+0,x
sta: {]line*SPRITE_PLANE_SPAN}+2,x
sta: {]line*SPRITE_PLANE_SPAN}+4,x
sta: {]line*SPRITE_PLANE_SPAN}+6,x
]line equ ]line+1
--^
plb plb
rts rts
@ -820,21 +817,19 @@ _EraseTileSprite
_EraseTileSprite16x16 _EraseTileSprite16x16
phb ; Save the bank to switch to the sprite plane phb ; Save the bank to switch to the sprite plane
pea #^spritedata pei SpriteBanks
plb plb ; pop the data bank (low byte)
lda #0
]line equ 0 ]line equ 0
lup 16 lup 16
sta: {]line*SPRITE_PLANE_SPAN}+0,x stz: {]line*SPRITE_PLANE_SPAN}+0,x
sta: {]line*SPRITE_PLANE_SPAN}+2,x stz: {]line*SPRITE_PLANE_SPAN}+2,x
sta: {]line*SPRITE_PLANE_SPAN}+4,x stz: {]line*SPRITE_PLANE_SPAN}+4,x
sta: {]line*SPRITE_PLANE_SPAN}+6,x stz: {]line*SPRITE_PLANE_SPAN}+6,x
]line equ ]line+1 ]line equ ]line+1
--^ --^
pea #^spritemask plb ; pop the mask bank (high byte)
plb
lda #$FFFF lda #$FFFF
]line equ 0 ]line equ 0
@ -846,7 +841,6 @@ _EraseTileSprite16x16
]line equ ]line+1 ]line equ ]line+1
--^ --^
pla
plb plb
rts rts