Remove obsolete blitter routines

This commit is contained in:
Lucas Scharenbroich 2022-09-02 20:37:26 -05:00
parent 33da3d4a97
commit 217a1176a9
16 changed files with 0 additions and 1426 deletions

View File

@ -1,126 +0,0 @@
use Util.Macs.s
use Load.Macs.s
use Locator.Macs.s
use Mem.Macs.s
use Misc.Macs.s
use Tool222.MACS.s
use Core.MACS.s
use .\Defs.s
EngineStartUp ENT
phb
phk
plb
jsr ToolStartUp ; Start up the toolbox tools we rely on
jsr _CoreStartUp
jsr SoundStartUp ; Start up any sound/music tools
plb
rtl
EngineShutDown ENT
phb
phk
plb
jsr SoundShutDown
jsr _CoreShutDown
jsr ToolShutDown
plb
rtl
ToolStartUp
_TLStartUp ; normal tool initialization
pha
_MMStartUp
_Err ; should never happen
pla
sta MasterId ; our master handle references the memory allocated to us
ora #$0100 ; set auxID = $01 (valid values $01-0f)
sta UserId ; any memory we request must use our own id
_MTStartUp
rts
MasterId ds 2
; Fatal error handler invoked by the _Err macro
PgmDeath tax
pla
inc
phx
phk
pha
bra ContDeath
PgmDeath0 pha
pea $0000
pea $0000
ContDeath ldx #$1503
jsl $E10000
; Use Tool222 (NinjaTrackerPlus) for music playback
SoundStartUp
lda #NO_MUSIC
bne :no_music
pea $00DE
pea $0000
_LoadOneTool
_Err
lda UserId
pha
_NTPStartUp
:no_music
rts
SoundShutDown
lda #NO_MUSIC
bne :no_music
_NTPShutDown
:no_music
rts
ToolShutDown
rts
put CoreImpl.s
put blitter/Template.s
put Memory.s
put Graphics.s
put Sprite.s
put blitter/Tiles.s
put Sprite2.s
put SpriteRender.s
put Render.s
put Timer.s
put Script.s
put blitter/Blitter.s
put blitter/Horz.s
put blitter/PEISlammer.s
put blitter/Tables.s
put blitter/Tiles00000.s ; normal tiles
put blitter/Tiles00001.s ; dynamic tiles
put blitter/Tiles00010.s ; normal masked tiles
put blitter/Tiles00011.s ; dynamic masked tiles
put blitter/Tiles10000.s ; normal tiles + sprites
put blitter/Tiles10001.s ; dynamic tiles + sprites
put blitter/Tiles10010.s ; normal masked tiles + sprites
put blitter/Tiles10011.s ; dynamic masked tiles + sprites
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
put blitter/BG0.s
put blitter/BG1.s
put blitter/SCB.s
put TileMap.s

View File

@ -1,52 +0,0 @@
; _TBSolidTile
;
; Define the addresses of the subroutines that draw the normal and flipped variants of the tiles, both
; in the optimized (no second background) and normal cases.
;
; On entry, the following register values need to be set
;
; X : address of base tile in the tiledata bank (tileId * 128)
; Y : address of the top-left corder of the tile location in the code field
; B : set to the code field bank
_TBSolidTile_00
jsr _TBCopyData
jmp _TBFillPEAOpcode
_TBSolidTile_0H
jsr _TBCopyData
jmp _TBFillPEAOpcode
_TBSolidTile_V0
jsr _TBCopyDataV
jmp _TBFillPEAOpcode
_TBSolidTile_VH
jsr _TBCopyDataV
jmp _TBFillPEAOpcode
; Old routines
_TBCopyData
]line equ 0
lup 8
ldal tiledata+{]line*4},x
sta: $0004+{]line*$1000},y
ldal tiledata+{]line*4}+2,x
sta: $0001+{]line*$1000},y
]line equ ]line+1
--^
rts
_TBCopyDataV
]src equ 7
]dest equ 0
lup 8
ldal tiledata+{]src*4},x
sta: $0004+{]dest*$1000},y
ldal tiledata+{]src*4}+2,x
sta: $0001+{]dest*$1000},y
]src equ ]src-1
]dest equ ]dest+1
--^
rts

