Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag790.c
Go to the documentation of this file.
1/*
2 * WSTAG790: Chamber Room, Kusanagi City (the Real World). Where Junior logs
3 * into the game; Guardromon saves.
4 */
5
6#include "common.h"
7#include "field/stage.h"
8
9/*
10 * Once the substate is set to 1, moves the map objects of animations 2, 3, 4 and
11 * 7 and shows those of 5 to 9 in turn
12 */
14 s32 i;
15
16 switch (task->state) {
17 case TASK_INIT:
18 default:
19 for (i = 0; i < 8; i++) {
20 task->tiles[i] = FIELDSTG_findObject(i + 2);
21 }
22 task->nextState(task);
23 break;
24 case TASK_RUN:
25 switch (task->substate) {
26 case 0:
27 break;
28 case 1:
29 switch (task->step) {
30 case 0:
32 task->nextStep(task);
33 /* fallthrough */
34 case 1:
35 if (task->counter & 1) {
36 task->tiles[0]->y++;
37 task->tiles[1]->y++;
38 task->tiles[2]->y++;
39 task->tiles[5]->y++;
40 }
41 if (++task->counter != 8) {
42 break;
43 }
44 task->nextStep(task);
45 /* fallthrough */
46 case 2:
47 if (task->counter & 1) {
48 task->tiles[1]->y++;
49 task->tiles[5]->y++;
50 }
51 if (++task->counter != 0x10) {
52 break;
53 }
54 task->nextStep(task);
55 /* fallthrough */
56 case 3:
57 if (task->counter == 0) {
58 task->tiles[3]->visible = 1;
60 task->tickCounter(task);
61 }
62 if (task->tiles[3]->clutRow == 0xF) {
63 task->nextStep(task);
64 }
65 break;
66 case 4:
67 if (task->counter == 0) {
68 task->tiles[3]->visible = 0;
69 task->tiles[4]->visible = 1;
70 task->tiles[5]->visible = 0;
71 task->tiles[6]->visible = 1;
72 task->tickCounter(task);
73 }
74 if (task->tiles[6]->clutRow == 0xF) {
75 task->tiles[6]->visible = 0;
76 task->tiles[7]->visible = 1;
77 task->nextStep(task);
78 }
79 break;
80 }
81 break;
82 }
83 break;
84 case TASK_DONE:
85 case TASK_KILL:
86 break;
87 }
88}
89
90/* Starts the task (substate 1) when map object 0x32C is triggered */
92 if (task != NULL && id == 0x32C) {
93 task->setSubstate(task, 1);
94 }
95}
96
97/* Creates the task of updateTileGroup with id 0x329 */
99 return createTaskWithId(updateTileGroup, sizeof(StageTileGroup), 0, 0x329);
100}
101
102/* Once the substate is set to 1, animates the frame of the map object of animation 1 for 20 frames, then plays a sound */
104 StageTile *tile;
105
106 switch (task->state) {
107 case TASK_INIT:
108 default:
109 task->nextState(task);
110 /* fallthrough */
111 case TASK_RUN:
112 switch (task->substate) {
113 case 0:
114 break;
115 case 1:
116 switch (task->step) {
117 case 0:
118 task->frame = (task->counter >> 2) + 5;
119 if (++task->counter >= 0x14) {
121 task->nextStep(task);
122 } else {
123 tile = FIELDSTG_findObject(1);
124 if (tile != NULL) {
125 tile->frame = task->frame;
126 }
127 }
128 break;
129 }
130 break;
131 }
132 break;
133 case TASK_DONE:
134 case TASK_KILL:
135 break;
136 }
137}
138
139/* Starts the task (substate 1) when map object 0x32E is triggered */
141 if (task != NULL && id == 0x32E) {
142 task->setSubstate(task, 1);
143 }
144}
145
146/*
147 * Command 808 of the event scripts: the map object of event 4 in the Chamber
148 * Room, whose frame plays for 20 frames, then a sound (updateFrameTask)
149 */
151 return createTaskWithId(updateFrameTask, sizeof(StageFrameTask), 0, arg);
152}
153
154/* Creates two objects and the event object of story progress 1 */
155void updateStage(StageTask *task, void **children) {
156 switch (task->state) {
157 case TASK_INIT:
158 default:
159 children[2] = createCommand809(0x329);
160 children[1] = createCommand808(0x328);
162 children[0] = FIELDSTG_startEvent(4);
163 }
164 task->nextState(task);
165 break;
166 case TASK_RUN:
167 case TASK_DONE:
168 case TASK_KILL:
169 break;
170 }
171}
172
173#define STAGE_CHILDREN_SIZE 0xC
175
176#if VERSION_US || VERSION_JP
177#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
178#define EVENT_TEXT_FILE (TEXT_EVENTS_700 - 1)
179#define STAGE_FILE 0x1BB
180#define STAGE_ARCHIVE 0x322
181#elif VERSION_EU
182#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
183#define EVENT_TEXT_FILE (TEXT_EVENTS_700 - 1)
184#define STAGE_FILE 0x1C9
185#define STAGE_ARCHIVE 0x331
186#endif
187/* Sets the stage up: its map, actors and events, playing the ambience ENV_0024 */
204
206 SCRIPT_LOOK_AT(1, 0x157, 0x121),
207 SCRIPT_PLACE(1, 0, 0),
208 SCRIPT_POSE(1, 1, 1),
209 SCRIPT_PLACE(0xB, 0, 0),
210 SCRIPT_POSE(0xB, 1, 1),
211 SCRIPT_PLACE(0xC, 0, 0),
212 SCRIPT_POSE(0xC, 1, 1),
213 SCRIPT_PLACE(0xD, 0x18A, 0xF6),
214 SCRIPT_POSE(0xD, 1, 3),
215 SCRIPT_COMMAND(0x328, 0x32D, 0x328),
216 SCRIPT_COMMAND(0x329, 0x32D, 0x328),
217 SCRIPT_WAIT(0x3C),
218 SCRIPT_PLACE(1, 0xE5, 0x159),
219 SCRIPT_POSE(1, 1, 5),
220 SCRIPT_WAIT(0x1E),
221 SCRIPT_WALK(1, 0x157, 0x121, 0),
223 SCRIPT_FOLLOW(1, 1),
224 SCRIPT_POSE(1, 0x3A, 1),
225 SCRIPT_WAIT(0x78),
226 SCRIPT_TALK(0, 1, 1, 3),
227 SCRIPT_POSE(1, 7, 0),
229 SCRIPT_POSE(1, 1, 0),
230 SCRIPT_WAIT(0x1E),
231 SCRIPT_WALK(1, 0x19B, 0xFF, 5),
233 SCRIPT_POSE(1, 1, 3),
234 SCRIPT_POSE(0xD, 1, 7),
235 SCRIPT_WAIT(0x1E),
236 SCRIPT_TALK(0, 2, 0xD, 0),
237 SCRIPT_POSE(0xD, 7, 7),
239 SCRIPT_POSE(0xD, 1, 7),
240 SCRIPT_WAIT(0x1E),
241 SCRIPT_TALK(0, 3, 1, 1),
242 SCRIPT_POSE(1, 7, 3),
244 SCRIPT_POSE(1, 1, 3),
245 SCRIPT_WAIT(0x1E),
246 SCRIPT_POSE(1, 1, 7),
247 SCRIPT_POSE(0xD, 2, 3),
248 SCRIPT_WAIT(0x3C),
249 SCRIPT_POSE(1, 0x29, 7),
250 SCRIPT_WAIT(0x5A),
251 SCRIPT_POSE(1, 0x2A, 7),
252 SCRIPT_POSE(0xD, 1, 3),
253 SCRIPT_COMMAND(0x323, 0x325, 0xD),
254 SCRIPT_WAIT(0x3C),
255 SCRIPT_POSE(1, 1, 7),
256 SCRIPT_POSE(0xD, 1, 7),
257 SCRIPT_COMMAND(0x323, 0x326, 0xD),
258 SCRIPT_WAIT(0x1E),
259 SCRIPT_POSE(1, 1, 3),
260 SCRIPT_WAIT(0x1E),
261 SCRIPT_TALK(0, 4, 0xD, 0),
262 SCRIPT_POSE(0xD, 7, 7),
263 SCRIPT_COMMAND(0x329, 0x32B, 1),
265 SCRIPT_POSE(0xD, 1, 7),
266 SCRIPT_WAIT(0x1E),
267 SCRIPT_TALK(0, 5, 1, 1),
268 SCRIPT_POSE(1, 7, 3),
270 SCRIPT_POSE(1, 1, 3),
271 SCRIPT_WAIT(0x1E),
272 SCRIPT_LOOK_AT(1, 0x19B, 0xFF),
273 SCRIPT_WALK(1, 0x1D5, 0xE1, 5),
274 SCRIPT_POSE(0xD, 1, 3),
276 SCRIPT_PLACE(1, 0, 0),
277 SCRIPT_POSE(1, 1, 0),
278 SCRIPT_POSE(0xD, 2, 3),
279 SCRIPT_WAIT(0x3C),
280 SCRIPT_PLACE(0xB, 0xEB, 0x151),
281 SCRIPT_POSE(0xB, 1, 5),
282 SCRIPT_WAIT(0x1E),
283 SCRIPT_WALK(0xB, 0xFE, 0x148, 5),
284 SCRIPT_PLACE(0xC, 0xEB, 0x151),
285 SCRIPT_POSE(0xC, 1, 5),
286 SCRIPT_WAIT_WALK(0xB),
287 SCRIPT_WALK(0xB, 0x171, 0x10F, 5),
288 SCRIPT_WALK(0xC, 0x15A, 0x11B, 5),
289 SCRIPT_WAIT_WALK(0xC),
290 SCRIPT_POSE(0xB, 1, 5),
291 SCRIPT_POSE(0xC, 1, 5),
292 SCRIPT_COMMAND(0x328, 0x32E, 1),
293 SCRIPT_WAIT(0x3C),
294 SCRIPT_POSE(0xB, 0x33, 5),
295 SCRIPT_WAIT(0x3C),
296 SCRIPT_TALK(0, 7, 0xB, 2),
297 SCRIPT_POSE(0xB, 0xC, 5),
299 SCRIPT_POSE(0xB, 1, 5),
300 SCRIPT_WAIT(0x1E),
301 SCRIPT_TALK(0, 8, 0xC, 2),
302 SCRIPT_POSE(0xC, 7, 5),
304 SCRIPT_POSE(0xC, 1, 5),
305 SCRIPT_COMMAND(0x329, 0x32C, 1),
306 SCRIPT_WAIT(0x12C),
307#if VERSION_US
308 SCRIPT_LEAVE(0xE02, 0x170, 0x11F, 1),
309#elif VERSION_EU || VERSION_JP
310 SCRIPT_LEAVE(0xE03, 0x170, 0x11F, 1),
311#endif
313};
315 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
316 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
317 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
318 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
319 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
320 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
321 { 0x140, 0x100, 0x166, 0x1D0, 0x98, 0xD0, 0x170, 0x1FB },
322 { 0x180, 0x100, 0x1B6, 0x130, 0x1D8, 0x30, 0x170, 0x1FA },
323 { 0x180, 0x100, 0x1B4, 0x1A3, 0x1D0, 0xA3, 0x170, 0x1F9 },
324 { 0x180, 0x100, 0x1A6, 0x130, 0x198, 0x30, 0x170, 0x1F8 },
325};
328FieldActorEntry actor0 = { NULL, NULL, 1, 4, 0, 0, 0 };
330FieldActorEntry actor2 = { NULL, NULL, 0xC, 6, 0, 0, 0 };
333 &actor0,
334 &actor1,
335 &actor2,
336 &actor3,
337 NULL,
338};
340 { 1, 4, 0x40, 2, 0xC, 0, 0, 0, 0, 0, 479, 117, 0, 0 },
341 { 1, 7, 0x40, 2, 0x39, 0, 0, 0, 0, 0, 407, 126, 0, 0 },
342 { 0, 8, 0x40, 2, 0x34, 2, 0, 0xF, 5, 0, 407, 138, 0, 0 },
343 { 0, 9, 0x40, 2, 0x38, 2, 0xE, 0xF, 4, 0xE, 407, 138, 0, 0 },
344 { 1, 3, 0x90, 2, 0xB, 0, 0, 0, 0, 0, 415, 79, 0, 0 },
345 { 1, 2, 0x40, 2, 0xA, 0, 0, 0, 0, 0, 387, 76, 0, 0 },
346 { 0, 5, 0x40, 2, 0x33, 2, 0, 0xF, 4, 0, 428, 172, 0, 0 },
347 { 0, 6, 0x40, 2, 0x37, 2, 0xE, 0xF, 4, 0xE, 428, 172, 0, 0 },
348 { 1, 1, 0x40, 2, 4, 0, 0, 0, 0, 0, 418, 191, 0, 0 },
349 { 1, 0, 0x40, 2, 0x32, 2, 0, 3, 2, 0, 254, 146, 0, 0 },
350 { 1, 0, 0x40, 2, 0x32, 2, 0, 3, 2, 0, 442, 241, 0, 0 },
351 { 1, 0, 0x40, 2, 0x32, 2, 0, 3, 2, 0, 538, 288, 0, 0 },
352 { 1, 0, 0x40, 6, 0x36, 0, 0, 7, 0xA, 0, 361, 205, 0, 0 },
353 { 1, 0, 0x40, 0xA, 0x35, 0, 0, 0, 0, 0, 150, 0, 0, 0 },
354 { 1, 0, 0x40, 4, 0, 0, 0, 0, 0, 0, 398, 279, 296, 0 },
355 { 1, 0, 0x40, 4, 1, 0, 0, 0, 0, 0, 430, 247, 264, 0 },
356 { 1, 0, 0x40, 4, 2, 0, 0, 0, 0, 0, 397, 263, 281, 0 },
357 { 1, 0, 0x40, 4, 3, 0, 0, 0, 0, 0, 429, 232, 247, 0 },
358 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
359};
360void (*stageFuncs[])(void) = {
362};
364 { 4, script4, EVENT_TEXT(3), NULL, NULL },
365 { -1, NULL, 0, NULL, NULL },
366};
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#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_CCOMBINE
Definition stage.h:755
#define SOUND_SIGNALON
Definition stage.h:753
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define SOUND_DOORCLSE
Definition stage.h:754
#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 SCRIPT_POSE(id, set, dir)
Actor.setPose: its animation set, facing dir.
Definition field_map.h:158
#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 PROGRESS(n)
GAME.progress is n.
Definition game_state.h:69
StageTile * FIELDSTG_findObject(s32 anim)
The first map object of an animation, or NULL (FIELDSTG_findNextObject goes on)
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_CHAMBER_ROOM
ENV_0024: the Chamber Rooms.
Definition sound.h:140
#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,...
@ STORY_ACCOUNT_REGISTERED
WSTAG785, event 1: the account is registered, and the clerk sends Junior to the Chamber Room.
Definition story.h:26
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
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
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
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
A frame the task sets on a map object.
Definition stage.h:609
void(* nextState)(struct StageFrameTask *task)
Definition stage.h:610
void(* nextStep)(struct StageFrameTask *task)
Definition stage.h:610
The task a stage starts (startStage), updated by its updateStage.
Definition stage.h:26
void(* nextState)(struct StageTask *task)
Definition stage.h:27
void(* setSubstate)(struct StageTask *task, s32 substate)
Definition stage.h:27
s32 state
Definition stage.h:27
The map objects with animations 2 to 9.
Definition stage.h:383
void(* nextState)(struct StageTileGroup *task)
Definition stage.h:384
void(* nextStep)(struct StageTileGroup *task)
Definition stage.h:384
void(* tickCounter)(struct StageTileGroup *task)
Definition stage.h:384
StageTile * tiles[8]
Definition stage.h:385
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
Definition field_map.h:208
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
u16 actor1Conditions[]
Definition wstag790.c:326
FieldActorEntry actor0
Definition wstag790.c:328
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag790.c:360
void updateFrameTask(StageFrameTask *task)
Once the substate is set to 1, animates the frame of the map object of animation 1 for 20 frames,...
Definition wstag790.c:103
void * createCommand809(s32 arg)
Creates the task of updateTileGroup with id 0x329.
Definition wstag790.c:98
void handleCommand808(StageTask *task, s32 id)
Starts the task (substate 1) when map object 0x32E is triggered.
Definition wstag790.c:140
void updateTileGroup(StageTileGroup *task)
Once the substate is set to 1, moves the map objects of animations 2, 3, 4 and 7 and shows those of 5...
Definition wstag790.c:13
FieldActorEntry actor2
Definition wstag790.c:330
FieldActorEntry * stageActors[]
Definition wstag790.c:332
s16 script4[]
Definition wstag790.c:205
#define STAGE_ARCHIVE
Definition wstag790.c:185
u16 actor3Conditions[]
Definition wstag790.c:327
void * createCommand808(s32 arg)
Command 808 of the event scripts: the map object of event 4 in the Chamber Room, whose frame plays fo...
Definition wstag790.c:150
ActorImage stageImages[]
Definition wstag790.c:314
void setupStage(void)
Sets the stage up: its map, actors and events, playing the ambience ENV_0024.
Definition wstag790.c:188
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag790.c:339
void handleCommand809(StageTask *task, s32 id)
Starts the task (substate 1) when map object 0x32C is triggered.
Definition wstag790.c:91
FieldActorEntry actor1
Definition wstag790.c:329
#define STAGE_FILE
Definition wstag790.c:184
#define STAGE_TEXT
Definition wstag790.c:182
FieldActorEntry actor3
Definition wstag790.c:331
FieldEvent stageEvents[]
Definition wstag790.c:363