Better clamping for terrain chunk compiling

This commit is contained in:
blondie7575 2023-08-04 19:37:09 -07:00
parent 49c1b08cb0
commit 92a3a9040e
2 changed files with 17 additions and 6 deletions

View File

@ -939,7 +939,7 @@ processTerrainImpactStoreContinue:
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

View File

@ -295,12 +295,19 @@ compileTerrainDone:
; 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
; Clamp chunk to left and right terrain edges
lda compileTerrainRowStart
bmi compileTerrainChunkClampZero
ldx #MAXTERRAINHEIGHT-1
compileTerrainChunkClampResume:
lda compileTerrainRowEnd
cmp #TERRAINWIDTH
bcs compileTerrainChunkClampHigh
compileTerrainChunkResume:
ldy #0
ldx #MAXTERRAINHEIGHT-1
stx SCRATCHL
sty PARAML0
@ -329,9 +336,13 @@ compileTerrainChunkDone:
rts
compileTerrainChunkClampZero:
ldy #0
bra compileTerrainChunkResume
stz compileTerrainRowStart
bra compileTerrainChunkClampResume
compileTerrainChunkClampHigh:
lda #TERRAINWIDTH-1
sta compileTerrainRowEnd
bra compileTerrainChunkResume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainRow