First working version of virtual stack unrender

So fast!!
This commit is contained in:
blondie7575 2018-01-06 15:30:06 -08:00
parent e0a48fc5ac
commit c82e9d8a30
5 changed files with 59 additions and 30 deletions

25
GenerateSpanDataTable.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys
def main(argv):
print ("terrainSpanDataPtr:",end="")
rowCount = 19
MAXTERRAINHEIGHT = 100 # Must match assembly code!
for jump in range(0,MAXTERRAINHEIGHT):
rowCount += 1
if (rowCount==20):
print ("\n\t.word ", end="")
rowCount=0
print ("SPANROWSIZE*%d" % (jump), end="")
if (rowCount<19):
print (",", end="")
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -27,6 +27,7 @@ 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)
CACHEDATA = $6C ; General purpose cache data (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

View File

@ -31,6 +31,7 @@ beginGameplay:
jsr compileTerrainSpans
; jsr compileTerrain
; jsr clipTerrain
jsr renderTerrainSpans
; Create players
lda #56
@ -57,8 +58,8 @@ gameplayLoop:
; lda terrainDirty
; beq gameplayLoopKbd
BORDER_COLOR #$3
jsr unrenderTerrainSpans
jsr renderTerrainSpans
; jsr unrenderTerrainSpans
stz terrainDirty
BORDER_COLOR #$1

Binary file not shown.

View File

@ -69,7 +69,12 @@ renderTerrainDone:
;
;
renderTerrainSpans:
pha
SAVE_AXY
FASTGRAPHICS
lda #$800 ; Prepare unrender cache
tcs
lda #terrainSpanWriteCache
sta CACHEPTR
@ -77,23 +82,6 @@ renderTerrainSpans:
renderTerrainSpansLoop:
sta PARAML1
jsr renderTerrainRowSpans
dec
bne renderTerrainSpansLoop
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainRowSpans:
;
; PARAML1 = Row index (bottom relative)
;
; Trashes SCRATCHL,SCRATCHL2,PARAML0
;
renderTerrainRowSpans:
SAVE_AXY
; Find row data
lda PARAML1
@ -120,18 +108,17 @@ renderTerrainRowSpans:
lda #0
clc
renderTerrainRowSpansFindLeftLoop:
adc terrainSpanData+2,y
cmp leftScreenEdge
bpl renderTerrainRowSpansFoundLeft
iny
iny
pha
sta CACHEDATA
lda SCRATCHL
eor #%110000 ; Toggle span color cache
sta SCRATCHL
pla
lda CACHEDATA
bra renderTerrainRowSpansFindLeftLoop
renderTerrainRowSpansFoundLeft:
@ -147,10 +134,11 @@ renderTerrainRowSpansLoop:
sta VRAMBANK,x
; Cache the index we wrote to so we can erase later
txa
sta (CACHEPTR)
inc CACHEPTR
inc CACHEPTR
phx
; txa
; sta (CACHEPTR)
; inc CACHEPTR
; inc CACHEPTR
; Advance to end of span
clc
@ -171,10 +159,17 @@ renderTerrainRowSpansLoop:
bra renderTerrainRowSpansLoop
renderTerrainRowSpansDone:
lda PARAML1
dec
bne renderTerrainSpansLoop
pea 0 ; Null-terminate the unrender cache
SLOWGRAPHICS
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; unrenderTerrainSpans:
;
@ -182,18 +177,25 @@ renderTerrainRowSpansDone:
unrenderTerrainSpans:
SAVE_AXY
phb
pea $e1e1 ; Work entirely in bank E1 for all local read/writes
plb
plb
ldy #$800-1
unrenderTerrainSpansLoop:
dec CACHEPTR
dec CACHEPTR
lda (CACHEPTR)
lda 0,y
beq unrenderTerrainSpansDone
tax
lda #0
sta VRAMBANK,x
sta a:0,x
dey
dey
bra unrenderTerrainSpansLoop
unrenderTerrainSpansDone:
plb
RESTORE_AXY
rts