mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-01-16 23:29:54 +00:00
Remove dead code and implement Slow tile renderers in terms of the Fast once to avoid code bloat
This commit is contained in:
parent
2820d318a0
commit
a91f39aab8
60
src/Tiles.s
60
src/Tiles.s
@ -119,7 +119,7 @@ InitTiles
|
|||||||
bra :out
|
bra :out
|
||||||
|
|
||||||
:dyn lda #0 ; Initialize with Tile 0
|
:dyn lda #0 ; Initialize with Tile 0
|
||||||
ldy #DynOverZA
|
ldy #FastProcs
|
||||||
jsr _SetTileProcs
|
jsr _SetTileProcs
|
||||||
|
|
||||||
:out
|
:out
|
||||||
@ -274,8 +274,8 @@ _SetTile
|
|||||||
; are both Dynamic tiles or both Basic tiles, then we can use an optimized routine. Otherwise
|
; are both Dynamic tiles or both Basic tiles, then we can use an optimized routine. Otherwise
|
||||||
; we must set the opcodes as well as the operands
|
; we must set the opcodes as well as the operands
|
||||||
:setTileDyn
|
:setTileDyn
|
||||||
brk $55
|
|
||||||
ldy #DynProcs
|
; ldy #DynProcs
|
||||||
lda procIdx
|
lda procIdx
|
||||||
jsr _SetTileProcs
|
jsr _SetTileProcs
|
||||||
jmp _PushDirtyTileX
|
jmp _PushDirtyTileX
|
||||||
@ -350,26 +350,42 @@ _SetTileProcs
|
|||||||
;
|
;
|
||||||
; <MODE><Over|Under><Z|N><A|V>
|
; <MODE><Over|Under><Z|N><A|V>
|
||||||
FastProcs
|
FastProcs
|
||||||
FastOverZA dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
|
FastOverZA dw ConstTile0Fast,SpriteOver0Fast,OneSpriteFastOver0
|
||||||
FastOverZV dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
|
FastOverZV dw ConstTile0Fast,SpriteOver0Fast,OneSpriteFastOver0
|
||||||
FastOverNA dw _TBCopyDataAFast,GenericOverAFast,_OneSpriteFastOverA
|
FastOverNA dw CopyTileAFast,SpriteOverAFast,OneSpriteFastOverA
|
||||||
FastOverNV dw _TBCopyDataVFast,GenericOverVFast,_OneSpriteFastOverV
|
FastOverNV dw CopyTileVFast,SpriteOverVFast,OneSpriteFastOverV
|
||||||
FastUnderZA dw _TBConstTile0,GenericUnderZero,GenericUnderZero
|
FastUnderZA dw ConstTile0Fast,SpriteUnder0Fast,SpriteUnder0Fast
|
||||||
FastUnderZV dw _TBConstTile0,GenericUnderZero,GenericUnderZero
|
FastUnderZV dw ConstTile0Fast,SpriteUnder0Fast,SpriteUnder0Fast
|
||||||
FastUnderNA dw _TBCopyDataAFast,GenericUnderAFast,_OneSpriteFastUnderA
|
FastUnderNA dw CopyTileAFast,SpriteUnderAFast,OneSpriteFastUnderA
|
||||||
FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV
|
FastUnderNV dw CopyTileVFast,SpriteUnderVFast,OneSpriteFastUnderV
|
||||||
;FastUnderNA dw _TBCopyDataFast,GenericUnderAFast,_OneSpriteFastUnderA
|
|
||||||
;FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV
|
; "Slow" procs. These are duplicates of the "Fast" functions, but also
|
||||||
|
; set the PEA opcode in all cases.
|
||||||
|
SlowProcs
|
||||||
|
SlowOverZA dw ConstTile0Slow,SpriteOver0Slow,OneSpriteSlowOver0
|
||||||
|
SlowOverZV dw ConstTile0Slow,SpriteOver0Slow,OneSpriteSlowOver0
|
||||||
|
SlowOverNA dw CopyTileASlow,SpriteOverASlow,OneSpriteSlowOverA
|
||||||
|
SlowOverNV dw CopyTileVSlow,SpriteOverVSlow,OneSpriteSlowOverV
|
||||||
|
SlowUnderZA dw ConstTile0Slow,SpriteUnder0Slow,SpriteUnder0Slow
|
||||||
|
SlowUnderZV dw ConstTile0Slow,SpriteUnder0Slow,SpriteUnder0Slow
|
||||||
|
SlowUnderNA dw CopyTileASlow,SpriteUnderASlow,OneSpriteSlowUnderA
|
||||||
|
SlowUnderNV dw CopyTileVSlow,SpriteUnderVSlow,OneSpriteSlowUnderV
|
||||||
|
|
||||||
|
; "Dynamic" procs. These are the specialized routines for a dynamic tiles
|
||||||
|
; that does not need to worry about a second background. Because dynamic
|
||||||
|
; tiles don't support horizontal or vertical flipping, there are only two
|
||||||
|
; sets of procedures: one for Over and one for Under.
|
||||||
|
;DynOver dw _TBDynamicTile,DynamicOver,_OneSpriteDynamicOver
|
||||||
|
;DynUnder dw _TBDynamicTile,DynamicUnder,_OneSpriteDynamicUnder
|
||||||
|
|
||||||
|
; "Two Layer" procs. These are the most complex procs. Generally,
|
||||||
|
; all of these methods are implemented by building up the data
|
||||||
|
; and mask into the direct page space and then calling a common
|
||||||
|
; function to create the complex code fragments in the code field.
|
||||||
|
; There is not a lot of opportuinity to optimize these routines.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DynProcs
|
|
||||||
DynOverZA
|
|
||||||
DynOverZV
|
|
||||||
DynOverNA
|
|
||||||
DynOverNV
|
|
||||||
DynUnderZA
|
|
||||||
DynUnderZV
|
|
||||||
DynUnderNA
|
|
||||||
DynUnderNV
|
|
||||||
|
|
||||||
; SetBG0XPos
|
; SetBG0XPos
|
||||||
;
|
;
|
||||||
|
@ -365,6 +365,7 @@ _TSGetSeconds
|
|||||||
put Render.s
|
put Render.s
|
||||||
put render/Render.s
|
put render/Render.s
|
||||||
put render/Fast.s
|
put render/Fast.s
|
||||||
|
put render/Slow.s
|
||||||
put render/Sprite1.s
|
put render/Sprite1.s
|
||||||
put render/Sprite2.s
|
put render/Sprite2.s
|
||||||
put tiles/DirtyTileQueue.s
|
put tiles/DirtyTileQueue.s
|
||||||
|
@ -84,8 +84,7 @@ _TBCopyTileMaskToCBuffV
|
|||||||
; _TBConstTile
|
; _TBConstTile
|
||||||
;
|
;
|
||||||
; A specialized routine that fills in a tile with a single constant value. It's intended to be used to
|
; A specialized routine that fills in a tile with a single constant value. It's intended to be used to
|
||||||
; fill in solid colors, so there are no specialized horizontal or verical flipped variantsConstUnderZero
|
; fill in solid colors, so there are no specialized horizontal or verical flipped variants
|
||||||
_TBConstTile0
|
|
||||||
_TBConstTileX
|
_TBConstTileX
|
||||||
lda #0
|
lda #0
|
||||||
sta: $0001,y
|
sta: $0001,y
|
||||||
|
@ -40,10 +40,9 @@ _TBSolidTile_VH
|
|||||||
|
|
||||||
; This is called via a JMP (abs,x) with an extra byte on the stack that holds the bank
|
; This is called via a JMP (abs,x) with an extra byte on the stack that holds the bank
|
||||||
; register value. This must be restored prior to returning
|
; register value. This must be restored prior to returning
|
||||||
_TBCopyDataFast
|
CopyTileAFast
|
||||||
_TBCopyDataAFast
|
|
||||||
tax
|
tax
|
||||||
_TBCopyDataFastX
|
_CopyTileAFast
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
ldal tiledata+{]line*4},x
|
ldal tiledata+{]line*4},x
|
||||||
@ -55,25 +54,14 @@ _TBCopyDataFastX
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBCopyDataSlow
|
CopyTileASlow
|
||||||
tax
|
tax
|
||||||
jsr _TBFillPEAOpcode
|
jsr FillPEAOpcode
|
||||||
jmp _TBCopyDataFastX
|
jmp _CopyTileAFast
|
||||||
|
|
||||||
_TBCopyData
|
CopyTileVFast
|
||||||
]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
|
|
||||||
|
|
||||||
_TBCopyDataVFast
|
|
||||||
tax
|
tax
|
||||||
_TBCopyDataVFastX
|
_CopyTileVFast
|
||||||
]src equ 7
|
]src equ 7
|
||||||
]dest equ 0
|
]dest equ 0
|
||||||
lup 8
|
lup 8
|
||||||
@ -87,10 +75,24 @@ _TBCopyDataVFastX
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBCopyDataVSlow
|
CopyTileVSlow
|
||||||
tax
|
tax
|
||||||
jsr _TBFillPEAOpcode
|
jsr FillPEAOpcode
|
||||||
jmp _TBCopyDataVFastX
|
jmp _CopyTileVFast
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; 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
|
_TBCopyDataV
|
||||||
]src equ 7
|
]src equ 7
|
||||||
|
@ -2,13 +2,29 @@
|
|||||||
; there are no dynamic tile or two layer tiles enabled, so all of the tiles are comprised
|
; there are no dynamic tile or two layer tiles enabled, so all of the tiles are comprised
|
||||||
; of PEA opcodes. These functions take advantage of this as the fact that masks are
|
; of PEA opcodes. These functions take advantage of this as the fact that masks are
|
||||||
; not needed to improve rendering speed.
|
; not needed to improve rendering speed.
|
||||||
;
|
|
||||||
; The following functions are defined here
|
|
||||||
;
|
|
||||||
; GenericOverAFast : Places data from tmp_sprite_data on top of the TileStore's tile
|
|
||||||
; GenericUnderAFast : Places the TileStore's tile on top of tmp_sprite_data
|
|
||||||
|
|
||||||
GenericOverAFast
|
ConstTile0Fast
|
||||||
|
lda #0
|
||||||
|
sta: $0001,y
|
||||||
|
sta: $0004,y
|
||||||
|
sta $1001,y
|
||||||
|
sta $1004,y
|
||||||
|
sta $2001,y
|
||||||
|
sta $2004,y
|
||||||
|
sta $3001,y
|
||||||
|
sta $3004,y
|
||||||
|
sta $4001,y
|
||||||
|
sta $4004,y
|
||||||
|
sta $5001,y
|
||||||
|
sta $5004,y
|
||||||
|
sta $6001,y
|
||||||
|
sta $6004,y
|
||||||
|
sta $7001,y
|
||||||
|
sta $7004,y
|
||||||
|
plb
|
||||||
|
rts
|
||||||
|
|
||||||
|
SpriteOverAFast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
@ -16,6 +32,7 @@ GenericOverAFast
|
|||||||
tax
|
tax
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_SpriteOverAFast ; Alternate entry point for the "Slow" routines
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
ldal tiledata+{]line*4},x
|
ldal tiledata+{]line*4},x
|
||||||
@ -33,7 +50,7 @@ GenericOverAFast
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
GenericOverVFast
|
SpriteOverVFast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
@ -41,6 +58,7 @@ GenericOverVFast
|
|||||||
tax
|
tax
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_SpriteOverVFast
|
||||||
]src equ 7
|
]src equ 7
|
||||||
]dest equ 0
|
]dest equ 0
|
||||||
lup 8
|
lup 8
|
||||||
@ -59,12 +77,13 @@ GenericOverVFast
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
GenericOverZero
|
SpriteOver0Fast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_SpriteOver0Fast
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
lda tmp_sprite_data+{]line*4}
|
lda tmp_sprite_data+{]line*4}
|
||||||
@ -78,7 +97,7 @@ GenericOverZero
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
GenericUnderAFast
|
SpriteUnderAFast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
@ -86,6 +105,7 @@ GenericUnderAFast
|
|||||||
tax
|
tax
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_SpriteUnderAFast
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
lda tmp_sprite_data+{]line*4}
|
lda tmp_sprite_data+{]line*4}
|
||||||
@ -103,7 +123,7 @@ GenericUnderAFast
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
GenericUnderVFast
|
SpriteUnderVFast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
@ -111,6 +131,7 @@ GenericUnderVFast
|
|||||||
tax
|
tax
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_SpriteUnderVFast
|
||||||
]src equ 7
|
]src equ 7
|
||||||
]dest equ 0
|
]dest equ 0
|
||||||
lup 8
|
lup 8
|
||||||
@ -130,13 +151,14 @@ GenericUnderVFast
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
GenericUnderZero
|
SpriteUnder0Fast
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
plb
|
plb
|
||||||
lda #0
|
|
||||||
|
|
||||||
|
_SpriteUnder0Fast
|
||||||
|
lda #0
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
sta: $0004+{]line*$1000},y
|
sta: $0004+{]line*$1000},y
|
||||||
|
@ -34,32 +34,6 @@ ThreeSprites tyx
|
|||||||
FourSprites tyx
|
FourSprites tyx
|
||||||
jmp CopyFourSpritesDataAndMaskToDP
|
jmp CopyFourSpritesDataAndMaskToDP
|
||||||
|
|
||||||
; Helper functions (and macros)
|
|
||||||
|
|
||||||
; CopyTileToDP -- executes the K_TS_COPY_TILE_DATA routine. This may copy just data or data+mask
|
|
||||||
; information to the direct page
|
|
||||||
_CopyTileToDP mac
|
|
||||||
ldy TileStore+TS_TILE_ADDR,x ; load the tile address
|
|
||||||
pei DP2_TILEDATA_AND_TILESTORE_BANKS
|
|
||||||
plb ; set to the tiledata bank
|
|
||||||
jsr (K_TS_COPY_TILE_DATA,x) ; preserves X-reg
|
|
||||||
plb
|
|
||||||
<<<
|
|
||||||
CopyTileToDP
|
|
||||||
_CopyTileToDP
|
|
||||||
rts
|
|
||||||
|
|
||||||
; CopyTileToDPSprite -- same as above, but returns with the Data BAnk set to the sprite data bank
|
|
||||||
_CopyTileToDPSprite mac
|
|
||||||
ldy TileStore+TS_TILE_ADDR,x ; load the tile address
|
|
||||||
pei DP2_TILEDATA_AND_SPRITEDATA_BANKS
|
|
||||||
plb ; set to the tiledata bank
|
|
||||||
jsr (K_TS_COPY_TILE_DATA,x) ; preserves X-reg
|
|
||||||
plb
|
|
||||||
<<<
|
|
||||||
CopyTileToDPSprite
|
|
||||||
_CopyTileToDPSprite
|
|
||||||
rts
|
|
||||||
|
|
||||||
; Simple pair of routines that copies just the tile data to the direct page workspace. Data Bank
|
; Simple pair of routines that copies just the tile data to the direct page workspace. Data Bank
|
||||||
; must be set to the TileData bank in entry.
|
; must be set to the TileData bank in entry.
|
||||||
@ -77,54 +51,6 @@ CopyTileDataToDPA
|
|||||||
--^
|
--^
|
||||||
rts
|
rts
|
||||||
|
|
||||||
CopyTileDataToDPV
|
|
||||||
]src equ 7
|
|
||||||
]dest equ 0
|
|
||||||
lup 8
|
|
||||||
lda tiledata+{]src*4},y
|
|
||||||
sta tmp_tile_data+{]dest*4}
|
|
||||||
|
|
||||||
lda tiledata+{]src*4}+2,y
|
|
||||||
sta tmp_tile_data+{]dest*4}+2
|
|
||||||
]src equ ]src-1
|
|
||||||
]dest equ ]dest+1
|
|
||||||
--^
|
|
||||||
rts
|
|
||||||
|
|
||||||
; Copy both the tile and mask data to the driect page space
|
|
||||||
_CopyTileDataAndMaskToDP
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
lda tiledata+{]line*4},y
|
|
||||||
sta tmp_tile_data+{]line*4}
|
|
||||||
lda tiledata+{]line*4}+32,y
|
|
||||||
sta tmp_tile_mask+{]line*4}
|
|
||||||
|
|
||||||
lda tiledata+{]line*4}+2,y
|
|
||||||
sta tmp_tile_data+{]line*4}+2
|
|
||||||
lda tiledata+{]line*4}+32+2,y
|
|
||||||
sta tmp_tile_mask+{]line*4}+2
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
rts
|
|
||||||
|
|
||||||
_CopyTileDataAndMaskToDPV
|
|
||||||
]src equ 7
|
|
||||||
]dest equ 0
|
|
||||||
lup 8
|
|
||||||
lda tiledata+{]src*4},y
|
|
||||||
sta tmp_tile_data+{]dest*4}
|
|
||||||
lda tiledata+{]src*4}+32,y
|
|
||||||
sta tmp_tile_mask+{]dest*4}
|
|
||||||
|
|
||||||
lda tiledata+{]src*4}+2,y
|
|
||||||
sta tmp_tile_data+{]dest*4}+2
|
|
||||||
lda tiledata+{]src*4}+32+2,y
|
|
||||||
sta tmp_tile_mask+{]dest*4}+2
|
|
||||||
]src equ ]src-1
|
|
||||||
]dest equ ]dest+1
|
|
||||||
--^
|
|
||||||
rts
|
|
||||||
|
|
||||||
; Given a populate tmp_sprite_data buffer to use as a base, merge it with a tile and write to the
|
; Given a populate tmp_sprite_data buffer to use as a base, merge it with a tile and write to the
|
||||||
; code field
|
; code field
|
||||||
|
@ -6,46 +6,81 @@
|
|||||||
; GenericOverSlow : Places data from tmp_sprite_data on top of the TileStore's tile
|
; GenericOverSlow : Places data from tmp_sprite_data on top of the TileStore's tile
|
||||||
; GenericUnderSlow : Places the TileStore's tile on top of tmp_sprite_data
|
; GenericUnderSlow : Places the TileStore's tile on top of tmp_sprite_data
|
||||||
|
|
||||||
GenericOverSlow
|
ConstTile0Slow
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp ConstTile0Fast
|
||||||
|
|
||||||
|
SpriteOverASlow
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
lda TileStore+TS_TILE_ADDR,x
|
lda TileStore+TS_TILE_ADDR,x
|
||||||
tax
|
tax
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteOverAFast
|
||||||
|
|
||||||
]line equ 0
|
SpriteOverVSlow
|
||||||
lup 8
|
|
||||||
ldal tiledata+{]line*4},x
|
|
||||||
and tmp_sprite_mask+{]line*4}
|
|
||||||
ora tmp_sprite_data+{]line*4}
|
|
||||||
sta: $0004+{]line*$1000},y
|
|
||||||
|
|
||||||
ldal tiledata+{]line*4}+2,x
|
|
||||||
and tmp_sprite_mask+{]line*4}+2
|
|
||||||
ora tmp_sprite_data+{]line*4}+2
|
|
||||||
sta: $0001+{]line*$1000},y
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
jmp _FillPEAOpcode
|
|
||||||
|
|
||||||
GenericUnderSlow
|
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
lda TileStore+TS_TILE_ADDR,x
|
lda TileStore+TS_TILE_ADDR,x
|
||||||
tax
|
tax
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteOverVFast
|
||||||
|
|
||||||
|
SpriteOver0Slow
|
||||||
|
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
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteOver0Fast
|
||||||
|
|
||||||
|
SpriteUnderASlow
|
||||||
|
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
|
||||||
|
lda TileStore+TS_TILE_ADDR,x
|
||||||
|
tax
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteUnderAFast
|
||||||
|
|
||||||
|
SpriteUnderVSlow
|
||||||
|
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
|
||||||
|
lda TileStore+TS_TILE_ADDR,x
|
||||||
|
tax
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteUnderVFast
|
||||||
|
|
||||||
|
SpriteUnder0Slow
|
||||||
|
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
|
||||||
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _SpriteUnder0Fast
|
||||||
|
|
||||||
|
; Helper function; no stack manipulation
|
||||||
|
FillPEAOpcode
|
||||||
|
sep #$20
|
||||||
|
lda #$F4
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
lda tmp_sprite_data+{]line*4}
|
sta: $0000+{]line*$1000},y
|
||||||
andl tiledata+{]line*4}+32,x
|
sta: $0003+{]line*$1000},y
|
||||||
oral tiledata+{]line*4}+32,x
|
|
||||||
sta: $0004+{]line*$1000},y
|
|
||||||
|
|
||||||
lda tmp_sprite_data+{]line*4}+2
|
|
||||||
andl tiledata+{]line*4}+32+2,x
|
|
||||||
oral tiledata+{]line*4}+32+2,x
|
|
||||||
sta: $0001+{]line*$1000},y
|
|
||||||
]line equ ]line+1
|
]line equ ]line+1
|
||||||
--^
|
--^
|
||||||
jmp _FillPEAOpcode
|
rep #$20
|
||||||
|
rts
|
||||||
|
|
||||||
|
; This is a dtub; will be removed eventually
|
||||||
|
_FillPEAOpcode
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
plb ; Restore the TileStore bank
|
||||||
|
rts
|
@ -8,13 +8,14 @@
|
|||||||
; The simplest implementation. When drawing a sprite over Tile 0 in FAST mode, we can just copy the
|
; 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.
|
; sprite data into the coe field directly.
|
||||||
|
|
||||||
_OneSpriteFastOver0
|
OneSpriteFastOver0
|
||||||
ldy TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
||||||
plb ; set to the code field bank
|
plb ; set to the code field bank
|
||||||
|
|
||||||
|
_OneSpriteFastOver0
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||||
@ -30,11 +31,11 @@ _OneSpriteFastOver0
|
|||||||
; Next implementation; drawing a sprite onto a regular tile. The 1-sprite dispatch preerves the
|
; Next implementation; drawing a sprite onto a regular tile. The 1-sprite dispatch preerves the
|
||||||
; X-register, so it already points to the TileStore
|
; X-register, so it already points to the TileStore
|
||||||
|
|
||||||
_OneSpriteFastOverV
|
OneSpriteFastOverV
|
||||||
jsr FastCopyTileDataV
|
jsr FastCopyTileDataV
|
||||||
bra _OneSpriteFastOver
|
bra _OneSpriteFastOver
|
||||||
|
|
||||||
_OneSpriteFastOverA
|
OneSpriteFastOverA
|
||||||
jsr FastCopyTileDataA
|
jsr FastCopyTileDataA
|
||||||
|
|
||||||
_OneSpriteFastOver
|
_OneSpriteFastOver
|
||||||
@ -44,6 +45,8 @@ _OneSpriteFastOver
|
|||||||
ldx sprite_ptr0
|
ldx sprite_ptr0
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_OneSpriteFastOverA
|
||||||
|
_OneSpriteFastOverV
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
lda tmp_tile_data+{]line*4}
|
lda tmp_tile_data+{]line*4}
|
||||||
@ -62,73 +65,45 @@ _OneSpriteFastOver
|
|||||||
|
|
||||||
; This is the "SLOW" variant that fills in the PEA opcode specialized for Tile 0.
|
; This is the "SLOW" variant that fills in the PEA opcode specialized for Tile 0.
|
||||||
|
|
||||||
_OneSpriteSlowOver0
|
OneSpriteSlowOver0
|
||||||
ldy TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
||||||
plb ; set to the code field bank
|
plb ; set to the code field bank
|
||||||
|
jsr FillPEAOpcode
|
||||||
]line equ 0
|
jmp _OneSpriteFastOver0
|
||||||
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
|
|
||||||
--^
|
|
||||||
|
|
||||||
jmp _FillPEAOpcode
|
|
||||||
|
|
||||||
; Slow variant for regular tile.
|
; Slow variant for regular tile.
|
||||||
|
OneSpriteSlowOverV
|
||||||
_OneSpriteSlowOver
|
jsr FastCopyTileDataV
|
||||||
jsr CopyTileDataToDPA
|
|
||||||
|
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
ldx sprite_ptr0
|
ldx sprite_ptr0
|
||||||
plb
|
plb
|
||||||
|
jsr FillPEAOpcode
|
||||||
|
jmp _OneSpriteFastOverV
|
||||||
|
|
||||||
]line equ 0
|
OneSpriteSlowOverA
|
||||||
lup 8
|
jsr FastCopyTileDataA
|
||||||
lda tmp_tile_data+{]line*4}
|
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
||||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
pha ; and put on the stack for later. Has TileStore bank in high byte.
|
||||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
sta: $0004+{]line*$1000},y
|
ldx sprite_ptr0
|
||||||
|
plb
|
||||||
lda tmp_tile_data+{]line*4}+2
|
jsr FillPEAOpcode
|
||||||
andl spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
jmp _OneSpriteFastOverA
|
||||||
oral spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
|
||||||
sta: $0001+{]line*$1000},y
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
|
|
||||||
; Fall through here to give the common case a small boost
|
|
||||||
_FillPEAOpcode
|
|
||||||
sep #$20
|
|
||||||
lda #$F4
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
sta: $0000+{]line*$1000},y
|
|
||||||
sta: $0003+{]line*$1000},y
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
rep #$20
|
|
||||||
|
|
||||||
plb ; Restore the TileStore bank
|
|
||||||
rts
|
|
||||||
|
|
||||||
;------------------------------
|
;------------------------------
|
||||||
; Section: Below Tile Renderers
|
; Section: Below Tile Renderers
|
||||||
|
|
||||||
; Drawing under the zero tile is the same as not drawing a sprite fo both the fast and slow cases
|
; Drawing under the zero tile is the same as not drawing a sprite fo both the fast and slow cases
|
||||||
_OneSpriteFastUnderA
|
OneSpriteFastUnderA
|
||||||
jsr FastCopyTileDataAndMaskA
|
jsr FastCopyTileDataAndMaskA
|
||||||
bra _OneSpriteFastUnder
|
bra _OneSpriteFastUnder
|
||||||
|
|
||||||
_OneSpriteFastUnderV
|
OneSpriteFastUnderV
|
||||||
jsr FastCopyTileDataAndMaskV
|
jsr FastCopyTileDataAndMaskV
|
||||||
|
|
||||||
_OneSpriteFastUnder
|
_OneSpriteFastUnder
|
||||||
@ -138,6 +113,8 @@ _OneSpriteFastUnder
|
|||||||
ldx sprite_ptr0
|
ldx sprite_ptr0
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
_OneSpriteFastUnderA
|
||||||
|
_OneSpriteFastUnderV
|
||||||
]line equ 0
|
]line equ 0
|
||||||
lup 8
|
lup 8
|
||||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||||
@ -155,23 +132,22 @@ _OneSpriteFastUnder
|
|||||||
plb
|
plb
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_OneSpriteSlowUnder0
|
OneSpriteSlowUnderA
|
||||||
|
jsr FastCopyTileDataAndMaskA
|
||||||
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
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.
|
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
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
lda TileStore+TS_TILE_ADDR,x ; load the address of this tile's data (pre-calculated)
|
ldx sprite_ptr0
|
||||||
plb ; set the code field bank
|
plb
|
||||||
jmp (K_TS_BASE_TILE_DISP,x) ; go to the tile copy routine
|
jsr FillPEAOpcode
|
||||||
|
jmp _OneSpriteFastUnderA
|
||||||
|
|
||||||
;--------------------------------
|
OneSpriteSlowUnderV
|
||||||
; Helper functions for one Sprite
|
jsr FastCopyTileDataAndMaskV
|
||||||
CopyOneSpriteDataToDP
|
lda TileStore+TS_CODE_ADDR_HIGH,x ; load the bank of the target code field line
|
||||||
]line equ 0
|
pha ; and put on the stack for later. Has TileStore bank in high byte.
|
||||||
lup 8
|
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
ldx sprite_ptr0
|
||||||
sta tmp_sprite_data+{]line*4}
|
plb
|
||||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
jsr FillPEAOpcode
|
||||||
sta tmp_sprite_data+{]line*4}+2
|
jmp _OneSpriteFastUnderV
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
rts
|
|
||||||
|
@ -1,13 +1,4 @@
|
|||||||
; Specialize routines for handling two sprites. Like Sprite3.s and Sprite4.s there are four
|
; Specialize routines for handling two sprites.
|
||||||
; variants -- one to handle over / under sprite orders and one each for whether the mask needs
|
|
||||||
; to be used or not.
|
|
||||||
TwoSpriteLine mac
|
|
||||||
db $37,sprite_ptr1 ; and [sprite_ptr1],y
|
|
||||||
ora (sprite_ptr1),y
|
|
||||||
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
|
||||||
ora (sprite_ptr0),y
|
|
||||||
<<<
|
|
||||||
|
|
||||||
TwoSpriteData mac
|
TwoSpriteData mac
|
||||||
lda (sprite_ptr1),y
|
lda (sprite_ptr1),y
|
||||||
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
||||||
@ -19,68 +10,6 @@ TwoSpriteMask mac
|
|||||||
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
||||||
<<<
|
<<<
|
||||||
|
|
||||||
TwoSpritesOver
|
|
||||||
tyx ; save after compositing the sprites
|
|
||||||
phb ; save the current bank
|
|
||||||
jsr CopyTileToDPSprite ; copy necessary tile data to the direct page
|
|
||||||
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}
|
|
||||||
lda tmp_tile_data+{]line*4}
|
|
||||||
TwoSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}
|
|
||||||
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}+2
|
|
||||||
lda tmp_tile_data+{]line*4}+2
|
|
||||||
TwoSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}+2
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
|
|
||||||
plb
|
|
||||||
jmp (K_TS_APPLY_TILE_DATA,x)
|
|
||||||
|
|
||||||
|
|
||||||
TwoSpritesUnderFast
|
|
||||||
tyx ; save after compositing the sprites
|
|
||||||
phb ; save the current bank
|
|
||||||
jsr CopyTwoSpritesDataToDP ; copy necessary sprite data to the direct page
|
|
||||||
jmp MergeSpriteWithTileFast
|
|
||||||
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}
|
|
||||||
lda tmp_tile_data+{]line*4}
|
|
||||||
TwoSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}
|
|
||||||
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}+2
|
|
||||||
lda tmp_tile_data+{]line*4}+2
|
|
||||||
TwoSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}+2
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
|
|
||||||
plb
|
|
||||||
jmp (K_TS_APPLY_TILE_DATA,x)
|
|
||||||
|
|
||||||
;---------------------------------
|
|
||||||
; Helper functions for two Sprites
|
|
||||||
CopyTwoSpritesDataToDP
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}
|
|
||||||
TwoSpriteData
|
|
||||||
sta tmp_sprite_data+{]line*4}
|
|
||||||
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}+2
|
|
||||||
TwoSpriteData
|
|
||||||
sta tmp_sprite_data+{]line*4}+2
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
rts
|
|
||||||
|
|
||||||
CopyFourSpritesDataAndMaskToDP
|
CopyFourSpritesDataAndMaskToDP
|
||||||
CopyThreeSpritesDataAndMaskToDP
|
CopyThreeSpritesDataAndMaskToDP
|
||||||
CopyTwoSpritesDataAndMaskToDP
|
CopyTwoSpritesDataAndMaskToDP
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
ThreeSpriteLine mac
|
|
||||||
db $37,sprite_ptr2 ; and [sprite_ptr2],y
|
|
||||||
ora (sprite_ptr2),y
|
|
||||||
db $37,sprite_ptr1 ; and [sprite_ptr1],y
|
|
||||||
ora (sprite_ptr1),y
|
|
||||||
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
|
||||||
ora (sprite_ptr0),y
|
|
||||||
<<<
|
|
||||||
|
|
||||||
; Three sprites wiithout extra masking
|
|
||||||
ThreeSpritesFast
|
|
||||||
tyx ; save for after compositing the sprites
|
|
||||||
|
|
||||||
ldy TileStore+TS_TILE_ADDR,x
|
|
||||||
pei DP2_TILEDATA_AND_SPRITEDATA_BANKS
|
|
||||||
plb ; set to the tiledata bank
|
|
||||||
jsr (K_TS_COPY_TILE_DATA,x)
|
|
||||||
plb ; set to the sprite data bank
|
|
||||||
|
|
||||||
]line equ 0
|
|
||||||
lup 8
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}
|
|
||||||
lda tmp_tile_data+{]line*4}
|
|
||||||
ThreeSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}
|
|
||||||
|
|
||||||
ldy #{]line*SPRITE_PLANE_SPAN}+2
|
|
||||||
lda tmp_tile_data+{]line*4}+2
|
|
||||||
ThreeSpriteLine
|
|
||||||
sta tmp_tile_data+{]line*4}+2
|
|
||||||
]line equ ]line+1
|
|
||||||
--^
|
|
||||||
|
|
||||||
plb
|
|
||||||
jmp _CopyDP2ToCodeField
|
|
Loading…
x
Reference in New Issue
Block a user