Add hook for VBL callback

This commit is contained in:
Lucas Scharenbroich 2023-05-09 10:16:58 -05:00
parent 3eba3fa8e6
commit 4ee67fb8be
7 changed files with 43 additions and 14 deletions

View File

@ -175,9 +175,11 @@ OVERLAY_SOLID equ $8000 ; Overlay covers the scan line and is fu
OVERLAY_ABOVE equ $0000 ; Overlay is drawn above scanline sprites OVERLAY_ABOVE equ $0000 ; Overlay is drawn above scanline sprites
OVERLAY_BELOW equ $4000 ; Overlay is drawn below scanline sprites OVERLAY_BELOW equ $4000 ; Overlay is drawn below scanline sprites
; GetAddress table IDs ; GetAddress IDs
scanlineHorzOffset equ $0001 scanlineHorzOffset equ $0001
scanlineHorzOffset2 equ $0002 scanlineHorzOffset2 equ $0002
tileStore equ $0003
vblCallback equ $0004
; CopyPicToBG1 flags ; CopyPicToBG1 flags
COPY_PIC_NORMAL equ $0000 ; Copy into BG1 buffer in "normal mode" COPY_PIC_NORMAL equ $0000 ; Copy into BG1 buffer in "normal mode"

View File

@ -166,8 +166,14 @@ OneSecHandler mx %11
; This is OK, it's referenced by a long address ; This is OK, it's referenced by a long address
VBLTASK hex 00000000 VBLTASK hex 00000000
dw 0 TaskCnt dw 1
hex 5AA5 hex 5AA5
VblTaskCode mx %11
lda #1
stal TaskCnt ; Reset the task count
_VblTaskPatch jml _TaskStub ; Just something to catch the interrupt
_TaskStub rtl
mx %00
; Reset the engine to a known state ; Reset the engine to a known state
; Blitter initialization ; Blitter initialization

View File

@ -192,6 +192,7 @@ DIRTY_BIT_SPRITE_ARRAY equ $0040
scanlineHorzOffset equ $0001 ; Table of 416 words, a double-array of scanline offset values. Values must be in range [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] scanlineHorzOffset2 equ $0002 ; Table of 416 words, a double-array of scanline offset values. Values must be in range [0, 163]
tileStore equ $0003 tileStore equ $0003
vblCallback equ $0004 ; User routine to be called by VBL interrupt. Set to $000000 to disconnect
; CopyPicToBG1 flags ; CopyPicToBG1 flags
COPY_PIC_NORMAL equ $0000 ; Copy into BG1 buffer in "normal mode" treating the buffer as a 164x208 pixmap with stride of 256 COPY_PIC_NORMAL equ $0000 ; Copy into BG1 buffer in "normal mode" treating the buffer as a 164x208 pixmap with stride of 256

View File

