Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
menu.c
Go to the documentation of this file.
1/* The partner menu, where the partner to rename is chosen */
2
4
5/* Shows (creating it the first time) or hides a text window of the partner menu:
6 2 to 4 are the party's names, the others strings of TEXT_DIGIMON_NAMING */
7void STDGNAME_showMenuWindow(PartnerMenuTask *task, TextWindow **window, s32 index, s32 show) {
8 s32 layer = 0;
9 char *name;
10
11 if (index < 5) {
12 layer = task->layer;
13 }
14 if (show) {
15 if (*window == NULL) {
16 *window = createTextWindow(layer, 1, STDGNAME_menuWindows[index].x, STDGNAME_menuWindows[index].y);
17 (*window)->setDepth(*window, 1);
18 }
19 if (index >= 2 && index <= 4) {
21 (*window)->style = STDGNAME_funcs.style;
22 (*window)->setString(*window, name, -1);
23 } else {
24 (*window)->setString(*window, FILE_CACHE.load(TEXT_FILE(TEXT_DIGIMON_NAMING)), STDGNAME_menuWindows[index].text);
25 }
26 (*window)->setPalette(*window, PALETTE_WHITE);
27 } else if (*window != NULL) {
28 (*window)->setVisible(*window, 0);
29 }
30}
31
32/* Draws the partner menu, its parts opening by scaling: its three sprites (the
33 one at the chosen partner in a cycling palette), each partner's animation in
34 its slot and the slots' frames over a glow in a cycling palette */
36 SpriteDrawer sprite;
37 s32 i;
38 s32 value;
39 s32 partner;
40
41 initSpriteDrawer(&sprite);
42 sprite.setLayerId(task->layer, 2);
43 sprite.setTexture(0x280, 0);
44 for (i = 0; i < 3; i++) {
45 if (STDGNAME_menuSprites[i].sprite == -1) {
46 break;
47 }
48 value = task->tweens[i].level;
49 if (value != 0x1000) {
50 if (STDGNAME_menuSprites[i].vertical) {
51 sprite.setScale(ONE, value, ONE);
52 } else {
53 sprite.setScale(value, ONE, ONE);
54 }
55 if (STDGNAME_menuSprites[i].sprite == 0x20) {
57 } else {
58 sprite.setPivot(STDGNAME_menuSprites[i].pivotX, STDGNAME_menuSprites[i].pivotY);
59 }
60 } else {
61 sprite.setScale(ONE, ONE, ONE);
62 }
63 if (STDGNAME_menuSprites[i].sprite == 0x20) {
64 if ((GFX.funcs.getTime() & 3) == 3) {
65 if (++task->titleClut >= 16) {
66 task->titleClut = 0;
67 }
68 }
69 sprite.setClutRow(task->titleClut);
71 sprite.setClutRow(0);
72 } else {
74 }
75 }
76 for (i = 0; i < task->partyCount; i++) {
77 partner = GAME.funcs.getPartyPartner(i);
78 if (partner >= 0 && task->tweens[i + 3].level != 0) {
79 if (GFX.funcs.getTime() - task->anims[i].time >= 13) {
80 task->anims[i].time = GFX.funcs.getTime();
81 if (STDGNAME_menuAnims[partner][++task->anims[i].frame] == -1) {
82 task->anims[i].frame = 0;
83 }
84 }
85 STRETCH_SPRITE(sprite, task->tweens[i + 3].level, STDGNAME_menuSlots[0].pivotX + 2, STDGNAME_menuSlots[0].pivotY + 2);
87 STDGNAME_menuSlots[0].x + 2, STDGNAME_menuSlots[0].y + 2 + i * 43);
88 }
89 }
90 if ((GFX.funcs.getTime() & 3) == 3) {
91 if (++task->cursorClut >= 14) {
92 task->cursorClut = 0;
93 }
94 }
95 for (i = 0; i < task->partyCount; i++) {
96 if (GAME.funcs.getPartyPartner(i) >= 0) {
97 if (task->tweens[i + 3].level != 0) {
98 STRETCH_SPRITE(sprite, task->tweens[i + 3].level, STDGNAME_menuSlots[0].pivotX, STDGNAME_menuSlots[0].pivotY + i * 43);
99 sprite.setLayerId(task->layer, 1);
100 sprite.setClutRow(task->cursorClut);
102 sprite.setLayerId(task->layer, 2);
103 sprite.setClutRow(0);
105 }
106 }
107 }
108}
109
110/* Up/down choose a partner; cross picks it to rename, triangle leaves the screen
111 (choice -1, fading out). 1 once either is pressed */
114 if (--STDGNAME_funcs.partner < 0) {
116 }
118 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
119 if (++STDGNAME_funcs.partner > task->partyCount - 1) {
121 }
123 }
124 if (PAD_PRESSED(PAD_CROSS)) {
127 return 1;
128 }
131 task->screen->choice = -1;
132 task->screen->fadeOut(task->screen);
133 return 1;
134 }
135 return 0;
136}
137
138/* The partner menu's task: opens its panels, then each partner's slot and name
139 one after the other, runs the menu and closes everything once a choice is
140 made */
142 s32 i;
143 s32 j;
144 s32 done;
145
146 switch (task->state) {
147 case TASK_INIT:
148 default:
149 task->nextState(task);
150 for (i = 0; i < 6; i++) {
151 task->tweens[i].duration = 10;
152 }
153 for (i = 0; i < 3; i++) {
154 if (GAME.funcs.getPartyPartner(i) >= 0) {
155 task->partyCount++;
156 }
157 }
158 break;
159 case TASK_RUN:
160 done = 0;
161 switch (task->substate) {
162 case 0:
163 default:
164 STDGNAME_funcs.startFade(&task->tweens[0], 1);
165 STDGNAME_funcs.startFade(&task->tweens[1], 1);
166 task->substate++;
167 break;
168 case 1:
169 done += STDGNAME_funcs.updateFade(&task->tweens[0]);
170 done += STDGNAME_funcs.updateFade(&task->tweens[1]);
171 if (done == 2) {
172 STDGNAME_showMenuWindow(task, &windows[0], 0, 1);
173 STDGNAME_showMenuWindow(task, &windows[1], 1, 1);
174 STDGNAME_funcs.startFade(&task->tweens[3], 1);
175 task->nextSubstate(task);
176 }
177 break;
178 case 2:
179 if (STDGNAME_funcs.updateFade(&task->tweens[task->step + 3])) {
180 STDGNAME_showMenuWindow(task, &windows[task->step + 2], task->step + 2, 1);
181 if (task->step < task->partyCount - 1) {
182 task->step++;
183 STDGNAME_funcs.startFade(&task->tweens[task->step + 3], 1);
184 } else {
185 STDGNAME_funcs.startFade(&task->tweens[2], 1);
186 task->nextSubstate(task);
187 }
188 }
189 break;
190 case 4:
191 if (STDGNAME_runMenu(task, windows)) {
192 task->substate++;
193 for (i = 0; i < 6; i++) {
194 STDGNAME_funcs.startFade(&task->tweens[i], 0);
195 STDGNAME_showMenuWindow(task, &windows[i], i, 0);
196 }
197 }
198 break;
199 case 3:
200 case 5:
201 if (STDGNAME_funcs.updateFade(&task->tweens[2])) {
202 task->substate++;
203 }
204 break;
205 case 6:
206 for (j = 0; j < 6; j++) {
207 done += STDGNAME_funcs.updateFade(&task->tweens[j]);
208 }
209 if (done == 6) {
210 task->setState(task, TASK_KILL);
211 }
212 break;
213 }
214 STDGNAME_drawMenu(task, windows);
215 break;
216 case TASK_DONE:
217 case TASK_KILL:
218 break;
219 }
220}
221
222/* Creates the partner menu (task) to pick the partner to rename */
225
226 task->screen = screen;
227 task->layer = SCREEN_LAYER;
228 return task;
229}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
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
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_DIGIMON_NAMING
DGNMET: STDGNAME's.
Definition file.h:209
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define STRETCH_SPRITE(sprite, level, x, y)
Definition gfx.h:273
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
Definition gfx.h:45
void STDGNAME_updateMenu(PartnerMenuTask *task, TextWindow **windows)
The partner menu's task: opens its panels, then each partner's slot and name one after the other,...
Definition menu.c:141
PartnerMenuTask * STDGNAME_createMenu(ScreenTask *screen)
Creates the partner menu (task) to pick the partner to rename.
Definition menu.c:223
void STDGNAME_showMenuWindow(PartnerMenuTask *task, TextWindow **window, s32 index, s32 show)
Shows (creating it the first time) or hides a text window of the partner menu: 2 to 4 are the party's...
Definition menu.c:7
void STDGNAME_drawMenu(PartnerMenuTask *task, TextWindow **windows)
Draws the partner menu, its parts opening by scaling: its three sprites (the one at the chosen partne...
Definition menu.c:35
s32 STDGNAME_runMenu(PartnerMenuTask *task, TextWindow **windows)
Up/down choose a partner; cross picks it to rename, triangle leaves the screen (choice -1,...
Definition menu.c:112
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#define PAD_TRIANGLE
Definition pad.h:32
#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
STDGNAME.PRO: the screen where the partners are renamed.
#define STDGNAME_SPRITES
sprite bank
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_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#define SOUND_MENU_MOVE
SYSTEM06.
Definition sound.h:43
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
MenuWindow STDGNAME_menuWindows[]
Definition stdgname.c:631
MenuSprite STDGNAME_menuSprites[]
The partner menu: its sprites, the partners' slots (one under the other, 43 pixels apart),...
Definition stdgname.c:616
ScreenFuncs STDGNAME_funcs
style: the text style of the partners' names in the menu (STDGNAME_showMenuWindow)
Definition stdgname.c:646
s32 STDGNAME_menuAnims[][7]
Definition stdgname.c:638
MenuSlot STDGNAME_menuSlots[]
Definition stdgname.c:627
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
struct PartnerStats *(* getPartnerStats)(s32 partner)
Definition game_state.h:38
s32(* getPartyPartner)()
Definition game_state.h:28
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
s32 sprite
-1 ends the list
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
The partner menu.
void(* nextSubstate)(struct PartnerMenuTask *task)
void(* setState)(struct PartnerMenuTask *task, s32 state)
struct ScreenTask * screen
PanelAnim tweens[6]
void(* nextState)(struct PartnerMenuTask *task)
MenuAnim anims[3]
char name[0x18]
Definition game_state.h:304
void(* startFade)(PanelAnim *fade, s32 fadeIn)
s32(* updateFade)(PanelAnim *fade)
TextStyle * style
The screen's controller.
void(* fadeOut)(struct ScreenTask *task)
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(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
#define PALETTE_WHITE
The text windows' palettes (TextWindow.palette, setPalette): rows of the font's CLUTs,...
Definition text.h:112
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)