mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-11-26 07:49:17 +00:00
Fix lookup tables to fix boundary rendering
This commit is contained in:
parent
b6202ca44c
commit
2c409b02a7
27
src/Sprite.s
27
src/Sprite.s
@ -19,13 +19,14 @@ InitSprites
|
||||
cpx #$FFFE
|
||||
bne :loop2
|
||||
|
||||
; Initialize the VBuff offset values for the different cases
|
||||
; Initialize the VBuff offset values for the different cases. These are locations in
|
||||
; the TileStoreLookup table, which has different dimensions than the underlying TileStore
|
||||
; array
|
||||
|
||||
TILE_STORE_SPAN equ {TILE_STORE_WIDTH*2}
|
||||
LAST_ROW equ {TILE_STORE_SPAN*{TILE_STORE_HEIGHT-1}}
|
||||
NEXT_TO_LAST_ROW equ {TILE_STORE_SPAN*{TILE_STORE_HEIGHT-2}}
|
||||
LAST_COL equ {TILE_STORE_WIDTH-1}*2
|
||||
NEXT_TO_LAST_COL equ {TILE_STORE_WIDTH-2}*2
|
||||
LAST_ROW equ {2*TS_LOOKUP_SPAN*{TILE_STORE_HEIGHT-1}}
|
||||
NEXT_TO_LAST_ROW equ {2*TS_LOOKUP_SPAN*{TILE_STORE_HEIGHT-2}}
|
||||
LAST_COL equ {{TILE_STORE_WIDTH-1}*2}
|
||||
NEXT_TO_LAST_COL equ {{TILE_STORE_WIDTH-2}*2}
|
||||
|
||||
lda #0 ; Normal row, Normal column
|
||||
ldx #0
|
||||
@ -98,7 +99,7 @@ NEXT_TO_LAST_COL equ {TILE_STORE_WIDTH-2}*2
|
||||
jsr _CacheSpriteBanks
|
||||
rts
|
||||
|
||||
; Call with X-register set to TileStore tile and Acc set to the VBuff slot offset
|
||||
; Call with X-register set to TileStore tile and A set to the VBuff slot offset
|
||||
_SetVBuffValues
|
||||
COL_BYTES equ 4 ; VBUFF_TILE_COL_BYTES
|
||||
ROW_BYTES equ 384 ; VBUFF_TILE_ROW_BYTES
|
||||
@ -121,27 +122,27 @@ ROW_BYTES equ 384 ; VBUFF_TILE_ROW_BYTES
|
||||
lda #{2*COL_BYTES}+{0*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+1*{TS_LOOKUP_SPAN*2},x
|
||||
ldy TileStoreLookup+{1*{TS_LOOKUP_SPAN*2}},x
|
||||
lda #{0*COL_BYTES}+{1*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+1*{TS_LOOKUP_SPAN*2}+2,x
|
||||
ldy TileStoreLookup+{1*{TS_LOOKUP_SPAN*2}}+2,x
|
||||
lda #{1*COL_BYTES}+{1*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+1*{TS_LOOKUP_SPAN*2}+4,x
|
||||
ldy TileStoreLookup+{1*{TS_LOOKUP_SPAN*2}}+4,x
|
||||
lda #{2*COL_BYTES}+{1*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+2*{TS_LOOKUP_SPAN*2},x
|
||||
ldy TileStoreLookup+{2*{TS_LOOKUP_SPAN*2}},x
|
||||
lda #{0*COL_BYTES}+{2*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+2*{TS_LOOKUP_SPAN*2}+2,x
|
||||
ldy TileStoreLookup+{2*{TS_LOOKUP_SPAN*2}}+2,x
|
||||
lda #{1*COL_BYTES}+{2*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
|
||||
ldy TileStoreLookup+2*{TS_LOOKUP_SPAN*2}+4,x
|
||||
ldy TileStoreLookup+{2*{TS_LOOKUP_SPAN*2}}+4,x
|
||||
lda #{2*COL_BYTES}+{2*ROW_BYTES}
|
||||
sta (tmp0),y
|
||||
rts
|
||||
|
@ -113,10 +113,6 @@ _CalcDirtySprite
|
||||
pha
|
||||
and #$FFFC
|
||||
lsr ; Even numbers from [0, 160] (81 elements)
|
||||
; cmp #TILE_STORE_WIDTH*2
|
||||
; bcc :x_in_range
|
||||
; sbc #TILE_STORE_WIDTH*2
|
||||
;:x_in_range
|
||||
sta tmp3
|
||||
adc RowTop
|
||||
sta _Sprites+TS_LOOKUP_INDEX,y ; This is the index into the TileStoreLookup table
|
||||
@ -183,7 +179,7 @@ _CalcDirtySprite
|
||||
; The X-register still has the TileStoreLookupYTable index, which we re-use to get a VBuff
|
||||
; array selector for the vertical location
|
||||
|
||||
lda VBuffVertTableSelect,x ; A bunch of 12, 24 or 36 values
|
||||
lda VBuffVertTableSelect,x ; A bunch of 0, 12 or 24 values
|
||||
clc
|
||||
ldx tmp3
|
||||
adc VBuffHorzTableSelect,x ; A bunch of 0, 4 or 8 values
|
||||
|
@ -470,10 +470,22 @@ ScreenModeHeight ENT
|
||||
; The eighth block is (X = N-1, Y = M-2)
|
||||
; The ninth block is (X = N-2, Y = M-2)
|
||||
|
||||
VBuffVertTableSelect ENT
|
||||
ds 51*2
|
||||
VBuffVertTableSelect ENT ; 51 entries
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,48,24
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,48,24
|
||||
VBuffHorzTableSelect ENT
|
||||
ds 81*2
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,16,8
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,0
|
||||
dw 0,0,0,0,0,0,0,0,0,16,8
|
||||
|
||||
VBuffStart ds TILE_STORE_SIZE
|
||||
VBuffArray ENT
|
||||
|
@ -5,20 +5,20 @@ TILE_STORE_HEIGHT equ 26
|
||||
MAX_TILES equ {26*41} ; Number of tiles in the code field (41 columns * 26 rows)
|
||||
TILE_STORE_SIZE equ {MAX_TILES*2} ; The tile store contains a tile descriptor in each slot
|
||||
|
||||
TS_TILE_ID equ TILE_STORE_SIZE*0 ; tile descriptor for this location
|
||||
TS_DIRTY equ TILE_STORE_SIZE*1 ; Flag. Used to prevent a tile from being queued multiple times per frame
|
||||
TS_SPRITE_FLAG equ TILE_STORE_SIZE*2 ; Bitfield of all sprites that intersect this tile. 0 if no sprites.
|
||||
TS_TILE_ADDR equ TILE_STORE_SIZE*3 ; cached value, the address of the tiledata for this tile
|
||||
TS_CODE_ADDR_LOW equ TILE_STORE_SIZE*4 ; const value, address of this tile in the code fields
|
||||
TS_CODE_ADDR_HIGH equ TILE_STORE_SIZE*5
|
||||
TS_WORD_OFFSET equ TILE_STORE_SIZE*6 ; const value, word offset value for this tile if LDA (dp),y instructions re used
|
||||
TS_BASE_ADDR equ TILE_STORE_SIZE*7 ; const value, because there are two rows of tiles per bank, this is set to $0000 ot $8000.
|
||||
TS_SCREEN_ADDR equ TILE_STORE_SIZE*8 ; cached value of on-screen location of tile. Used for DirtyRender.
|
||||
TS_TILE_ID equ {TILE_STORE_SIZE*0} ; tile descriptor for this location
|
||||
TS_DIRTY equ {TILE_STORE_SIZE*1} ; Flag. Used to prevent a tile from being queued multiple times per frame
|
||||
TS_SPRITE_FLAG equ {TILE_STORE_SIZE*2} ; Bitfield of all sprites that intersect this tile. 0 if no sprites.
|
||||
TS_TILE_ADDR equ {TILE_STORE_SIZE*3} ; cached value, the address of the tiledata for this tile
|
||||
TS_CODE_ADDR_LOW equ {TILE_STORE_SIZE*4} ; const value, address of this tile in the code fields
|
||||
TS_CODE_ADDR_HIGH equ {TILE_STORE_SIZE*5}
|
||||
TS_WORD_OFFSET equ {TILE_STORE_SIZE*6} ; const value, word offset value for this tile if LDA (dp),y instructions re used
|
||||
TS_BASE_ADDR equ {TILE_STORE_SIZE*7} ; const value, because there are two rows of tiles per bank, this is set to $0000 ot $8000.
|
||||
TS_SCREEN_ADDR equ {TILE_STORE_SIZE*8} ; cached value of on-screen location of tile. Used for DirtyRender.
|
||||
|
||||
; TODO: Move these arrays into the K bank to support direct dispatch via jmp (abs,x)
|
||||
TS_BASE_TILE_COPY equ TILE_STORE_SIZE*9 ; derived from TS_TILE_ID to optimize tile copy to support sprite rendering
|
||||
TS_BASE_TILE_DISP equ TILE_STORE_SIZE*10 ; derived from TS_TILE_ID to optimize base (non-sprite) tile dispatch in the Render function
|
||||
TS_DIRTY_TILE_DISP equ TILE_STORE_SIZE*11 ; derived from TS_TILE_ID to optimize dirty tile dispatch in the Render function
|
||||
TS_BASE_TILE_COPY equ {TILE_STORE_SIZE*9} ; derived from TS_TILE_ID to optimize tile copy to support sprite rendering
|
||||
TS_BASE_TILE_DISP equ {TILE_STORE_SIZE*10} ; derived from TS_TILE_ID to optimize base (non-sprite) tile dispatch in the Render function
|
||||
TS_DIRTY_TILE_DISP equ {TILE_STORE_SIZE*11} ; derived from TS_TILE_ID to optimize dirty tile dispatch in the Render function
|
||||
|
||||
TILE_STORE_NUM equ 12 ; Need this many parallel arrays
|
||||
|
||||
@ -91,7 +91,7 @@ TS_LOOKUP_BORDER equ 2
|
||||
TS_LOOKUP_SPAN equ {TS_LOOKUP_WIDTH+TS_LOOKUP_BORDER}
|
||||
TS_LOOKUP_ROWS equ {TS_LOOKUP_HEIGHT+TS_LOOKUP_BORDER}
|
||||
|
||||
; Blitter template constancts
|
||||
; Blitter template constants
|
||||
PER_TILE_SIZE equ 3
|
||||
SNIPPET_SIZE equ 32
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user