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

View File

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