More banking fixes

This commit is contained in:
Lucas Scharenbroich 2022-05-19 23:40:45 -05:00
parent e52ef4f7cf
commit 9ac9ea623e
6 changed files with 15 additions and 319 deletions

View File

@ -296,9 +296,9 @@ _ReadControl
ora 1,s
sta 1,s
cmpl LastKey
cmp LastKey
beq :KbdDown
stal LastKey
sta LastKey
lda #PAD_KEY_DOWN ; set the keydown flag
ora 2,s
@ -306,8 +306,7 @@ _ReadControl
bra :KbdDown
:KbdNotDwn
lda #0
stal LastKey
stz LastKey
:KbdDown
rep #$20
pla

View File

@ -167,7 +167,7 @@ AllocOneBank PushLong #0
plx ; base address of the new handle
pla ; high address 00XX of the new handle (bank)
xba ; swap accumulator bytes to XX00
sta :bank+2 ; store as bank for next op (overwrite $XX00)
stal :bank+2 ; store as bank for next op (overwrite $XX00)
:bank ldal $000001,X ; recover the bank address in A=XX/00
rts

View File

@ -109,10 +109,10 @@ InitTiles
; that are happening
lda #0
stal TileStore+TS_TILE_ID,x ; clear the tile store with the special zero tile
stal TileStore+TS_TILE_ADDR,x
stal TileStore+TS_SPRITE_FLAG,x ; no sprites are set at the beginning
stal TileStore+TS_DIRTY,x ; none of the tiles are dirty
sta TileStore+TS_TILE_ID,x ; clear the tile store with the special zero tile
sta TileStore+TS_TILE_ADDR,x
sta TileStore+TS_SPRITE_FLAG,x ; no sprites are set at the beginning
sta TileStore+TS_DIRTY,x ; none of the tiles are dirty
; lda DirtyTileProcs ; Fill in with the first dispatch address
; stal TileStore+TS_DIRTY_TILE_DISP,x
@ -137,21 +137,21 @@ InitTiles
lda #>TileStore ; get middle 16 bits: "00 -->BBHH<-- LL"
and #$FF00 ; merge with code field bank
ora BRowTableHigh,y
stal TileStore+TS_CODE_ADDR_HIGH,x ; High word of the tile address (just the bank)
sta TileStore+TS_CODE_ADDR_HIGH,x ; High word of the tile address (just the bank)
lda BRowTableLow,y
stal TileStore+TS_BASE_ADDR,x ; May not be needed later if we can figure out the right constant...
sta TileStore+TS_BASE_ADDR,x ; May not be needed later if we can figure out the right constant...
lda :col ; Set the offset values based on the column
asl ; of this tile
asl
stal TileStore+TS_WORD_OFFSET,x ; This is the offset from 0 to 82, used in LDA (dp),y instruction
sta TileStore+TS_WORD_OFFSET,x ; This is the offset from 0 to 82, used in LDA (dp),y instruction
tay
lda Col2CodeOffset+2,y
clc
adcl TileStore+TS_BASE_ADDR,x
stal TileStore+TS_CODE_ADDR_LOW,x ; Low word of the tile address in the code field
adc TileStore+TS_BASE_ADDR,x
sta TileStore+TS_CODE_ADDR_LOW,x ; Low word of the tile address in the code field
dec :col
bpl :hop
@ -236,10 +236,6 @@ _SetTile
; continuously overwrite it.
;
; We assume that there is a clean code field in this routine
SetBG0XPos ENT
jsr _SetBG0XPos
rtl
_SetBG0XPos
cmp StartX
beq :out ; Easy, if nothing changed, then nothing changes
@ -258,10 +254,6 @@ _SetBG0XPos
; SetBG0YPos
;
; Set the virtual position of the primary background layer.
SetBG0YPos ENT
jsr _SetBG0YPos
rtl
_SetBG0YPos
cmp StartY
beq :out ; Easy, if nothing changed, then nothing changes

View File

@ -32,7 +32,6 @@ _RestoreBG0Opcodes
lda LastPatchOffset ; If zero, there are no saved opcodes
sta :exit_offset
beq :loop
:loop
ldx :virt_line_x2

View File

