Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag925.c
Go to the documentation of this file.
1/*
2 * WSTAG925: Login Room, Amaterasu City, in the extra chapter. The European
3 * version's: in its extra chapter (STORY_EXTRA), mode 630 starts it instead of
4 * WSTAG226.
5 */
6
7#include "common.h"
8#include "field/stage.h"
9/* Defined below, after the code that uses them */
11extern s8 tileEffectSortY[];
12extern s8 tileEffectY[];
13
14/* Creates the event object of flag 0x40CD while it is clear */
15void updateStage(StageTask *task, void **children) {
16 switch (task->state) {
17 case TASK_INIT:
18 default:
19 if (FLAGS_00.checkCondition(FLAG(0x40, 0xCD), 0)) {
20 children[0] = FIELDSTG_startEvent(0x640);
21 }
22 task->nextState(task);
23 break;
24 case TASK_RUN:
25 case TASK_DONE:
26 case TASK_KILL:
27 break;
28 }
29}
30
31#define STAGE_CHILDREN_SIZE 4
33
34/*
35 * After event 1600, with the Tour Leader (Digimon Online's practice): heals
36 * the party's HP and MP (the European special action 0x53) and keeps it from
37 * playing again
38 */
39void endEvent1600(void) {
40 FLAGS_00.applyAction(FLAG(0x40, 0xCD), 1);
42}
43
44#if VERSION_EU
45#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_08)
46#define STAGE_FILE 0x8E9
47#define STAGE_FILE_8 0x19E
48#elif VERSION_JP
49#define STAGE_TEXT 0x89A
50#define STAGE_FILE 0x8A4
51#define STAGE_FILE_8 0x190
52#endif
53/* Sets the stage up: its map, actors and events, playing the ambience ENV_0011 */
72
74
76
77/* Moves the map objects with animations 1 to 3 to (x, y) and plays their animations once with a sound, then hides them and kills itself */
79 StageTile *object;
80 StageTile *tile;
81 s32 i;
82 s32 j;
83 s32 k;
84 s32 done;
85 s32 frame;
86
87 switch (task->state) {
88 case TASK_INIT:
89 default:
90 resetTileEffect(task);
91 task->nextState(task);
92 task->setSubstate(task, 1);
93 break;
94 case TASK_RUN:
95 switch (task->substate) {
96 case 0:
97 break;
98 case 1:
99 switch (task->step) {
100 case 0:
101 i = 0;
102 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
103 if (object->anim >= 1 && object->anim <= 3) {
104 task->anims[i].tile = object;
105 object->x = task->x;
106 object->y = task->y + tileEffectY[i];
107 object->sortY = task->y + tileEffectSortY[i];
108 i++;
109 }
110 }
112 task->nextStep(task);
113 /* fallthrough */
114 case 1:
115 done = 0;
116 for (j = 0; j < 3; j++) {
117 tile = task->anims[j].tile;
118 frame = stepAnimationOnce(&task->anims[j], updateTileEffectFrames[j], 0);
119 switch (frame) {
120 case 0xFF:
121 done++;
122 /* fallthrough */
123 case 0x12C:
124 tile->visible = 0;
125 tile->frame = 0;
126 break;
127 default:
128 tile->visible = 1;
129 tile->frame = frame;
130 break;
131 }
132 }
133 if (done < 3) {
134 break;
135 }
136 task->nextStep(task);
137 /* fallthrough */
138 case 2:
139 for (k = 0; k < 3; k++) {
140 task->anims[k].tile->visible = 0;
141 }
142 resetTileEffect(task);
143 task->setState(task, TASK_KILL);
144 break;
145 }
146 break;
147 }
148 break;
149 case TASK_DONE:
150 case TASK_KILL:
151 break;
152 }
153}
154
155/* Creates the StageTileEffect of updateTileEffect at (0x150, 0x112) with the given id */
158
159 task->x = 0x150;
160 task->y = 0x112;
161 return task;
162}
163
164/* Defined below, after the tables that use them */
165extern s16 script1600[];
166
168 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
169 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
170 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
171 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
172 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
173 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
174 { 0x140, 0x100, 0x14A, 0x1B8, 0x28, 0xB8, 0x170, 0x1FE },
175 { 0x140, 0x100, 0x170, 0x1B0, 0xC0, 0xB0, 0x160, 0x1FD },
176};
178 { NULL, NULL, 0x26 },
179 { NULL, NULL, 0 },
180};
181u16 actor0Conditions[] = { FLAG(0x40, 0xCD), 0, CODES_END };
183FieldActorEntry actor1 = { NULL, actor1Talks, 0xD, 5, 265, 397, 3 };
185 &actor0,
186 &actor1,
187 NULL,
188};
190 { 0, 1, 0x50, 6, 0x46, 0, 0, 0, 0, 0, 112, 274, 0, 0 },
191 { 1, 0, 0x40, 6, 0x3F, 1, 0x3F, 0x42, 6, 0, 116, 258, 0, 0 },
192 { 1, 0, 0x40, 6, 0x3F, 1, 0x3F, 0x42, 6, 0, 228, 282, 0, 0 },
193 { 1, 0, 0x40, 6, 0x3F, 1, 0x3F, 0x42, 6, 0, 340, 258, 0, 0 },
194 { 1, 0, 0x40, 6, 0x3F, 1, 0x3F, 0x42, 6, 0, 355, 346, 0, 0 },
195 { 0, 2, 0x50, 4, 0x48, 0, 0, 0, 0, 0, 112, 227, 301, 0 },
196 { 0, 3, 0x50, 4, 0x55, 0, 0, 0, 0, 0, 112, 227, 294, 0 },
197 { 1, 0, 0x40, 4, 0x3B, 1, 0x3B, 0x3E, 6, 0, 116, 274, 300, 0 },
198 { 1, 0, 0x40, 4, 0x3B, 1, 0x3B, 0x3E, 6, 0, 228, 298, 324, 0 },
199 { 1, 0, 0x40, 4, 0x3B, 1, 0x3B, 0x3E, 6, 0, 340, 274, 300, 0 },
200 { 1, 0, 0x40, 4, 0x3B, 1, 0x3B, 0x3E, 6, 0, 355, 362, 388, 0 },
201 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
202};
204 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x273, 0x2DA, 0x17E, 1, 0, 0, 0 },
205 { { { CODES_END, 0 }, { CODES_END, 0 } }, 0, 0, 0, 0, 0, 0, 0, 0 },
206};
207void (*stageFuncs[])(void) = {
209};
210#define EVENT_TEXT_FILE EXTRA_TEXT
212 { 1600, script1600, EVENT_TEXT(0), NULL, endEvent1600 },
213 { -1, NULL, 0, NULL, NULL },
214};
216 SCRIPT_LOOK_AT(1, 0x11E, 0x127),
217 SCRIPT_PLACE(1, 0, 0),
218 SCRIPT_POSE(1, 1, 0),
219 SCRIPT_PLACE(0xD, 0x10F, 0x191),
220 SCRIPT_POSE(0xD, 1, 3),
221 SCRIPT_WAIT(0x78),
222 SCRIPT_WAIT(0x1E),
223 SCRIPT_COMMAND(0x357, 0x335, 1),
224 SCRIPT_WAIT(0x5A),
225 SCRIPT_WAIT(0x5A),
226 SCRIPT_PLACE(1, 0x170, 0x11F),
227 SCRIPT_POSE(1, 1, 1),
228 SCRIPT_WAIT(0xB4),
229 SCRIPT_WAIT(0x1E),
230 SCRIPT_WALK(1, 0x150, 0x130, 1),
232 SCRIPT_POSE(1, 0x3A, 1),
233 SCRIPT_WAIT(0xB4),
234 SCRIPT_TALK(0, 1, 1, 0),
235 SCRIPT_POSE(1, 1, 1),
237 SCRIPT_WAIT(0x1E),
238 SCRIPT_WALK(1, 0x130, 0x160, 1),
240 SCRIPT_FOLLOW(0, 1),
241 SCRIPT_WALK(1, 0xF0, 0x180, 1),
243 SCRIPT_POSE(1, 1, 7),
244 SCRIPT_WAIT(0x1E),
245 SCRIPT_TALK(0, 2, 0xD, 2),
246 SCRIPT_POSE(0xD, 7, 3),
248 SCRIPT_POSE(0xD, 1, 3),
249 SCRIPT_WAIT(0x1E),
250 SCRIPT_TALK(0, 3, 1, 1),
251 SCRIPT_POSE(1, 7, 7),
253 SCRIPT_POSE(1, 1, 1),
254 SCRIPT_WAIT(0x1E),
255 SCRIPT_TALK(0, 4, 1, 1),
257 SCRIPT_WAIT(0x1E),
258 SCRIPT_WALK(1, 0x50, 0x1D0, 1),
259 SCRIPT_POSE(0xD, 1, 1),
260 SCRIPT_WAIT(0x5A),
261 SCRIPT_LEAVE(0x273, 0x2DA, 0x17E, 1),
263};
265 { 70, 4 }, { 71, 4 }, { 70, 4 }, { 71, 4 },
266 { 255, 0x3E7 },
267};
269 { 0x12C, 56 }, { 85, 6 }, { 86, 6 }, { 87, 4 },
270 { 88, 4 }, { 89, 4 }, { 90, 4 }, { 88, 4 },
271 { 89, 4 }, { 90, 4 }, { 88, 4 }, { 89, 4 },
272 { 90, 4 }, { 88, 4 }, { 89, 4 }, { 90, 4 },
273 { 88, 4 }, { 89, 4 }, { 90, 4 }, { 255, 0x3E7 },
274};
276 { 0x12C, 16 }, { 72, 4 }, { 73, 4 }, { 74, 4 },
277 { 73, 4 }, { 75, 6 }, { 76, 6 }, { 77, 14 },
278 { 78, 114 }, { 79, 6 }, { 80, 6 }, { 81, 6 },
279 { 82, 6 }, { 83, 6 }, { 84, 8 }, { 255, 0x3E7 },
280};
285 30, 30, 30, 0,
286};
288 0, -47, -47,
289};
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed char s8
Definition common.h:7
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
EventTask * FIELDSTG_startEvent(s32 id)
Starts the event id of FieldState.events: its script, start and end, and its text; the player stands ...
Definition event.c:250
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.
Definition stage.h:732
#define SOUND_LOGINEF
Definition stage.h:750
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
Definition field_map.h:168
#define SCRIPT_END
The commands of an event script (FieldEvent.script), as FIELDSTG_runEvent reads them: a halfword kind...
Definition field_map.h:156
#define SCRIPT_LOOK_AT(snap, x, y)
FIELDSTG_pointCamera.
Definition field_map.h:172
#define SCRIPT_LEAVE(mode, x, y, dir)
FIELDSTG_leaveField; ends the event.
Definition field_map.h:170
#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...
Definition field_map.h:161
#define SCRIPT_FOLLOW(snap, id)
FIELDSTG_followWithCamera.
Definition field_map.h:171
#define FIELD_MAP_FLOOR0
Some of FieldMap's maps (files): those of the floors the player walks on come first,...
Definition field_map.h:85
#define SCRIPT_WALK(id, x, y, dir)
Actor.setGoal: walks to (x, y), then faces dir.
Definition field_map.h:162
#define SCRIPT_WAIT_BOX
until box 0 closes
Definition field_map.h:167
#define SLOT_EXIT
The kinds of StageSlot (type).
Definition field_map.h:255
#define SCRIPT_POSE(id, set, dir)
Actor.setPose: its animation set, facing dir.
Definition field_map.h:158
#define FIELD_MAP_TRIGGERS
a cell's value: a direction (3 bits) and a StageSlot (5)
Definition field_map.h:88
#define SCRIPT_WAIT(frames)
Definition field_map.h:166
#define SCRIPT_PLACE(id, x, y)
puts a character at (x, y)
Definition field_map.h:157
#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...
Definition field_map.h:165
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
FieldState FIELDSTG_state
Definition fieldstg.c:2641
#define CODES_END
Definition game_state.h:83
#define FLAG(group, id)
The codes of the (code, value) pairs that FLAGS_00 checks as conditions and applies as actions (event...
Definition game_state.h:68
void resetTileEffect(StageTileEffect *task)
Restarts the three animations of a StageTileEffect, from the stage's updateTileEffectFrames.
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define MUSIC_DIGIMON_LAB
ENV_0011: Asuka's Digimon Lab and Login Room.
Definition sound.h:127
#define MUSIC_BANK(music)
The sound bank of a music, which a stage loads for it (FieldState.soundBank)
Definition sound.h:148
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,...
#define SPECIAL_HEAL_PARTY
the European and Japanese versions, an action: restores the party's HP and MP
Definition story.h:1795
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
One frame of a sprite animation; frame 0xFF ends it (or loops it)
Definition gfx.h:296
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
Definition field_map.h:194
An event of the table FieldState.events, up to the first id -1, which FIELDSTG_startEvent starts.
Definition field_map.h:141
void(* setFile)(s32 index, s32 file)
FIELDSTG_setMapFile.
Definition field_map.h:100
void(* setFirstMap)(s32 index)
FIELDSTG_setFirstMap: the map the player starts on (GAME.mapIndex), when the mode is new.
Definition field_map.h:104
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
Definition field_map.h:445
FieldEvent * events
up to the first id -1
Definition field_map.h:451
s32 soundBank
SOUND.loadBank's, or 0.
Definition field_map.h:459
StageTile * objects
the map objects, up to the first margin 0
Definition field_map.h:446
s32 imageFile
or an image archive file, or 0
Definition field_map.h:449
Vec2 start
where the player starts
Definition field_map.h:456
StageSlot * slots
up to the first type 0
Definition field_map.h:447
ActorImage * actors
then the actors', from actors[2]
Definition field_map.h:454
s32 mapFile
the file of the map's tiles (FIELDSTG_createMapStreamer)
Definition field_map.h:444
s32 startDir
and its direction
Definition field_map.h:457
s32 textFile
the stage's text file, for the talks
Definition field_map.h:461
union FieldState::@12 images
s32 music
SOUND.playSound's, or 0.
Definition field_map.h:460
What a character says (FIELDSTG_runActorAction): the first whose conditions hold, or the last,...
Definition field_map.h:176
void(* applyAction)(s32 code, s32 value)
Definition game_state.h:52
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
What the player can trigger on a map (FIELDSTG_updateTriggers): a record of the table at FieldState....
Definition field_map.h:276
The task a stage starts (startStage), updated by its updateStage.
Definition stage.h:26
void(* nextState)(struct StageTask *task)
Definition stage.h:27
s32 state
Definition stage.h:27
StageTile * tile
Definition stage.h:109
Three map objects (animations 1 to 3) moved to (x, y) and animated once when the substate is set to 1...
Definition stage.h:117
void(* setState)(struct StageTileEffect *task, s32 state)
Definition stage.h:118
StageTileAnim anims[3]
Definition stage.h:121
void(* setSubstate)(struct StageTileEffect *task, s32 substate)
Definition stage.h:118
void(* nextState)(struct StageTileEffect *task)
Definition stage.h:118
void(* nextStep)(struct StageTileEffect *task)
Definition stage.h:118
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
Definition field_map.h:208
u8 anim
which of a stage's animations sets frame (1-3); FIELDSTG finds objects by it (its lift,...
Definition field_map.h:210
Definition gfx.h:352
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.
Definition task.c:80
FieldActorEntry actor0
Definition wstag925.c:182
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag925.c:207
void updateTileEffect(StageTileEffect *task)
Moves the map objects with animations 1 to 3 to (x, y) and plays their animations once with a sound,...
Definition wstag925.c:78
AnimFrame * updateTileEffectFrames[]
Defined below, after the code that uses them.
Definition wstag925.c:281
s8 tileEffectSortY[]
Definition wstag925.c:284
#define STAGE_FILE_8
Definition wstag925.c:47
FieldActorEntry * stageActors[]
Definition wstag925.c:184
s8 tileEffectY[]
Definition wstag925.c:287
FieldTalk actor1Talks[]
Definition wstag925.c:177
AnimFrame updateTileEffectFrames_0[]
Definition wstag925.c:264
void * createCommand855(s32 id)
Creates the StageTileEffect of updateTileEffect at (0x150, 0x112) with the given id.
Definition wstag925.c:156
ActorImage stageImages[]
Definition wstag925.c:167
void setupStage(void)
Sets the stage up: its map, actors and events, playing the ambience ENV_0011.
Definition wstag925.c:54
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag925.c:189
AnimFrame updateTileEffectFrames_2[]
Definition wstag925.c:268
StageSlot stageSlots[]
Definition wstag925.c:203
s16 script1600[]
Defined below, after the tables that use them.
Definition wstag925.c:215
AnimFrame updateTileEffectFrames_1[]
Definition wstag925.c:275
FieldActorEntry actor1
Definition wstag925.c:183
#define STAGE_FILE
Definition wstag925.c:46
void endEvent1600(void)
After event 1600, with the Tour Leader (Digimon Online's practice): heals the party's HP and MP (the ...
Definition wstag925.c:39
#define STAGE_TEXT
Definition wstag925.c:45
FieldEvent stageEvents[]
Definition wstag925.c:211
u16 actor0Conditions[]
Definition wstag925.c:181