Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
confirm.c
Go to the documentation of this file.
1/* The confirmation page: the name and the partners chosen, yes or no, and
2 the progress */
3
4#include "menus/player_name.h"
5
6/* Creates the confirmation's windows: the title, the name, the partners'
7 name, the message, yes and no with their cursor, and the progress */
9 windows->title = createTextWindow(task->layer, 1, 0x20, 0x1A);
10 windows->title->setPalette(windows->title, PALETTE_GREEN);
11 windows->name = createTextWindow(task->layer, 1, 0x61, 0x42);
12 windows->name->setPalette(windows->name, PALETTE_BLUE);
13 windows->pack = createTextWindow(task->layer, 1, 0x40, 0x60);
14 windows->pack->setPalette(windows->pack, PALETTE_BLUE);
15 windows->message = createTextWindow(task->layer, 1, 0x5A, 0xA9);
16 windows->message->setPalette(windows->message, PALETTE_BLUE);
17 windows->yes = createTextWindow(task->layer, 1, 0x6B, 0xB9);
18 windows->yes->setPalette(windows->yes, PALETTE_BLUE);
19 windows->no = createTextWindow(task->layer, 1, 0x6B, 0xC7);
20 windows->no->setPalette(windows->no, PALETTE_BLUE);
21 windows->cursor = createCursor(task->layer, task->depth - 2, 0x5A, 0xB9);
22 windows->cursor->setPalette(windows->cursor, PALETTE_BLUE);
23 windows->cursor->setVisible(windows->cursor, 0);
24 windows->progress = createTextWindow(task->layer, 1, 0xE3, 0xA9);
25 windows->progress->setPalette(windows->progress, PALETTE_BLUE);
26}
27
28/* Shows the confirmation's windows with the name typed (without its leading
29 spaces) and the partners chosen, the cursor on yes or no; or hides them */
31 u16 *name;
32 s32 i;
33
34 if (show != 0) {
35 windows->title->setString(windows->title, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x15);
36 name = task->name;
37 for (i = 0; name[i] == SJIS_SPACE; i++) {
38 }
39 windows->name->setText(windows->name, &name[i]);
40 windows->pack->setString(windows->pack, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), task->choice + 10);
41 windows->message->setString(windows->message, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x16);
42 windows->yes->setString(windows->yes, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x17);
43 windows->no->setString(windows->no, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x18);
44 windows->cursor->setPos(windows->cursor, 0x5A, task->cursor * 14 + 0xB9);
45 windows->cursor->setVisible(windows->cursor, 1);
46 } else {
47 windows->title->setVisible(windows->title, 0);
48 windows->name->setVisible(windows->name, 0);
49 windows->pack->setVisible(windows->pack, 0);
50 windows->message->setVisible(windows->message, 0);
51 windows->yes->setVisible(windows->yes, 0);
52 windows->no->setVisible(windows->no, 0);
53 windows->cursor->setVisible(windows->cursor, 0);
54 windows->progress->setVisible(windows->progress, 0);
55 }
56}
57
58/* Draws the confirmation: the title panel with its glow, the three partners
59 chosen (animated) and the panels, as they open, and the progress bar
60 while the progress counts up */
62 SpriteDrawer sprite;
63 SVECTOR out[4];
64 SVECTOR in[4];
65 s32 *partners;
66 PartnerAnim *anim;
67 POLY_G4 *poly;
68 u_long *ot;
69 Layer *layer;
70 s32 i;
71 s32 j;
72
73 partners = STPLNMET_funcs.choices[task->choice];
74 initSpriteDrawer(&sprite);
75 sprite.setTexture(0x280, 0x100);
76 if (GFX.funcs.getTime() - task->clutTime > 4) {
77 task->clutTime = GFX.funcs.getTime();
78 task->clutRow++;
79 if (task->clutRow >= 14) {
80 task->clutRow = 0;
81 }
82 }
83 if (task->tweenA.level != 0) {
84 if (task->tweenA.level != ONE) {
85 sprite.setScale(task->tweenA.level, ONE, ONE);
86 sprite.setPivot(0x37, 0x42);
87 }
88 sprite.setLayerId(task->layer, task->depth);
89 sprite.setClutRow(task->clutRow);
90 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 6, 0x37, 0x2F);
91 sprite.setClutRow(0);
92 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 2, 0x37, 0x2F);
93 }
94 if (GFX.funcs.getTime() - task->frameTime > 12) {
95 task->frameTime = GFX.funcs.getTime();
96 for (i = 0; i < 3; i++) {
97 anim = &STPLNMET_funcs.anims[partners[i]];
98 task->frames[i]++;
99 if (task->frames[i] >= 8 || anim->frames[task->frames[i]] == -1) {
100 task->frames[i] = 0;
101 }
102 }
103 }
104 if (task->tweenB.level != 0) {
105 sprite.setLayerId(task->layer, task->depth);
106 if (task->tweenB.level == ONE) {
107 sprite.setTexture(0x140, 0x100);
108 for (i = 0; i < 3; i++) {
109 anim = &STPLNMET_funcs.anims[partners[i]];
110 sprite.draw(FILE_CACHE.getEntry(PLNMET_BANK), anim->frames[task->frames[i]], 0x57 + i * 0x38, 0x6C);
111 }
112 }
113 sprite.setTexture(0x280, 0x100);
114 if (task->tweenB.level != ONE) {
115 sprite.setScale(ONE, task->tweenB.level, ONE);
116 sprite.setPivot(0xA0, 0x78);
117 }
118 sprite.setLayerId(task->layer, task->depth - 1);
119 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 10, 0x37, 0x59);
120 sprite.setLayerId(task->layer, task->depth);
121 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 9, 0x37, 0x59);
122 if (task->tweenB.level != ONE) {
123 sprite.setPivot(0xA0, 0xBE);
124 }
125 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 1, 0, 0xA2);
126 }
127 if (task->substate == 1 || task->substate == 2) {
128 sprite.setLayerId(task->layer, task->depth - 1);
129 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 0x37, 0x51, 0xBF);
130 task->scale.vy = task->scale.vz = ONE;
131 if (task->progress == 100) {
132 task->scale.vx = ONE;
133 } else {
134 task->scale.vx = task->progress * 41;
135 }
136 RotMatrixYXZ_gte(&task->rot, &task->matrix);
137 ScaleMatrix(&task->matrix, &task->scale);
138 layer = GFX.funcs.getLayer(task->layer);
139 ot = layer->getOtEntry(layer, task->depth - 1);
140 poly = GFX.funcs.getPrim();
141 setPolyG4(poly);
142 setRGB0(poly, 0x7F, 0x32, 0xF2);
143 setRGB1(poly, 0xD1, 0x2F, 0xDE);
144 setRGB2(poly, 0x7F, 0x32, 0xF2);
145 setRGB3(poly, 0xD1, 0x2F, 0xDE);
146 in[1].vx = in[3].vx = 0x98;
147 in[0].vy = in[1].vy = 0xBC;
148 in[0].vx = in[2].vx = 0;
149 in[2].vy = in[3].vy = 0xC8;
150 in[0].vz = in[1].vz = in[2].vz = in[3].vz = 0;
151 for (j = 0; j < 4; j++) {
152 ApplyMatrixSV(&task->matrix, &in[j], &out[j]);
153 out[j].vx += 0x54;
154 out[j].vy += 6;
155 }
156 setXY4(poly, out[0].vx, out[0].vy, out[1].vx, out[1].vy, out[2].vx, out[2].vy, out[3].vx, out[3].vy);
157 addPrim(ot, poly);
158 GFX.funcs.setPrim(poly + 1);
159 }
160}
161
162/* The confirmation's states: yes or no (substate 200 for no or triangle); yes
163 counts the progress up to 100, then waits 120 frames before substate 100.
164 Once closing, closes the panels and ends */
166 s32 old;
167
168 switch (task->substate) {
169 case 0:
170 default:
171 old = task->cursor;
172 if (PAD_PRESSED(PAD_UP)) {
173 task->cursor = 0;
174 } else if (PAD_PRESSED(PAD_DOWN)) {
175 task->cursor = 1;
176 }
177 if (old != task->cursor) {
179 windows->cursor->setPos(windows->cursor, 0x5A, task->cursor * 14 + 0xB9);
180 }
181 if (PAD_PRESSED(PAD_CROSS)) {
183 if (task->cursor == 0) {
184 task->substate = 1;
185 task->progress = 0;
186 windows->yes->setVisible(windows->yes, 0);
187 windows->no->setVisible(windows->no, 0);
188 windows->cursor->setVisible(windows->cursor, 0);
189 windows->message->setString(windows->message, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x1D);
190 windows->progress->setString(windows->progress, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x19);
191 windows->progress->setNumber(windows->progress, 1, task->progress);
192 windows->progress->setRightAlign(windows->progress, 1);
193 } else {
194 task->substate = 200;
195 }
196 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
198 task->substate = 200;
199 }
200 break;
201 case 1:
202 task->progress++;
203 if (task->progress > 100) {
204 task->progress = 100;
205 windows->message->setString(windows->message, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 0x1E);
207 task->nextSubstate(task);
208 } else {
210 }
211 windows->progress->setNumber(windows->progress, 1, task->progress);
212 windows->progress->setRightAlign(windows->progress, 1);
213 break;
214 case 2:
215 task->step++;
216 if (task->step > 120) {
217 task->substate = 100;
218 }
219 break;
220 case 50:
223 STPLNMET_showConfirmWindows(task, windows, 0);
224 task->substate++;
225 break;
226 case 51:
228 if (STPLNMET_funcs.updateFade(&task->tweenB) != 0) {
229 task->state = TASK_KILL;
230 }
231 break;
232 case 100:
233 case 200:
234 break;
235 }
236}
237
238/* Hides the confirmation, or shows it again (confirm->hide) with its cursor on
239 yes and the partners' animations from their first frame */
241 NameConfirmWindows *windows = task->children;
242 s32 i;
243
244 if (hide != 0) {
245 task->state = TASK_DONE;
246 STPLNMET_showConfirmWindows(task, windows, 0);
247 } else {
248 task->state = TASK_RUN;
249 task->substate = 0;
250 for (i = 0; i < 3; i++) {
251 task->frames[i] = 0;
252 }
253 task->cursor = 0;
254 STPLNMET_showConfirmWindows(task, windows, 1);
255 }
256}
257
258/* Starts closing the confirmation (confirm->close): its panels close, then it ends */
260 task->substate = 50;
261}
262
263/* The confirmation's task: creates its windows and waits hidden with its
264 panels open, then runs and draws it while shown */
266 switch (task->state) {
267 case TASK_INIT:
268 default:
269 task->nextState(task);
270 STPLNMET_createConfirmWindows(task, windows);
271 task->tweenA.duration = 10;
272 task->tweenA.level = ONE;
273 task->tweenB.duration = 10;
274 task->tweenB.level = ONE;
275 STPLNMET_hideConfirm(task, 1);
276 break;
277 case TASK_RUN:
278 STPLNMET_runConfirm(task, windows);
280 break;
281 case TASK_DONE:
282 case TASK_KILL:
283 break;
284 }
285}
286
287/* Creates the confirmation of the name and the partners (task), hidden */
290
293 task->layer = 0x1001;
294 task->depth = 6;
295 task->screen = screen;
296 return task;
297}
signed int s32
Definition common.h:11
unsigned short u16
Definition common.h:10
void STPLNMET_closeConfirm(NameConfirm *task)
Starts closing the confirmation (confirm->close): its panels close, then it ends.
Definition confirm.c:259
void STPLNMET_drawConfirm(NameConfirm *task)
Draws the confirmation: the title panel with its glow, the three partners chosen (animated) and the p...
Definition confirm.c:61
void STPLNMET_runConfirm(NameConfirm *task, NameConfirmWindows *windows)
The confirmation's states: yes or no (substate 200 for no or triangle); yes counts the progress up to...
Definition confirm.c:165
void STPLNMET_updateConfirm(NameConfirm *task, NameConfirmWindows *windows)
The confirmation's task: creates its windows and waits hidden with its panels open,...
Definition confirm.c:265
void STPLNMET_hideConfirm(NameConfirm *task, s32 hide)
Hides the confirmation, or shows it again (confirm->hide) with its cursor on yes and the partners' an...
Definition confirm.c:240
void STPLNMET_showConfirmWindows(NameConfirm *task, NameConfirmWindows *windows, s32 show)
Shows the confirmation's windows with the name typed (without its leading spaces) and the partners ch...
Definition confirm.c:30
NameConfirm * STPLNMET_createConfirm(PlayerNameScreen *screen)
Creates the confirmation of the name and the partners (task), hidden.
Definition confirm.c:288
void STPLNMET_createConfirmWindows(NameConfirm *task, NameConfirmWindows *windows)
Creates the confirmation's windows: the title, the name, the partners' name, the message,...
Definition confirm.c:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#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
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_ONLINE
NAMEET: the Digimon Online registration.
Definition file.h:220
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define SJIS_SPACE
full-width space, 0x81 0x40
Definition name_entry.h:17
#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
STPLNMET.PRO: the player's name entry (MODE_PLAYER_NAME).
#define PLNMET_MENU
sprite bank
Definition player_name.h:36
#define PLNMET_BANK
the keyboard's and partners' sprites
Definition player_name.h:37
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_COUNT
SYSTEM10: a number counts up or down.
Definition sound.h:45
#define SOUND_SYSTEM05
Definition sound.h:57
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
Definition sound.h:38
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#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...
PlayerNameFuncs STPLNMET_funcs
STPLNMET's data (data/stplnmet.c), in its order.
Definition stplnmet.c:841
void(* setPalette)()
Definition text.h:35
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setVisible)()
(cursor, visible)
Definition text.h:33
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
void *(* getPrim)(void)
Definition gfx.h:19
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
void(* setPrim)(void *next)
Definition gfx.h:20
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
u_long *(* getOtEntry)(struct Layer *, s32 depth)
Definition gfx.h:155
TextWindow * pack
TextWindow * name
TextWindow * message
TextWindow * title
TextWindow * no
TextWindow * progress
TextWindow * yes
The confirmation of the name and the partners (STPLNMET_updateConfirm)
void(* nextState)(struct NameConfirm *task)
SVECTOR rot
PanelAnim tweenB
void(* hide)(struct NameConfirm *task, s32 hide)
s32 frames[3]
MATRIX matrix
PanelAnim tweenA
void(* nextSubstate)(struct NameConfirm *task)
void(* close)(struct NameConfirm *task)
s32 choice
STPLNMET_funcs.choices.
s32 progress
0-100
s32 cursor
0 yes, 1 no
void * children
struct PlayerNameScreen * screen
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
A partner Digimon's animation in a menu: up to seven sprite ids, -1 ending it early (the sprites are ...
Definition game_state.h:340
s32 frames[7]
Definition game_state.h:341
void(* startFade)(PanelAnim *fade, s32 fadeIn)
s32(* updateFade)(PanelAnim *fade)
PartnerAnim * anims
s32(* choices)[3]
three partners each
The main task of the screen (STPLNMET_createScreen)
Definition player_name.h:82
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
void(* setPalette)(struct TextWindow *obj, u8 arg)
Definition text.h:174
void(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setNumber)()
Definition text.h:166
void(* setText)()
Definition text.h:164
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
#define PALETTE_BLUE
a light blue: what is highlighted or current
Definition text.h:113
#define PALETTE_GREEN
Definition text.h:116
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)