2022-06-20 20:55:09 +00:00
|
|
|
; If there are no sprites, then we copy the tile data into the code field as fast as possible.
|
|
|
|
; If there are sprites, then additional work is required
|
|
|
|
_RenderTile
|
2022-07-05 04:55:32 +00:00
|
|
|
lda TileStore+TS_SPRITE_FLAG,x ; any sprites on this tile?
|
|
|
|
bne _HasSprites
|
2022-06-20 20:55:09 +00:00
|
|
|
|
2023-03-14 14:11:53 +00:00
|
|
|
; Probably best to rework this to just jump to the tile routine directly, event if there
|
|
|
|
; is some boilerplate code because it is useful to be able to access the data bank before
|
|
|
|
; switching to the code field bank.
|
|
|
|
|
2022-06-20 20:55:09 +00:00
|
|
|
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)
|
|
|
|
plb ; set the code field bank
|
|
|
|
jmp (K_TS_BASE_TILE_DISP,x) ; go to the tile copy routine
|
|
|
|
|
2023-03-14 14:11:53 +00:00
|
|
|
; This is the specialized renderer for the dirty tile rendering mode. The difference is that
|
2022-07-05 04:55:32 +00:00
|
|
|
; it is assumed that the screen is static and the tiles are aligned with the graphics screen.
|
|
|
|
; The engine must be in "Fast" tile mode for dirty tile rendering to work. It is possible
|
|
|
|
; to switch the engine into this mode by rendering a full screen of solid tiles and then
|
|
|
|
; doing a dirty tile rendering.
|
|
|
|
;
|
|
|
|
; The main result is that this renderer skips copying tile data into the play field and
|
2023-03-14 14:11:53 +00:00
|
|
|
; just draws to the screen directly, and only draws tiles in the dirty tile queue
|
2022-07-05 04:55:32 +00:00
|
|
|
_RenderDirtyTile
|
|
|
|
lda TileStore+TS_SPRITE_FLAG,x ; any sprites on this tile?
|
|
|
|
bne _HasSprites
|
|
|
|
jmp (K_TS_BASE_TILE_DISP,x) ; This is just to select between H/V flips
|
|
|
|
|
2022-06-20 20:55:09 +00:00
|
|
|
; Execute the sprite tree. If there is only one sprite, control will immediately be passed to
|
2023-03-14 14:11:53 +00:00
|
|
|
; the routine at K_TS_ONE_SPRITE. Otherwise, the control is passed to a routine based on the
|
|
|
|
; different number of sprites. These routines need to copy the flattened sprite data and mask
|
|
|
|
; into the direct page workspace to be used by the K_TS_SPRITE_TILE_DISP routine
|
2022-07-05 04:55:32 +00:00
|
|
|
_HasSprites txy
|
2022-06-20 20:55:09 +00:00
|
|
|
SpriteBitsToVBuffAddrs $0000;TwoSprites;ThreeSprites;FourSprites
|
|
|
|
|
|
|
|
; Dispatch vectors for the two, three and four sprite functions. These just
|
|
|
|
; flatten the sprite data into the direct page workspace and then pass control
|
|
|
|
; to the configurable routine which is set in SetTile and knows what to do
|
|
|
|
; based on the tile properties (over/under, engine mode, etc.)
|
2022-06-21 16:23:06 +00:00
|
|
|
;
|
2023-03-14 14:11:53 +00:00
|
|
|
; NOTE: Could pull the CopyXXXSprites function inline and save the 3 cycles for the JMP,
|
2022-06-21 16:23:06 +00:00
|
|
|
; - or - put the TYX into the macro and jump directly from there.
|
2022-06-20 20:55:09 +00:00
|
|
|
TwoSprites tyx
|
2022-06-21 16:23:06 +00:00
|
|
|
jmp CopyTwoSpritesDataAndMaskToDP
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
ThreeSprites tyx
|
2022-06-21 16:23:06 +00:00
|
|
|
jmp CopyThreeSpritesDataAndMaskToDP
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
FourSprites tyx
|
2022-06-21 16:23:06 +00:00
|
|
|
jmp CopyFourSpritesDataAndMaskToDP
|