Alchemy
Loading...
Searching...
No Matches

bilibin_cave.c File Reference

The cave that leads past Bilibin, in three sections walked in turn: the entrance section (BilibinCave3) with a Growth plant, the middle section (BilibinCave2) with Reveal and Douse, and the exit section (BilibinCave1), a puzzle of Douse, Frost and pushed actors. More...

Go to the source code of this file.

Macros

#define DIRECTION_STEP(dx, dz)
 Packs signed pixel steps with X in the upper halfword and Z in the lower.

Enumerations

enum  { GROWTH_TARGET = 8 }
 Actors of the entrance section, named by the Psynergy that works on them. More...
enum  { MIDDLE_DOUSE_TARGET = 9 }
 Actors of the middle section. More...
enum  {
  EXIT_DOUSE_TARGET = 8 , PUSHED_ACTOR_A = 11 , PUSHED_ACTOR_B = 12 , FROST_TARGET_A = 15 ,
  FROST_TARGET_B = 16 , FROST_TARGET_C = 17
}
 Actors of the exit section. More...

Functions

static void BilibinCave_RestoreGrowthSection (void)
 Restores the collision change already made by Growth.
static void BilibinCave_RestoreDouseSection (void)
 Opens section 2 and restores its Douse target.
static void BilibinCave_RestoreIcePuzzleSection (void)
 Initializes section 1's animated actors and persistent puzzle states.
static void BilibinCave_EmptyActorSetupHook (s32 actorId)
 The original setup invokes this empty hook for every animated actor.
static s32 BilibinCave_ClearScriptedActorSpriteFlags (struct ScriptInterpreter *interpreter)
 Clears the scripted actor's sprite flags and completes this script command.
const struct SceneEntrance * BilibinCave_GetEntrances (void)
const struct SceneRegion * BilibinCave_GetRegions (void)
const u32 * BilibinCave_GetExits (void)
const struct ScenePlacement * BilibinCave_GetPlacements (void)
const struct SceneEvent * BilibinCave_GetEvents (void)
static void Event_AlterCrossingCell (void)
 Replaces the crossing cell with the attributes at source cell (1, 0).
static void Event_RestoreCrossingCell (void)
 Restores the crossing cell from source cell (0, 0).
static void Event_RevealHiddenPath (void)
 Replaces the narrow tile strip and its two-row collision rectangle.
static void Event_HideRevealedPath (void)
 Restores the strip's tiles and its one-row collision rectangle.
static void Event_DouseMiddleSectionTarget (void)
 Douse on the middle section's target: it disappears, for good.
static void Event_DouseExitSectionTarget (void)
 Douse on the exit section's target: it disappears, and the first Frost target settles into a surface the party can walk over.
static void BilibinCave_FreezeTarget (s32 actor)
 Clears a Frost target's child effect, then plays its freezing animation.
static void Event_FreezeFirstTarget (void)
 Frost on the first target, before the Douse target is gone.
static void Event_FreezeSecondTarget (void)
 Frost on the second target.
static void Event_FreezeThirdTarget (void)
 Frost on the third target, while 0x302 is set.
static void BilibinCave_UpdateFrostTargetFromMovableActors (void)
 After a push or Move: while either pushed actor stands on cell (35, 23) (0x303 and 0x304), the third Frost target changes with a sound, and 0x302 says so; when both leave, it changes back.
static void Event_GrowPlant (void)
 Growth on the entrance section's target: the plant grows and its cell's collision changes; 0x305 keeps it grown.
static void Event_SetMapTriggerFlag (void)
 Enables the map-work byte while crossing this touch trigger.
static void Event_ClearMapTriggerFlag (void)
 Clears the same map-work byte at the opposing trigger.
s32 BilibinCave_Initialize (void)
 Restores the current section's saved puzzle state.
static void BilibinCave_ClearActorSpriteFlags (s32 actorId)
 Clears the drawing flags of an actor used by the cave's animations.
static void Event_PushActorAhead (void)
 Pushes the actor ahead only when its next cell and movement probe are clear.

Variables

