Tweaking updated sprite dispatch flow

This commit is contained in:
Lucas Scharenbroich 2022-06-21 07:29:18 -05:00
parent 4ea3033b5e
commit 553fd3c02a
7 changed files with 273 additions and 71 deletions

View File

@ -38,8 +38,6 @@ Flips equ 12
pea #256 pea #256
pea #160 pea #160
; pea #176
; pea #144
_GTESetScreenMode _GTESetScreenMode
; Load a tileset ; Load a tileset
@ -95,58 +93,57 @@ HERO_SPRITE equ SPRITE_16X16+1
cpx #MAX_SPRITES*2 cpx #MAX_SPRITES*2
bcc :sloop bcc :sloop
; Manually fill in the 41x26 tiles of the TileStore with a test pattern of trees ; Manually fill in the 41x26 tiles of the TileStore with a test pattern of trees
;
; Tile 65 Tile 66
; Tile 97 Tile 98
stz 0 ; X
stz 2 ; Y
:tloop jsr _fillTileStore
ldx 0
ldy 2
phx ldx #0
phy ldy #0
pea #65 jsr _drawTree
inx
phx
phy
pea #66
cpy #24 ldx #3
beq :skip_last ldy #0
iny jsr _drawTreeH
phx
phy
pea #98
dex ldx #0
phx ldy #3
phy jsr _drawTreeV
pea #97
_GTESetTile ldx #3
_GTESetTile ldy #3
:skip_last jsr _drawTreeHV
_GTESetTile
_GTESetTile
lda 0 ldx #9
inc ldy #0
inc jsr _drawTree
sta 0
cmp #40
bcc :tloop
stz 0 ldx #9
lda 2 ldy #3
inc jsr _drawTree
inc
sta 2 ldx #12
cmp #25 ldy #0
bcc :tloop jsr _drawTree
ldx #12
ldy #3
jsr _drawTree
ldx #6
ldy #0
jsr _drawTreeFront
ldx #6
ldy #3
jsr _drawTreeFront
ldx #6
ldy #6
jsr _drawTreeFront
ldx #3
ldy #6
jsr _drawTreeFront
ldx #0
ldy #6
jsr _drawTreeFront
; Initialize the frame counter ; Initialize the frame counter
@ -450,6 +447,162 @@ GTEStartUp
:ok3 :ok3
rts rts
_fillTileStore
stz Tmp0
:oloop
stz Tmp1
:iloop
pei Tmp1
pei Tmp0
pea #129
_GTESetTile
lda Tmp1
inc
sta Tmp1
cmp #41
bcc :iloop
lda Tmp0
inc
sta Tmp0
cmp #26
bcc :oloop
rts
; Tile 65 Tile 66
; Tile 97 Tile 98
_drawTreeFront
phx
phy
pea #65+TILE_PRIORITY_BIT
inx
phx
phy
pea #66+TILE_PRIORITY_BIT
iny
phx
phy
pea #98+TILE_PRIORITY_BIT
dex
phx
phy
pea #97+TILE_PRIORITY_BIT
_GTESetTile
_GTESetTile
_GTESetTile
_GTESetTile
rts
_drawTree
phx
phy
pea #65
inx
phx
phy
pea #66
iny
phx
phy
pea #98
dex
phx
phy
pea #97
_GTESetTile
_GTESetTile
_GTESetTile
_GTESetTile
rts
_drawTreeH
phx
phy
pea #66+TILE_HFLIP_BIT
inx
phx
phy
pea #65+TILE_HFLIP_BIT
iny
phx
phy
pea #97+TILE_HFLIP_BIT
dex
phx
phy
pea #98+TILE_HFLIP_BIT
_GTESetTile
_GTESetTile
_GTESetTile
_GTESetTile
rts
_drawTreeV
phx
phy
pea #97+TILE_VFLIP_BIT
inx
phx
phy
pea #98+TILE_VFLIP_BIT
iny
phx
phy
pea #66+TILE_VFLIP_BIT
dex
phx
phy
pea #65+TILE_VFLIP_BIT
_GTESetTile
_GTESetTile
_GTESetTile
_GTESetTile
rts
_drawTreeHV
phx
phy
pea #98+TILE_VFLIP_BIT+TILE_HFLIP_BIT
inx
phx
phy
pea #97+TILE_VFLIP_BIT+TILE_HFLIP_BIT
iny
phx
phy
pea #65+TILE_VFLIP_BIT+TILE_HFLIP_BIT
dex
phx
phy
pea #66+TILE_VFLIP_BIT+TILE_HFLIP_BIT
_GTESetTile
_GTESetTile
_GTESetTile
_GTESetTile
rts
MyUserId ds 2 MyUserId ds 2
ToolPath str '1/Tool160' ToolPath str '1/Tool160'
FrameCount ds 2 FrameCount ds 2

