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
SCRATCHL2 = $67 ; Second 16-bit scratch
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
SHADOWREGISTER = $72 ; Cache for shadow 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:
pha
stz terrainSpanWriteCacheLen
lda #MAXTERRAINHEIGHT-1
lda #terrainSpanWriteCache
sta CACHEPTR
lda #MAXTERRAINHEIGHT-1
renderTerrainSpansLoop:
sta PARAML1
@ -89,21 +90,18 @@ renderTerrainSpansLoop:
unrenderTerrainSpans:
SAVE_AXY
ldy #0
unrenderTerrainSpansLoop:
lda terrainSpanWriteCache,y
dec CACHEPTR
dec CACHEPTR
lda (CACHEPTR)
beq unrenderTerrainSpansDone
tax
lda #0
sta VRAMBANK,x
bra unrenderTerrainSpansLoop
iny
iny
cpy terrainSpanWriteCacheLen
bne unrenderTerrainSpansLoop
stz terrainSpanWriteCacheLen
unrenderTerrainSpansDone:
RESTORE_AXY
rts
@ -173,14 +171,10 @@ renderTerrainRowSpansLoop:
sta VRAMBANK,x
; Cache the index we wrote to so we can erase later
phy
ldy terrainSpanWriteCacheLen
txa
sta terrainSpanWriteCache,y
iny
iny
sty terrainSpanWriteCacheLen
ply
sta (CACHEPTR)
inc CACHEPTR
inc CACHEPTR
; Advance to end of span
clc
@ -854,10 +848,10 @@ terrainSpanData:
.endrepeat
.endrepeat
terrainSpanWriteCacheNull:
.word 0 ; Null terminator for when popping off LIFO
terrainSpanWriteCache:
.repeat 512
.word 0
.word 0 ; LIFO for tracking span byte writes
.endrepeat
terrainSpanWriteCacheLen:
.word 0