s32 gBilibinCave_ClearSpriteScript []
struct SceneEntrance gBilibinCaveEntrancesOther []
struct SceneEntrance gBilibinCaveEntrances3 []
struct SceneEntrance gBilibinCaveEntrances2 []
struct SceneEntrance gBilibinCaveEntrances1 []
u32 gBilibinCaveExits []
struct ScenePlacement gBilibinCavePlacementsOther []
struct ScenePlacement gBilibinCavePlacements3 []
struct ScenePlacement gBilibinCavePlacements2 []
struct ScenePlacement gBilibinCavePlacements1 []
struct SceneEvent gBilibinCaveEventsOther []
struct SceneEvent gBilibinCaveEvents3 []
struct SceneEvent gBilibinCaveEvents2 []
struct SceneEvent gBilibinCaveEvents1 []
s32 gBilibinCave_PushSteps []

Detailed Description

The cave that leads past Bilibin, in three sections walked in turn: the entrance section (BilibinCave3) with a Growth plant, the middle section (BilibinCave2) with Reveal and Douse, and the exit section (BilibinCave1), a puzzle of Douse, Frost and pushed actors.

Definition in file bilibin_cave.c.

Macro Definition Documentation

◆ DIRECTION_STEP

#define DIRECTION_STEP ( dx,
dz )
Value:
(((u32)(dx) << 16) | ((dz) & 0xffff))
unsigned int u32
Definition types.h:15

Packs signed pixel steps with X in the upper halfword and Z in the lower.

Definition at line 638 of file bilibin_cave.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Actors of the entrance section, named by the Psynergy that works on them.

Enumerator
GROWTH_TARGET 

Definition at line 44 of file bilibin_cave.c.

◆ anonymous enum

anonymous enum

Actors of the middle section.

Enumerator
MIDDLE_DOUSE_TARGET 

Definition at line 47 of file bilibin_cave.c.

◆ anonymous enum

anonymous enum

Actors of the exit section.

Enumerator
EXIT_DOUSE_TARGET 
PUSHED_ACTOR_A 

moved by Move or pushed

PUSHED_ACTOR_B 
FROST_TARGET_A 

walkable once the Douse target is gone

FROST_TARGET_B 
FROST_TARGET_C 

changes as a pushed actor reaches cell (35, 23)

Definition at line 50 of file bilibin_cave.c.

Function Documentation

◆ BilibinCave_RestoreGrowthSection()

void BilibinCave_RestoreGrowthSection ( void )
static

Restores the collision change already made by Growth.

Definition at line 291 of file bilibin_cave.c.

Referenced by BilibinCave_Initialize(), and BilibinCave_RestoreGrowthSection().

◆ BilibinCave_RestoreDouseSection()

void BilibinCave_RestoreDouseSection ( void )
static

Opens section 2 and restores its Douse target.

Definition at line 300 of file bilibin_cave.c.

Referenced by BilibinCave_Initialize(), and BilibinCave_RestoreDouseSection().

◆ BilibinCave_RestoreIcePuzzleSection()

void BilibinCave_RestoreIcePuzzleSection ( void )
static

Initializes section 1's animated actors and persistent puzzle states.

Definition at line 322 of file bilibin_cave.c.

Referenced by BilibinCave_Initialize(), and BilibinCave_RestoreIcePuzzleSection().

◆ BilibinCave_EmptyActorSetupHook()

void BilibinCave_EmptyActorSetupHook ( s32 actorId)
static

The original setup invokes this empty hook for every animated actor.

Definition at line 473 of file bilibin_cave.c.

Referenced by BilibinCave_EmptyActorSetupHook(), and BilibinCave_RestoreIcePuzzleSection().

◆ BilibinCave_ClearScriptedActorSpriteFlags()

s32 BilibinCave_ClearScriptedActorSpriteFlags ( struct ScriptInterpreter * interpreter)
static

Clears the scripted actor's sprite flags and completes this script command.

Definition at line 60 of file bilibin_cave.c.

Referenced by BilibinCave_ClearScriptedActorSpriteFlags().

◆ BilibinCave_GetEntrances()

const struct SceneEntrance * BilibinCave_GetEntrances ( void )

Definition at line 67 of file bilibin_cave.c.

Referenced by BilibinCave_GetEntrances().

◆ BilibinCave_GetRegions()

