diff --git a/projectile.s b/projectile.s index cb1f7a9..710e86b 100644 --- a/projectile.s +++ b/projectile.s @@ -914,7 +914,6 @@ processTerrainImpactStoreContinue: sta PARAML0 pha ; Dirt explosion will need this sta compileTerrainRowStart ; Terrain chunk compiler will need this - lda #TERRAINWIDTH sta compileTerrainRowEnd lda projectileData+GO_POSY,y @@ -927,6 +926,20 @@ processTerrainImpactStoreContinue: tay PROJECTILETYPEPTR_Y + sec ; Quick sidebar to calculate crater compiling extents while we have the pointers + lda #TERRAINWIDTH + sbc compileTerrainRowStart + sbc projectileTypes+PT_RADIUS,y + sbc projectileTypes+PT_RADIUS,y + sta compileTerrainRowStart + sec + lda #TERRAINWIDTH + sbc compileTerrainRowEnd + clc + adc projectileTypes+PT_RADIUS,y + adc #GAMEOBJECTWIDTH + sta compileTerrainRowEnd +;don't forget to clamp these to terrain edges' lda projectileTypes+PT_RADIUS,y tay phy ; We'll need the radius in a moment diff --git a/terrain.s b/terrain.s index 34ae3a4..dce122e 100644 --- a/terrain.s +++ b/terrain.s @@ -289,14 +289,13 @@ compileTerrainDone: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; compileTerrainChunk ; -; Y = First 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 ; compileTerrainChunk: + ldy #0 tya ; Be extra safe and make sure Y is never negative or we'll spray RAM with terrain data bmi compileTerrainChunkClampZero ldx #MAXTERRAINHEIGHT-1