Terrain chunk compiler now rectangular!

This greatly speeds it up and allows vertical slice compiling to eliminate most false terrain overhangs
This commit is contained in:
blondie7575 2023-07-30 11:09:45 -07:00
parent 826660643c
commit fad2daa4d7
4 changed files with 36 additions and 15 deletions

View File

@ -25,8 +25,6 @@ mainBank2:
jmp titleScreen jmp titleScreen
quitGame: quitGame:
jsr unsetVBLInterruptVector
jsr unsetScanLineInterruptVector
NORMALMEMORY NORMALMEMORY
CLASSICVIDEO CLASSICVIDEO
jml (PRODOSRETURN) jml (PRODOSRETURN)

View File

@ -913,6 +913,10 @@ processTerrainImpactNegative:
processTerrainImpactStoreContinue: processTerrainImpactStoreContinue:
sta PARAML0 sta PARAML0
pha ; Dirt explosion will need this pha ; Dirt explosion will need this
sta compileTerrainRowStart ; Terrain chunk compiler will need this
lda #TERRAINWIDTH
sta compileTerrainRowEnd
lda projectileData+GO_POSY,y lda projectileData+GO_POSY,y
sec sec
sbc #GAMEOBJECTHEIGHT ; This fudge makes tunneling work better sbc #GAMEOBJECTHEIGHT ; This fudge makes tunneling work better
@ -943,9 +947,9 @@ processTerrainImpactStoreContinue:
sta SCRATCHL ; Need radius in a memory location for this math sta SCRATCHL ; Need radius in a memory location for this math
txa txa
sec sec
sbc SCRATCHL ; Need to subtract diameter to ensure enough terrain is recompiled. Not 100% sure why?
sbc SCRATCHL sbc SCRATCHL
tay tay
lda SCRATCHL
jsr compileTerrainChunk jsr compileTerrainChunk
jsr clipTerrain jsr clipTerrain

View File

@ -263,6 +263,9 @@ compileTerrain:
ldy #0 ldy #0
lda #compiledTerrain lda #compiledTerrain
sta PARAML0 sta PARAML0
stz compileTerrainRowStart
lda #TERRAINWIDTH
sta compileTerrainRowEnd
compileTerrainLoop: compileTerrainLoop:
sty PARAML1 sty PARAML1
@ -288,15 +291,15 @@ compileTerrainDone:
; ;
; Y = First row to compile (bottom-relative) ; Y = First row to compile (bottom-relative)
; X = Last row to compile (bottom-relative) ; X = Last row to compile (bottom-relative)
; compileTerrainRowStart = Start column to compile (logical terrainData index)
; compileTerrainRowEnd = Ending column to compile (logical terrainData index)
; ;
; Trashes A,Y, SCRATCHL, PARAML0, PARAML1 ; Trashes A,Y, SCRATCHL, PARAML0, PARAML1
; ;
compileTerrainChunk: compileTerrainChunk:
tya ; Be extra safe and make sure Y is never negative or we'll spray RAM with terrain data tya ; Be extra safe and make sure Y is never negative or we'll spray RAM with terrain data
bmi compileTerrainChunkClampZero bmi compileTerrainChunkClampZero
cpx #MAXTERRAINHEIGHT ; Same caution for top of terrain ldx #MAXTERRAINHEIGHT-1
beq compileTerrainChunkResume
bcs compileTerrainChunkClampTop
compileTerrainChunkResume: compileTerrainChunkResume:
stx SCRATCHL stx SCRATCHL
@ -330,15 +333,14 @@ compileTerrainChunkClampZero:
ldy #0 ldy #0
bra compileTerrainChunkResume bra compileTerrainChunkResume
compileTerrainChunkClampTop:
ldx #MAXTERRAINHEIGHT
bra compileTerrainChunkResume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainRow ; compileTerrainRow
; ;
; PARAML0 = Start of compiled row data ; PARAML0 = Start of compiled row data
; PARAML1 = Row index ; PARAML1 = Row index
; compileTerrainRowStart = Start column to compile (logical terrainData index)
; compileTerrainRowEnd = Ending column to compile (logical terrainData index)
; ;
; Note: DA = PHX = FG/FG ; Note: DA = PHX = FG/FG
; 48 = PHA = FG/BG ; 48 = PHA = FG/BG
@ -347,8 +349,20 @@ compileTerrainChunkClampTop:
compileTerrainRow: compileTerrainRow:
SAVE_AXY SAVE_AXY
ldy #0 lda compileTerrainRowStart ; Initialize horizontal counters
ldx #0 lsr
lsr
and #%11111100 ; Word-align it
tay
asl ; Logical counter is 4x compiled counter
asl
tax
lda compileTerrainRowEnd ; Convert end counter to compiled version
lsr
lsr
and #%11111100
sta compileTerrainRowEndCompiled
compileTerrainColumnLoop: compileTerrainColumnLoop:
stz compileTerrainOpcode stz compileTerrainOpcode
@ -399,7 +413,7 @@ compileTerrainColumnStore:
inx inx
iny iny
iny iny
cpy #VISIBLETERRAINWIDTH cpy compileTerrainRowEndCompiled
bne compileTerrainColumnLoop bne compileTerrainColumnLoop
RESTORE_AXY RESTORE_AXY
@ -462,8 +476,12 @@ compileTerrainColumn3BG:
compileTerrainOpcode: compileTerrainOpcode:
.word 0 .word 0
compileTerrainRowStart:
.word 0
compileTerrainRowEnd:
.word 640
compileTerrainRowEndCompiled:
.word 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; prepareRowRendering: ; prepareRowRendering:
@ -504,7 +522,6 @@ prepareRowRenderingLoopNext:
bne prepareRowRenderingLoop bne prepareRowRenderingLoop
prepareRowRenderingDone: prepareRowRenderingDone:
;HARDBRK
RESTORE_AXY RESTORE_AXY
rts rts

View File

@ -187,6 +187,8 @@ titleScreenMainLoopEndFrame:
titleScreenBeginGame: titleScreenBeginGame:
; Transition to gameplay ; Transition to gameplay
jsr unsetVBLInterruptVector
jsr unsetScanLineInterruptVector
stz menuActionRequested stz menuActionRequested
lda #skyPalette lda #skyPalette
sta PARAML2 sta PARAML2