const struct SceneRegion * BilibinCave_GetRegions ( void )

Definition at line 82 of file bilibin_cave.c.

Referenced by BilibinCave_GetRegions().

◆ BilibinCave_GetExits()

const u32 * BilibinCave_GetExits ( void )

Definition at line 84 of file bilibin_cave.c.

Referenced by BilibinCave_GetExits().

◆ BilibinCave_GetPlacements()

const struct ScenePlacement * BilibinCave_GetPlacements ( void )

Definition at line 86 of file bilibin_cave.c.

Referenced by BilibinCave_GetPlacements().

◆ BilibinCave_GetEvents()

const struct SceneEvent * BilibinCave_GetEvents ( void )

Definition at line 101 of file bilibin_cave.c.

Referenced by BilibinCave_GetEvents().

◆ Event_AlterCrossingCell()

void Event_AlterCrossingCell ( void )
static

Replaces the crossing cell with the attributes at source cell (1, 0).

Definition at line 117 of file bilibin_cave.c.

Referenced by Event_AlterCrossingCell().

◆ Event_RestoreCrossingCell()

void Event_RestoreCrossingCell ( void )
static

Restores the crossing cell from source cell (0, 0).

Definition at line 122 of file bilibin_cave.c.

Referenced by Event_RestoreCrossingCell().

◆ Event_RevealHiddenPath()

void Event_RevealHiddenPath ( void )
static

Replaces the narrow tile strip and its two-row collision rectangle.

Definition at line 127 of file bilibin_cave.c.

Referenced by Event_RevealHiddenPath().

◆ Event_HideRevealedPath()

void Event_HideRevealedPath ( void )
static

Restores the strip's tiles and its one-row collision rectangle.

Definition at line 143 of file bilibin_cave.c.

Referenced by Event_HideRevealedPath().

◆ Event_DouseMiddleSectionTarget()

void Event_DouseMiddleSectionTarget ( void )
static

Douse on the middle section's target: it disappears, for good.

Definition at line 159 of file bilibin_cave.c.

Referenced by Event_DouseMiddleSectionTarget().

◆ Event_DouseExitSectionTarget()

void Event_DouseExitSectionTarget ( void )
static

Douse on the exit section's target: it disappears, and the first Frost target settles into a surface the party can walk over.

Definition at line 168 of file bilibin_cave.c.

Referenced by Event_DouseExitSectionTarget().

◆ BilibinCave_FreezeTarget()

void BilibinCave_FreezeTarget ( s32 actor)
inlinestatic

Clears a Frost target's child effect, then plays its freezing animation.

Definition at line 183 of file bilibin_cave.c.

Referenced by BilibinCave_FreezeTarget(), Event_FreezeFirstTarget(), Event_FreezeSecondTarget(), and Event_FreezeThirdTarget().

◆ Event_FreezeFirstTarget()

void Event_FreezeFirstTarget ( void )
static

Frost on the first target, before the Douse target is gone.

Definition at line 193 of file bilibin_cave.c.

Referenced by Event_FreezeFirstTarget().

◆ Event_FreezeSecondTarget()

void Event_FreezeSecondTarget ( void )
static

Frost on the second target.

Definition at line 198 of file bilibin_cave.c.

Referenced by Event_FreezeSecondTarget().

◆ Event_FreezeThirdTarget()

void Event_FreezeThirdTarget ( void )
static

Frost on the third target, while 0x302 is set.

Definition at line 203 of file bilibin_cave.c.

Referenced by Event_FreezeThirdTarget().

◆ BilibinCave_UpdateFrostTargetFromMovableActors()

void BilibinCave_UpdateFrostTargetFromMovableActors ( void )
static

After a push or Move: while either pushed actor stands on cell (35, 23) (0x303 and 0x304), the third Frost target changes with a sound, and 0x302 says so; when both leave, it changes back.

Definition at line 210 of file bilibin_cave.c.

Referenced by BilibinCave_UpdateFrostTargetFromMovableActors(), and Event_PushActorAhead().

◆ Event_GrowPlant()

void Event_GrowPlant ( void )
static

Growth on the entrance section's target: the plant grows and its cell's collision changes; 0x305 keeps it grown.

