Add final tile blitter

This commit is contained in:
Lucas Scharenbroich 2021-11-19 16:48:39 -06:00
parent fd6c686a95
commit a7ba1e4b6b
3 changed files with 126 additions and 1 deletions

View File

@ -419,6 +419,7 @@ ReadControl ENT
put blitter/Tiles11000.s ; normal high priority tiles + sprites
put blitter/Tiles11001.s ; dynamic high priority tiles + sprites
put blitter/Tiles11010.s ; normal high priority masked tiles + sprites
put blitter/Tiles11011.s ; dynamic high priority masked tiles + sprites
put blitter/TilesBG1.s
put blitter/Vert.s

View File

@ -203,7 +203,8 @@ TileProcs dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolid
dw _TBDynamicPrioritySpriteTile_00,_TBDynamicPrioritySpriteTile_00 ; 11001 : high-priority dynamic tiles w/sprite
dw _TBMaskedPrioritySpriteTile_00,_TBMaskedPrioritySpriteTile_0H
dw _TBMaskedPrioritySpriteTile_V0,_TBMaskedPrioritySpriteTile_VH ; 11010 : high-priority masked normal tiles w/sprite
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11011 : high-priority masked dynamic tiles w/sprite
dw _TBDynamicMaskedPrioritySpriteTile_00,_TBDynamicMaskedPrioritySpriteTile_00
dw _TBDynamicMaskedPrioritySpriteTile_00,_TBDynamicMaskedPrioritySpriteTile_00 ; 11011 : high-priority masked dynamic tiles w/sprite
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11100 : high-priority fringed normal tiles w/sprite
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11101 : high-priority fringed dynamic tiles w/sprite

123
src/blitter/Tiles11011.s Normal file
View File

@ -0,0 +1,123 @@
; _TBDynamicMaskedPrioritySpriteTile
;
; This tile type does not explicitly support horizontal or vertical flipping. An appropriate tile
; descriptor should be passed into CopyTileToDyn to put the horizontally or vertically flipped source
; data into the dynamic tile buffer
_TBDynamicMaskedPrioritySpriteTile_00
sty _Y_REG ; This is restored in the macro
sta _X_REG ; Cache some column values derived from _X_REG
tax
ora #$B100 ; Pre-calc the LDA (dp),y opcode + operand
xba
sta _OP_CACHE
clc
ldal JTableOffset,x ; Get the address offset and add to the base address
adc _BASE_ADDR ; of the current code field line
sta _JTBL_CACHE
lda _TILE_ID ; Get the original tile descriptor
and #$007F ; clamp to < (32 * 4)
ora #$3580 ; Pre-calc the AND $80,x opcode + operand
xba
sta _T_PTR ; This is an op to load the dynamic tile data
ldx _SPR_X_REG
CopyDynPrioMaskedSpriteWord {0*SPRITE_PLANE_SPAN};$0003
CopyDynPrioMaskedSpriteWord {1*SPRITE_PLANE_SPAN};$1003
CopyDynPrioMaskedSpriteWord {2*SPRITE_PLANE_SPAN};$2003
CopyDynPrioMaskedSpriteWord {3*SPRITE_PLANE_SPAN};$3003
CopyDynPrioMaskedSpriteWord {4*SPRITE_PLANE_SPAN};$4003
CopyDynPrioMaskedSpriteWord {5*SPRITE_PLANE_SPAN};$5003
CopyDynPrioMaskedSpriteWord {6*SPRITE_PLANE_SPAN};$6003
CopyDynPrioMaskedSpriteWord {7*SPRITE_PLANE_SPAN};$7003
ldx _X_REG
clc
ldal JTableOffset+2,x ; Get the address offset and add to the base address
adc _BASE_ADDR ; of the current code field line
sta _JTBL_CACHE
lda _OP_CACHE
adc #$0200
sta _OP_CACHE
lda _T_PTR
adc #$0200
sta _T_PTR
ldx _SPR_X_REG
CopyDynPrioMaskedSpriteWord {0*SPRITE_PLANE_SPAN}+2;$0000
CopyDynPrioMaskedSpriteWord {1*SPRITE_PLANE_SPAN}+2;$1000
CopyDynPrioMaskedSpriteWord {2*SPRITE_PLANE_SPAN}+2;$2000
CopyDynPrioMaskedSpriteWord {3*SPRITE_PLANE_SPAN}+2;$3000
CopyDynPrioMaskedSpriteWord {4*SPRITE_PLANE_SPAN}+2;$4000
CopyDynPrioMaskedSpriteWord {5*SPRITE_PLANE_SPAN}+2;$5000
CopyDynPrioMaskedSpriteWord {6*SPRITE_PLANE_SPAN}+2;$6000
CopyDynPrioMaskedSpriteWord {7*SPRITE_PLANE_SPAN}+2;$7000
rts
; Masked renderer for a masked dynamic tile with sprite data underlaid.
;
; ]1 : sprite plane offset
; ]2 : code field offset
CopyDynPrioMaskedSpriteWord MAC
; Need to fill in the first 14 bytes of the JMP handler with the following code sequence where
; the data and mask from from the sprite plane
;
; lda ($00),y
; and #MASK
; ora #DATA
; and $80,x
; ora $00,x
; bra *+15
lda #$004C ; JMP to handler
sta: ]2,y
lda _JTBL_CACHE ; Get the offset to the exception handler for this column
ora #{]2&$F000} ; adjust for the current row offset
sta: ]2+1,y
tay ; This becomes the new address that we use to patch in
lda _OP_CACHE
sta: $0000,y ; LDA (00),y
lda #$0029 ; AND #SPRITE_MASK
sta: $0002,y
ldal spritemask+]1,x
cmp #$FFFF ; All 1's in the mask is a fully transparent sprite word
beq transparent ; so we can use the Tile00011 method
sta: $0003,y
lda #$0009 ; ORA #SPRITE_DATA
sta: $0005,y
ldal spritedata+]1,x
sta: $0006,y
lda _T_PTR
sta: $0008,y ; AND $80,x
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
sta: $000A,y ; ORA $00,x
lda #$0980 ; branch to the prologue (BRA *+11)
sta: $000C,y
bra next
; This is a transparent word, so just show the dynamic data
transparent
lda _T_PTR
sta: $0002,y ; AND $80,x
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
sta: $0004,y ; ORA $00,x
lda #$0F80 ; branch to the epilogue (BRA *+17)
sta: $0006,y
next
ldy _Y_REG ; restore original y-register value and move on
eom