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 partners page: the choice between the sets of starting partners */
2
3#include "menus/player_name.h"
4
5/* Creates the choice's windows: the title, the three labels, the partners'
6 name and text, and each partner's name and text */
8 s32 i;
9
10 windows->title = createTextWindow(task->layer, 1, 0x20, 0x1A);
11 windows->title->setPalette(windows->title, PALETTE_GREEN);
12 for (i = 0; i < 3; i++) {
13 windows->labels[i] = createTextWindow(task->layer, 1, 0x1A, 0x34 + i * 0x18);
14 windows->labels[i]->setPalette(windows->labels[i], PALETTE_BLUE);
15 }
16 windows->name = createTextWindow(task->layer, 1, 0x3A, 0x32);
17 windows->name->setPalette(windows->name, PALETTE_GREEN);
18 windows->text = createTextWindow(task->layer, 1, 0x3A, 0xC2);
19 windows->text->setLines(windows->text, 3);
20 windows->text->setPalette(windows->text, PALETTE_BLUE);
21 for (i = 0; i < 3; i++) {
22 windows->partners[i].name = createTextWindow(task->layer, 2, 0x72, 0x43 + i * 0x2A);
23 windows->partners[i].name->setPalette(windows->partners[i].name, PALETTE_RED);
24 windows->partners[i].text = createTextWindow(task->layer, 1, 0x72, 0x4F + i * 0x2A);
25 windows->partners[i].text->setLines(windows->partners[i].text, 2);
26 windows->partners[i].text->setPalette(windows->partners[i].text, PALETTE_BLUE);
27 }
28}
29
30/* Shows the choice's windows with the texts of the partners under the arrow, or hides them */
32 s32 i;
33 s32 *partners;
34
35 if (show != 0) {
36 partners = STPLNMET_funcs.choices[task->choice];
37 windows->title->setString(windows->title, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), 6);
38 for (i = 0; i < 3; i++) {
39 windows->labels[i]->setString(windows->labels[i], FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), i + 7);
40 }
41 windows->name->setString(windows->name, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), task->choice + 10);
42 windows->text->setString(windows->text, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), task->choice + 26);
43 for (i = 0; i < 3; i++) {
44 windows->partners[i].name->setString(windows->partners[i].name, FILE_CACHE.load(TEXT_FILE(TEXT_DIGIMON_NAMES)), partners[i] + 1);
45 windows->partners[i].text->setString(windows->partners[i].text, FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), partners[i] + 13);
46 }
47 return;
48 }
49 windows->title->setVisible(windows->title, 0);
50 for (i = 0; i < 3; i++) {
51 windows->labels[i]->setVisible(windows->labels[i], 0);
52 }
53 windows->name->setVisible(windows->name, 0);
54 windows->text->setVisible(windows->text, 0);
55 for (i = 0; i < 3; i++) {
56 windows->partners[i].name->setVisible(windows->partners[i].name, 0);
57 windows->partners[i].text->setVisible(windows->partners[i].text, 0);
58 }
59}
60
61/* Draws the choice: the three partners under the arrow (animated), the panel and
62 the blinking arrow on the choice */
64 SpriteDrawer sprite;
65 s32 *partners = STPLNMET_funcs.choices[task->choice];
66 PartnerAnim *anim;
67 s32 i;
68
69 initSpriteDrawer(&sprite);
70 sprite.setLayerId(task->layer, task->depth);
71 if (GFX.funcs.getTime() - task->frameTime > 12) {
72 task->frameTime = GFX.funcs.getTime();
73 for (i = 0; i < 3; i++) {
74 anim = &STPLNMET_funcs.anims[partners[i]];
75 task->frames[i]++;
76 if (task->frames[i] >= 8 || anim->frames[task->frames[i]] == -1) {
77 task->frames[i] = 0;
78 }
79 }
80 }
81 sprite.setTexture(0x140, 0x100);
82 for (i = 0; i < 3; i++) {
83 anim = &STPLNMET_funcs.anims[partners[i]];
84 sprite.draw(FILE_CACHE.getEntry(PLNMET_BANK), anim->frames[task->frames[i]], 0x41, 0x40 + i * 0x2A);
85 }
86 sprite.setTexture(0x280, 0x100);
87 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 7, 0x10, 0x2C);
88 sprite.setLayerId(task->layer, task->depth - 1);
89 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 8, 0x10, 0x2C);
90 if (GFX.funcs.getTime() - task->arrowTime > 8) {
91 task->arrowTime = GFX.funcs.getTime();
92 task->arrowFrame++;
93 if (task->arrowFrame >= 6) {
94 task->arrowFrame = 0;
95 }
96 }
98 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), 0x32, 0x10, 0x30 + task->choice * 0x18);
99}
100
101/* Picks one of the three choices of partners (up/down); cross confirms them
102 (substate 100), triangle goes back to the name (substate 200) */
104 s32 old = task->choice;
105 s32 i;
106
108 task->choice--;
109 if (task->choice < STARTER_PACK_BALANCED) {
111 }
112 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
113 task->choice++;
114 if (task->choice > STARTER_PACK_MANIAC) {
116 }
117 }
118 if (old != task->choice) {
120 STPLNMET_showChoiceWindows(task, windows, 1);
121 for (i = 0; i < 3; i++) {
122 task->frames[i] = 0;
123 }
124 }
125 if (PAD_PRESSED(PAD_CROSS)) {
127 task->substate = 100;
128 return;
129 }
132 task->substate = 200;
134 }
135}
136
137/* Hides the choice of the partners, or shows it again (partners->hide) */
139 PartnerChoiceWindows *windows = task->children;
140
141 if (hide != 0) {
142 task->state = TASK_DONE;
143 STPLNMET_showChoiceWindows(task, windows, 0);
144 } else {
145 task->state = TASK_RUN;
146 task->substate = 0;
147 STPLNMET_showChoiceWindows(task, windows, 1);
148 }
149}
150
151/* The choice's task: creates its windows and waits hidden, then runs and draws it while shown */
153 switch (task->state) {
154 case TASK_INIT:
155 default:
156 task->nextState(task);
157 STPLNMET_createChoiceWindows(task, windows);
158 STPLNMET_hideChoice(task, 1);
159 break;
160 case TASK_RUN:
161 STPLNMET_runChoice(task, windows);
163 break;
164 case TASK_DONE:
165 case TASK_KILL:
166 break;
167 }
168}
169
170/* Creates the choice of the partners (task), hidden */
173
175 task->layer = 0x1001;
176 task->depth = 6;
177 task->screen = screen;
178 return task;
179}
signed int s32
Definition common.h:11
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
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_ONLINE
NAMEET: the Digimon Online registration.
Definition file.h:220
#define TEXT_DIGIMON_NAMES
DIGNAM.
Definition file.h:211
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
@ STARTER_PACK_MANIAC
Definition game_state.h:479
@ STARTER_PACK_BALANCED
Definition game_state.h:479
void STPLNMET_hideChoice(PartnerChoice *task, s32 hide)
Hides the choice of the partners, or shows it again (partners->hide)
Definition choice.c:138
PartnerChoice * STPLNMET_createChoice(PlayerNameScreen *screen)
Creates the choice of the partners (task), hidden.
Definition choice.c:171
void STPLNMET_runChoice(PartnerChoice *task, PartnerChoiceWindows *windows)
Picks one of the three choices of partners (up/down); cross confirms them (substate 100),...
Definition choice.c:103
void STPLNMET_showChoiceWindows(PartnerChoice *task, PartnerChoiceWindows *windows, s32 show)
Shows the choice's windows with the texts of the partners under the arrow, or hides them.
Definition choice.c:31
void STPLNMET_createChoiceWindows(PartnerChoice *task, PartnerChoiceWindows *windows)
Creates the choice's windows: the title, the three labels, the partners' name and text,...
Definition choice.c:7
void STPLNMET_drawChoice(PartnerChoice *task)
Draws the choice: the three partners under the arrow (animated), the panel and the blinking arrow on ...
Definition choice.c:63
void STPLNMET_updateChoice(PartnerChoice *task, PartnerChoiceWindows *windows)
The choice's task: creates its windows and waits hidden, then runs and draws it while shown.
Definition choice.c:152
#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
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_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...
s32 STPLNMET_choiceArrowCluts[]
The CLUT rows the partner choice's cursor cycles through.
Definition stplnmet.c:817
PlayerNameFuncs STPLNMET_funcs
STPLNMET's data (data/stplnmet.c), in its order.
Definition stplnmet.c:841
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
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
TextWindow * labels[3]
struct PartnerChoiceWindows::@17 partners[3]
The choice of the partners (STPLNMET_updateChoice)
void(* nextState)(struct PartnerChoice *task)
void(* hide)(struct PartnerChoice *task, s32 hide)
struct PlayerNameScreen * screen
s32 choice
STPLNMET_funcs.choices.
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(* 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(* setLines)()
no prototype: callers would truncate u8 args
Definition text.h:184
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
#define PALETTE_RED
Definition text.h:117
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)