diff --git a/constants/seasons/parts.s b/constants/seasons/parts.s index a801699a..882a0a9a 100644 --- a/constants/seasons/parts.s +++ b/constants/seasons/parts.s @@ -41,8 +41,8 @@ .define PART_KING_MOBLINS_CANNONS $2d ;; -; created by facade - holes? -.define PART_2e $2e +; Created by facade to temporarily make holes. +.define PART_FACADE_HOLE_MAKER $2e ;; .define PART_2f $2f diff --git a/object_code/seasons/enemies/facade.s b/object_code/seasons/enemies/facade.s index 2bab385d..033b0d68 100644 --- a/object_code/seasons/enemies/facade.s +++ b/object_code/seasons/enemies/facade.s @@ -1,315 +1,448 @@ ; ================================================================================================== ; ENEMY_FACADE +; +; Variables: +; var03: The attack that has been randomly chosen. +; var30: The number of Beetles that have been spawned by the Beetle attack. ; ================================================================================================== enemyCode71: jr z,@normalStatus - sub $03 + sub ENEMYSTATUS_NO_HEALTH ret c ret nz - ; dead - ld e,$a4 + + ; Dead + ld e,Enemy.collisionType ld a,(de) or a - call nz,@dead - ld e,$82 + call nz,facadeKillSpawnedBeetles + + ld e,Enemy.subid ld a,(de) or a jp nz,enemyDie jp enemyBoss_dead @normalStatus: - ld e,$84 + ld e,Enemy.state ld a,(de) rst_jumpTable - .dw @state0 - .dw @stateStub - .dw @stateStub - .dw @stateStub - .dw @stateStub - .dw @stateStub - .dw @stateStub - .dw @stateStub - .dw @state8 - .dw @state9 - .dw @stateA - .dw @stateB - .dw @stateC - -@state0: + .dw facade_state_uninitialized + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_stub + .dw facade_state_waiting + .dw facade_state_chooseAttackAndBecomeVisible + .dw facade_state_waitAndRumble + .dw facade_state_attack + .dw facade_state_resetAndInvisible + +; Do different initialization depending on [subId]: +; zero: Just wait. +; non-zero: Start the fight. +facade_state_uninitialized: call ecom_setSpeedAndState8 - ld l,$8b + + ld l,Enemy.yh ld (hl),$58 - ld l,$8d + ld l,Enemy.xh ld (hl),$78 - ld e,$82 + + ; If subid == 0, jump to enemyBoss_initializeRoom. + ld e,Enemy.subid ld a,(de) or a ld a,$ff ld b,$00 jp z,enemyBoss_initializeRoom - ld l,$86 + + ; If subid is non-zero, start the fight. + ld l,Enemy.counter1 ld (hl),$3c - ld l,$84 + + ; [state] = 9 + ld l,Enemy.state inc (hl) ret -@stateStub: +facade_state_stub: ret -@state8: +; Waiting for Link to enter the fight. Only entered when subId is 0. +facade_state_waiting: + ; If Link is below $58, the fight is triggered. ldh a,(wRoomCollisions + ld a,(hl) + or a + jp nz,partDelete + + ld a,SND_POOF + call playSound + + jp objectSetVisible83 + +; Either make a hole or reset the tile at this position, depending on the value +; of animParameter. +@modifyTile: + ; Set animParameter to 0 so we only run this once. + push af + xor a + ld (de),a + call objectGetTileAtPosition + pop af + + ld e,Part.var30 + + ; If [animParameter] == 1, make a hole, otherwise (if it's 2), reset. + dec a + jr z,@@makeHole + + ; Reset the tile to what it was before. + ld a,(de) + ld (hl),a + ret + +; Store the current kind of tile in var30, then make the tile a hole. +@@makeHole: + ld a,(hl) + ld (de),a + ld (hl),TILEINDEX_HOLE + ret diff --git a/seasons.s b/seasons.s index ba2faabd..e228c5e6 100644 --- a/seasons.s +++ b/seasons.s @@ -675,7 +675,7 @@ m_section_free Part_Code_2 NAMESPACE partCode .include "object_code/seasons/parts/wallFlameShooterFlames.s" .include "object_code/seasons/parts/buriedMoldorm.s" .include "object_code/seasons/parts/kingMoblinsCannons.s" - .include "object_code/seasons/parts/2e.s" + .include "object_code/seasons/parts/facadeHoleMaker.s" .include "object_code/seasons/parts/2f.s" .include "object_code/seasons/parts/poppableBubble.s" .include "object_code/seasons/parts/33.s"