View File

@ -1,104 +0,0 @@
; _TBDynamicTile
;
; These subroutines fill in the code field with the instructions to render data from the dynamic
; code buffer. This is a bit different, because no tile data is manipulated. It is the
; responsibiliy of the user of the API to use the CopyTileToDyn subroutine to get data
; into the correct location.
;
; 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
_TBDynamicTile_00
jsr _TBDynamicData
jmp _TBFillLdaDpOpcode
_TBDynamic
ldal TileStore+TS_TILE_ID,x
and #$007F
ora #$4800
]line equ 0 ; render the first column
lup 8
sta: $0004+{]line*$1000},y
]line equ ]line+1
--^
inc ; advance to the next word
inc
]line equ 0 ; render the second column
lup 8
sta: $0001+{]line*$1000},y
]line equ ]line+1
--^
sep #$20
lda #$B5
sta: $0000,y
sta: $0003,y
sta $1000,y
sta $1003,y
sta $2000,y
sta $2003,y
sta $3000,y
sta $3003,y
sta $4000,y
sta $4003,y
sta $5000,y
sta $5003,y
sta $6000,y
sta $6003,y
sta $7000,y
sta $7003,y
rep #$20
plb
rts
; Primitive to render a dynamic tile
;
; LDA 00,x / PHA where the operand is fixed when the tile is rendered
; $B5 $00 $48
_TBDynamicData
lda _TILE_ID ; Get the original tile descriptor
and #$007F ; clamp to < (32 * 4)
ora #$4800 ; insert the PHA instruction
]line equ 0 ; render the first column
lup 8
sta: $0004+{]line*$1000},y
]line equ ]line+1
--^
inc ; advance to the next word
inc
]line equ 0 ; render the second column
lup 8
sta: $0001+{]line*$1000},y
]line equ ]line+1
--^
rts
; A simple helper function that fill in all of the opcodes of a tile with the LDA dp,x opcode.
_TBFillLdaDpOpcode
sep #$20
lda #$B5
sta: $0000,y
sta: $0003,y
sta $1000,y
sta $1003,y
sta $2000,y
sta $2003,y
sta $3000,y
sta $3003,y
sta $4000,y
sta $4003,y
sta $5000,y
sta $5003,y
sta $6000,y
sta $6003,y
sta $7000,y
sta $7003,y
rep #$20
rts

View File

