Much faster span cache management

This commit is contained in:
blondie7575 2017-12-25 22:41:09 -07:00
parent ee9645c47d
commit d2c5ef675f
3 changed files with 16 additions and 21 deletions

View File

@ -26,6 +26,7 @@ SCRATCH1 = $1a
SCRATCHL = $19 ; 16-bit version of scratch SCRATCHL = $19 ; 16-bit version of scratch
SCRATCHL2 = $67 ; Second 16-bit scratch SCRATCHL2 = $67 ; Second 16-bit scratch
PARAM24 = $67 ; 24-bit param (This is almost certainly messing up AppleSoft, but meh) PARAM24 = $67 ; 24-bit param (This is almost certainly messing up AppleSoft, but meh)
CACHEPTR = $6A ; General purpose cache pointer (This is almost certainly messing up AppleSoft, but meh)
STACKPTR = $70 ; Cache for stack pointer in fast graphics STACKPTR = $70 ; Cache for stack pointer in fast graphics
SHADOWREGISTER = $72 ; Cache for shadow register in fast graphics SHADOWREGISTER = $72 ; Cache for shadow register in fast graphics
STACKREGISTER = $73 ; Cache for stack register in fast graphics STACKREGISTER = $73 ; Cache for stack register in fast graphics

Binary file not shown.

View File

@ -68,9 +68,10 @@ renderTerrainDone:
; ;
renderTerrainSpans: renderTerrainSpans:
pha pha
stz terrainSpanWriteCacheLen lda #terrainSpanWriteCache
lda #MAXTERRAINHEIGHT-1 sta CACHEPTR
lda #MAXTERRAINHEIGHT-1
renderTerrainSpansLoop: renderTerrainSpansLoop:
sta PARAML1 sta PARAML1
@ -89,21 +90,18 @@ renderTerrainSpansLoop:
unrenderTerrainSpans: unrenderTerrainSpans:
SAVE_AXY SAVE_AXY
ldy #0
unrenderTerrainSpansLoop: unrenderTerrainSpansLoop:
lda terrainSpanWriteCache,y dec CACHEPTR
dec CACHEPTR
lda (CACHEPTR)
beq unrenderTerrainSpansDone
tax tax
lda #0 lda #0
sta VRAMBANK,x sta VRAMBANK,x
bra unrenderTerrainSpansLoop
iny unrenderTerrainSpansDone:
iny
cpy terrainSpanWriteCacheLen
bne unrenderTerrainSpansLoop
stz terrainSpanWriteCacheLen
RESTORE_AXY RESTORE_AXY
rts rts
@ -173,14 +171,10 @@ renderTerrainRowSpansLoop:
sta VRAMBANK,x sta VRAMBANK,x
; Cache the index we wrote to so we can erase later ; Cache the index we wrote to so we can erase later
phy
ldy terrainSpanWriteCacheLen
txa txa
sta terrainSpanWriteCache,y sta (CACHEPTR)
iny inc CACHEPTR
iny inc CACHEPTR
sty terrainSpanWriteCacheLen
ply
; Advance to end of span ; Advance to end of span
clc clc
@ -854,10 +848,10 @@ terrainSpanData:
.endrepeat .endrepeat
.endrepeat .endrepeat
terrainSpanWriteCacheNull:
.word 0 ; Null terminator for when popping off LIFO
terrainSpanWriteCache: terrainSpanWriteCache:
.repeat 512 .repeat 512
.word 0 .word 0 ; LIFO for tracking span byte writes
.endrepeat .endrepeat
terrainSpanWriteCacheLen:
.word 0