28 if (frame->
frame == 0xFF) {
43 switch (task->
state) {
94 switch (task->
state) {
101 if (object->
anim == 1) {
140 if (task !=
NULL &&
id == 0x35A) {
162 if (task->
step == 0) {
187 switch (task->
state) {
191 if (object->
anim == 2) {
197 for (i = 0; i < 5; i++) {
217 if (task->
step == 0) {
234 if (task->
spawn != 0) {
290 switch (task->
state) {
308#define STAGE_CHILDREN_SIZE 0xC
325#if VERSION_US || VERSION_JP
326#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
327#define EVENT_TEXT_FILE (TEXT_EVENTS_500 - 1)
328#define STAGE_FILE 0x267
329#define STAGE_ARCHIVE 0x3CF
331#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
332#define EVENT_TEXT_FILE (TEXT_EVENTS_500 - 1)
333#define STAGE_FILE 0x276
334#define STAGE_ARCHIVE 0x3DF
437 { 11, 4 }, { 12, 4 }, { 13, 7 }, { 14, 9 },
438 { 15, 10 }, { 16, 8 }, { 17, 4 }, { 18, 4 },
439 { 19, 4 }, { 20, 4 }, { 21, 4 }, { 22, 4 },
440 { 23, 100 }, { 255, 0 },
443 { 9, 25 }, { 8, 4 }, { 7, 4 }, { 6, 4 },
444 { 5, 4 }, { 4, 4 }, { 3, 6 }, { 2, 7 },
445 { 1, 8 }, { 0, 8 }, { 1, 10 }, { 2, 10 },
446 { 3, 10 }, { 4, 10 }, { 5, 10 }, { 6, 10 },
447 { 7, 10 }, { 8, 10 }, { 255, 0x3E7 },
450 { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 },
451 { 4, 4 }, { 5, 4 }, { 6, 4 }, { 7, 4 },
452 { 8, 4 }, { 255, 0x3E7 },
455 { 10, 4 }, { 9, 10 }, { 255, 0x3E7 },
458 { 10, 4 }, { 9, 4 }, { 255, 0 },
524 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
525 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
526 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
527 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
528 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
529 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
530 { 0x180, 0x100, 0x1A8, 0x1C8, 0x1A0, 0xC8, 0x150, 0x1FC },
531 { 0x180, 0x100, 0x1A0, 0x1C8, 0x180, 0xC8, 0x160, 0x1FC },
578 { 1, 0, 0x64, 2, 0x63, 0, 0, 0, 0, 0, 529, 465, 0, 0 },
579 { 1, 0, 0x64, 2, 0x61, 0, 0, 0, 0, 0, 427, 1040, 0, 0 },
580 { 1, 0, 0x64, 2, 0x61, 0, 0, 0, 0, 0, 546, 1044, 0, 0 },
581 { 1, 0, 0x64, 2, 0x62, 0, 0, 0, 0, 0, 502, 1051, 0, 0 },
582 { 0, 2, 0x80, 4, 0, 0, 0, 0, 0, 0, 701, 371, 371, 0 },
583 { 0, 7, 0xF0, 4, 0xB, 0, 0, 0, 0, 0, 564, 369, 369, 0 },
584 { 0, 5, 0xF0, 4, 0xB, 0, 0, 0, 0, 0, 592, 287, 287, 0 },
585 { 0, 3, 0xF0, 4, 0xB, 0, 0, 0, 0, 0, 648, 471, 471, 0 },
586 { 0, 6, 0xF0, 4, 0xB, 0, 0, 0, 0, 0, 775, 457, 457, 0 },
587 { 0, 4, 0xF0, 4, 0xB, 0, 0, 0, 0, 0, 815, 368, 368, 0 },
588 { 0, 1, 0x50, 4, 0x18, 0, 0, 0, 0, 0, 663, 340, 370, 0 },
589 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
592 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_EXIT, 0x245, 0x708, 0x20C, 3, 0, 0, 0 },
593 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_EXIT, 0x245, 0x708, 0x2DC, 3, 0, 0, 0 },
594 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_EXIT, 0x245, 0x708, 0x3BC, 3, 0, 0, 0 },
595 { { {
CODES_END, 0 }, {
CODES_END, 0 } },
SLOT_EXIT, 0x245, 0x708, 0x50E, 3, 0, 0, 0 },
596 { { {
PROGRESS(
STORY_BULBMON_FOUND), 1 }, {
FLAG_ZHU_QUE_CHIEF_CHALLENGE_SEEN, 0 } },
SLOT_EVENT, 0x2C6, 0, 0, 0, 0, 0, 0 },
597 { { {
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...
EventTask * FIELDSTG_startEvent(s32 id)
Starts the event id of FieldState.events: its script, start and end, and its text; the player stands ...
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 FIELD_COMMAND_PLAY_DEMO_BGM
#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_LOOK_AT(snap, x, y)
FIELDSTG_pointCamera.
#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 FIELD_COMMAND_STOP_CAMERA_SHAKE
#define FIELD_MAP_FLOOR0
Some of FieldMap's maps (files): those of the floors the player walks on come first,...
#define FIELD_COMMAND_SHAKE_CAMERA
#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 SLOT_EXIT
The kinds of StageSlot (type).
#define FIELD_MAP_AREAS
a cell's value: its battle area (FieldBattles), or 0
#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 EVENT_BATTLE(id)
action: FIELDSTG_battleFuncs.startEventBattle
#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.
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
#define MUSIC_BATTLE
BATL0000: the maps' random battles (AreaBattle, nearly all of them)
#define MUSIC_BUG_MAZE
BGM_0017: the Bug Maze (Network Break)
#define MUSIC_BOSS
BOSS_000: the sectors' boss battles.
#define MUSIC(bank, n)
A field's or a battle's music (FieldState.music, Battle.music): track (SEP) n of the first sequence o...
#define MUSIC_BANK(music)
The sound bank of a music, which a stage loads for it (FieldState.soundBank)
FIELDSTG's start of the stage (StageEntry.init in FIELDSTG_stages): the stage's task,...
s32 stepAnimationOnce(StageTileAnim *obj, AnimFrame *frames, s32 depth)
Steps OBJ's animation through FRAMES by the frame time (at most 4) and returns its frame,...
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 ...
#define SPECIAL_STORY_JUNGLE_SOUND_TO_AMATERASU_BRIDGE
GAME.progress is from STORY_JUNGLE_SOUND to STORY_AMATERASU_BRIDGE (PROGRESS_RANGES[0x12])
@ STORY_PRESIDENT_ARRESTED
WSTAG226 (Login Room, Amaterasu City), event 935, after the President of MAGAMI gives himself up (WST...
@ STORY_BULBMON_FOUND
WSTAG520 (Suzaku Hall), event 695: another earthquake; Bulbmon digs the holes.
@ STORY_JUNGLE_SOUND
WSTAG545 (Bug Maze Pit), event 711: Patamon heard a weird sound from the jungle, where its leader wen...
#define SPECIAL_STORY_ASUKA_HEADQUARTERS_TO_OPERATION_SIGMA
GAME.progress is from STORY_ASUKA_HEADQUARTERS to STORY_OPERATION_SIGMA (PROGRESS_RANGES[0x13])
#define SPECIAL_SHOW_ITEM_GET_ICON
an action: the player's icon plays its animation 3 with SOUND_ITEM_GET (FIELD_COMMAND_ICON3); the tal...
#define FLAG_ZHU_QUE_CHIEF_CHALLENGE_SEEN
wstag545 event 710: the player asks Zhu Que Chief where the Digi-Egg of Knowledge is; set at its end,...
#define FLAG_BUG_MAZE_PIT_DIGITAMA_MAIL_FOUND
wstag545: chest that gives the Digitama Mail, "I got" text; its conditions test it 0
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 battle of an area's BattleList, which can start on the field (see FIELDSTG_startEncounter); FIGHTST...
The battles of an area of the map (its cells' value at FieldMap.files[4]), one picked at random.
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
The battles of a place (FieldState.battles), by area of the map: the fourth area's are also the ones ...
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(* checkCondition)(u16 code, u16 value)
s32(* getFrameTime)(void)
short(* playSound)(s32 id)
returns the voice of a key-on
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)
A map object with the animation that sets its frame.
Where a StageTileAt is created.
The map object with the given animation, moved to (x, y)
void(* nextState)(struct StageTileAt *task)
void(* setState)(struct StageTileAt *task, s32 state)
void(* setSubstate)(struct StageTileAt *task, s32 substate)
The children of a StageTileSwitch.
The map object with animation 2, animated by substate, and the StageTileAt children that events set t...
s32 silent
no sound when an event comes
void(* setStep)(struct StageTileSwitch *task, s32 step)
void(* setSubstate)(struct StageTileSwitch *task, s32 substate)
s32 spawn
the child to set to TASK_DONE, + 1
void(* nextState)(struct StageTileSwitch *task)
void(* setSubstate)(struct StageTileTask *task, s32 substate)
void(* setState)(struct StageTileTask *task, s32 state)
void(* nextState)(struct StageTileTask *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,...
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.
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
void * createTileTask(s32 arg)
Creates the map object that event 710, Bulbmon's earthquake, sets off (updateTileTask),...
StageTileAt * createTileAt(s32 anim, s32 x, s32 y)
Creates a StageTileAt for the map object with the given animation.
void handleCommand847(StageTask *task, s32 id)
Command 847 of the event scripts: told 0x35A in event 710 (Bulbmon's earthquake), ends its task.
FieldActorEntry * stageActors[]
AnimFrame updateTileSwitchFrames_1[]
void updateTileAt(StageTileAt *task)
Moves the map object with the given animation to (x, y); hidden while running, shown and animated whe...
void * createCommand848(s32 id)
Creates the task of updateTileSwitch with the given id.
void endEvent710(void)
After event 710, with the player: starts the stage's event battle 0 and keeps it from playing again.
static void playSwitchOnce(StageTileSwitch *task, StageTile *tile, s32 n, s32 done, s32 next)
Plays the switch's animation N once (from its start, on step 0), then holds frame DONE and goes on to...
void handleCommand848(void *arg, s32 id)
Events 0x35D to 0x364: animate the map object (substates 1, 3, 5) or pick a child to set to TASK_DONE...
AnimFrame updateTileSwitchFrames_2[]
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing BGM_0017.
AnimFrame updateTileAtFrames[]
Defined below, after the code that uses them.
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
AnimFrame updateTileTaskFrames[]
void endEvent711(void)
After event 711, with the player: moves the story on to STORY_JUNGLE_SOUND.
AnimFrame * updateTileSwitchFrames[3]
AnimFrame updateTileSwitchFrames_0[]
void updateTileTask(StageTileTask *task)
Shows the map object with animation 1 (frame 0x18); when done, animates it once with a sound and goes...
s32 stepHeldAnimation(StageTileAnim *obj, AnimFrame *frames, s32 depth)
Steps an animation, holding its last frame, and returns the frame.
void updateTileSwitch(StageTileSwitch *task, StageTileAts *children)
The switch, the map object with animation 2, played by substate (events 0x35D to 0x35F); also sets th...
StageTileAtSpot updateTileSwitchSpots[]
FieldBattles stageBattles[]