@ -1,131 +0,0 @@
; _TBMaskedTile
;
; These tile renderes are for "normal" tiles that also apply their mask data. If the case of the second
; background being disabled, the optimized variants are the same as Tile00000
;
; Y register = address of code field tile
; X register = tile address
; Accumulator = logical word offset of the tile (0, 2, 4, ..., 82)
;
; Need to slightly remap these register inputs to save into the direct page cached values
_TBMaskedTile_00
_TBMaskedTile_0H
sta _X_REG ; Save these values as we will need to reload them
sty _Y_REG ; at certain points
stx _T_PTR
; Do the left column first
CopyMaskedWord tiledata+0;tiledata+32+0;$0003
CopyMaskedWord tiledata+4;tiledata+32+4;$1003
CopyMaskedWord tiledata+8;tiledata+32+8;$2003
CopyMaskedWord tiledata+12;tiledata+32+12;$3003
CopyMaskedWord tiledata+16;tiledata+32+16;$4003
CopyMaskedWord tiledata+20;tiledata+32+20;$5003
CopyMaskedWord tiledata+24;tiledata+32+24;$6003
CopyMaskedWord tiledata+28;tiledata+32+28;$7003
; Move the index for the JTableOffset array. This is the same index used for transparent words,
; so, if _X_REG is zero, then we would be patching out the last word in the code field with LDA (0),y
; and then increment _X_REG by two to patch the next-to-last word in the code field with LDA (2),y
inc _X_REG
inc _X_REG
; Do the right column
CopyMaskedWord tiledata+2;tiledata+32+2;$0000
CopyMaskedWord tiledata+6;tiledata+32+6;$1000
CopyMaskedWord tiledata+10;tiledata+32+10;$2000
CopyMaskedWord tiledata+14;tiledata+32+14;$3000
CopyMaskedWord tiledata+18;tiledata+32+18;$4000
CopyMaskedWord tiledata+22;tiledata+32+22;$5000
CopyMaskedWord tiledata+26;tiledata+32+26;$6000
CopyMaskedWord tiledata+30;tiledata+32+30;$7000
rts
;_TBMaskedTile_0H
; sta _X_REG
; sty _Y_REG
; stx _T_PTR
;
; CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$0003
; CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$1003
; CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$2003
; CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$3003
; CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$4003
; CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$5003
; CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$6003
; CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$7003
;
; inc _X_REG
; inc _X_REG
;
; CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$0000
; CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$1000
; CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$2000
; CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$3000
; CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$4000
; CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$5000
; CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$6000
; CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$7000
;
; rts
_TBMaskedTile_V0
_TBMaskedTile_VH
sta _X_REG
sty _Y_REG
stx _T_PTR
CopyMaskedWord tiledata+0;tiledata+32+0;$7003
CopyMaskedWord tiledata+4;tiledata+32+4;$6003
CopyMaskedWord tiledata+8;tiledata+32+8;$5003
CopyMaskedWord tiledata+12;tiledata+32+12;$4003
CopyMaskedWord tiledata+16;tiledata+32+16;$3003
CopyMaskedWord tiledata+20;tiledata+32+20;$2003
CopyMaskedWord tiledata+24;tiledata+32+24;$1003
CopyMaskedWord tiledata+28;tiledata+32+28;$0003
inc _X_REG
inc _X_REG
CopyMaskedWord tiledata+2;tiledata+32+2;$7000
CopyMaskedWord tiledata+6;tiledata+32+6;$6000
CopyMaskedWord tiledata+10;tiledata+32+10;$5000
CopyMaskedWord tiledata+14;tiledata+32+14;$4000
CopyMaskedWord tiledata+18;tiledata+32+18;$3000
CopyMaskedWord tiledata+22;tiledata+32+22;$2000
CopyMaskedWord tiledata+26;tiledata+32+26;$1000
CopyMaskedWord tiledata+30;tiledata+32+30;$0000
rts
;_TBMaskedTile_VH
; sta _X_REG
; sty _Y_REG
; stx _T_PTR
;
; CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$7003
; CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$6003
; CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$5003
; CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$4003
; CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$3003
; CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$2003
; CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$1003
; CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$0003
;
; inc _X_REG
; inc _X_REG
;
; CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$7000
; CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$6000
; CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$5000
; CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$4000
; CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$3000
; CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$2000
; CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$1000
; CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$0000
;
; rts

View File

