Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
field.c
Go to the documentation of this file.
1/* The field's main task: it sets the field up, runs it, and closes it for a
2 battle or another mode, and what the executable, the stages and the actors
3 ask of it: an encounter, an event, the inn or a warp. It's one object
4 because startEncounter's jump tables follow FIELDSTG_updateField's with a gap that
5 only the same object's 8-byte alignment makes */
6
7#include "field/field_mode.h"
8
9/* Has the battle's files read while the transition plays */
10static inline void requestBattleFiles(void) {
11#if VERSION_US || VERSION_JP
12 FILE_CACHE.request(0x1BD);
13 FILE_CACHE.request(0x1BE);
14 FILE_CACHE.request(0xBE);
15 FILE_CACHE.request(0x1FA);
16 FILE_CACHE.request(0x159);
17#elif VERSION_EU
18 FILE_CACHE.request(0x1CB);
19 FILE_CACHE.request(0x1CC);
20 FILE_CACHE.request(0x1CF);
21 FILE_CACHE.request(0x208);
22 FILE_CACHE.request(0x167);
23#endif
24}
25
26/* Puts the transition's tiles where they cover the screen */
27static inline void placeTransitionTiles(void) {
28 s32 row;
29 s32 col;
30
31 for (row = 0; row < TRANSITION_ROWS; row++) {
32 for (col = 0; col < TRANSITION_COLUMNS; col++) {
33 FIELDSTG_tiles[col][row].x = col * TRANSITION_TILE_WIDTH;
34 FIELDSTG_tiles[col][row].y = row * TRANSITION_TILE_HEIGHT;
35 }
36 }
37}
38
39/* Asks for the battle's files once the CD has been free on two frames */
40static inline void waitToRequestBattleFiles(void) {
42 case 0:
43 if (CD_READER.isBusy() == 0) {
45 }
46 break;
47 case 1:
48 if (CD_READER.isBusy() == 0) {
51 }
52 break;
53 }
54}
55
56/*
57 * On a frame the GPU draws the first buffer, moves the next tile
58 * (FIELDSTG_tileMoves[counter]) out of the screen; after the last one,
59 * waits TRANSITION_WAIT frames and asks for the battle's mode
60 */
61static inline void moveTransitionTile(FieldTask *task, s32 speed) {
62 s32 more;
63
64 do {
65 TileMove *move = &FIELDSTG_tileMoves[task->counter];
66
67 if (GFX.buffer != 0) {
68 break;
69 }
70 if (move->dir != 0) {
71 *move->value += speed * move->dir;
72 if (move->dir >= 0) {
73 more = move->limit > *move->value;
74 } else {
75 more = *move->value > move->limit;
76 }
77 if (!more) {
78 *move->value = TRANSITION_GONE;
79 task->tickCounter(task);
80 }
81 } else {
83 if (++task->step >= TRANSITION_WAIT) {
84 if (task->step < TRANSITION_DONE) {
86 }
87 task->step = TRANSITION_DONE;
88 }
89 }
90 } while (0);
91}
92
93/*
94 * The field's battle transition: the screen breaks into TRANSITION_COLUMNS by
95 * TRANSITION_ROWS tiles that slide off in a spiral (FIELDSTG_tileMoves, one move per counter step), then it
96 * requests the battle's mode. The match depends on the move being an early
97 * exit, a do-while (0) that breaks while the buffer is busy, with move
98 * declared in it: the block's note stops stmt.c from rolling the exit test
99 * to the loop's end, and the loop notes make the GFX.buffer load wait for
100 * the counter's in the second scheduler.
101 */
103 Task **children = (Task **)fieldChildren; /* all of them, as a list of tasks to kill */
104 Layer *layer;
105 u_long *ot;
106 s32 speed;
107 PrimPtr prim;
108 s32 i;
109 s32 j;
110 s32 k;
111 s16 x;
112 s16 y;
113
114 switch (task->substate) {
115 case 0:
120 layer->setBgColor(layer, 0, 0, 0);
122 layer->setBgColor(layer, 0, 0, 0);
124 GAME.fieldPos = fieldChildren->actors[0]->pos;
125 GAME.fieldDir = fieldChildren->actors[0]->dir;
127 SOUND.stopAll();
129 for (k = 0; k < task->childCount; k++) {
130 if (*children != NULL) {
131 (*children)->setState(*children, TASK_KILL);
132 }
133 children++;
134 }
136 task->nextSubstate(task);
137 /* fallthrough */
138 case 1:
141 ot = layer->getOtEntry(layer, 0);
143 moveTransitionTile(task, speed);
144 if (task->step != TRANSITION_DONE) {
145 prim.any = GFX.funcs.getPrim();
146 setRGB0(prim.f4, 0x10, 0x10, 0x10);
147 setPolyF4(prim.f4);
148 setSemiTrans(prim.f4, 1);
149 prim.f4->x0 = 0;
150 prim.f4->x1 = SCREEN_WIDTH;
151 prim.f4->x2 = 0;
152 prim.f4->x3 = SCREEN_WIDTH;
153 prim.f4->y0 = 0;
154 prim.f4->y1 = 0;
155 prim.f4->y2 = SCREEN_HEIGHT;
156 prim.f4->y3 = SCREEN_HEIGHT;
157 addPrim(ot, prim.f4);
158 prim.f4++;
159 setDrawTPage(prim.tpage, 0, 1, getTPage(0, 2, 320, 0));
160 addPrim(ot, prim.tpage);
161 prim.tpage++;
162 for (i = 0; i < TRANSITION_ROWS; i++) {
163 for (j = 0; j < TRANSITION_COLUMNS; j++) {
164 if (FIELDSTG_tiles[j][i].x != TRANSITION_GONE && FIELDSTG_tiles[j][i].y != TRANSITION_GONE) {
165 setPolyFT4(prim.ft4);
166 setSemiTrans(prim.ft4, 1);
167 setRGB0(prim.ft4, 0x80, 0x80, 0x80);
168 x = FIELDSTG_tiles[j][i].x;
169 prim.ft4->x0 = prim.ft4->x2 = x;
170 prim.ft4->x1 = prim.ft4->x3 = x + TRANSITION_TILE_WIDTH;
171 y = FIELDSTG_tiles[j][i].y;
172 prim.ft4->u0 = 0;
173 prim.ft4->u1 = TRANSITION_TILE_WIDTH;
174 prim.ft4->u2 = 0;
175 prim.ft4->u3 = TRANSITION_TILE_WIDTH;
176 prim.ft4->v0 = i * TRANSITION_TILE_HEIGHT;
177 prim.ft4->v1 = i * TRANSITION_TILE_HEIGHT;
180 prim.ft4->y0 = prim.ft4->y1 = y;
181 prim.ft4->y2 = prim.ft4->y3 = y + TRANSITION_TILE_HEIGHT;
182 prim.ft4->tpage = getTPage(2, 0, TRANSITION_IMAGE_X + j * TRANSITION_TILE_WIDTH, 0);
183 addPrim(ot, prim.ft4);
184 prim.ft4++;
185 }
186 }
187 }
188 GFX.funcs.setPrim(prim.ft4);
189 } else {
190 task->nextSubstate(task);
191 }
192 break;
193 case 2:
194 break;
195 }
196}
197
198/* Closes the field for the next mode: the view shrinks to nothing, the cover
199 fades in, and the mode is requested with where the player stands */
201 Vec2 clip;
202 Layer *layer;
203 Actor *actor;
204 Actor *player;
205 s32 width;
206 s32 height;
207
208 switch (task->substate) {
209 default:
210 case 0:
212 player = TASK_REGISTRY.funcs.find(FIELD_TASK_ACTOR, -1, 0);
213 if (player != NULL && player->tile.x != 0) {
214 task->centerOnPlayer = 1;
215 } else {
216 task->centerOnPlayer = 0;
217 }
218 task->width = SCREEN_WIDTH;
219 task->fade = 0;
220 task->height = SCREEN_HEIGHT;
221 task->nextSubstate(task);
222 /* fallthrough */
223 case 1:
225 layer->setBgColor(layer, 1, 1, 1);
226 task->width -= 10;
227 task->height -= 7;
228 if (task->width <= 0) {
229 layer->setBgColor(layer, 0, 0, 0);
230 task->width = 0;
231 task->height = 0;
232 task->nextSubstate(task);
233 }
235 layer->getScroll(layer, &clip);
236 if (task->centerOnPlayer != 0) {
237 clip.x = actor->tile.x - clip.x;
238 clip.y = actor->tile.y - clip.y;
239 } else {
240 clip.x = SCREEN_WIDTH / 2;
241 clip.y = SCREEN_HEIGHT / 2;
242 }
243 clip.x -= task->width / 2;
244 if (clip.x < 0) {
245 clip.x = 0;
246 }
247 clip.y -= task->height / 2;
248 if (clip.y < 0) {
249 clip.y = 0;
250 }
251 layer->setClipPos(layer, clip.x, clip.y);
252 width = task->width;
253 height = task->height;
254 if (clip.x + width > SCREEN_WIDTH) {
255 width = SCREEN_WIDTH - clip.x;
256 }
257 if (clip.y + height > SCREEN_HEIGHT) {
258 height = SCREEN_HEIGHT - clip.y;
259 }
260 layer->setClipSize(layer, width, height);
262 if (task->fade != 0x8000) {
263 task->fade += 0x400;
264 }
265 break;
266 case 2:
268 switch (task->step) {
269 default:
270 case 0:
271 task->width = 0;
272 task->height = 0;
273 task->step++;
274 case 1:
275 break;
276 }
277 task->width += 8;
278 layer->setClipPos(layer, task->width, task->height);
279 layer->setClipSize(layer, (SCREEN_WIDTH / 2 - task->width) * 2, (SCREEN_HEIGHT / 2 - task->height) * 2);
280 if (task->width > SCREEN_WIDTH / 2) {
283 GAME.fieldPos = children->actors[0]->pos;
284 GAME.fieldDir = children->actors[0]->dir;
285 task->nextSubstate(task);
286 }
288 break;
289 case 3:
290 break;
291 }
292}
293
294/* Whether the mode is FIELD_MODE_WSTAG415 or FIELD_MODE_WSTAG815, whose field
295 keeps the file cache and doesn't take the high buffer */
298 return 1;
299 }
301}
302
303/* Sets the screen up for the field: the display and its layers */
304static inline void setUpFieldScreen(void) {
305 RECT rect;
306 Layer *layer;
307
308 GFX.funcs.reset();
309 GFX.funcs.allocPrimBuffers(0x6400);
311 rect.x = 0;
312 rect.y = 0;
313 rect.w = SCREEN_WIDTH;
314 rect.h = SCREEN_HEIGHT;
315 layer = GFX.funcs.createLayer(&rect, 1, FIELD_LAYER_BACK);
316 layer->setBgColor(layer, 1, 1, 1);
318 layer = GFX.funcs.createLayer(&rect, 4, FIELD_LAYER_MAP);
319 layer->allocCallbacks(layer, 0x32);
321 layer = GFX.funcs.createLayer(&rect, 1, FIELD_LAYER_BANNER);
322 layer->setBgColor(layer, 1, 1, 1);
323}
324
325/* Creates the map's characters (FieldState.actors but the player's) whose
326 conditions hold, where their entries put them */
327static inline void createCharacters(FieldChildren *children) {
328 FieldActorEntry **npcList;
329 FieldActorEntry *npc;
330 s32 i;
331
332 npcList = FIELDSTG_state.actors;
333 if (npcList != NULL) {
334 i = 0;
335 while (*npcList != NULL) {
336 npc = *npcList;
337 switch (npc->id) {
338 case 1:
339 case 0x6A:
340 case 0x146:
341 case 0x147:
342 break;
343 default:
344 if (npc->conditions == NULL || FLAGS_00.checkConditions(npc->conditions) != 0) {
345 children->npcs[i] = FIELDSTG_createActor(npc->id, 1, npc->image, npc);
346 children->npcs[i]->pos.x = npc->x << 8;
347 children->npcs[i]->pos.y = npc->y << 8;
348 children->npcs[i]->dir = npc->dir;
349 i++;
350 }
351 break;
352 }
353 npcList++;
354 }
355 }
356}
357
358/* Ends the player, the partners and the map's characters */
359static inline void killCharacters(FieldChildren *children) {
360 s32 i;
361
362 for (i = 0; i < 4; i++) {
363 if (children->actors[i] != NULL) {
364 children->actors[i]->setState(children->actors[i], TASK_KILL);
365 }
366 }
367 for (i = 0; i < 15; i++) {
368 if (children->npcs[i] != NULL) {
369 children->npcs[i]->setState(children->npcs[i], TASK_KILL);
370 }
371 }
372}
373
374/* Creates the player: the first of the characters 1, 0x6A, 0x146 and 0x147
375 in FieldState.actors whose conditions hold, or the player and the party's
376 partners */
377static inline void createParty(FieldChildren *children) {
378 FieldActorEntry **list;
379 FieldActorEntry *entry;
380 s32 id;
381
382 do {
383 list = FIELDSTG_state.actors;
384 id = 0;
385 if (list != NULL) {
386 while (*list != NULL) {
387 entry = *list;
388 switch (entry->id) {
389 case 1:
390 case 0x6A:
391 case 0x146:
392 case 0x147:
393 if (entry->conditions == NULL || FLAGS_00.checkConditions(entry->conditions) == 1) {
394 id = entry->id;
395 }
396 break;
397 }
398 if (id != 0) {
399 break;
400 }
401 list++;
402 }
403 }
404 if (id != 0) {
405 children->actors[0] = FIELDSTG_createActor(id, 0, 0, NULL);
406 break;
407 }
410 if (GAME.funcs.getPartyPartner(0) >= 0) {
412 }
413 if (GAME.funcs.getPartyPartner(1) >= 0) {
415 }
416 if (GAME.funcs.getPartyPartner(2) >= 0) {
418 }
419 }
420 } while (0);
421}
422
423/*
424 * The warp's steps: its effect and sound, a fade out after 0x3C, the
425 * field's characters, map and objects killed while the warp's cutscene
426 * plays, then the field left for the warp's mode and place
427 */
428static inline void warpAway(FieldTask *task, FieldChildren *children) {
429 switch (task->step) {
430 case 0:
431 default:
432 children->effect = FIELDSTG_createEffect(task->warpPos.x, task->warpPos.y, task->warpKind);
434 task->nextStep(task);
435 /* fallthrough */
436 case 1:
437 if (task->counter < 0x3C) {
438 task->counter += GFX.funcs.getFrameTime();
439 break;
440 }
442 children->fade->start(children->fade, 0, 0x14);
443 task->nextStep(task);
444 /* fallthrough */
445 case 2:
446 if (children->fade->state == TASK_DONE) {
447 killCharacters(children);
448 children->mapStreamer->setState(children->mapStreamer, TASK_KILL);
449 children->mapObjects->setState(children->mapObjects, TASK_KILL);
451 children->fade->start(children->fade, 1, 0x14);
452 task->nextStep(task);
453 }
454 break;
455 case 3:
456 if (children->cutscene->state == TASK_DONE) {
457 GAME.place = task->warp->place;
458 GAME.placeArg = task->warp->placeArg;
459 FIELDSTG_leaveField(task->warp->mode, -1, task->warp->x << 8, task->warp->y << 8, task->warp->dir);
460 }
461 break;
462 }
463}
464
465/*
466 * From the STORY_GENJI_BEATEN on, START opens the field menu (STSTATUS) while
467 * the field is idle; the player's place is kept to come back to
468 */
469static inline void openFieldMenu(FieldTask *task, FieldChildren *children) {
471 do {
472 if (GAME.progress < STORY_GENJI_BEATEN || !(PAD.getPressed(0) & (1 << PAD_START))) {
473 break;
474 }
477 children->menu = createFieldMenu(FIELD_LAYER_MAP, 0);
479 GAME.fieldPos = children->actors[0]->pos;
480 GAME.fieldDir = children->actors[0]->dir;
481 children->actors[0]->setSubstate(children->actors[0], ACTOR_STAND);
483 task->nextSubstate(task);
484 } while (0);
485 }
486}
487
488/*
489 * The field's first step: the file cache and the screen set up, the stage's
490 * overlay loaded and started, the mode's visited flag set, the player's
491 * start taken from where the field was left, and the banner created
492 */
493static inline void startField(FieldTask *task, FieldChildren *children) {
494 s32 mode;
495
496 if (FIELDSTG_keepsFileCache() == 0) {
497 FILE_CACHE.freeFrom(0x8015C674);
498 }
500 if (FIELDSTG_keepsFileCache() == 0) {
501 task->highBuffer = HEAP.allocHigh(0x9615C, 2);
502 }
503 if (GAME.clearTempFlags == 0) {
505 }
508 if (FIELDSTG_state.stageFile != 0) {
510 }
512 children->stage = FIELDSTG_state.stageInit(task);
513 }
516 mode = GAME.funcs.getPrevMode();
517 /* from other than a field (0x2xx, 0x3xx), STDWTITL,
518 STPLNMET or STAGSLCT, the player comes back
519 where the field was left */
520 if ((mode & 0xFF00) != 0x200 && (mode & 0xFF00) != 0x300 && MODE_OVERLAY(mode) != MODE_TITLE &&
521 mode != MODE_STAGE_SELECT && mode != MODE_PLAYER_NAME) {
522 GAME.modeArg = -1;
525 }
526 children->banner = FIELDSTG_createBanner(1);
527 task->nextSubstate(task);
528}
529
530/*
531 * The field's last loading step: once the CD is free, the high buffer freed
532 * and the map streamer created (unless the file cache is kept), then the
533 * banner told to go once the map runs, and the field runs
534 */
535static inline void showField(FieldTask *task, FieldChildren *children) {
536 if (FIELDSTG_keepsFileCache() == 0) {
537 switch (task->step) {
538 case 0:
539 default:
540 if (CD_READER.isBusy() != 0) {
541 break;
542 }
543 if (task->highBuffer != NULL) {
544 HEAP.free(task->highBuffer);
545 }
547 task->nextStep(task);
548 /* fallthrough */
549 case 1:
550 if (children->mapStreamer->state == TASK_RUN && children->banner->state == TASK_DONE) {
551 children->banner->setSubstate(children->banner, 1);
552 task->nextState(task);
553 }
554 break;
555 }
556 } else if (children->banner->state == TASK_DONE) {
557 children->banner->setSubstate(children->banner, 1);
558 task->nextState(task);
559 }
560}
561
562/*
563 * The field's update: sets up the stage, creates the characters and the
564 * NPCs, then runs the field and opens its menu. The match depends on two
565 * early exits written as do-while (0)s with breaks: one around the leader's
566 * search and the actors it creates (createParty), one around the menu's
567 * opening. flow
568 * weighs the references inside a loop's notes one level more, which is
569 * what ranks the list pointer above the entry it loads, the search's
570 * hoisted 1 above task, and the menu's GAME base above the other saved
571 * registers; written as plain ifs, task takes s3 for s4.
572 */
574 switch (task->state) {
575 case TASK_INIT:
576 default:
577 switch (task->substate) {
578 case 0:
579 default:
580 startField(task, children);
581 /* fallthrough */
582 case 1:
583 switch (task->step) {
584 case 0:
585 default:
586 if (FIELDSTG_state.soundBank != 0) {
588 }
589 task->nextStep(task);
590 /* fallthrough */
591 case 1:
592 if (SOUND.isLoading() == 0) {
593 if (FIELDSTG_state.music != 0) {
595 } else {
597 }
598 task->nextSubstate(task);
599 }
600 break;
601 }
602 break;
603 case 2:
604 switch (task->step) {
605 case 0:
606 default:
608 task->nextStep(task);
609 break;
610 case 1:
611 if (children->awaited.fileLoader == NULL) {
612 task->nextSubstate(task);
613 }
614 break;
615 }
616 break;
617 case 3:
618 if (FIELDSTG_state.objects != NULL) {
620 }
621 if (FIELDSTG_state.slots != NULL) {
623 }
624 createParty(children);
625 createCharacters(children);
626 children->camera = FIELDSTG_createCamera();
627 task->nextSubstate(task);
628 break;
629 case 4:
630 showField(task, children);
631 break;
632 }
633 break;
634 case TASK_RUN:
635 switch (task->substate) {
636 case 0:
637 default:
638 openFieldMenu(task, children);
639 break;
640 case 1:
641 if (children->menu == NULL) {
644 task->setSubstate(task, 0);
645 }
646 break;
647 case 2:
648 if (children->awaited.inn == NULL) {
651 task->setSubstate(task, 0);
652 }
653 break;
654 case 3:
655 warpAway(task, children);
656 break;
657 }
658 break;
659 case TASK_DONE:
661 FIELDSTG_playBattleTransition(task, children);
662 break;
663 }
664 if (task->leaveDelay <= 0) {
666 FIELDSTG_closeField(task, children);
667 break;
668 }
669 task->leaveDelay -= GFX.funcs.getFrameTime();
670 break;
671 case TASK_KILL:
672 break;
673 }
674}
675
676/* Creates the field's main task */
680
681/*
682 * Leaves the field for a mode after a delay: the field task
683 * (FIELD_TASK_FIELD) goes to TASK_DONE, which closes the field (FIELDSTG_closeField) and requests the
684 * mode with its argument. The player comes back to the field at (x, y),
685 * facing dir.
686 */
687void FIELDSTG_leaveFieldAfter(s32 mode, s32 arg, s32 x, s32 y, s32 dir, s32 delay) {
689
690 if (task != NULL) {
691 task->nextMode = mode;
692 task->nextModeArg = arg;
693 task->leaveDelay = delay;
694 task->setState(task, TASK_DONE);
698 }
699}
700
701/* Leaves the field for a mode now (the executable calls it by this name) */
702void FIELDSTG_leaveField(s32 mode, s32 arg, s32 x, s32 y, s32 dir) {
703 FIELDSTG_leaveFieldAfter(mode, arg, x, y, dir, 0);
704}
705
706/* The prize of a battle, an item: the common one, or the rare one when the
707 roll is 0 */
708#define PICK_PRIZE(common, rare) \
709 if (roll != 0) { \
710 BATTLE_SETUP.prize = common; \
711 } else { \
712 BATTLE_SETUP.prize = rare; \
713 }
714
715/* The prize of an odd prize fighter in the stage of the mode: the rare item 1
716 time in 32 */
717static inline void pickOddFighterPrize(s32 mode) {
718 s32 roll = RANDOM.next() & 0x1F;
719
720 switch (mode) {
721 case 0x21D: /* WSTAG330 */
722 default:
723 PICK_PRIZE(0x177, 0x186);
724 break;
725 case 0x22A: /* WSTAG400 */
726 PICK_PRIZE(0x179, 0x186);
727 break;
728 case 0x233: /* WSTAG445 */
729 case 0x235: /* WSTAG455 */
730 case 0x237: /* WSTAG465 */
731 case 0x23A: /* WSTAG480 */
732 case 0x23B: /* WSTAG485 */
733 case 0x23C: /* WSTAG490 */
734 case 0x24A: /* WSTAG565 */
735 case 0x24C: /* WSTAG575 */
736 PICK_PRIZE(0x17A, 0x187);
737 break;
738#if VERSION_EU || VERSION_JP
739 case 0x28C: /* WSTAG331 */
740 if (GAME.progress != STORY_EXTRA) {
741 PICK_PRIZE(0x17C, 0x187);
742 } else { /* WSTAG940 */
743 PICK_PRIZE(0x17F, 0x188);
744 }
745 break;
746 case 0x28D: /* WSTAG336 */
747 if (GAME.progress != STORY_EXTRA) {
748 PICK_PRIZE(0x17C, 0x187);
749 } else { /* WSTAG941 */
750 PICK_PRIZE(0x179, 0x186);
751 }
752 break;
753 case 0x28E: /* WSTAG341 */
754 if (GAME.progress != STORY_EXTRA) {
755 PICK_PRIZE(0x17C, 0x187);
756 } else { /* WSTAG942 */
757 PICK_PRIZE(0x178, 0x186);
758 }
759 break;
760 case 0x28F: /* WSTAG346 */
761 if (GAME.progress != STORY_EXTRA) {
762 PICK_PRIZE(0x17C, 0x187);
763 } else { /* WSTAG943 */
764 PICK_PRIZE(0x17E, 0x188);
765 }
766 break;
767 case 0x290: /* WSTAG351 */
768 if (GAME.progress != STORY_EXTRA) {
769 PICK_PRIZE(0x17C, 0x187);
770 } else { /* WSTAG944 */
771 PICK_PRIZE(0x180, 0x189);
772 }
773 break;
774 case 0x291: /* WSTAG356 */
775 if (GAME.progress != STORY_EXTRA) {
776 PICK_PRIZE(0x17C, 0x187);
777 } else { /* WSTAG945 */
778 PICK_PRIZE(0x181, 0x189);
779 }
780 break;
781 case 0x296: /* WSTAG381 */
782 if (GAME.progress != STORY_EXTRA) {
783 PICK_PRIZE(0x17C, 0x187);
784 } else { /* WSTAG950 */
785 PICK_PRIZE(0x182, 0x189);
786 }
787 break;
788 case 0x298: /* WSTAG396 */
789 if (GAME.progress != STORY_EXTRA) {
790 PICK_PRIZE(0x17C, 0x187);
791 } else { /* WSTAG952 */
792 PICK_PRIZE(0x183, 0x18A);
793 }
794 break;
795 case 0x299: /* WSTAG401 */
796 if (GAME.progress != STORY_EXTRA) {
797 PICK_PRIZE(0x17F, 0x188);
798 } else { /* WSTAG953 */
799 PICK_PRIZE(0x185, 0x18A);
800 }
801 break;
802#else
803 case 0x28C: /* WSTAG331 */
804 case 0x28D: /* WSTAG336 */
805 case 0x28E: /* WSTAG341 */
806 case 0x28F: /* WSTAG346 */
807 case 0x290: /* WSTAG351 */
808 case 0x291: /* WSTAG356 */
809 case 0x296: /* WSTAG381 */
810 case 0x298: /* WSTAG396 */
811 PICK_PRIZE(0x17C, 0x187);
812 break;
813 case 0x299: /* WSTAG401 */
814 PICK_PRIZE(0x17F, 0x188);
815 break;
816#endif
817 case 0x2A1: /* WSTAG446 */
818 case 0x2A3: /* WSTAG456 */
819 case 0x2A4: /* WSTAG466 */
820 case 0x2A7: /* WSTAG481 */
821 case 0x2A8: /* WSTAG486 */
822 case 0x2A9: /* WSTAG491 */
823 PICK_PRIZE(0x180, 0x189);
824 break;
825 case 0x261: /* WSTAG690 */
826 case 0x262: /* WSTAG695 */
827 case 0x265: /* WSTAG710 */
828 case 0x266: /* WSTAG715 */
829 PICK_PRIZE(0x181, 0x189);
830 break;
831 case 0x2B4: /* WSTAG566 */
832 case 0x2B6: /* WSTAG576 */
833 case 0x2C9: /* WSTAG691 */
834 case 0x2CA: /* WSTAG696 */
835 case 0x2CD: /* WSTAG711 */
836 case 0x2CE: /* WSTAG716 */
837 PICK_PRIZE(0x184, 0x18A);
838 break;
839 }
840}
841
842/* The prize of an even prize fighter in the stage of the mode: the rare item 1
843 time in 16 */
844static inline void pickEvenFighterPrize(s32 mode) {
845 s32 roll = RANDOM.next() & 0xF;
846
847 switch (mode) {
848 case 0x201: /* WSTAG202 */
849 default:
850 PICK_PRIZE(0x177, 0x186);
851 break;
852 case 0x234: /* WSTAG450 */
853 case 0x235: /* WSTAG455 */
854 case 0x237: /* WSTAG465 */
855 case 0x23A: /* WSTAG480 */
856 case 0x23B: /* WSTAG485 */
857 case 0x23C: /* WSTAG490 */
858 case 0x23D: /* WSTAG495 */
859 PICK_PRIZE(0x178, 0x186);
860 break;
861 case 0x247: /* WSTAG550 */
862 case 0x249: /* WSTAG560 */
863 case 0x24B: /* WSTAG570 */
864 PICK_PRIZE(0x17B, 0x187);
865 break;
866#if VERSION_EU || VERSION_JP
867 case 0x271: /* WSTAG203 */
868 if (GAME.progress != STORY_EXTRA) {
869 PICK_PRIZE(0x17D, 0x188);
870 } else { /* WSTAG921 */
871 PICK_PRIZE(0x177, 0x186);
872 }
873 break;
874 case 0x28C: /* WSTAG331 */
875 if (GAME.progress != STORY_EXTRA) {
876 PICK_PRIZE(0x17D, 0x188);
877 } else { /* WSTAG940 */
878 PICK_PRIZE(0x17A, 0x187);
879 }
880 break;
881 case 0x28D: /* WSTAG336 */
882 if (GAME.progress != STORY_EXTRA) {
883 PICK_PRIZE(0x17D, 0x188);
884 } else { /* WSTAG941 */
885 PICK_PRIZE(0x179, 0x186);
886 }
887 break;
888 case 0x28E: /* WSTAG341 */
889 if (GAME.progress != STORY_EXTRA) {
890 PICK_PRIZE(0x17D, 0x188);
891 } else { /* WSTAG942 */
892 PICK_PRIZE(0x178, 0x186);
893 }
894 break;
895 case 0x28F: /* WSTAG346 */
896 if (GAME.progress != STORY_EXTRA) {
897 PICK_PRIZE(0x17D, 0x188);
898 } else { /* WSTAG943 */
899 PICK_PRIZE(0x17B, 0x187);
900 }
901 break;
902 case 0x290: /* WSTAG351 */
903 if (GAME.progress != STORY_EXTRA) {
904 PICK_PRIZE(0x17D, 0x188);
905 } else { /* WSTAG944 */
906 PICK_PRIZE(0x184, 0x18A);
907 }
908 break;
909 case 0x296: /* WSTAG381 */
910 if (GAME.progress != STORY_EXTRA) {
911 PICK_PRIZE(0x17D, 0x188);
912 } else { /* WSTAG950 */
913 PICK_PRIZE(0x17C, 0x187);
914 }
915 break;
916 case 0x299: /* WSTAG401 */
917 if (GAME.progress != STORY_EXTRA) {
918 PICK_PRIZE(0x17D, 0x188);
919 } else { /* WSTAG953 */
920 PICK_PRIZE(0x17D, 0x188);
921 }
922 break;
923#else
924 case 0x271: /* WSTAG203 */
925 case 0x28C: /* WSTAG331 */
926 case 0x28D: /* WSTAG336 */
927 case 0x28E: /* WSTAG341 */
928 case 0x28F: /* WSTAG346 */
929 case 0x290: /* WSTAG351 */
930 case 0x296: /* WSTAG381 */
931 case 0x299: /* WSTAG401 */
932 PICK_PRIZE(0x17D, 0x188);
933 break;
934#endif
935 case 0x2A2: /* WSTAG451 */
936 case 0x2A3: /* WSTAG456 */
937 case 0x2A4: /* WSTAG466 */
938 case 0x2A7: /* WSTAG481 */
939 case 0x2A8: /* WSTAG486 */
940 case 0x2A9: /* WSTAG491 */
941 case 0x2AA: /* WSTAG496 */
942 PICK_PRIZE(0x17E, 0x188);
943 break;
944 case 0x266: /* WSTAG715 */
945 PICK_PRIZE(0x182, 0x189);
946 break;
947 case 0x2B1: /* WSTAG551 */
948 case 0x2B3: /* WSTAG561 */
949 case 0x2B5: /* WSTAG571 */
950 PICK_PRIZE(0x183, 0x18A);
951 break;
952 case 0x2CE: /* WSTAG716 */
953 PICK_PRIZE(0x185, 0x18A);
954 break;
955 }
956}
957
958/*
959 * Starts encounter FIELDSTG_encounters[encounter]: the field task
960 * (FIELD_TASK_FIELD) leaves for the battle (MODE_BATTLE, after a movie in the chapter
961 * STORY_MOVIE_BATTLES), and BATTLE_SETUP takes the encounter's
962 * enemies and bytes. A battle led by one of the prize fighters always gives
963 * an item, which the field's stage (named in each case by the stage its mode
964 * loads, FIELDSTG_stages) and a roll pick: the rare item comes 1 in 32
965 * times for the odd fighters and 1 in 16 for the even ones. In the European
966 * version's extra chapter some stages give other items.
967 */
970 s32 i;
971 s32 next;
972 s32 mode;
973
974 if (task != NULL) {
977 next = MODE_BATTLE_MOVIE;
979 next = MODE_BATTLE;
980 }
981 task->nextMode = next;
982 task->nextModeArg = 0;
983 task->setState(task, TASK_DONE);
984 BATTLE_SETUP.battle = encounter;
987 for (i = 0; i < 12; i++) {
989 }
990 for (i = 0; i < 3; i++) {
992 }
997 mode = GAME.funcs.getMode();
998 if (BATTLE_SETUP.enemies[0].fighter & 1) {
1000 } else {
1002 }
1003 }
1004 }
1005}
1006
1007#undef PICK_PRIZE
1008
1009/* Starts battle 5 of the fourth area: the end of the stages' events 9000 */
1012
1013 FIELDSTG_startBattle(battle);
1015 return NULL;
1016}
1017
1018/* Starts the event FIELDSTG_eventIds[index] (the executable calls it) */
1021 FieldChildren *children = field->children;
1022
1023 children->event = FIELDSTG_startEvent(FIELDSTG_eventIds[index]);
1024}
1025
1026/* Opens the inn: the field task waits for it (the executable calls it) */
1029 FieldChildren *children = task->children;
1030
1032 FIELDSTG_state.busy = 1;
1033 children->awaited.inn = createInn(FIELD_LAYER_MAP);
1034 task->setSubstate(task, 2);
1035}
1036
1037/* Starts a warp from pos: the field task plays the effect and the cutscene
1038 of kind, then leaves for the warp's mode */
1039void FIELDSTG_startWarp(s32 kind, Vec2 *pos, SlotDest *dest) {
1041
1042 task->warpKind = kind;
1043 task->warpPos.x = pos->x;
1044 task->warpPos.y = pos->y;
1045 task->warp = dest;
1046 task->setSubstate(task, 3);
1047}
Task * FIELDSTG_createBanner(s32 show)
Creates the area name banner, which closes at once unless show; the player is frozen until it ends.
Definition banner.c:241
Camera * FIELDSTG_createCamera(void)
Creates the camera.
Definition camera.c:139
CdReader CD_READER
The CD reader.
Definition cd_reader.c:10
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
CutsceneAnim * FIELDSTG_createCutsceneAnim(s32 kind)
Creates a cutscene animation of a kind.
Definition cutscene.c:124
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
FieldEffect * FIELDSTG_createEffect(s32 x, s32 y, s32 set)
Creates the effect of a set at (x, y)
Definition effect.c:79
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
Actor * FIELDSTG_createActor(s32 key1, s32 kind, s32 image, FieldActorEntry *entry)
Creates a character (FIELD_TASK_ACTOR): key1 is the character, key2 its kind (0 the player,...
Definition actor.c:128
void FIELDSTG_startListedEvent(s32 index)
Starts the event FIELDSTG_eventIds[index] (the executable calls it)
Definition field.c:1019
void FIELDSTG_openInn(void)
Opens the inn: the field task waits for it (the executable calls it)
Definition field.c:1027
static void moveTransitionTile(FieldTask *task, s32 speed)
On a frame the GPU draws the first buffer, moves the next tile (FIELDSTG_tileMoves[counter]) out of t...
Definition field.c:61
void * FIELDSTG_startEventBattle5(void)
Starts battle 5 of the fourth area: the end of the stages' events 9000.
Definition field.c:1010
static void setUpFieldScreen(void)
Sets the screen up for the field: the display and its layers.
Definition field.c:304
static void killCharacters(FieldChildren *children)
Ends the player, the partners and the map's characters.
Definition field.c:359
static void createCharacters(FieldChildren *children)
Creates the map's characters (FieldState.actors but the player's) whose conditions hold,...
Definition field.c:327
void FIELDSTG_updateField(FieldTask *task, FieldChildren *children)
The field's update: sets up the stage, creates the characters and the NPCs, then runs the field and o...
Definition field.c:573
void FIELDSTG_closeField(FieldTask *task, FieldChildren *children)
Closes the field for the next mode: the view shrinks to nothing, the cover fades in,...
Definition field.c:200
void FIELDSTG_startWarp(s32 kind, Vec2 *pos, SlotDest *dest)
Starts a warp from pos: the field task plays the effect and the cutscene of kind, then leaves for the...
Definition field.c:1039
static void pickEvenFighterPrize(s32 mode)
The prize of an even prize fighter in the stage of the mode: the rare item 1 time in 16.
Definition field.c:844
static void startField(FieldTask *task, FieldChildren *children)
The field's first step: the file cache and the screen set up, the stage's overlay loaded and started,...
Definition field.c:493
static void requestBattleFiles(void)
Has the battle's files read while the transition plays.
Definition field.c:10
void FIELDSTG_leaveField(s32 mode, s32 arg, s32 x, s32 y, s32 dir)
Leaves the field for a mode now (the executable calls it by this name)
Definition field.c:702
static void placeTransitionTiles(void)
Puts the transition's tiles where they cover the screen.
Definition field.c:27
void FIELDSTG_leaveFieldAfter(s32 mode, s32 arg, s32 x, s32 y, s32 dir, s32 delay)
Leaves the field for a mode after a delay: the field task (FIELD_TASK_FIELD) goes to TASK_DONE,...
Definition field.c:687
static void pickOddFighterPrize(s32 mode)
The prize of an odd prize fighter in the stage of the mode: the rare item 1 time in 32.
Definition field.c:717
static void showField(FieldTask *task, FieldChildren *children)
The field's last loading step: once the CD is free, the high buffer freed and the map streamer create...
Definition field.c:535
static void waitToRequestBattleFiles(void)
Asks for the battle's files once the CD has been free on two frames.
Definition field.c:40
s32 FIELDSTG_keepsFileCache(void)
Whether the mode is FIELD_MODE_WSTAG415 or FIELD_MODE_WSTAG815, whose field keeps the file cache and ...
Definition field.c:296
static void createParty(FieldChildren *children)
Creates the player: the first of the characters 1, 0x6A, 0x146 and 0x147 in FieldState....
Definition field.c:377
static void openFieldMenu(FieldTask *task, FieldChildren *children)
From the STORY_GENJI_BEATEN on, START opens the field menu (STSTATUS) while the field is idle; the pl...
Definition field.c:469
void FIELDSTG_playBattleTransition(FieldTask *task, FieldChildren *fieldChildren)
The field's battle transition: the screen breaks into TRANSITION_COLUMNS by TRANSITION_ROWS tiles tha...
Definition field.c:102
void FIELDSTG_startEncounter(s32 encounter)
Starts encounter FIELDSTG_encounters[encounter]: the field task (FIELD_TASK_FIELD) leaves for the bat...
Definition field.c:968
Task * FIELDSTG_createField(void)
Creates the field's main task.
Definition field.c:677
#define PICK_PRIZE(common, rare)
The prize of a battle, an item: the common one, or the rare one when the roll is 0.
Definition field.c:708
static void warpAway(FieldTask *task, FieldChildren *children)
The warp's steps: its effect and sound, a fade out after 0x3C, the field's characters,...
Definition field.c:428
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#define FIELD_LAYER_COVER
the cover that fades the screen (FIELDSTG_drawCover)
Definition field_map.h:19
#define FIELD_CHARACTER_PARTNERS
Definition field_map.h:186
#define FIELD_LAYER_TEXT
the message and talk boxes
Definition field_map.h:22
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
#define FIELD_FLAG_ENCOUNTERED
The FLAGS_00 flag that every encounter sets (FIELDSTG_startEncounter); until it is set,...
Definition field_map.h:190
#define FIELD_LAYER_BACK
The field's drawing layers, by their ids (GFX.funcs.createLayer), as FIELDSTG_updateField creates the...
Definition field_map.h:18
#define FIELD_MAP_AREAS
a cell's value: its battle area (FieldBattles), or 0
Definition field_map.h:87
#define FIELD_TASK_FIELD
the field's main task (FIELDSTG_createField)
Definition field_map.h:27
#define FIELD_CHARACTER_PLAYER
The characters (Actor.key1, FieldActorEntry.id) that FIELDSTG_updateField creates for the party.
Definition field_map.h:185
#define FIELD_LAYER_BANNER
the area name banner
Definition field_map.h:21
#define ACTOR_STAND
Definition field_map.h:306
FieldMenu * createFieldMenu(s32 layerId, s32 cursor)
Opens the field menu on a layer with the cursor on an option.
Definition field_menu.c:426
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define TRANSITION_WAIT
the steps after the last tile, before the mode
Definition field_mode.h:680
#define FIELD_VISITED_FLAG(mode)
The flag set when the field of a mode is entered: FLAGS_00's group 0x20, flag mode - 0x200.
Definition field_mode.h:660
#define FIELD_MODE_WSTAG815
Definition field_mode.h:665
#define TRANSITION_SPEED
pixels a frame
Definition field_mode.h:678
#define TRANSITION_GONE
a tile's coordinate once it has slid off
Definition field_mode.h:679
#define TRANSITION_ROWS
Definition field_mode.h:674
#define TRANSITION_TILE_HEIGHT
Definition field_mode.h:676
#define SOUND_ENCOUNTS
the transition to a battle
Definition field_mode.h:43
#define TRANSITION_DONE
the step once the mode is requested
Definition field_mode.h:681
#define SOUND_DIGIMENT
a warp's effect
Definition field_mode.h:42
#define FIELD_PRIZE_FIGHTER_COUNT
Definition field_mode.h:669
#define TRANSITION_IMAGE_X
Definition field_mode.h:677
#define FIELD_MODE_WSTAG415
The modes of two fields that keep the file cache (FIELDSTG_keepsFileCache)
Definition field_mode.h:663
#define TRANSITION_TILE_WIDTH
Definition field_mode.h:675
#define TRANSITION_COLUMNS
FIELDSTG_playBattleTransition's tiles: a copy of the screen at TRANSITION_IMAGE_X in VRAM,...
Definition field_mode.h:673
#define FIELD_PRIZE_FIGHTERS
The fighters whose battles always give an item (FIELDSTG_startEncounter)
Definition field_mode.h:668
static void FIELDSTG_startBattle(AreaBattle *battle)
Starts a battle: its fight stage, its music and its encounter.
FieldMap FIELDSTG_map
Definition fieldstg.c:3660
s16 FIELDSTG_eventIds[]
the events FIELDSTG_startListedEvent starts
Definition fieldstg.c:1910
RECT FIELDSTG_screenRect
Definition fieldstg.c:3761
Encounter FIELDSTG_encounters[]
The battles that can start on the field (FIELDSTG_startEncounter)
Definition fieldstg.c:948
TileMove FIELDSTG_tileMoves[]
Definition fieldstg.c:1846
Vec2 FIELDSTG_tiles[5][6]
FIELDSTG_playBattleTransition's.
Definition fieldstg.c:3758
s32 FIELDSTG_battleFileStep
FIELDSTG_playBattleTransition's: 0 and 1 wait for the CD, 2 the battle's files are asked for.
Definition fieldstg.c:3759
FieldState FIELDSTG_state
Definition fieldstg.c:2641
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
Task * FIELDSTG_createFileLoader(s32 step)
Creates the file loader, which starts at a step.
#define MODE_STAGE_SELECT
STAGSLCT, the debug stage select.
Definition game_state.h:454
#define MODE_BATTLE
FIGHTSTG.
Definition game_state.h:432
#define MODE_PLAYER_NAME
STPLNMET: the player's name entry.
Definition game_state.h:431
#define MODE_TITLE
STDWTITL's title screen; its movies follow.
Definition game_state.h:438
#define MODE_OVERLAY(mode)
The first mode of a mode's overlay: MODE_OVERLAY(mode) == MODE_TITLE for all of STDWTITL's.
Definition game_state.h:459
#define MODE_BATTLE_MOVIE
Definition game_state.h:446
#define SCREEN_WIDTH
The screen the modes draw on (setDisplayMode, their layers' rects)
Definition gfx.h:36
#define SCREEN_HEIGHT
Definition gfx.h:37
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
Inn * createInn(s32 layerId)
Starts the inn of the current game mode on a layer.
Definition inn.c:343
BattleSetup BATTLE_SETUP
Definition items.c:886
MapObjects * FIELDSTG_createMapObjects(s32 sprites, StageTile *objects)
Creates the map's objects, with their sprites.
MapStreamer * FIELDSTG_createMapStreamer(s32 file)
Creates the map streamer of a file.
void FIELDSTG_drawCover(s32 id, s32 level)
Covers the screen on the layer id at a shade of level (8.8)
OverlayLoader OVERLAY_LOADER
Definition overlay.c:21
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_START
Definition pad.h:21
Random RANDOM
Definition random.c:533
TaskRegistry TASK_REGISTRY
Definition registry.c:122
ScreenFade * createScreenFade(s32 layerId)
A screen fade task on a layer, idle until started.
Definition screen_fade.c:76
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
@ STORY_GENJI_BEATEN
WSTAG200, event 52: after the first battle, won against Tamer Genji (event 50), the Digimon Navi give...
Definition story.h:36
@ STORY_EXTRA
WSTAG780, event 1500, in the European and Japanese versions: the extra chapter, whose stages are FIEL...
Definition story.h:149
@ STORY_MOVIE_BATTLES
WSTAG820, event 1080, with Snatchmon: each encounter plays MODE_BATTLE_MOVIE first.
Definition story.h:146
@ STORY_PARTNERS_RECEIVED
WSTAG212, events 10 to 12: the Tamer Service downloads the starter pack's Digimon (DM0010-DM0012,...
Definition story.h:32
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
Vec2 pos
Definition field_map.h:336
void(* setSubstate)(struct Actor *task, s32 substate)
Definition field_map.h:335
Vec2 tile
Definition field_map.h:337
void(* setState)(struct Actor *task, s32 state)
Definition field_map.h:335
s32 dir
Definition field_map.h:338
A battle of an area's BattleList, which can start on the field (see FIELDSTG_startEncounter); FIGHTST...
Definition field_map.h:402
s32 fighter
0 for none
Definition game_state.h:354
AreaBattle * battles[8]
Definition field_map.h:413
u8 ambushChance
a chance that WFIGHTMN scales by level
Definition game_state.h:387
s32 battle
the battle (BattleResult.battle)
Definition game_state.h:384
BattleEnemy enemies[3]
Definition game_state.h:386
u8 encounterKind
Encounter.kind; only the enemies' condition 13 reads it.
Definition game_state.h:388
u8 blocks[12]
by BATTLE_BLOCK_*: what the player can't do in the battle
Definition game_state.h:389
s32 hasPrize
1: the battle always gives prize
Definition game_state.h:390
s32(* isBusy)(void)
Definition file.h:63
u8 ambushChance
Definition field_mode.h:738
BattleEnemy * enemies[3]
Definition field_mode.h:737
u8 kind
copied to BATTLE_SETUP.encounterKind: 1 for nearly all the maps' random battles (some enemies' battle...
Definition field_mode.h:739
u8 blocks[12]
copied to BATTLE_SETUP.blocks
Definition field_mode.h:743
A character of the field (FieldState.actors, a list of pointers up to NULL), which FIELDSTG_updateFie...
Definition field_map.h:194
s16 x
in pixels
Definition field_map.h:199
s16 image
its ActorImage, of FieldState.images.actors from 2 (FIELDSTG_createActor)
Definition field_map.h:198
u16 * conditions
FLAGS_00.checkConditions's, or NULL.
Definition field_map.h:195
BattleList * battles[4]
Definition field_map.h:426
The children of the field's main task (FieldTask, FIELDSTG_updateField)
Definition field_mode.h:714
struct Actor * actors[4]
the player and the partners
Definition field_mode.h:724
struct Camera * camera
Definition field_mode.h:725
struct MapStreamer * mapStreamer
FIELDSTG_createMapStreamer's.
Definition field_mode.h:729
EventTask * event
Definition field_mode.h:718
Task * fileLoader
FIELDSTG_createFileLoader's, as the field starts.
Definition field_mode.h:720
FieldMenu * menu
createFieldMenu's
Definition field_mode.h:730
struct Inn * inn
createInn's (FIELDSTG_openInn)
Definition field_mode.h:721
union FieldChildren::@14 awaited
the task the field waits for, until it ends
ScreenFade * fade
Definition field_mode.h:716
struct Triggers * triggers
FIELDSTG_createTriggers's.
Definition field_mode.h:727
Task * banner
FIELDSTG_createBanner's.
Definition field_mode.h:723
Task * stage
FieldState.stageInit's.
Definition field_mode.h:728
struct FieldEffect * effect
FIELDSTG_createEffect's.
Definition field_mode.h:715
struct CutsceneAnim * cutscene
FIELDSTG_createCutsceneAnim's.
Definition field_mode.h:717
struct Actor * npcs[15]
FieldState.actors's other characters.
Definition field_mode.h:726
struct MapObjects * mapObjects
FIELDSTG_createMapObjects's.
Definition field_mode.h:731
void(* setFile)(s32 index, s32 file)
FIELDSTG_setMapFile.
Definition field_map.h:100
s32 frozen
no control, triggers or encounters for the player: while the area name banner shows (FIELDSTG_createB...
Definition field_map.h:466
struct Task *(* stageInit)(void *owner)
starts the stage's task
Definition field_map.h:443
s32 sheetEntry
the stage's sprite sheet, loaded before the field starts, or 0
Definition field_map.h:445
s32 busy
an event, a warp, a launch or a battle has the player
Definition field_map.h:468
s32 defaultStartDir
and its direction
Definition field_map.h:472
s32 battleStarting
an encounter started (FIELDSTG_startEncounter)
Definition field_map.h:469
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
void(* init)(void)
FIELDSTG_pickStage.
Definition field_map.h:473
s32 menuOpen
the field menu (START) or the inn (FIELDSTG_openInn) is open: the pad doesn't move the player
Definition field_map.h:464
FieldBattles * battles
Definition field_map.h:450
StageSlot * slots
up to the first type 0
Definition field_map.h:447
ActorImage * actors
then the actors', from actors[2]
Definition field_map.h:454
s32 acting
the player talks, climbs, slides or searches
Definition field_map.h:470
s32 mapFile
the file of the map's tiles (FIELDSTG_createMapStreamer)
Definition field_map.h:444
Vec2 defaultStart
where the player starts without a mode argument
Definition field_map.h:471
s32 music
SOUND.playSound's, or 0.
Definition field_map.h:460
s32 stageFile
the stage overlay's file
Definition field_map.h:442
The field's main task (FIELDSTG_updateField, FIELD_TASK_FIELD); its children follow.
Definition field_mode.h:698
void * children
Definition field_mode.h:699
s32 centerOnPlayer
the closing clip shrinks onto the player
Definition field_mode.h:707
s32 leaveDelay
the frames left before it closes the field
Definition field_mode.h:706
void * highBuffer
a buffer at the end of the heap
Definition field_mode.h:705
s32 nextMode
the mode it leaves for (FIELDSTG_leaveFieldAfter)
Definition field_mode.h:703
void(* tickCounter)(struct FieldTask *task)
Definition field_mode.h:699
void(* nextSubstate)(struct FieldTask *task)
Definition field_mode.h:699
s32 width
of the clip rectangle
Definition field_mode.h:701
void(* nextStep)(struct FieldTask *task)
Definition field_mode.h:699
Vec2 warpPos
where the warp's effect plays
Definition field_mode.h:709
void(* setSubstate)(struct FieldTask *task, s32 substate)
Definition field_mode.h:699
s32 childCount
Definition field_mode.h:699
void(* setState)(struct FieldTask *task, s32 state)
Definition field_mode.h:699
void(* nextState)(struct FieldTask *task)
Definition field_mode.h:699
s32 fade
FIELDSTG_drawCover's level.
Definition field_mode.h:700
s32 nextModeArg
Definition field_mode.h:704
SlotDest * warp
where it leads
Definition field_mode.h:710
s32 warpKind
the effect and cutscene of a warp (FIELDSTG_startWarp)
Definition field_mode.h:708
void(* touchMarked)(void)
Definition file.h:99
void(* markCached)(void)
Definition file.h:98
void(* freeFrom)(u32 addr)
Definition file.h:95
void(* request)(s32 file)
Definition file.h:90
void(* applyAction)(s32 code, s32 value)
Definition game_state.h:52
s32(* checkConditions)(u16 *list)
Definition game_state.h:51
void(* updateModeFlags)(void)
Definition game_state.h:55
s32(* getMode)(void)
Definition game_state.h:19
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
s32(* getPartyPartner)()
Definition game_state.h:28
s32(* getPrevMode)()
Definition game_state.h:23
u16 place
where the last warp or trigger put the player (FieldBattles.id)
Definition game_state.h:506
u16 placeArg
the place's argument, which the stage reads with it
Definition game_state.h:507
s32 clearTempFlags
Definition game_state.h:573
s32 fieldMode
where the menu returns to
Definition game_state.h:503
Vec2 fieldPos
the player's, there
Definition game_state.h:504
GameFuncs funcs
Definition game_state.h:582
void *(* getPrim)(void)
Definition gfx.h:19
void(* reset)(void)
Definition gfx.h:17
s32(* getFrameTime)(void)
Definition gfx.h:32
void(* allocPrimBuffers)(s32 size)
Definition gfx.h:18
struct Layer *(* createLayer)(RECT *rect, s32 otShift, s32 id)
Definition gfx.h:24
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
void(* setPrim)(void *next)
Definition gfx.h:20
void(* setDisplayMode)(s32 w, s32 h, s32 hires, s32 interlace)
Definition gfx.h:26
s32 buffer
the one being drawn
Definition gfx.h:73
GfxFuncs funcs
Definition gfx.h:77
void *(* allocHigh)(s32 size, s32 tag)
from the end of the heap
Definition heap.h:30
void(* free)(void *ptr)
Definition heap.h:27
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
void(* getScroll)()
Definition gfx.h:148
u_long *(* getOtEntry)(struct Layer *, s32 depth)
Definition gfx.h:155
void(* setBgColor)()
no prototype: callers would truncate u8 args
Definition gfx.h:152
void(* setClipSize)()
no prototype: callers would truncate s16 args
Definition gfx.h:146
void(* allocCallbacks)()
Definition gfx.h:159
void(* setClipPos)()
no prototype: callers would truncate s16 args
Definition gfx.h:145
void(* setState)(struct MapObjects *task, s32 state)
Definition field_mode.h:509
void(* setState)(struct MapStreamer *task, s32 state)
Definition field_mode.h:488
void(* loadSubOverlay)(s32 file)
Definition overlay.h:14
s32(* getPressed)(s32 pad)
Definition pad.h:125
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15
void(* start)(struct ScreenFade *fade, s32 fadeIn, s32 frames)
TASK_DONE when done.
Definition gfx.h:368
s32 state
Definition gfx.h:362
Where a slot leads: a StageSlot from its arg on, as the warps (FieldTask.warp) and the launches (Laun...
Definition field_map.h:291
s16 x
in pixels
Definition field_map.h:293
u16 place
copied to GAME.place, the place (FieldBattles.id)
Definition field_map.h:297
u16 placeArg
copied to GAME.placeArg
Definition field_map.h:298
s32 music
the exclusive sound playing
Definition sound.h:183
s32(* isLoading)(void)
Definition sound.h:193
void(* stopSound)(s32 id)
Definition sound.h:195
void(* loadBank)(s32 id)
Definition sound.h:190
void(* stopAll)(void)
Definition sound.h:194
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
Any task, seen through its header.
Definition task.h:62
void(* setSubstate)(struct Task *task, s32 substate)
Definition task.h:63
s32 state
Definition task.h:63
A step of FIELDSTG_playBattleTransition's spiral: one coordinate of a tile moves by dir until it pass...
Definition field_mode.h:685
s32 * value
Definition field_mode.h:686
s32 dir
1, -1, or 0 at the end
Definition field_mode.h:687
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353
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
Triggers * FIELDSTG_createTriggers(s32 sheetEntry, StageSlot *slots)
Creates the triggers.
Definition trigger.c:239
The next free primitive of the packet buffer (getPrim), written as the kind that is drawn next.
Definition gfx.h:344
POLY_F4 * f4
Definition gfx.h:347
POLY_FT4 * ft4
Definition gfx.h:348
DR_TPAGE * tpage
Definition gfx.h:349
void * any
Definition gfx.h:345