diff --git a/gscats.2mg b/gscats.2mg index 3a0f349..1967dc9 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/projectile.s b/projectile.s index 447b747..2bba117 100644 --- a/projectile.s +++ b/projectile.s @@ -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 diff --git a/terrain.s b/terrain.s index d6a53f7..5287aa0 100644 --- a/terrain.s +++ b/terrain.s @@ -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 ; diff --git a/utility.s b/utility.s index aa76f73..f0ed556 100644 --- a/utility.s +++ b/utility.s @@ -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