@ -1,122 +0,0 @@
; _TBDynamicMaskTile
;
; Insert a code sequence to mask the dynamic tile against the background. This is quite a slow process because
; every word needs to be handled with a JMP exception; but it looks good!
_TBDynamicMaskTile_00
jsr _TBDynamicDataAndMask
jmp _TBFillJMPOpcode
; A = dynamic tile id (must be <32)
_TBDynamicDataAndMask
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
; We need to do an AND dp|$80,x / ORA dp,x. The opcode values are $35 and $15, respectively.
; We pre-calculate the AND opcode with the high bit of the operand set and then, in the macro
; perform and EOR #$2080 to covert the opcode and operand in one instruction
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
CopyMaskedDWord $0003
CopyMaskedDWord $1003
CopyMaskedDWord $2003
CopyMaskedDWord $3003
CopyMaskedDWord $4003
CopyMaskedDWord $5003
CopyMaskedDWord $6003
CopyMaskedDWord $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
CopyMaskedDWord $0000
CopyMaskedDWord $1000
CopyMaskedDWord $2000
CopyMaskedDWord $3000
CopyMaskedDWord $4000
CopyMaskedDWord $5000
CopyMaskedDWord $6000
CopyMaskedDWord $7000
rts
; A simple helper function that fill in all of the opcodes of a tile with the JMP opcode.
_TBFillJMPOpcode
sep #$20
lda #$4C
sta: $0000,y
sta: $0003,y
sta $1000,y
sta $1003,y
sta $2000,y
sta $2003,y
sta $3000,y
sta $3003,y
sta $4000,y
sta $4003,y
sta $5000,y
sta $5003,y
sta $6000,y
sta $6003,y
sta $7000,y
sta $7003,y
rep #$20
rts
; Masked renderer for a dynamic tile. What's interesting about this renderer is that the mask
; value is not used directly, but simply indicates if we can use a LDA 0,x / PHA sequence,
; a LDA (00),y / PHA, or a JMP to a blended render
;
; If a dynamic tile is animated, there is the possibility to create a special mask that marks
; words of the tile that a front / back / mixed across all frames.
;
; ]1 : code field offset
;
; This macro does not set the opcode since they will all be JMP instructions, they can be
; filled more efficiently in a separate routine.
CopyMaskedDWord MAC
; Need to fill in the first 6 bytes of the JMP handler with the following code sequence
;
; lda (00),y
; and $80,x
; ora $00,x
; bra *+17
lda _JTBL_CACHE
ora #{]1&$F000} ; adjust for the current row offset
sta: ]1+1,y
tax ; This becomes the new address that we use to patch in
lda _OP_CACHE
sta: $0000,x ; LDA (00),y
lda _T_PTR
sta: $0002,x ; AND $80,x
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
sta: $0004,x ; ORA $00,x
lda #$0F80 ; branch to the prologue (BRA *+17)
sta: $0006,x
eom

View File

@ -1,6 +0,0 @@
; _TBPriorityTile
;
; 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

View File

@ -1,6 +0,0 @@
; _TBPriorityDynamicTile
;
; 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 Tile00001.s implementation
_TBPriorityDynamicTile dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00

View File

@ -1,19 +0,0 @@
; _TBMaskedPriorityTile
;
; 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

View File

@ -1,99 +0,0 @@
; _TBSolidSpriteTile
;
; 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
_TBSolidSpriteTile_0H
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)
jmp _TBFillPEAOpcode ; Fill in the code field opcodes
_TBSolidSpriteTile_V0
_TBSolidSpriteTile_VH
jsr _TBCopyTileDataToCBuffV
jsr _TBApplySpriteData
jmp _TBFillPEAOpcode
; Fast variation that does not need to set the opcode
_TBFastSpriteTile_00
_TBFastSpriteTile_0H
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_V0
_TBFastSpriteTile_VH
jsr _TBCopyTileDataToCBuffV
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
_TBApplySpriteDataOne
ldx spriteIdx
]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
_TBApplySpriteDataTwo
]line equ 0
lup 8
lda blttmp+{]line*4}
ldx spriteIdx+2
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
ldx spriteIdx
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
sta: $0004+{]line*$1000},y
lda blttmp+{]line*4}+2
ldx spriteIdx+2
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
ldx spriteIdx
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 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

View File

