mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-06-08 03:29:32 +00:00
Get tile data to display from code field
This commit is contained in:
parent
755ac3fbfd
commit
fd07ead8ed
|
@ -102,7 +102,7 @@ _ApplyTilesFast
|
||||||
lda DirtyTileCount ; Cache the dirty tile count
|
lda DirtyTileCount ; Cache the dirty tile count
|
||||||
sta DP2_DIRTY_TILE_COUNT
|
sta DP2_DIRTY_TILE_COUNT
|
||||||
|
|
||||||
jsr _PopDirtyTile2
|
jsr _PopDirtyTilesFast
|
||||||
|
|
||||||
stz DirtyTileCount
|
stz DirtyTileCount
|
||||||
|
|
||||||
|
|
36
src/Tiles.s
36
src/Tiles.s
|
@ -175,15 +175,15 @@ InitTiles
|
||||||
_SetTile
|
_SetTile
|
||||||
pha
|
pha
|
||||||
jsr _GetTileStoreOffset0 ; Get the address of the X,Y tile position
|
jsr _GetTileStoreOffset0 ; Get the address of the X,Y tile position
|
||||||
tax
|
tay
|
||||||
pla
|
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
|
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
|
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.
|
; 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
|
; functionality. Sometimes it is simple, but in cases of the sprites overlapping Dynamic Tiles and other cases
|
||||||
; it can be more involved.
|
; 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
|
and #TILE_VFLIP_BIT+TILE_HFLIP_BIT ; get the lookup value
|
||||||
xba
|
xba
|
||||||
tay
|
tax
|
||||||
; lda DirtyTileProcs,y
|
; ldal DirtyTileProcs,x
|
||||||
; stal TileStore+TS_DIRTY_TILE_DISP,x
|
; sta TileStore+TS_DIRTY_TILE_DISP,y
|
||||||
|
|
||||||
; lda CopyTileProcs,y
|
; ldal CopyTileProcs,x
|
||||||
; stal TileStore+TS_DIRTY_TILE_COPY,x
|
; sta TileStore+TS_DIRTY_TILE_COPY,y
|
||||||
|
|
||||||
lda EngineMode
|
lda EngineMode
|
||||||
bit #ENGINE_MODE_DYN_TILES+ENGINE_MODE_TWO_LAYER
|
bit #ENGINE_MODE_DYN_TILES+ENGINE_MODE_TWO_LAYER
|
||||||
beq :fast
|
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
|
and #TILE_CTRL_MASK
|
||||||
xba
|
xba
|
||||||
tay
|
tax
|
||||||
; lda TileProcs,y
|
; ldal TileProcs,x
|
||||||
; stal TileStore+TS_BASE_TILE_DISP,x
|
; sta TileStore+TS_BASE_TILE_DISP,y
|
||||||
bra :out
|
bra :out
|
||||||
|
|
||||||
:fast
|
:fast
|
||||||
lda FastTileProcs,y
|
ldal FastTileProcs,x
|
||||||
stal TileStore+TS_BASE_TILE_DISP,x
|
sta TileStore+TS_BASE_TILE_DISP,y
|
||||||
:out
|
:out
|
||||||
|
jmp _PushDirtyTileY ; on the next call to _ApplyTiles
|
||||||
txa ; Add this tile to the list of dirty tiles to refresh
|
|
||||||
jmp _PushDirtyTileX ; on the next call to _ApplyTiles
|
|
||||||
|
|
||||||
:nochange rts
|
:nochange rts
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ _BltRange
|
||||||
tsc ; save the stack pointer
|
tsc ; save the stack pointer
|
||||||
stal stk_save+1
|
stal stk_save+1
|
||||||
|
|
||||||
bra blt_return
|
|
||||||
blt_entry jml $000000 ; Jump into the blitter code $XX/YY00
|
blt_entry jml $000000 ; Jump into the blitter code $XX/YY00
|
||||||
|
|
||||||
blt_return _R0W0
|
blt_return _R0W0
|
||||||
|
|
|
@ -38,6 +38,24 @@ _PushDirtyTileX
|
||||||
txa ; Make sure TileStore offset is returned in the accumulator
|
txa ; Make sure TileStore offset is returned in the accumulator
|
||||||
rts
|
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
|
; 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,
|
; 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
|
; 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
|
; Bank = Tile Store
|
||||||
; D = Page 2
|
; D = Page 2
|
||||||
_PopDirtyTilesFast
|
_PopDirtyTilesFast
|
||||||
|
; brk $EE
|
||||||
ldx DP2_DIRTY_TILE_COUNT ; This is pre-multiplied by 2
|
ldx DP2_DIRTY_TILE_COUNT ; This is pre-multiplied by 2
|
||||||
bne pdtf_not_empty ; If there are no items, exit
|
bne pdtf_not_empty ; If there are no items, exit
|
||||||
at_exit rts
|
at_exit rts
|
||||||
|
|
|
@ -13,9 +13,11 @@ NoSpriteFast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
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
|
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
|
; The TS_BASE_TILE_DISP routines will come from this table when ENGINE_MODE_TWO_LAYER and
|
||||||
; ENGINE_MODE_DYN_TILES are both off.
|
; ENGINE_MODE_DYN_TILES are both off.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user