Add SCB binding infrastructure
This commit is contained in:
parent
b87e2a8d33
commit
cc8e03e6d3
21
src/Core.s
21
src/Core.s
|
@ -8,7 +8,7 @@
|
|||
use .\Defs.s
|
||||
|
||||
; Feature flags
|
||||
NO_INTERRUPTS equ 0 ; turn off for crossrunner debugging
|
||||
NO_INTERRUPTS equ 1 ; turn off for crossrunner debugging
|
||||
NO_MUSIC equ 1 ; turn music + tool loading off
|
||||
|
||||
; External data provided by the main program segment
|
||||
|
@ -245,6 +245,9 @@ EngineReset
|
|||
stz BG1TileMapPtr
|
||||
stz BG1TileMapPtr+2
|
||||
|
||||
stz SCBArrayPtr
|
||||
stz SCBArrayPtr+2
|
||||
|
||||
stz OneSecondCounter
|
||||
|
||||
]step equ 0
|
||||
|
@ -403,19 +406,19 @@ ReadControl ENT
|
|||
put blitter/Tables.s
|
||||
put blitter/Template.s
|
||||
put blitter/Tiles.s
|
||||
put blitter/Tiles00000.s
|
||||
put blitter/Tiles00001.s
|
||||
; put blitter/Tiles00010.s
|
||||
; put blitter/Tiles00011.s
|
||||
put blitter/Tiles10000.s
|
||||
put blitter/Tiles11000.s
|
||||
put blitter/Tiles00000.s ; normal tiles
|
||||
put blitter/Tiles00001.s ; dynamic tiles
|
||||
put blitter/Tiles00010.s ; normal masked tiles
|
||||
put blitter/Tiles00011.s ; dynamic masked tiles
|
||||
|
||||
put blitter/Tiles10000.s ; normal tiles + sprites
|
||||
; put blitter/Tiles10001.s
|
||||
; put blitter/Tiles10010.s
|
||||
; put blitter/Tiles10011.s
|
||||
; put blitter/Tiles11000.s
|
||||
put blitter/Tiles11000.s ; normal high priority tile + sprites
|
||||
put blitter/TilesBG1.s
|
||||
put blitter/Vert.s
|
||||
put blitter/BG0.s
|
||||
put blitter/BG1.s
|
||||
put blitter/SCB.s
|
||||
put TileMap.s
|
||||
|
|
@ -14,6 +14,8 @@ COMMAND_KEY_REG equ $E0C061
|
|||
OPTION_KEY_REG equ $E0C062
|
||||
|
||||
SHADOW_SCREEN equ $012000
|
||||
SHADOW_SCREEN_SCB equ $019D00
|
||||
SHADOW_SCREEN_PALETTES equ $019E00
|
||||
SHR_SCREEN equ $E12000
|
||||
SHR_SCB equ $E19D00
|
||||
SHR_PALETTES equ $E19E00
|
||||
|
@ -76,7 +78,8 @@ BG1TileMapWidth equ 82
|
|||
BG1TileMapHeight equ 84
|
||||
BG1TileMapPtr equ 86
|
||||
|
||||
Next equ 90
|
||||
SCBArrayPtr equ 90 ; USed for palette binding
|
||||
Next equ 94
|
||||
|
||||
BankLoad equ 128
|
||||
|
||||
|
|
|
@ -23,6 +23,11 @@ CopyBG1Tile EXT
|
|||
CopyTileToDyn EXT
|
||||
Render EXT
|
||||
|
||||
; SCB/Palette binding (high bit of array point indicates whether to bind to BG0 Y position (0)
|
||||
; or BG1 Y position (1).
|
||||
SetSCBArray EXT
|
||||
BltSCB EXT
|
||||
|
||||
; Rotation
|
||||
ApplyBG1XPosAngle EXT
|
||||
ApplyBG1YPosAngle EXT
|
||||
|
|
18
src/Render.s
18
src/Render.s
|
@ -108,15 +108,15 @@ _Render
|
|||
|
||||
; Now render all of the remaining lines in top-to-bottom (or bottom-to-top) order
|
||||
|
||||
lda ScreenY0 ; pass the address of the first line of the overlay
|
||||
clc
|
||||
adc #0
|
||||
asl
|
||||
tax
|
||||
lda ScreenAddr,x
|
||||
clc
|
||||
adc ScreenX0
|
||||
jsl Overlay
|
||||
lda ScreenY0 ; pass the address of the first line of the overlay
|
||||
clc
|
||||
adc #0
|
||||
asl
|
||||
tax
|
||||
lda ScreenAddr,x
|
||||
clc
|
||||
adc ScreenX0
|
||||
jsl Overlay
|
||||
|
||||
ldx #8 ; Blit the full virtual buffer to the screen
|
||||
ldy ScreenHeight
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
; SCB binding. Really just a fast copy from an array in memory to the SCBs for a range of
|
||||
; physical lines. Follow the same calling conventions as _BltRange
|
||||
;
|
||||
; X = first line (inclusive), valid range of 0 to 199
|
||||
; Y = last line (exclusive), valid range >X up to 200
|
||||
;
|
||||
; The lines are based on the appearance of lines in the play field, so blitting lines 0 through
|
||||
; 19 will draw the first 20 lines on the play field, regardless of where the playfield is physically
|
||||
; on the SHR screen or the current value of StartY
|
||||
;
|
||||
; This could be made faster by forcing a SCB array to be copied into PEAs ahead of time, but this
|
||||
; is a bit more flexible
|
||||
BltSCB ENT
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
jsr _BltSCB
|
||||
plb
|
||||
rtl
|
||||
|
||||
_BltSCBOut
|
||||
rts
|
||||
_BltSCB
|
||||
lda SCBArrayPtr
|
||||
ora SCBArrayPtr+2
|
||||
beq _BltSCBOut
|
||||
|
||||
phb ; preserve the bank register
|
||||
tsc ; save the stack pointer
|
||||
stal :stk_save+1
|
||||
|
||||
sep #$20 ; Get the offset into the SCB array
|
||||
lda SCBArrayPtr+2
|
||||
pha ; Stash the bank to set later
|
||||
rep #$20
|
||||
|
||||
lda SCBArrayPtr+2
|
||||
bpl :bind_to_bg0
|
||||
lda BG1StartY
|
||||
bra :bind_to_bg1
|
||||
:bind_to_bg0
|
||||
lda StartY
|
||||
:bind_to_bg1
|
||||
clc
|
||||
adc SCBArrayPtr
|
||||
tax
|
||||
|
||||
lda ScreenHeight ; Calculate the number of scan lines / entry point
|
||||
asl
|
||||
asl
|
||||
eor #$FFFF
|
||||
inc
|
||||
clc
|
||||
adc #:scb_end
|
||||
sta :entry+1
|
||||
|
||||
lda ScreenY1 ; Get the SCB address to but into the stack register
|
||||
dec
|
||||
clc
|
||||
adc #SHADOW_SCREEN_SCB
|
||||
|
||||
plb ; Pop the bank with the SCB array
|
||||
sei ; turn off interrupts while we slam SCBs
|
||||
tcs ; set the stack to teh SCB area in Bank 01
|
||||
_R0W1
|
||||
:entry jmp :scb_end
|
||||
|
||||
; 100 lda/pha to cover, potentialls, the full screen
|
||||
]line equ 198
|
||||
lup 100
|
||||
lda: ]line,x
|
||||
pha
|
||||
]line equ ]line-2
|
||||
--^
|
||||
:scb_end
|
||||
|
||||
_R0W0
|
||||
:stk_save lda #0000 ; load the stack
|
||||
tcs
|
||||
cli ; re-enable interrupts
|
||||
|
||||
plb ; restore the bank
|
||||
rts
|
||||
|
||||
|
||||
; Quick helper to set the pointer (X = low word, A = hgih work)
|
||||
SetSCBArray ENT
|
||||
jsr _SetSCBArray
|
||||
rtl
|
||||
|
||||
_SetSCBArray
|
||||
stx SCBArrayPtr
|
||||
sta SCBArrayPtr+2
|
||||
rts
|
|
@ -154,24 +154,31 @@ _RenderTile2
|
|||
; A second set that are optimized for when EngineMode has BG1 disabled.
|
||||
TileProcs dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00000 : normal tiles
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00 ; 00001 : dynamic tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00010 : masked normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00011 : masked dynamic tiles
|
||||
dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH ; 00010 : masked normal tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00 ; 00011 : masked dynamic tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
|
||||
; Fringe tiles not supported yet, so just repeat the block from above
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00100 : fringed normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00101 : fringed dynamic tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00110 : fringed masked normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 00111 : fringed masked dynamic tiles
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00 ; 00101 : fringed dynamic tiles
|
||||
dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH ; 00110 : fringed masked normal tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00 ; 00111 : fringed masked dynamic tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
|
||||
; High-priority tiles without a sprite in front of them are just normal tiles. Repeat the top half
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01000 : high-priority normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01001 : high-priority dynamic tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01010 : high-priority masked normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01011 : high-priority masked dynamic tiles
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00 ; 01001 : high-priority dynamic tiles
|
||||
dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH ; 01010 : high-priority masked normal tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00 ; 01011 : high-priority masked dynamic tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01100 : high-priority fringed normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01101 : high-priority fringed dynamic tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01110 : high-priority fringed masked normal tiles
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 01111 : high-priority fringed masked dynamic tiles
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00 ; 01101 : high-priority fringed dynamic tiles
|
||||
dw _TBMaskedTile_00,_TBMaskedTile_0H,_TBMaskedTile_V0,_TBMaskedTile_VH ; 01110 : high-priority fringed masked normal tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00 ; 01111 : high-priority fringed masked dynamic tiles
|
||||
dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
|
||||
; Here are all the sprite variants of the tiles
|
||||
dw _TBSolidSpriteTile_00,_TBSolidSpriteTile_0H,
|
||||
dw _TBSolidSpriteTile_V0,_TBSolidSpriteTile_VH ; 10000 : normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10001 : dynamic tiles w/sprite
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
;
|
||||
; Insert a code sequence to mask the dynamic tile against the background. This is quite a slow process because
|
||||
; every word needs to be handled with a JMP exception; but it looks good!
|
||||
_TBDynamicMaskTile dw _TBDynamicMaskTile_00,_TBDynamicMaskTile_00,_TBDynamicMaskTile_00,_TBDynamicMaskTile_00
|
||||
dw _TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00,_TBDynamicTile_00
|
||||
|
||||
_TBDynamicMaskTile_00
|
||||
jsr _TBDynamicDataAndMask
|
||||
jmp _TBFillJMPOpcode
|
||||
|
|
Loading…
Reference in New Issue