Clear sprite flag when erasing sprite

This commit is contained in:
Lucas Scharenbroich 2021-11-11 22:22:10 -06:00
parent dec9a3d106
commit 673b97419a

View File

@ -80,46 +80,75 @@ _RenderSprites
txy ; switch to the Y register txy ; switch to the Y register
; Run through the list of tile store offsets that this sprite was last drawn into and mark ; Run through the list of tile store offsets that this sprite was last drawn into and mark
; those tiles as dirty. The largest number tiles that a sprite could possibly cover is 20 ; those tiles as dirty. The largest number of tiles that a sprite could possibly cover is 20
; (an unaligned 4x3 sprite), covering a 5x4 area of play field tiles. ; (an unaligned 4x3 sprite), covering a 5x4 area of play field tiles.
; ;
; For now, we limit ourselves to 4 tiles until things are working.... ; For now, we limit ourselves to 4 tiles until things are working....
;
; There is only one sprite, so clear the TS_SPRITE_FLAG field, too
lda _Sprites+TILE_STORE_ADDR_1,y ldx _Sprites+TILE_STORE_ADDR_1,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_2,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_2,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_3,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_3,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_4,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_4,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_5,y stz TileStore+TS_SPRITE_FLAG,x
jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_5,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_6,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_6,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_7,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_7,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_8,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_8,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
lda _Sprites+TILE_STORE_ADDR_9,y jsr _PushDirtyTileX
ldx _Sprites+TILE_STORE_ADDR_9,y
beq :erase_done beq :erase_done
jsr _PushDirtyTile stz TileStore+TS_SPRITE_FLAG,x
jsr _PushDirtyTileX
:erase_done :erase_done
; Really, we should only be erasing and redrawing a sprite if its local coordinates change. Look into this ; Really, we should only be erasing and redrawing a sprite if its local coordinates change. Look into this
; as a future optimization. Ideally, all of the sprites will be rendered into the sprite plane in a separate ; as a future optimization. Ideally, all of the sprites will be rendered into the sprite plane in a separate
; pass from this function, which is primarily concerned with flagging dirty tiles in the Tile Store. ; pass from this function, which is primarily concerned with flagging dirty tiles in the Tile Store.
ldx _Sprites+OLD_VBUFF_ADDR,y ldx _Sprites+OLD_VBUFF_ADDR,y
; jsr _EraseTileSprite ; erase from the old position beq :noerase
jsr _EraseTileSprite ; erase from the old position
inx
inx
inx
inx
jsr _EraseTileSprite
txa
clc
adc #8*256
tax
jsr _EraseTileSprite
dex
dex
dex
dex
jsr _EraseTileSprite
:noerase
; Draw the sprite into the sprint plane buffer(s) ; Draw the sprite into the sprint plane buffer(s)