Fixed compiled terrain rendering

I thought it was working after the merging with fill mode, but it actually wasn’t. Should be now. Using only compiled rendering as of this commit.
This commit is contained in:
blondie7575 2018-07-24 18:43:41 -07:00
parent d4077a7edc
commit f599267718
5 changed files with 43 additions and 17 deletions

View File

@ -122,7 +122,6 @@ gameplayLoopRender:
BORDER_COLOR #$3 BORDER_COLOR #$3
jsl renderTerrainSpans jsl renderTerrainSpans
jsr renderTerrain jsr renderTerrain
stz terrainDirty stz terrainDirty
BORDER_COLOR #$1 BORDER_COLOR #$1
@ -337,7 +336,7 @@ fire:
basePalette: basePalette:
; Color 0 and 1 must both be sky blue. Compiled rendering uses PHD (which must contain $0000), ; Color 0 and 1 must both be sky blue. Compiled rendering uses PHD (which must contain $0000),
; and span rendering uses fill mode, so 0 can't be used there ; and span rendering uses fill mode, so 0 can't be used there
.word $0aef,$0aef,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0777,$0f00,$0bbb,$ddd,$007b,$0ff0,$0000,$0fff .word $0aef,$0080,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0777,$0f00,$0bbb,$ddd,$007b,$0ff0,$0000,$0fff
statusBarPalette: statusBarPalette:
.word $0888,$0aef,$0F00,$0861,$0c93,$0eb4,$0d66,$0f9a,$00f0,$0fff,$0bbb,$ddd,$007b,$0000,$0ff0,$0fff .word $0888,$0aef,$0F00,$0861,$0c93,$0eb4,$0d66,$0f9a,$00f0,$0fff,$0bbb,$ddd,$007b,$0000,$0ff0,$0fff

Binary file not shown.

View File

@ -206,6 +206,24 @@ nobrk:
.endmacro .endmacro
.macro DEADLOCK
deadlock: jmp deadlock
.endmacro
.macro BREAKLOCK
pha
lda breakpoint
beq nobrk
pla
deadlock: jmp deadlock
nobrk:
pla
.endmacro
;;;;;;;;;; ;;;;;;;;;;
; Stack Macros ; Stack Macros

View File

@ -199,7 +199,7 @@ unclipTerrain:
SAVE_AXY SAVE_AXY
phd phd
lda #(CLIPPEDTERRAINSTACK & $ff00) lda #(CLIPPEDTERRAINSTACK & $f000)
pha pha
pld ; Point direct page at our clip data pld ; Point direct page at our clip data
@ -208,10 +208,14 @@ unclipTerrain:
sbc mapScrollPos sbc mapScrollPos
tay tay
sec ; Find stopping point for stack-relative addressing
lda clippedTerrainStackPtr lda clippedTerrainStackPtr
and #$00ff and #$0fff
sbc #7 ; 4 bytes past top of stack, +3 for starting offset
sta STACKPTR
lda #$0fff-3 ; Start at the bottom of the stack
tax tax
inx
unclipTerrainLoop: unclipTerrainLoop:
lda 2,x lda 2,x
@ -227,11 +231,11 @@ unclipTerrainLoop:
sbc #COMPILEDTERRAINROW+2 sbc #COMPILEDTERRAINROW+2
tay tay
inx dex ; Walk up the stack to reverse the data
inx dex
inx dex
inx dex
cpx #$100 ; When x hits the top of the stack, we're done cpx STACKPT ; When x hits the top of the stack, we're done
bne unclipTerrainLoop bne unclipTerrainLoop
pld pld
@ -424,12 +428,12 @@ prepareRowRenderingLoop:
lda playerData+GO_POSY,y lda playerData+GO_POSY,y
sbc #GAMEOBJECTHEIGHT sbc #GAMEOBJECTHEIGHT
cmp SCRATCHL2 ; cmp SCRATCHL2
bcc prepareRowRenderingCompileMode ; bcc prepareRowRenderingCompileMode
beq prepareRowRenderingCompileMode ; beq prepareRowRenderingCompileMode
jsr enableFillMode ; jsr enableFillMode
bra prepareRowRenderingLoopNext ; bra prepareRowRenderingLoopNext
prepareRowRenderingCompileMode: prepareRowRenderingCompileMode:
jsr disableFillMode jsr disableFillMode
@ -441,6 +445,8 @@ prepareRowRenderingLoopNext:
cpx #200-MAXTERRAINHEIGHT cpx #200-MAXTERRAINHEIGHT
bne prepareRowRenderingLoop bne prepareRowRenderingLoop
prepareRowRenderingDone:
;HARDBRK
RESTORE_AXY RESTORE_AXY
rts rts
@ -487,11 +493,11 @@ generateTerrainLoop:
; lda #2 ; lda #2
; sta compiledTerrain-4 ; sta compiledTerrain-4
rts rts
compiledTerrain: compiledTerrain:
.repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT .repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT
.byte $00 .byte $42
.endrepeat .endrepeat
compiledTerrainEnd: compiledTerrainEnd:

View File

@ -31,6 +31,7 @@ renderTerrainSpans:
lda #MAXTERRAINHEIGHT-1 lda #MAXTERRAINHEIGHT-1
sec sec
sbc lastCompiledTerrainY sbc lastCompiledTerrainY
beq renderTerrainRowSpansSkip ; All terrain needs compiled rendering
renderTerrainSpansLoop: renderTerrainSpansLoop:
sta PARAML1 sta PARAML1
@ -112,6 +113,8 @@ renderTerrainRowSpansDone:
bne renderTerrainSpansLoop bne renderTerrainSpansLoop
pea 0 ; Null-terminate the unrender cache pea 0 ; Null-terminate the unrender cache
renderTerrainRowSpansSkip:
SLOWGRAPHICS SLOWGRAPHICS
RESTORE_DBR RESTORE_DBR
RESTORE_AXY RESTORE_AXY