altmiller_cave.c
Altmiller Cave, six dark rooms where the party finds Babi, the ruler of Tolbi, invisible and unable to move.
games/tbs/src/scene/altmiller_cave.c on GitHub
Altmiller Cave, six dark rooms where the party finds Babi, the ruler of Tolbi, invisible and unable to move. He sends the party for the Mystic Draught behind a wall deep in the cave, which opens to five rocks turned in the order of the colored lights over them. Restored, Babi is found by two Tolbi soldiers and invites the party to fight in Colosso's finals.
The cave darkens as the party walks in, and Reveal lights it up.
Functions
AltmillerCave_StartDjinnBattle
static void AltmillerCave_StartDjinnBattle(void)
Talking to the Djinni in room 4 starts the battle for Djinni 65.
Used by gAltmillerCave_Events4.
AltmillerCave_GetEntrances
const struct SceneEntrance *AltmillerCave_GetEntrances(void)
The six rooms share one entrance table.
AltmillerCave_ApplyFadeBlend
static void AltmillerCave_ApplyFadeBlend(void)
Darkens room 1 to its current level: the brighter blend at level 0, each level one step darker.
Used by AltmillerCave_InitializeDarkness, AltmillerCave_SetFadeLevel.
AltmillerCave_SetFadeLevel
static void AltmillerCave_SetFadeLevel(s32 level)
Keeps room 1's darkness level, and shows it unless Reveal is lighting the room.
Used by AltmillerCave_DarkenToLevel0, AltmillerCave_DarkenToLevel1, AltmillerCave_DarkenToLevel2, AltmillerCave_DarkenToLevel3, AltmillerCave_DarkenToLevel4, AltmillerCave_DarkenToLevel5.
AltmillerCave_DarkenToLevel0
static void AltmillerCave_DarkenToLevel0(void)
Room 1's darkness boundaries: crossing one sets its level.
Used by gAltmillerCave_EventsOther.
AltmillerCave_InitializeDarkness
static void AltmillerCave_InitializeDarkness(void)
Darkens the cave on entry: room 1 by its levels, the other dark rooms evenly.
Used by AltmillerCave_EndReveal, AltmillerCave_Initialize.
AltmillerCave_StartReveal
static void AltmillerCave_StartReveal(void)
Reveal's light: room 1 is lit and room 6's rocks show their colors.
Used by gAltmillerCave_Events6, gAltmillerCave_EventsOther.
AltmillerCave_EndReveal
static void AltmillerCave_EndReveal(void)
Reveal's light ends: the cave darkens again and room 6's rocks lose their colors.
Used by gAltmillerCave_Events2, gAltmillerCave_Events3, gAltmillerCave_Events5, gAltmillerCave_Events6, gAltmillerCave_EventsOther.
AltmillerCave_BeginRetreat
static void AltmillerCave_BeginRetreat(void)
Retreat's first phase: the Psynergy's first actor faces south, and its object is copied into a new one for the effect to use.
Used by gAltmillerCave_Events2, gAltmillerCave_Events3, gAltmillerCave_Events5, gAltmillerCave_EventsOther.
AltmillerCave_UpdateMovedObstacle
static void AltmillerCave_UpdateMovedObstacle(void)
After Move on room 4's block: in its cell at (30, 20) it settles and opens the way beside it (remembered in TBS_PATCH_1 and later).
Used by AltmillerCave_AdvanceObstacleAndCheckPassage, gAltmillerCave_Events4.
AltmillerCave_AdvanceObstacleAndCheckPassage
static void AltmillerCave_AdvanceObstacleAndCheckPassage(void)
Walking east into room 4's block pushes it a cell.
Used by gAltmillerCave_Events4.
AltmillerCave_CheckFrostTargetCollision
static void AltmillerCave_CheckFrostTargetCollision(void)
Frost's first phase on room 4's puddle: notes whether its place is blocked, which keeps it from freezing.
Used by gAltmillerCave_Events4.
AltmillerCave_FreezePuddle
static void AltmillerCave_FreezePuddle(void)
Frost on room 4's puddle, unless blocked: it freezes and its cell takes the frozen attributes kept at (76, 16).
Used by gAltmillerCave_Events4.
AltmillerCave_HopSelectedActor
static void AltmillerCave_HopSelectedActor(void)
Walking into room 4's puddle while it is not frozen: the leader hops 32 pixels over it, if the landing is clear.
Used by gAltmillerCave_Events4.
AltmillerCave_MoveStagedActorToClearPosition
static void AltmillerCave_MoveStagedActorToClearPosition(void)
Walking into one of the three obstacles pushes it, if there is room.
Used by gAltmillerCave_Events4, gAltmillerCave_Events6.
AltmillerCave_PulseLight
static void AltmillerCave_PulseLight(union FieldObject *fieldObject)
Update callback of the light at the top of the stopped ring: it pulses through four sizes.
Used by AltmillerCave_SpinLights.
AltmillerCave_PlaceLight
static void AltmillerCave_PlaceLight(s32 actorId, s32 radius, s32 angle)
Puts a light on the ring, radius pixels from its center above the rocks, at the given angle.
Used by AltmillerCave_PlaceLights, AltmillerCave_TurnRock.
AltmillerCave_PlaceLights
static void AltmillerCave_PlaceLights(s32 angle)
Spaces the five lights evenly around the ring, the first at the given angle.
Used by AltmillerCave_Initialize, AltmillerCave_SpinLights.
AltmillerCave_SpinLights
static void AltmillerCave_SpinLights(void)
Scheduler task that spins the ring of lights: it speeds up, coasts, slows and stops with the chosen light at the top, which then pulses; a click (SE_135) sounds for each fifth of a turn.
Used by AltmillerCave_TurnRock.
AltmillerCave_TurnRock
static void AltmillerCave_TurnRock(s32 rock)
Talking to one of room 6's rocks rotates it. "Isaac rotated the rock." Turning the leftmost rock, then the rightmost, brings out the ring of lights; then each time the rock matching the light at the top is turned, the ring spins to another light, and a wrong rock puts the lights away and starts over. After three lights matched the ring shrinks away, the wall bursts and the way to Babi's draught opens.
Used by gAltmillerCave_Events6.
AltmillerCave_FacePartyNorth
static __inline__ void AltmillerCave_FacePartyNorth(void)
The party turns north, toward Babi.
Used by AltmillerCave_RestoreBabiAndInviteParty.
AltmillerCave_RestoreBabiAndInviteParty
static void AltmillerCave_RestoreBabiAndInviteParty(void)
Bringing Babi the Mystic Draught: he drinks it and appears, startling the party; Ivan reads his mind and finds him to be Babi, the ruler of Tolbi, who sought Lemurians to escape growing old. Two Tolbi soldiers find him and lead him home, and he invites the party to Colosso's finals; Garet asks whether they should take part.
Used by gAltmillerCave_Events2.
AltmillerCave_MeetInvisibleBabi
static void AltmillerCave_MeetInvisibleBabi(void)
Talking to the invisible Babi the first time: he can be heard but not seen, cannot move, and asks the party to bring his draught from deep in the cave, telling the order of the five rocks.
Used by gAltmillerCave_Events2.
AltmillerCave_RepeatRockOrder
static void AltmillerCave_RepeatRockOrder(void)
Talking to Babi again before the draught is found: he asks whether the party forgot the order of the rock colors, and tells it again.
Used by gAltmillerCave_Events2.
AltmillerCave_BabiCallsPartyBack
static void AltmillerCave_BabiCallsPartyBack(void)
Walking away from Babi once: the party is told where the draught is. "Wait... The draught is... on a table behind the door."
Used by gAltmillerCave_Events2.
AltmillerCave_MatchLeaderPriority
static void AltmillerCave_MatchLeaderPriority(union FieldObject *fieldObject)
Update callback of room 6's obstacles: drawn on the leader's sprite priority.
Used by AltmillerCave_Initialize.
AltmillerCave_RedrawObstacleFootprints
static __inline__ void AltmillerCave_RedrawObstacleFootprints(void)
Redraws the three obstacles' cells where they stand.
Used by AltmillerCave_Initialize.
AltmillerCave_Initialize
s32 AltmillerCave_Initialize(void)
Sets up the room being entered: an entry from outside the cave takes the room's first entrance; room 1 picks its darkness from the entrance; room 2's Babi is invisible until rescued; room 4's obstacles and pillar and room 6's obstacles, lights and rocks are restored. Returns 0.
AltmillerCave_UpdateWallFragment
static void AltmillerCave_UpdateWallFragment(struct EffectSlot *fragment)
Update callback of a piece of the burst wall: it flies off to a random point 120 pixels away, with a crash every fourth frame as they start.
Used by AltmillerCave_ReleaseWallBurst.
AltmillerCave_ReleaseWallBurst
static void AltmillerCave_ReleaseWallBurst(void)
The wall bursts: 24 pieces fly out from the ring's center, the wall's cells open to the passage, and the shaking calms.
Used by AltmillerCave_TurnRock.
Also, functions without a comment: AltmillerCave_GetRegions, AltmillerCave_GetExits, AltmillerCave_GetPlacements, AltmillerCave_DarkenToLevel1, AltmillerCave_DarkenToLevel2, AltmillerCave_DarkenToLevel3, AltmillerCave_DarkenToLevel4, AltmillerCave_DarkenToLevel5, AltmillerCave_GetEvents.
Structures
LightWheel
struct LightWheel
The ring of five lights above room 6's rocks as it spins to its next light: angles are 16-bit turns, the light at the top is the chosen one.
| Field | Declared as | |
|---|---|---|
phase | s16 phase | |
ticks | s16 ticks | |
unk04 | s16 unk04 | |
angle | u16 angle | |
speed | u16 speed | |
travel | u16 travel | How far the ring has turned since its last click. |
Used by AltmillerCave_SpinLights, AltmillerCave_TurnRock, gAltmillerCave_LightWheel, gAltmillerCave_LightWheelState.
RockPuzzle
struct RockPuzzle
Room 6's rock puzzle, kept in gSceneState: the rounds of lights matched in byte 0, then the state and the light shown.
| Field | Declared as | |
|---|---|---|
state | u8 state | |
chosen | s8 chosen |
Macros
DIRECTION_STEP
#define DIRECTION_STEP(dx, dz) (((u32)(dx) << 16) | ((dz) & 0xffff))
Pixel step by direction: X in the upper halfword, Z in the lower.
Used by gBilibinCave_PushSteps, gBilibin_FacingCellSteps, gColossoRiver_DirectionSteps, gColossoWall_DirectionSteps, gStagedActor_DirectionSteps.
Also, macros without a comment: ROCK_PUZZLE.
Globals
gAltmillerCave_PulseScales
u32 gAltmillerCave_PulseScales[]
The sizes the light at the top pulses through.
Used by AltmillerCave_PulseLight.
gAltmillerCave_GuardsArrivePath
s32 gAltmillerCave_GuardsArrivePath[]
The two soldiers walk in to Babi.
Used by AltmillerCave_RestoreBabiAndInviteParty.
gAltmillerCave_SecondGuardLeavePath
s32 gAltmillerCave_SecondGuardLeavePath[]
Babi and the soldiers walk out of the room, each by his own path.
Used by AltmillerCave_RestoreBabiAndInviteParty.
Also, globals without a comment: gAltmillerCave_LightWheelState, gStagedActor_DirectionSteps, gStagedActor_FootprintKinds, gStagedActor_FootprintBounds, gAltmillerCave_LightWheel, gAltmillerCave_Entrances, gAltmillerCave_Exits, gAltmillerCave_PlacementsOther, gAltmillerCave_Placements2, gAltmillerCave_Placements4, gAltmillerCave_Placements6, gAltmillerCave_FirstGuardLeavePath, gAltmillerCave_BabiLeavePath, gAltmillerCave_EventsOther, gAltmillerCave_Events2, gAltmillerCave_Events3, gAltmillerCave_Events4, gAltmillerCave_Events5, gAltmillerCave_Events6.
Declarations
Math_DivideUnsigned
s32 Math_DivideUnsigned(s32 value, s32 divisor)
Divides the nonnegative random value for wall-fragment scaling.