Simplify the handling of the dirty tiles to just store the dirty word and not keep the array of dirty tile offsets. Have the flea use game and non-game dirty tiles to fix the problem with LHS tiles being marked dirty all the time.

This commit is contained in:
Jeremy Rand 2020-09-04 01:55:38 -04:00
parent 22a22d3533
commit 92c02ded0f
6 changed files with 22 additions and 73 deletions

View File

@ -102,7 +102,6 @@ gameDone anop
drawDirtyGameTiles entry drawDirtyGameTiles entry
stz numDirtyGameTiles
_drawDirtyGameRow 0 _drawDirtyGameRow 0
_drawDirtyGameRow 1 _drawDirtyGameRow 1
_drawDirtyGameRow 2 _drawDirtyGameRow 2

View File

@ -25,22 +25,19 @@ FLEA_FAST_UPDATES_PER_TILE equ TILE_PIXEL_HEIGHT/4-1
drawFlea entry drawFlea entry
lda fleaState lda fleaState
beq drawFlea_done bne drawFlea_cont
rtl
drawFlea_cont anop
ldy fleaScreenOffset ldy fleaScreenOffset
ldx fleaSprite ldx fleaSprite
jsl fleaJump jsl fleaJump
ldy numDirtyGameTiles _dirtyGameOrNonGameTile fleaTileOffsets
_dirtyGameOrNonGameTile fleaTileOffsets+2
_dirtyGameOrNonGameTile fleaTileOffsets+4
_dirtyGameOrNonGameTile fleaTileOffsets+6
_dirtyGameTileWithY fleaTileOffsets
_dirtyGameTileWithY fleaTileOffsets+2
_dirtyGameTileWithY fleaTileOffsets+4
_dirtyGameTileWithY fleaTileOffsets+6
sty numDirtyGameTiles
drawFlea_done anop
rtl rtl

View File

@ -60,10 +60,10 @@ drawSegments_handleTiles anop
asl a asl a
tay tay
_dirtyGameTile segmentTileOffsets _dirtyGameTileWithY segmentTileOffsets
_dirtyGameTile segmentTileOffsets+2 _dirtyGameTileWithY segmentTileOffsets+2
_dirtyGameTile segmentTileOffsets+4 _dirtyGameTileWithY segmentTileOffsets+4
_dirtyGameTile segmentTileOffsets+6 _dirtyGameTileWithY segmentTileOffsets+6
plx plx
drawSegments_skipSegment anop drawSegments_skipSegment anop

View File

