Simplify all of the remaining tile blitters

This commit is contained in:
Lucas Scharenbroich 2021-11-20 13:58:24 -06:00
parent cd5de05d74
commit 76801c0e5e
4 changed files with 96 additions and 104 deletions

View File

@ -5,40 +5,26 @@
; there is no way to do everything inline, so a composite tile is created on the fly and written to ; there is no way to do everything inline, so a composite tile is created on the fly and written to
; a direct page buffer. This direct page buffer is then used to render the tile. ; a direct page buffer. This direct page buffer is then used to render the tile.
_TBSolidSpriteTile_00 _TBSolidSpriteTile_00
_TBSolidSpriteTile_0H
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer (using correct x-register) jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer (using correct x-register)
jsr _TBApplySpriteData ; Overlay the data from the sprite plane (and copy into the code field) jsr _TBApplySpriteData ; Overlay the data from the sprite plane (and copy into the code field)
jmp _TBFillPEAOpcode ; Fill in the code field opcodes jmp _TBFillPEAOpcode ; Fill in the code field opcodes
_TBSolidSpriteTile_0H
jsr _TBCopyTileDataToCBuffH
jsr _TBApplySpriteData
jmp _TBFillPEAOpcode
_TBSolidSpriteTile_V0 _TBSolidSpriteTile_V0
jsr _TBCopyTileDataToCBuffV
jsr _TBApplySpriteData
jmp _TBFillPEAOpcode
_TBSolidSpriteTile_VH _TBSolidSpriteTile_VH
jsr _TBCopyTileDataToCBuffVH jsr _TBCopyTileDataToCBuffV
jsr _TBApplySpriteData jsr _TBApplySpriteData
jmp _TBFillPEAOpcode jmp _TBFillPEAOpcode
; Fast variation that does not need to set the opcode ; Fast variation that does not need to set the opcode
_TBFastSpriteTile_00 _TBFastSpriteTile_00
_TBFastSpriteTile_0H
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer
jmp _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field) jmp _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field)
_TBFastSpriteTile_0H
jsr _TBCopyTileDataToCBuffH
jmp _TBApplySpriteData
_TBFastSpriteTile_V0 _TBFastSpriteTile_V0
jsr _TBCopyTileDataToCBuffV
jmp _TBApplySpriteData
_TBFastSpriteTile_VH _TBFastSpriteTile_VH
jsr _TBCopyTileDataToCBuffVH jsr _TBCopyTileDataToCBuffV
jmp _TBApplySpriteData jmp _TBApplySpriteData
; Need to update the X-register before calling this ; Need to update the X-register before calling this
@ -78,17 +64,17 @@ _TBCopyTileDataToCBuff
--^ --^
rts rts
_TBCopyTileDataToCBuffH ;_TBCopyTileDataToCBuffH
]line equ 0 ;]line equ 0
lup 8 ; lup 8
ldal tiledata+{]line*4}+64,x ; ldal tiledata+{]line*4}+64,x
sta blttmp+{]line*4} ; sta blttmp+{]line*4}
;
ldal tiledata+{]line*4}+64+2,x ; ldal tiledata+{]line*4}+64+2,x
sta blttmp+{]line*4}+2 ; sta blttmp+{]line*4}+2
]line equ ]line+1 ;]line equ ]line+1
--^ ; --^
rts ; rts
_TBCopyTileDataToCBuffV _TBCopyTileDataToCBuffV
]src equ 7 ]src equ 7
@ -104,19 +90,19 @@ _TBCopyTileDataToCBuffV
--^ --^
rts rts
_TBCopyTileDataToCBuffVH ;_TBCopyTileDataToCBuffVH
]src equ 7 ;]src equ 7
]dest equ 0 ;]dest equ 0
lup 8 ; lup 8
ldal tiledata+{]src*4}+64,x ; ldal tiledata+{]src*4}+64,x
sta blttmp+{]dest*4} ; sta blttmp+{]dest*4}
;
ldal tiledata+{]src*4}+64+2,x ; ldal tiledata+{]src*4}+64+2,x
sta blttmp+{]dest*4}+2 ; sta blttmp+{]dest*4}+2
]src equ ]src-1 ;]src equ ]src-1
]dest equ ]dest+1 ;]dest equ ]dest+1
--^ ; --^
rts ; rts
; Copy tile mask data into the direct page compositing buffer. ; Copy tile mask data into the direct page compositing buffer.
@ -132,17 +118,17 @@ _TBCopyTileMaskToCBuff
--^ --^
rts rts
_TBCopyTileMaskToCBuffH ;_TBCopyTileMaskToCBuffH
]line equ 0 ;]line equ 0
lup 8 ; lup 8
ldal tiledata+{]line*4}+32+64,x ; ldal tiledata+{]line*4}+32+64,x
sta blttmp+{]line*4}+32 ; sta blttmp+{]line*4}+32
;
ldal tiledata+{]line*4}+32+64+2,x ; ldal tiledata+{]line*4}+32+64+2,x
sta blttmp+{]line*4}+32+2 ; sta blttmp+{]line*4}+32+2
]line equ ]line+1 ;]line equ ]line+1
--^ ; --^
rts ; rts
_TBCopyTileMaskToCBuffV _TBCopyTileMaskToCBuffV
]src equ 7 ]src equ 7
@ -158,19 +144,19 @@ _TBCopyTileMaskToCBuffV
--^ --^
rts rts
_TBCopyTileMaskToCBuffVH ;_TBCopyTileMaskToCBuffVH
]src equ 7 ;]src equ 7
]dest equ 0 ;]dest equ 0
lup 8 ; lup 8
ldal tiledata+{]src*4}+32+64,x ; ldal tiledata+{]src*4}+32+64,x
sta blttmp+{]dest*4}+32 ; sta blttmp+{]dest*4}+32
;
ldal tiledata+{]src*4}+32+64+2,x ; ldal tiledata+{]src*4}+32+64+2,x
sta blttmp+{]dest*4}+32+2 ; sta blttmp+{]dest*4}+32+2
]src equ ]src-1 ;]src equ ]src-1
]dest equ ]dest+1 ;]dest equ ]dest+1
--^ ; --^
rts ; rts
; Copy just the data into the code field from the composite buffer ; Copy just the data into the code field from the composite buffer

