Skip to content

Commit

Permalink
Remove boss projectiles/body when boss is defeated
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Oct 3, 2024
1 parent 7a3ca98 commit e5bc107
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/boss.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
;;; with Annalog. If not, see <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

.INCLUDE "actor.inc"
.INCLUDE "audio.inc"
.INCLUDE "boss.inc"
.INCLUDE "device.inc"
Expand All @@ -34,7 +35,9 @@
.IMPORT Func_DivMod
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_GetRandomByte
.IMPORT Func_InitActorDefault
.IMPORT Func_InitActorSmokeExplosion
.IMPORT Func_InitActorSmokeParticle
.IMPORT Func_IsFlagSet
.IMPORT Func_LockDoorDevice
.IMPORT Func_MarkRoomSafe
Expand All @@ -47,6 +50,7 @@
.IMPORT Func_SetMachineIndex
.IMPORT Func_ShakeRoom
.IMPORT Func_UnlockDoorDevice
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_DeviceAnim_u8_arr
.IMPORT Ram_DeviceTarget_byte_arr
.IMPORT Ram_DeviceType_eDevice_arr
Expand Down Expand Up @@ -222,6 +226,7 @@ _BossBattle:
jsr Func_SetFlag
jsr Func_MarkRoomSafe
jsr FuncA_Room_DisableAllMachinesAndConsoles
jsr FuncA_Room_ExpireAllBossProjectiles
;; Turn off the boss music.
lda #eMusic::Silence
sta Zp_Next_sAudioCtrl + sAudioCtrl::Music_eMusic
Expand Down Expand Up @@ -441,6 +446,47 @@ _DisableConsoles:
rts
.ENDPROC

;;; Expires all boss-fired projectiles, either turning them to smoke or just
;;; removing them.
.PROC FuncA_Room_ExpireAllBossProjectiles
ldx #kMaxActors - 1
_Loop:
jsr _MaybeExpireActor ; preserves X
dex
.assert kMaxActors <= $80, error
bpl _Loop
rts
_MaybeExpireActor:
lda Ram_ActorType_eActor_arr, x
cmp #eActor::ProjFireball
beq _ExpireFireball
cmp #eActor::ProjBreakfire
beq _ExpireBreakfire
cmp #eActor::ProjBreakball
beq _ExpireBreakball
cmp #eActor::ProjFlamestrike
beq _ExpireFlamestrike
cmp #eActor::ProjSpine
beq _ExpireSpine
cmp #eActor::ProjBreakbomb
beq _ExpireBreakbomb
rts
_ExpireBreakbomb:
_ExpireFireball:
_ExpireSpine:
ldy #eActor::SmokeParticle ; param: actor type
jmp Func_InitActorDefault ; preserves X
_ExpireBreakfire:
lda #$c0 ; param: angle ($c0 = up)
jmp Func_InitActorSmokeParticle ; preserves X
_ExpireBreakball:
jmp Func_InitActorSmokeExplosion ; preserves X
_ExpireFlamestrike:
lda #eActor::None
sta Ram_ActorType_eActor_arr, x
rts
.ENDPROC

;;;=========================================================================;;;

.SEGMENT "PRGA_Objects"
Expand Down
11 changes: 9 additions & 2 deletions src/rooms/boss_lava.asm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
.IMPORT Ram_MachineGoalHorz_u8_arr
.IMPORT Ram_Oam_sObj_arr64
.IMPORT Ram_PlatformLeft_i16_0_arr
.IMPORT Ram_PlatformType_ePlatform_arr
.IMPORT Ram_PpuTransfer_arr
.IMPORTZP Zp_Active_sIrq
.IMPORTZP Zp_Buffered_sIrq
Expand Down Expand Up @@ -665,6 +666,8 @@ _BossHurt:
bne _StartScuttling ; boss is not dead yet
.assert eBossMode::Dead = 0, error
sta Zp_RoomState + sState::Current_eBossMode
lda #ePlatform::Zone
sta Ram_PlatformType_ePlatform_arr + kBossBodyPlatformIndex
rts
_StartScuttling:
lda #eBossMode::Scuttling
Expand Down Expand Up @@ -976,7 +979,12 @@ _RegR:
.PROC FuncA_Room_BossLava_EnterRoom
ldax #DataC_Boss_Lava_sBoss ; param: sBoss ptr
jsr FuncA_Room_InitBoss ; sets Z if boss is alive
bne _BossIsDead
beq _BossIsAlive
_BossIsDead:
;; Remove the boss's body.
lda #ePlatform::Zone
sta Ram_PlatformType_ePlatform_arr + kBossBodyPlatformIndex
rts
_BossIsAlive:
lda #kBossInitHealth
sta Zp_RoomState + sState::BossHealth_u8
Expand All @@ -988,7 +996,6 @@ _BossIsAlive:
lda #kBossInitGoalX
sta Zp_RoomState + sState::BossGoalX_u8
.assert kBossInitGoalY = 0, error
_BossIsDead:
rts
.ENDPROC

Expand Down

0 comments on commit e5bc107

Please sign in to comment.