Skip to content

Commit

Permalink
Set a flag once all goo baddies in ShadowDrill are dead
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Jun 30, 2024
1 parent 2c7f3e8 commit dfa3084
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/flag.inc
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ kSaveMagicNumber = $b2
ShadowHeartTaggedGhost
ShadowOfficeRemovedWall
ShadowOfficeTaggedGhost
ShadowDrillClearedGoo
NUM_VALUES
.ENDENUM
.ASSERT eFlag::NUM_VALUES <= $100, error
Expand Down
1 change: 1 addition & 0 deletions src/newgame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ _SetFlags:
.byte eFlag::ShadowHallInitialized
.byte eFlag::ShadowHallGlassBroken
.byte eFlag::PaperJerome02
.byte eFlag::ShadowDrillClearedGoo
.byte eFlag::ShadowTrapDisarmed
.byte eFlag::PaperJerome04
.byte eFlag::ShadowHeartTaggedGhost
Expand Down
37 changes: 35 additions & 2 deletions src/rooms/shadow_drill.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.INCLUDE "../actor.inc"
.INCLUDE "../charmap.inc"
.INCLUDE "../device.inc"
.INCLUDE "../flag.inc"
.INCLUDE "../machine.inc"
.INCLUDE "../machines/laser.inc"
.INCLUDE "../macros.inc"
Expand All @@ -42,11 +43,14 @@
.IMPORT FuncA_Room_MachineLaserReset
.IMPORT Func_MachineLaserReadRegC
.IMPORT Func_Noop
.IMPORT Func_SetFlag
.IMPORT Func_SetMachineIndex
.IMPORT Func_WriteToLowerAttributeTable
.IMPORT Ppu_ChrObjShadow
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_MachineGoalHorz_u8_arr
.IMPORT Ram_PlatformLeft_i16_0_arr
.IMPORT Sram_ProgressFlags_arr
.IMPORTZP Zp_AvatarFlags_bObj
.IMPORTZP Zp_AvatarPosY_i16

Expand Down Expand Up @@ -248,6 +252,9 @@ _ReadX:

;;; @param A The bSpawn value for where the avatar is entering the room.
.PROC FuncA_Room_ShadowDrill_EnterRoom
;; Gravity is reversed in this room. If the player avatar entered from a
;; passage, invert its Y-position within the passage so that it will be on
;; the ceiling.
cmp #bSpawn::Passage | kUpperPassageIndex
beq @upperPassage
and #bSpawn::Passage
Expand All @@ -268,15 +275,41 @@ _SetGravityReversed:
lda Zp_AvatarFlags_bObj
ora #bObj::FlipV
sta Zp_AvatarFlags_bObj
_MaybeRemoveGoo:
;; If the ShadowDrillClearedGoo flag is set, remove all the goo baddies.
;; Since these are the only actors in the room, we can just remove all
;; actors.
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowDrillClearedGoo
beq @done
lda #eActor::None
ldx #kMaxActors - 1
@loop:
sta Ram_ActorType_eActor_arr, x
dex
.assert kMaxActors <= $80, error
bpl @loop
@done:
rts
.ENDPROC

.PROC FuncA_Room_ShadowDrill_TickRoom
;; TODO: Once all goos are dead, set a flag to make them not reappear.
ldx #kLaserMachineIndex
jsr Func_SetMachineIndex
jsr FuncA_Room_HarmAvatarIfWithinLaserBeam
jmp FuncA_Room_KillGooWithLaserBeam
jsr FuncA_Room_KillGooWithLaserBeam
_SetFlagIfAllGooBaddiesAreDead:
ldx #kMaxActors - 1
@loop:
lda Ram_ActorType_eActor_arr, x
.assert eActor::None = 0, error
bne @done ; there's still a goo baddie alive
dex
.assert kMaxActors <= $80, error
bpl @loop
ldx #eFlag::ShadowDrillClearedGoo ; param: flag
jmp Func_SetFlag
@done:
rts
.ENDPROC

.PROC FuncA_Room_ShadowDrillLaser_InitReset
Expand Down

0 comments on commit dfa3084

Please sign in to comment.