@ -1,211 +0,0 @@
; _TBDynamicSpriteTile
;
; 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
_TBDynamicSpriteTile
sta _X_REG
ldal TileStore+TS_JMP_ADDR,x ; Get the address of the exception handler
sta _JTBL_CACHE
ldal TileStore+TS_TILE_ID,x ; Get the original tile descriptor
and #$007F ; clamp to < (32 * 4)
ora #$B500
xba
sta _OP_CACHE ; This is the 2-byte opcode for to load the data
CopyDynWord 0;$0003
CopyDynWord 4;$1003
CopyDynWord 8;$2003
CopyDynWord 12;$3003
CopyDynWord 16;$4003
CopyDynWord 20;$5003
CopyDynWord 24;$6003
CopyDynWord 28;$7003
clc
lda _JTBL_CACHE
adc #32 ; All the snippets are 32 bytes wide and, since we're
sta _JTBL_CACHE ; within one tile, the second column is consecutive
lda _OP_CACHE
adc #$0200 ; Advance to the next word
sta _OP_CACHE
CopyDynWord 2;$0000
CopyDynWord 6;$1000
CopyDynWord 10;$2000
CopyDynWord 14;$3000
CopyDynWord 18;$4000
CopyDynWord 22;$5000
CopyDynWord 26;$6000
CopyDynWord 30;$7000
plb
rts
_TBDynamicSpriteTile_00
sty _Y_REG ; This is restored in the macro
sta _X_REG ; Cache some column values derived from _X_REG
tax
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 #$B500
xba
sta _OP_CACHE ; This is the 2-byte opcode for to load the data
ldx _SPR_X_REG
CopyDynSpriteWord {0*SPRITE_PLANE_SPAN};$0003
CopyDynSpriteWord {1*SPRITE_PLANE_SPAN};$1003
CopyDynSpriteWord {2*SPRITE_PLANE_SPAN};$2003
CopyDynSpriteWord {3*SPRITE_PLANE_SPAN};$3003
CopyDynSpriteWord {4*SPRITE_PLANE_SPAN};$4003
CopyDynSpriteWord {5*SPRITE_PLANE_SPAN};$5003
CopyDynSpriteWord {6*SPRITE_PLANE_SPAN};$6003
CopyDynSpriteWord {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
ldx _SPR_X_REG
CopyDynSpriteWord {0*SPRITE_PLANE_SPAN}+2;$0000
CopyDynSpriteWord {1*SPRITE_PLANE_SPAN}+2;$1000
CopyDynSpriteWord {2*SPRITE_PLANE_SPAN}+2;$2000
CopyDynSpriteWord {3*SPRITE_PLANE_SPAN}+2;$3000
CopyDynSpriteWord {4*SPRITE_PLANE_SPAN}+2;$4000
CopyDynSpriteWord {5*SPRITE_PLANE_SPAN}+2;$5000
CopyDynSpriteWord {6*SPRITE_PLANE_SPAN}+2;$6000
CopyDynSpriteWord {7*SPRITE_PLANE_SPAN}+2;$7000
rts
; Create a masked render based on data in the direct page temporary buffer
;
; ]1 : sprite buffer offset
; ]2 : code field offset
CopyDynWord mac
lda tmp_sprite_mask+{]1} ; load the mask value
bne mixed ; a non-zero value may be mixed
; This is a solid word
lda #$00F4 ; PEA instruction
sta: ]2,y
lda tmp_sprite_data+{]1} ; load the sprite data
sta: ]2+1,y ; PEA operand
bra next
mixed cmp #$FFFF ; All 1's in the mask is a fully transparent sprite word
beq transparent
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
tax ; This becomes the new address that we use to patch in
lda _OP_CACHE ; Get the LDA dp,x instruction for this column
sta: $0000,x
lda #$0029 ; AND #SPRITE_MASK
sta: $0002,x
lda tmp_sprite_mask+{]1}
sta: $0003,x
lda #$0009 ; ORA #SPRITE_DATA
sta: $0005,x
lda tmp_sprite_data+{]1}
sta: $0006,x
lda #$0D80 ; branch to the prologue (BRA *+15)
sta: $0008,x
bra next
; This is a transparent word, so just show the dynamic data
transparent
lda #$4800 ; Put the PHA in the third byte
sta: {]2}+1,y
lda _OP_CACHE ; Store the LDA dp,x instruction with operand
sta: {]2},y
next
<<<
; Masked renderer for a dynamic tile with sprite data overlaid.
;
; ]1 : sprite plane offset
; ]2 : code field offset
CopyDynSpriteWord MAC
; Need to fill in the first 10 bytes of the JMP handler with the following code sequence where
; the data and mask from from the sprite plane
;
; lda $00,x
; and #MASK
; ora #DATA
; bra *+15
;
; If MASK == 0, then we can do a PEA. If MASK == $FFFF, then fall back to the simple Dynamic Tile
; code.
ldal spritemask+{]1},x ; load the mask value
bne mixed ; a non-zero value may be mixed
; This is a solid word
lda #$00F4 ; PEA instruction
sta: ]2,y
ldal spritedata+{]1},x ; load the sprite data
sta: ]2+1,y ; PEA operand
bra next
mixed cmp #$FFFF ; All 1's in the mask is a fully transparent sprite word
beq transparent
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 ; Get the LDA dp,x instruction for this column
sta: $0000,y
lda #$0029 ; AND #SPRITE_MASK
sta: $0002,y
ldal spritemask+{]1},x
sta: $0003,y
lda #$0009 ; ORA #SPRITE_DATA
sta: $0005,y
ldal spritedata+{]1},x
sta: $0006,y
lda #$0D80 ; branch to the prologue (BRA *+15)
sta: $0008,y
ldy _Y_REG ; restore original y-register value and move on
bra next
; This is a transparent word, so just show the dynamic data
transparent
lda #$4800 ; Put the PHA in the third byte
sta: ]2+1,y
lda _OP_CACHE ; Store the LDA dp,x instruction with operand
sta: ]2,y
next
eom