View File

@ -12,7 +12,7 @@
}, },
"scripts": { "scripts": {
"test": "npm run build && build-image.bat %npm_package_config_cadius% && %npm_package_config_gsport%", "test": "npm run build && build-image.bat %npm_package_config_cadius% && %npm_package_config_gsport%",
"debug": "%npm_package_config_crossrunner% GTEToolDemo -Source MAINSEG_Output.txt -Debug -CompatibilityLayer", "debug": "%npm_package_config_crossrunner% GTEToolDemo -Source MAINSEG_Output.txt -Debug -CompatibilityLayer -Map App.s",
"build": "npm run build:tool && npm run build:sys16", "build": "npm run build:tool && npm run build:sys16",
"build:sys16": "%npm_package_config_merlin32% -V %npm_package_config_macros% App.s", "build:sys16": "%npm_package_config_merlin32% -V %npm_package_config_macros% App.s",
"build:tool": "%npm_package_config_merlin32% -V %npm_package_config_macros% ../../src/Master.s" "build:tool": "%npm_package_config_merlin32% -V %npm_package_config_macros% ../../src/Master.s"

View File

@ -217,28 +217,20 @@ _SetTile
lda #4 lda #4
sta procIdx sta procIdx
:low_priority :low_priority
lda #TILE_ID_MASK lda #TILE_ID_MASK
bit newTileId bit newTileId
bne :not_zero beq :is_zero
lda #2 lda #2
tsb procIdx tsb procIdx
:not_zero :is_zero
lda #TILE_VFLIP_BIT lda #TILE_VFLIP_BIT
bit newTileId
beq :no_vflip beq :no_vflip
lda #1 lda #1
tsb procIdx tsb procIdx
:no_vflip :no_vflip
; Multiple by 6 to get the correct table entry index
asl procIdx
lda procIdx
asl
adc procIdx
sta procIdx
; Now integrate with the engine mode indicator ; Now integrate with the engine mode indicator
lda EngineMode lda EngineMode
@ -296,12 +288,22 @@ _SetTile
tblPtr equ blttmp tblPtr equ blttmp
_SetTileProcs _SetTileProcs
; Set a long pointer to this bank ; Multiple the proc index by 6 to get the correct table entry offset
sty tblPtr
clc asl
sta tblPtr
asl
adc tblPtr adc tblPtr
sta tblPtr sta tblPtr
; Add this offset to the base table address
tya
adc tblPtr
sta tblPtr
; Set the pointer to this bank
phk phk
phk phk
pla pla
@ -350,12 +352,16 @@ _SetTileProcs
FastProcs FastProcs
FastOverZA dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0 FastOverZA dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
FastOverZV dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0 FastOverZV dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
FastOverNA dw _TBCopyDataFast,GenericOverAFast,_OneSpriteFastOverA FastOverNA dw _TBCopyDataAFast,GenericOverZero,_OneSpriteFastOverA
FastOverNV dw _TBCopyDataVFast,GenericOverVFast,_OneSpriteFastOverV FastOverNV dw _TBCopyDataVFast,GenericOverZero,_OneSpriteFastOverV
;FastOverNA dw _TBCopyDataAFast,GenericOverAFast,_OneSpriteFastOverA
;FastOverNV dw _TBCopyDataVFast,GenericOverVFast,_OneSpriteFastOverV
FastUnderZA dw _TBConstTile0,GenericUnderZero,GenericUnderZero FastUnderZA dw _TBConstTile0,GenericUnderZero,GenericUnderZero
FastUnderZV dw _TBConstTile0,GenericUnderZero,GenericUnderZero FastUnderZV dw _TBConstTile0,GenericUnderZero,GenericUnderZero
FastUnderNA dw _TBCopyDataFast,GenericUnderAFast,_OneSpriteFastUnderA FastUnderNA dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV FastUnderNV dw _TBConstTile0,GenericOverZero,_OneSpriteFastOver0
;FastUnderNA dw _TBCopyDataFast,GenericUnderAFast,_OneSpriteFastUnderA
;FastUnderNV dw _TBCopyDataVFast,GenericUnderVFast,_OneSpriteFastUnderV
DynProcs DynProcs
DynOverZA DynOverZA
@ -483,7 +489,7 @@ endbit1 mac
; OPTIMIZATION: ; OPTIMIZATION:
; ;
; bit #$00FF ; Optimization to skip the first 8 bits if they are all zeros ; bit #$00FF ; Skip the first 8 bits if they are all zeros
; bne norm_entry ; bne norm_entry
; xba ; xba
; jmp skip_entry ; jmp skip_entry

View File

@ -41,6 +41,7 @@ _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 _TBCopyDataFast
_TBCopyDataAFast
tax tax
_TBCopyDataFastX _TBCopyDataFastX
]line equ 0 ]line equ 0