Definition at line 258 of file bilibin_cave.c.

Referenced by Event_GrowPlant(), Event_GrowPlant(), Event_GrowPlant(), and Event_GrowPlant().

◆ Event_SetMapTriggerFlag()

void Event_SetMapTriggerFlag ( void )
static

Enables the map-work byte while crossing this touch trigger.

Definition at line 265 of file bilibin_cave.c.

Referenced by Event_SetMapTriggerFlag().

◆ Event_ClearMapTriggerFlag()

void Event_ClearMapTriggerFlag ( void )
static

Clears the same map-work byte at the opposing trigger.

Definition at line 271 of file bilibin_cave.c.

Referenced by Event_ClearMapTriggerFlag().

◆ BilibinCave_Initialize()

s32 BilibinCave_Initialize ( void )

Restores the current section's saved puzzle state.

Definition at line 277 of file bilibin_cave.c.

Referenced by BilibinCave_Initialize().

◆ BilibinCave_ClearActorSpriteFlags()

void BilibinCave_ClearActorSpriteFlags ( s32 actorId)
inlinestatic

Clears the drawing flags of an actor used by the cave's animations.

Definition at line 316 of file bilibin_cave.c.

Referenced by BilibinCave_ClearActorSpriteFlags(), and BilibinCave_RestoreIcePuzzleSection().

◆ Event_PushActorAhead()

void Event_PushActorAhead ( void )
static

Pushes the actor ahead only when its next cell and movement probe are clear.

Definition at line 407 of file bilibin_cave.c.

Referenced by Event_PushActorAhead().

Variable Documentation

◆ gBilibinCave_ClearSpriteScript

s32 gBilibinCave_ClearSpriteScript[]
Initial value:
= {
}
static s32 BilibinCave_ClearScriptedActorSpriteFlags(struct ScriptInterpreter *interpreter)
Clears the scripted actor's sprite flags and completes this script command.
#define SC_END
Return to the main script.
Definition objcmd.h:32
#define SC_CALL(fn)
Definition objcmd.h:50

Definition at line 475 of file bilibin_cave.c.

◆ gBilibinCaveEntrancesOther

struct SceneEntrance gBilibinCaveEntrancesOther[]
Initial value:
= {
{0, CONDITION_ALWAYS, 72, 0, 488, FACING_NORTH, 0, -1, -1, -1, -1, 0},
}
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ FACING_NORTH
Definition field_scene.h:32

Definition at line 480 of file bilibin_cave.c.

Referenced by BilibinCave_GetEntrances().

◆ gBilibinCaveEntrances3

