Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
stage.h
Go to the documentation of this file.
1#ifndef STAGE_H
2#define STAGE_H
3
4/*
5 * The stage overlays (AAA/PRO/WSTAG###.PRO), loaded at 0x800A4CA4 on top of
6 * FIELDSTG. Each stage is its own small program; many share the same
7 * functions, built from the same source. Those have the same name in every
8 * stage (config/<version>/stages/<stage>.txt):
9 *
10 * - startStage(owner), FIELDSTG's start of the stage (StageEntry.init in
11 * FIELDSTG_stages, which links it as WSTAGnnn_startStage, include/field/stages.h):
12 * creates the StageTask, updateStage, and runs the stage's setup through
13 * its stageFuncs;
14 * - setupStage(), the first of stageFuncs: fills FIELDSTG_state (FieldState)
15 * with the stage's file, text, map objects, triggers and battles;
16 * - stepAnimation and its kin, the animation steppers.
17 *
18 * The ones whose copies are the same C are in src/field/stages/common/. A stage
19 * with two copies of a function names the second with a 2.
20 */
21
22#include "engine/game.h"
23#include "field/field_map.h"
24
25/* The task a stage starts (startStage), updated by its updateStage */
26typedef struct StageTask {
28 /* 0x50 */ void *owner;
29} StageTask;
30
31/*
32 * Carries the borrow down the digits of GAME.countdown, the timer of the
33 * timed stages: a units digit that went below 0 (255) becomes 9 and takes one
34 * from the digit above. The match depends on this statement macro's do-while.
35 */
36#define COUNTDOWN_BORROW(c) \
37 do { \
38 if (c[2] >= 10) { \
39 c[2] = 9; \
40 c[1]--; \
41 } \
42 if (c[1] >= 10) { \
43 c[1] = 9; \
44 c[0]--; \
45 } \
46 } while (0)
47
48/* Where an exit (StageSlot) leads: copyPlacePoints copies a place's points
49 to the stage's first slots, field by field */
50typedef struct StagePoint {
51 /* 0x00 */ u16 arg; /* the mode */
52 /* 0x02 */ u16 place;
53 /* 0x04 */ u16 placeArg;
54 /* 0x06 */ u16 x;
55 /* 0x08 */ u16 y;
56 /* 0x0A */ u16 dir;
57 /* 0x0C */ struct StagePoint *next;
59
60/* The points of a place (GAME.place and GAME.placeArg, which the exit the
61 player came through set) */
62typedef struct StagePoints {
63 /* 0x00 */ s16 place;
64 /* 0x02 */ s16 placeArg;
65 /* 0x04 */ StagePoint *points;
67
68/* A sprite of a StageEffect: its frame (0 for none) and palette row */
69typedef struct StageSprite {
70 /* 0x0 */ s16 frame;
71 /* 0x2 */ s16 clutRow;
73
74/*
75 * A sprite at (x, y) from the stage's sheet (FieldState.sheetEntry)
76 * with an animated palette, and a second one above it that a one-shot
77 * animation adds to frame (what it is in the game isn't known yet)
78 */
79typedef struct StageEffect {
81 /* 0x50 */ s32 frame;
82 /* 0x54 */ s32 x;
83 /* 0x58 */ s32 y;
84 /* 0x5C */ AnimState anim; /* the one-shot animation */
85 /* 0x60 */ AnimState clutAnim;
86 /* 0x64 */ StageSprite sprites[2]; /* drawn at depth 6 and 4 */
88
89/*
90 * The table of a stage's functions: its setup, then the menu stages' tween
91 * (startTween and updateTween), which opens and closes a menu panel as the
92 * menus' PanelAnim does (shared/start_fade.inc.c, update_fade.inc.c; the
93 * stages' copy sets step before level)
94 */
95typedef struct StageFuncs {
96 /* 0x0 */ void (*setup)(void); /* fills FIELDSTG_state */
97 /* 0x4 */ void (*start)(PanelAnim *tween, s32 up);
98 /* 0x8 */ s32 (*update)(PanelAnim *tween); /* whether it has ended */
100
101/* The task that animates the map objects */
102typedef struct StageTileAnims {
104 /* 0x50 */ AnimState anims[4]; /* as many as the stage uses */
106
107/* A map object with the animation that sets its frame */
108typedef struct StageTileAnim {
109 /* 0x0 */ StageTile *tile;
110 /* 0x4 */ AnimState anim;
112
113/*
114 * Three map objects (animations 1 to 3) moved to
115 * (x, y) and animated once when the substate is set to 1
116 */
117typedef struct StageTileEffect {
119 /* 0x50 */ s32 x;
120 /* 0x54 */ s32 y;
121 /* 0x58 */ StageTileAnim anims[3];
123
124/* The children of a task with one per party slot */
125typedef struct StagePartyChildren {
126 /* 0x0 */ void *party[3];
128
129/*
130 * A map object that wanders around where it starts,
131 * animated, turning every period frames: towards home when it is more than
132 * 30 away, else at random
133 */
134typedef struct StageWanderer {
136 /* 0x50 */ s16 mode; /* 0: hidden, 1: wandering, 2: waiting, 3: slowing down */
137 /* 0x52 */ u8 tileAnim; /* the map object (FieldState.objects) it moves */
138 /* 0x53 */ u8 speedIndex;
139 /* 0x54 */ s32 start; /* the first frame and timer */
140 /* 0x58 */ s32 wait;
141 /* 0x5C */ s32 homeX;
142 /* 0x60 */ s32 homeY;
143 /* 0x64 */ s32 x; /* 8.8 */
144 /* 0x68 */ s32 y;
145 /* 0x6C */ s16 posX; /* x and y >> 8 */
146 /* 0x6E */ s16 posY;
147 /* 0x70 */ s16 timer;
148 /* 0x72 */ s16 period; /* frames between turns */
149 /* 0x74 */ s16 speed;
150 /* 0x76 */ s16 angle; /* 0x1000 a turn */
151 /* 0x78 */ StageTileAnim tile;
153
154/* StageWanderer moving two map objects: tileAnim and tileAnim + 9 */
155typedef struct StageWanderPair {
157 /* 0x50 */ s16 mode;
158 /* 0x52 */ u8 tileAnim;
159 /* 0x53 */ u8 speedIndex;
160 /* 0x54 */ s32 start;
161 /* 0x58 */ s32 wait;
162 /* 0x5C */ s32 homeX;
163 /* 0x60 */ s32 homeY;
164 /* 0x64 */ s32 x;
165 /* 0x68 */ s32 y;
166 /* 0x6C */ s16 posX;
167 /* 0x6E */ s16 posY;
168 /* 0x70 */ s16 timer;
169 /* 0x72 */ s16 period;
170 /* 0x74 */ s16 speed;
171 /* 0x76 */ s16 angle;
172 /* 0x78 */ StageTileAnim tiles[2];
174
175/*
176 * Two map objects (animations 8 and 9) shown while
177 * mode isn't 0, and hidden by a one-shot animation wait frames after mode 2
178 */
179typedef struct StageTileDuo {
181 /* 0x50 */ s16 mode;
182 /* 0x52 */ s16 wait;
183 /* 0x54 */ StageTileAnim tiles[2];
185
186/*
187 * Animates the map objects with animations 1 and 2:
188 * the first alone while running, both when done
189 */
190typedef struct StageTilePair {
192 /* 0x50 */ s32 playing; /* the second animation of the first map object */
193 /* 0x54 */ s32 done; /* start in TASK_DONE */
194 /* 0x58 */ StageTileAnim anims[2];
196
197/* StageTilePair with halfword flags */
198typedef struct StageTilePair16 {
200 /* 0x50 */ s16 playing;
201 /* 0x52 */ s16 done;
202 /* 0x54 */ StageTileAnim anims[2];
204
205/* StageTilePair with byte flags, for the map objects of two given animations */
206typedef struct StageTilePairN {
208 /* 0x50 */ u8 playing;
209 /* 0x51 */ u8 done; /* 1: start in TASK_DONE */
210 /* 0x52 */ s16 anim; /* the map objects' animations: anim and anim + 1 */
211 /* 0x54 */ StageTileAnim anims[2];
213
214/*
215 * A trap's effect over a partner it leaves at 1 HP (events 9000 to 9015 of
216 * WSTAG740 and WSTAG741, on the Fire floor of the dungeon of traps): two sprites from the
217 * stage's sheet at (x, y), each animated once, drawn 0xF0 above and 0x14
218 * below
219 */
220typedef struct StageSpritePair {
222 /* 0x50 */ s32 pad50; /* never read or written */
223 /* 0x54 */ s32 x;
224 /* 0x58 */ s32 y;
225 /* 0x5C */ AnimState anims[2];
226 /* 0x64 */ StageSprite sprites[2];
228
229/* A map object played through a sequence of animations */
230typedef struct StageTileSeq {
231 /* 0x0 */ s16 seq; /* the step playing, 0 when finished */
232 /* 0x2 */ s16 setFrame; /* 0: the animation sets clutRow, else frame */
233 /* 0x4 */ StageTile *tile;
234 /* 0x8 */ AnimState anim;
236
237/* The map objects with animations 1 to 4, sequenced */
242
243/* StageTileSeq with a byte setFrame and a sound to play at frame 0x34 */
244typedef struct StageTileSeq8 {
245 /* 0x0 */ s16 seq;
246 /* 0x2 */ u8 sound; /* 1: play it, once */
247 /* 0x3 */ u8 setFrame;
248 /* 0x4 */ StageTile *tile;
249 /* 0x8 */ AnimState anim;
251
256
257/* A step of a StageTileSeq: its animation, and the step after it ends */
258typedef struct StageSeqStep {
259 /* 0x0 */ AnimFrame *frames;
260 /* 0x4 */ s16 once; /* play once, then go to next */
261 /* 0x6 */ s16 next; /* 0: hide the map object */
263
264/* A frame of a StageTileFrame animation, which sets two frames of a map object */
265typedef struct StageTileFrame {
266 /* 0x0 */ u8 frame;
267 /* 0x1 */ u8 duration;
268 /* 0x2 */ u8 clutRow; /* for StageTile.clutRow */
269 /* 0x3 */ u8 last; /* go to the next animation of the sequence after it */
271
272/* Where a sequence of StageTileFrame animations (NULL-terminated) is at */
273typedef struct StageTileCursor {
274 /* 0x0 */ s16 seq;
275 /* 0x2 */ s16 index;
276 /* 0x4 */ s32 timer;
278
279/*
280 * The map object with animation 1, played once with a
281 * sound when the substate is set to 1 (frame 5 before, 10 after)
282 */
283typedef struct StageSoundTile {
285 /* 0x50 */ s16 voice; /* what SOUND.playSound returned */
286 /* 0x54 */ StageTileAnim obj;
288
289/* A sprite effect a stage creates at (x, y) with the given frame, by kind */
290typedef struct StageEffectSpot {
291 /* 0x0 */ s16 frame;
292 /* 0x2 */ s16 kind;
293 /* 0x4 */ s32 x;
294 /* 0x8 */ s32 y;
296
297/*
298 * What moves a StageFaller or the StageMover of WSTAG415 at (x, y) in 8.8,
299 * and its animation: one layout in both, whose animation the two step
300 * functions, copies of each other, play (stepFallBody loops it,
301 * stepMoverBody holds its last frame)
302 */
303typedef struct StageBody {
304 /* 0x00 */ s32 x;
305 /* 0x04 */ s32 y;
306 /* 0x08 */ s32 vx;
307 /* 0x0C */ s32 vy;
308 /* 0x10 */ s16 timer; /* the mover's frames of falling; a faller never sets it */
309 /* 0x12 */ s16 mode; /* the mover's; a faller's is 1 once it has bounced */
310 /* 0x14 */ AnimState anim;
311} StageBody;
312
313/* A sprite of WSTAG415 that falls from a point of a table, bounces once and dies at the bottom */
314typedef struct StageFaller {
316 /* 0x50 */ s32 frame;
317 /* 0x54 */ s32 x;
318 /* 0x58 */ s32 y;
319 /* 0x5C */ StageBody body;
321
322/* Where a StageFaller starts and how it falls */
323typedef struct StageFallParams {
324 /* 0x0 */ AnimFrame *frames;
325 /* 0x4 */ s16 x;
326 /* 0x6 */ s16 y;
327 /* 0x8 */ s16 floorY;
328 /* 0xA */ s16 vx;
329 /* 0xC */ s16 gravity;
330 /* 0xE */ s16 bounce; /* divides vy when bouncing, 0 for no bounce */
332
333/* The object of WSTAG415 that events 0x331 to 0x334 drive */
334typedef struct StageMover {
336 /* 0x50 */ s32 frame;
337 /* 0x54 */ s32 x;
338 /* 0x58 */ s32 y;
339 /* 0x5C */ StageTile *tile; /* the map object (FieldState.objects) with animation 1 */
340 /* 0x60 */ StageBody body;
341} StageMover;
342
343/* A scrolling background of two images of an archive, moving by (vx, -vy) */
344typedef struct StageScroller {
346 /* 0x50 */ s32 x; /* 8.8 */
347 /* 0x54 */ s32 y;
348 /* 0x58 */ s32 vx;
349 /* 0x5C */ s32 vy;
351
352/* A map object, animated */
357
358/* StageTileDuo with one map object */
359typedef struct StageTileSolo {
361 /* 0x50 */ s16 mode;
362 /* 0x52 */ s16 wait;
363 /* 0x54 */ StageTileAnim tile;
365
366/* The map object with the given animation, moved to (x, y) */
367typedef struct StageTileAt {
369 /* 0x50 */ s32 x;
370 /* 0x54 */ s32 y;
371 /* 0x58 */ s32 anim;
372 /* 0x5C */ StageTileAnim obj;
374
375/* The map object with animation 1 and a frame counter */
381
382/* The map objects with animations 2 to 9 */
387
388/* A frame of a StageRiser's animation; the last (frame 0xFF) sets move */
389typedef struct StageRiserFrame {
390 /* 0x0 */ s16 frame;
391 /* 0x2 */ u8 duration;
392 /* 0x3 */ u8 move;
394
395/* A map object animated and moved by its animation */
396typedef struct StageRiser {
397 /* 0x00 */ s32 y; /* 8.8 */
398 /* 0x04 */ s32 move; /* added to the map object's y */
399 /* 0x08 */ s16 active;
400 /* 0x0A */ s16 tileAnim;
401 /* 0x0C */ AnimState anim;
402 /* 0x10 */ StageTile *tile;
403} StageRiser;
404
405/* A map object that moves by a speed in 8.8 */
406typedef struct StageLift {
407 /* 0x0 */ s16 active;
408 /* 0x2 */ s16 speed;
409 /* 0x4 */ StageTile *tile;
410} StageLift;
411
412/* Map objects that events start moving */
413typedef struct StageRisers {
415 /* 0x050 */ StageRiser risers[11];
416 /* 0x12C */ StageLift lifts[3];
417 /* 0x144 */ s32 timer;
418 /* 0x148 */ s16 pushing; /* moves the player */
419 /* 0x14A */ s16 push;
421
422/* A map object animated while playing is set */
423typedef struct StageTileAnimFlag {
424 /* 0x0 */ StageTile *tile;
425 /* 0x4 */ s32 playing;
426 /* 0x8 */ AnimState anim;
428
429/* Six map objects, animated by mode */
430typedef struct StageTileSix {
432 /* 0x50 */ s32 mode;
433 /* 0x54 */ StageTileAnim tiles[6];
435
436/* StageTileSix with flagged map objects */
442
443/* A sprite that flies off diagonally, animated */
444typedef struct StageFlyer {
446 /* 0x50 */ s32 up; /* else down */
447 /* 0x54 */ s32 right; /* else left; also flips the sprite */
448 /* 0x58 */ s32 still; /* doesn't move or animate */
449 /* 0x5C */ s32 anim;
450 /* 0x60 */ s32 frame;
451 /* 0x64 */ s32 timer;
452 /* 0x68 */ s32 x; /* 8.8 */
453 /* 0x6C */ s32 y;
454} StageFlyer;
455
456/* A brightness that rises from 12 to 28, holds, then falls back */
457typedef struct StageGlow {
459 /* 0x50 */ s32 level;
460} StageGlow;
461
462/* An animation played at (x, y) */
463typedef struct StageAnimSpot {
464 /* 0x0 */ AnimFrame *frames;
465 /* 0x4 */ s16 x;
466 /* 0x6 */ s16 y;
468
469/* Two map objects, animated */
474
475/* Two pictures that change by turns, and the flyers they let out */
476typedef struct StageFlyerGate {
478 /* 0x50 */ s32 left; /* the picture of the first two (0-2) */
479 /* 0x54 */ s32 right; /* the picture of the third (0-2) */
480 /* 0x58 */ s32 spawnA; /* let out the first set of flyers */
481 /* 0x5C */ s32 spawnB; /* let out the second set */
483
484/* An animation of a table of byte pairs (frame, duration; duration 0 loops to frame) */
485typedef struct StageByteAnim {
486 /* 0x00 */ s32 anim; /* the animation wanted */
487 /* 0x04 */ s32 cur; /* the animation playing */
488 /* 0x08 */ s32 index;
489 /* 0x0C */ s32 frame;
490 /* 0x10 */ s32 timer;
492
493/* Two StageByteAnim animations */
498
499/* A quad of the screen: its corners and what it shows */
500typedef struct StageQuad {
501 /* 0x00 */ s16 x0;
502 /* 0x02 */ s16 y0;
503 /* 0x04 */ s16 x1;
504 /* 0x06 */ s16 y1;
505 /* 0x08 */ s16 x2;
506 /* 0x0A */ s16 y2;
507 /* 0x0C */ s16 x3;
508 /* 0x0E */ s16 y3;
509 /* 0x10 */ s16 kind; /* 0-1: the frame of that animation, else the texture */
510} StageQuad;
511
512/*
513 * A texture of a StageQuad: its page, square at (u, v), and palette. vramX
514 * and vramY, the square's place in VRAM (tpageX + (u & 0xFF) / 4, tpageY +
515 * v, the 4-bit texels four to a halfword), are in the table but nothing reads
516 * them.
517 */
518typedef struct StageQuadTexture {
519 /* 0x00 */ s16 tpageX;
520 /* 0x02 */ s16 tpageY;
521 /* 0x04 */ s16 vramX; /* unused */
522 /* 0x06 */ s16 vramY; /* unused */
523 /* 0x08 */ s16 u;
524 /* 0x0A */ s16 v;
525 /* 0x0C */ u16 clutX;
526 /* 0x0E */ u16 clutY;
528
529/* The map objects with animations 3 and 4, each animated once */
530typedef struct StageTileOnce {
532 /* 0x50 */ s32 pad50; /* never read or written */
535
536/* A frame of a looping animation: after the last (frame 0xFF) it goes back to loop */
537typedef struct StageTileLoopFrame {
538 /* 0x0 */ s16 frame;
539 /* 0x2 */ u8 duration;
540 /* 0x3 */ u8 loop;
542
543/* A frame of a StageFloaterPart's animation, with what it adds to value */
544typedef struct StageFloaterFrame {
545 /* 0x0 */ s16 frame;
546 /* 0x2 */ s16 duration;
547 /* 0x4 */ s32 delta;
549
550/* A sprite of a StageFloater, its animation and what the animation adds up */
551typedef struct StageFloaterPart {
552 /* 0x0 */ s32 value;
554 /* 0x8 */ AnimState anim;
556
557/* A sprite from the stage's sheet at (x, y) that moves up or down in TASK_DONE */
558typedef struct StageFloater {
560 /* 0x50 */ s32 x;
561 /* 0x54 */ s32 y;
562 /* 0x58 */ s32 y8; /* y << 8 while moving */
563 /* 0x5C */ s32 up;
564 /* 0x60 */ StageFloaterPart parts[3];
566
567/* Where a StageFloater is created */
568typedef struct StageFloaterSpot {
569 /* 0x0 */ s32 x;
570 /* 0x4 */ s32 y;
571 /* 0x8 */ s32 up;
573
574/* Sets its children to TASK_DONE one after the other, at the times of a table */
580
581/* The children of a StageFloaterChain */
582typedef struct StageFloaters {
583 /* 0x00 */ StageFloater *floaters[27];
585
586/* The map objects with animations 1 to 4 */
591
592/* The map objects with animations 4 to 1, animated */
593typedef struct StageTileSet {
595 /* 0x50 */ s32 done; /* start in TASK_DONE */
596 /* 0x54 */ StageTile *tiles[4]; /* animations 4, 3, 2 and 1 */
597 /* 0x64 */ AnimState anim;
598 /* 0x68 */ AnimState anim2; /* animation 1's, looping */
600
601/* A sprite drawn over a character (FIELDSTG's actor found by its key) */
602typedef struct StageActorMark {
604 /* 0x50 */ s32 kind;
605 /* 0x54 */ Actor *actor;
607
608/* A frame the task sets on a map object */
609typedef struct StageFrameTask {
611 /* 0x50 */ s32 frame;
612 /* 0x54 */ u8 pad54[8]; /* never read or written: createTask allocates 0x5C bytes */
614
615/* The map objects with animations 1 to 5, each playing a sequence */
620
621/*
622 * The map object with animation 2, animated by
623 * substate, and the StageTileAt children that events set to TASK_DONE
624 */
625typedef struct StageTileSwitch {
627 /* 0x50 */ s32 spawn; /* the child to set to TASK_DONE, + 1 */
628 /* 0x54 */ s32 silent; /* no sound when an event comes */
629 /* 0x58 */ StageTileAnim obj;
631
632/* Where a StageTileAt is created */
633typedef struct StageTileAtSpot {
634 /* 0x0 */ s32 x;
635 /* 0x4 */ s32 y;
636 /* 0x8 */ s32 anim;
638
639/* The children of a StageTileSwitch */
640typedef struct StageTileAts {
641 /* 0x00 */ StageTileAt *tiles[5];
643
644/* A looping animation of a table of byte pairs (frame, duration; frame 0 loops) */
645typedef struct StageBytePlay {
646 /* 0x0 */ s32 frame;
647 /* 0x4 */ s32 index;
648 /* 0x8 */ s32 timer; /* counts up */
650
651/* The animations of sprites drawn all over the stage */
652typedef struct StageSpriteField {
654 /* 0x50 */ StageBytePlay anims[10]; /* nine used */
656
657/* A sprite of the stage: where, which animation, and flipped */
658typedef struct StageSpriteSpot {
659 /* 0x0 */ s16 x; /* 0 ends the table */
660 /* 0x2 */ s16 y;
661 /* 0x4 */ u8 anim;
662 /* 0x5 */ u8 flip;
664
665/* A yes/no menu at the bottom of the screen, a copy of FIELDSTG's ChoiceTask
666 (FIELDSTG_runChoice) without its type; its children are a ChoiceChildren */
667typedef struct StageMenu {
669 /* 0x50 */ s32 cursor;
670 /* 0x54 */ PanelAnim tween;
671} StageMenu; /* 0x64 */
672
673
674/* A list menu whose entries show a message */
675typedef struct StageListMenu {
677 /* 0x50 */ s32 count;
678 /* 0x54 */ s32 cursor;
679 /* 0x58 */ s32 showArrow;
680 /* 0x5C */ s32 arrowFrame;
681 /* 0x60 */ s32 arrowTime;
682 /* 0x64 */ PanelAnim tweens[2]; /* list, message box */
683} StageListMenu; /* 0x84 */
684
685typedef struct StageListMenuChildren {
686 /* 0x00 */ TextWindow *options[8];
687 /* 0x20 */ Cursor *cursor;
688 /* 0x24 */ TextWindow *message;
689} StageListMenuChildren; /* 0x28 */
690
691/*
692 * The menu sprite sheet, and an entry of a text file: the European version
693 * numbers the disc's files differently, and has a copy of each text file per
694 * language, one after the other, so it adds the language (LANGUAGE, which
695 * CNTY_SEL sets) to the file. The Japanese version numbers them as the USA
696 * one, and its text files are the Japanese copies (a stage's text defines
697 * are TEXT_FILE of the USA version's).
698 */
699#if VERSION_US || VERSION_JP
700#define MENU_SPRITES 0x2770000
701#elif VERSION_EU
702#define MENU_SPRITES 0x2860000
703#endif
704#if VERSION_US
705#define TEXT_ENTRY(file, n) ((file) << 16 | (n))
706#elif VERSION_EU || VERSION_JP
707#define TEXT_ENTRY(file, n) ((LANGUAGE << 16) + ((file) << 16 | (n)))
708#endif
709
710/*
711 * The text file of the extra chapter's (WSTAG920-974) menus and events, to
712 * which TEXT_ENTRY adds the language: the European version's copies of it, one
713 * per language, start with the Japanese one (COUNTRY/JPN/MSDMG900.BIN), which
714 * is the Japanese version's
715 */
716#if VERSION_EU
717#define EXTRA_TEXT (TEXT_EVENTS_900 - 1)
718#elif VERSION_JP
719#define EXTRA_TEXT 0x939
720#endif
721
722/*
723 * The files a stage's setup function gives FIELDSTG, numbered differently in
724 * each version, are the stage's own defines: STAGE_TEXT, its text file (the
725 * European version adds the language), and STAGE_FILE, the file whose
726 * entries go to FIELDSTG_map.setFile (STAGE_FILE << 16 | n), its neighbours
727 * usually the files at mapFile and imageFile (STAGE_FILE_8 and STAGE_ARCHIVE
728 * otherwise). EVENT_TEXT_FILE is the text file of the stage's events,
729 * counted from TEXT_FILE(1) as FieldEvent.text is.
730 */
731/* An entry of the stage's events' text file, for FieldEvent.text */
732#define EVENT_TEXT(n) (EVENT_TEXT_FILE << 16 | (n))
733
734/* The sounds the stages play, with SOUNDTST's names (engine/sound.h has the
735 ones the overlays share) */
736#define SOUND_MTL_DOWN 0x40012
737#define SOUND_COMAT102 0x8004213E
738#define SOUND_COMAT103 0x800421BF
739#define SOUND_COMEX105 0x800442C1
740#define SOUND_COMEX112 0x80044648
741#define SOUND_COMEX114 0x8004474A
742#define SOUND_BULB_000 0x340001
743#define SOUND_BULB_001 0x340002
744#define SOUND_GONDRA_B 0x340003
745#define SOUND_BULB_002 0x4C0001
746#define SOUND_FLOOR_LT 0x4C0002
747#define SOUND_DIGITAMA 0x540001
748#define SOUND_SE000000 0xA40004
749#define SOUND_DOOROPEN 0x80A4203C
750#define SOUND_LOGINEF 0xCC0001
751#define SOUND_FLOOR_DN 0xEC0001
752#define SOUND_ENTRY_02 0x1000000
753#define SOUND_SIGNALON 0x1000002
754#define SOUND_DOORCLSE 0x8100303C
755#define SOUND_CCOMBINE 0x8100383C
756#define SOUND_DIGI_EN0 0x10C0000
757#define SOUND_DIGI_EN1 0x10C0001
758#define SOUND_DIGI_EN2 0x10C0002
759
760
761/*
762 * The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
763 * updateStage takes the task, and in some stages its children too.
764 */
766void setupStage(void);
767
768/* The stage's functions (common/start_stage.inc.c calls the first): a
769 StageFuncs in the stages with a tween, which define STAGE_TWEEN before
770 they include this file, and in the others an array of just setupStage */
771#ifdef STAGE_TWEEN
773#else
774extern void (*stageFuncs[])(void);
775#endif
776
777/* The tables and color setupStage gives FIELDSTG_state (FieldState) */
778extern StageTile stageObjects[];
779extern StageSlot stageSlots[];
780extern ActorImage stageImages[];
782extern const CVECTOR stageColor;
783extern FieldEvent stageEvents[];
785
786/* Names some stages define */
787extern StagePoints *placePoints[];
788extern AnimFrame effectFrames[];
792
793#endif /* STAGE_H */
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
#define TASK_HEADER(Type)
Definition task.h:39
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag211.c:585
AnimFrame effectClutFrames[]
Definition wstag311.c:1046
const CVECTOR stageColor
the color the setup copies to FIELDSTG_state.spriteColor
Definition wstag211.c:23
FieldActorEntry * stageActors[]
Definition wstag211.c:460
void updateTileAnims(StageTileAnims *task)
Animates the map objects of animation 1 with updateTileAnimsFrames, stepped again for each map object...
ActorImage stageImages[]
Definition wstag211.c:152
void setupStage(void)
Sets the stage up: its map, actors, battles and events, playing KANRIBGM; BGM_0029 instead except at ...
Definition wstag211.c:37
AnimFrame effectFrames[]
Definition wstag311.c:1050
StagePoints * placePoints[]
Names some stages define.
Definition wstag825.c:69
StageEffect * createStageEffect(s32 x, s32 y, s32 frame)
Creates a StageEffect at (x, y) with its sprites' frames from FRAME.
StageTile stageObjects[]
The tables and color setupStage gives FIELDSTG_state (FieldState)
Definition wstag211.c:500
StageSlot stageSlots[]
Definition wstag211.c:575
void updateStage()
The names every stage defines, each its own (config/<version>/stages/<stage>.txt).
FieldBattles stageBattles[]
Definition wstag211.c:149
FieldEvent stageEvents[]
Definition wstag211.c:588
What the stage overlays and the executable use of FIELDSTG (fieldstg.h has the rest): its layers and ...
Where an actor's frames go in VRAM: one of the records after the FieldImage (Actor....
Definition field_map.h:114
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
One frame of a sprite animation; frame 0xFF ends it (or loops it)
Definition gfx.h:296
A menu cursor: a text window showing one of the CURSOR_FRAMES glyphs.
Definition text.h:19
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
Opens or closes a menu panel: level goes 0 -> ONE in duration frames (or back at twice the speed),...
Definition menu.h:18
A sprite drawn over a character (FIELDSTG's actor found by its key)
Definition stage.h:602
Actor * actor
Definition stage.h:605
An animation played at (x, y)
Definition stage.h:463
AnimFrame * frames
Definition stage.h:464
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
An animation of a table of byte pairs (frame, duration; duration 0 loops to frame)
Definition stage.h:485
s32 cur
the animation playing
Definition stage.h:487
s32 anim
the animation wanted
Definition stage.h:486
Two StageByteAnim animations.
Definition stage.h:494
StageByteAnim anims[2]
Definition stage.h:496
A looping animation of a table of byte pairs (frame, duration; frame 0 loops)
Definition stage.h:645
s32 timer
counts up
Definition stage.h:648
A sprite effect a stage creates at (x, y) with the given frame, by kind.
Definition stage.h:290
A sprite at (x, y) from the stage's sheet (FieldState.sheetEntry) with an animated palette,...
Definition stage.h:79
s32 x
Definition stage.h:82
s32 frame
Definition stage.h:81
AnimState anim
the one-shot animation
Definition stage.h:84
StageSprite sprites[2]
drawn at depth 6 and 4
Definition stage.h:86
AnimState clutAnim
Definition stage.h:85
s32 y
Definition stage.h:83
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
StageBody body
Definition stage.h:319
s32 frame
Definition stage.h:316
Sets its children to TASK_DONE one after the other, at the times of a table.
Definition stage.h:575
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
StageFloaterPart parts[3]
Definition stage.h:564
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
Two pictures that change by turns, and the flyers they let out.
Definition stage.h:476
s32 right
the picture of the third (0-2)
Definition stage.h:479
s32 left
the picture of the first two (0-2)
Definition stage.h:478
s32 spawnA
let out the first set of flyers
Definition stage.h:480
s32 spawnB
let out the second set
Definition stage.h:481
A sprite that flies off diagonally, animated.
Definition stage.h:444
s32 frame
Definition stage.h:450
s32 anim
Definition stage.h:449
s32 timer
Definition stage.h:451
s32 right
else left; also flips the sprite
Definition stage.h:447
s32 up
else down
Definition stage.h:446
s32 y
Definition stage.h:453
s32 still
doesn't move or animate
Definition stage.h:448
s32 x
8.8
Definition stage.h:452
A frame the task sets on a map object.
Definition stage.h:609
u8 pad54[8]
never read or written: createTask allocates 0x5C bytes
Definition stage.h:612
The table of a stage's functions: its setup, then the menu stages' tween (startTween and updateTween)...
Definition stage.h:95
void(* start)(PanelAnim *tween, s32 up)
Definition stage.h:97
void(* setup)(void)
fills FIELDSTG_state
Definition stage.h:96
s32(* update)(PanelAnim *tween)
whether it has ended
Definition stage.h:98
A brightness that rises from 12 to 28, holds, then falls back.
Definition stage.h:457
s32 level
Definition stage.h:459
A map object that moves by a speed in 8.8.
Definition stage.h:406
StageTile * tile
Definition stage.h:409
s16 active
Definition stage.h:407
s16 speed
Definition stage.h:408
TextWindow * message
Definition stage.h:688
TextWindow * options[8]
Definition stage.h:686
A list menu whose entries show a message.
Definition stage.h:675
s32 arrowFrame
Definition stage.h:680
PanelAnim tweens[2]
list, message box
Definition stage.h:682
s32 showArrow
Definition stage.h:679
s32 arrowTime
Definition stage.h:681
A yes/no menu at the bottom of the screen, a copy of FIELDSTG's ChoiceTask (FIELDSTG_runChoice) witho...
Definition stage.h:667
PanelAnim tween
Definition stage.h:670
s32 cursor
Definition stage.h:669
The object of WSTAG415 that events 0x331 to 0x334 drive.
Definition stage.h:334
StageTile * tile
the map object (FieldState.objects) with animation 1
Definition stage.h:339
s32 frame
Definition stage.h:336
StageBody body
Definition stage.h:340
s32 x
Definition stage.h:337
s32 y
Definition stage.h:338
The children of a task with one per party slot.
Definition stage.h:125
void * party[3]
Definition stage.h:126
Where an exit (StageSlot) leads: copyPlacePoints copies a place's points to the stage's first slots,...
Definition stage.h:50
u16 arg
the mode
Definition stage.h:51
struct StagePoint * next
Definition stage.h:57
u16 place
Definition stage.h:52
u16 placeArg
Definition stage.h:53
u16 y
Definition stage.h:55
u16 dir
Definition stage.h:56
u16 x
Definition stage.h:54
The points of a place (GAME.place and GAME.placeArg, which the exit the player came through set)
Definition stage.h:62
s16 place
Definition stage.h:63
StagePoint * points
Definition stage.h:65
s16 placeArg
Definition stage.h:64
A texture of a StageQuad: its page, square at (u, v), and palette.
Definition stage.h:518
s16 vramY
unused
Definition stage.h:522
s16 vramX
unused
Definition stage.h:521
A quad of the screen: its corners and what it shows.
Definition stage.h:500
s16 x1
Definition stage.h:503
s16 x2
Definition stage.h:505
s16 y3
Definition stage.h:508
s16 x0
Definition stage.h:501
s16 x3
Definition stage.h:507
s16 y1
Definition stage.h:504
s16 y0
Definition stage.h:502
s16 kind
0-1: the frame of that animation, else the texture
Definition stage.h:509
s16 y2
Definition stage.h:506
A frame of a StageRiser's animation; the last (frame 0xFF) sets move.
Definition stage.h:389
A map object animated and moved by its animation.
Definition stage.h:396
s16 tileAnim
Definition stage.h:400
s32 move
added to the map object's y
Definition stage.h:398
s32 y
8.8
Definition stage.h:397
StageTile * tile
Definition stage.h:402
s16 active
Definition stage.h:399
AnimState anim
Definition stage.h:401
Map objects that events start moving.
Definition stage.h:413
StageRiser risers[11]
Definition stage.h:415
s16 push
Definition stage.h:419
StageLift lifts[3]
Definition stage.h:416
s32 timer
Definition stage.h:417
s16 pushing
moves the player
Definition stage.h:418
A scrolling background of two images of an archive, moving by (vx, -vy)
Definition stage.h:344
s32 x
8.8
Definition stage.h:346
A step of a StageTileSeq: its animation, and the step after it ends.
Definition stage.h:258
AnimFrame * frames
Definition stage.h:259
s16 next
0: hide the map object
Definition stage.h:261
s16 once
play once, then go to next
Definition stage.h:260
What the player can trigger on a map (FIELDSTG_updateTriggers): a record of the table at FieldState....
Definition field_map.h:276
The map object with animation 1, played once with a sound when the substate is set to 1 (frame 5 befo...
Definition stage.h:283
StageTileAnim obj
Definition stage.h:286
s16 voice
what SOUND.playSound returned
Definition stage.h:285
The animations of sprites drawn all over the stage.
Definition stage.h:652
StageBytePlay anims[10]
nine used
Definition stage.h:654
A trap's effect over a partner it leaves at 1 HP (events 9000 to 9015 of WSTAG740 and WSTAG741,...
Definition stage.h:220
s32 pad50
never read or written
Definition stage.h:222
AnimState anims[2]
Definition stage.h:225
StageSprite sprites[2]
Definition stage.h:226
A sprite of the stage: where, which animation, and flipped.
Definition stage.h:658
s16 x
0 ends the table
Definition stage.h:659
A sprite of a StageEffect: its frame (0 for none) and palette row.
Definition stage.h:69
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 * owner
Definition stage.h:28
A map object animated while playing is set.
Definition stage.h:423
StageTile * tile
Definition stage.h:424
AnimState anim
Definition stage.h:426
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
The task that animates the map objects.
Definition stage.h:102
AnimState anims[4]
as many as the stage uses
Definition stage.h:104
Where a StageTileAt is created.
Definition stage.h:633
The map object with the given animation, moved to (x, y)
Definition stage.h:367
StageTileAnim obj
Definition stage.h:372
s32 anim
Definition stage.h:371
The children of a StageTileSwitch.
Definition stage.h:640
StageTileAt * tiles[5]
Definition stage.h:641
Where a sequence of StageTileFrame animations (NULL-terminated) is at.
Definition stage.h:273
The map objects with animations 1 to 5, each playing a sequence.
Definition stage.h:616
StageTileCursor cursors[5]
Definition stage.h:618
Two map objects (animations 8 and 9) shown while mode isn't 0, and hidden by a one-shot animation wai...
Definition stage.h:179
StageTileAnim tiles[2]
Definition stage.h:183
Three map objects (animations 1 to 3) moved to (x, y) and animated once when the substate is set to 1...
Definition stage.h:117
StageTileAnim anims[3]
Definition stage.h:121
A frame of a StageTileFrame animation, which sets two frames of a map object.
Definition stage.h:265
u8 last
go to the next animation of the sequence after it
Definition stage.h:269
u8 clutRow
for StageTile.clutRow
Definition stage.h:268
The map objects with animations 2 to 9.
Definition stage.h:383
StageTile * tiles[8]
Definition stage.h:385
Two map objects, animated.
Definition stage.h:470
StageTileAnim tiles[2]
Definition stage.h:472
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 3 and 4, each animated once.
Definition stage.h:530
s32 pad50
never read or written
Definition stage.h:532
StageTileAnimFlag tiles[2]
Definition stage.h:533
StageTilePair with halfword flags.
Definition stage.h:198
StageTileAnim anims[2]
Definition stage.h:202
StageTilePair with byte flags, for the map objects of two given animations.
Definition stage.h:206
StageTileAnim anims[2]
Definition stage.h:211
s16 anim
the map objects' animations: anim and anim + 1
Definition stage.h:210
u8 done
1: start in TASK_DONE
Definition stage.h:209
Animates the map objects with animations 1 and 2: the first alone while running, both when done.
Definition stage.h:190
StageTileAnim anims[2]
Definition stage.h:194
s32 done
start in TASK_DONE
Definition stage.h:193
s32 playing
the second animation of the first map object
Definition stage.h:192
The map objects with animations 1 to 4.
Definition stage.h:587
StageTileAnim anims[4]
Definition stage.h:589
StageTileSeq with a byte setFrame and a sound to play at frame 0x34.
Definition stage.h:244
StageTile * tile
Definition stage.h:248
u8 sound
1: play it, once
Definition stage.h:246
AnimState anim
Definition stage.h:249
A map object played through a sequence of animations.
Definition stage.h:230
StageTile * tile
Definition stage.h:233
s16 seq
the step playing, 0 when finished
Definition stage.h:231
s16 setFrame
0: the animation sets clutRow, else frame
Definition stage.h:232
AnimState anim
Definition stage.h:234
StageTileSeq8 entries[4]
Definition stage.h:254
The map objects with animations 1 to 4, sequenced.
Definition stage.h:238
StageTileSeq entries[4]
Definition stage.h:240
The map objects with animations 4 to 1, animated.
Definition stage.h:593
AnimState anim2
animation 1's, looping
Definition stage.h:598
AnimState anim
Definition stage.h:597
StageTile * tiles[4]
animations 4, 3, 2 and 1
Definition stage.h:596
s32 done
start in TASK_DONE
Definition stage.h:595
StageTileSix with flagged map objects.
Definition stage.h:437
StageTileAnimFlag tiles[6]
Definition stage.h:440
Six map objects, animated by mode.
Definition stage.h:430
StageTileAnim tiles[6]
Definition stage.h:433
StageTileDuo with one map object.
Definition stage.h:359
StageTileAnim tile
Definition stage.h:363
The map object with animation 2, animated by substate, and the StageTileAt children that events set t...
Definition stage.h:625
s32 silent
no sound when an event comes
Definition stage.h:628
StageTileAnim obj
Definition stage.h:629
s32 spawn
the child to set to TASK_DONE, + 1
Definition stage.h:627
A map object, animated.
Definition stage.h:353
StageTileAnim obj
Definition stage.h:355
The map object with animation 1 and a frame counter.
Definition stage.h:376
StageTile * tile
Definition stage.h:378
An object of a map, which FIELDSTG draws: a record of the table at FieldState.objects,...
Definition field_map.h:208
StageWanderer moving two map objects: tileAnim and tileAnim + 9.
Definition stage.h:155
StageTileAnim tiles[2]
Definition stage.h:172
A map object that wanders around where it starts, animated, turning every period frames: towards home...
Definition stage.h:134
s32 start
the first frame and timer
Definition stage.h:139
u8 tileAnim
the map object (FieldState.objects) it moves
Definition stage.h:137
s32 x
8.8
Definition stage.h:143
s16 posX
x and y >> 8
Definition stage.h:145
s16 angle
0x1000 a turn
Definition stage.h:150
s16 mode
0: hidden, 1: wandering, 2: waiting, 3: slowing down
Definition stage.h:136
u8 speedIndex
Definition stage.h:138
StageTileAnim tile
Definition stage.h:151
s16 period
frames between turns
Definition stage.h:148
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131