View File

@ -2,6 +2,7 @@
; ;
; Renders a composited tile with masking to the code field. ; Renders a composited tile with masking to the code field.
_TBMaskedSpriteTile_00 _TBMaskedSpriteTile_00
_TBMaskedSpriteTile_0H
sta _X_REG ; Immedately stash the parameters sta _X_REG ; Immedately stash the parameters
sty _Y_REG sty _Y_REG
@ -10,15 +11,16 @@ _TBMaskedSpriteTile_00
jsr _TBMergeSpriteDataAndMask ; Overlay the data and mask from the sprite plane into the compositing buffer jsr _TBMergeSpriteDataAndMask ; Overlay the data and mask from the sprite plane into the compositing buffer
jmp _TBMaskedCBuff ; Render the masked tile from the compositing buffer into the code field jmp _TBMaskedCBuff ; Render the masked tile from the compositing buffer into the code field
_TBMaskedSpriteTile_0H ;_TBMaskedSpriteTile_0H
sta _X_REG ; sta _X_REG
sty _Y_REG ; sty _Y_REG
jsr _TBCopyTileDataToCBuffH ; jsr _TBCopyTileDataToCBuffH
jsr _TBCopyTileMaskToCBuffH ; jsr _TBCopyTileMaskToCBuffH
jsr _TBMergeSpriteDataAndMask ; jsr _TBMergeSpriteDataAndMask
jmp _TBMaskedCBuff ; jmp _TBMaskedCBuff
_TBMaskedSpriteTile_V0 _TBMaskedSpriteTile_V0
_TBMaskedSpriteTile_VH
sta _X_REG sta _X_REG
sty _Y_REG sty _Y_REG
jsr _TBCopyTileDataToCBuffV jsr _TBCopyTileDataToCBuffV
@ -26,13 +28,13 @@ _TBMaskedSpriteTile_V0
jsr _TBMergeSpriteDataAndMask jsr _TBMergeSpriteDataAndMask
jmp _TBMaskedCBuff jmp _TBMaskedCBuff
_TBMaskedSpriteTile_VH ;_TBMaskedSpriteTile_VH
sta _X_REG ; sta _X_REG
sty _Y_REG ; sty _Y_REG
jsr _TBCopyTileDataToCBuffVH ; jsr _TBCopyTileDataToCBuffVH
jsr _TBCopyTileMaskToCBuffVH ; jsr _TBCopyTileMaskToCBuffVH
jsr _TBMergeSpriteDataAndMask ; jsr _TBMergeSpriteDataAndMask
jmp _TBMaskedCBuff ; jmp _TBMaskedCBuff
_TBMergeSpriteDataAndMask _TBMergeSpriteDataAndMask
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane

View File