struct SceneEntrance gBilibinCaveEntrances3[]
Initial value:
= {
{0, CONDITION_ALWAYS, 372, 0, 272, FACING_NORTH, 0, -1, -1, -1, -1, 0},
{1, CONDITION_ALWAYS, 99, 0, 447, FACING_NORTH, 0, -1, -1, -1, -1, 0},
{2, CONDITION_ALWAYS, 342, 0, 254, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
{3, CONDITION_ALWAYS, 440, 0, 136, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
}
@ FACING_SOUTH
Definition field_scene.h:28

Definition at line 485 of file bilibin_cave.c.

Referenced by BilibinCave_GetEntrances().

◆ gBilibinCaveEntrances2

struct SceneEntrance gBilibinCaveEntrances2[]
Initial value:
= {
{0, CONDITION_ALWAYS, 864, 0, 168, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
{1, CONDITION_ALWAYS, 312, 0, 756, FACING_NORTH, 0, 40, 60, 630, 840, 0},
{2, CONDITION_ALWAYS, 472, 0, 680, FACING_NORTH, 0, 40, 60, 630, 840, 0},
{3, CONDITION_ALWAYS, 392, 0, 200, FACING_SOUTH, 0, 40, 60, 630, 840, 0},
{4, CONDITION_ALWAYS, 536, 0, 426, FACING_SOUTH, 0, 40, 60, 630, 840, 0},
{5, CONDITION_ALWAYS, 856, 0, 124, FACING_SOUTH, 0, 760, 65, 925, 330, 0},
{6, CONDITION_ALWAYS, 808, 0, 248, FACING_NORTH, 0, 760, 65, 925, 330, 0},
}

Definition at line 493 of file bilibin_cave.c.

Referenced by BilibinCave_GetEntrances().

◆ gBilibinCaveEntrances1

struct SceneEntrance gBilibinCaveEntrances1[]
Initial value:
= {
{0, CONDITION_ALWAYS, 172, 0, 300, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
{1, CONDITION_ALWAYS, 120, 0, 472, FACING_NORTH, 0, 60, 60, 790, 600, 0},
{2, CONDITION_ALWAYS, 312, 0, 524, FACING_NORTH, 0, 60, 60, 790, 600, 0},
{3, CONDITION_ALWAYS, 538, 0, 548, FACING_NORTH, 0, 60, 60, 790, 600, 0},
{4, CONDITION_ALWAYS, 344, 0, 176, FACING_SOUTH, 0, 60, 60, 790, 600, 0},
{5, CONDITION_ALWAYS, 856, 0, 632, FACING_NORTH, 0, 740, 510, 980, 690, 0},
}

Definition at line 504 of file bilibin_cave.c.

Referenced by BilibinCave_GetEntrances().

◆ gBilibinCaveExits

u32 gBilibinCaveExits[]
Initial value:
= {
SCENE_EXITS(49), SCENE_EXIT(1, 2, 35), SCENE_EXIT(2, 48, 1),
SCENE_EXIT(3, 48, 2), SCENE_EXIT(0, 48, 0), SCENE_EXIT(1, 49, 2),
SCENE_EXIT(2, 49, 3), SCENE_EXIT(3, 47, 1), SCENE_EXIT(4, 48, 6),
SCENE_EXIT(5, 47, 2), SCENE_EXIT(6, 48, 4), SCENE_EXIT(0, 47, 0),
SCENE_EXIT(1, 48, 3), SCENE_EXIT(2, 48, 5), SCENE_EXIT(3, 2, 48),
SCENE_EXIT(4, 47, 5), SCENE_EXIT(5, 47, 4), SCENE_EXITS_END,
}
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#define SCENE_EXIT(exit, scene, entrance)
Definition field_scene.h:73
#define SCENE_EXITS_END
Definition field_scene.h:77

Definition at line 514 of file bilibin_cave.c.

Referenced by BilibinCave_GetExits().

◆ gBilibinCavePlacementsOther

struct ScenePlacement gBilibinCavePlacementsOther[]
Initial value:
= {
}

Definition at line 523 of file bilibin_cave.c.

Referenced by BilibinCave_GetPlacements().

◆ gBilibinCavePlacements3

struct ScenePlacement gBilibinCavePlacements3[]
Initial value:
= {
}
@ TALK_KEEP_FACING
@ ACTOR_STAND
#define PIXELS(value)

Definition at line 528 of file bilibin_cave.c.

Referenced by BilibinCave_GetPlacements().

◆ gBilibinCavePlacements2

struct ScenePlacement gBilibinCavePlacements2[]
Initial value:

Definition at line 534 of file bilibin_cave.c.

Referenced by BilibinCave_GetPlacements().

◆ gBilibinCavePlacements1

struct ScenePlacement gBilibinCavePlacements1[]

Definition at line 544 of file bilibin_cave.c.

Referenced by BilibinCave_GetPlacements().

◆ gBilibinCaveEventsOther

struct SceneEvent gBilibinCaveEventsOther[]
Initial value:
= {
}
#define SCENE_EVENTS_END

Definition at line 586 of file bilibin_cave.c.

Referenced by BilibinCave_GetEvents().

◆ gBilibinCaveEvents3

struct SceneEvent gBilibinCaveEvents3[]
Initial value:
= {
}
@ ABILITY_GROWTH
Definition ability_ids.h:10
@ GROWTH_TARGET
static void Event_RestoreCrossingCell(void)
Restores the crossing cell from source cell (0, 0).
static void Event_GrowPlant(void)
Growth on the entrance section's target: the plant grows and its cell's collision changes; 0x305 keep...
static void Event_AlterCrossingCell(void)
Replaces the crossing cell with the attributes at source cell (1, 0).
@ EVENT_TOUCH
@ EVENT_EXIT
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)

Definition at line 590 of file bilibin_cave.c.

Referenced by BilibinCave_GetEvents().

◆ gBilibinCaveEvents2

struct SceneEvent gBilibinCaveEvents2[]
Initial value:
= {
}
@ ABILITY_DOUSE
Definition ability_ids.h:12
@ ABILITY_REVEAL
Definition ability_ids.h:19
static void Event_RevealHiddenPath(void)
Replaces the narrow tile strip and its two-row collision rectangle.
static void Event_DouseMiddleSectionTarget(void)
Douse on the middle section's target: it disappears, for good.
@ MIDDLE_DOUSE_TARGET
static void Event_HideRevealedPath(void)
Restores the strip's tiles and its one-row collision rectangle.
#define FIND_ITEM(item)
#define PSYNERGY_IN_AREA(ability, phase)
#define SEARCH(target)
@ SEARCH_CHEST
#define FLAG_BILIBIN_CAVE_SECOND_DOUSE_TARGET_CLEARED
Definition flags.h:110
@ ITEM_ELVEN_RAPIER
Definition item_ids.h:15

Definition at line 600 of file bilibin_cave.c.

Referenced by BilibinCave_GetEvents().

◆ gBilibinCaveEvents1

struct SceneEvent gBilibinCaveEvents1[]
Initial value:
= {
{ SEARCH(SEARCH_CHEST), 100, 0xf5e, FIND_ITEM(ITEM_VIAL) },
}
@ ABILITY_MOVE
Definition ability_ids.h:15
@ ABILITY_FROST
Definition ability_ids.h:11
static void Event_ClearMapTriggerFlag(void)
Clears the same map-work byte at the opposing trigger.
static void BilibinCave_UpdateFrostTargetFromMovableActors(void)
After a push or Move: while either pushed actor stands on cell (35, 23) (0x303 and 0x304),...
static void Event_SetMapTriggerFlag(void)
Enables the map-work byte while crossing this touch trigger.
static void Event_FreezeThirdTarget(void)
Frost on the third target, while 0x302 is set.
static void Event_PushActorAhead(void)
Pushes the actor ahead only when its next cell and movement probe are clear.
static void Event_FreezeSecondTarget(void)
Frost on the second target.
static void Event_DouseExitSectionTarget(void)
Douse on the exit section's target: it disappears, and the first Frost target settles into a surface ...
@ FROST_TARGET_B
@ PUSHED_ACTOR_B
@ EXIT_DOUSE_TARGET
@ FROST_TARGET_C
changes as a pushed actor reaches cell (35, 23)
@ FROST_TARGET_A
walkable once the Douse target is gone
@ PUSHED_ACTOR_A
moved by Move or pushed
static void Event_FreezeFirstTarget(void)
Frost on the first target, before the Douse target is gone.
#define IF_FLAG_SET(flag)
Definition field_scene.h:48
#define TOUCH_WALKING_INTO(facing)
@ FACING_WEST
Definition field_scene.h:30
#define TOUCH_WALKING
#define FLAG_BILIBIN_CAVE_FIRST_DOUSE_TARGET_CLEARED
Definition flags.h:111
@ ITEM_WATER_OF_LIFE
Definition item_ids.h:49
@ ITEM_VIAL
Definition item_ids.h:42
@ ITEM_PSY_CRYSTAL
Definition item_ids.h:46

Definition at line 614 of file bilibin_cave.c.

Referenced by BilibinCave_GetEvents().

◆ gBilibinCave_PushSteps

s32 gBilibinCave_PushSteps[]
Initial value:
= {
DIRECTION_STEP(0, 16), DIRECTION_STEP(-16, 0), DIRECTION_STEP(-16, 0),
DIRECTION_STEP(-16, 0), DIRECTION_STEP(-16, 0), DIRECTION_STEP(0, -16),
DIRECTION_STEP(0, -16), DIRECTION_STEP(0, -16), DIRECTION_STEP(0, -16),
}
#define DIRECTION_STEP(dx, dz)
Pixel step by direction: X in the upper halfword, Z in the lower.

Definition at line 640 of file bilibin_cave.c.

Referenced by Event_PushActorAhead().