View File

@ -146,3 +146,45 @@ GenericUnderZero
plb plb
rts 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.
;
; Preserves the X-register
FastCopyTileDataA
ldy TileStore+TS_TILE_ADDR,x ; load the tile address
pei DP2_TILEDATA_AND_TILESTORE_BANKS
plb ; set to the tiledata bank
]line equ 0
lup 8
lda tiledata+{]line*4},y
sta tmp_tile_data+{]line*4}
lda tiledata+{]line*4}+2,y
sta tmp_tile_data+{]line*4}+2
]line equ ]line+1
--^
plb
rts
FastCopyTileDataV
ldy TileStore+TS_TILE_ADDR,x ; load the tile address
pei DP2_TILEDATA_AND_TILESTORE_BANKS
plb ; set to the tiledata bank
]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
--^
plb
rts

View File

@ -65,7 +65,7 @@ CopyTileToDPSprite
; must be set to the TileData bank in entry. ; must be set to the TileData bank in entry.
; ;
; Preserves the X-register ; Preserves the X-register
CopyTileDataToDP CopyTileDataToDPA
]line equ 0 ]line equ 0
lup 8 lup 8
lda tiledata+{]line*4},y lda tiledata+{]line*4},y

View File

@ -34,11 +34,11 @@ _OneSpriteFastOver0
; The 1-sprite dispatch prserves the X-register, so it already points to the TileStore ; The 1-sprite dispatch prserves the X-register, so it already points to the TileStore
_OneSpriteFastOverV _OneSpriteFastOverV
jsr CopyTileDataToDPV jsr FastCopyTileDataV
bra _OneSpriteFastOver bra _OneSpriteFastOver
_OneSpriteFastOverA _OneSpriteFastOverA
jsr CopyTileDataToDP jsr FastCopyTileDataA
_OneSpriteFastOver _OneSpriteFastOver
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
@ -86,7 +86,7 @@ _OneSpriteSlowOver0
; Slow variant for regular tile. ; Slow variant for regular tile.
_OneSpriteSlowOver _OneSpriteSlowOver
jsr CopyTileDataToDP 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.