Get tile data to display from code field

This commit is contained in:
Lucas Scharenbroich 2022-05-18 21:39:39 -05:00
parent 755ac3fbfd
commit fd07ead8ed
5 changed files with 41 additions and 23 deletions

View File

@ -102,7 +102,7 @@ _ApplyTilesFast
lda DirtyTileCount ; Cache the dirty tile count
sta DP2_DIRTY_TILE_COUNT
jsr _PopDirtyTile2
jsr _PopDirtyTilesFast
stz DirtyTileCount

View File

@ -175,15 +175,15 @@ InitTiles
_SetTile
pha
jsr _GetTileStoreOffset0 ; Get the address of the X,Y tile position
tax
tay
pla
cmpl TileStore+TS_TILE_ID,x ; Only set to dirty if the value changed
cmp TileStore+TS_TILE_ID,y ; Only set to dirty if the value changed
beq :nochange
stal TileStore+TS_TILE_ID,x ; Value is different, store it.
sta TileStore+TS_TILE_ID,y ; Value is different, store it.
jsr _GetTileAddr
stal TileStore+TS_TILE_ADDR,x ; Committed to drawing this tile, so get the address of the tile in the tiledata bank for later
sta TileStore+TS_TILE_ADDR,y ; Committed to drawing this tile, so get the address of the tile in the tiledata bank for later
; Set the standard renderer procs for this tile.
;
@ -196,35 +196,33 @@ _SetTile
; functionality. Sometimes it is simple, but in cases of the sprites overlapping Dynamic Tiles and other cases
; it can be more involved.
ldal TileStore+TS_TILE_ID,x
lda TileStore+TS_TILE_ID,y
and #TILE_VFLIP_BIT+TILE_HFLIP_BIT ; get the lookup value
xba
tay
; lda DirtyTileProcs,y
; stal TileStore+TS_DIRTY_TILE_DISP,x
tax
; ldal DirtyTileProcs,x
; sta TileStore+TS_DIRTY_TILE_DISP,y
; lda CopyTileProcs,y
; stal TileStore+TS_DIRTY_TILE_COPY,x
; ldal CopyTileProcs,x
; sta TileStore+TS_DIRTY_TILE_COPY,y
lda EngineMode
bit #ENGINE_MODE_DYN_TILES+ENGINE_MODE_TWO_LAYER
beq :fast
ldal TileStore+TS_TILE_ID,x ; Get the non-sprite dispatch address
lda TileStore+TS_TILE_ID,y ; Get the non-sprite dispatch address
and #TILE_CTRL_MASK
xba
tay
; lda TileProcs,y
; stal TileStore+TS_BASE_TILE_DISP,x
tax
; ldal TileProcs,x
; sta TileStore+TS_BASE_TILE_DISP,y
bra :out
:fast
lda FastTileProcs,y
stal TileStore+TS_BASE_TILE_DISP,x
ldal FastTileProcs,x
sta TileStore+TS_BASE_TILE_DISP,y
:out
txa ; Add this tile to the list of dirty tiles to refresh
jmp _PushDirtyTileX ; on the next call to _ApplyTiles
jmp _PushDirtyTileY ; on the next call to _ApplyTiles
:nochange rts

View File

@ -74,7 +74,6 @@ _BltRange
tsc ; save the stack pointer
stal stk_save+1
bra blt_return
blt_entry jml $000000 ; Jump into the blitter code $XX/YY00
blt_return _R0W0

View File

@ -38,6 +38,24 @@ _PushDirtyTileX
txa ; Make sure TileStore offset is returned in the accumulator
rts
; alternate entry point if the Y-register is already set
_PushDirtyTileY
lda TileStore+TS_DIRTY,y
bne :occupied2
inc ; any non-zero value will work
sta TileStore+TS_DIRTY,y ; and is 1 cycle faster than loading a constant value
tya
ldy DirtyTileCount ; 4
sta DirtyTiles,y ; 6
iny ; 2
iny ; 2
sty DirtyTileCount ; 4 = 18
rts
:occupied2
tya ; Make sure TileStore offset is returned in the accumulator
rts
; Remove a dirty tile from the list and return it in state ready to be rendered. It is important
; that the core rendering functions *only* use _PopDirtyTile to get a list of tiles to update,
; because this routine merges the tile IDs stored in the Tile Store with the Sprite
@ -68,6 +86,7 @@ _PopDirtyTile2 ; alternate entry point
; Bank = Tile Store
; D = Page 2
_PopDirtyTilesFast
; brk $EE
ldx DP2_DIRTY_TILE_COUNT ; This is pre-multiplied by 2
bne pdtf_not_empty ; If there are no items, exit
at_exit rts

View File

@ -13,9 +13,11 @@ NoSpriteFast
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
pha ; and put on the stack for later. Has TileStore bank in high byte.
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
lda TileStore+TS_TILE_ADDR,x ; load the address of this tile's data (pre-calculated)
lda TileStore+TS_TILE_ADDR,x ; load the address of this tile's data (pre-calculated)
lda TileStore+TS_BASE_TILE_DISP,x ; go to the tile copy routine (just basics)
stal nsf_patch+1
plb ; set the code field bank
jmp (TileStore+TS_BASE_TILE_DISP,x) ; go to the tile copy routine (just basics)
nsf_patch jmp $0000
; The TS_BASE_TILE_DISP routines will come from this table when ENGINE_MODE_TWO_LAYER and
; ENGINE_MODE_DYN_TILES are both off.