@ -1,294 +0,0 @@
; Collection of data tables
;
; Col2CodeOffset
;
; Takes a column number (0 - 81) and returns the offset into the blitter code
; template.
;
; This is used for rendering tile data into the code field. For example, is we assume that
; we are filling in the operands for a bunch of PEA values, we could do this
;
; ldy tileColumn*2
; lda #DATA
; ldx Col2CodeOffset,y
; sta $0001,x
;
; The table values are pre-reversed so that loop can go in logical order 0, 2, 4, ...
; and the resulting offsets will map to the code instructions in right-to-left order.
;
; Remember, because the data is pushed on to the stack, the last instruction, which is
; in the highest memory location, pushed data that apepars on the left edge of the screen.
PER_TILE_SIZE equ 3
]step equ 0
dw CODE_TOP ; There is a spot where we load Col2CodeOffet-2,x
Col2CodeOffset lup 82
dw CODE_TOP+{{81-]step}*PER_TILE_SIZE}
]step equ ]step+1
--^
dw CODE_TOP+{81*PER_TILE_SIZE}
; A parallel table to Col2CodeOffset that holds the offset to the exception handler address for each column
SNIPPET_SIZE equ 32
]step equ 0
dw SNIPPET_BASE
JTableOffset lup 82
dw SNIPPET_BASE+{{81-]step}*SNIPPET_SIZE}
]step equ ]step+1
--^
dw SNIPPET_BASE+{81*SNIPPET_SIZE}
; Table of BRA instructions that are used to exit the code field. Separate tables for
; even and odd aligned cases.
;
; The even exit point is closest to the code field. The odd exit point is 3 bytes further
;
; These tables are reversed to be parallel with the JTableOffset and Col2CodeOffset tables above. The
; physical word index that each instruction is intended to be placed at is in the comment.
CodeFieldEvenBRA
bra *+6 ; 81 -- need to skip over the JMP loop that passed control back
bra *+9 ; 80
bra *+12 ; 79
bra *+15 ; 78
bra *+18 ; 77
bra *+21 ; 76
bra *+24 ; 75
bra *+27 ; 74
bra *+30 ; 73
bra *+33 ; 72
bra *+36 ; 71
bra *+39 ; 70
bra *+42 ; 69
bra *+45 ; 68
bra *+48 ; 67
bra *+51 ; 66
bra *+54 ; 65
bra *+57 ; 64
bra *+60 ; 63
bra *+63 ; 62
bra *+66 ; 61
bra *+69 ; 60
bra *+72 ; 59
bra *+75 ; 58
bra *+78 ; 57
bra *+81 ; 56
bra *+84 ; 55
bra *+87 ; 54
bra *+90 ; 53
bra *+93 ; 52
bra *+96 ; 51
bra *+99 ; 50
bra *+102 ; 49
bra *+105 ; 48
bra *+108 ; 47
bra *+111 ; 46
bra *+114 ; 45
bra *+117 ; 44
bra *+120 ; 43
bra *+123 ; 42
bra *+126 ; 41
bra *-123 ; 40
bra *-120 ; 39
bra *-117 ; 38
bra *-114 ; 37
bra *-111 ; 36
bra *-108 ; 35
bra *-105 ; 34
bra *-102 ; 33
bra *-99 ; 32
bra *-96 ; 31
bra *-93 ; 30
bra *-90 ; 29
bra *-87 ; 28
bra *-84 ; 27
bra *-81 ; 26
bra *-78 ; 25
bra *-75 ; 24
bra *-72 ; 23
bra *-69 ; 22
bra *-66 ; 21
bra *-63 ; 20
bra *-60 ; 19
bra *-57 ; 18
bra *-54 ; 17
bra *-51 ; 16
bra *-48 ; 15
bra *-45 ; 14
bra *-42 ; 13
bra *-39 ; 12
bra *-36 ; 11
bra *-33 ; 10
bra *-30 ; 9
bra *-27 ; 8
bra *-24 ; 7
bra *-21 ; 6
bra *-18 ; 5
bra *-15 ; 4
bra *-12 ; 3
bra *-9 ; 2
bra *-6 ; 1
bra *-3 ; 0
CodeFieldOddBRA
bra *+9 ; 81 -- need to skip over two JMP instructions
bra *+12 ; 80
bra *+15 ; 79
bra *+18 ; 78
bra *+21 ; 77
bra *+24 ; 76
bra *+27 ; 75
bra *+30 ; 74
bra *+33 ; 73
bra *+36 ; 72
bra *+39 ; 71
bra *+42 ; 70
bra *+45 ; 69
bra *+48 ; 68
bra *+51 ; 67
bra *+54 ; 66
bra *+57 ; 65
bra *+60 ; 64
bra *+63 ; 64
bra *+66 ; 62
bra *+69 ; 61
bra *+72 ; 60
bra *+75 ; 59
bra *+78 ; 58
bra *+81 ; 57
bra *+84 ; 56
bra *+87 ; 55
bra *+90 ; 54
bra *+93 ; 53
bra *+96 ; 52
bra *+99 ; 51
bra *+102 ; 50
bra *+105 ; 49
bra *+108 ; 48
bra *+111 ; 47
bra *+114 ; 46
bra *+117 ; 45
bra *+120 ; 44
bra *+123 ; 43
bra *+126 ; 42
bra *+129 ; 41
bra *-126 ; 40
bra *-123 ; 39
bra *-120 ; 38
bra *-117 ; 37
bra *-114 ; 36
bra *-111 ; 35
bra *-108 ; 34
bra *-105 ; 33
bra *-102 ; 32
bra *-99 ; 31
bra *-96 ; 30
bra *-93 ; 29
bra *-90 ; 28
bra *-87 ; 27
bra *-84 ; 26
bra *-81 ; 25
bra *-78 ; 24
bra *-75 ; 23
bra *-72 ; 22
bra *-69 ; 21
bra *-66 ; 20
bra *-63 ; 19
bra *-60 ; 18
bra *-57 ; 17
bra *-54 ; 16
bra *-51 ; 15
bra *-48 ; 14
bra *-45 ; 13
bra *-42 ; 12
bra *-39 ; 11
bra *-36 ; 10
bra *-33 ; 9
bra *-30 ; 8
bra *-27 ; 7
bra *-24 ; 6
bra *-21 ; 5
bra *-18 ; 4
bra *-15 ; 3
bra *-12 ; 2
bra *-9 ; 1
bra *-6 ; 0 -- branch back 6 to skip the JMP even path
]step equ $2000
ScreenAddr ENT
lup 200
dw ]step
]step = ]step+160
--^
; Table of offsets into each row of a Tile Store table. We currently have two tables defined; one
; that is the backing store for the tiles rendered into the code field, and another that holds
; backlink information on the sprite entries that overlap various tiles.
;
; This table is double-length to support accessing off the end modulo its legth
TileStoreYTable ENT
]step equ 0
lup 26
dw ]step
]step = ]step+{41*2}
--^
]step equ 0
lup 26
dw ]step
]step = ]step+{41*2}
--^
; Create a table to look up the "next" column with modulo wraparound. Basically a[i] = i
; and the table is double-length. Use constant offsets to pick an amount to advance
NextCol
]step equ 0
lup 41
dw ]step
]step = ]step+2
--^
]step equ 0
lup 41
dw ]step
]step = ]step+2
--^
; This is a double-length table that holds the right-edge adresses of the playfield on the physical
; screen. At most, it needs to hold 200 addresses for a full height playfield. It is double-length
; so that code can pick any offset and copy values without needing to check for a wrap-around. If the
; playfield is less than 200 lines tall, then any values after 2 * PLAYFIELD_HEIGHT are undefined.
RTable ds 400
ds 400
; Array of addresses for the banks that hold the blitter.
BlitBuff ENT
dw $5a5a
ds 4*13
; The blitter table (BTable) is a double-length table that holds the full 4-byte address of each
; line of the blit fields. We decompose arrays of pointers into separate high and low words so
; that everything can use the same indexing offsets
BTableHigh ds 208*2*2
BTableLow ds 208*2*2
; A shorter table that just holds the blitter row addresses
BRowTableHigh ds 26*2*2
BRowTableLow ds 26*2*2
; A double-length table of addresses for the BG1 bank. The BG1 buffer is 208 rows of 256 bytes each and
; the first row starts $1800 bytes in to center the buffer in the bank
]step equ $1800
BG1YTable lup 208
dw ]step
]step = ]step+256
--^
]step equ 256
lup 208
dw ]step
]step = ]step+256
--^
; Repeat
BG1YOffsetTable lup 26
dw 1,1,1,2,2,2,2,2,1,1,1,0,0,0,0,0
--^

View File

@ -21,11 +21,11 @@ _PushDirtyTile
; alternate entry point if the x-register is already set
_PushDirtyTileX
ldal TileStore+TS_DIRTY,x
lda TileStore+TS_DIRTY,x
bne :occupied2
inc ; any non-zero value will work
stal TileStore+TS_DIRTY,x ; and is 1 cycle faster than loading a constant value
sta TileStore+TS_DIRTY,x ; and is 1 cycle faster than loading a constant value
txa
ldx DirtyTileCount ; 4