Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
choice.c
Go to the documentation of this file.
1/* The yes/no questions of the story */
2
3#include "field/field_mode.h"
4
5/*
6 * A yes/no question of the story (FIELDSTG_askChoice0 to FIELDSTG_askChoice15
7 * make one per type): asks FIELDSTG_choices[type]'s question and starts the
8 * event of the answer.
9 */
11 SpriteDrawer drawer;
12 s32 prev;
13 s32 i;
14 s32 j;
15 s32 k;
16
17 switch (task->state) {
18 case TASK_INIT:
19 default:
20 task->nextState(task);
21 task->tween.duration = 10;
22 for (i = 0; i < 2; i++) {
23 children->options[i] = createTextWindow(FIELD_LAYER_MAP, 1, 0x1C, 0xBE + i * 14);
24 children->options[i]->setDepth(children->options[i], 1);
25 }
26 children->cursor = createCursor(FIELD_LAYER_MAP, 1, 0x12, 0xBE);
27 children->cursor->setVisible(children->cursor, 0);
28 children->title = createTextWindow(FIELD_LAYER_MAP, 1, 0x12, 0xB0);
29 break;
30 case TASK_RUN:
31 switch (task->substate) {
32 case 0:
33 default:
34 FIELDSTG_tweenStart(&task->tween, 1);
35 task->substate++;
36 break;
37 case 1:
38 if (FIELDSTG_tweenUpdate(&task->tween)) {
39 for (j = 0; j < 2; j++) {
40 children->options[j]->setString(children->options[j], FILE_CACHE.getEntry(FIELDSTG_choices[task->type].text + (TEXT_FILE(1) << 16)), j + 2);
41 }
42 children->cursor->setVisible(children->cursor, 1);
43 children->title->setString(children->title, FILE_CACHE.getEntry(FIELDSTG_choices[task->type].text + (TEXT_FILE(1) << 16)), 1);
44 task->substate++;
45 }
46 break;
47 case 2:
48 prev = task->selection;
50 if (--task->selection < 0) {
51 task->selection = 0;
52 }
53 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
54 task->selection++;
55 if (task->selection > 1) {
56 task->selection = 1;
57 }
58 }
59 if (prev != task->selection) {
61 children->cursor->setPos(children->cursor, 0x12, task->selection * 14 + 0xBE);
62 break;
63 }
66 task->substate = 10;
67 }
68 break;
69 case 3:
70 children->event = FIELDSTG_startEvent(task->selection == 0 ? FIELDSTG_choices[task->type].events[0] : FIELDSTG_choices[task->type].events[1]);
71 task->substate++;
72 break;
73 case 4:
74 if (children->event == NULL) {
75 task->state = TASK_KILL;
76 }
77 break;
78 case 10:
79 for (k = 0; k < 2; k++) {
80 children->options[k]->setVisible(children->options[k], 0);
81 }
82 children->cursor->setVisible(children->cursor, 0);
83 children->title->setVisible(children->title, 0);
84 FIELDSTG_tweenStart(&task->tween, 0);
85 task->substate++;
86 break;
87 case 11:
88 if (FIELDSTG_tweenUpdate(&task->tween)) {
89 task->substate = 3;
90 }
91 break;
92 }
93 initSpriteDrawer(&drawer);
94 drawer.setLayerId(FIELD_LAYER_MAP, 2);
96 drawer.setFollowScroll(0);
97 if (task->tween.level != 0) {
98 if (task->tween.level != 0x1000) {
99 drawer.setScale(task->tween.level, 0x1000, 0x1000);
100 drawer.setPivot(0, 0xC3);
101 }
102 drawer.draw(FILE_CACHE.getEntry(FILE_MENU_SPRITES << 16), 0x45, 0, 0xAC);
103 }
104 break;
105 case TASK_DONE:
106 case TASK_KILL:
107 break;
108 }
109}
110
111/* Asks question n of FIELDSTG_choices: the start of the FieldEvent before the
112 events of its answers (FIELDSTG_events) */
113#define ASK_CHOICE(n) \
114 void *FIELDSTG_askChoice##n(void) { \
115 ChoiceTask *task = createTask(FIELDSTG_runChoice, sizeof(ChoiceTask), sizeof(ChoiceChildren)); \
116 task->type = n; \
117 return task; \
118 }
119
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
#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
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
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
void FIELDSTG_runChoice(ChoiceTask *task, ChoiceChildren *children)
A yes/no question of the story (FIELDSTG_askChoice0 to FIELDSTG_askChoice15 make one per type): asks ...
Definition choice.c:10
#define ASK_CHOICE(n)
Asks question n of FIELDSTG_choices: the start of the FieldEvent before the events of its answers (FI...
Definition choice.c:113
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define FIELD_MENU_SPRITES_X
the executable's FILE_MENU_SPRITES
Definition field_mode.h:35
s32(* FIELDSTG_tweenUpdate)(PanelAnim *tween)
FIELDSTG_updateTween.
Definition fieldstg.c:2561
ChoiceText FIELDSTG_choices[16]
Definition fieldstg.c:1309
void(* FIELDSTG_tweenStart)(PanelAnim *tween, s32 in)
FIELDSTG_startTween.
Definition fieldstg.c:2560
#define TEXT_FILE(file)
Definition file.h:190
#define FILE_MENU_SPRITES
Files the engine loads by number.
Definition file.h:188
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
Definition pad.h:140
#define PAD_UP
Definition pad.h:22
#define PAD_REPEATED(button)
Definition pad.h:141
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
Definition sound.h:38
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
Definition sound.h:40
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
The children of a yes/no question at the bottom of the screen: FIELDSTG's ChoiceTask and the stages' ...
Definition field_map.h:483
TextWindow * options[2]
Definition field_map.h:485
Cursor * cursor
Definition field_map.h:486
TextWindow * title
Definition field_map.h:484
struct EventTask * event
the answer's (FIELDSTG_startEvent)
Definition field_map.h:487
A yes/no question of the story (FIELDSTG_runChoice); its children are a ChoiceChildren (field_map....
Definition field_mode.h:347
s32 type
FIELDSTG_choices's.
Definition field_mode.h:349
PanelAnim tween
the panel's width
Definition field_mode.h:351
void(* nextState)(struct ChoiceTask *task)
Definition field_mode.h:348
s32 text
the file counted from TEXT_FILE(1) << 16 | its entry: the question, then the answers
Definition field_mode.h:356
s16 events[2]
FIELDSTG_startEvent's, for each answer.
Definition field_mode.h:358
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setVisible)()
(cursor, visible)
Definition text.h:33
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
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(* setPivot)()
(x, y)
Definition gfx.h:250
void(* setScale)()
(x, y, z), ONE = 1.0
Definition gfx.h:248
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* setFollowScroll)()
(on)
Definition gfx.h:251
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void(* setDepth)()
Definition text.h:183
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)