@ -9,7 +9,6 @@
macro macro
_drawDirtyGameRow &rowNum _drawDirtyGameRow &rowNum
trace on
short i,m short i,m
lda >BORDER_COLOUR_REGISTER lda >BORDER_COLOUR_REGISTER
and #$f0 and #$f0
@ -64,48 +63,16 @@ _drawDirtyGameRow_wait&rowNum anop
_drawDirtyGameRow_skip&tileOffset anop _drawDirtyGameRow_skip&tileOffset anop
&tileOffset seta &tileOffset+2 &tileOffset seta &tileOffset+2
aif &tileOffset<&lastTileOffset,.drawDirtyGameRowLoop aif &tileOffset<&lastTileOffset,.drawDirtyGameRowLoop
trace off
mend mend
; This macro uses the Y register as an index into the tile offsets. This is ; This macro uses the Y register as an index into the tile offsets. This is
; needed for segments because each segment has their own dirty tile offsets. ; needed for segments because each segment has their own dirty tile offsets.
macro
_dirtyGameTile &tileOffset
ldx &tileOffset,y
lda tileDirty,x
bne _dirtyGameTile_skip&SYSCNT
lda #TILE_STATE_DIRTY
sta tileDirty,x
txa
ldx numDirtyGameTiles
sta dirtyGameTiles,x
inx
inx
stx numDirtyGameTiles
_dirtyGameTile_skip&SYSCNT anop
mend
; Call this with Y already loaded with the numDirtyGameTiles. Also, the new
; numDirtyGameTiles is left in Y. The caller must store it.
macro macro
_dirtyGameTileWithY &tileOffset _dirtyGameTileWithY &tileOffset
ldx &tileOffset,y
ldx &tileOffset
lda tileDirty,x
bne _dirtyGameTileWithY_skip&SYSCNT
lda #TILE_STATE_DIRTY lda #TILE_STATE_DIRTY
sta tileDirty,x sta tileDirty,x
txa
sta dirtyGameTiles,y
iny
iny
_dirtyGameTileWithY_skip&SYSCNT anop
mend mend
@ -113,23 +80,20 @@ _dirtyGameTileWithY_skip&SYSCNT anop
_dirtyGameOrNonGameTile &tileOffset _dirtyGameOrNonGameTile &tileOffset
ldx &tileOffset ldx &tileOffset
cpx #RHS_FIRST_TILE_OFFSET
bge _dirtyGameTile_nonGame&SYSCNT
lda #TILE_STATE_DIRTY
sta tileDirty,x
bra _dirtyGameTile_skip&SYSCNT
_dirtyGameTile_nonGame&SYSCNT anop
lda tileDirty,x lda tileDirty,x
bne _dirtyGameTile_skip&SYSCNT bne _dirtyGameTile_skip&SYSCNT
lda #TILE_STATE_DIRTY lda #TILE_STATE_DIRTY
sta tileDirty,x sta tileDirty,x
txa
cmp #RHS_FIRST_TILE_OFFSET
bge _dirtyGameTile_nonGame&SYSCNT
ldy numDirtyGameTiles
sta dirtyGameTiles,y
iny
iny
sty numDirtyGameTiles
bra _dirtyGameTile_skip&SYSCNT
_dirtyGameTile_nonGame&SYSCNT anop
ldy numDirtyNonGameTiles ldy numDirtyNonGameTiles
txa
sta dirtyNonGameTiles,y sta dirtyNonGameTiles,y
iny iny
iny iny

View File

@ -37,12 +37,7 @@
#define STARTING_NUM_MUSHROOMS 30 #define STARTING_NUM_MUSHROOMS 30
#define STARTING_NUM_PLAYERS 3 #define STARTING_NUM_PLAYERS 3
#define ADD_DIRTY_GAME_TILE(tileNum) \ #define ADD_DIRTY_GAME_TILE(tileNum) tileDirty[tileNum] = 1;
if (!tileDirty[tileNum]) { \
tileDirty[tileNum] = 1; \
dirtyGameTiles[numDirtyGameTiles / 2] = ((tileNum) * sizeof(word)); \
numDirtyGameTiles += 2; \
}
#define ADD_DIRTY_NON_GAME_TILE(tileNum) \ #define ADD_DIRTY_NON_GAME_TILE(tileNum) \
if (!tileDirty[tileNum]) { \ if (!tileDirty[tileNum]) { \
@ -61,9 +56,6 @@ tTileOffset tileBelow[TOTAL_NUM_TILES];
tTileOffset tileLeft[TOTAL_NUM_TILES]; tTileOffset tileLeft[TOTAL_NUM_TILES];
tTileOffset tileRight[TOTAL_NUM_TILES]; tTileOffset tileRight[TOTAL_NUM_TILES];
tTileOffset dirtyGameTiles[NUM_GAME_TILES + GAME_NUM_TILES_TALL];
word numDirtyGameTiles;
tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES]; tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
word numDirtyNonGameTiles; word numDirtyNonGameTiles;
@ -179,7 +171,6 @@ void initTiles(void)
} }
} }
numDirtyGameTiles = 0;
numDirtyNonGameTiles = 0; numDirtyNonGameTiles = 0;
} }

View File

@ -113,8 +113,6 @@ extern tTileOffset tileBelow[TOTAL_NUM_TILES];
extern tTileOffset tileLeft[TOTAL_NUM_TILES]; extern tTileOffset tileLeft[TOTAL_NUM_TILES];
extern tTileOffset tileRight[TOTAL_NUM_TILES]; extern tTileOffset tileRight[TOTAL_NUM_TILES];
extern tTileOffset dirtyGameTiles[NUM_GAME_TILES + GAME_NUM_TILES_TALL];
extern word numDirtyGameTiles;
extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES]; extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
extern word numDirtyNonGameTiles; extern word numDirtyNonGameTiles;