mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-02-19 13:30:30 +00:00
Most of the horizontal flip routines are not needed since the _GetTileAddr function returns the correct tile address. Need to finish auditing other Tile blitters
This commit is contained in:
parent
65ce5cbbc0
commit
cd5de05d74
@ -60,8 +60,6 @@ RenderTile EXT ; Y = address from GetTileStoreOffset
|
|||||||
GetTileStoreOffset EXT ; X = column, Y = row
|
GetTileStoreOffset EXT ; X = column, Y = row
|
||||||
TileStore EXT ; Tile store internal data structure
|
TileStore EXT ; Tile store internal data structure
|
||||||
|
|
||||||
DrawTileSprite EXT ; X = target address in sprite plane, Y = address in tile bank
|
|
||||||
EraseTileSprite EXT ; X = target address is sprite plane
|
|
||||||
GetSpriteVBuffAddr EXT ; X = x-coordinate (0 - 159), Y = y-coordinate (0 - 199). Return in Acc.
|
GetSpriteVBuffAddr EXT ; X = x-coordinate (0 - 159), Y = y-coordinate (0 - 199). Return in Acc.
|
||||||
|
|
||||||
; Allocate a full 64K bank
|
; Allocate a full 64K bank
|
||||||
|
84
src/Sprite.s
84
src/Sprite.s
@ -130,25 +130,7 @@ _RenderSprites
|
|||||||
; as a future optimization. Ideally, all of the sprites will be rendered into the sprite plane in a separate
|
; as a future optimization. Ideally, all of the sprites will be rendered into the sprite plane in a separate
|
||||||
; pass from this function, which is primarily concerned with flagging dirty tiles in the Tile Store.
|
; pass from this function, which is primarily concerned with flagging dirty tiles in the Tile Store.
|
||||||
|
|
||||||
ldx _Sprites+OLD_VBUFF_ADDR,y
|
jsr _EraseSpriteY
|
||||||
beq :noerase
|
|
||||||
jsr _EraseTileSprite ; erase from the old position
|
|
||||||
inx
|
|
||||||
inx
|
|
||||||
inx
|
|
||||||
inx
|
|
||||||
jsr _EraseTileSprite
|
|
||||||
txa
|
|
||||||
clc
|
|
||||||
adc #8*256
|
|
||||||
tax
|
|
||||||
jsr _EraseTileSprite
|
|
||||||
dex
|
|
||||||
dex
|
|
||||||
dex
|
|
||||||
dex
|
|
||||||
jsr _EraseTileSprite
|
|
||||||
:noerase
|
|
||||||
|
|
||||||
; Draw the sprite into the sprint plane buffer(s)
|
; Draw the sprite into the sprint plane buffer(s)
|
||||||
|
|
||||||
@ -490,6 +472,66 @@ _DrawSprites
|
|||||||
bra :loop
|
bra :loop
|
||||||
:out rts
|
:out rts
|
||||||
|
|
||||||
|
; X = _Sprites array offset
|
||||||
|
_EraseSprite
|
||||||
|
txy
|
||||||
|
_EraseSpriteY
|
||||||
|
lda _Sprites+OLD_VBUFF_ADDR,y
|
||||||
|
beq :noerase
|
||||||
|
lda _Sprites+SPRITE_ID,y
|
||||||
|
and #$1800 ; use bits 11 and 12 to dispatch (oly care about size)
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
xba
|
||||||
|
tax
|
||||||
|
jmp (:erase_sprite,x)
|
||||||
|
:noerase rts
|
||||||
|
:erase_sprite dw erase_8x8,erase_8x16,erase_16x8,erase_16x16
|
||||||
|
|
||||||
|
erase_8x8
|
||||||
|
ldx _Sprites+OLD_VBUFF_ADDR,y
|
||||||
|
jmp _EraseTileSprite ; erase from the old position
|
||||||
|
|
||||||
|
erase_8x16
|
||||||
|
clc
|
||||||
|
ldx _Sprites+OLD_VBUFF_ADDR,y
|
||||||
|
jsr _EraseTileSprite
|
||||||
|
|
||||||
|
txa
|
||||||
|
adc #{8*SPRITE_PLANE_SPAN}
|
||||||
|
tax
|
||||||
|
jmp _EraseTileSprite
|
||||||
|
|
||||||
|
erase_16x8
|
||||||
|
clc
|
||||||
|
ldx _Sprites+OLD_VBUFF_ADDR,y
|
||||||
|
jsr _EraseTileSprite
|
||||||
|
|
||||||
|
txa
|
||||||
|
adc #4
|
||||||
|
tax
|
||||||
|
jmp _EraseTileSprite
|
||||||
|
|
||||||
|
erase_16x16
|
||||||
|
clc
|
||||||
|
ldx _Sprites+OLD_VBUFF_ADDR,y
|
||||||
|
jsr _EraseTileSprite
|
||||||
|
|
||||||
|
txa
|
||||||
|
adc #4
|
||||||
|
tax
|
||||||
|
jsr _EraseTileSprite
|
||||||
|
|
||||||
|
txa
|
||||||
|
adc #{8*SPRITE_PLANE_SPAN}-4
|
||||||
|
tax
|
||||||
|
jsr _EraseTileSprite
|
||||||
|
|
||||||
|
txa
|
||||||
|
adc #4
|
||||||
|
tax
|
||||||
|
jmp _EraseTileSprite
|
||||||
|
|
||||||
; X = _Sprites array offset
|
; X = _Sprites array offset
|
||||||
_DrawSprite
|
_DrawSprite
|
||||||
txy
|
txy
|
||||||
@ -806,10 +848,6 @@ _DrawTile8x8V
|
|||||||
; X = address is sprite plane -- erases an 8x8 region
|
; X = address is sprite plane -- erases an 8x8 region
|
||||||
SPRITE_PLANE_SPAN equ 256
|
SPRITE_PLANE_SPAN equ 256
|
||||||
|
|
||||||
EraseTileSprite ENT
|
|
||||||
jsr _EraseTileSprite
|
|
||||||
rtl
|
|
||||||
|
|
||||||
_EraseTileSprite
|
_EraseTileSprite
|
||||||
phb ; Save the bank to switch to the sprite plane
|
phb ; Save the bank to switch to the sprite plane
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ _SetTile
|
|||||||
tay
|
tay
|
||||||
pla
|
pla
|
||||||
|
|
||||||
cmp TileStore+TS_TILE_ID,y ; Only set to dirty if the value changes
|
cmp TileStore+TS_TILE_ID,y ; Only set to dirty if the value changed
|
||||||
beq :nochange
|
beq :nochange
|
||||||
|
|
||||||
sta TileStore+TS_TILE_ID,y ; Value is different, store it.
|
sta TileStore+TS_TILE_ID,y ; Value is different, store it.
|
||||||
@ -668,27 +668,6 @@ PushDirtyTile ENT
|
|||||||
plb
|
plb
|
||||||
rtl
|
rtl
|
||||||
|
|
||||||
_PushDirtyTileOld
|
|
||||||
tay ; check if this already marked immediately
|
|
||||||
lda TileStore+TS_DIRTY,y ; If the lookup === $FFFF (<$8000), it is free.
|
|
||||||
bpl :occupied
|
|
||||||
|
|
||||||
; At this point, keep the Y register value because it is the correct offset to all of the tile
|
|
||||||
; record fields.
|
|
||||||
ldx DirtyTileCount
|
|
||||||
|
|
||||||
txa
|
|
||||||
sta TileStore+TS_DIRTY,y ; Store a back-link to this record
|
|
||||||
|
|
||||||
tya
|
|
||||||
sta DirtyTiles,x ; Store the lookup address in the list
|
|
||||||
|
|
||||||
inx
|
|
||||||
inx
|
|
||||||
stx DirtyTileCount ; Commit
|
|
||||||
:occupied
|
|
||||||
rts
|
|
||||||
|
|
||||||
; alternate version that is very slightly slower, but preserves the y-register
|
; alternate version that is very slightly slower, but preserves the y-register
|
||||||
_PushDirtyTile
|
_PushDirtyTile
|
||||||
tax
|
tax
|
||||||
|
@ -8,15 +8,13 @@
|
|||||||
; X : address of base tile in the tiledata bank (tileId * 128)
|
; 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
|
; Y : address of the top-left corder of the tile location in the code field
|
||||||
; B : set to the code field bank
|
; B : set to the code field bank
|
||||||
;_TBSolidTile dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH
|
|
||||||
; dw _TBCopyData,_TBCopyDataH,_TBCopyDataV,_TBCopyDataVH
|
|
||||||
|
|
||||||
_TBSolidTile_00
|
_TBSolidTile_00
|
||||||
jsr _TBCopyData
|
jsr _TBCopyData
|
||||||
jmp _TBFillPEAOpcode
|
jmp _TBFillPEAOpcode
|
||||||
|
|
||||||
_TBSolidTile_0H
|
_TBSolidTile_0H
|
||||||
jsr _TBCopyDataH
|
jsr _TBCopyData
|
||||||
jmp _TBFillPEAOpcode
|
jmp _TBFillPEAOpcode
|
||||||
|
|
||||||
_TBSolidTile_V0
|
_TBSolidTile_V0
|
||||||
@ -24,7 +22,7 @@ _TBSolidTile_V0
|
|||||||
jmp _TBFillPEAOpcode
|
jmp _TBFillPEAOpcode
|
||||||
|
|
||||||
_TBSolidTile_VH
|
_TBSolidTile_VH
|
||||||
jsr _TBCopyDataVH
|
jsr _TBCopyDataV
|
||||||
jmp _TBFillPEAOpcode
|
jmp _TBFillPEAOpcode
|
||||||
|
|
||||||
; The workhorse blitter. This blitter copies tile data into the code field without masking. This is the
|
; The workhorse blitter. This blitter copies tile data into the code field without masking. This is the
|
||||||
@ -49,16 +47,16 @@ _TBCopyData
|
|||||||
--^
|
--^
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBCopyDataH
|
;_TBCopyDataH
|
||||||
]line equ 0
|
;]line equ 0
|
||||||
lup 8
|
; lup 8
|
||||||
ldal tiledata+{]line*4}+64,x
|
; ldal tiledata+{]line*4}+64,x
|
||||||
sta: $0004+{]line*$1000},y
|
; sta: $0004+{]line*$1000},y
|
||||||
ldal tiledata+{]line*4}+66,x
|
; ldal tiledata+{]line*4}+66,x
|
||||||
sta: $0001+{]line*$1000},y
|
; sta: $0001+{]line*$1000},y
|
||||||
]line equ ]line+1
|
;]line equ ]line+1
|
||||||
--^
|
; --^
|
||||||
rts
|
; rts
|
||||||
|
|
||||||
_TBCopyDataV
|
_TBCopyDataV
|
||||||
]src equ 7
|
]src equ 7
|
||||||
@ -73,18 +71,18 @@ _TBCopyDataV
|
|||||||
--^
|
--^
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBCopyDataVH
|
;_TBCopyDataVH
|
||||||
]src equ 7
|
;]src equ 7
|
||||||
]dest equ 0
|
;]dest equ 0
|
||||||
lup 8
|
; lup 8
|
||||||
ldal tiledata+{]src*4}+64,x
|
; ldal tiledata+{]src*4}+64,x
|
||||||
sta: $0004+{]dest*$1000},y
|
; sta: $0004+{]dest*$1000},y
|
||||||
ldal tiledata+{]src*4}+66,x
|
; ldal tiledata+{]src*4}+66,x
|
||||||
sta: $0001+{]dest*$1000},y
|
; sta: $0001+{]dest*$1000},y
|
||||||
]src equ ]src-1
|
;]src equ ]src-1
|
||||||
]dest equ ]dest+1
|
;]dest equ ]dest+1
|
||||||
--^
|
; --^
|
||||||
rts
|
; rts
|
||||||
|
|
||||||
; A simple helper function that fill in all of the opcodes of a tile with the PEA opcode. This is
|
; A simple helper function that fill in all of the opcodes of a tile with the PEA opcode. This is
|
||||||
; a common function since a tile must be explicitly flagged to use a mask, so this routine is used
|
; a common function since a tile must be explicitly flagged to use a mask, so this routine is used
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
;
|
;
|
||||||
; Need to slightly remap these register inputs to save into the direct page cached values
|
; Need to slightly remap these register inputs to save into the direct page cached values
|
||||||
_TBMaskedTile_00
|
_TBMaskedTile_00
|
||||||
|
_TBMaskedTile_0H
|
||||||
sta _X_REG ; Save these values as we will need to reload them
|
sta _X_REG ; Save these values as we will need to reload them
|
||||||
sty _Y_REG ; at certain points
|
sty _Y_REG ; at certain points
|
||||||
stx _T_PTR
|
stx _T_PTR
|
||||||
@ -44,35 +45,36 @@ _TBMaskedTile_00
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBMaskedTile_0H
|
;_TBMaskedTile_0H
|
||||||
sta _X_REG
|
; sta _X_REG
|
||||||
sty _Y_REG
|
; sty _Y_REG
|
||||||
stx _T_PTR
|
; stx _T_PTR
|
||||||
|
;
|
||||||
CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$0003
|
; CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$0003
|
||||||
CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$1003
|
; CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$1003
|
||||||
CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$2003
|
; CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$2003
|
||||||
CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$3003
|
; CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$3003
|
||||||
CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$4003
|
; CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$4003
|
||||||
CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$5003
|
; CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$5003
|
||||||
CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$6003
|
; CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$6003
|
||||||
CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$7003
|
; CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$7003
|
||||||
|
;
|
||||||
inc _X_REG
|
; inc _X_REG
|
||||||
inc _X_REG
|
; inc _X_REG
|
||||||
|
;
|
||||||
CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$0000
|
; CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$0000
|
||||||
CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$1000
|
; CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$1000
|
||||||
CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$2000
|
; CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$2000
|
||||||
CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$3000
|
; CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$3000
|
||||||
CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$4000
|
; CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$4000
|
||||||
CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$5000
|
; CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$5000
|
||||||
CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$6000
|
; CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$6000
|
||||||
CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$7000
|
; CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$7000
|
||||||
|
;
|
||||||
rts
|
; rts
|
||||||
|
|
||||||
_TBMaskedTile_V0
|
_TBMaskedTile_V0
|
||||||
|
_TBMaskedTile_VH
|
||||||
sta _X_REG
|
sta _X_REG
|
||||||
sty _Y_REG
|
sty _Y_REG
|
||||||
stx _T_PTR
|
stx _T_PTR
|
||||||
@ -100,30 +102,30 @@ _TBMaskedTile_V0
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_TBMaskedTile_VH
|
;_TBMaskedTile_VH
|
||||||
sta _X_REG
|
; sta _X_REG
|
||||||
sty _Y_REG
|
; sty _Y_REG
|
||||||
stx _T_PTR
|
; stx _T_PTR
|
||||||
|
;
|
||||||
CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$7003
|
; CopyMaskedWord tiledata+64+0;tiledata+64+32+0;$7003
|
||||||
CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$6003
|
; CopyMaskedWord tiledata+64+4;tiledata+64+32+4;$6003
|
||||||
CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$5003
|
; CopyMaskedWord tiledata+64+8;tiledata+64+32+8;$5003
|
||||||
CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$4003
|
; CopyMaskedWord tiledata+64+12;tiledata+64+32+12;$4003
|
||||||
CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$3003
|
; CopyMaskedWord tiledata+64+16;tiledata+64+32+16;$3003
|
||||||
CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$2003
|
; CopyMaskedWord tiledata+64+20;tiledata+64+32+20;$2003
|
||||||
CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$1003
|
; CopyMaskedWord tiledata+64+24;tiledata+64+32+24;$1003
|
||||||
CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$0003
|
; CopyMaskedWord tiledata+64+28;tiledata+64+32+28;$0003
|
||||||
|
;
|
||||||
inc _X_REG
|
; inc _X_REG
|
||||||
inc _X_REG
|
; inc _X_REG
|
||||||
|
;
|
||||||
CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$7000
|
; CopyMaskedWord tiledata+64+2;tiledata+64+32+2;$7000
|
||||||
CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$6000
|
; CopyMaskedWord tiledata+64+6;tiledata+64+32+6;$6000
|
||||||
CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$5000
|
; CopyMaskedWord tiledata+64+10;tiledata+64+32+10;$5000
|
||||||
CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$4000
|
; CopyMaskedWord tiledata+64+14;tiledata+64+32+14;$4000
|
||||||
CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$3000
|
; CopyMaskedWord tiledata+64+18;tiledata+64+32+18;$3000
|
||||||
CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$2000
|
; CopyMaskedWord tiledata+64+22;tiledata+64+32+22;$2000
|
||||||
CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$1000
|
; CopyMaskedWord tiledata+64+26;tiledata+64+32+26;$1000
|
||||||
CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$0000
|
; CopyMaskedWord tiledata+64+30;tiledata+64+32+30;$0000
|
||||||
|
;
|
||||||
rts
|
; rts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user