View File

@ -1,88 +0,0 @@
; _TBMaskedSpriteTile
;
; Renders a composited tile with masking to the code field.
_TBMaskedSpriteTile_00
_TBMaskedSpriteTile_0H
sta _X_REG ; Immedately stash the parameters
sty _Y_REG
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 _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
;_TBMaskedSpriteTile_0H
; sta _X_REG
; sty _Y_REG
; jsr _TBCopyTileDataToCBuffH
; jsr _TBCopyTileMaskToCBuffH
; jsr _TBMergeSpriteDataAndMask
; jmp _TBMaskedCBuff
_TBMaskedSpriteTile_V0
_TBMaskedSpriteTile_VH
sta _X_REG
sty _Y_REG
jsr _TBCopyTileDataToCBuffV
jsr _TBCopyTileMaskToCBuffV
jsr _TBMergeSpriteDataAndMask
jmp _TBMaskedCBuff
;_TBMaskedSpriteTile_VH
; sta _X_REG
; sty _Y_REG
; jsr _TBCopyTileDataToCBuffVH
; jsr _TBCopyTileMaskToCBuffVH
; jsr _TBMergeSpriteDataAndMask
; jmp _TBMaskedCBuff
_TBMergeSpriteDataAndMask
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 blttmp+{]line*4}
ldal spritemask+{]line*SPRITE_PLANE_SPAN},x
and blttmp+{]line*4}+32
sta blttmp+{]line*4}+32
lda blttmp+{]line*4}+2
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
sta blttmp+{]line*4}+2
ldal spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
and blttmp+{]line*4}+32+2
sta blttmp+{]line*4}+32+2
]line equ ]line+1
--^
rts
; See the Tiles00010.s blitter for additional details
_TBMaskedCBuff
CopyMaskedWordD blttmp+0;$0003
CopyMaskedWordD blttmp+4;$1003
CopyMaskedWordD blttmp+8;$2003
CopyMaskedWordD blttmp+12;$3003
CopyMaskedWordD blttmp+16;$4003
CopyMaskedWordD blttmp+20;$5003
CopyMaskedWordD blttmp+24;$6003
CopyMaskedWordD blttmp+28;$7003
inc _X_REG
inc _X_REG
CopyMaskedWordD blttmp+2;$0000
CopyMaskedWordD blttmp+6;$1000
CopyMaskedWordD blttmp+10;$2000
CopyMaskedWordD blttmp+14;$3000
CopyMaskedWordD blttmp+18;$4000
CopyMaskedWordD blttmp+22;$5000
CopyMaskedWordD blttmp+26;$6000
CopyMaskedWordD blttmp+30;$7000
rts

View File

