mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-12-29 09:33:23 +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
|
||||
|
||||
:dyn lda #0 ; Initialize with Tile 0
|
||||
ldy #DynOverZA
|
||||
ldy #FastProcs
|
||||
jsr _SetTileProcs
|
||||
|
||||
:out
|
||||
@ -274,8 +274,8 @@ _SetTile
|
||||
; 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
|
||||
:setTileDyn
|
||||
brk $55
|
||||
ldy #DynProcs
|
||||
|
||||
; ldy #DynProcs
|
||||
lda procIdx
|
||||
jsr _SetTileProcs
|
||||
jmp _PushDirtyTileX
|
||||
@ -350,26 +350,42 @@ _SetTileProcs
|
||||
;
|
||||
; <MODE><Over|Under><Z|N><A|V>
|
||||
FastProcs
|
||||
FastOverZA dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
|
||||
FastOverZV dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
|
||||
FastOverNA dw _TBCopyDataAFast,GenericOverAFast,_OneSpriteFastOverA
|
||||
FastOverNV dw _TBCopyDataVFast,GenericOverVFast,_OneSpriteFastOverV
|
||||
FastUnderZA dw _TBConstTile0,GenericUnderZero,GenericUnderZero
|
||||
FastUnderZV dw _TBConstTile0,GenericUnderZero,GenericUnderZero
|
||||
FastUnderNA dw _TBCopyDataAFast,GenericUnderAFast,_OneSpriteFastUnderA
|
||||
FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV
|
||||
;FastUnderNA dw _TBCopyDataFast,GenericUnderAFast,_OneSpriteFastUnderA
|
||||
;FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV
|
||||
FastOverZA dw ConstTile0Fast,SpriteOver0Fast,OneSpriteFastOver0
|
||||
FastOverZV dw ConstTile0Fast,SpriteOver0Fast,OneSpriteFastOver0
|
||||
FastOverNA dw CopyTileAFast,SpriteOverAFast,OneSpriteFastOverA
|
||||
FastOverNV dw CopyTileVFast,SpriteOverVFast,OneSpriteFastOverV
|
||||
FastUnderZA dw ConstTile0Fast,SpriteUnder0Fast,SpriteUnder0Fast
|
||||
FastUnderZV dw ConstTile0Fast,SpriteUnder0Fast,SpriteUnder0Fast
|
||||
FastUnderNA dw CopyTileAFast,SpriteUnderAFast,OneSpriteFastUnderA
|
||||
FastUnderNV dw CopyTileVFast,SpriteUnderVFast,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
|
||||
;
|
||||
|
@ -365,6 +365,7 @@ _TSGetSeconds
|
||||
put Render.s
|
||||
put render/Render.s
|
||||
put render/Fast.s
|
||||
put render/Slow.s
|
||||
put render/Sprite1.s
|
||||
put render/Sprite2.s
|
||||
put tiles/DirtyTileQueue.s
|
||||
|
@ -84,8 +84,7 @@ _TBCopyTileMaskToCBuffV
|
||||
; _TBConstTile
|
||||
;
|
||||
; 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
|
||||
_TBConstTile0
|
||||
; fill in solid colors, so there are no specialized horizontal or verical flipped variants
|
||||
_TBConstTileX
|
||||
lda #0
|
||||
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
|
||||
; register value. This must be restored prior to returning
|
||||
_TBCopyDataFast
|
||||
_TBCopyDataAFast
|
||||
CopyTileAFast
|
||||
tax
|
||||
_TBCopyDataFastX
|
||||
_CopyTileAFast
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4},x
|
||||
@ -55,25 +54,14 @@ _TBCopyDataFastX
|
||||
plb
|
||||
rts
|
||||
|
||||
_TBCopyDataSlow
|
||||
CopyTileASlow
|
||||
tax
|
||||
jsr _TBFillPEAOpcode
|
||||
jmp _TBCopyDataFastX
|
||||
jsr FillPEAOpcode
|
||||
jmp _CopyTileAFast
|
||||
|
||||
_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
|
||||
|
||||
_TBCopyDataVFast
|
||||
CopyTileVFast
|
||||
tax
|
||||
_TBCopyDataVFastX
|
||||
_CopyTileVFast
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
@ -87,10 +75,24 @@ _TBCopyDataVFastX
|
||||
plb
|
||||
rts
|
||||
|
||||
_TBCopyDataVSlow
|
||||
CopyTileVSlow
|
||||
tax
|
||||
jsr _TBFillPEAOpcode
|
||||
jmp _TBCopyDataVFastX
|
||||
jsr FillPEAOpcode
|
||||
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
|
||||
]src equ 7
|
||||
|
@ -2,13 +2,29 @@
|
||||
; 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
|
||||
; 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
|
||||
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
|
||||
@ -16,6 +32,7 @@ GenericOverAFast
|
||||
tax
|
||||
plb
|
||||
|
||||
_SpriteOverAFast ; Alternate entry point for the "Slow" routines
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal tiledata+{]line*4},x
|
||||
@ -33,7 +50,7 @@ GenericOverAFast
|
||||
plb
|
||||
rts
|
||||
|
||||
GenericOverVFast
|
||||
SpriteOverVFast
|
||||
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
|
||||
@ -41,6 +58,7 @@ GenericOverVFast
|
||||
tax
|
||||
plb
|
||||
|
||||
_SpriteOverVFast
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
@ -59,12 +77,13 @@ GenericOverVFast
|
||||
plb
|
||||
rts
|
||||
|
||||
GenericOverZero
|
||||
SpriteOver0Fast
|
||||
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
|
||||
|
||||
_SpriteOver0Fast
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda tmp_sprite_data+{]line*4}
|
||||
@ -78,7 +97,7 @@ GenericOverZero
|
||||
plb
|
||||
rts
|
||||
|
||||
GenericUnderAFast
|
||||
SpriteUnderAFast
|
||||
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
|
||||
@ -86,6 +105,7 @@ GenericUnderAFast
|
||||
tax
|
||||
plb
|
||||
|
||||
_SpriteUnderAFast
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda tmp_sprite_data+{]line*4}
|
||||
@ -103,7 +123,7 @@ GenericUnderAFast
|
||||
plb
|
||||
rts
|
||||
|
||||
GenericUnderVFast
|
||||
SpriteUnderVFast
|
||||
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
|
||||
@ -111,6 +131,7 @@ GenericUnderVFast
|
||||
tax
|
||||
plb
|
||||
|
||||
_SpriteUnderVFast
|
||||
]src equ 7
|
||||
]dest equ 0
|
||||
lup 8
|
||||
@ -130,13 +151,14 @@ GenericUnderVFast
|
||||
plb
|
||||
rts
|
||||
|
||||
GenericUnderZero
|
||||
SpriteUnder0Fast
|
||||
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
|
||||
lda #0
|
||||
|
||||
_SpriteUnder0Fast
|
||||
lda #0
|
||||
]line equ 0
|
||||
lup 8
|
||||
sta: $0004+{]line*$1000},y
|
||||
|
@ -34,32 +34,6 @@ ThreeSprites tyx
|
||||
FourSprites tyx
|
||||
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
|
||||
; must be set to the TileData bank in entry.
|
||||
@ -77,54 +51,6 @@ CopyTileDataToDPA
|
||||
--^
|
||||
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
|
||||
; code field
|
||||
|
@ -6,46 +6,81 @@
|
||||
; 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
|
||||
|
||||
GenericOverSlow
|
||||
ConstTile0Slow
|
||||
jsr FillPEAOpcode
|
||||
jmp ConstTile0Fast
|
||||
|
||||
SpriteOverASlow
|
||||
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 _SpriteOverAFast
|
||||
|
||||
]line equ 0
|
||||
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
|
||||
SpriteOverVSlow
|
||||
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 _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
|
||||
lup 8
|
||||
lda tmp_sprite_data+{]line*4}
|
||||
andl tiledata+{]line*4}+32,x
|
||||
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
|
||||
sta: $0000+{]line*$1000},y
|
||||
sta: $0003+{]line*$1000},y
|
||||
]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
|
||||
; 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
|
||||
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
|
||||
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
||||
plb ; set to the code field bank
|
||||
|
||||
_OneSpriteFastOver0
|
||||
]line equ 0
|
||||
lup 8
|
||||
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
|
||||
; X-register, so it already points to the TileStore
|
||||
|
||||
_OneSpriteFastOverV
|
||||
OneSpriteFastOverV
|
||||
jsr FastCopyTileDataV
|
||||
bra _OneSpriteFastOver
|
||||
|
||||
_OneSpriteFastOverA
|
||||
OneSpriteFastOverA
|
||||
jsr FastCopyTileDataA
|
||||
|
||||
_OneSpriteFastOver
|
||||
@ -44,6 +45,8 @@ _OneSpriteFastOver
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
|
||||
_OneSpriteFastOverA
|
||||
_OneSpriteFastOverV
|
||||
]line equ 0
|
||||
lup 8
|
||||
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.
|
||||
|
||||
_OneSpriteSlowOver0
|
||||
OneSpriteSlowOver0
|
||||
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.
|
||||
ldy TileStore+TS_CODE_ADDR_LOW,x ; load the address of the code field
|
||||
tax ; VBuff address from SpriteBitsToVBuffAddrs macro
|
||||
plb ; set to the code field bank
|
||||
|
||||
]line equ 0
|
||||
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
|
||||
jsr FillPEAOpcode
|
||||
jmp _OneSpriteFastOver0
|
||||
|
||||
; Slow variant for regular tile.
|
||||
|
||||
_OneSpriteSlowOver
|
||||
jsr CopyTileDataToDPA
|
||||
|
||||
OneSpriteSlowOverV
|
||||
jsr FastCopyTileDataV
|
||||
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
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
jsr FillPEAOpcode
|
||||
jmp _OneSpriteFastOverV
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda tmp_tile_data+{]line*4}
|
||||
andl spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
oral spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta: $0004+{]line*$1000},y
|
||||
|
||||
lda tmp_tile_data+{]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
|
||||
--^
|
||||
|
||||
; 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
|
||||
OneSpriteSlowOverA
|
||||
jsr FastCopyTileDataA
|
||||
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
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
jsr FillPEAOpcode
|
||||
jmp _OneSpriteFastOverA
|
||||
|
||||
;------------------------------
|
||||
; Section: Below Tile Renderers
|
||||
|
||||
; Drawing under the zero tile is the same as not drawing a sprite fo both the fast and slow cases
|
||||
_OneSpriteFastUnderA
|
||||
OneSpriteFastUnderA
|
||||
jsr FastCopyTileDataAndMaskA
|
||||
bra _OneSpriteFastUnder
|
||||
|
||||
_OneSpriteFastUnderV
|
||||
OneSpriteFastUnderV
|
||||
jsr FastCopyTileDataAndMaskV
|
||||
|
||||
_OneSpriteFastUnder
|
||||
@ -138,6 +113,8 @@ _OneSpriteFastUnder
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
|
||||
_OneSpriteFastUnderA
|
||||
_OneSpriteFastUnderV
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
@ -155,23 +132,22 @@ _OneSpriteFastUnder
|
||||
plb
|
||||
rts
|
||||
|
||||
_OneSpriteSlowUnder0
|
||||
OneSpriteSlowUnderA
|
||||
jsr FastCopyTileDataAndMaskA
|
||||
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 ; load the address of this tile's data (pre-calculated)
|
||||
plb ; set the code field bank
|
||||
jmp (K_TS_BASE_TILE_DISP,x) ; go to the tile copy routine
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
jsr FillPEAOpcode
|
||||
jmp _OneSpriteFastUnderA
|
||||
|
||||
;--------------------------------
|
||||
; Helper functions for one Sprite
|
||||
CopyOneSpriteDataToDP
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
sta tmp_sprite_data+{]line*4}
|
||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
sta tmp_sprite_data+{]line*4}+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
||||
OneSpriteSlowUnderV
|
||||
jsr FastCopyTileDataAndMaskV
|
||||
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
|
||||
ldx sprite_ptr0
|
||||
plb
|
||||
jsr FillPEAOpcode
|
||||
jmp _OneSpriteFastUnderV
|
||||
|
@ -1,13 +1,4 @@
|
||||
; Specialize routines for handling two sprites. Like Sprite3.s and Sprite4.s there are four
|
||||
; 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
|
||||
<<<
|
||||
|
||||
; Specialize routines for handling two sprites.
|
||||
TwoSpriteData mac
|
||||
lda (sprite_ptr1),y
|
||||
db $37,sprite_ptr0 ; and [sprite_ptr0],y
|
||||
@ -19,68 +10,6 @@ TwoSpriteMask mac
|
||||
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
|
||||
CopyThreeSpritesDataAndMaskToDP
|
||||
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…
Reference in New Issue
Block a user