Fixed nasty memory overwrite

If terrain crater was on a mountain top, the crate math tried to compile above max terrain height
This commit is contained in:
blondie7575 2023-07-22 18:01:10 -07:00
parent 4b183a0d99
commit 2c1100f0b8
2 changed files with 9 additions and 4 deletions

View File

@ -59,14 +59,14 @@
isa = PBXGroup;
children = (
70E9D85F1F2BD95400555C19 /* equates.s */,
700F21DE1F43E31300D7007D /* input.s */,
70E9D8621F2BD95400555C19 /* macros.s */,
706DF1641F2D39F700AA6680 /* loader.s */,
701E708E2A67844B0030C35D /* loaderGraphics.s */,
701E708F2A69CE520030C35D /* loadingBar.s */,
701E70902A6A23800030C35D /* sharedGraphics.s */,
70E9D8601F2BD95400555C19 /* graphics.s */,
70E9D8611F2BD95400555C19 /* gscats.s */,
70E9D8621F2BD95400555C19 /* macros.s */,
70A80FB01F43D7F200BD34C9 /* gamemanager.s */,
7099E3841F41022100182A82 /* gameobject.s */,
70F011D123B989B800C8873F /* random.s */,
706DF1651F2D4A8100AA6680 /* terrain.s */,
@ -74,6 +74,7 @@
70F011D023B91B2900C8873F /* dirt.s */,
70C073091F5BAA3E009844A9 /* collision.s */,
70F086A01F4230CB002446C3 /* utility.s */,
700F21DE1F43E31300D7007D /* input.s */,
700C39C51F2E5CA800C24F9C /* tables.s */,
70E266E31F6F262D005AC7E4 /* circleTable.s */,
70F0869F1F413A89002446C3 /* player.s */,
@ -84,7 +85,6 @@
700F21DF1F4A364600D7007D /* projectile.s */,
705C54E62124B7F300515A6B /* fan.s */,
708D1B1E27B9A1A600909AFC /* crosshair.s */,
70A80FB01F43D7F200BD34C9 /* gamemanager.s */,
70E554C41F807ADB00F3C871 /* spritebank.s */,
70E9D8631F2BD95400555C19 /* Makefile */,
70BDCBC92006AD5F00CB51F1 /* linkerConfig */,

View File

@ -294,6 +294,9 @@ compileTerrainDone:
compileTerrainChunk:
tya ; Be extra safe and make sure Y is never negative or we'll spray RAM with terrain data
bmi compileTerrainChunkClampZero
cpx #MAXTERRAINHEIGHT ; Same caution for top of terrain
beq compileTerrainChunkResume
bcs compileTerrainChunkClampTop
compileTerrainChunkResume:
stx SCRATCHL
@ -309,7 +312,6 @@ compileTerrainChunkResume:
compileTerrainChunkLoop:
sty PARAML1
;HARDBRK
jsr compileTerrainRow
iny
cpy SCRATCHL
@ -328,6 +330,9 @@ compileTerrainChunkClampZero:
ldy #0
bra compileTerrainChunkResume
compileTerrainChunkClampTop:
ldx #MAXTERRAINHEIGHT
bra compileTerrainChunkResume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainRow