27 switch (task->
state) {
62 if (task !=
NULL &&
id == 0x34C) {
81 switch (task->
state) {
90 if (object->
anim == 10) {
98 if (task->
mode != 0) {
105 if (task->
mode == 2) {
106 if (--task->
wait <= 0) {
130 fading->
frame = 0x3D;
179 switch (task->
state) {
188 switch (object->
anim) {
200 for (i = 0; i < 2; i++) {
202 if (task->
mode != 0) {
210 if (task->
mode == 2) {
211 if (--task->
wait <= 0) {
224 for (j = 0; j < 2; j++) {
274 return dist < dx + dy;
298 task->
posX = task->
x >> 8;
299 task->
posY = task->
y >> 8;
309 switch (task->
state) {
318 task->
homeX =
object->x;
319 task->
homeY =
object->y;
320 task->
x =
object->x << 8;
321 task->
y =
object->y << 8;
331 if (task->
mode != 0) {
335 if (task->
mode != 0) {
338 tile->
x = task->
posX;
339 tile->
y = task->
posY;
343 if (task->
mode == 3) {
345 if (task->
speed <= 0x10) {
349 if (task->
mode == 2) {
350 if (--task->
wait <= 0) {
376 fading->
x = task->
posX;
377 fading->
y = task->
posY;
414 switch (task->
state) {
429#define STAGE_CHILDREN_SIZE 4
441#if VERSION_US || VERSION_JP
442#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
443#define EVENT_TEXT_FILE (TEXT_EVENTS_400 - 1)
444#define STAGE_FILE 0x354
445#define STAGE_ARCHIVE 0x44F
447#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
448#define EVENT_TEXT_FILE (TEXT_EVENTS_400 - 1)
449#define STAGE_FILE 0x363
450#define STAGE_ARCHIVE 0x45F
506 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 },
507 { 4, 8 }, { 5, 8 }, { 6, 8 }, { 7, 8 },
508 { 8, 8 }, { 9, 8 }, { 10, 8 }, { 11, 8 },
509 { 12, 8 }, { 13, 8 }, { 14, 8 }, { 255, 0 },
512 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 },
513 { 4, 8 }, { 5, 8 }, { 6, 8 }, { 7, 8 },
514 { 8, 8 }, { 9, 8 }, { 10, 8 }, { 11, 8 },
518 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 },
519 { 4, 8 }, { 5, 8 }, { 6, 8 }, { 7, 8 },
520 { 8, 8 }, { 9, 8 }, { 10, 8 }, { 11, 8 },
521 { 12, 8 }, { 13, 8 }, { 14, 8 }, { 255, 0 },
524 { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
525 { 4, 6 }, { 5, 6 }, { 6, 6 }, { 7, 6 },
526 { 8, 6 }, { 9, 6 }, { 10, 6 }, { 11, 6 },
530 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 },
531 { 4, 8 }, { 5, 8 }, { 6, 8 }, { 7, 8 },
532 { 8, 8 }, { 9, 8 }, { 10, 8 }, { 11, 8 },
533 { 12, 8 }, { 13, 8 }, { 14, 8 }, { 255, 0 },
536 { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
537 { 4, 6 }, { 5, 6 }, { 6, 6 }, { 7, 6 },
538 { 8, 6 }, { 9, 6 }, { 10, 6 }, { 11, 6 },
552 { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 },
553 { 4, 4 }, { 5, 4 }, { 4, 4 }, { 3, 4 },
554 { 2, 4 }, { 1, 4 }, { 255, 0 },
557 { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 },
558 { 4, 4 }, { 5, 4 }, { 6, 8 }, { 7, 8 },
559 { 8, 8 }, { 9, 8 }, { 10, 8 }, { 255, 0x3E7 },
565 0, 0x648, 0xC93, 0x12E2, 0x1936, 0x1F92, 0x259F, 0x2C6B,
566 0x32EB, 0x39C7, 0x401F, 0x46D7, 0x4DA7, 0x5491, 0x5B98, 0x62BF,
567 0x6A09, 0x7179, 0x7913, 0x80DB, 0x88B5, 0x9105, 0x9970, 0xA21B,
568 0xAB0D, 0xB44A, 0xBDDC, 0xC7C8, 0xD217, 0xDCD2, 0xE805, 0xF3BA,
572 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
573 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
574 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
575 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
576 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
577 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
578 { 0, 0, 0, 0, 0, 0, 0, 0 },
579 { 0x140, 0x100, 0x17A, 0x1D8, 0xE8, 0xD8, 0x170, 0x1F1 },
594 { 0, 8, 0xFF, 2, 0x3E, 0, 0, 0, 0, 0, 46, 288, 0, 0 },
595 { 0, 3, 0x40, 2, 0xD, 0, 0, 0, 0, 0, 52, 288, 0, 0 },
596 { 0, 2, 0x40, 2, 0xD, 0, 0, 0, 0, 0, 154, 262, 0, 0 },
597 { 0, 1, 0x40, 2, 0xD, 0, 0, 0, 0, 0, 174, 359, 0, 0 },
598 { 0, 7, 0x40, 2, 0xE, 0, 0, 0, 0, 0, 103, 297, 0, 0 },
599 { 0, 5, 0x40, 2, 0xE, 0, 0, 0, 0, 0, 117, 236, 0, 0 },
600 { 0, 6, 0x40, 2, 0xE, 0, 0, 0, 0, 0, 217, 300, 0, 0 },
601 { 1, 0, 0x40, 2, 0x32, 2, 0, 1, 0xC, 0, 48, 288, 0, 0 },
602 { 1, 0, 0x40, 2, 0x32, 2, 0, 1, 0xC, 0, 160, 280, 0, 0 },
603 { 1, 0, 0x40, 2, 0x33, 2, 0, 1, 0xC, 0, 104, 248, 0, 0 },
604 { 1, 0, 0x40, 2, 0x33, 2, 0, 1, 0xC, 0, 233, 263, 0, 0 },
605 { 1, 0, 0x40, 2, 0x33, 2, 0, 1, 0xC, 0, 233, 335, 0, 0 },
606 { 0, 0xA, 0xFF, 6, 0x3C, 0, 0, 0, 0, 0, 50, 239, 0, 0 },
607 { 0, 9, 0xFF, 6, 0x3F, 0, 0, 0, 0, 0, 46, 288, 0, 0 },
608 { 1, 0, 0x40, 4, 0, 0, 0, 0, 0, 0, 240, 72, 135, 0 },
609 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
612 { { {
PROGRESS(
STORY_TEDDY_FOUND), 1 }, {
CODES_END, 0 } },
SLOT_EVENT, 0x172, 0, 0, 0, 0, 0, 0 },
613 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_CLIMB_DOWN, 0xE, 0xEF, 0xA8, 0, 0, 0, 0 },
614 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_CLIMB_UP, 0xE, 0xDF, 0x190, 0, 0, 0, 0 },
615 { { {
CODES_END, 0 }, {
CODES_END, 0 } }, 0, 0, 0, 0, 0, 0, 0, 0 },
GfxState GFX
GFX: the graphics state and its methods.
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
GameState GAME
The save data, the game mode and the methods.
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
The stage overlays (AAA/PRO/WSTAG###.PRO), loaded at 0x800A4CA4 on top of FIELDSTG.
#define EVENT_TEXT(n)
An entry of the stage's events' text file, for FieldEvent.text.
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define SCRIPT_WAIT_WALK(id)
until the character gets to its goal
#define FIELD_COMMAND_HALT_PARTNERS
The field commands, which an event script hands FIELD_TASK_COMMANDS as the first argument of a pose c...
#define SCRIPT_END
The commands of an event script (FieldEvent.script), as FIELDSTG_runEvent reads them: a halfword kind...
#define SCRIPT_LEAVE(mode, x, y, dir)
FIELDSTG_leaveField; ends the event.
#define SCRIPT_COMMAND(id, command, arg)
the same word for a script command's id: FIELDSTG_setEventPose creates its task if none runs and hand...
#define SCRIPT_FOLLOW(snap, id)
FIELDSTG_followWithCamera.
#define FIELD_MAP_FLOOR0
Some of FieldMap's maps (files): those of the floors the player walks on come first,...
#define FIELD_COMMAND_ICON3
its substate 3, with ITEM_GET
#define SLOT_EVENT
starts the event arg
#define SCRIPT_WALK(id, x, y, dir)
Actor.setGoal: walks to (x, y), then faces dir.
#define SCRIPT_WAIT_BOX
until box 0 closes
#define SCRIPT_POSE(id, set, dir)
Actor.setPose: its animation set, facing dir.
#define FIELD_MAP_TRIGGERS
a cell's value: a direction (3 bits) and a StageSlot (5)
#define SCRIPT_WAIT(frames)
#define FIELD_TASK_COMMANDS
script command 813 (FIELDSTG_startCommandTask): the field commands
#define SCRIPT_PLACE(id, x, y)
puts a character at (x, y)
#define SCRIPT_TALK(box, entry, id, kind)
box of the event's boxes shows the event text's entry: a talk box at the corner kind next to the char...
FieldState FIELDSTG_state
#define ITEM(kind, id)
an item, in the bag or equipped; kind (bits 9-11) isn't read, and the scripts set it after the item's...
#define PROGRESS(n)
GAME.progress is n.
s32 getAngle(s32 x, s32 y)
The angle of (x, y), 0x100 a turn, from the stage's table of tangents angleTangents.
#define MUSIC_RELIABILITY_SPOT
BGM_0014: the Reliability Spot.
#define MUSIC_BANK(music)
The sound bank of a music, which a stage loads for it (FieldState.soundBank)
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
FIELDSTG's start of the stage (StageEntry.init in FIELDSTG_stages): the stage's task,...
s32 stepTileAnimation3(StageTileAnim *obj, AnimFrame *frames, s32 once, s32 depth)
stepTileAnimation under a third name: steps OBJ's animation through FRAMES by the frame time (at most...
s32 stepTileAnimation(StageTileAnim *obj, AnimFrame *frames, s32 once, s32 depth)
Steps OBJ's animation through FRAMES by the frame time (at most 4) and returns its frame: at the end ...
@ STORY_TEDDY_FOUND
WSTAG212, event 352: Teddy is found; MAGAMI is part of the A.o.A, and the player sets off to beat the...
@ STORY_DE_SINCERITY
WSTAG460 (Reliability Spot), event 370: the Qing Long Chief, asked for the Digi-Egg of Knowledge,...
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
One frame of a sprite animation; frame 0xFF ends it (or loops it)
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
An event of the table FieldState.events, up to the first id -1, which FIELDSTG_startEvent starts.
void(* setFile)(s32 index, s32 file)
FIELDSTG_setMapFile.
void(* setFirstMap)(s32 index)
FIELDSTG_setFirstMap: the map the player starts on (GAME.mapIndex), when the mode is new.
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
FieldEvent * events
up to the first id -1
s32 soundBank
SOUND.loadBank's, or 0.
StageTile * objects
the map objects, up to the first margin 0
s32 imageFile
or an image archive file, or 0
Vec2 start
where the player starts
StageSlot * slots
up to the first type 0
ActorImage * actors
then the actors', from actors[2]
s32 mapFile
the file of the map's tiles (FIELDSTG_createMapStreamer)
s32 startDir
and its direction
s32 textFile
the stage's text file, for the talks
union FieldState::@12 images
s32 music
SOUND.playSound's, or 0.
What a character says (FIELDSTG_runActorAction): the first whose conditions hold, or the last,...
void(* applyAction)(s32 code, s32 value)
s32(* getFrameTime)(void)
s32(* next)(void)
0 to RANDOM_COUNT - 1
What the player can trigger on a map (FIELDSTG_updateTriggers): a record of the table at FieldState....
The task a stage starts (startStage), updated by its updateStage.
void(* nextState)(struct StageTask *task)
void(* setState)(struct StageTask *task, s32 state)
Two map objects (animations 8 and 9) shown while mode isn't 0, and hidden by a one-shot animation wai...
void(* nextState)(struct StageTileDuo *task)
void(* setSubstate)(struct StageTileDuo *task, s32 substate)
void(* setState)(struct StageTileDuo *task, s32 state)
StageTileDuo with one map object.
void(* setState)(struct StageTileSolo *task, s32 state)
void(* setSubstate)(struct StageTileSolo *task, s32 substate)
void(* nextState)(struct StageTileSolo *task)
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
u8 anim
which of a stage's animations sets frame (1-3); FIELDSTG finds objects by it (its lift,...
A map object that wanders around where it starts, animated, turning every period frames: towards home...
s32 start
the first frame and timer
u8 tileAnim
the map object (FieldState.objects) it moves
void(* nextState)(struct StageWanderer *task)
void(* setSubstate)(struct StageWanderer *task, s32 substate)
s16 mode
0: hidden, 1: wandering, 2: waiting, 3: slowing down
s16 period
frames between turns
void(* setState)(struct StageWanderer *task, s32 state)
Any task, seen through its header.
void(* setState)(struct Task *task, s32 state)
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
s32 stepTileAnimation2(StageTileAnimFlag *obj, AnimFrame *frames, s32 once, s32 depth)
stepTileAnimation (common/step_tile_animation.inc.c) for a StageTileAnimFlag: steps OBJ's animation t...
AnimFrame updateTileDuoFrames1_0[]
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
void handleCommand830(Task *task, s32 id)
Sets the task to TASK_DONE when the id is 0x34C.
void fadeOutTileSolo(StageTileSolo *task, s32 command, s32 arg)
Makes the StageTileSolo hide in 20 frames; command and arg, a script command handler's (ScriptCommand...
void updateTileDuo(StageTileDuo *task)
Cycles the colors of the map objects with animations 8 and 9 by the Digi- Egg of Sincerity while mode...
void moveWanderer(StageWanderer *task)
Moves the wanderer, turning it every period frames.
FieldActorEntry * stageActors[]
AnimFrame * updateTileDuoFrames0[]
void * createTileDuoTask(void)
Creates the updateTileDuo task.
s32 isFarFromHome(StageWanderer *task, s32 dist)
Whether the wanderer is more than dist from home (in x + y)
AnimFrame updateTileDuoFrames0_1[]
void updateWanderer(StageWanderer *task)
Wanders; when done, plays the animation of updateWandererFrames1 once and hides.
AnimFrame updateTileDuoFrames0_0[]
void updateTileSolo(StageTileSolo *task)
Shows the map object with animation 10 (animated) while mode isn't 0, and hides it by a one-shot anim...
StageWanderer * createWandererTask(s32 tileAnim, s32 speedIndex, s32 start)
Creates a wanderer of the map object with the given animation.
void setupStage(void)
Sets the stage up: its map, actors and events, playing BGM_0014.
void updateCommand830(StageTask *task, void **children)
Creates the tiles and the seven wanderers; in TASK_DONE makes them all hide and goes back to TASK_RUN...
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
AnimFrame updateTileDuoFrames1_1[]
u8 tileDuoObjectFrames[2][2]
void * createWanderer(s32 arg)
Creates one of the map objects that wander by the Digi-Egg of Sincerity (updateWanderer) with an id; ...
AnimFrame updateTileSoloFrames0[]
AnimFrame * updateTileDuoFrames1[]
AnimFrame updateTileSoloFrames1[]
void * createTileSoloTask(void)
Creates the color-cycling map object by the Digi-Egg of Sincerity (updateTileSolo),...
void * createCommand830(s32 id)
Creates the task of updateCommand830 with the given id.
void endEvent370(void)
After event 370, with the player: moves the story on to STORY_DE_SINCERITY and gives the player the D...
void * createTileSolo(s32 arg)
Creates the color-cycling map object by the Digi-Egg of Sincerity (updateTileSolo) with an id; nothin...
AnimFrame updateWandererFrames1[]
AnimFrame updateWandererFrames0[]
Defined below, after the code that uses them.