Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag800.c
Go to the documentation of this file.
1/*
2 * WSTAG800: Magasta B2F, Undersea Base. Where the player tries to stop the
3 * Juggernaut's launch.
4 */
5
6#include "common.h"
7#include "field/stage.h"
8#if VERSION_US || VERSION_JP
9#define TIMER_SHEET 0x6EE
10#elif VERSION_EU
11#define TIMER_SHEET 0x6FE
12#endif
13
14/* Defined below, after the code that uses them */
20extern s16 timerDigitX[];
23
25
26/* Shows the first map object animated while running; when done, both */
28 StageTile *tile;
29 StageTile *object;
30 s32 i;
31 s32 frame;
32
33 switch (task->state) {
34 case TASK_INIT:
35 default:
36 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
37 if (object->anim == 1) {
38 task->anims[0].anim.index = 0;
39 task->anims[0].anim.timer = (u8)updateTilePair16Frames0[0].duration;
40 task->anims[0].tile = object;
41 }
42 if (object->anim == 2) {
43 task->anims[1].anim.index = 0;
44 task->anims[1].anim.timer = (u8)updateTilePair16Frames1[0].duration;
45 task->anims[1].tile = object;
46 }
47 }
48 task->playing = 0;
49 if (task->done == 0) {
50 task->nextState(task);
51 } else {
52 task->anims[0].anim.index = 0;
53 task->anims[0].anim.timer = (u8)updateTilePair16Frames2[0].duration;
54 task->setState(task, TASK_DONE);
55 }
56 break;
57 case TASK_RUN:
58 for (i = 0; i < 2; i++) {
59 tile = task->anims[i].tile;
60 switch (i) {
61 case 0:
62 tile->visible = 1;
63 tile->frame = 0x46;
65 break;
66 case 1:
67 tile->visible = 0;
68 break;
69 }
70 }
71 break;
72 case TASK_DONE:
73 for (i = 0; i < 2; i++) {
74 tile = task->anims[i].tile;
75 switch (i) {
76 case 0:
77 tile->visible = 1;
78 if (task->playing) {
79 frame = stepTileAnimation(&task->anims[0], updateTilePair16Frames2, 1, 0);
80 if (frame == 0xFF) {
81 tile->frame = 0x50;
82 task->playing = 0;
83 } else {
84 tile->frame = frame;
85 }
86 } else {
87 tile->frame = 0x50;
88 }
89 tile->clutRow = 0;
90 break;
91 case 1:
92 tile->visible = 1;
93 tile->frame = 0x51;
95 break;
96 }
97 }
98 break;
99 case TASK_KILL:
100 break;
101 }
102}
103
104/* Plays the first map object's one-shot animation when the event of map object 0x35B happens */
106 if (id == 0x35B) {
107 task->playing = 1;
108 task->anims[0].anim.index = 0;
109 task->anims[0].anim.timer = (u8)updateTilePair16Frames2[0].duration;
110 task->setState(task, TASK_DONE);
111 }
112}
113
114/* Creates the button's map objects of event 850 (updateTilePair16) with an id */
116 return createTaskWithId(updateTilePair16, sizeof(StageTilePair16), 0, arg);
117}
118
119/* Creates the tile pair object, started in TASK_DONE */
122
123 task->done = 1;
124 return task;
125}
126
127/* stepTileAnimation for a StageTileAnimFlag */
129 AnimFrame *frame = &frames[obj->anim.index];
130 s32 dt = GFX.funcs.getFrameTime();
131
132 if (dt > 4) {
133 dt = 4;
134 }
135 if (depth == 0) {
136 obj->anim.timer -= dt;
137 }
138 if (obj->anim.timer <= 0) {
139 frame++;
140 obj->anim.index++;
141 obj->anim.timer += (u8)frame->duration;
142 if (once) {
143 if (frame->frame == 0xFF) {
144 return 0xFF;
145 }
146 } else if (frame->frame == 0xFF) {
147 frame = frames;
148 obj->anim.index = 0;
149 obj->anim.timer += (u8)frame->duration;
150 }
151 stepTileAnimation2(obj, frames, once, depth + 1);
152 }
153 return frame->frame;
154}
155
156/* Plays the map objects with animations 3 and 4 once, then ends */
158 StageTile *object;
159 StageTile *tile;
160 s32 i;
161 s32 frame;
162
163 switch (task->state) {
164 case TASK_INIT:
165 default:
166 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
167 if (object->anim == 3) {
168 task->tiles[0].playing = 0;
169 task->tiles[0].tile = object;
170 }
171 if (object->anim == 4) {
172 task->tiles[1].playing = 0;
173 task->tiles[1].tile = object;
174 }
175 }
176 task->tiles[0].playing = 1;
177 task->tiles[0].anim.index = 0;
178 task->tiles[0].anim.timer = (u8)updateTileOnceFrames_0[0].duration;
179 task->tiles[1].playing = 1;
180 task->tiles[1].anim.index = 0;
181 task->tiles[1].anim.timer = (u8)updateTileOnceFrames_1[0].duration;
182 task->nextState(task);
183 break;
184 case TASK_RUN:
185 for (i = 0; i < 2; i++) {
186 tile = task->tiles[i].tile;
187 if (task->tiles[i].playing) {
188 frame = stepTileAnimation2(&task->tiles[i], updateTileOnceFrames[i], 1, 0);
189 if (frame == 0xFF) {
190 task->tiles[i].playing = 0;
191 tile->visible = 0;
192 } else {
193 tile->visible = 1;
194 if (i == 0) {
195 tile->frame = frame;
196 tile->clutRow = 0;
197 } else {
198 tile->frame = 0x33;
199 tile->clutRow = frame;
200 }
201 }
202 } else {
203 tile->visible = 0;
204 }
205 }
206 if (task->tiles[0].playing == 0 && task->tiles[1].playing == 0) {
207 task->setState(task, TASK_KILL);
208 }
209 break;
210 case TASK_DONE:
211 case TASK_KILL:
212 break;
213 }
214}
215
216/*
217 * Command 839 of the event scripts: the button the player pushes in event
218 * 871 to stop the Juggernaut (updateTileOnce)
219 */
221 return createTaskWithId(updateTileOnce, sizeof(StageTileOnce), 0, arg);
222}
223
225
226/* The timer: counts GAME.countdown down while nothing stops it, then starts event 0x5E2 */
227void updateTimer(StageTask *task, void **children) {
228 u8 *countdown;
229
230 switch (task->state) {
231 case TASK_RUN:
234 break;
235 }
236 drawTimer(task);
237 countdown = GAME.countdown;
238 if (countdown[0] != 0 || countdown[1] != 0 || countdown[2] != 0) {
239 countdown[3] -= GFX.funcs.getFrameTime();
240 if (countdown[3] > 60) {
241 countdown[2]--;
242 countdown[3] += 60;
244 }
245 COUNTDOWN_BORROW(countdown);
246 break;
247 }
248 children[0] = FIELDSTG_startEvent(0x5E2);
249 /* fallthrough */
250 case TASK_INIT:
251 default:
252 task->nextState(task);
253 break;
254 case TASK_DONE:
255 case TASK_KILL:
256 break;
257 }
258}
259
261
262/* Creates the timer, the stage's four effects, the event object of flags 0x4044/0x4045 and one of two objects by flag 0x4061 */
263void updateStage(StageTask *task, void **children) {
264 s32 i;
265
266 switch (task->state) {
267 case TASK_INIT:
268 default:
269 children[0] = createTimer();
270 for (i = 0; i < 4; i++) {
271 if (updateStageSpots[i].kind == 0) {
272 children[i + 1] = createStageEffect(updateStageSpots[i].x, updateStageSpots[i].y, updateStageSpots[i].frame);
273 }
274 }
276 children[7] = FIELDSTG_startEvent(0x367);
277 }
279 children[5] = createTilePair16(0x345);
280 } else {
281 children[5] = createTilePair16Done();
282 }
283 task->nextState(task);
284 break;
285 case TASK_RUN:
286 case TASK_DONE:
287 case TASK_KILL:
288 break;
289 }
290}
291
292#define STAGE_CHILDREN_SIZE 0x20
299
300/* After event 850, with the player: sets flag 0x1C0A and keeps it from playing again */
305
306/*
307 * After event 870, with Mech Soldier: starts the stage's event battle 0 and
308 * keeps it from playing again
309 */
314
315/*
316 * After event 871, with the player: gives the player the Dramon Guard and
317 * keeps it from playing again
318 */
323
324#if VERSION_US || VERSION_JP
325#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
326#define EVENT_TEXT_FILE (TEXT_EVENTS_800 - 1)
327#define STAGE_FILE 0x6EE
328#define STAGE_FILE_8 0x715
329#elif VERSION_EU
330#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
331#define EVENT_TEXT_FILE (TEXT_EVENTS_800 - 1)
332#define STAGE_FILE 0x6FE
333#define STAGE_FILE_8 0x725
334#endif
335/* Sets the stage up: its map, actors, battles and events, playing BGM_0011 */
356
358 SCRIPT_WALK(2, 0x3BC, 0x337, 3),
361 SCRIPT_WAIT(0x1E),
362 SCRIPT_COMMAND(0x323, 0x325, 2),
363 SCRIPT_WAIT(0x5A),
364 SCRIPT_COMMAND(0x323, 0x326, 2),
365 SCRIPT_WAIT(0x1E),
366 SCRIPT_TALK(0, 1, 2, 0),
367 SCRIPT_POSE(2, 1, 3),
369 SCRIPT_WAIT(0x1E),
371 SCRIPT_WAIT(0x1E),
372 SCRIPT_COMMAND(0x345, 0x35B, 2),
373 SCRIPT_WAIT(0x78),
374 SCRIPT_POSE(2, 1, 3),
375 SCRIPT_WAIT(0x1E),
376 SCRIPT_POSE(2, 1, 7),
378 SCRIPT_WAIT(0x1E),
379 SCRIPT_POSE(2, 1, 5),
380 SCRIPT_WAIT(0x1E),
381 SCRIPT_POSE(2, 1, 7),
382 SCRIPT_WAIT(0x1E),
383 SCRIPT_POSE(2, 1, 1),
384 SCRIPT_WAIT(0x1E),
385 SCRIPT_POSE(2, 1, 7),
386 SCRIPT_WAIT(0x1E),
387 SCRIPT_TALK(0, 2, 2, 0),
388 SCRIPT_POSE(2, 7, 7),
390 SCRIPT_WAIT(0x1E),
391 SCRIPT_WALK(2, 0x3E0, 0x348, 7),
393 SCRIPT_POSE(2, 1, 7),
394 SCRIPT_WAIT(0x1E),
396};
398 SCRIPT_WALK(2, 0x590, 0x1B0, 5),
401 SCRIPT_POSE(2, 1, 5),
402 SCRIPT_WAIT(0x1E),
403 SCRIPT_TALK(0, 1, 2, 0),
404 SCRIPT_POSE(2, 7, 5),
406 SCRIPT_POSE(2, 1, 5),
407 SCRIPT_WAIT(0x1E),
408 SCRIPT_COMMAND(0x323, 0x325, 0xD0),
409 SCRIPT_WAIT(0x5A),
410 SCRIPT_COMMAND(0x323, 0x326, 0xD0),
411 SCRIPT_WAIT(0x1E),
412 SCRIPT_POSE(0xD0, 1, 1),
413 SCRIPT_WAIT(0x1E),
414 SCRIPT_TALK(0, 2, 0xD0, 0),
416 SCRIPT_WAIT(0x1E),
417 SCRIPT_WALK(0xD0, 0x5A8, 0x1A4, 1),
418 SCRIPT_WAIT_WALK(0xD0),
420};
422 SCRIPT_PLACE(2, 0x590, 0x1B0),
423 SCRIPT_POSE(2, 1, 5),
424 SCRIPT_PLACE(0x13C, 0x5A8, 0x1A4),
425 SCRIPT_POSE(0x13C, 1, 1),
426 SCRIPT_WAIT(0x78),
427 SCRIPT_TALK(0, 1, 2, 0),
428 SCRIPT_POSE(2, 7, 5),
430 SCRIPT_POSE(2, 1, 5),
431 SCRIPT_WAIT(0x1E),
432 SCRIPT_POSE(2, 1, 5),
433 SCRIPT_WAIT(0x1E),
434 SCRIPT_COMMAND(0x323, 0x325, 2),
435 SCRIPT_WAIT(0x5A),
436 SCRIPT_COMMAND(0x323, 0x326, 2),
437 SCRIPT_WAIT(0x1E),
438 SCRIPT_WALK(2, 0x598, 0x1AC, 5),
440 SCRIPT_WAIT(0x1E),
441 SCRIPT_PLACE(0x13C, 0, 0),
442 SCRIPT_POSE(0x13C, 1, 0),
443 SCRIPT_WAIT(0x1E),
444 SCRIPT_TALK(0, 2, 2, 0),
445 SCRIPT_POSE(2, 7, 5),
447 SCRIPT_POSE(2, 1, 5),
448 SCRIPT_WAIT(0x1E),
449 SCRIPT_COMMAND(0x323, 0x325, 2),
450 SCRIPT_WAIT(0x5A),
451 SCRIPT_COMMAND(0x323, 0x326, 2),
452 SCRIPT_WAIT(0x1E),
453 SCRIPT_TALK(0, 3, 2, 0),
454 SCRIPT_POSE(2, 7, 5),
456 SCRIPT_POSE(2, 1, 5),
457 SCRIPT_WAIT(0x1E),
458 SCRIPT_WALK(2, 0x5F7, 0x17C, 5),
460 SCRIPT_POSE(2, 1, 5),
461 SCRIPT_WAIT(0x1E),
462 SCRIPT_POSE(2, 1, 5),
463 SCRIPT_WAIT(0x1E),
464 SCRIPT_POSE(2, 1, 4),
465 SCRIPT_WAIT(0x1E),
466 SCRIPT_POSE(2, 1, 5),
467 SCRIPT_WAIT(0x1E),
468 SCRIPT_POSE(2, 1, 6),
469 SCRIPT_WAIT(0x3C),
470 SCRIPT_POSE(2, 1, 6),
471 SCRIPT_COMMAND(0x323, 0x325, 2),
472 SCRIPT_WAIT(0x3C),
473 SCRIPT_COMMAND(0x323, 0x326, 2),
474 SCRIPT_WAIT(0x1E),
475 SCRIPT_WALK(2, 0x607, 0x184, 5),
477 SCRIPT_POSE(2, 1, 5),
478 SCRIPT_WAIT(0x1E),
479 SCRIPT_TALK(0, 4, 2, 0),
480 SCRIPT_POSE(2, 7, 5),
482 SCRIPT_POSE(2, 1, 5),
483 SCRIPT_WAIT(0x1E),
484 SCRIPT_POSE(2, 1, 5),
485 SCRIPT_WAIT(0x1E),
486 SCRIPT_POSE(2, 1, 6),
487 SCRIPT_WAIT(0x1E),
488 SCRIPT_POSE(2, 1, 5),
489 SCRIPT_WAIT(0x1E),
490 SCRIPT_POSE(2, 1, 4),
491 SCRIPT_WAIT(0x1E),
492 SCRIPT_POSE(2, 1, 5),
494 SCRIPT_WAIT(0x1E),
495 SCRIPT_POSE(2, 1, 5),
496 SCRIPT_COMMAND(0x347, 0x35B, 2),
497 SCRIPT_WAIT(0xB4),
498 SCRIPT_TALK(0, 5, 2, 0),
499 SCRIPT_POSE(2, 7, 5),
501 SCRIPT_POSE(2, 1, 5),
502 SCRIPT_WAIT(0x1E),
503 SCRIPT_TALK(0, 6, 2, 4),
504 SCRIPT_COMMAND(0x323, 0x325, 2),
507 SCRIPT_POSE(2, 1, 1),
508 SCRIPT_COMMAND(0x323, 0x326, 2),
509 SCRIPT_WAIT(0x1E),
510 SCRIPT_TALK(0, 7, 2, 0),
511 SCRIPT_POSE(2, 7, 1),
513 SCRIPT_POSE(2, 1, 1),
514 SCRIPT_WAIT(0x1E),
515 SCRIPT_POSE(2, 1, 1),
518};
520 SCRIPT_WAIT(0x1E),
521 SCRIPT_COMMAND(0x323, 0x325, 2),
522 SCRIPT_WAIT(0x5A),
523 SCRIPT_COMMAND(0x323, 0x326, 2),
524 SCRIPT_WAIT(0x1E),
525 SCRIPT_POSE(2, 1, 0),
526 SCRIPT_WAIT(0x1E),
527 SCRIPT_TALK(0, 1, 2, 2),
528 SCRIPT_POSE(2, 7, 0),
530 SCRIPT_POSE(2, 1, 0),
531 SCRIPT_WAIT(0x1E),
532 SCRIPT_LEAVE(0x26D, 1, 1, 1),
534};
536 { 0, 8 }, { 1, 8 }, { 255, 0 },
537};
539 { 71, 4 }, { 72, 4 }, { 73, 4 }, { 74, 4 },
540 { 75, 4 }, { 76, 4 }, { 77, 4 }, { 78, 4 },
541 { 79, 4 }, { 80, 4 }, { 255, 0 },
542};
544 { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
545 { 4, 6 }, { 5, 6 }, { 255, 0 },
546};
548 { 52, 6 }, { 53, 6 }, { 54, 6 }, { 55, 6 },
549 { 56, 6 }, { 57, 6 }, { 58, 6 }, { 59, 6 },
550 { 60, 6 }, { 61, 6 }, { 62, 6 }, { 63, 6 },
551 { 64, 6 }, { 65, 6 }, { 66, 6 }, { 67, 6 },
552 { 68, 6 }, { 69, 6 }, { 255, 0 },
553};
555 { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
556 { 4, 6 }, { 5, 6 }, { 0, 6 }, { 1, 6 },
557 { 2, 6 }, { 3, 6 }, { 4, 6 }, { 5, 6 },
558 { 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
559 { 4, 6 }, { 5, 6 }, { 255, 0 },
560};
565 226, 253, 0x118, 0,
566};
568 { 28, 0, 0x4BC, 0x273 },
569 { 28, 0, 0x39C, 0x373 },
570 { 20, 0, 0x2BC, 211 },
571 { 20, 0, 0x43C, 0x323 },
572};
574 { 0, 6 }, { 1, 6 }, { 2, 68 }, { 1, 4 },
575 { 0, 4 }, { 255, 0 },
576};
578 { 0x12C, 18 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
579 { 4, 6 }, { 5, 4 }, { 6, 4 }, { 7, 4 },
580 { 5, 4 }, { 6, 4 }, { 7, 4 }, { 5, 4 },
581 { 6, 4 }, { 7, 4 }, { 5, 4 }, { 6, 4 },
582 { 7, 4 }, { 4, 4 }, { 3, 4 }, { 2, 4 },
583 { 1, 4 }, { 255, 0x3E7 },
584};
598AreaBattle area1Battle0 = { 0, 0, MUSIC(1, 0) };
599AreaBattle area1Battle1 = { 0, 0, MUSIC(1, 0) };
600AreaBattle area1Battle2 = { 0, 0, MUSIC(1, 0) };
601AreaBattle area1Battle3 = { 0, 0, MUSIC(1, 0) };
602AreaBattle area1Battle4 = { 0, 0, MUSIC(1, 0) };
603AreaBattle area1Battle5 = { 0, 0, MUSIC(1, 0) };
604AreaBattle area1Battle6 = { 0, 0, MUSIC(1, 0) };
605AreaBattle area1Battle7 = { 0, 0, MUSIC(1, 0) };
611AreaBattle area2Battle0 = { 0, 0, MUSIC(1, 0) };
612AreaBattle area2Battle1 = { 0, 0, MUSIC(1, 0) };
613AreaBattle area2Battle2 = { 0, 0, MUSIC(1, 0) };
614AreaBattle area2Battle3 = { 0, 0, MUSIC(1, 0) };
615AreaBattle area2Battle4 = { 0, 0, MUSIC(1, 0) };
616AreaBattle area2Battle5 = { 0, 0, MUSIC(1, 0) };
617AreaBattle area2Battle6 = { 0, 0, MUSIC(1, 0) };
618AreaBattle area2Battle7 = { 0, 0, MUSIC(1, 0) };
625AreaBattle area3Battle1 = { 0, 0, MUSIC(1, 0) };
626AreaBattle area3Battle2 = { 0, 0, MUSIC(1, 0) };
627AreaBattle area3Battle3 = { 0, 0, MUSIC(1, 0) };
628AreaBattle area3Battle4 = { 0, 0, MUSIC(1, 0) };
629AreaBattle area3Battle5 = { 0, 0, MUSIC(1, 0) };
630AreaBattle area3Battle6 = { 0, 0, MUSIC(1, 0) };
631AreaBattle area3Battle7 = { 0, 0, MUSIC(1, 0) };
641 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
642 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
643 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
644 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
645 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
646 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
647 { 0x180, 0x100, 0x19C, 0x158, 0x170, 0x58, 0x170, 0x1D9 },
648 { 0x180, 0x100, 0x1A2, 0x158, 0x188, 0x58, 0x170, 0x1D8 },
649 { 0x180, 0x100, 0x1A8, 0x158, 0x1A0, 0x58, 0x170, 0x1D7 },
650 { 0x180, 0x100, 0x18C, 0x170, 0x130, 0x70, 0x170, 0x1D6 },
651 { 0x180, 0x100, 0x192, 0x170, 0x148, 0x70, 0x170, 0x1D5 },
652 { 0x140, 0x100, 0x16E, 0x1A8, 0xB8, 0xA8, 0x170, 0x1D4 },
653 { 0x140, 0x100, 0x17A, 0x1B0, 0xE8, 0xB0, 0x170, 0x1D3 },
654};
661 { NULL, actor0Talk0Actions, 0x21B },
662 { NULL, NULL, 0 },
663};
665 { NULL, actor1Talk0Actions, 0x21C },
666 { NULL, NULL, 0 },
667};
669 { NULL, actor2Talk0Actions, 0x17D },
670 { NULL, NULL, 0 },
671};
673 { NULL, actor3Talk0Actions, 0x191 },
674 { NULL, NULL, 0 },
675};
677 { NULL, actor4Talk0Actions, 0x21F },
678 { NULL, NULL, 0 },
679};
683u16 actor3Conditions[] = { FLAG(2, 0x48), 0, CODES_END };
696FieldActorEntry actor5 = { actor5Conditions, NULL, 0xD0, 9, 1473, 409, 5 };
697FieldActorEntry actor6 = { actor6Conditions, NULL, 0x13C, 0xA, 0, 0, 1 };
699 &actor0,
700 &actor1,
701 &actor2,
702 &actor3,
703 &actor4,
704 &actor5,
705 &actor6,
706 NULL,
707};
709 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 728, 212, 0, 0 },
710 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 760, 197, 0, 0 },
711 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 952, 884, 0, 0 },
712 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 984, 868, 0, 0 },
713 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 1112, 804, 0, 0 },
714 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 1144, 788, 0, 0 },
715 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 1240, 629, 0, 0 },
716 { 1, 0, 0x40, 2, 0x32, 2, 0, 5, 4, 0, 1272, 612, 0, 0 },
717 { 1, 2, 0x64, 6, 0x51, 0, 0, 0, 0, 0, 898, 764, 0, 0 },
718 { 1, 1, 0x64, 6, 0x46, 0, 0, 0, 0, 0, 898, 764, 0, 0 },
719 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 656, 176, 0, 0 },
720 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 688, 160, 0, 0 },
721 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 880, 848, 0, 0 },
722 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 912, 832, 0, 0 },
723 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 1040, 768, 0, 0 },
724 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 1072, 752, 0, 0 },
725 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 1168, 592, 0, 0 },
726 { 1, 0, 0x40, 6, 0x32, 2, 0, 5, 4, 0, 1200, 576, 0, 0 },
727 { 0, 4, 0x64, 6, 0x33, 0, 0, 0, 0, 0, 1550, 338, 0, 0 },
728 { 0, 3, 0x64, 6, 0x34, 0, 0, 0, 0, 0, 1550, 338, 0, 0 },
729 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
730};
732 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x2DA, 0x4F2, 0x150, 3, 0, 0, 0 },
733 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x2DA, 0x522, 0x1F6, 3, 0, 0, 0 },
734 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x2DA, 0x552, 0x28E, 3, 0, 0, 0 },
735 { { { CODES_END, 0 }, { CODES_END, 0 } }, SLOT_EXIT, 0x2DA, 0x554, 0x400, 3, 0, 0, 0 },
736 { { { PROGRESS(STORY_REAL_WORLD), 1 }, { FLAG_MECH_SOLDIER_WIN_SEEN, 0 } }, SLOT_EVENT, 0x366, 0, 0, 0, 0, 0, 0 },
737 { { { FLAG(0x1C, 5), 1 }, { FLAG_MECH_SOLDIER_ALERT_SEEN, 0 } }, SLOT_EVENT, 0x352, 0, 0, 0, 0, 0, 0 },
738 { { { FLAG(0x1C, 5), 1 }, { CODES_END, 0 } }, SLOT_LAUNCH, 0x2DB, 0x450, 0x330, 1, 0, 0, 0 },
739 { { { FLAG(0x1C, 5), 1 }, { CODES_END, 0 } }, SLOT_LAUNCH, 0x2DB, 0x2D0, 0xE0, 5, 0, 0, 0 },
740 { { { CODES_END, 0 }, { CODES_END, 0 } }, 0, 0, 0, 0, 0, 0, 0, 0 },
741};
742void (*stageFuncs[])(void) = {
744};
746 { 850, script850, EVENT_TEXT(0), NULL, endEvent850 },
747 { 870, script870, EVENT_TEXT(1), NULL, endEvent870 },
748 { 871, script871, EVENT_TEXT(2), NULL, endEvent871 },
749 { 1506, script1506, EVENT_TEXT(0x12), NULL, NULL },
750 { -1, NULL, 0, NULL, NULL },
751};
#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
unsigned char u8
Definition common.h:8
StageEffect * createStageEffect(s32 x, s32 y, s32 frame)
Creates a StageEffect at (x, y) with its sprites' frames from FRAME.
void * createTimer(void)
Creates the updateTimer task.
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
void drawTimer(StageTask *task)
Draws the timer: its frame and the three digits of GAME.countdown, from the sprites of the stage's TI...
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
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
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define COUNTDOWN_BORROW(c)
Carries the borrow down the digits of GAME.countdown, the timer of the timed stages: a units digit th...
Definition stage.h:36
#define SCRIPT_WAIT_WALK(id)
until the character gets to its goal
Definition field_map.h:168
#define FIELD_COMMAND_HALT_PARTNERS
The field commands, which an event script hands FIELD_TASK_COMMANDS as the first argument of a pose c...
Definition field_map.h:41
#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 SLOT_LAUNCH
sends the player flying (FIELDSTG_launchActor)
Definition field_map.h:267
#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 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 SLOT_EVENT
starts the event arg
Definition field_map.h:262
#define SCRIPT_WALK(id, x, y, dir)
Actor.setGoal: walks to (x, y), then faces dir.
Definition field_map.h:162
#define FIELD_COMMAND_PLAY_SWITCH03
Definition field_map.h:67
#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 FIELD_MAP_AREAS
a cell's value: its battle area (FieldBattles), or 0
Definition field_map.h:87
#define FIELD_COMMAND_PLAY_GONDRA_S
Definition field_map.h:72
#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 FIELD_COMMAND_PLAY_COMCD103
Definition field_map.h:74
#define FIELD_TASK_COMMANDS
script command 813 (FIELDSTG_startCommandTask): the field commands
Definition field_map.h:33
#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 EVENT_BATTLE(id)
action: FIELDSTG_battleFuncs.startEventBattle
Definition game_state.h:72
#define CODES_END
Definition game_state.h:83
#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...
Definition game_state.h:80
#define PROGRESS(n)
GAME.progress is n.
Definition game_state.h:69
#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
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 SOUND_COUNT
SYSTEM10: a number counts up or down.
Definition sound.h:45
#define MUSIC_BATTLE
BATL0000: the maps' random battles (AreaBattle, nearly all of them)
Definition sound.h:76
#define MUSIC_MAGASTA
BGM_0011: the Undersea Base (Magasta), and the Deeper Crevice's gondola.
Definition sound.h:87
#define MUSIC(bank, n)
A field's or a battle's music (FieldState.music, Battle.music): track (SEP) n of the first sequence o...
Definition sound.h:70
#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 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 FLAG_MAGASTA_B2F_BERET_FOUND
wstag800: chest that gives the Beret, "I got" text; its conditions test it 0
Definition story.h:372
@ STORY_REAL_WORLD
WSTAG750 (the emergency Matrix Chamber), event 820: back in the real world, for 180 seconds.
Definition story.h:121
#define FLAG_MAGASTA_B2F_ROYAL_CROWN_FOUND
wstag800: chest that gives the Royal Crown, "I got" text; its conditions test it 0
Definition story.h:375
#define FLAG_MECH_SOLDIER_ALERT_SEEN
wstag800 event 850: a Mech Soldier sounds the intruder alert at the Juggernaut launch; set at its end...
Definition story.h:1496
#define FLAG_MAGASTA_B2F_SUPER_CHARGE_FOUND
wstag800: chest that gives the Super Charge, "I got" text; its conditions test it 0
Definition story.h:378
#define FLAG_ROYAL_GUARD_CHALLENGE_SEEN
wstag800 event 871: the player tells the Royal Guard to stop the launch; set at its end,...
Definition story.h:1436
#define FLAG_MAGASTA_BUTTON_PRESSED
wstag795 event 830: the player pushes a button on a control panel in Magasta B1F; set at its end,...
Definition story.h:1430
#define FLAG_MECH_SOLDIER_WIN_SEEN
wstag800 event 870: the player wins and finds the Dramon Guard in Magasta B2F; set at its end,...
Definition story.h:1433
#define FLAG_MAGASTA_B2F_MISTY_ARMOR_FOUND
wstag800: chest that gives the Misty Armor, "I got" text; its conditions test it 0
Definition story.h:381
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
s16 frame
Definition gfx.h:297
s16 duration
Definition gfx.h:298
s16 index
Definition gfx.h:302
s16 timer
Definition gfx.h:303
A battle of an area's BattleList, which can start on the field (see FIELDSTG_startEncounter); FIGHTST...
Definition field_map.h:402
The battles of an area of the map (its cells' value at FieldMap.files[4]), one picked at random.
Definition field_map.h:411
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
Definition field_map.h:194
The battles of a place (FieldState.battles), by area of the map: the fourth area's are also the ones ...
Definition field_map.h:422
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 frozen
no control, triggers or encounters for the player: while the area name banner shows (FIELDSTG_createB...
Definition field_map.h:466
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
Definition field_map.h:445
s32 busy
an event, a warp, a launch or a battle has the player
Definition field_map.h:468
s32 battleStarting
an encounter started (FIELDSTG_startEncounter)
Definition field_map.h:469
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
s32 menuOpen
the field menu (START) or the inn (FIELDSTG_openInn) is open: the pad doesn't move the player
Definition field_map.h:464
FieldBattles * battles
Definition field_map.h:450
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 acting
the player talks, climbs, slides or searches
Definition field_map.h:470
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
u8 countdown[4]
Definition game_state.h:572
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
A sprite effect a stage creates at (x, y) with the given frame, by kind.
Definition stage.h:290
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
A map object animated while playing is set.
Definition stage.h:423
StageTile * tile
Definition stage.h:424
AnimState anim
Definition stage.h:426
StageTile * tile
Definition stage.h:109
AnimState anim
Definition stage.h:110
The map objects with animations 3 and 4, each animated once.
Definition stage.h:530
void(* nextState)(struct StageTileOnce *task)
Definition stage.h:531
StageTileAnimFlag tiles[2]
Definition stage.h:533
void(* setState)(struct StageTileOnce *task, s32 state)
Definition stage.h:531
StageTilePair with halfword flags.
Definition stage.h:198
StageTileAnim anims[2]
Definition stage.h:202
void(* nextState)(struct StageTilePair16 *task)
Definition stage.h:199
void(* setState)(struct StageTilePair16 *task, s32 state)
Definition stage.h:199
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 * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
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 wstag800.c:681
u16 actor0Talk0Actions[]
Definition wstag800.c:655
AreaBattle area2Battle7
Definition wstag800.c:618
FieldActorEntry actor0
Definition wstag800.c:691
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag800.c:742
FieldActorEntry actor6
Definition wstag800.c:697
FieldTalk actor2Talks[]
Definition wstag800.c:668
AreaBattle area2Battle6
Definition wstag800.c:617
s16 script870[]
Definition wstag800.c:397
AnimFrame effectClutFrames[]
Definition wstag800.c:573
s32 stepTileAnimation2(StageTileAnimFlag *obj, AnimFrame *frames, s32 once, s32 depth)
stepTileAnimation for a StageTileAnimFlag
Definition wstag800.c:128
AnimFrame updateTilePair16Frames2[]
Definition wstag800.c:538
AreaBattle area1Battle6
Definition wstag800.c:604
AnimFrame * updateTileOnceFrames[]
Definition wstag800.c:561
FieldActorEntry actor5
Definition wstag800.c:696
AreaBattle area0Battle7
Definition wstag800.c:592
FieldActorEntry actor2
Definition wstag800.c:693
AnimFrame updateTilePair16Frames1[]
Definition wstag800.c:543
#define STAGE_FILE_8
Definition wstag800.c:333
AreaBattle area3Battle4
Definition wstag800.c:628
AreaBattle area3Battle3
Definition wstag800.c:627
AreaBattle area0Battle1
Definition wstag800.c:586
AreaBattle area2Battle0
Definition wstag800.c:611
void * createTilePair16Done(void)
Creates the tile pair object, started in TASK_DONE.
Definition wstag800.c:120
void updateTileOnce(StageTileOnce *task)
Plays the map objects with animations 3 and 4 once, then ends.
Definition wstag800.c:157
FieldActorEntry * stageActors[]
Definition wstag800.c:698
AreaBattle area1Battle2
Definition wstag800.c:600
AnimFrame updateTileOnceFrames_0[]
Definition wstag800.c:547
s16 script871[]
Definition wstag800.c:421
AreaBattle area3Battle0
Definition wstag800.c:624
AreaBattle area0Battle6
Definition wstag800.c:591
void endEvent871(void)
After event 871, with the player: gives the player the Dramon Guard and keeps it from playing again.
Definition wstag800.c:319
FieldTalk actor1Talks[]
Definition wstag800.c:664
AreaBattle area3Battle2
Definition wstag800.c:626
FieldTalk actor0Talks[]
Definition wstag800.c:660
AreaBattle area3Battle1
Definition wstag800.c:625
AreaBattle area0Battle3
Definition wstag800.c:588
u16 actor2Talk0Actions[]
Definition wstag800.c:657
FieldTalk actor4Talks[]
Definition wstag800.c:676
u16 actor4Conditions[]
Definition wstag800.c:684
FieldActorEntry actor4
Definition wstag800.c:695
u16 actor3Conditions[]
Definition wstag800.c:683
AreaBattle area3Battle6
Definition wstag800.c:630
AnimFrame updateTilePair16Frames0[]
Defined below, after the code that uses them.
Definition wstag800.c:535
ActorImage stageImages[]
Definition wstag800.c:640
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing BGM_0011.
Definition wstag800.c:336
AnimFrame effectFrames[]
Definition wstag800.c:577
AreaBattle area2Battle4
Definition wstag800.c:615
StageEffectSpot updateStageSpots[]
Definition wstag800.c:567
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag800.c:708
s16 timerDigitX[]
Definition wstag800.c:564
u16 actor5Conditions[]
Definition wstag800.c:685
FieldTalk actor3Talks[]
Definition wstag800.c:672
BattleList area3Battles
Definition wstag800.c:632
AreaBattle area3Battle5
Definition wstag800.c:629
AreaBattle area0Battle5
Definition wstag800.c:590
BattleList area1Battles
Definition wstag800.c:606
void updateTimer(StageTask *task, void **children)
The timer: counts GAME.countdown down while nothing stops it, then starts event 0x5E2.
Definition wstag800.c:227
void endEvent870(void)
After event 870, with Mech Soldier: starts the stage's event battle 0 and keeps it from playing again...
Definition wstag800.c:310
BattleList area2Battles
Definition wstag800.c:619
s16 script850[]
Definition wstag800.c:357
AreaBattle area1Battle4
Definition wstag800.c:602
u16 actor6Conditions[]
Definition wstag800.c:690
AreaBattle area2Battle2
Definition wstag800.c:613
AreaBattle area1Battle5
Definition wstag800.c:603
StageSlot stageSlots[]
Definition wstag800.c:731
AreaBattle area2Battle1
Definition wstag800.c:612
u16 actor1Talk0Actions[]
Definition wstag800.c:656
AreaBattle area1Battle3
Definition wstag800.c:601
s16 script1506[]
Definition wstag800.c:519
void endEvent850(void)
After event 850, with the player: sets flag 0x1C0A and keeps it from playing again.
Definition wstag800.c:301
AreaBattle area1Battle0
Definition wstag800.c:598
FieldActorEntry actor1
Definition wstag800.c:692
AnimFrame updateTileOnceFrames_1[]
Definition wstag800.c:554
AreaBattle area0Battle0
Definition wstag800.c:585
AreaBattle area0Battle2
Definition wstag800.c:587
#define STAGE_FILE
Definition wstag800.c:332
AreaBattle area2Battle5
Definition wstag800.c:616
u16 actor4Talk0Actions[]
Definition wstag800.c:659
AreaBattle area1Battle1
Definition wstag800.c:599
AreaBattle area2Battle3
Definition wstag800.c:614
u16 actor2Conditions[]
Definition wstag800.c:682
AreaBattle area0Battle4
Definition wstag800.c:589
#define STAGE_TEXT
Definition wstag800.c:330
void updateTilePair16(StageTilePair16 *task)
Shows the first map object animated while running; when done, both.
Definition wstag800.c:27
u16 actor3Talk0Actions[]
Definition wstag800.c:658
AreaBattle area3Battle7
Definition wstag800.c:631
BattleList area0Battles
Definition wstag800.c:593
void handleCommand837(StageTilePair16 *task, s32 id)
Plays the first map object's one-shot animation when the event of map object 0x35B happens.
Definition wstag800.c:105
void * createTilePair16(s32 arg)
Creates the button's map objects of event 850 (updateTilePair16) with an id.
Definition wstag800.c:115
AreaBattle area1Battle7
Definition wstag800.c:605
void * createCommand839(s32 arg)
Command 839 of the event scripts: the button the player pushes in event 871 to stop the Juggernaut (u...
Definition wstag800.c:220
FieldActorEntry actor3
Definition wstag800.c:694
FieldBattles stageBattles[]
Definition wstag800.c:637
FieldEvent stageEvents[]
Definition wstag800.c:745
u16 actor0Conditions[]
Definition wstag800.c:680