@ -1,134 +0,0 @@
; _TBDynamicMaskedSpriteTile
;
; 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
;
; When rendering, the background, via lda (dp),y, is shown behind the animate sprite
_TBDynamicMaskedSpriteTile_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
CopyDynMaskedSpriteWord {0*SPRITE_PLANE_SPAN};$0003
CopyDynMaskedSpriteWord {1*SPRITE_PLANE_SPAN};$1003
CopyDynMaskedSpriteWord {2*SPRITE_PLANE_SPAN};$2003
CopyDynMaskedSpriteWord {3*SPRITE_PLANE_SPAN};$3003
CopyDynMaskedSpriteWord {4*SPRITE_PLANE_SPAN};$4003
CopyDynMaskedSpriteWord {5*SPRITE_PLANE_SPAN};$5003
CopyDynMaskedSpriteWord {6*SPRITE_PLANE_SPAN};$6003
CopyDynMaskedSpriteWord {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
CopyDynMaskedSpriteWord {0*SPRITE_PLANE_SPAN}+2;$0000
CopyDynMaskedSpriteWord {1*SPRITE_PLANE_SPAN}+2;$1000
CopyDynMaskedSpriteWord {2*SPRITE_PLANE_SPAN}+2;$2000
CopyDynMaskedSpriteWord {3*SPRITE_PLANE_SPAN}+2;$3000
CopyDynMaskedSpriteWord {4*SPRITE_PLANE_SPAN}+2;$4000
CopyDynMaskedSpriteWord {5*SPRITE_PLANE_SPAN}+2;$5000
CopyDynMaskedSpriteWord {6*SPRITE_PLANE_SPAN}+2;$6000
CopyDynMaskedSpriteWord {7*SPRITE_PLANE_SPAN}+2;$7000
rts
; Masked renderer for a masked dynamic tile with sprite data overlaid.
;
; ]1 : sprite plane offset
; ]2 : code field offset
CopyDynMaskedSpriteWord 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 $80,x
; ora $00,x
; and #MASK
; ora #DATA
; bra *+15
;
; If MASK == 0, then we can do a PEA. If MASK == $FFFF, then fall back to the simple Dynamic Tile
; code and eliminate the constanct AND/ORA instructions.
ldal spritemask+{]1},x ; load the mask value
bne mixed ; a non-zero value may be mixed
; This is a solid word
lda #$00F4 ; PEA instruction
sta: ]2,y
ldal spritedata+{]1},x ; load the sprite data
sta: ]2+1,y ; PEA operand
bra next
; We will always do a JMP to the eception handler, so set that up, then check for sprite
; transparency
mixed
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 _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 #$0029 ; AND #SPRITE_MASK
sta: $0006,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: $0007,y
lda #$0009 ; ORA #SPRITE_DATA
sta: $0009,y
ldal spritedata+{]1},x
sta: $000A,y
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 #$0F80 ; branch to the epilogue (BRA *+17)
sta: $0006,y
next
ldy _Y_REG ; restore original y-register value and move on
eom

View File

@ -1,50 +0,0 @@
; _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
_TBSolidPrioritySpriteTile_0H
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
_TBSolidPrioritySpriteTile_VH
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
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane
]line equ 0
lup 8
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
and blttmp+{]line*4}+32
ora blttmp+{]line*4}
sta: $0004+{]line*$1000},y
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
and blttmp+{]line*4}+32+2
ora blttmp+{]line*4}+2
sta: $0001+{]line*$1000},y
]line equ ]line+1
--^
ldx _X_REG ; restore the original value
rts

View File

