33#include "text/msg_ids.h"
46#define FLAG_GOMA_CAVE_STUMP_FELL 0x300
47#define FLAG_GOMA_CAVE_EAST_PILLAR_IN_PLACE 0x301
48#define FLAG_GOMA_CAVE_WEST_PILLAR_MOVED 0x302
110 s32 scriptAndChildValue,
111 s32 planeAndPriority) {
123 sprite = fragment->sprite;
130 fragment->
speed = firstRate;
132 fragment->
work = (
u16)planeAndPriority;
133 priority = (
u32)planeAndPriority >> 16;
193 struct FieldActor *firstXSource, *firstZSource;
194 s32 firstRandomX, firstRandomSpeed, firstStyle, firstSpeedBand,
195 firstSpeedTimes13, firstFallingSpeed;
196 struct FieldActor *secondXSource, *secondZSource;
197 s32 secondRandomX, secondRandomSpeed, secondStyle, secondSpeedBand,
198 secondSpeedTimes13, secondFallingSpeed;
201 if (framePhase == 0) {
204 fixedX = firstXSource->
x.
fixed;
206 ((((
u32)(((firstRandomX << 1) + firstRandomX) << 2)) >> 16) << 16);
209 fixedZ = firstZSource->
z.
fixed;
212 firstSpeedBand = ((
u32)((firstRandomSpeed << 2) + firstRandomSpeed) >> 16);
215 (((firstSpeedBand << 1) + firstSpeedBand) << 2) + firstSpeedBand;
216 firstFallingSpeed = firstSpeedTimes13 << 6;
217 firstFallingSpeed -= firstSpeedTimes13;
218 firstFallingSpeed <<= 3;
219 firstFallingSpeed += firstSpeedBand;
221 firstFallingSpeed = -firstFallingSpeed;
223 firstFallingSpeed, firstStyle, framePhase);
225 if (framePhase == 0) {
228 fixedX = secondXSource->
x.
fixed;
230 ((((
u32)(((secondRandomX << 1) + secondRandomX) << 2)) >> 16) << 16);
233 fixedZ = secondZSource->
z.
fixed;
237 ((
u32)((secondRandomSpeed << 2) + secondRandomSpeed) >> 16);
240 (((secondSpeedBand << 1) + secondSpeedBand) << 2) + secondSpeedBand;
241 secondFallingSpeed = secondSpeedTimes13 << 6;
242 secondFallingSpeed -= secondSpeedTimes13;
243 secondFallingSpeed <<= 3;
244 secondFallingSpeed += secondSpeedBand;
246 secondFallingSpeed = -secondFallingSpeed;
248 secondFallingSpeed, secondStyle, framePhase);
261 void (*fragmentCallback)(void);
268 struct FieldActor *bounceActor, *gravityActor;
271 s32 randomX, randomSpeed, style, speedBand, speedTimes13, fallingSpeed;
298 bounceActor->
bounce = zero;
313 fixedX = xSource->
x.
fixed;
314 fixedX += ((((
u32)(((randomX << 1) + randomX) << 2)) >> 16) << 16);
317 fixedZ = zSource->
z.
fixed;
320 speedBand = ((
u32)((randomSpeed << 2) + randomSpeed) >> 16);
322 speedTimes13 = (((speedBand << 1) + speedBand) << 2) + speedBand;
323 fallingSpeed = speedTimes13 << 6;
324 fallingSpeed -= speedTimes13;
326 fallingSpeed += speedBand;
328 fallingSpeed = -fallingSpeed;
330 fallingSpeed, style, zero);
353 if (
x == 38 &&
z == 14) {
395 StagedActor_AdvancePair();
414 savedMotionFlags = *motionFlags;
416 destination = ⌖
428 *motionFlags &= 0x7e;
431 *(
s16 *)((
u8 *)destination + 10));
434 *motionFlags = savedMotionFlags;
545#define DIRECTION_STEP(dx, dz) (((u32)(dx) << 16) | ((dz) & 0xffff))
558 207, 205, 228, 229, 298, 297,
601 { 0,
CONDITION_ALWAYS, 172, 0, 149,
FACING_SOUTH, 0, -1, -1, -1, -1, 0 },
602 { 1,
CONDITION_ALWAYS, 88, 0, 184,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
603 { 2,
CONDITION_ALWAYS, 584, 0, 184,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
604 { 3,
CONDITION_ALWAYS, 520, 0, 232,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
605 { 4,
CONDITION_ALWAYS, 232, 0, 184,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
606 { 5,
CONDITION_ALWAYS, 536, 0, 408,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
607 { 99,
CONDITION_ALWAYS, 376, 0, 200,
FACING_SOUTH, 0, 8, 8, 728, 504, 0 },
Ability numbers, named from the English release.
void ObjectGroup_SetChildValue(struct FieldActor *actor, s32 param)
Sets the param byte of every animated part of an actor's sprite.
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
const struct ScenePlacement * Scene_GetPlacements(void)
const struct SceneEntrance * Scene_GetEntrances(void)
const struct SceneEvent * Scene_GetEvents(void)
const u32 * Scene_GetExits(void)
Both scenes share one exit table.
const struct SceneRegion * Scene_GetRegions(void)
s32 Scene_Initialize(void)
Sets up whichever scene is being entered and runs its arrival events.
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[]
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
B5Context, the object context a battle routine reads; most of its fields are still unnamed.
s32 Field_TryJumpForward(void)
Makes the leader jump two tiles forward, over the tile in front, when the map allows it (Map_CheckObj...
The engine calls the debug menus import, and their palette swatch tiles.
Djinn numbers, named from the English release.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
static s32 FieldObject_CheckMovementCollision(struct FieldActor *actor, struct FieldPosition *position)
Scene commands: the all-caps macros the scene scripts are written in.
#define OBJ_DIR(no, d, t)
#define OBJ_POS_SET(no, x, z)
#define OBJ_EMOTE(no, e, t)
#define OBJ_SPEED(no, s, a)
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
void Engine_ActorMoveToAndWait(s32 actor, s32 x, s32 z)
void Engine_ActorJump(s32 actor, s32 height, s32 frames)
static void Actor_MoveToAndWait(s32 actor, s32 x, s32 z)
void Engine_ActorSetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_ActorSetDestination(s32 actor, s32 x, s32 z)
void Engine_EventWaitForScreen(void)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
void Engine_ObjectSetBlendMode(struct FieldActor *object, s32 mode)
void Engine_EventOpenScreen(void)
void Engine_GameFlagSet(s32 flag)
void Engine_MapRenderWaitForValues(void)
void Engine_GameFlagClear(s32 flag)
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)
static void Event_ShowMessage(s32 speaker, s32 flags)
void Engine_ActorSetChildValue(s32 actor, s32 value)
static void Map_SetShake(s32 horizontal, s32 vertical, s32 decay)
Sets shake amplitudes in fixed-point pixels and the per-frame decay factor.
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
void Engine_ActorSetDestinationOffset(s32 actor, s32 dx, s32 dz)
Field objects and actors, and the scene transition styles.
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
#define SCENE_TRANSITION(style, variant)
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define SCENE_EXIT(exit, scene, entrance)
@ TALK_FACE_PARTY_AND_BACK
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
#define EVENT_TOUCH_WALKING
#define TOUCH_WALKING_INTO(facing)
The scene service layer: one typed inline for each engine service a scene calls by its own name,...
static s32 Task_AddCallback(void(*callback)(void), s32 priority)
Calls the main-image scheduler through engine_call.h.
16.16 fixed-point constants, sine and cosine, and the library division.
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
FixedPointPosition, a position in 16.16 fixed point.
Game flags, named where their meaning is shown.
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
#define FLAG_GOMA_CAVE_WITNESS_LEFT
after the party caught Forge
volatile u32 gFrameCount
Frames WaitFrames has finished.
GameState, the game's state: play time, coins, the scene and the leader's position,...
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
static void Event_MoveWestPillar(void)
Move on the west pillar, and after each push: the pillar stands on one of three columns,...
static void Event_MoveEastPillar(void)
Move on the east pillar: once it reaches column 23 it settles into the floor and can be walked over.
s32 gGomaCavePillar_WitnessFrames
struct SceneEvent gGomaCavePillar_Events[]
static s32 GomaCavePillar_FinishFragment(struct ScriptInterpreter *interpreter)
Applies child value 15 at the end of a fragment's lifetime.
#define FLAG_GOMA_CAVE_EAST_PILLAR_IN_PLACE
sunk into its place
static void Event_PushEastPillar(void)
Walking into the east pillar pushes it a step.
static void GomaCavePillar_UpdateFragment(union FieldObject *fieldObject)
Advances the fragment's selected coordinate plane and keeps its targets in step.
static void Event_WitnessCheersForgeCaught(void)
Raised once Forge is caught: the man is amazed, then walks off.
#define FLAG_GOMA_CAVE_WEST_PILLAR_MOVED
one step east of its start
static void GomaCavePillar_SpawnStumpDust(void)
While the stump teeters, dust falls from it: one fragment every eighth frame, two on every sixteenth.
static void GomaCavePillar_SpawnFragment(s32 x, s32 y, s32 z, s32 firstRate, s32 secondRate, s32 scriptAndChildValue, s32 planeAndPriority)
Creates a fragment with two axis rates, a script and packed plane/priority.
static void Event_PushStumpOver(void)
Move on the stump: once it is pushed to the edge (column 25), it teeters shedding dust,...
#define FLAG_GOMA_CAVE_STUMP_FELL
pushed over into the room below
#define WITNESS
the man who fought Forge and lost it
GomaCavePillarFragmentPlane
s32 gGomaCavePillar_FragmentScript2[]
static void Event_FightForge(void)
Talking to Forge: the man beside it jumps in surprise, and the battle with the Djinni begins.
static void Event_JumpGapWest(void)
Walking west at the gap: the leader jumps across it.
static void GomaCavePillar_FidgetWhileForgeFights(void)
While the battle with Forge runs, the man reacts on a timer; once the Djinni event is over,...
u32 gGomaCavePillar_Exits[]
s32 gGomaCavePillar_FragmentScript0[]
static void GomaCavePillar_CopyWestPillarCells(s32 sourceColumn)
Copies the map cells for the west pillar on either side of its track.
struct ScenePlacement gGomaCavePillar_Placements[]
s32 gGomaCavePillar_FragmentScript1[]
struct SceneEntrance gGomaCavePillar_Entrances[]
static void GomaCavePillar_SettleEastPillar(void)
Once the east pillar reaches its place (cell 38, 14), it sinks two pixels into the floor and six frag...
struct GomaCavePillarFragmentScripts gGomaCavePillar_FragmentScripts
The screen blend's globals and the graphics routines.
The main-image routines scene overlays import.
Item numbers, named from the English release.
Declares nothing of its own: it only includes edition.h and types.h.
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_LOOP(n, to)
Repeat up to n times.
#define SC_WAIT(n)
Wait n frames.
#define SC_TOP
Script start.
void Field_RequestDjinnBattle(s32 flag, s32 no)
Sets up the battle with Djinni number no.
The field object script interpreter and the operands its commands read.
Song and sound effect ids, indices into gSound_SongTable.
#define SE_JUMP
An actor jumps: ObjectMotion_Launch plays the high jump above 5 pixels a frame.
struct EventWork * gEventWork
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_AudioPlayCue()
void Engine_ActorShowEmote()
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 running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
s16 raisedTrigger
a raised event for Scene_RunRaisedEvent
s32 startTransition
SCENE_TRANSITION(style, variant).
s32 transitionFrames
frames
A field actor: a person or thing on the field with a position, motion toward a target,...
s32 speed
speed limit, 16.16 fixed-point pixels per frame
s32 targetX
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
s32 targetZ
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
s32 bounce
The share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created)...
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
s32 velocityY
16.16 fixed-point pixels per frame
s32 gravity
Taken off the vertical velocity each frame while it is above the ground, in 16.16 fixed-point pixels ...
union FieldCoordinate z
16.16 fixed-point pixels
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
s32 targetY
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
u8 terrainId
The map layer (0 to 3) its ground height is read from, which the scrolling camera updates from the ce...
s32 z
16.16 fixed-point pixels
s16 pendingDjinnEvent
The Djinni battle pending (DJINNI_0 plus its number, flags in bits 15 to 11), resolved on returning t...
The action scripts a pillar fragment can run, chosen by the low bits of its spawn value.
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.
Values that differ by patch level or language, chosen once for their code.
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.
The patch levels: our groups of the measured changes from the Japanese release.