mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-11-26 22:50:22 +00:00
Rename tile blitters to match internal bit fields and add in the solid prioity blitter
This commit is contained in:
parent
55484fd3e4
commit
de5bdc6041
@ -8,7 +8,7 @@
|
||||
use .\Defs.s
|
||||
|
||||
; Feature flags
|
||||
NO_INTERRUPTS equ 1 ; turn off for crossrunner debugging
|
||||
NO_INTERRUPTS equ 0 ; turn off for crossrunner debugging
|
||||
NO_MUSIC equ 1 ; turn music + tool loading off
|
||||
|
||||
; External data provided by the main program segment
|
||||
@ -394,7 +394,8 @@ ReadControl ENT
|
||||
; put blitter/Tiles00001.s
|
||||
; put blitter/Tiles00010.s
|
||||
; put blitter/Tiles00011.s
|
||||
put blitter/Tiles01000.s
|
||||
put blitter/Tiles10000.s
|
||||
put blitter/Tiles11000.s
|
||||
; put blitter/Tiles10001.s
|
||||
; put blitter/Tiles10010.s
|
||||
; put blitter/Tiles10011.s
|
||||
|
@ -182,7 +182,7 @@ TileProcs dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10110 : fringed masked normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10111 : fringed masked dynamic tiles w/sprite
|
||||
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11000 : high-priority normal tiles w/sprite
|
||||
dw _TBSolidPrioritySpriteTile_00,_TBSolidPrioritySpriteTile_0H,_TBSolidPrioritySpriteTile_V0,_TBSolidPrioritySpriteTile_VH ; 11000 : high-priority normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11001 : high-priority dynamic tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_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
|
||||
|
@ -1,132 +1,6 @@
|
||||
; _TBSolidSpriteTile
|
||||
; _TBPriorityTile
|
||||
;
|
||||
; Renders solid tiles with sprites layered on top of the tile data. Because we need to combine
|
||||
; data from the sprite plane, tile data and write to the code field (which are all in different banks),
|
||||
; 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.
|
||||
_TBSolidSpriteTile_00
|
||||
; ldx #45*128
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer (using correct x-register)
|
||||
jsr _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field)
|
||||
jmp _TBFillPEAOpcode ; Fill in the code field opcodes
|
||||
|
||||
_TBSolidSpriteTile_0H
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidSpriteTile_V0
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidSpriteTile_VH
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
; Fast variation that does not need to set the opcode
|
||||
_TBFastSpriteTile_00
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer
|
||||
jmp _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field)
|
||||
|
||||
_TBFastSpriteTile_0H
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
_TBFastSpriteTile_V0
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
_TBFastSpriteTile_VH
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
; Need to update the X-register before calling this
|
||||
_TBApplySpriteData
|
||||
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta: $0004+{]line*$1000},y
|
||||
|
||||
lda blttmp+{]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
|
||||
--^
|
||||
rts
|
||||
|
||||
; Copy tile data into the direct page compositing buffer. The main reason to do this in full passes is
|
||||
; because we can avoid needing to use both the X and Y registers during the compositing process and
|
||||
; reserve Y to hold the code field address.
|
||||
;
|
||||
; Also, we can get away with not setting the bank register, this is a wash in terms of speed, but results
|
||||
; in simpler, more composable subroutines
|
||||
_TBCopyTileDataToCBuff
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
ldal tiledata+{]line*4}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffH
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4}+64,x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
ldal tiledata+{]line*4}+64+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffV
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
ldal tiledata+{]src*4}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffVH
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4}+64,x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
ldal tiledata+{]src*4}+64+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
; Copy just the data into the code field from the composite buffer
|
||||
_TBSolidComposite
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
sta: $0004+{]line*$1000},y
|
||||
lda blttmp+{]line*4}+2
|
||||
sta: $0001+{]line*$1000},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
; The priority bit allows the tile to be rendered in front of sprites. If there's no sprite
|
||||
; in this tile area, then just fallback to the Tile00000.s implementation
|
||||
_TBPriorityTile dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH
|
||||
dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
|
@ -1,132 +1,19 @@
|
||||
; _TBMaskedSpriteTile
|
||||
; _TBMaskedPriorityTile
|
||||
;
|
||||
; Renders a composited tile with masking to the code field.
|
||||
_TBMaskedSpriteTile dw _TBMaskedSpriteTile_00
|
||||
dw _TBMaskedSpriteTile_0H
|
||||
dw _TBMaskedSpriteTile_V0
|
||||
dw _TBMaskedSpriteTile_VH
|
||||
; dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
|
||||
_TBMaskedSpriteTile_00
|
||||
jsr _TBCreateComposite
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_0H
|
||||
jsr _TBCreateCompositeH
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_V0
|
||||
jsr _TBCreateCompositeV
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_VH
|
||||
jsr _TBCreateCompositeVH
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBCreateCompositeDataAndMask
|
||||
phb
|
||||
pea #^tiledata
|
||||
plb
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]line*4},y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
lda: tiledata+{]line*4}+32,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}+32
|
||||
|
||||
lda: tiledata+{]line*4}+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
|
||||
lda: tiledata+{]line*4}+32+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+32+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
|
||||
plb
|
||||
plb
|
||||
rts
|
||||
|
||||
_TBCreateCompositeH
|
||||
phb
|
||||
pea #^tiledata
|
||||
plb
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]line*4}+64,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
lda: tiledata+{]line*4}+64+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
|
||||
plb
|
||||
plb
|
||||
rts
|
||||
|
||||
|
||||
_TBCreateCompositeV
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]src*4},y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
lda: tiledata+{]src*4}+2,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCreateCompositeVH
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]src*4}+64,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
lda: tiledata+{]src*4}+64+2,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
; Copy just the data into the code field from the composite buffer
|
||||
_TBSolidComposite
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
sta: $0004+{]line*$1000},y
|
||||
lda blttmp+{]line*4}+2
|
||||
sta: $0001+{]line*$1000},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
; The priority bit allows the tile to be rendered in front of sprites. If there's no sprite
|
||||
; in this tile area, then just fallback to the Tile00000.s implementation
|
||||
_TBMaskedPriorityTile dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH
|
||||
dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
|
||||
; NOTE: Eventually, we want a way to support this use-case
|
||||
;
|
||||
; When the high-priority bit is set for a tile, then the BG0 tile will be rendered behind the BG1 data. In
|
||||
; order to support this, the optional BG1 mask buffer needs to be enabled and *every* word in the tile
|
||||
; becomes a JMP handler (similar to masked dynamic tiles)
|
||||
;
|
||||
; The 8 bytes of code that is generated in the JMP handler is
|
||||
;
|
||||
; lda #tiledata
|
||||
; and [dp],y
|
||||
; ora (dp),y
|
||||
; nop
|
||||
|
@ -1,6 +1,187 @@
|
||||
; _TBPriorityTile
|
||||
; _TBSolidSpriteTile
|
||||
;
|
||||
; The priority bit allows the tile to be rendered in front of sprites. If there's no sprite
|
||||
; in this tile area, then just fallback to the Tile00000.s implementation
|
||||
_TBPriorityTile dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH
|
||||
dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
; Renders solid tiles with sprites layered on top of the tile data. Because we need to combine
|
||||
; data from the sprite plane, tile data and write to the code field (which are all in different banks),
|
||||
; 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.
|
||||
_TBSolidSpriteTile_00
|
||||
; ldx #45*128
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer (using correct x-register)
|
||||
jsr _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field)
|
||||
jmp _TBFillPEAOpcode ; Fill in the code field opcodes
|
||||
|
||||
_TBSolidSpriteTile_0H
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidSpriteTile_V0
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidSpriteTile_VH
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jsr _TBApplySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
; Fast variation that does not need to set the opcode
|
||||
_TBFastSpriteTile_00
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile into the compositing buffer
|
||||
jmp _TBApplySpriteData ; Overlay the data form the sprite plane (and copy into the code field)
|
||||
|
||||
_TBFastSpriteTile_0H
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
_TBFastSpriteTile_V0
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
_TBFastSpriteTile_VH
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jmp _TBApplySpriteData
|
||||
|
||||
; Need to update the X-register before calling this
|
||||
_TBApplySpriteData
|
||||
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta: $0004+{]line*$1000},y
|
||||
|
||||
lda blttmp+{]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
|
||||
--^
|
||||
rts
|
||||
|
||||
; Copy tile data into the direct page compositing buffer. The main reason to do this in full passes is
|
||||
; because we can avoid needing to use both the X and Y registers during the compositing process and
|
||||
; reserve Y to hold the code field address.
|
||||
;
|
||||
; Also, we can get away with not setting the bank register, this is a wash in terms of speed, but results
|
||||
; in simpler, more composable subroutines
|
||||
_TBCopyTileDataToCBuff
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
ldal tiledata+{]line*4}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffH
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4}+64,x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
ldal tiledata+{]line*4}+64+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffV
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
ldal tiledata+{]src*4}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileDataToCBuffVH
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4}+64,x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
ldal tiledata+{]src*4}+64+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
|
||||
; Copy tile mask data into the direct page compositing buffer.
|
||||
_TBCopyTileMaskToCBuff
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4}+32,x
|
||||
sta blttmp+{]line*4}+32
|
||||
|
||||
ldal tiledata+{]line*4}+32+2,x
|
||||
sta blttmp+{]line*4}+32+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileMaskToCBuffH
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4}+32+64,x
|
||||
sta blttmp+{]line*4}+32
|
||||
|
||||
ldal tiledata+{]line*4}+32+64+2,x
|
||||
sta blttmp+{]line*4}+32+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileMaskToCBuffV
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4}+32,x
|
||||
sta blttmp+{]dest*4}+32
|
||||
|
||||
ldal tiledata+{]src*4}+32+2,x
|
||||
sta blttmp+{]dest*4}+32+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCopyTileMaskToCBuffVH
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]src*4}+32+64,x
|
||||
sta blttmp+{]dest*4}+32
|
||||
|
||||
ldal tiledata+{]src*4}+32+64+2,x
|
||||
sta blttmp+{]dest*4}+32+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
|
||||
; Copy just the data into the code field from the composite buffer
|
||||
_TBSolidComposite
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
sta: $0004+{]line*$1000},y
|
||||
lda blttmp+{]line*4}+2
|
||||
sta: $0001+{]line*$1000},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
@ -1,19 +1,132 @@
|
||||
; _TBMaskedPriorityTile
|
||||
; _TBMaskedSpriteTile
|
||||
;
|
||||
; The priority bit allows the tile to be rendered in front of sprites. If there's no sprite
|
||||
; in this tile area, then just fallback to the Tile00000.s implementation
|
||||
_TBMaskedPriorityTile dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH
|
||||
dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
; Renders a composited tile with masking to the code field.
|
||||
_TBMaskedSpriteTile dw _TBMaskedSpriteTile_00
|
||||
dw _TBMaskedSpriteTile_0H
|
||||
dw _TBMaskedSpriteTile_V0
|
||||
dw _TBMaskedSpriteTile_VH
|
||||
; dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
||||
|
||||
_TBMaskedSpriteTile_00
|
||||
jsr _TBCreateComposite
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_0H
|
||||
jsr _TBCreateCompositeH
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_V0
|
||||
jsr _TBCreateCompositeV
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBMaskedSpriteTile_VH
|
||||
jsr _TBCreateCompositeVH
|
||||
jsr _TBSolidComposite
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBCreateCompositeDataAndMask
|
||||
phb
|
||||
pea #^tiledata
|
||||
plb
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]line*4},y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
lda: tiledata+{]line*4}+32,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}+32
|
||||
|
||||
lda: tiledata+{]line*4}+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
|
||||
lda: tiledata+{]line*4}+32+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+32+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
|
||||
plb
|
||||
plb
|
||||
rts
|
||||
|
||||
_TBCreateCompositeH
|
||||
phb
|
||||
pea #^tiledata
|
||||
plb
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]line*4}+64,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
lda: tiledata+{]line*4}+64+2,y
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
|
||||
plb
|
||||
plb
|
||||
rts
|
||||
|
||||
|
||||
_TBCreateCompositeV
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]src*4},y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
lda: tiledata+{]src*4}+2,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
_TBCreateCompositeVH
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
lda: tiledata+{]src*4}+64,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN},x
|
||||
sta blttmp+{]dest*4}
|
||||
|
||||
lda: tiledata+{]src*4}+64+2,y
|
||||
andl spritemask+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
oral spritedata+{]dest*SPRITE_PLANE_SPAN}+2,x
|
||||
sta blttmp+{]dest*4}+2
|
||||
]src equ ]src-1
|
||||
]dest equ ]dest+1
|
||||
--^
|
||||
rts
|
||||
|
||||
; Copy just the data into the code field from the composite buffer
|
||||
_TBSolidComposite
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda blttmp+{]line*4}
|
||||
sta: $0004+{]line*$1000},y
|
||||
lda blttmp+{]line*4}+2
|
||||
sta: $0001+{]line*$1000},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
|
||||
; NOTE: Eventually, we want a way to support this use-case
|
||||
;
|
||||
; When the high-priority bit is set for a tile, then the BG0 tile will be rendered behind the BG1 data. In
|
||||
; order to support this, the optional BG1 mask buffer needs to be enabled and *every* word in the tile
|
||||
; becomes a JMP handler (similar to masked dynamic tiles)
|
||||
;
|
||||
; The 8 bytes of code that is generated in the JMP handler is
|
||||
;
|
||||
; lda #tiledata
|
||||
; and [dp],y
|
||||
; ora (dp),y
|
||||
; nop
|
||||
|
@ -1,6 +0,0 @@
|
||||
; _TBPriorityDynamicMaskTile
|
||||
;
|
||||
; The priority bit allows the tile to be rendered in front of sprites. If there's no sprite
|
||||
; in this tile area, then just fallback to the Tile00000.s implementation
|
||||
_TBPriorityDynamicMaskTile dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00,_TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00
|
@ -1,7 +1,31 @@
|
||||
; _TBPrioritySpriteTile
|
||||
; _TBSolidPrioritySpriteTile
|
||||
;
|
||||
; 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
|
||||
_TBSolidPrioritySpriteTile_00
|
||||
; ldx #45*128
|
||||
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 _TBApplyPrioritySpriteData ; Underlay the data fromthe sprite plane (and copy into the code field)
|
||||
jmp _TBFillPEAOpcode ; Fill in the code field opcodes
|
||||
|
||||
_TBSolidPrioritySpriteTile_0H
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jsr _TBCopyTileMaskToCBuffH
|
||||
jsr _TBApplyPrioritySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidPrioritySpriteTile_V0
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jsr _TBCopyTileMaskToCBuffV
|
||||
jsr _TBApplyPrioritySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
_TBSolidPrioritySpriteTile_VH
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jsr _TBCopyTileMaskToCBuffVH
|
||||
jsr _TBApplyPrioritySpriteData
|
||||
jmp _TBFillPEAOpcode
|
||||
|
||||
; Need to update the X-register before calling this
|
||||
_TBApplyPrioritySpriteData
|
||||
|
Loading…
Reference in New Issue
Block a user