Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
digivolve_menu.c
Go to the documentation of this file.
1/* FIGHTSTG's digivolve menu, the Digimon the active partner can digivolve
2 into. */
3
5
6/* Shows the names of the Digimon the menu's partner can digivolve into, its
7 current one in palette 7 */
9 TextWindow **windows = task->children;
10 BattleFighter *fighter;
11 DigimonData *data;
12 s32 index;
13 s32 current;
14 s32 i;
15
16 /* the match depends on setting index in the loop's init: set before the
17 loop, its -1 is scheduled two instructions earlier */
18 for (i = 0, index = -1; i < 3; i++) {
19 if (task->partner == GAME.funcs.getPartyMember(i)) {
20 index = i;
21 break;
22 }
23 }
24 if (index == -1) {
25 return;
26 }
27 fighter = &FIGHTSTG_battle.state.fighters[0][index];
28 if (fighter->temporary) {
29 current = fighter->prevId;
30 } else {
31 current = fighter->id;
32 }
33 for (i = 0; i < task->count; i++) {
34 if (windows[i + 1] == NULL) {
35 windows[i + 1] = createTextWindow(BATTLE_LAYER_MENUS, 1, 0xBB, 0x92 + i * 0x13);
36 }
37 data = GET_DIGIMON(task->ids[i]);
38 if (data != NULL) {
39 windows[i + 1]->setString(windows[i + 1], FILE_CACHE.load(TEXT_FILE(TEXT_DIGIMON_NAMES)), data->nameId);
40 if (current == task->ids[i]) {
41 windows[i + 1]->setPalette(windows[i + 1], PALETTE_GREY);
42 } else {
43 windows[i + 1]->setPalette(windows[i + 1], PALETTE_WHITE);
44 }
45 }
46 }
47}
48
49/* the cursor of the Digimon a partner can change into (FIGHTSTG_updateDigivolveMenu sets
50 its count) */
52 0, 168, 147, 19, 36, 167, 146, 19,
53};
54
55/* The digivolve menu's task: L1 and R1 turn the PartnerInfo's page, cross
56 picks one other than the fighter's current Digimon into *result,
57 triangle gives -2. The match depends on taking the children as the
58 update's void * and copying them: as a parameter of their own type they
59 are equivalent to their argument slot, whose doubled live length gives
60 their register to changed */
61void FIGHTSTG_updateDigivolveMenu(DigivolveMenu *task, void *children) {
62 DigivolveMenuWindows *w = children;
63 BattleFighter *fighter;
64 s32 pressed;
65 s32 changed;
66 s32 show;
67 s32 current;
68 s32 id;
69 s32 count;
70 s32 i;
71
72 switch (task->state) {
73 case TASK_INIT:
74 default:
75 id = task->partner;
77 task->ids[0] = DIGIMON_DATA[id].id;
78 count = 1;
79 for (i = 0; i < 3; i++) {
80 if (task->slots[i] >= 3) {
81 task->ids[count] = task->slots[i];
82 count++;
83 }
84 }
85 task->count = count;
88 w->info[0] = FIGHTSTG_createPartnerInfo(task->partner, task->page, w->cursor->sel);
90 task->sel = -1;
91 task->nextState(task);
92 break;
93 case TASK_RUN:
94 changed = 0;
95 show = 1; /* never cleared, but the original tests it */
96 /* the match depends on the do-while and its breaks, the stages' early exit */
97 do {
98 pressed = PAD.getPressed(0);
99 if (pressed & (1 << PAD_R1)) {
100 if (++task->page == 3) {
101 task->page = 0;
102 }
103 changed = 1;
105 break;
106 }
107 if (pressed & (1 << PAD_L1)) {
108 if (--task->page < 0) {
109 task->page = 2;
110 }
111 changed = 1;
113 break;
114 }
115 if (pressed & (1 << PAD_CROSS)) {
118 if (fighter->temporary) {
119 current = fighter->prevId;
120 } else {
121 current = fighter->id;
122 }
123 if (current != task->ids[w->cursor->sel]) {
124 *task->result = task->ids[w->cursor->sel];
125 task->setState(task, 3);
126 w->cursor->locked = 1;
127 break;
128 }
129 }
130 if (pressed & (1 << PAD_TRIANGLE)) {
131 *task->result = -2;
132 task->setState(task, 3);
134 }
135 } while (0);
136 if (w->cursor->sel != task->sel) {
137 task->sel = w->cursor->sel;
138 changed = 1;
139 }
140 if (changed) {
141 if (show) {
142 if (w->info[0] != NULL) {
143 w->info[0]->setState(w->info[0], 2);
144 w->info[1] = FIGHTSTG_createPartnerInfo(task->partner, task->page, w->cursor->sel);
145 } else {
146 if (w->info[1] != NULL) {
147 w->info[1]->setState(w->info[1], 2);
148 }
149 w->info[0] = FIGHTSTG_createPartnerInfo(task->partner, task->page, w->cursor->sel);
150 }
151 } else {
152 if (w->info[0] != NULL) {
153 w->info[0]->setState(w->info[0], 2);
154 }
155 if (w->info[1] != NULL) {
156 w->info[1]->setState(w->info[1], 2);
157 }
158 }
159 }
160 break;
161 case TASK_DONE:
162 case TASK_KILL:
163 break;
164 }
165}
166
167/* Opens the menu of the Digimon the partner *result can digivolve into;
168 *result gets the one picked, or -2 to go back */
171
172 task->result = result;
173 task->partner = *result;
174 *result = -1;
175 return task;
176}
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
MenuCursor * FIGHTSTG_createCursor(CursorLayout *layout)
Creates a menu cursor laid out by layout.
Definition cursor.c:136
#define BATTLE_LAYER_MENUS
the HUD, the menus and the messages
Definition types.h:31
FIGHTSTG.PRO: the battle.
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
DigimonData DIGIMON_DATA[55]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
Definition digimon.c:7
void FIGHTSTG_updateDigivolveMenu(DigivolveMenu *task, void *children)
The digivolve menu's task: L1 and R1 turn the PartnerInfo's page, cross picks one other than the figh...
void FIGHTSTG_showDigivolveNames(DigivolveMenu *task)
Shows the names of the Digimon the menu's partner can digivolve into, its current one in palette 7.
CursorLayout FIGHTSTG_changeCursor
the cursor of the Digimon a partner can change into (FIGHTSTG_updateDigivolveMenu sets its count)
DigivolveMenu * FIGHTSTG_createDigivolveMenu(s32 *result)
Opens the menu of the Digimon the partner *result can digivolve into; result gets the one picked,...
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_NAMES
DIGNAM.
Definition file.h:211
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
DigimonData *(* GET_DIGIMON)(s32 id)
getDigimon for the overlays, in the small data (.sdata) between game/items.c's and file/file_table....
Definition get_digimon.c:10
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_CROSS
Definition pad.h:31
#define PAD_TRIANGLE
Definition pad.h:32
#define PAD_L1
Definition pad.h:28
#define PAD_R1
Definition pad.h:29
PartnerInfo * FIGHTSTG_createPartnerInfo(s32 partner, s32 page, s32 slot)
Shows page page about the partner in slot (0 for itself)
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
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
Definition battle.h:191
u8 temporary
id is a temporary Digimon
Definition battle.h:202
s16 id
the Digimon (DIGIMON_DATA)
Definition battle.h:192
s16 prevId
its own id while id is a temporary one
Definition battle.h:193
s32 active[2]
each side's fighter
Definition battle.h:226
BattleFighter fighters[2][3]
Definition battle.h:227
BattleState state
Definition battle.h:240
A menu cursor's layout, which FIGHTSTG_createCursor copies into its task: a highlight bar over count ...
Definition menu.h:288
s32 count
Definition menu.h:289
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
Definition game_state.h:86
u8 nameId
string in file 0x4F
Definition game_state.h:105
FIGHTSTG_updateDigivolveMenu's children.
Definition menu.h:58
struct MenuCursor * cursor
Definition menu.h:59
struct PartnerInfo * info[2]
shown and hiding, in turns
Definition menu.h:61
The menu of the Digimon the active partner can digivolve into (FIGHTSTG_createDigivolveMenu),...
Definition menu.h:46
void(* nextState)(struct DigivolveMenu *task)
Definition menu.h:47
s32 page
the PartnerInfo page, 0-2
Definition menu.h:50
s32 state
Definition menu.h:47
s32 count
Definition menu.h:53
s16 ids[4]
the partner, then its digivolutions (slots of 3 or more)
Definition menu.h:52
void(* setState)(struct DigivolveMenu *task, s32 state)
Definition menu.h:47
s32 * result
-1 until it is done, then the Digimon or -2
Definition menu.h:48
void * children
Definition menu.h:47
s16 slots[4]
GAME.funcs.getPartnerSlots's.
Definition menu.h:54
s32 partner
*result when it was made
Definition menu.h:49
s32 sel
the cursor's line last frame
Definition menu.h:51
void *(* load)(u32 file)
Definition file.h:92
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
s32(* getPartnerSlots)()
(partner, s16 *out): the count
Definition game_state.h:32
GameFuncs funcs
Definition game_state.h:582
s32 sel
Definition menu.h:304
s32 locked
Definition menu.h:305
s32(* getPressed)(s32 pad)
Definition pad.h:125
void(* setState)(struct PartnerInfo *task, s32 state)
Definition menu.h:201
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131
void(* setPalette)(struct TextWindow *obj, u8 arg)
Definition text.h:174
void(* setString)()
Definition text.h:165
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
#define PALETTE_GREY
what is unavailable
Definition text.h:119
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)