diff --git a/equates.s b/equates.s index 38589c5..092c765 100644 --- a/equates.s +++ b/equates.s @@ -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 diff --git a/gscats.2mg b/gscats.2mg index c1e12fc..9cf6c25 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/terrain.s b/terrain.s index e31e713..dd6b7dd 100644 --- a/terrain.s +++ b/terrain.s @@ -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