Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag805.c
Go to the documentation of this file.
1/*
2 * WSTAG805: Magasta 1F, Undersea Base. Where the Juggernaut launches.
3 */
4
5#include "common.h"
6#include "field/stage.h"
7/* Defined below, after the code that uses them */
10extern s16 floaterChainTimes[];
20
21/* Creates the 27 floaters; in TASK_DONE sets them moving one after the other */
23 s32 i;
24
25 switch (task->state) {
26 case TASK_INIT:
27 default:
28 task->nextState(task);
29 for (i = 0; i < 27; i++) {
31 }
32 break;
33 case TASK_RUN:
34 break;
35 case TASK_DONE:
36 if (task->timer >= floaterChainTimes[task->next] && task->timer < floaterChainTimes[task->next + 1]) {
37 children->floaters[task->next]->setState(children->floaters[task->next], TASK_DONE);
38 task->next++;
39 if (floaterChainTimes[task->next] == 0x1000) {
40 task->setState(task, TASK_RUN);
41 }
42 }
43 task->timer += GFX.funcs.getFrameTime();
44 break;
45 case TASK_KILL:
46 break;
47 }
48}
49
50/* Starts the chain when the event of map object 0x335 happens */
52 if (task != NULL && id == 0x335) {
53 task->next = 0;
54 task->timer = 0;
55 task->setState(task, TASK_DONE);
56 }
57}
58
59/* Creates the chain of floaters */
63
64/* Advances a looping animation, returns its frame */
66 StageTileLoopFrame *frame = &frames[obj->anim.index];
68 s32 loop;
69
70 if (dt > 4) {
71 dt = 4;
72 }
73 if (depth == 0) {
74 obj->anim.timer -= dt;
75 }
76 if (obj->anim.timer <= 0) {
77 frame++;
78 obj->anim.index++;
79 obj->anim.timer += frame->duration;
80 if (frame->frame == 0xFF) {
81 loop = frame->loop;
82 frame = &frames[loop];
83 obj->anim.index = loop;
84 obj->anim.timer += frame->duration;
85 }
86 stepTileLoop(obj, frames, depth + 1);
87 }
88 return frame->frame;
89}
90
91/* Animates the map objects with animations 1 to 4: 2 and 3 hidden while running */
93 StageTile *object;
94 StageTile *tile;
95 s32 i;
96 s32 frame;
97
98 switch (task->state) {
99 case TASK_INIT:
100 default:
101 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
102 switch (object->anim) {
103 case 1:
104 task->anims[0].anim.index = 0;
106 task->anims[0].tile = object;
107 break;
108 case 2:
109 task->anims[1].anim.index = 0;
111 task->anims[1].tile = object;
112 break;
113 case 3:
114 task->anims[2].anim.index = 0;
116 task->anims[2].tile = object;
117 break;
118 case 4:
119 task->anims[3].anim.index = 0;
121 task->anims[3].tile = object;
122 break;
123 }
124 }
125 task->nextState(task);
126 break;
127 case TASK_RUN:
128 for (i = 0; i < 4; i++) {
129 tile = task->anims[i].tile;
130 switch (i) {
131 case 0:
132 tile->visible = 1;
133 tile->frame = 0x24;
134 tile->clutRow = 0;
135 break;
136 case 1:
137 tile->visible = 0;
138 break;
139 case 2:
140 tile->visible = 0;
141 break;
142 case 3:
143 tile->visible = 1;
144 tile->frame = 0x13;
145 tile->clutRow = stepTileLoop(&task->anims[3], updateTileQuadFrames_3, 0);
146 break;
147 }
148 }
149 break;
150 case TASK_DONE:
151 for (i = 0; i < 4; i++) {
152 tile = task->anims[i].tile;
153 switch (i) {
154 case 0:
155 tile->visible = 1;
156 tile->frame = stepTileLoop(&task->anims[0], updateTileQuadFrames_0, 0);
157 tile->clutRow = 0;
158 break;
159 case 1:
160 tile->visible = 1;
161 tile->frame = 0x15;
162 tile->clutRow = stepTileLoop(&task->anims[1], updateTileQuadFrames_1, 0);
163 break;
164 case 2:
165 tile->visible = 1;
166 tile->frame = 0x16;
167 frame = stepTileLoop(&task->anims[2], updateTileQuadFrames_2, 0);
168 if (frame == 0x12C) {
169 tile->clutRow = 0;
170 } else {
171 tile->clutRow = frame;
172 }
173 break;
174 case 3:
175 tile->visible = 0;
176 break;
177 }
178 }
179 break;
180 case TASK_KILL:
181 break;
182 }
183}
184
185/* Plays a sound and starts the map objects' TASK_DONE animations when the event of map object 0x35B happens */
187 if (task != NULL && id == 0x35B) {
189 task->setState(task, TASK_DONE);
190 }
191}
192
193/*
194 * Creates the map objects of event 881, where the Juggernaut launches
195 * (updateTileQuad), with an id
196 */
197void *createTileQuad(s32 arg) {
198 return createTaskWithId(updateTileQuad, sizeof(StageTileQuad), 0, arg);
199}
200
201/* Advances a part's animation (adding up its deltas when once), returns its frame */
203 StageFloaterFrame *frame = &frames[obj->anim.index];
204 s32 dt = GFX.funcs.getFrameTime();
205
206 if (dt > 4) {
207 dt = 4;
208 }
209 if (depth == 0) {
210 obj->anim.timer -= dt;
211 }
212 if (once) {
213 obj->value += frame->delta;
214 }
215 if (obj->anim.timer <= 0) {
216 frame++;
217 obj->anim.index++;
218 obj->anim.timer += frame->duration;
219 if (once) {
220 if (frame->frame == 0xFF) {
221 obj->anim.index--;
222 frame--;
223 obj->anim.timer += frame->duration;
224 }
225 } else if (frame->frame == 0xFF) {
226 frame = frames;
227 obj->anim.index = 0;
228 obj->anim.timer += frame->duration;
229 }
230 stepFloaterPart(obj, frames, once, depth + 1);
231 }
232 return frame->frame;
233}
234
236
237/* Draws a part of a floater */
238void drawFloaterPart(StageFloater *task, Layer *layer, s32 idx) {
239 SpriteDrawer drawer;
240 StageFloaterPart *part = &task->parts[idx];
241
242 initSpriteDrawer(&drawer);
243 drawer.setTexture(0x140, 0x100);
244 drawer.setLayer(layer, 10);
245 drawer.setClutRow(part->sprite.clutRow);
246 drawer.draw(FILE_CACHE.getEntry(FIELDSTG_state.sheetEntry), part->sprite.frame, task->x, task->y);
247}
248
249/* A floater: animated in place while running, moving up or down with a sound in TASK_DONE */
252 s32 y8;
253 s32 value;
254
255 switch (task->state) {
256 case TASK_INIT:
257 default:
258 task->nextState(task);
259 break;
260 case TASK_RUN:
261 if (task->substate == 0) {
262 task->parts[0].anim.index = 0;
264 task->parts[1].anim.index = 0;
266 task->parts[2].anim.index = 0;
268 task->setSubstate(task, 1);
269 }
270 task->parts[0].sprite.frame = stepFloaterPart(&task->parts[0], updateFloaterFrames0, 0, 0);
271 task->parts[0].sprite.clutRow = stepFloaterPart(&task->parts[2], updateFloaterFrames2, 0, 0);
272 task->parts[1].sprite.frame = 0x28;
273 task->parts[1].sprite.clutRow = stepFloaterPart(&task->parts[1], updateFloaterFrames1, 0, 0);
274 if (task->parts[0].sprite.frame != 0 && isOnScreen(task->x, task->y, 0x20, 0x64)) {
275 drawFloaterPart(task, layer, 0);
276 }
277 if (task->parts[1].sprite.frame != 0 && isOnScreen(task->x, task->y, 0x20, 0x64)) {
278 drawFloaterPart(task, layer, 1);
279 }
280 break;
281 case TASK_DONE:
282 if (task->substate == 0) {
283 task->parts[0].anim.index = 0;
285 task->y8 = task->y << 8;
286 task->setSubstate(task, 1);
288 }
289 task->parts[0].sprite.frame = stepFloaterPart(&task->parts[0], updateFloaterFrames3, 1, 0);
290 task->parts[0].sprite.clutRow = 0;
291 if (task->y >= -100 && task->y <= 1000) {
292 value = task->parts[0].value;
293 y8 = task->y8;
294 task->y8 = task->up ? y8 - value : y8 + value;
295 task->y = task->y8 >> 8;
296 }
297 if (task->parts[0].sprite.frame != 0 && isOnScreen(task->x, task->y, 0x20, 0x64)) {
298 drawFloaterPart(task, layer, 0);
299 }
300 break;
301 case TASK_KILL:
302 break;
303 }
304}
305
306/* Creates a floater at (x, y) */
309
310 task->x = x;
311 task->y = y;
312 task->up = up;
313 return task;
314}
315
316/* Creates two objects and the event object of flags 0x4046/0x4048 that applies */
317void updateStage(StageTask *task, void **children) {
318 switch (task->state) {
319 case TASK_INIT:
320 default:
321 task->nextState(task);
322 children[0] = createFloaterChain(0x349);
323 children[1] = createTileQuad(0x348);
324 do {
326 children[2] = FIELDSTG_startEvent(0x370);
327 break;
328 }
330 FLAGS_00.checkCondition(FLAG(0x40, 0x64), 0)) {
331 children[2] = FIELDSTG_startEvent(0x371);
332 break;
333 }
335 FLAGS_00.checkCondition(FLAG(0x40, 0x65), 0)) {
336 children[2] = FIELDSTG_startEvent(0x372);
337 break;
338 }
339 } while (0);
340 break;
341 case TASK_RUN:
342 case TASK_DONE:
343 case TASK_KILL:
344 break;
345 }
346}
347
348#define STAGE_CHILDREN_SIZE 0xC
350
351/*
352 * After event 880, with Royal Guard: starts the stage's event battle 0 and
353 * keeps it from playing again
354 */
359
360/* After event 881, with the player: gives the player the Wing Helmet */
361void endEvent881(void) {
362 FLAGS_00.applyAction(ITEM(5, 0xF0), 1);
363}
364
365/* After event 882, with Royal Guard: keeps it from playing again */
366void endEvent882(void) {
367 FLAGS_00.applyAction(FLAG(0x40, 0x65), 1);
368}
369
370const CVECTOR stageColor = { 0x80, 0x80, 0x80, 0x00 };
371#if VERSION_US || VERSION_JP
372#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
373#define EVENT_TEXT_FILE (TEXT_EVENTS_800 - 1)
374#define STAGE_FILE 0x662
375#elif VERSION_EU
376#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_07)
377#define EVENT_TEXT_FILE (TEXT_EVENTS_800 - 1)
378#define STAGE_FILE 0x672
379#endif
380/* Sets the stage up: its map, actors, battles and events, playing BGM_0011 */
399
401 SCRIPT_PLACE(1, 0x2B4, 0x198),
402 SCRIPT_POSE(1, 1, 3),
403 SCRIPT_PLACE(0xD2, 0x168, 0xC5),
404 SCRIPT_POSE(0xD2, 1, 3),
405 SCRIPT_WAIT(0x1E),
406 SCRIPT_WALK(1, 0x288, 0x182, 3),
408 SCRIPT_WALK(1, 0x248, 0x136, 3),
410 SCRIPT_WALK(1, 0x1D8, 0xFE, 3),
412 SCRIPT_TALK(0, 5, 0xD2, 3),
413 SCRIPT_POSE(1, 1, 3),
415 SCRIPT_POSE(1, 0xC, 3),
416 SCRIPT_COMMAND(0x323, 0x325, 1),
417 SCRIPT_WAIT(0x3C),
418 SCRIPT_POSE(1, 1, 3),
419 SCRIPT_COMMAND(0x323, 0x326, 1),
420 SCRIPT_WAIT(0x1E),
421 SCRIPT_WALK(1, 0x188, 0xD6, 3),
423 SCRIPT_POSE(1, 1, 3),
424 SCRIPT_WAIT(0x1E),
425 SCRIPT_TALK(0, 1, 1, 3),
426 SCRIPT_POSE(1, 0xC, 3),
428 SCRIPT_COMMAND(0x323, 0x325, 0xD2),
429 SCRIPT_WAIT(0x3C),
430 SCRIPT_POSE(1, 1, 3),
431 SCRIPT_POSE(0xD2, 1, 7),
432 SCRIPT_COMMAND(0x323, 0x326, 0xD2),
433 SCRIPT_WAIT(0x1E),
434 SCRIPT_TALK(0, 2, 0xD2, 2),
436 SCRIPT_WAIT(0x1E),
437 SCRIPT_TALK(0, 3, 1, 3),
439 SCRIPT_WAIT(0x1E),
440 SCRIPT_TALK(0, 4, 0xD2, 2),
442 SCRIPT_WAIT(0x1E),
444};
446 SCRIPT_PLACE(1, 0x188, 0xD6),
447 SCRIPT_POSE(1, 1, 3),
448 SCRIPT_PLACE(0x13C, 0x173, 0xCA),
449 SCRIPT_POSE(0x13C, 1, 1),
450 SCRIPT_WAIT(0x78),
451 SCRIPT_TALK(0, 1, 1, 2),
452 SCRIPT_POSE(1, 7, 3),
454 SCRIPT_POSE(1, 1, 3),
455 SCRIPT_WAIT(0x1E),
456 SCRIPT_WALK(1, 0x17A, 0xCF, 3),
458 SCRIPT_WAIT(0x1E),
459 SCRIPT_PLACE(0x13C, 0, 0),
460 SCRIPT_POSE(0x13C, 1, 1),
461 SCRIPT_WAIT(0x1E),
462 SCRIPT_TALK(0, 7, 1, 2),
463 SCRIPT_POSE(1, 7, 3),
465 SCRIPT_POSE(1, 1, 3),
466 SCRIPT_WAIT(0x3C),
467 SCRIPT_COMMAND(0x348, 0x35B, 1),
468 SCRIPT_WAIT(0x3C),
469 SCRIPT_TALK(0, 3, 1, 4),
471 SCRIPT_COMMAND(0x323, 0x325, 1),
473 SCRIPT_WAIT(0x3C),
474 SCRIPT_COMMAND(0x323, 0x326, 1),
475 SCRIPT_WAIT(0x1E),
476 SCRIPT_TALK(0, 4, 1, 2),
478 SCRIPT_WALK(1, 0x160, 0xC2, 3),
480 SCRIPT_POSE(1, 1, 3),
481 SCRIPT_WAIT(0x1E),
482 SCRIPT_POSE(1, 1, 3),
483 SCRIPT_COMMAND(0x323, 0x327, 1),
484 SCRIPT_WAIT(0x3C),
485 SCRIPT_COMMAND(0x323, 0x326, 1),
486 SCRIPT_WAIT(0x1E),
487 SCRIPT_TALK(0, 6, 1, 3),
489 SCRIPT_WAIT(0x78),
490 SCRIPT_COMMAND(0x323, 0x325, 1),
491 SCRIPT_WAIT(0x3C),
492 SCRIPT_COMMAND(0x323, 0x326, 1),
493 SCRIPT_WAIT(0x1E),
494 SCRIPT_TALK(0, 2, 1, 3),
496 SCRIPT_WAIT(0x1E),
497 SCRIPT_LOOK_AT(0, 0xE0, 0xB2),
498 SCRIPT_COMMAND(0x349, 0x335, 1),
499 SCRIPT_WAIT(0x12C),
500 SCRIPT_FOLLOW(0, 1),
501 SCRIPT_WAIT(0x1E),
502 SCRIPT_TALK(0, 5, 1, 3),
505 SCRIPT_WAIT(0x96),
507#if VERSION_US
508 SCRIPT_LEAVE(0xE03, 1, 1, 1),
509#elif VERSION_EU || VERSION_JP
510 SCRIPT_LEAVE(0xE04, 1, 1, 1),
511#endif
513};
515 SCRIPT_FOLLOW(1, 0xD2),
516 SCRIPT_PLACE(2, 0, 0),
517 SCRIPT_POSE(2, 1, 0),
518 SCRIPT_PLACE(0xD2, 0x168, 0xC5),
519 SCRIPT_POSE(0xD2, 1, 3),
520 SCRIPT_WAIT(0x1E),
521 SCRIPT_WAIT(0xB4),
522 SCRIPT_TALK(0, 4, 0xD2, 3),
524 SCRIPT_WAIT(0x1E),
525 SCRIPT_COMMAND(0x348, 0x35B, 2),
526 SCRIPT_WAIT(0x3C),
527 SCRIPT_TALK(0, 1, 0xD2, 4),
530 SCRIPT_WAIT(0x96),
531 SCRIPT_LOOK_AT(0, 0xE0, 0xB2),
532 SCRIPT_COMMAND(0x349, 0x335, 2),
533 SCRIPT_WAIT(0x12C),
534 SCRIPT_FOLLOW(0, 0xD2),
535 SCRIPT_WAIT(0x1E),
536 SCRIPT_TALK(0, 2, 0xD2, 3),
538 SCRIPT_WAIT(0x5A),
539 SCRIPT_TALK(0, 3, 0xD2, 3),
542 SCRIPT_WAIT(0x96),
544#if VERSION_US
545 SCRIPT_LEAVE(0xE03, 0x15E, 0xCA, 1),
546#elif VERSION_EU || VERSION_JP
547 SCRIPT_LEAVE(0xE04, 0x15E, 0xCA, 1),
548#endif
550};
552 { 8, 140, 0 },
553 { 28, 0x12C, 1 },
554 { 48, 120, 0 },
555 { 68, 0x118, 1 },
556 { 88, 100, 0 },
557 { 108, 0x104, 1 },
558 { 128, 80, 0 },
559 { 148, 240, 1 },
560 { 168, 60, 0 },
561 { 188, 220, 1 },
562 { 208, 40, 1 },
563 { 228, 200, 0 },
564 { 248, 20, 1 },
565 { 0x120, 0, 1 },
566 { 0x148, -0x14, 1 },
567 { 0x15C, 140, 1 },
568 { 0x170, -0x28, 0 },
569 { 0x184, 120, 1 },
570 { 0x198, -0x3C, 0 },
571 { 0x1AC, 100, 1 },
572 { 0x1C0, -0x50, 0 },
573 { 0x1D4, 80, 1 },
574 { 0x1FC, 60, 1 },
575 { 0x224, 40, 1 },
576 { 0x24C, 20, 1 },
577 { 0x274, 0, 1 },
578 { 0x29C, -0x14, 1 },
579};
581 0, 4, 12, 16, 24, 28, 36, 40,
582 48, 52, 60, 64, 72, 84, 96, 100,
583 108, 112, 120, 124, 132, 136, 148, 160,
584 172, 184, 196, 0x1000,
585};
587 { 23, 4, 0 },
588 { 24, 4, 0 },
589 { 25, 4, 0 },
590 { 26, 4, 0 },
591 { 27, 4, 0 },
592 { 28, 4, 0 },
593 { 29, 4, 0 },
594 { 30, 4, 0 },
595 { 31, 4, 0 },
596 { 32, 4, 0 },
597 { 33, 4, 0 },
598 { 34, 8, 0 },
599 { 35, 8, 0 },
600 { 255, 0, 11 },
601};
603 { 0, 8, 0 },
604 { 1, 8, 0 },
605 { 2, 8, 0 },
606 { 3, 8, 0 },
607 { 4, 8, 0 },
608 { 5, 8, 0 },
609 { 255, 0, 0 },
610};
612 { 0, 8, 0 },
613 { 1, 8, 0 },
614 { 2, 8, 0 },
615 { 3, 6, 0 },
616 { 4, 6, 0 },
617 { 5, 6, 0 },
618 { 255, 0, 0 },
619};
621 { 0x12C, 4, 0 },
622 { 0, 8, 0 },
623 { 1, 8, 0 },
624 { 2, 8, 0 },
625 { 3, 6, 0 },
626 { 4, 6, 0 },
627 { 5, 6, 0 },
628 { 255, 0, 1 },
629};
637 { 42, 4, 0 },
638 { 42, 4, 0 },
639 { 43, 4, 0 },
640 { 43, 4, 0 },
641 { 44, 4, 0 },
642 { 44, 4, 0 },
643 { 45, 4, 0 },
644 { 45, 4, 0 },
645 { 255, 0, 0 },
646};
648 { 0, 4, 0 },
649 { 1, 4, 0 },
650 { 0, 4, 0 },
651 { 1, 4, 0 },
652 { 0, 4, 0 },
653 { 1, 4, 0 },
654 { 0, 4, 0 },
655 { 1, 4, 0 },
656 { 255, 0, 0 },
657};
659 { 11, 4, 0 },
660 { 12, 4, 0 },
661 { 13, 4, 0 },
662 { 14, 4, 0 },
663 { 15, 4, 0 },
664 { 16, 4, 0 },
665 { 17, 4, 0 },
666 { 17, 4, 0 },
667 { 18, 30, 64 },
668 { 18, 30, 0 },
669 { 255, 0x3E7, 0 },
670};
672 { 0, 8, 0 },
673 { 1, 8, 0 },
674 { 2, 8, 0 },
675 { 3, 8, 0 },
676 { 4, 8, 0 },
677 { 5, 8, 0 },
678 { 255, 0, 0 },
679};
680AreaBattle area0Battle0 = { 0, 0, MUSIC(1, 0) };
681AreaBattle area0Battle1 = { 0, 0, MUSIC(1, 0) };
682AreaBattle area0Battle2 = { 0, 0, MUSIC(1, 0) };
683AreaBattle area0Battle3 = { 0, 0, MUSIC(1, 0) };
684AreaBattle area0Battle4 = { 0, 0, MUSIC(1, 0) };
685AreaBattle area0Battle5 = { 0, 0, MUSIC(1, 0) };
686AreaBattle area0Battle6 = { 0, 0, MUSIC(1, 0) };
687AreaBattle area0Battle7 = { 0, 0, MUSIC(1, 0) };
693AreaBattle area1Battle0 = { 0, 0, MUSIC(1, 0) };
694AreaBattle area1Battle1 = { 0, 0, MUSIC(1, 0) };
695AreaBattle area1Battle2 = { 0, 0, MUSIC(1, 0) };
696AreaBattle area1Battle3 = { 0, 0, MUSIC(1, 0) };
697AreaBattle area1Battle4 = { 0, 0, MUSIC(1, 0) };
698AreaBattle area1Battle5 = { 0, 0, MUSIC(1, 0) };
699AreaBattle area1Battle6 = { 0, 0, MUSIC(1, 0) };
700AreaBattle area1Battle7 = { 0, 0, MUSIC(1, 0) };
706AreaBattle area2Battle0 = { 0, 0, MUSIC(1, 0) };
707AreaBattle area2Battle1 = { 0, 0, MUSIC(1, 0) };
708AreaBattle area2Battle2 = { 0, 0, MUSIC(1, 0) };
709AreaBattle area2Battle3 = { 0, 0, MUSIC(1, 0) };
710AreaBattle area2Battle4 = { 0, 0, MUSIC(1, 0) };
711AreaBattle area2Battle5 = { 0, 0, MUSIC(1, 0) };
712AreaBattle area2Battle6 = { 0, 0, MUSIC(1, 0) };
713AreaBattle area2Battle7 = { 0, 0, MUSIC(1, 0) };
720AreaBattle area3Battle1 = { 0, 0, MUSIC(1, 0) };
721AreaBattle area3Battle2 = { 0, 0, MUSIC(1, 0) };
722AreaBattle area3Battle3 = { 0, 0, MUSIC(1, 0) };
723AreaBattle area3Battle4 = { 0, 0, MUSIC(1, 0) };
724AreaBattle area3Battle5 = { 0, 0, MUSIC(1, 0) };
725AreaBattle area3Battle6 = { 0, 0, MUSIC(1, 0) };
726AreaBattle area3Battle7 = { 0, 0, MUSIC(1, 0) };
736 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
737 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
738 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
739 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
740 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
741 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
742 { 0x140, 0x100, 0x159, 0x120, 0x64, 0x20, 0x140, 0x1F5 },
743 { 0x140, 0x100, 0x147, 0x100, 0x1C, 0, 0x150, 0x1F5 },
744 { 0x140, 0x100, 0x144, 0x1D8, 0x10, 0xD8, 0x160, 0x1F5 },
745};
754FieldActorEntry actor1 = { actor1Conditions, NULL, 0xD2, 5, 360, 197, 3 };
755FieldActorEntry actor2 = { actor2Conditions, NULL, 0x13C, 6, 0, 0, 1 };
757 &actor0,
758 &actor1,
759 &actor2,
760 NULL,
761};
763 { 1, 1, 0xFF, 6, 0x13, 0, 0, 0, 0, 0, 235, 78, 0, 0 },
764 { 1, 2, 0xFF, 6, 0x15, 0, 0, 0, 0, 0, 235, 78, 0, 0 },
765 { 1, 3, 0xFF, 6, 0x16, 0, 0, 0, 0, 0, 235, 78, 0, 0 },
766 { 1, 4, 0xFF, 6, 0x17, 0, 0, 0, 0, 0, 235, 78, 0, 0 },
767 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
768};
769void (*stageFuncs[])(void) = {
771};
773 { 880, script880, EVENT_TEXT(3), NULL, endEvent880 },
774 { 881, script881, EVENT_TEXT(4), NULL, endEvent881 },
775 { 882, script882, EVENT_TEXT(5), NULL, endEvent882 },
776 { -1, NULL, 0, NULL, NULL },
777};
#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
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
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
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define SOUND_COMAT103
Definition stage.h:738
#define FIELD_COMMAND_PLAY_DEMO_BGM
Definition field_map.h:53
#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 FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#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_COMMAND_STOP_CAMERA_SHAKE
Definition field_map.h:63
#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 FIELD_COMMAND_SHAKE_CAMERA
Definition field_map.h:62
#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 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
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#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
s32 isOnScreen(s32 x, s32 y, s32 w, s32 h)
Whether the rectangle (x, y, w, h) is in the view of the map's layer.
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_MAGASTA
BGM_0011: the Undersea Base (Magasta), and the Deeper Crevice's gondola.
Definition sound.h:87
#define SOUND_GONDRA_S
Definition sound.h:58
#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
#define MUSIC_BOSS_1
BOSS_001: the Digimon Arena's, the cities', the dungeons' and the A.o.A's boss battles.
Definition sound.h:109
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
FIELDSTG's start of the stage (StageEntry.init in FIELDSTG_stages): the stage's task,...
#define FLAG_FORCED_DIGITIZATION_SEEN
wstag750 event 860: the realize transfer limit is reached and the player is forced back to digital; s...
Definition story.h:1445
@ STORY_REAL_WORLD
WSTAG750 (the emergency Matrix Chamber), event 820: back in the real world, for 180 seconds.
Definition story.h:121
#define FLAG_JUGGERNAUT_LAUNCH_SEEN
wstag805 event 880: the player wins but the field is gone and the Juggernaut launches; set at its end...
Definition story.h:1439
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
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 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
FieldBattles * battles
Definition field_map.h:450
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
CVECTOR spriteColor
the field's sprites' color, unless cd is 0
Definition field_map.h:458
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
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
void(* applyAction)(s32 code, s32 value)
Definition game_state.h:52
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
s32(* getFrameTime)(void)
Definition gfx.h:32
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setLayer)()
(layer, depth)
Definition gfx.h:245
void(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
Sets its children to TASK_DONE one after the other, at the times of a table.
Definition stage.h:575
void(* nextState)(struct StageFloaterChain *task)
Definition stage.h:576
void(* setState)(struct StageFloaterChain *task, s32 state)
Definition stage.h:576
A frame of a StageFloaterPart's animation, with what it adds to value.
Definition stage.h:544
A sprite of a StageFloater, its animation and what the animation adds up.
Definition stage.h:551
AnimState anim
Definition stage.h:554
StageSprite sprite
Definition stage.h:553
Where a StageFloater is created.
Definition stage.h:568
A sprite from the stage's sheet at (x, y) that moves up or down in TASK_DONE.
Definition stage.h:558
void(* setState)(struct StageFloater *task, s32 state)
Definition stage.h:559
void(* nextState)(struct StageFloater *task)
Definition stage.h:559
void(* setSubstate)(struct StageFloater *task, s32 substate)
Definition stage.h:559
s32 state
Definition stage.h:559
StageFloaterPart parts[3]
Definition stage.h:564
s32 substate
Definition stage.h:559
s32 y8
y << 8 while moving
Definition stage.h:562
The children of a StageFloaterChain.
Definition stage.h:582
StageFloater * floaters[27]
Definition stage.h:583
s16 clutRow
Definition stage.h:71
s16 frame
Definition stage.h:70
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 with the animation that sets its frame.
Definition stage.h:108
StageTile * tile
Definition stage.h:109
AnimState anim
Definition stage.h:110
A frame of a looping animation: after the last (frame 0xFF) it goes back to loop.
Definition stage.h:537
The map objects with animations 1 to 4.
Definition stage.h:587
void(* setState)(struct StageTileQuad *task, s32 state)
Definition stage.h:588
StageTileAnim anims[4]
Definition stage.h:589
void(* nextState)(struct StageTileQuad *task)
Definition stage.h:588
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 wstag805.c:747
AreaBattle area2Battle7
Definition wstag805.c:713
FieldActorEntry actor0
Definition wstag805.c:753
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag805.c:769
void * createTileQuad(s32 arg)
Creates the map objects of event 881, where the Juggernaut launches (updateTileQuad),...
Definition wstag805.c:197
StageFloater * createFloater(s32 x, s32 y, s32 up)
Defined below, after the code that uses them.
Definition wstag805.c:307
AreaBattle area2Battle6
Definition wstag805.c:712
StageTileLoopFrame updateTileQuadFrames_2[]
Definition wstag805.c:620
AreaBattle area1Battle6
Definition wstag805.c:699
StageFloaterFrame updateFloaterFrames1[]
Definition wstag805.c:671
void endEvent881(void)
After event 881, with the player: gives the player the Wing Helmet.
Definition wstag805.c:361
StageFloaterFrame updateFloaterFrames0[]
Definition wstag805.c:636
void endEvent882(void)
After event 882, with Royal Guard: keeps it from playing again.
Definition wstag805.c:366
AreaBattle area0Battle7
Definition wstag805.c:687
FieldActorEntry actor2
Definition wstag805.c:755
const CVECTOR stageColor
the color the setup copies to FIELDSTG_state.spriteColor
Definition wstag805.c:370
void * createFloaterChain(s32 arg)
Creates the chain of floaters.
Definition wstag805.c:60
AreaBattle area3Battle4
Definition wstag805.c:723
AreaBattle area3Battle3
Definition wstag805.c:722
AreaBattle area0Battle1
Definition wstag805.c:681
s16 floaterChainTimes[]
Definition wstag805.c:580
AreaBattle area2Battle0
Definition wstag805.c:706
void drawFloaterPart(StageFloater *task, Layer *layer, s32 idx)
Draws a part of a floater.
Definition wstag805.c:238
FieldActorEntry * stageActors[]
Definition wstag805.c:756
AreaBattle area1Battle2
Definition wstag805.c:695
StageFloaterFrame updateFloaterFrames3[]
Definition wstag805.c:658
AreaBattle area3Battle0
Definition wstag805.c:719
StageTileLoopFrame updateTileQuadFrames_0[]
Definition wstag805.c:586
StageFloaterSpot updateFloaterChainSpots[]
Definition wstag805.c:551
AreaBattle area0Battle6
Definition wstag805.c:686
AreaBattle area3Battle2
Definition wstag805.c:721
AreaBattle area3Battle1
Definition wstag805.c:720
AreaBattle area0Battle3
Definition wstag805.c:683
AreaBattle area3Battle6
Definition wstag805.c:725
s32 stepTileLoop(StageTileAnim *obj, StageTileLoopFrame *frames, s32 depth)
Advances a looping animation, returns its frame.
Definition wstag805.c:65
ActorImage stageImages[]
Definition wstag805.c:735
s16 script880[]
Definition wstag805.c:400
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing BGM_0011.
Definition wstag805.c:381
AreaBattle area2Battle4
Definition wstag805.c:710
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag805.c:762
void updateTileQuad(StageTileQuad *task)
Animates the map objects with animations 1 to 4: 2 and 3 hidden while running.
Definition wstag805.c:92
BattleList area3Battles
Definition wstag805.c:727
AreaBattle area3Battle5
Definition wstag805.c:724
AreaBattle area0Battle5
Definition wstag805.c:685
BattleList area1Battles
Definition wstag805.c:701
void updateFloater(StageFloater *task)
A floater: animated in place while running, moving up or down with a sound in TASK_DONE.
Definition wstag805.c:250
BattleList area2Battles
Definition wstag805.c:714
StageTileLoopFrame updateTileQuadFrames_3[]
Definition wstag805.c:602
AreaBattle area1Battle4
Definition wstag805.c:697
AreaBattle area2Battle2
Definition wstag805.c:708
AreaBattle area1Battle5
Definition wstag805.c:698
AreaBattle area2Battle1
Definition wstag805.c:707
AreaBattle area1Battle3
Definition wstag805.c:696
AreaBattle area1Battle0
Definition wstag805.c:693
void handleCommand841(StageFloaterChain *task, s32 id)
Starts the chain when the event of map object 0x335 happens.
Definition wstag805.c:51
s16 script882[]
Definition wstag805.c:514
FieldActorEntry actor1
Definition wstag805.c:754
AreaBattle area0Battle0
Definition wstag805.c:680
void updateFloaterChain(StageFloaterChain *task, StageFloaters *children)
Creates the 27 floaters; in TASK_DONE sets them moving one after the other.
Definition wstag805.c:22
AreaBattle area0Battle2
Definition wstag805.c:682
#define STAGE_FILE
Definition wstag805.c:378
AreaBattle area2Battle5
Definition wstag805.c:711
StageTileLoopFrame updateTileQuadFrames_1[]
Definition wstag805.c:611
AreaBattle area1Battle1
Definition wstag805.c:694
AreaBattle area2Battle3
Definition wstag805.c:709
u16 actor2Conditions[]
Definition wstag805.c:752
s32 stepFloaterPart(StageFloaterPart *obj, StageFloaterFrame *frames, s32 once, s32 depth)
Advances a part's animation (adding up its deltas when once), returns its frame.
Definition wstag805.c:202
StageFloaterFrame updateFloaterFrames2[]
Definition wstag805.c:647
AreaBattle area0Battle4
Definition wstag805.c:684
StageTileLoopFrame * updateTileQuadFrames[]
Definition wstag805.c:630
#define STAGE_TEXT
Definition wstag805.c:376
s16 script881[]
Definition wstag805.c:445
AreaBattle area3Battle7
Definition wstag805.c:726
BattleList area0Battles
Definition wstag805.c:688
AreaBattle area1Battle7
Definition wstag805.c:700
void endEvent880(void)
After event 880, with Royal Guard: starts the stage's event battle 0 and keeps it from playing again.
Definition wstag805.c:355
FieldBattles stageBattles[]
Definition wstag805.c:732
FieldEvent stageEvents[]
Definition wstag805.c:772
void handleCommand840(StageTileQuad *task, s32 id)
Plays a sound and starts the map objects' TASK_DONE animations when the event of map object 0x35B hap...
Definition wstag805.c:186
u16 actor0Conditions[]
Definition wstag805.c:746