@ -2,7 +2,7 @@
TYP $BA ; Tool set file TYP $BA ; Tool set file
DSK Tool160 DSK Tool160
XPL XPL
; Main toolbox interface and code ; Main toolbox interface and code
@ -12,41 +12,41 @@
; 64KB Tile Memory ; 64KB Tile Memory
ASM static/TileData.s ASM static/TileData.s
KND #$1001 ; Type and Attributes ($10=Static,$01=Data) KND #$1101 ; Type and Attributes ($10=Static,$01=Data)
ALI BANK ALI BANK
SNA TDATA SNA TDATA
; 64KB Sprite Plane Data ; 64KB Sprite Plane Data
ASM static/SprData.s ASM static/SprData.s
KND #$1001 ; Type and Attributes ($11=Static+Bank Relative,$01=Data) KND #$1101 ; Type and Attributes ($11=Static+Bank Relative,$01=Data)
ALI BANK ALI BANK
SNA SDATA SNA SDATA
; 64KB Sprite Mask Data ; 64KB Sprite Mask Data
ASM static/SprMask.s ASM static/SprMask.s
KND #$1001 ; Type and Attributes ($11=Static+Bank Relative,$01=Data) KND #$1101 ; Type and Attributes ($11=Static+Bank Relative,$01=Data)
ALI BANK ALI BANK
SNA SMASK SNA SMASK
; 64KB Tile Store ; 64KB Tile Store
ASM static/TileStore.s ASM static/TileStore.s
KND #$1001 ; Type and Attributes ($11=Static+Bank Relative,$01=Data) KND #$1101 ; Type and Attributes ($11=Static+Bank Relative,$01=Data)
ALI BANK ALI BANK
SNA TSTORE SNA TSTORE
; 64KB Rotation Data Tables ; 64KB Rotation Data Tables
ASM RotData.s ASM RotData.s
KND #$1001 ; Type and Attributes ($11=Static+Bank Relative,$01=Data) KND #$1101 ; Type and Attributes ($11=Static+Bank Relative,$01=Data)
ALI BANK ALI BANK
SNA ROTDATA SNA ROTDATA
; Additional code ; Additional code
; ASM FastCopies.s ; ASM FastCopies.s
; KND #$1001 ; Type and Attributes ($11=Static+Bank Relative,$01=Data) ; KND #$1101 ; Type and Attributes ($11=Static+Bank Relative,$01=Data)
; ALI BANK ; ALI BANK
; SNA FASTCPY ; SNA FASTCPY

View File

@ -6,7 +6,7 @@
; X = first tile ; X = first tile
; Y = last tile ; Y = last tile
; ;
; To copy in three tiles starting at tile 5, for example, X = 5 and Y = 9 ; To copy in four tiles starting at tile 5, for example, X = 5 and Y = 9
_LoadTileSet _LoadTileSet
txa txa
_Mul128 ; Jump to the target location _Mul128 ; Jump to the target location

View File

@ -887,7 +887,7 @@ _TSSetBG1Scale
sta BG1Scaling sta BG1Scaling
_TSExit #0;#2 _TSExit #0;#2
; Pointer GetAddress(tblId) ; Pointer GetAddress(addrId)
_TSGetAddress _TSGetAddress
:tblId equ FirstParam+0 :tblId equ FirstParam+0
:output equ FirstParam+2 :output equ FirstParam+2
@ -919,7 +919,7 @@ _TSGetAddress
:out :out
_TSExit #0;#2 _TSExit #0;#2
; SetAddress(tblId, Pointer) ; SetAddress(addrId, Pointer)
_TSSetAddress _TSSetAddress
:ptr equ FirstParam+0 :ptr equ FirstParam+0
:tblId equ FirstParam+4 :tblId equ FirstParam+4
@ -944,7 +944,27 @@ _TSSetAddress
lda :ptr+2,s lda :ptr+2,s
sta BG1StartXMod164Tbl+2 sta BG1StartXMod164Tbl+2
bra :out bra :out
:next_2
:next_2 cmp #vblCallback
bne :next_3
lda :ptr,s
ora :ptr+2,s
beq :vbl_restore
lda :ptr,s
stal _VblTaskPatch+1 ; long addressing because we're patching code in the K bank
lda :ptr+1,s
stal _VblTaskPatch+2
bra :out
:vbl_restore
lda #_TaskStub
stal _VblTaskPatch+1
lda #>_TaskStub
stal _VblTaskPatch+2
bra :out
:next_3
:out :out
_TSExit #0;#6 _TSExit #0;#6

View File

@ -4,7 +4,7 @@ _RenderTile
lda TileStore+TS_SPRITE_FLAG,x ; any sprites on this tile? lda TileStore+TS_SPRITE_FLAG,x ; any sprites on this tile?
bne _HasSprites bne _HasSprites
; Probably best to rework this to just jump to the tile routine directly, event if there ; Probably best to rework this to just jump to the tile routine directly, even if there
; is some boilerplate code because it is useful to be able to access the data bank before ; is some boilerplate code because it is useful to be able to access the data bank before
; switching to the code field bank. ; switching to the code field bank.