Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
wstag415.c
Go to the documentation of this file.
1/*
2 * WSTAG415: Deeper Crevice, East Sector. The gondola ride to South Sector.
3 */
4
5#include "common.h"
6#include "field/stage.h"
7/* Defined below, after the code that uses them */
12
13/* The files of the background, which the versions number differently */
14#if VERSION_US || VERSION_JP
15#define BG_ARCHIVE 0x74E
16#define BG_FILE 0x759
17#elif VERSION_EU
18#define BG_ARCHIVE 0x75E
19#define BG_FILE 0x769
20#endif
21
22/* Steps the looping animation of a faller's StageBody, returning its frame */
23s32 stepFallBody(StageBody *body, AnimFrame *frames, s32 depth) {
24 AnimFrame *frame = &frames[body->anim.index];
26
27 if (dt > 4) {
28 dt = 4;
29 }
30 if (depth == 0) {
31 body->anim.timer -= dt;
32 }
33 if (body->anim.timer <= 0) {
34 frame++;
35 body->anim.index++;
36 body->anim.timer += frame->duration;
37 if (frame->frame == 0xFF) {
38 frame = frames;
39 body->anim.index = 0;
40 body->anim.timer += frame->duration;
41 }
42 stepFallBody(body, frames, depth + 1);
43 }
44 return frame->frame;
45}
46
47/* Draws a StageFaller (a layer callback) */
48void drawFaller(StageFaller *task, Layer *layer) {
49 SpriteDrawer drawer;
50
51 if (task->state == TASK_RUN) {
52 initSpriteDrawer(&drawer);
53 drawer.setTexture(0x140, 0x100);
54 drawer.setLayer(layer, 4);
55 drawer.setClutRow(0);
56 drawer.setAltClut(0, 0x1F0);
57 drawer.draw(FILE_CACHE.getEntry(FIELDSTG_state.sheetEntry), task->frame, task->x, task->y);
58 }
59}
60
61/*
62 * Updates a StageFaller of kind key1: it falls from the start of its
63 * updateFallerParams with their speed and gravity, bounces once off their
64 * floorY (if they bounce), and ends below the screen
65 */
68 s32 dv;
69
70 switch (task->state) {
71 case TASK_INIT:
72 default:
73 task->body.x = updateFallerParams[task->key1].x << 8;
74 task->body.y = updateFallerParams[task->key1].y << 8;
75 task->body.mode = 0;
76 task->body.vy = 0;
77 task->body.vx = updateFallerParams[task->key1].vx;
78 task->nextState(task);
79 break;
80 case TASK_RUN:
81 task->frame = stepFallBody(&task->body, updateFallerParams[task->key1].frames, 0);
83 task->body.x += task->body.vx;
84 task->body.vy += dv;
85 task->x = task->body.x >> 8;
86 task->body.y += task->body.vy;
87 task->y = task->body.y >> 8;
88 if (updateFallerParams[task->key1].bounce != 0 && task->body.mode == 0 && task->y >= updateFallerParams[task->key1].floorY) {
89 task->body.y = updateFallerParams[task->key1].floorY << 8;
90 task->y = updateFallerParams[task->key1].floorY;
91 task->body.vy = -(task->body.vy / updateFallerParams[task->key1].bounce);
92 task->body.vx = updateFallerParams[task->key1].vx * 3;
93 task->body.mode = 1;
95 }
96 if (task->frame != 0) {
97 layer->addSortedCallback(layer, drawFaller, task, task->y, 0);
98 }
99 if (task->y > 0x244) {
100 task->setState(task, TASK_KILL);
101 }
102 break;
103 case TASK_DONE:
104 case TASK_KILL:
105 break;
106 }
107}
108
109/* Creates the task of updateFaller with the given id, of kind KIND (its updateFallerParams) */
110static inline Task *createFaller(s32 id, s32 kind) {
111 Task *task = createTaskWithId(updateFaller, sizeof(StageFaller), 0, id);
112
113 task->key1 = kind;
114 return task;
115}
116
117/* The fallers of kinds 0 to 9 */
119 return createFaller(id, 0);
120}
121
122/* Command 817 of the event scripts: a thing that falls in event 150's earthquake (kind 1) */
124 return createFaller(id, 1);
125}
126
127/* Command 818 of the event scripts: a thing that falls in event 150's earthquake (kind 2) */
129 return createFaller(id, 2);
130}
131
132/* Command 819 of the event scripts: a thing that falls in event 150's earthquake (kind 3) */
134 return createFaller(id, 3);
135}
136
137/* Command 820 of the event scripts: a thing that falls in event 150's earthquake (kind 4) */
139 return createFaller(id, 4);
140}
141
142/* Command 821 of the event scripts: a thing that falls in event 150's earthquake (kind 5) */
144 return createFaller(id, 5);
145}
146
147/* Command 822 of the event scripts: a thing that falls in event 150's earthquake (kind 6) */
149 return createFaller(id, 6);
150}
151
152/* Command 823 of the event scripts: a thing that falls in event 150's earthquake (kind 7) */
154 return createFaller(id, 7);
155}
156
157/* Command 824 of the event scripts: a thing that falls in event 150's earthquake (kind 8) */
159 return createFaller(id, 8);
160}
161
162/*
163 * Command 825 of the event scripts: the last of the ten things that fall in
164 * event 150's earthquake (kind 9)
165 */
167 return createFaller(id, 9);
168}
169
170/* Steps the animation of the mover's StageBody, holding its last frame, and returns the frame */
171s32 stepMoverBody(StageBody *body, AnimFrame *frames, s32 depth) {
172 AnimFrame *frame = &frames[body->anim.index];
173 s32 dt = GFX.funcs.getFrameTime();
174
175 if (dt > 4) {
176 dt = 4;
177 }
178 if (depth == 0) {
179 body->anim.timer -= dt;
180 }
181 if (body->anim.timer <= 0) {
182 frame++;
183 body->anim.index++;
184 body->anim.timer += frame->duration;
185 if (frame->frame == 0xFF) {
186 frame--;
187 body->anim.index--;
188 body->anim.timer += frame->duration;
189 }
190 stepMoverBody(body, frames, depth + 1);
191 }
192 return frame->frame;
193}
194
195/* Updates a StageMover: falls in mode 1 and plays an animation in modes 2 to 4 */
197 StageTile *tile;
198 StageTile *object;
199
200 switch (task->state) {
201 case TASK_INIT:
202 default:
203 if (task->key1 == 0) {
204 task->body.x = 0x9600;
205 task->body.y = 0xE600;
206 task->body.mode = 0;
207 task->body.vy = 0;
208 task->body.vx = 0;
209 task->body.timer = 0;
210 } else {
211 task->body.x = 0x9600;
212 task->body.y = 0x1AE00;
213 task->body.timer = 0;
214 task->body.mode = 0;
215 task->x = task->body.x >> 8;
216 task->y = task->body.y >> 8;
217 }
218 for (object = FIELDSTG_state.objects; object->margin != 0; object++) {
219 if (object->anim == 1) {
220 task->tile = object;
221 object->x = task->x;
222 object->x = task->y; /* x again, not y */
223 break;
224 }
225 }
226 task->nextState(task);
227 break;
228 case TASK_RUN:
229 switch (task->body.mode) {
230 case 0:
231 task->frame = 0x32;
232 break;
233 case 1:
234 task->frame = 0x32;
235 task->body.vy += GFX.funcs.getFrameTime() * 0x30;
236 task->body.x += task->body.vx;
237 task->body.y += task->body.vy;
238 task->x = task->body.x >> 8;
239 task->y = task->body.y >> 8;
240 if (task->y >= 0x1AE) {
241 task->body.y = 0x1AE00;
242 task->y = 0x1AE;
243 if (task->body.vy > 0x200) {
245 }
246 task->body.vy = -(task->body.vy / 6);
247 }
248 task->body.timer++;
249 break;
250 case 2:
251 task->frame = stepMoverBody(&task->body, updateMoverFrames0, 0);
252 if (task->frame == 0x35 && task->substate == 0) {
254 task->substate++;
255 }
256 if (task->frame == 0x3B && task->substate == 1) {
258 task->substate++;
259 }
260 break;
261 case 3:
262 task->frame = stepMoverBody(&task->body, updateMoverFrames1, 0);
263 break;
264 case 4:
265 task->frame = stepMoverBody(&task->body, updateMoverFrames2, 0);
266 if (task->frame == 2 && task->substate == 0) {
268 task->substate++;
269 }
270 if (task->frame == 0x20 && task->substate == 1) {
272 task->substate++;
273 }
274 if (task->frame == 0x2A && task->substate == 2) {
276 task->step = 0;
277 task->substate++;
278 }
279 if (task->substate == 3 || task->substate == 4) {
280 if ((++task->step & 0x1F) == 0) {
282 task->step = 0;
283 task->substate++;
284 }
285 }
286 break;
287 }
288 tile = task->tile;
289 tile->frame = task->frame;
290 tile->x = task->x;
291 tile->y = task->y;
292 tile->visible = 1;
293 break;
294 case TASK_DONE:
295 case TASK_KILL:
296 break;
297 }
298}
299
300/* Handles the events 0x331 to 0x334 sent to a StageMover */
302 if (task != NULL) {
303 switch (id) {
304 case 0x331:
305 task->body.x = 0x9600;
306 task->body.y = 0xE600;
307 task->body.mode = 1;
308 task->body.vy = 0;
309 task->body.vx = 0;
310 task->body.timer = 0;
311 break;
312 case 0x332:
314 task->body.anim.index = 0;
316 task->body.mode = 2;
317 task->substate = 0;
318 break;
319 case 0x333:
321 task->body.anim.index = 0;
323 task->body.mode = 3;
324 break;
325 case 0x334:
326 task->body.mode = 4;
327 task->body.anim.index = 0;
329 task->substate = 0;
330 break;
331 }
332 }
333}
334
335/* Creates the task of updateMover with the given id, kind 0 */
337 Task *task = createTaskWithId(updateMover, sizeof(StageMover), 0, id);
338
339 task->key1 = 0;
340 return task;
341}
342
343/*
344 * Creates the mover of event 151, where the Digimon gets away (updateMover),
345 * already falling (mode 1)
346 */
348 Task *task = createTaskWithId(updateMover, sizeof(StageMover), 0, id);
349
350 task->key1 = 1;
351 return task;
352}
353
354/* Draws a StageScroller: each image twice, the second 0x200 left and 0x100 down */
356 SpriteDrawer drawer;
357 s32 pos[2];
358
359 initSpriteDrawer(&drawer);
360 drawer.setLayerId(FIELD_LAYER_MAP, 7);
361 drawer.setTexture(0x280, 0);
362 drawer.setAltClut(0, 0xF0);
363 pos[0] = task->x >> 8;
364 pos[1] = (task->y >> 8) + 0x100;
365 drawer.draw(FILE_CACHE.getEntry(BG_ARCHIVE << 16 | 2), 0, pos[0], pos[1]);
366 drawer.draw(FILE_CACHE.getEntry(BG_ARCHIVE << 16 | 2), 0, pos[0] - 0x200, pos[1] + 0x100);
367 drawer.setTexture(0x280, 0x100);
368 drawer.setAltClut(0, 0xF8);
369 pos[0] = (task->x >> 8) + 0x100;
370 drawer.draw(FILE_CACHE.getEntry(BG_ARCHIVE << 16 | 4), 0, pos[0], pos[1]);
371 drawer.draw(FILE_CACHE.getEntry(BG_ARCHIVE << 16 | 4), 0, pos[0] - 0x200, pos[1] + 0x100);
372}
373
374/* Loads the images of a StageScroller and scrolls it, slowing down to a stop in substate 1 */
376 TimLoader loader;
377
378 switch (task->state) {
379 case TASK_INIT:
380 default:
381 initTimLoader(&loader);
382 loader.setImagePos(0x280, 0);
383 loader.setClutPos(0, 0xF0);
385 loader.setImagePos(0x280, 0x100);
386 loader.setClutPos(0, 0xF8);
387 loader.loadArchive(FILE_CACHE.load(BG_FILE + 1));
388 task->nextState(task);
389 if (task->key1 != 0) {
390 task->nextSubstate(task);
391 }
392 break;
393 case TASK_RUN:
394 switch (task->substate) {
395 case 0:
396 default:
397 task->vx = 0x800;
398 task->vy = 0x400;
399 break;
400 case 1:
401 if (task->vx == 0x800) {
403 }
404 if (task->vx != 0) {
405 task->vx -= 0x10;
406 task->vy = task->vx / 2;
407 if (task->vx < 0) {
408 task->vx = 0;
409 task->vy = 0;
410 }
411 }
412 break;
413 }
414 task->x += task->vx;
415 task->y -= task->vy;
416 if (task->x > 0x1FFFF) {
417 task->x -= 0x20000;
418 task->y += 0x10000;
419 }
420 drawScroller(task);
421 break;
422 case TASK_DONE:
423 case TASK_KILL:
424 break;
425 }
426}
427
428/* Sets the substate of the task to 1 when the id is 0x336 */
429void handleCommand812(Task *task, s32 id) {
430 if (task != NULL && id == 0x336) {
431 task->setSubstate(task, 1);
432 }
433}
434
435/* Creates the task of updateScroller (id 0x32C) of the given kind */
437 Task *task = createTaskWithId(updateScroller, sizeof(StageScroller), 0, 0x32C);
438
439 task->key1 = kind;
440 return task;
441}
442
443/* Creates the event objects of progress 6, which depend on flag 0x4018 */
444void updateStage(StageTask *task, void **children) {
445 switch (task->state) {
446 case TASK_INIT:
447 default:
449 if (FLAGS_00.checkCondition(FLAG(0x40, 0x18), 0)) {
450 children[0] = createScroller(0);
451 children[1] = FIELDSTG_startEvent(0x96);
452 } else {
453 children[0] = createScroller(1);
454 children[2] = createMover(0x32B);
455 children[1] = FIELDSTG_startEvent(0x97);
456 }
457 }
458 task->nextState(task);
459 break;
460 case TASK_RUN:
461 case TASK_DONE:
462 case TASK_KILL:
463 break;
464 }
465}
466
467#define STAGE_CHILDREN_SIZE 0xC
469
470/* After event 150, with the player: starts the stage's event battle 0 and sets flag 0x4018 */
471void endEvent150(void) {
472 FLAGS_00.applyAction(FLAG(0x40, 0x18), 1);
474}
475
476#if VERSION_US || VERSION_JP
477#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
478#define EVENT_TEXT_FILE (TEXT_EVENTS_400 - 1)
479#define STAGE_FILE 0x74E
480#elif VERSION_EU
481#define STAGE_TEXT TEXT_FILE(TEXT_TALKS_06)
482#define EVENT_TEXT_FILE (TEXT_EVENTS_400 - 1)
483#define STAGE_FILE 0x75E
484#endif
485/* Sets the stage up: its map, actors, battles and events, playing BGM_0011 */
501
503 SCRIPT_FOLLOW(1, 1),
504 SCRIPT_PLACE(1, 0x114, 0x157),
505 SCRIPT_POSE(1, 1, 1),
506 SCRIPT_COMMAND(0x32B, 0x330, 1),
507 SCRIPT_WAIT(0xB4),
508 SCRIPT_COMMAND(0x32C, 0x336, 0x32C),
509 SCRIPT_WAIT_ANIM(0x32C),
510 SCRIPT_WAIT(0x1E),
511 SCRIPT_COMMAND(0x323, 0x325, 1),
512 SCRIPT_WAIT(0x3C),
513 SCRIPT_COMMAND(0x323, 0x326, 1),
514 SCRIPT_WAIT(0x1E),
515 SCRIPT_WAIT(0x3C),
516 SCRIPT_POSE(1, 0x3A, 1),
517 SCRIPT_WAIT(0x3C),
518 SCRIPT_TALK(0, 1, 1, 0),
520 SCRIPT_POSE(1, 1, 1),
521 SCRIPT_WAIT(0x1E),
522 SCRIPT_TALK(0, 2, 1, 4),
526 SCRIPT_WAIT(0x3C),
527 SCRIPT_TALK(0, 3, 1, 0),
528 SCRIPT_POSE(1, 0x33, 1),
530 SCRIPT_POSE(1, 1, 1),
531 SCRIPT_WAIT(0x3C),
532 SCRIPT_LOOK_AT(0, 0xD8, 0x175),
533 SCRIPT_WAIT(0x3C),
534 SCRIPT_COMMAND(0x330, 0x335, 0x330),
535 SCRIPT_WAIT(0x5A),
536 SCRIPT_COMMAND(0x331, 0x335, 0x331),
537 SCRIPT_COMMAND(0x337, 0x335, 0x337),
538 SCRIPT_WAIT(0x3C),
539 SCRIPT_COMMAND(0x332, 0x335, 0x332),
540 SCRIPT_COMMAND(0x334, 0x335, 0x334),
541 SCRIPT_COMMAND(0x336, 0x335, 0x336),
542 SCRIPT_WAIT(0x3C),
543 SCRIPT_COMMAND(0x333, 0x335, 0x333),
544 SCRIPT_COMMAND(0x339, 0x335, 0x339),
545 SCRIPT_WAIT(0x3C),
546 SCRIPT_COMMAND(0x335, 0x335, 0x335),
547 SCRIPT_COMMAND(0x338, 0x335, 0x333),
548 SCRIPT_WAIT(0x3C),
549 SCRIPT_COMMAND(0x32B, 0x331, 0x32B),
550 SCRIPT_WAIT(0x78),
551 SCRIPT_WAIT(0x1E),
553 SCRIPT_WAIT(0xC),
554 SCRIPT_TALK(0, 4, 1, 0),
555 SCRIPT_POSE(1, 0x33, 1),
557 SCRIPT_POSE(1, 1, 1),
558 SCRIPT_WAIT(0x1E),
559 SCRIPT_COMMAND(0x32B, 0x332, 0x32B),
560 SCRIPT_WAIT(0x78),
561 SCRIPT_WAIT(0x78),
562 SCRIPT_COMMAND(0x32B, 0x333, 0x32B),
563 SCRIPT_WAIT(0xC),
565};
567 SCRIPT_LOOK_AT(1, 0xD8, 0x175),
568 SCRIPT_PLACE(1, 0x114, 0x157),
569 SCRIPT_POSE(1, 1, 1),
570 SCRIPT_COMMAND(0x32C, 0x336, 1),
571 SCRIPT_WAIT(6),
572 SCRIPT_WAIT(0x54),
573 SCRIPT_COMMAND(0x32B, 0x334, 1),
574 SCRIPT_WAIT(0x9C),
575 SCRIPT_FOLLOW(0, 1),
576 SCRIPT_WAIT(0x1E),
577 SCRIPT_TALK(0, 2, 1, 2),
579 SCRIPT_WAIT(0x78),
580 SCRIPT_TALK(0, 1, 1, 4),
583 SCRIPT_COMMAND(0x323, 0x325, 1),
584 SCRIPT_WAIT(0x3C),
585 SCRIPT_COMMAND(0x323, 0x326, 1),
586 SCRIPT_WAIT(0x3C),
587 SCRIPT_LEAVE(0x232, 0x1EF, 0xB9, 1),
589};
591 { 70, 8 }, { 71, 8 }, { 72, 8 }, { 73, 8 },
592 { 255, 0 },
593};
595 { 74, 8 }, { 75, 8 }, { 76, 8 }, { 77, 8 },
596 { 255, 0 },
597};
599 { updateFallerParams_0, -0x20, 230, 0, 0x180, 88, 0 },
600 { updateFallerParams_1, 0, 230, 0x1C2, 0x200, 72, 4 },
601 { updateFallerParams_0, 32, 230, 0x19A, 0x180, 88, 8 },
602 { updateFallerParams_1, 64, 230, 0, 0x200, 72, 0 },
603 { updateFallerParams_1, 80, 230, 0, 0x200, 72, 0 },
604 { updateFallerParams_0, 16, 230, 0, 96, 88, 0 },
605 { updateFallerParams_1, 48, 230, 0x1CC, 128, 72, 4 },
606 { updateFallerParams_0, 80, 230, 0x1A4, 96, 88, 8 },
607 { updateFallerParams_1, 112, 230, 0, 128, 72, 0 },
608 { updateFallerParams_1, 140, 230, 0, 128, 72, 0 },
609};
611 { 50, 5 }, { 52, 5 }, { 53, 5 }, { 54, 40 },
612 { 55, 8 }, { 56, 8 }, { 57, 10 }, { 58, 12 },
613 { 59, 180 }, { 255, 0 },
614};
616 { 60, 4 }, { 61, 4 }, { 62, 0x3E7 }, { 255, 0 },
617};
619 { 1, 4 }, { 2, 4 }, { 3, 4 }, { 4, 4 },
620 { 5, 4 }, { 6, 4 }, { 7, 4 }, { 8, 4 },
621 { 9, 4 }, { 10, 4 }, { 11, 4 }, { 12, 4 },
622 { 13, 4 }, { 14, 4 }, { 15, 4 }, { 16, 4 },
623 { 17, 4 }, { 18, 4 }, { 19, 4 }, { 20, 4 },
624 { 21, 4 }, { 22, 4 }, { 23, 4 }, { 24, 4 },
625 { 25, 4 }, { 26, 4 }, { 27, 4 }, { 28, 4 },
626 { 29, 4 }, { 30, 4 }, { 31, 4 }, { 32, 4 },
627 { 33, 4 }, { 34, 4 }, { 35, 4 }, { 36, 4 },
628 { 37, 4 }, { 38, 4 }, { 39, 4 }, { 40, 4 },
629 { 41, 4 }, { 42, 4 }, { 43, 4 }, { 44, 4 },
630 { 45, 4 }, { 46, 4 }, { 47, 4 }, { 255, 0x3E7 },
631};
632AreaBattle area0Battle0 = { 0, 0, MUSIC(1, 0) };
633AreaBattle area0Battle1 = { 0, 0, MUSIC(1, 0) };
634AreaBattle area0Battle2 = { 0, 0, MUSIC(1, 0) };
635AreaBattle area0Battle3 = { 0, 0, MUSIC(1, 0) };
636AreaBattle area0Battle4 = { 0, 0, MUSIC(1, 0) };
637AreaBattle area0Battle5 = { 0, 0, MUSIC(1, 0) };
638AreaBattle area0Battle6 = { 0, 0, MUSIC(1, 0) };
639AreaBattle area0Battle7 = { 0, 0, MUSIC(1, 0) };
645AreaBattle area1Battle0 = { 0, 0, MUSIC(1, 0) };
646AreaBattle area1Battle1 = { 0, 0, MUSIC(1, 0) };
647AreaBattle area1Battle2 = { 0, 0, MUSIC(1, 0) };
648AreaBattle area1Battle3 = { 0, 0, MUSIC(1, 0) };
649AreaBattle area1Battle4 = { 0, 0, MUSIC(1, 0) };
650AreaBattle area1Battle5 = { 0, 0, MUSIC(1, 0) };
651AreaBattle area1Battle6 = { 0, 0, MUSIC(1, 0) };
652AreaBattle area1Battle7 = { 0, 0, MUSIC(1, 0) };
658AreaBattle area2Battle0 = { 0, 0, MUSIC(1, 0) };
659AreaBattle area2Battle1 = { 0, 0, MUSIC(1, 0) };
660AreaBattle area2Battle2 = { 0, 0, MUSIC(1, 0) };
661AreaBattle area2Battle3 = { 0, 0, MUSIC(1, 0) };
662AreaBattle area2Battle4 = { 0, 0, MUSIC(1, 0) };
663AreaBattle area2Battle5 = { 0, 0, MUSIC(1, 0) };
664AreaBattle area2Battle6 = { 0, 0, MUSIC(1, 0) };
665AreaBattle area2Battle7 = { 0, 0, MUSIC(1, 0) };
672AreaBattle area3Battle1 = { 0, 0, MUSIC(1, 0) };
673AreaBattle area3Battle2 = { 0, 0, MUSIC(1, 0) };
674AreaBattle area3Battle3 = { 0, 0, MUSIC(1, 0) };
675AreaBattle area3Battle4 = { 0, 0, MUSIC(1, 0) };
676AreaBattle area3Battle5 = { 0, 0, MUSIC(1, 0) };
677AreaBattle area3Battle6 = { 0, 0, MUSIC(1, 0) };
678AreaBattle area3Battle7 = { 0, 0, MUSIC(1, 0) };
688 { 0x200, 0x100, 0x21C, 0x1A6, 0x70, 0xA6, 0x230, 0x1FE },
689 { 0x200, 0x100, 0x200, 0x100, 0, 0, 0x220, 0x1FE },
690 { 0x200, 0x100, 0x216, 0x138, 0x58, 0x38, 0x200, 0x1FD },
691 { 0x200, 0x100, 0x208, 0x1BC, 0x20, 0xBC, 0x210, 0x1FD },
692 { 0x200, 0x100, 0x210, 0x1BC, 0x40, 0xBC, 0x220, 0x1FD },
693 { 0x200, 0x100, 0x200, 0x1BC, 0, 0xBC, 0x230, 0x1FD },
694 { 0x1C0, 0x100, 0x1CC, 0x150, 0x230, 0x50, 0x160, 0x1FF },
695};
696FieldActorEntry actor0 = { NULL, NULL, 1, 4, 0, 0, 7 };
698 &actor0,
699 NULL,
700};
702 { 1, 0, 0x6E, 6, 0, 0, 0, 0, 0, 0, 225, 318, 0, 0 },
703 { 1, 1, 0x94, 4, 0x32, 0, 0, 0, 0, 0, 0, -50, 0, 0 },
704 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
705};
706void (*stageFuncs[])(void) = {
708};
710 { 150, script150, EVENT_TEXT(4), NULL, endEvent150 },
711 { 151, script151, EVENT_TEXT(5), NULL, NULL },
712 { -1, NULL, 0, NULL, NULL },
713};
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
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
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 SOUND_COMEX105
Definition stage.h:739
#define EVENT_TEXT(n)
An entry of the stage's events' text file, for FieldEvent.text.
Definition stage.h:732
#define SOUND_GONDRA_B
Definition stage.h:744
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
#define SOUND_BULB_001
Definition stage.h:743
#define SOUND_MTL_DOWN
The sounds the stages play, with SOUNDTST's names (engine/sound.h has the ones the overlays share)
Definition stage.h:736
#define SOUND_COMEX112
Definition stage.h:740
#define SOUND_BULB_000
Definition stage.h:742
#define SOUND_COMEX114
Definition stage.h:741
#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_COMMAND_SHAKE_CAMERA
Definition field_map.h:62
#define SCRIPT_WAIT_BOX
until box 0 closes
Definition field_map.h:167
#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 SCRIPT_WAIT(frames)
Definition field_map.h:166
#define SCRIPT_WAIT_ANIM(id)
until its animation ends
Definition field_map.h:169
#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 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 MUSIC_MAGASTA
BGM_0011: the Undersea Base (Magasta), and the Deeper Crevice's gondola.
Definition sound.h:87
#define MUSIC_BOSS
BOSS_000: the sectors' boss battles.
Definition sound.h:108
#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
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,...
@ STORY_FAKE_BLUE_CARD
WSTAG410 (East Station), event 90: the Blue Card the player was given turns out to be a fake.
Definition story.h:42
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(* 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 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
void *(* load)(u32 file)
Definition file.h:92
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
void(* addSortedCallback)()
Definition gfx.h:160
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(* setAltClut)()
(x, y)
Definition gfx.h:243
void(* setLayer)()
(layer, depth)
Definition gfx.h:245
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
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
What moves a StageFaller or the StageMover of WSTAG415 at (x, y) in 8.8, and its animation: one layou...
Definition stage.h:303
s32 vy
Definition stage.h:307
AnimState anim
Definition stage.h:310
s32 y
Definition stage.h:305
s16 timer
the mover's frames of falling; a faller never sets it
Definition stage.h:308
s16 mode
the mover's; a faller's is 1 once it has bounced
Definition stage.h:309
s32 vx
Definition stage.h:306
s32 x
Definition stage.h:304
Where a StageFaller starts and how it falls.
Definition stage.h:323
AnimFrame * frames
Definition stage.h:324
s16 bounce
divides vy when bouncing, 0 for no bounce
Definition stage.h:330
A sprite of WSTAG415 that falls from a point of a table, bounces once and dies at the bottom.
Definition stage.h:314
void(* setState)(struct StageFaller *task, s32 state)
Definition stage.h:315
s32 key1
Definition stage.h:315
StageBody body
Definition stage.h:319
void(* nextState)(struct StageFaller *task)
Definition stage.h:315
s32 frame
Definition stage.h:316
s32 state
Definition stage.h:315
The object of WSTAG415 that events 0x331 to 0x334 drive.
Definition stage.h:334
s32 key1
Definition stage.h:335
void(* nextState)(struct StageMover *task)
Definition stage.h:335
StageTile * tile
the map object (FieldState.objects) with animation 1
Definition stage.h:339
s32 frame
Definition stage.h:336
s32 substate
Definition stage.h:335
StageBody body
Definition stage.h:340
s32 x
Definition stage.h:337
s32 y
Definition stage.h:338
s32 step
Definition stage.h:335
s32 state
Definition stage.h:335
A scrolling background of two images of an archive, moving by (vx, -vy)
Definition stage.h:344
s32 substate
Definition stage.h:345
void(* nextState)(struct StageScroller *task)
Definition stage.h:345
void(* nextSubstate)(struct StageScroller *task)
Definition stage.h:345
s32 x
8.8
Definition stage.h:346
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
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
Any task, seen through its header.
Definition task.h:62
s32 key1
Definition task.h:63
void(* setSubstate)(struct Task *task, s32 substate)
Definition task.h:63
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setClutPos)()
(x, y)
Definition gfx.h:337
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* loadArchive)()
(archive): each image 64 halfwords to the right
Definition gfx.h:338
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
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119
void handleCommand811(StageMover *task, s32 id)
Handles the events 0x331 to 0x334 sent to a StageMover.
Definition wstag415.c:301
AreaBattle area2Battle7
Definition wstag415.c:665
FieldActorEntry actor0
Definition wstag415.c:696
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag415.c:706
Task * createCommand819(s32 id)
Command 819 of the event scripts: a thing that falls in event 150's earthquake (kind 3)
Definition wstag415.c:133
Task * createCommand816(s32 id)
The fallers of kinds 0 to 9.
Definition wstag415.c:118
AnimFrame updateFallerParams_0[]
Definition wstag415.c:590
AreaBattle area2Battle6
Definition wstag415.c:664
AnimFrame updateMoverFrames1[]
Definition wstag415.c:615
AnimFrame updateMoverFrames2[]
Definition wstag415.c:618
Task * createCommand811(s32 id)
Creates the task of updateMover with the given id, kind 0.
Definition wstag415.c:336
Task * createCommand822(s32 id)
Command 822 of the event scripts: a thing that falls in event 150's earthquake (kind 6)
Definition wstag415.c:148
Task * createCommand817(s32 id)
Command 817 of the event scripts: a thing that falls in event 150's earthquake (kind 1)
Definition wstag415.c:123
Task * createCommand820(s32 id)
Command 820 of the event scripts: a thing that falls in event 150's earthquake (kind 4)
Definition wstag415.c:138
AreaBattle area1Battle6
Definition wstag415.c:651
Task * createScroller(s32 kind)
Creates the task of updateScroller (id 0x32C) of the given kind.
Definition wstag415.c:436
void endEvent150(void)
After event 150, with the player: starts the stage's event battle 0 and sets flag 0x4018.
Definition wstag415.c:471
#define BG_FILE
Definition wstag415.c:19
AreaBattle area0Battle7
Definition wstag415.c:639
#define BG_ARCHIVE
The files of the background, which the versions number differently.
Definition wstag415.c:18
void drawScroller(StageScroller *task)
Draws a StageScroller: each image twice, the second 0x200 left and 0x100 down.
Definition wstag415.c:355
void handleCommand812(Task *task, s32 id)
Sets the substate of the task to 1 when the id is 0x336.
Definition wstag415.c:429
AreaBattle area3Battle4
Definition wstag415.c:675
AreaBattle area3Battle3
Definition wstag415.c:674
AreaBattle area0Battle1
Definition wstag415.c:633
AreaBattle area2Battle0
Definition wstag415.c:658
AnimFrame updateFallerParams_1[]
Definition wstag415.c:594
FieldActorEntry * stageActors[]
Definition wstag415.c:697
AreaBattle area1Battle2
Definition wstag415.c:647
AreaBattle area3Battle0
Definition wstag415.c:671
s32 stepFallBody(StageBody *body, AnimFrame *frames, s32 depth)
Steps the looping animation of a faller's StageBody, returning its frame.
Definition wstag415.c:23
AreaBattle area0Battle6
Definition wstag415.c:638
static Task * createFaller(s32 id, s32 kind)
Creates the task of updateFaller with the given id, of kind KIND (its updateFallerParams)
Definition wstag415.c:110
AreaBattle area3Battle2
Definition wstag415.c:673
Task * createCommand821(s32 id)
Command 821 of the event scripts: a thing that falls in event 150's earthquake (kind 5)
Definition wstag415.c:143
AreaBattle area3Battle1
Definition wstag415.c:672
AreaBattle area0Battle3
Definition wstag415.c:635
AreaBattle area3Battle6
Definition wstag415.c:677
ActorImage stageImages[]
Definition wstag415.c:687
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing BGM_0011.
Definition wstag415.c:486
void updateScroller(StageScroller *task)
Loads the images of a StageScroller and scrolls it, slowing down to a stop in substate 1.
Definition wstag415.c:375
AreaBattle area2Battle4
Definition wstag415.c:662
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag415.c:701
AnimFrame updateMoverFrames0[]
Definition wstag415.c:610
StageFallParams updateFallerParams[]
Defined below, after the code that uses them.
Definition wstag415.c:598
BattleList area3Battles
Definition wstag415.c:679
AreaBattle area3Battle5
Definition wstag415.c:676
AreaBattle area0Battle5
Definition wstag415.c:637
BattleList area1Battles
Definition wstag415.c:653
BattleList area2Battles
Definition wstag415.c:666
Task * createCommand823(s32 id)
Command 823 of the event scripts: a thing that falls in event 150's earthquake (kind 7)
Definition wstag415.c:153
AreaBattle area1Battle4
Definition wstag415.c:649
AreaBattle area2Battle2
Definition wstag415.c:660
AreaBattle area1Battle5
Definition wstag415.c:650
AreaBattle area2Battle1
Definition wstag415.c:659
AreaBattle area1Battle3
Definition wstag415.c:648
s16 script150[]
Definition wstag415.c:502
Task * createCommand825(s32 id)
Command 825 of the event scripts: the last of the ten things that fall in event 150's earthquake (kin...
Definition wstag415.c:166
AreaBattle area1Battle0
Definition wstag415.c:645
AreaBattle area0Battle0
Definition wstag415.c:632
AreaBattle area0Battle2
Definition wstag415.c:634
#define STAGE_FILE
Definition wstag415.c:483
s16 script151[]
Definition wstag415.c:566
AreaBattle area2Battle5
Definition wstag415.c:663
AreaBattle area1Battle1
Definition wstag415.c:646
AreaBattle area2Battle3
Definition wstag415.c:661
AreaBattle area0Battle4
Definition wstag415.c:636
#define STAGE_TEXT
Definition wstag415.c:481
Task * createCommand818(s32 id)
Command 818 of the event scripts: a thing that falls in event 150's earthquake (kind 2)
Definition wstag415.c:128
s32 stepMoverBody(StageBody *body, AnimFrame *frames, s32 depth)
Steps the animation of the mover's StageBody, holding its last frame, and returns the frame.
Definition wstag415.c:171
Task * createMover(s32 id)
Creates the mover of event 151, where the Digimon gets away (updateMover), already falling (mode 1)
Definition wstag415.c:347
void updateFaller(StageFaller *task)
Updates a StageFaller of kind key1: it falls from the start of its updateFallerParams with their spee...
Definition wstag415.c:66
AreaBattle area3Battle7
Definition wstag415.c:678
BattleList area0Battles
Definition wstag415.c:640
AreaBattle area1Battle7
Definition wstag415.c:652
Task * createCommand824(s32 id)
Command 824 of the event scripts: a thing that falls in event 150's earthquake (kind 8)
Definition wstag415.c:158
FieldBattles stageBattles[]
Definition wstag415.c:684
FieldEvent stageEvents[]
Definition wstag415.c:709
void updateMover(StageMover *task)
Updates a StageMover: falls in mode 1 and plays an animation in modes 2 to 4.
Definition wstag415.c:196
void drawFaller(StageFaller *task, Layer *layer)
Draws a StageFaller (a layer callback)
Definition wstag415.c:48