Fixed memory corruption of spit damage

This commit is contained in:
blondie7575 2024-01-21 18:21:05 -07:00
parent 926e69e33d
commit 30f16aaef5
2 changed files with 14 additions and 12 deletions

View File

@ -132,7 +132,7 @@ playerCreateInit:
sta playerData+PD_POWER,y
lda #START_TREATS
sta playerData+PD_TREATS,y
lda #MAX_ANGER
lda #0
sta playerData+PD_ANGER,y
lda #0
sta playerData+PD_CURRWEAPON,y
@ -248,9 +248,9 @@ playerFire:
; Check for movement
lda playerData+PD_CURRWEAPON,y
cmp #3
cmp #PT_MOVELEFT
beq playerFireMoveLeft
cmp #4
cmp #PT_MOVERIGHT
beq playerFireMoveRight
; Animate the shooting
@ -544,9 +544,7 @@ syncPlayerHeader:
PLAYERPTR_Y
; Convert anger to progress bar value
sec
lda #MAX_ANGER
sbc playerData+PD_ANGER,y
lda playerData+PD_ANGER,y
lsr
lsr
jsr setProgressBar

View File

@ -92,6 +92,8 @@ projectileTypes:
PT_SPIT = 0
PT_BOMB = 1
PT_FAN = 2
PT_MOVELEFT = 3
PT_MOVERIGHT = 3
; Spit
.word 4 ; Damage
@ -678,6 +680,7 @@ endProjectile:
; Trashes A
;
deleteProjectile:
phx
lda projectileData+GO_POSX,y
bmi deleteProjectileDone ; Already deleted
@ -694,6 +697,7 @@ deleteProjectile:
JSRA
deleteProjectileDone:
plx
rts
@ -709,7 +713,7 @@ deleteAllProjectilesLoop:
PROJECTILEPTR_Y
jsr deleteProjectile
inx
cpx #4
cpx #3
bne deleteAllProjectilesLoop
RESTORE_AXY
@ -962,12 +966,12 @@ processPlayerImpact:
; Apply damage
lda playerData+PD_ANGER,x
sec
sbc projectileTypes+PT_DAMAGE,y
clc
adc projectileTypes+PT_DAMAGE,y
; Check for death
beq processPlayerImpactDeath
bmi processPlayerImpactDeath
cmp #MAX_ANGER
bcs processPlayerImpactDeath
sta playerData+PD_ANGER,x
rts