2022-06-20 20:55:09 +00:00
|
|
|
; Specialized routines that can be assigned to K_TS_ONE_SPRITE for rendering a single sprite into
|
|
|
|
; a tile. There are more variants of this function because having a single sprite in a tile is a very
|
|
|
|
; common scenario, so we put additional effort into optimizing this case.
|
|
|
|
|
|
|
|
;------------------------------
|
|
|
|
; Section: Above Tile Renderers
|
|
|
|
|
|
|
|
; The simplest implementation. When drawing a sprite over Tile 0 in FAST mode, we can just copy the
|
|
|
|
; sprite data into the coe field directly.
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteFastOver0
|
2022-06-20 20:55:09 +00:00
|
|
|
ldy TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
|
|
|
phy ; 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
|
|
|
|
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
|
|
|
plb ; set to the code field bank
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
_OneSpriteFastOver0
|
2022-06-20 20:55:09 +00:00
|
|
|
]line equ 0
|
|
|
|
lup 8
|
|
|
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
|
|
|
sta: $0004+{]line*$1000},y
|
|
|
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
|
|
|
sta: $0001+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
|
|
|
|
plb ; Restore the TileStore bank
|
|
|
|
rts
|
|
|
|
|
2022-06-21 16:23:06 +00:00
|
|
|
; Next implementation; drawing a sprite onto a regular tile. The 1-sprite dispatch preerves the
|
|
|
|
; X-register, so it already points to the TileStore
|
2022-06-20 20:55:09 +00:00
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteFastOverV
|
2022-06-21 12:29:18 +00:00
|
|
|
jsr FastCopyTileDataV
|
2022-06-20 20:55:09 +00:00
|
|
|
bra _OneSpriteFastOver
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteFastOverA
|
2022-06-21 12:29:18 +00:00
|
|
|
jsr FastCopyTileDataA
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
_OneSpriteFastOver
|
|
|
|
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
|
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
_OneSpriteFastOverA
|
|
|
|
_OneSpriteFastOverV
|
2022-06-20 20:55:09 +00:00
|
|
|
]line equ 0
|
|
|
|
lup 8
|
|
|
|
lda tmp_tile_data+{]line*4}
|
|
|
|
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
|
|
|
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
|
|
|
sta: $0004+{]line*$1000},y
|
|
|
|
|
|
|
|
lda tmp_tile_data+{]line*4}+2
|
|
|
|
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
|
|
|
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
|
|
|
sta: $0001+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
plb
|
|
|
|
rts
|
|
|
|
|
|
|
|
; This is the "SLOW" variant that fills in the PEA opcode specialized for Tile 0.
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteSlowOver0
|
2022-06-20 20:55:09 +00:00
|
|
|
ldy TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
|
|
|
phy ; 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
|
|
|
|
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
|
|
|
plb ; set to the code field bank
|
2022-06-21 18:33:17 +00:00
|
|
|
jsr FillPEAOpcode
|
|
|
|
jmp _OneSpriteFastOver0
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
; Slow variant for regular tile.
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteSlowOverV
|
|
|
|
jsr FastCopyTileDataV
|
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
|
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
2022-06-21 18:33:17 +00:00
|
|
|
jsr FillPEAOpcode
|
|
|
|
jmp _OneSpriteFastOverV
|
2022-06-20 20:55:09 +00:00
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteSlowOverA
|
|
|
|
jsr FastCopyTileDataA
|
|
|
|
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
|
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
|
|
|
jsr FillPEAOpcode
|
|
|
|
jmp _OneSpriteFastOverA
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
;------------------------------
|
|
|
|
; Section: Below Tile Renderers
|
|
|
|
|
|
|
|
; Drawing under the zero tile is the same as not drawing a sprite fo both the fast and slow cases
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteFastUnderA
|
2022-06-21 15:06:17 +00:00
|
|
|
jsr FastCopyTileDataAndMaskA
|
2022-06-20 20:55:09 +00:00
|
|
|
bra _OneSpriteFastUnder
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteFastUnderV
|
2022-06-21 15:06:17 +00:00
|
|
|
jsr FastCopyTileDataAndMaskV
|
2022-06-20 20:55:09 +00:00
|
|
|
|
|
|
|
_OneSpriteFastUnder
|
|
|
|
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
|
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
_OneSpriteFastUnderA
|
|
|
|
_OneSpriteFastUnderV
|
2022-06-20 20:55:09 +00:00
|
|
|
]line equ 0
|
|
|
|
lup 8
|
|
|
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
2022-06-21 15:06:17 +00:00
|
|
|
and tmp_tile_mask+{]line*4}
|
2022-06-20 20:55:09 +00:00
|
|
|
ora tmp_tile_data+{]line*4}
|
|
|
|
sta: $0004+{]line*$1000},y
|
|
|
|
|
|
|
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
2022-06-21 15:06:17 +00:00
|
|
|
and tmp_tile_mask+{]line*4}+2
|
2022-06-20 20:55:09 +00:00
|
|
|
ora tmp_tile_data+{]line*4}+2
|
|
|
|
sta: $0001+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
|
|
|
|
plb
|
|
|
|
rts
|
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteSlowUnderA
|
|
|
|
jsr FastCopyTileDataAndMaskA
|
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
|
2022-06-21 18:33:17 +00:00
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
|
|
|
jsr FillPEAOpcode
|
|
|
|
jmp _OneSpriteFastUnderA
|
2022-06-20 20:55:09 +00:00
|
|
|
|
2022-06-21 18:33:17 +00:00
|
|
|
OneSpriteSlowUnderV
|
|
|
|
jsr FastCopyTileDataAndMaskV
|
|
|
|
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
|
|
|
|
ldx sprite_ptr0
|
|
|
|
plb
|
|
|
|
jsr FillPEAOpcode
|
|
|
|
jmp _OneSpriteFastUnderV
|