Only recompile affected terrain rows for cratering

This commit is contained in:
blondie7575 2019-12-29 10:26:38 -07:00
parent 2d58dc0862
commit 9baa167896
4 changed files with 68 additions and 6 deletions

Binary file not shown.

View File

@ -877,7 +877,7 @@ processPlayerImpactDeath:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; processTerrainImpact
;
; Trashes A,Y
; Trashes A,Y, SCRATCHL
;
processTerrainImpact:
ldy projectileActive
@ -888,17 +888,19 @@ processTerrainImpact:
lda projectileData+GO_POSX,y
clc
adc #GAMEOBJECTWIDTH/2 ; /2 is a fudge that makes crater location look better in this direction
adc #GAMEOBJECTWIDTH/2+1 ; A fudge that makes crater location look better in this direction, and tunneling work better
bra processTerrainStoreContinue
processTerrainImpactNegative:
lda projectileData+GO_POSX,y
clc
adc #GAMEOBJECTWIDTH/4-1 ; A fudge that makes crater location look better in this direction, and tunneling work better
processTerrainStoreContinue:
sta PARAML0
lda projectileData+GO_POSY,y
sec
sbc #GAMEOBJECTHEIGHT
sbc #GAMEOBJECTHEIGHT ; This fudge makes tunneling work better
sta PARAML1
lda projectileData+JD_TYPE,y
@ -907,9 +909,29 @@ processTerrainStoreContinue:
lda projectileTypes+PT_RADIUS,y
tay
phy ; We'll need the radius in a moment
jsr craterTerrain
jsr compileTerrain
jsr unclipTerrain
; Recompile the rows affected by the crater
clc
lda PARAML1 ; Impact point is top row to recompile
adc #GAMEOBJECTHEIGHT ; Expand recompile area upwards because of tunneling fudge
tax
clc
pla
adc #GAMEOBJECTHEIGHT ; Expand "vertical" radius area because of tunneling fudge
sta SCRATCHL ; Need radius in a memory location for this math
txa
sec
sbc SCRATCHL
tay
lda SCRATCHL
jsr compileTerrainChunk
jsr clipTerrain
rts

View File

@ -271,11 +271,50 @@ compileTerrainLoop:
bra compileTerrainLoop
compileTerrainDone:
;jsl compileTerrainSpans ; Part of the now disabled fill-mode renderer
RESTORE_AY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainChunk
;
; Y = First row to compile (bottom-relative)
; X = Last row to compile (bottom-relative)
; A = |X-Y|
;
; Trashes A,Y, SCRATCHL
;
compileTerrainChunk:
;HARDBRK
stx SCRATCHL
sty PARAML0
; Compute the start of memory affected
lda #COMPILEDTERRAINROW
sta PARAML1
jsr mult16
clc
adc #compiledTerrain
sta PARAML0
compileTerrainChunkLoop:
sty PARAML1
;HARDBRK
jsr compileTerrainRow
iny
cpy SCRATCHL
beq compileTerrainChunkDone
clc
lda #COMPILEDTERRAINROW
adc PARAML0
sta PARAML0
bra compileTerrainChunkLoop
compileTerrainChunkDone:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainRow
;

View File

@ -106,7 +106,8 @@ intToStringResult: .byte 0,0,0,0,0,0
; PARAML1 = Operand 2 (16 bits)
; A => Op1 * Op2 (16 bits)
; Algorithm from https://apple2.gs/downloads/Programmanual.pdf
; Trashes X
;
; Trashes X,PARAML0,PARAML1
;
mult16:
lda #0 ; Initialize result