@ -1,92 +0,0 @@
; _TBDynamicPrioritySpriteTile
;
; Variant of _TBDynamicSpriteTile (Tile10001), but draw the sprite data behind the dynamic tile
_TBDynamicPrioritySpriteTile_00
jsr _TBDynamicPriorityDataAndMask
jmp _TBFillJMPOpcode
_TBDynamicPriorityDataAndMask
sty _Y_REG ; This is restored in the macro
sta _X_REG ; Cache some column values derived from _X_REG
tax
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 _OP_CACHE ; This is an op to load the dynamic tile data
ldx _SPR_X_REG
CopyDynPriSpriteWord {0*SPRITE_PLANE_SPAN};$0003
CopyDynPriSpriteWord {1*SPRITE_PLANE_SPAN};$1003
CopyDynPriSpriteWord {2*SPRITE_PLANE_SPAN};$2003
CopyDynPriSpriteWord {3*SPRITE_PLANE_SPAN};$3003
CopyDynPriSpriteWord {4*SPRITE_PLANE_SPAN};$4003
CopyDynPriSpriteWord {5*SPRITE_PLANE_SPAN};$5003
CopyDynPriSpriteWord {6*SPRITE_PLANE_SPAN};$6003
CopyDynPriSpriteWord {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
ldx _SPR_X_REG
CopyDynPriSpriteWord {0*SPRITE_PLANE_SPAN}+2;$0000
CopyDynPriSpriteWord {1*SPRITE_PLANE_SPAN}+2;$1000
CopyDynPriSpriteWord {2*SPRITE_PLANE_SPAN}+2;$2000
CopyDynPriSpriteWord {3*SPRITE_PLANE_SPAN}+2;$3000
CopyDynPriSpriteWord {4*SPRITE_PLANE_SPAN}+2;$4000
CopyDynPriSpriteWord {5*SPRITE_PLANE_SPAN}+2;$5000
CopyDynPriSpriteWord {6*SPRITE_PLANE_SPAN}+2;$6000
CopyDynPriSpriteWord {7*SPRITE_PLANE_SPAN}+2;$7000
rts
; Masked renderer for a dynamic tile with sprite data overlaid.
;
; ]1 : sprite plane offset
; ]2 : code field offset
CopyDynPriSpriteWord MAC
; Need to fill in the first 9 bytes of the JMP handler with the following code sequence where
; the data and mask from from the sprite plane
;
; lda #DATA
; and $80,x
; ora $00,x
; bra *+16
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 #$00A9 ; LDA #DATA
sta: $0000,y
ldal spritedata+{]1},x
sta: $0001,y
lda _OP_CACHE
sta: $0003,y ; AND $80,x
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
sta: $0005,y ; ORA $00,x
lda #$0E80 ; branch to the prologue (BRA *+16)
sta: $0007,y
ldy _Y_REG ; restore original y-register value and move on
eom

View File

@ -1,63 +0,0 @@
; _TBMaskedPrioritySpriteTile
;
; Renders a composited tile with masking to the code field. The sprite is underlaid
_TBMaskedPrioritySpriteTile_00
_TBMaskedPrioritySpriteTile_0H
sta _X_REG ; Immedately stash the parameters
sty _Y_REG
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 _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
;_TBMaskedPrioritySpriteTile_0H
; sta _X_REG
; sty _Y_REG
; jsr _TBCopyTileDataToCBuffH
; jsr _TBCopyTileMaskToCBuffH
; jsr _TBUnderlaySpriteDataAndMask
; jmp _TBMaskedCBuff
_TBMaskedPrioritySpriteTile_V0
_TBMaskedPrioritySpriteTile_VH
sta _X_REG
sty _Y_REG
jsr _TBCopyTileDataToCBuffV
jsr _TBCopyTileMaskToCBuffV
jsr _TBUnderlaySpriteDataAndMask
jmp _TBMaskedCBuff
;_TBMaskedPrioritySpriteTile_VH
; sta _X_REG
; sty _Y_REG
; jsr _TBCopyTileDataToCBuffVH
; jsr _TBCopyTileMaskToCBuffVH
; jsr _TBUnderlaySpriteDataAndMask
; jmp _TBMaskedCBuff
_TBUnderlaySpriteDataAndMask
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane
]line equ 0
lup 8
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
and blttmp+{]line*4}+32
ora blttmp+{]line*4} ; Maybe this can be a TSB???
sta blttmp+{]line*4}
ldal spritemask+{]line*SPRITE_PLANE_SPAN},x
and blttmp+{]line*4}+32
sta blttmp+{]line*4}+32
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
and blttmp+{]line*4}+32+2
ora blttmp+{]line*4}+2
sta blttmp+{]line*4}+2
ldal spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
and blttmp+{]line*4}+32+2
sta blttmp+{]line*4}+32+2
]line equ ]line+1
--^
rts

View File

@ -1,123 +0,0 @@
; _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