@ -3,28 +3,30 @@
; When the sprite is composited with the tile data, the tile mask is used to place the tile data on top of ; When the sprite is composited with the tile data, the tile mask is used to place the tile data on top of
; any sprite data ; any sprite data
_TBSolidPrioritySpriteTile_00 _TBSolidPrioritySpriteTile_00
_TBSolidPrioritySpriteTile_0H
jsr _TBCopyTileDataToCBuff ; Copy the tile data into the compositing buffer (using correct x-register) jsr _TBCopyTileDataToCBuff ; Copy the tile data into the compositing buffer (using correct x-register)
jsr _TBCopyTileMaskToCBuff ; Copy the tile mask into the compositing buffer (using correct x-register) jsr _TBCopyTileMaskToCBuff ; Copy the tile mask into the compositing buffer (using correct x-register)
jsr _TBApplyPrioritySpriteData ; Underlay the data fromthe sprite plane (and copy into the code field) jsr _TBApplyPrioritySpriteData ; Underlay the data fromthe sprite plane (and copy into the code field)
jmp _TBFillPEAOpcode ; Fill in the code field opcodes jmp _TBFillPEAOpcode ; Fill in the code field opcodes
_TBSolidPrioritySpriteTile_0H ;_TBSolidPrioritySpriteTile_0H
jsr _TBCopyTileDataToCBuffH ; jsr _TBCopyTileDataToCBuffH
jsr _TBCopyTileMaskToCBuffH ; jsr _TBCopyTileMaskToCBuffH
jsr _TBApplyPrioritySpriteData ; jsr _TBApplyPrioritySpriteData
jmp _TBFillPEAOpcode ; jmp _TBFillPEAOpcode
_TBSolidPrioritySpriteTile_V0 _TBSolidPrioritySpriteTile_V0
_TBSolidPrioritySpriteTile_VH
jsr _TBCopyTileDataToCBuffV jsr _TBCopyTileDataToCBuffV
jsr _TBCopyTileMaskToCBuffV jsr _TBCopyTileMaskToCBuffV
jsr _TBApplyPrioritySpriteData jsr _TBApplyPrioritySpriteData
jmp _TBFillPEAOpcode jmp _TBFillPEAOpcode
_TBSolidPrioritySpriteTile_VH ;_TBSolidPrioritySpriteTile_VH
jsr _TBCopyTileDataToCBuffVH ; jsr _TBCopyTileDataToCBuffVH
jsr _TBCopyTileMaskToCBuffVH ; jsr _TBCopyTileMaskToCBuffVH
jsr _TBApplyPrioritySpriteData ; jsr _TBApplyPrioritySpriteData
jmp _TBFillPEAOpcode ; jmp _TBFillPEAOpcode
; Need to update the X-register before calling this ; Need to update the X-register before calling this
_TBApplyPrioritySpriteData _TBApplyPrioritySpriteData

View File

@ -2,6 +2,7 @@
; ;
; Renders a composited tile with masking to the code field. The sprite is underlaid ; Renders a composited tile with masking to the code field. The sprite is underlaid
_TBMaskedPrioritySpriteTile_00 _TBMaskedPrioritySpriteTile_00
_TBMaskedPrioritySpriteTile_0H
sta _X_REG ; Immedately stash the parameters sta _X_REG ; Immedately stash the parameters
sty _Y_REG sty _Y_REG
@ -10,15 +11,16 @@ _TBMaskedPrioritySpriteTile_00
jsr _TBUnderlaySpriteDataAndMask ; Underlay the data and mask from the sprite plane into the compositing buffer jsr _TBUnderlaySpriteDataAndMask ; Underlay the data and mask from the sprite plane into the compositing buffer
jmp _TBMaskedCBuff ; Render the masked tile from the compositing buffer into the code field jmp _TBMaskedCBuff ; Render the masked tile from the compositing buffer into the code field
_TBMaskedPrioritySpriteTile_0H ;_TBMaskedPrioritySpriteTile_0H
sta _X_REG ; sta _X_REG
sty _Y_REG ; sty _Y_REG
jsr _TBCopyTileDataToCBuffH ; jsr _TBCopyTileDataToCBuffH
jsr _TBCopyTileMaskToCBuffH ; jsr _TBCopyTileMaskToCBuffH
jsr _TBUnderlaySpriteDataAndMask ; jsr _TBUnderlaySpriteDataAndMask
jmp _TBMaskedCBuff ; jmp _TBMaskedCBuff
_TBMaskedPrioritySpriteTile_V0 _TBMaskedPrioritySpriteTile_V0
_TBMaskedPrioritySpriteTile_VH
sta _X_REG sta _X_REG
sty _Y_REG sty _Y_REG
jsr _TBCopyTileDataToCBuffV jsr _TBCopyTileDataToCBuffV
@ -26,13 +28,13 @@ _TBMaskedPrioritySpriteTile_V0
jsr _TBUnderlaySpriteDataAndMask jsr _TBUnderlaySpriteDataAndMask
jmp _TBMaskedCBuff jmp _TBMaskedCBuff
_TBMaskedPrioritySpriteTile_VH ;_TBMaskedPrioritySpriteTile_VH
sta _X_REG ; sta _X_REG
sty _Y_REG ; sty _Y_REG
jsr _TBCopyTileDataToCBuffVH ; jsr _TBCopyTileDataToCBuffVH
jsr _TBCopyTileMaskToCBuffVH ; jsr _TBCopyTileMaskToCBuffVH
jsr _TBUnderlaySpriteDataAndMask ; jsr _TBUnderlaySpriteDataAndMask
jmp _TBMaskedCBuff ; jmp _TBMaskedCBuff
_TBUnderlaySpriteDataAndMask _TBUnderlaySpriteDataAndMask
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane