Implement full per-scanline offset support for BG1

This commit is contained in:
Lucas Scharenbroich 2023-03-11 03:41:12 -06:00
parent 7dd690ac04
commit d31bd30649
4 changed files with 33 additions and 4 deletions

View File

@ -174,6 +174,7 @@ OVERLAY_BELOW equ $4000 ; Overlay is drawn below scanline sprite
; GetAddress table IDs
scanlineHorzOffset equ $0001
scanlineHorzOffset2 equ $0002
; Tile constants
; TILE_RESERVED_BIT equ $8000

View File

@ -195,7 +195,8 @@ DIRTY_BIT_BG1_REFRESH equ $0020
DIRTY_BIT_SPRITE_ARRAY equ $0040
; GetAddress table IDs
scanlineHorzOffset equ $0001 ; table of 416 words, a double-array of scanline offset values. Must be 0, 163
scanlineHorzOffset equ $0001 ; Table of 416 words, a double-array of scanline offset values. Values must be in range [0, 163]
scanlineHorzOffset2 equ $0002 ; Table of 416 words, a double-array of scanline offset values. Values must be in range [0, 163]
; Script definition
YIELD equ $8000
@ -297,6 +298,7 @@ _DirectListBottom EXT
StartXMod164Tbl EXT
LastOffsetTbl EXT
BG1StartXMod164Tbl EXT
; Tool error codes
NO_TIMERS_AVAILABLE equ 10

View File

@ -886,13 +886,23 @@ _TSGetAddress
lda :tblId,s
cmp #scanlineHorzOffset
bne :out
bne :next_1
lda StartXMod164Tbl
sta :output,s
lda StartXMod164Tbl+2
sta :output+2,s
bra :out
:next_1 cmp #scanlineHorzOffset2
bne :next_2
lda BG1StartXMod164Tbl
sta :output,s
lda BG1StartXMod164Tbl+2
sta :output+2,s
bra :out
:next_2
:out
_TSExit #0;#2
@ -904,12 +914,24 @@ _TSSetAddress
_TSEntry
lda :tblId,s
cmp #scanlineHorzOffset
bne :out
bne :next_1
lda :ptr,s
sta StartXMod164Tbl
lda :ptr+2,s
sta StartXMod164Tbl+2
bra :out
:next_1
cmp #scanlineHorzOffset2
bne :next_2
lda :ptr,s
sta BG1StartXMod164Tbl
lda :ptr+2,s
sta BG1StartXMod164Tbl+2
bra :out
:next_2
:out
_TSExit #0;#6

View File

@ -388,13 +388,17 @@ BG1YOffsetTable ENT
; dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
--^
; Per-scanline offsets for BG0
; Pointer to per-scanline offsets for BG0
StartXMod164Tbl ENT
dw 0,0
LastOffsetTbl ENT
ds 416
; Pointer to per-scanline offsets for BG1
BG1StartXMod164Tbl ENT
dw 0,0
; Other Toolset variables
OneSecondCounter ENT
dw 0