Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
menu.c
Go to the documentation of this file.
1/* "PRESS START", then the two options (new game, continue) */
2
3#include "menus/title.h"
4
5/* The menu's sprites: the European version has them for each language */
6#if VERSION_US || VERSION_JP
7#define MENU_SPRITE(i) (8 + (i))
8#elif VERSION_EU
9#define MENU_SPRITE(i) (STDWTITL_menuSprites[LANGUAGE][i])
10#endif
11
12/* Draws the menu: the cursor while it is shown, then "PRESS START" or the two
13 options, the one not picked dimmed */
15 SpriteDrawer sprite;
16
17 if (task->showCursor) {
18 initSpriteDrawer(&sprite);
19 sprite.setLayerId(task->layerId, 0);
20 sprite.setTexture(0x280, STDWTITL_TEXTURE_Y);
21 sprite.setClutRow(task->blink);
25 }
26 if (task->showOptions == 0) {
27 initSpriteDrawer(&sprite);
28 sprite.setLayerId(task->layerId, 0);
29 sprite.setTexture(0x280, STDWTITL_TEXTURE_Y);
30 sprite.setClutRow(task->selection != 2);
32 } else {
33 initSpriteDrawer(&sprite);
34 sprite.setLayerId(task->layerId, 0);
35 sprite.setTexture(0x280, STDWTITL_TEXTURE_Y);
36 sprite.setClutRow(task->selection != 0);
37 sprite.draw(FILE_CACHE.getEntry(STDWTITL_spriteBank), MENU_SPRITE(1), task->options[0].x, task->options[0].y);
38 initSpriteDrawer(&sprite);
39 sprite.setLayerId(task->layerId, 0);
40 sprite.setTexture(0x280, STDWTITL_TEXTURE_Y);
41 sprite.setClutRow(task->selection != 1);
42 sprite.draw(FILE_CACHE.getEntry(STDWTITL_spriteBank), MENU_SPRITE(2), task->options[1].x, task->options[1].y);
43 }
44}
45
46/* "PRESS START": waits a moment, then for Start (choice 3 after ten seconds),
47 blinks and spreads the two options out from it */
48static inline void runPressStart(TitleMenuTask *task) {
49 switch (task->substate) {
50 case 1:
51 default:
52 if (task->timer++ >= 6) {
53 task->selection = 2;
54 task->timer = 0;
55 task->showCursor = 1;
56 task->nextSubstate(task);
57 }
58 break;
59 case 2:
61 task->nextSubstate(task);
62 task->timer = 0;
64 task->blink = 0;
65 }
66 if (++task->timer >= 600) {
67 task->choice = 3;
68 }
69 break;
70 case 3:
71 if ((++task->timer & 3) == 0) {
72 task->timer = 0;
73 if (++task->blink >= 3) {
74 task->nextSubstate(task);
75 task->showOptions = 1;
76 task->options[0].x = task->options[1].x = 79;
77 task->options[0].y = task->options[1].y = 166;
78 task->blink = 0;
79 task->showCursor = 0;
81 }
82 }
83 break;
84 case 4:
85 task->options[0].x = (STDWTITL_menuCursorPositions[0].x - 79) * task->timer / 15 + 79;
86 task->options[0].y = (STDWTITL_menuCursorPositions[0].y - 166) * task->timer / 15 + 166;
87 task->options[1].x = (STDWTITL_menuCursorPositions[1].x - 79) * task->timer / 15 + 79;
88 task->options[1].y = (STDWTITL_menuCursorPositions[1].y - 166) * task->timer / 15 + 166;
89 if (++task->timer >= 15) {
90 task->timer = 0;
91 task->nextSubstate(task);
92 }
93 break;
94 case 5:
95 if (++task->timer >= 6) {
96 task->setState(task, TASK_DONE);
97 }
98 break;
99 }
100}
101
102/* The two options: up and down move between new game and continue, and the
103 confirm button blinks the option and sets choice */
104static inline void runOptions(TitleMenuTask *task) {
105 switch (task->substate) {
106 case 0:
107 default:
108 task->showOptions = 1;
109 task->selection = 1;
110 task->showCursor = 1;
115 task->nextSubstate(task);
116 break;
117 case 1:
119 if (task->selection != 0) {
121 }
122 task->selection = 0;
123 }
125 if (task->selection != 1) {
127 }
128 task->selection = 1;
129 }
130 if (PAD_PRESSED(PAD_CROSS)) {
131 task->timer = 0;
133 task->nextSubstate(task);
134 }
135 break;
136 case 2:
137 if ((++task->timer & 3) == 0) {
138 task->timer = 0;
139 if (++task->blink >= 3) {
140 if (task->selection != 0) {
141 task->choice = 2;
142 } else {
143 task->choice = 1;
144 }
145 task->nextSubstate(task);
146 task->blink = 0;
147 }
148 }
149 break;
150 case 3:
151 break;
152 }
153}
154
155/* The menu's task: once shown, waits for Start on "PRESS START" (choice 3 after ten
156 seconds), blinks and spreads out the two options; then moves between new game
157 and continue, and the confirm button blinks the option and sets choice */
159 switch (task->state) {
160 case TASK_INIT:
161 default:
162 if (task->skip == 0) {
163 task->nextState(task);
164 } else {
165 task->setState(task, TASK_DONE);
166 }
167 task->choice = 0;
168 return;
169 case TASK_RUN:
170 if (task->substate == 0) {
171 return;
172 }
173 runPressStart(task);
174 break;
175 case TASK_DONE:
176 runOptions(task);
177 break;
178 case TASK_KILL:
179 return;
180 }
181 STDWTITL_drawMenu(task);
182}
183
184/* Shows "PRESS START" (the task's show), only while it waits */
186 if (task->state == TASK_RUN) {
187 task->setSubstate(task, 1);
188 }
189}
190
191/* Back to waiting for Start on "PRESS START" (the task's reset), only while running;
192 nothing in the overlay calls it */
194 if (task->state == TASK_RUN) {
195 task->selection = 2;
196 task->showCursor = 1;
197 task->timer = 0;
198 task->setSubstate(task, 2);
199 }
200}
201
202/* The menu's choice (the task's getChoice): 0 none yet, 1 new game, 2 continue,
203 3 timed out */
205 return task->choice;
206}
207
208/* Creates the title screen's menu (task); skip: the two options shown from the start */
211
212 task->show = STDWTITL_showMenu;
216 task->depth = 2;
217 task->skip = skip;
218 return task;
219}
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
s32 STDWTITL_spriteBank
Definition title.c:72
#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
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
void STDWTITL_resetMenu(TitleMenuTask *task)
Back to waiting for Start on "PRESS START" (the task's reset), only while running; nothing in the ove...
Definition menu.c:193
static void runPressStart(TitleMenuTask *task)
"PRESS START": waits a moment, then for Start (choice 3 after ten seconds), blinks and spreads the tw...
Definition menu.c:48
static void runOptions(TitleMenuTask *task)
The two options: up and down move between new game and continue, and the confirm button blinks the op...
Definition menu.c:104
void STDWTITL_showMenu(TitleMenuTask *task)
Shows "PRESS START" (the task's show), only while it waits.
Definition menu.c:185
#define MENU_SPRITE(i)
The menu's sprites: the European version has them for each language.
Definition menu.c:9
void STDWTITL_tickMenu(TitleMenuTask *task)
The menu's task: once shown, waits for Start on "PRESS START" (choice 3 after ten seconds),...
Definition menu.c:158
void STDWTITL_drawMenu(TitleMenuTask *task)
Draws the menu: the cursor while it is shown, then "PRESS START" or the two options,...
Definition menu.c:14
s32 STDWTITL_getMenuChoice(TitleMenuTask *task)
The menu's choice (the task's getChoice): 0 none yet, 1 new game, 2 continue, 3 timed out.
Definition menu.c:204
TitleMenuTask * STDWTITL_startMenuTask(s16 skip)
Creates the title screen's menu (task); skip: the two options shown from the start.
Definition menu.c:209
#define PAD_CROSS
Definition pad.h:31
#define PAD_START
Definition pad.h:21
#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_SWITCH03
Definition sound.h:52
#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...
Point STDWTITL_menuCursorPositions[]
Definition stdwtitl.c:48
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32 x
Definition title.h:163
s32 y
Definition title.h:164
s32 x
Definition title.h:188
s32 y
Definition title.h:189
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(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
s32 layerId
Definition title.h:179
s16 selection
0, 1: the options, 2: "PRESS START"
Definition title.h:176
void(* setSubstate)(struct TitleMenuTask *task, s32 substate)
Definition title.h:169
void(* show)(struct TitleMenuTask *task)
Definition title.h:182
u8 showCursor
Definition title.h:174
s16 choice
1: new game, 2: continue, 3: timed out
Definition title.h:171
s32(* getChoice)(struct TitleMenuTask *task)
Definition title.h:184
s32 substate
Definition title.h:169
void(* nextState)(struct TitleMenuTask *task)
Definition title.h:169
void(* setState)(struct TitleMenuTask *task, s32 state)
Definition title.h:169
MenuOption options[2]
Definition title.h:177
void(* reset)(struct TitleMenuTask *task)
Definition title.h:183
void(* nextSubstate)(struct TitleMenuTask *task)
Definition title.h:169
s16 showOptions
Definition title.h:173
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
STDWTITL.PRO: the title screen, the opening movies and a notice screen.
#define STDWTITL_TEXTURE_Y
The VRAM row of the title's sprites (SpriteDrawer.setTexture)
Definition title.h:49
#define STDWTITL_TITLE_LAYER
Definition title.h:30