25#define NULL ((void *)0)
48#include "text/msg_ids.h"
123 if ((leader->
z.
fixed >> 19) <= 22) {
224 if (leaderColumn == 12 && leaderRow == 32) {
234 effectData = &effectOptions;
239 u16 effectType = 0x11e;
241 effectData->
type = effectType;
249 Math_Divide((((speedRoll << 4) - speedRoll) << 16) + 0x3c0000, 100);
250 Effect_Spawn(sparkX << 16, 0, sparkZ << 16, 0, velocityY, velocityZ,
256 }
while ((
u32)sparkIndex <= 14);
293 leaderX = leader->
x.
fixed;
294 leaderColumn = leaderX / 0x100000;
296 if (leaderColumn == 7) {
389 if (arrivalSeen != 0)
411 for (sparkIndex = 0; sparkIndex <= 16; sparkIndex++) {
412 angle = sparkIndex << 12;
414 velocity[0] -= velocity[0] / 4;
415 velocity[2] -= velocity[2] / 2;
506 for (paceCycle = 0; paceCycle < 2; paceCycle++) {
633#define DIRECTION_STEP(dx, dz) (((dx) << 16) | ((dz) & 0xffff))
646 207, 205, 228, 229, 298, 297,
737 { 0,
CONDITION_ALWAYS, 209, 0, 279,
FACING_SOUTH, 0, -1, -1, -1, -1, 0 },
738 { 1,
CONDITION_ALWAYS, 136, 0, 280,
FACING_NORTH, 0, 16, 32, 256, 320, 0 },
739 { 2,
CONDITION_ALWAYS, 136, 0, 120,
FACING_SOUTH, 0, 16, 32, 256, 320, 0 },
740 { 3,
CONDITION_ALWAYS, 200, 0, 648,
FACING_NORTH, 0, 80, 432, 320, 688, 0 },
741 { 4,
CONDITION_ALWAYS, 120, 0, 520,
FACING_SOUTH, 0, 80, 432, 320, 688, 0 },
742 { 5,
CONDITION_ALWAYS, 280, 0, 520,
FACING_SOUTH, 0, 80, 432, 320, 688, 0 },
743 { 6,
CONDITION_ALWAYS, 200, 0, 552,
FACING_SOUTH, 0, 80, 432, 320, 688, 0 },
744 { 7,
CONDITION_ALWAYS, 360, 0, 184,
FACING_NORTH, 0, 304, 32, 800, 208, 0 },
745 { 8,
CONDITION_ALWAYS, 456, 0, 184,
FACING_NORTH, 0, 304, 32, 800, 208, 0 },
746 { 9,
CONDITION_ALWAYS, 616, 0, 184,
FACING_NORTH, 0, 304, 32, 800, 208, 0 },
747 { 10,
CONDITION_ALWAYS, 760, 0, 184,
FACING_NORTH, 0, 304, 32, 800, 208, 0 },
748 { 11,
CONDITION_ALWAYS, 344, 0, 88,
FACING_SOUTH, 0, 304, 32, 800, 208, 0 },
749 { 12,
CONDITION_ALWAYS, 536, 0, 88,
FACING_SOUTH, 0, 304, 32, 800, 208, 0 },
750 { 13,
FLAG_MERCURY_LIGHTHOUSE_CHANNELS_OPEN, 744, 0, 680,
FACING_NORTH, 0, 544, 512, 784, 720, 0 },
751 { 14,
FLAG_MERCURY_LIGHTHOUSE_CHANNELS_OPEN, 584, 0, 568,
FACING_SOUTH, 0, 544, 512, 784, 720, 0 },
752 { 15,
FLAG_MERCURY_LIGHTHOUSE_CHANNELS_OPEN, 744, 0, 568,
FACING_SOUTH, 0, 544, 512, 784, 720, 0 },
753 { 13,
CONDITION_ALWAYS, 584, 0, 424,
FACING_NORTH, 0, 384, 256, 624, 448, 0 },
754 { 14,
CONDITION_ALWAYS, 424, 0, 312,
FACING_SOUTH, 0, 384, 256, 624, 448, 0 },
755 { 15,
CONDITION_ALWAYS, 584, 0, 312,
FACING_SOUTH, 0, 384, 256, 624, 448, 0 },
756 { 16,
CONDITION_ALWAYS, 744, 0, 424,
FACING_NORTH, 0, 704, 256, 944, 448, 0 },
757 { 17,
CONDITION_ALWAYS, 344, 0, 872,
FACING_SOUTH, 0, 48, 768, 400, 960, 0 },
758 { 18,
CONDITION_ALWAYS, 232, 0, 872,
FACING_SOUTH, 0, 48, 768, 400, 960, 0 },
759 { 19,
CONDITION_ALWAYS, 568, 0, 872,
FACING_SOUTH, 0, 464, 768, 816, 960, 0 },
760 { 20,
CONDITION_ALWAYS, 696, 0, 872,
FACING_SOUTH, 0, 464, 768, 816, 960, 0 },
761 { 25,
CONDITION_ALWAYS, 744, 0, 600,
FACING_SOUTH, 0, 544, 512, 784, 720, 0 },
762 { 30,
CONDITION_ALWAYS, 136, 0, 296,
FACING_NORTH, 0, 16, 32, 256, 320, 0 },
763 { 31,
CONDITION_ALWAYS, 136, 0, 168,
FACING_NORTH, 0, 16, 32, 256, 320, 0 },
764 { 60,
CONDITION_ALWAYS, 136, 0, 152,
FACING_SOUTH, 0, 16, 32, 256, 320, 0 },
765 { 99,
CONDITION_ALWAYS, 136, 0, 232,
FACING_EAST, 0, 16, 32, 256, 320, 0 },
Ability numbers, named from the English release.
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
s32 gStagedActor_DirectionSteps[]
Pixel step by direction: X in the upper halfword, Z in the lower.
s32 gStagedActor_FootprintBounds[]
#define DIRECTION_STEP(dx, dz)
Pixel step by direction: X in the upper halfword, Z in the lower.
u32 gStagedActor_FootprintKinds[]
s32 AnimationObjects_SelectAnimation(struct AnimationObject *sprite, s32 animation)
Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer),...
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
const s32 * gEffectScripts[]
Calls through a function pointer, by argument count.
The engine calls the debug menus import, and their palette swatch tiles.
The engine call layer: one typed inline for each of the thirteen main-image routines below that the s...
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
void BattleFx_StartFadeOverlay(void *object)
Starts the fade overlay on object (the party leader when NULL): loads its solid tiles,...
Field effects, their scripts and the flags that spawn them.
@ EFFECT_USE_PALETTE
options.palette, as its group child value
@ EFFECT_USE_TYPE
options.type, else object type 222
@ EFFECT_USE_PRIORITY
options.priority, as the sprite's priority
@ EFFECT_USE_SCRIPT
options.script, run in mode 1
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Engine_MessageShowCentered(s32 message, s32 flags)
void Engine_CameraSetSpeed(s32 speed, s32 acceleration)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
void Engine_CameraMoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
void Engine_CameraMoveToActor(s32 actor, s32 pan)
s32 Engine_MathSin(s32 angle)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
static void Map_CopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
static void Actor_FaceActor(s32 actor, s32 target, s32 frames)
static void ColorBuffer_ApplyTarget(s32 value, s32 mode)
static void Actor_WalkTo(s32 actor, s32 x, s32 z)
void Engine_EventWaitForScreen(void)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
static s32 Math_Divide(s32 dividend, s32 divisor)
void Engine_EventOpenScreen(void)
void Engine_GameFlagSet(s32 flag)
void Engine_MapRenderWaitForValues(void)
void Engine_GameFlagClear(s32 flag)
void Engine_CameraWaitForMove(void)
static void Actor_SetActionScript(s32 actor, const s32 *script)
The engine encodes either a built-in action or an action-script address.
void Engine_ActorWaitForMove(s32 actor)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
void Engine_ActorWalkTo(s32 actor, s32 x, s32 z)
static void Map_SetShake(s32 horizontal, s32 vertical, s32 decay)
Sets shake amplitudes in fixed-point pixels and the per-frame decay factor.
static void Actor_SetChildValue(s32 actor, s32 value)
s32 Engine_MathCos(s32 angle)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_MapRedraw(void)
static s32 Random_Next(void)
void Engine_ColorBufferInterpolate(s32 frames)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_EventWait(s32 frames)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
static struct FieldActor * Actor_Get(s32 actor)
static void ColorBuffer_ApplySource(s32 value, s32 mode)
Field objects and actors, and the scene transition styles.
@ TRANSITION_BACKDROP_FADE
#define SCENE_TRANSITION(style, variant)
@ ACTOR_FACES_MOTION
turns toward its velocity, 1/16 turn a frame
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define PSYNERGY_IN_AREA(ability, phase)
#define IF_FLAG_SET(flag)
#define SCENE_EXIT(exit, scene, entrance)
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
#define TOUCH_WALKING_INTO(facing)
#define PLACEMENT_SHARE_PREVIOUS_SPRITE
Game flags, named where their meaning is shown.
#define FLAG_SCENE_TEMP_05
#define FLAG_MIA_ENTERED_MERCURY_LIGHTHOUSE
Past the Lizard Man, Mia has gone on into the lighthouse.
#define FLAG_MERCURY_LIGHTHOUSE_LIT
#define FLAG_MERCURY_LIGHTHOUSE_PLY_ACTIVATED
Ply in the entrance hall: the lights cycle and the pillar routes open.
#define FLAG_MERCURY_LIGHTHOUSE_CHANNELS_OPEN
All three channel blocks are in place and the water runs.
#define FLAG_SCENE_TEMP_00
#define FLAG_KEEP_PARTY_POSITION
#define FLAG_SCENE_TEMP_50
GameState, the game's state: play time, coins, the scene and the leader's position,...
#define Battle_SetStart(mode)
Sets the battle start type.
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
The screen blend's globals and the graphics routines.
The heap's work slots and HeapState.
The main-image routines scene overlays import.
The hardware's I/O registers and their bits, as pret names them.
#define BLDCNT_EFFECT_BLEND
weighted by REG_BLDALPHA
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
Io_Write16, a 16-bit write to a register or memory.
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Item numbers, named from the English release.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
The keypad state the VBlank interrupt keeps.
Small statement macros both games use for positions, velocities and bounds.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
Declares nothing of its own: it only includes edition.h and types.h.
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
The heaps: allocating and freeing blocks.
Includes field_event.h with FIELD_STAGED_ACTOR_IMPORTS defined, so a scene gets the staged-actor impo...
s32 gMercuryLighthouse_PillarScript[]
s32 gMercuryLighthouse_ScaleCounterScript[]
s32 gMercuryLighthouse_RampScript[]
s32 gMercuryLighthouse_SparkScript[]
u16 gMercuryLighthouse_MoveAngles[]
Mercury Lighthouse and its entrance: arriving on a floor through one of its sparkling passages.
static void MercuryLighthouse_ArriveWithSparks(void)
Unless the party returns to where it was, the leader appears 16 pixels north of the entrance,...
static void MercuryLighthouseEntrance_FightLizardMan(void)
Talking to the Lizard Man, Mind Read on him, or walking north into trigger 40 or 41: he stirs and the...
s32 gMercuryLighthouseEntrance_LizardManStepEast[]
const struct SceneEntrance * MercuryLighthouseEntrance_GetEntrances(void)
u32 gMercuryLighthouseEntrance_Exits[]
MercuryLighthouseEntranceActor
The entrance's actors.
static void MercuryLighthouseEntrance_MiaEntersLighthouse(void)
Entrance 31, back from the Lizard Man battle and once only: Mia nods to the leader and goes on into t...
s32 MercuryLighthouseEntrance_Initialize(void)
On entering: the lights, the Retreat point and the pillar routes Ply has opened, then the scene of th...
struct ScenePlacement gMercuryLighthouseEntrance_Placements[]
MercuryLighthouseEntranceExit
Exits the events take: the doorway scenes at entrances 30 and 31, and on to Mercury Lighthouse after ...
const struct ScenePlacement * MercuryLighthouseEntrance_GetPlacements(void)
Mia, the Lizard Man, the actors at the doorway and the Ply target.
static void MercuryLighthouseEntrance_TryPillarStep(void)
Walking into trigger 11, 21 or 31 once Ply has worked: one step across the water pillars in the press...
static void MercuryLighthouseEntrance_ReleaseRaisedPillar(void)
Touching trigger 31 once Ply has worked: the raised pillar is let go.
static void MercuryLighthouseEntrance_LizardManReturnsToCentre(void)
Touching trigger 40 or 42 while the Lizard Man stands aside: he steps back in front of the doorway.
@ FLAG_DROP_FROM_ABOVE_SEEN
@ FLAG_LIZARD_MAN_STEPPED_ASIDE
The Lizard Man has stepped into the leader's column.
static void MercuryLighthouseEntrance_RiseToMiddleLanding(void)
Walking north into trigger 69: the leader rises to the middle landing.
MercuryLighthouseEntranceEntrance
Entrances with a scene of their own.
@ ENTRANCE_DROP_FROM_ABOVE
the leader drops in from above
@ ENTRANCE_AFTER_LIZARD_MAN
the return from the Lizard Man battle
@ ENTRANCE_BEFORE_LIZARD_MAN
@ ENTRANCE_RISE_FROM_CHANNELS
static void MercuryLighthouseEntrance_RaiseTouchedPillar(void)
Touching trigger 11 once Ply has worked: the pillar underfoot rises to its full height.
static void MercuryLighthouseEntrance_SpawnTimedRiseEffect(void)
Touching trigger 21 once Ply has worked: rising sparks keep appearing while the leader stands on the ...
const struct SceneEvent * MercuryLighthouseEntrance_GetEvents(void)
The touch, search, talk and Psynergy events.
static s32 MercuryLighthouseEntrance_PlayStepSound(struct ScriptInterpreter *interpreter)
The sound of the Lizard Man's sidestep, played by all three step scripts as he lands.
const struct SceneRegion * MercuryLighthouseEntrance_GetRegions(void)
static void MercuryLighthouseEntrance_LizardManBlocksLeader(void)
Touching trigger 41 while he stands in the doorway: the Lizard Man steps into the leader's way,...
struct SceneEvent gMercuryLighthouseEntrance_Events[]
static void OverlayObject_SpawnKind24AtObject(struct FieldActor *source)
Spawns the short-lived rising effect at an actor's position.
static void MercuryLighthouseEntrance_ReadHeartInscription(void)
Searching the inscription (trigger 1).
const u32 * MercuryLighthouseEntrance_GetExits(void)
s32 gMercuryLighthouseEntrance_LizardManStepWest[]
static void MercuryLighthouseEntrance_RiseToSouthernLanding(void)
Walking north into trigger 67: the leader rises to the southern landing.
static void MercuryLighthouseEntrance_RiseToNorthernLanding(void)
Walking north into trigger 68: the leader rises to the northern landing.
static void MercuryLighthouseEntrance_ActivateWithPly(void)
Ply on the Ply target, from cell (12, 32) only: the room dims, fifteen sparks rise from the pool,...
s32 gMercuryLighthouseEntrance_LizardManStepCentre[]
s32 gMercuryLighthouseEntrance_RiseScript[]
struct SceneEntrance gMercuryLighthouseEntrance_Entrances[]
static void MercuryLighthouseEntrance_LizardManBlocksMia(void)
Entrance 30, unless resuming: Mia tries to get past the Lizard Man in the doorway,...
s32 gMercuryLighthouseEntrance_SparkBurstScript[]
Each spark pulses in size four times, then is released.
static s32 MercuryLighthouseEntrance_MiaWatchesLeader(union FieldObject *fieldObject)
static void MercuryLighthouseEntrance_ReturnToDoorway(void)
Touching trigger 10 by the doorway: the scene starts again at the doorway, where Mia goes in if she h...
static void MercuryLighthouse_ClearPalette(void)
While the pool sleeps: colours 9 to 15 of background palette 6 are black.
static void MercuryLighthouse_CyclePalette(void)
A scene callback: every fifth frame colour 9's red level steps on by 4, and each of colours 10 to 15 ...
Mercury Lighthouse and its entrance: leaving a floor through one of its sparkling passages.
static void MercuryLighthouse_LeaveThroughPassage(s32 exit)
Touch a passage: the leader moves north with the trail of sparks, vanishes, and after half a second t...
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_SET(w, v)
Write a work value.
#define SC_LOOP(n, to)
Repeat up to n times.
#define SC_POS(x, y, z)
Set position.
#define SC_SYNC
Wait for arrival.
#define SC_MOVE(x, y, z)
Move toward the target.
#define SC_WAIT(n)
Wait n frames.
#define SC_TOP
Script start.
#define SC_END
Return to the main script.
void Field_RequestBattleFromEncounterTable(s32 zoneNo, s32 slotNo)
Sets up a battle with enemy group slot of encounter table zone.
void Event_SetNextDestination(s32 scene, s32 entrance)
Sets the scene and entrance that the field goes to next (gGameState.nextScene and nextEntrance).
void BattleFx_SetQueuedSoundAndPlay(s32 soundId)
Plays SE_298, then soundId (SE_289 for -1), and remembers soundId for BattleFx_PlayQueuedSound in the...
Scene numbers, named after their places.
char SceneId_MercuryLighthouseEntrance
char SceneId_MercuryLighthouse4
The field object script interpreter and the operands its commands read.
Song and sound effect ids, indices into gSound_SongTable.
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void MercuryLighthouse_RestoreLights(s32 region, struct MercuryLighthouseLights *st)
Keeps the lights' state st in work slot 35 for the floor's region, the pool's collision code.
static s32 OverlayObject_RampWords24And28Over16Frames(struct ScriptInterpreter *interpreter)
Grows the moving light over the first sixteen script frames.
void MercuryLighthouse_HopAcrossPool(void)
Pushing against the pool's edge (triggers 11, 21 and 31): the leader hops two cells the way the pad p...
static s32 MercuryLighthouse_FollowLeader(struct ScriptInterpreter *interpreter)
Follows the linked actor and alternates the light's animation parameter.
static void MercuryLighthouse_RemoveColumnOnRetreat(void)
Retreat (PSYNERGY_IN_AREA(ABILITY_RETREAT, 1)): remove the column of light.
void MercuryLighthouse_LoseLights(void)
Touch trigger 31: the leader loses their lights, and the column swells and fades away.
static s32 OverlayObject_AdvanceScaleCounter(struct ScriptInterpreter *interpreter)
Expands the released light before its script removes it.
void MercuryLighthouse_SparkleAtLeader(void)
Touch trigger 21: while the leader stands there, a sparkle rises from them every 10 to 39 frames.
void MercuryLighthouse_ChargeLights(void)
Touch trigger 11, the pool's heart: the column of light appears over the leader if it is not there,...
static s32 SceneEffect_AdvanceAnchoredRiseFrame(struct ScriptInterpreter *interpreter)
Raises the spark while its scale follows a half-sine pulse.
The pushable actors' movement probes and footprint bounds.
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u16 priority
2 when created
The options of a spawned field effect, each used when its EFFECT_USE_ flag (or EFFECT_SCALE_TO_TARGET...
s16 type
the object type to create; 222 without the flag
s32 palette
passed to ObjectGroup_SetChildValue
s32 priority
the sprite's priority
const s32 * script
the object script, run in mode 1
s32 startTransition
SCENE_TRANSITION(style, variant).
A field actor: a person or thing on the field with a position, motion toward a target,...
u8 steeringFlags
ActorSteeringFlag bits.
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
union FieldCoordinate z
16.16 fixed-point pixels
s32 scaleX
16.16 fixed point, 0x10000 full size
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
u8 terrainId
The map layer (0 to 3) its ground height is read from, which the scrolling camera updates from the ce...
s16 retreatEntrance
where Retreat goes; the group's first entrance
s16 retreatScene
where Retreat goes; the group's first entrance
Published in the scene's light-controller slot while the pillar is active.
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
The prefix that command handlers read from a field object's 0x70-byte slot.
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
The integer types, TRUE, UNUSED and the fixed-address macros.
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
void UiText_ShowCenteredMessage(s32 message, s32 mode, s32 yOffset)
Shows a message centred on the screen (yOffset tiles lower) and waits until it is typed out,...