Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
entry_list.c
Go to the documentation of this file.
1/* The entry list: a partner's slots or all its entries, with the stats and
2 skills of the one picked */
3
4#include "menus/digimon_lab.h"
5
6/* Creates the panel's windows */
8 s32 i;
9 TextWindow **items;
10
11 windows->title = createTextWindow(panel->layer, 1, 0xAE, 0x15);
12 for (i = 0; i < 3; i++) {
13 windows->options[i] = createTextWindow(panel->layer, 1, 0xA7, i * 0xE + 0x31);
14 }
15 windows->digimonName = createTextWindow(panel->layer, 1, 0x5B, 0x6A);
16 for (i = 0; i < 6; i++) {
17 windows->values[i] = createTextWindow(panel->layer, 1, 0x7D, i * 0xE + 0x7F);
18 }
19 for (i = 0; i < 7; i++) {
20 windows->values[i + 6] = createTextWindow(panel->layer, 1, 0xA7, i * 0xE + 0x7F);
21 }
22 windows->levelLabel = createTextWindow(panel->layer, 1, 0xEB, 0x6A);
23 windows->values[13] = createTextWindow(panel->layer, 1, 0x12D, 0x6A);
24 for (i = 0; i < 6; i++) {
25 windows->skills[i] = createTextWindow(panel->layer, 1, 0xC2, i * 0xE + 0x8B);
26 }
27 for (i = 0, items = panel->children; i < panel->childCount - 2; i++, items++) {
28 if (*items != NULL) {
29 (*items)->setDepth(*items, panel->depth - 1);
30 }
31 }
32}
33
34/* Shows the list of ids and the stats and skills of the one under the
35 cursor; or hides the panel's windows */
37 PartnerTotals totals;
38 PartnerEntry entry;
39 DigimonData *data;
40 Partner *partner;
41 TextWindow **items;
42 s16 *stats;
43 s32 id;
44 s32 value;
45 s32 i;
46
47 if (show) {
48 if (panel->count == 0) {
49 windows->title->setString(windows->title, FILE_CACHE.load(TEXT_FILE(TEXT_DIGI_LAB)), 0x1E);
50 } else {
51 windows->title->setString(windows->title, FILE_CACHE.load(TEXT_FILE(TEXT_DIGI_LAB)), 0x1F);
52 }
53 partner = &GAME.partners[panel->partner];
54 for (i = 0; i < 3; i++) {
55 id = panel->ids[panel->scroll + i];
56 if (id < 3) {
57 if (i == 0) {
58 windows->options[0]->setString(windows->options[0], FILE_CACHE.load(TEXT_FILE(TEXT_DIGI_LAB)), 0x1B);
59 } else {
60 windows->options[i]->setVisible(windows->options[i], 0);
61 }
62 } else {
64 GET_DIGIMON(id)->nameId);
65 if (partner->battleDigivolve == id) {
66 windows->options[i]->setPalette(windows->options[i], PALETTE_BLUE);
67 } else {
68 windows->options[i]->setPalette(windows->options[i], PALETTE_WHITE);
69 }
70 }
71 }
72 id = panel->ids[panel->scroll + panel->cursor];
73 if (id != 0) {
74 GAME.funcs.getPartnerEntry(panel->partner, id, &entry);
75 GAME.funcs.computeStats(panel->partner, &totals);
76 data = GET_DIGIMON(id);
79 windows->values[13]->setNumber(windows->values[13], 0, entry.level);
80 for (i = 0; i < 6; i++) {
81 value = totals.fields.battle[i] + data->battleStats[i];
82 if (value >= 1000) {
83 value = 999;
84 }
85 windows->values[i]->setNumber(windows->values[i], 0, value);
86 if ((i == 0 && totals.fields.lowered[0] != 0) || (i == 1 && totals.fields.lowered[1] != 0) ||
87 (i == 4 && totals.fields.lowered[2] != 0)) {
88 windows->values[i]->setPalette(windows->values[i], PALETTE_PURPLE);
89 }
90 }
91 stats = totals.stats;
92 for (i = 0; i < 7; i++) {
93 value = stats[i + 12] + data->resistances[i];
94 if (value >= 1000) {
95 value = 999;
96 }
97 windows->values[i + 6]->setNumber(windows->values[i + 6], 0, value);
98 }
99 for (i = 0; i < 6; i++) {
100 if (entry.skills[i] != 0) {
101 windows->skills[i]->setString(windows->skills[i], FILE_CACHE.load(TEXT_FILE(TEXT_SKILL_NAMES)),
102 entry.skills[i] & SKILL_ID);
103 if (entry.skills[i] & SKILL_LAST) {
104 windows->skills[i]->setPalette(windows->skills[i], PALETTE_YELLOW);
105 } else if (entry.skills[i] & SKILL_MARKED) {
106 windows->skills[i]->setPalette(windows->skills[i], PALETTE_GREEN);
107 } else {
108 windows->skills[i]->setPalette(windows->skills[i], PALETTE_WHITE);
109 }
110 } else {
111 windows->skills[i]->setVisible(windows->skills[i], 0);
112 }
113 }
114 for (i = 0; i < 14; i++) {
115 windows->values[i]->setRightAlign(windows->values[i], 1);
116 }
117 } else {
118 windows->digimonName->setVisible(windows->digimonName, 0);
119 windows->levelLabel->setVisible(windows->levelLabel, 0);
120 for (i = 0; i < 14; i++) {
121 windows->values[i]->setVisible(windows->values[i], 0);
122 }
123 }
124 } else {
125 for (i = 0, items = panel->children; i < panel->childCount - 2; i++, items++) {
126 if (*items != NULL) {
127 (*items)->setVisible(*items, 0);
128 }
129 }
130 }
131}
132
133/* The entry list's close: fades it out and hides its windows and cursor */
135 LabEntryListWindows *windows = panel->children;
136
137 STGDGLAB_data.funcs.startFade(&panel->fade, 0);
138 STGDGLAB_showEntryList(panel, windows, 0);
139 windows->cursor->setVisible(windows->cursor, 0);
140 panel->substate++;
141}
142
143/* The panel's states: fades in, moves the cursor through the ids and
144 scrolls the list; triangle closes it */
146 s32 cursor;
147 s32 scroll;
148
149 switch (panel->substate) {
150 case 0:
151 default:
152 STGDGLAB_data.funcs.startFade(&panel->fade, 1);
153 panel->substate++;
154 break;
155 case 1:
156 if (STGDGLAB_data.funcs.updateFade(&panel->fade)) {
157 STGDGLAB_showEntryList(panel, windows, 1);
158 windows->cursor->setVisible(windows->cursor, 1);
159 if (panel->count >= 4) {
161 windows->scrollBar->setX(windows->scrollBar, 0x122, 0xC);
162 windows->scrollBar->setRange(windows->scrollBar, 0x35, 0x55);
163 windows->scrollBar->setCount(windows->scrollBar, 3, panel->count);
164 windows->scrollBar->setPos(windows->scrollBar, panel->cursor);
165 }
166 panel->substate++;
167 }
168 break;
169 case 2:
170 if (panel->count > 0) {
171 cursor = panel->cursor;
172 scroll = panel->scroll;
174 panel->cursor--;
175 if (panel->cursor < 0) {
176 panel->cursor = 0;
177 panel->scroll--;
178 if (panel->scroll < 0) {
179 panel->scroll = 0;
180 }
181 }
182 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
183 if (panel->count >= 3) {
184 panel->cursor++;
185 if (panel->cursor >= 3) {
186 panel->cursor = 2;
187 panel->scroll++;
188 if (panel->scroll > panel->count - 3) {
189 panel->scroll = panel->count - 3;
190 }
191 }
192 } else {
193 panel->cursor++;
194 if (panel->cursor > panel->count - 1) {
195 panel->cursor = panel->count - 1;
196 }
197 }
198 }
199#if VERSION_EU || VERSION_JP
200 if (windows->scrollBar != NULL && scroll != panel->scroll) {
201 windows->scrollBar->setPos(windows->scrollBar, panel->scroll);
202 }
203#endif
204 if (cursor != panel->cursor || scroll != panel->scroll) {
206 STGDGLAB_showEntryList(panel, windows, 1);
207 windows->cursor->setPos(windows->cursor, 0x9A, panel->cursor * 0xE + 0x31);
208#if VERSION_US
209 if (windows->scrollBar != NULL) {
210 windows->scrollBar->setPos(windows->scrollBar, panel->cursor + panel->scroll);
211 }
212#endif
213 }
214 }
215 if (panel->closable != 0 && PAD_PRESSED(PAD_TRIANGLE)) {
218 if (windows->scrollBar != NULL) {
219 windows->scrollBar->state = TASK_KILL;
220 }
221 }
222 break;
223 case 3:
224 if (STGDGLAB_data.funcs.updateFade(&panel->fade)) {
225 panel->setState(panel, TASK_KILL);
226 }
227 break;
228 case 4:
229 windows->cursor->setVisible(windows->cursor, 0);
230 break;
231 case 5:
232 windows->cursor->setVisible(windows->cursor, 1);
233 panel->substate = 2;
234 break;
235 }
236 panel->titlePanel.level = panel->listPanel.level = panel->fade.level;
237}
238
239/* Draws the panel's frames, its scroll arrows and the icons of the skills
240 of the id under the cursor */
242 SpriteDrawer sprite;
243 PartnerEntry entry;
244 s32 i;
245
246 initSpriteDrawer(&sprite);
247 sprite.setTexture(0x280, 0x100);
248 sprite.setLayerId(panel->layer, panel->depth);
249 if (panel->titlePanel.level != ONE) {
250 sprite.setScale(panel->titlePanel.level, ONE, ONE);
251 sprite.setPivot(0x140, 0x15);
252 }
253 sprite.draw(FILE_CACHE.getEntry(FILE_LAB_SPRITES << 16), 0x20, 0x92, 0xF);
254 STRETCH_SPRITE(sprite, panel->listPanel.level, 0x140, 0x45);
255 if (panel->listPanel.level == ONE) {
256 if (GFX.funcs.getTime() - panel->blinkTime >= 8) {
257 panel->blinkTime = GFX.funcs.getTime();
258 panel->blink = 1 - panel->blink;
259 }
260 if (panel->blink) {
261 if (panel->scroll != 0) {
262 sprite.draw(FILE_CACHE.getEntry(FILE_LAB_SPRITES << 16), 0x34, 0x123, 0x2D);
263 }
264 if (panel->scroll < panel->count - 3) {
265 sprite.draw(FILE_CACHE.getEntry(FILE_LAB_SPRITES << 16), 0x35, 0x123, 0x55);
266 }
267 }
268 }
269 sprite.draw(FILE_CACHE.getEntry(FILE_LAB_SPRITES << 16), 0x22, 0x92, 0x2A);
270 if (panel->count > 0) {
271 if (panel->fade.level != ONE) {
272 sprite.setScale(panel->listPanel.level, ONE, ONE);
273 sprite.setPivot(0x140, 0xA4);
274 } else {
275 sprite.setScale(ONE, ONE, ONE);
276 }
277 sprite.draw(FILE_CACHE.getEntry(FILE_LAB_SPRITES << 16), 0x2A, 0x54, 0x64);
278 sprite.setTexture(0x140, 0);
279 sprite.setLayerId(panel->layer, panel->depth - 1);
280 sprite.draw(FILE_CACHE.getEntry(FILE_MENU_SPRITES << 16), 0x14, 0x5B, 0x7F);
281 GAME.funcs.getPartnerEntry(panel->partner, panel->ids[panel->scroll + panel->cursor], &entry);
282 for (i = 0; i < 6; i++) {
283 if (entry.skills[i] != 0) {
285 TECHS[(entry.skills[i] & SKILL_ID) - 1].icon + 0x37, 0xB4, i * 0xE + 0x8B);
286 }
287 }
288 }
289}
290
291/* The entry list's task: lists the partner's slots and, with allEntries, its
292 other entries, creates the windows, then runs and draws the list */
294 s16 slots[4];
295 s16 entries[44];
296 s32 i;
297
298 switch (panel->state) {
299 case TASK_INIT:
300 default:
301 panel->nextState(panel);
302 GAME.funcs.getPartnerSlots(panel->partner, slots);
303 for (i = 0; i < 3; i++) {
304 if (slots[i] < 3) {
305 break;
306 }
307 panel->ids[panel->count] = slots[i];
308 panel->count++;
309 }
310 if (panel->allEntries != 0) {
311 GAME.funcs.listPartnerEntries(panel->partner, entries);
312 for (i = 0; i < 44; i++) {
313 if (entries[i] >= 3 && panel->ids[0] != entries[i] && panel->ids[1] != entries[i] &&
314 panel->ids[2] != entries[i]) {
315 panel->ids[panel->count] = entries[i];
316 panel->count++;
317 }
318 }
319 }
320 STGDGLAB_createEntryListWindows(panel, windows);
321 windows->cursor = createCursor(panel->layer, panel->depth - 1, 0x9A, panel->cursor * 0xE + 0x31);
322 windows->cursor->setVisible(windows->cursor, 0);
323 panel->titlePanel.duration = 10;
324 panel->listPanel.duration = 10;
325 panel->fade.duration = 10;
326 break;
327 case TASK_RUN:
328 STGDGLAB_runEntryList(panel, windows);
329 STGDGLAB_drawEntryList(panel, windows);
330 break;
331 case TASK_DONE:
332 case TASK_KILL:
333 break;
334 }
335}
336
337/* Creates the list of a partner's entries (task): only its slots unless
338 ALLENTRIES; CLOSABLE lets triangle close it */
339LabEntryList *STGDGLAB_createEntryList(s32 partner, s32 allEntries, s32 closable) {
341
343 panel->layer = SCREEN_LAYER;
344 panel->depth = 2;
345 panel->allEntries = allEntries;
346 panel->partner = partner;
347 panel->closable = closable;
348 return panel;
349}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
STGDGLAB.PRO: the Digimon Lab (MODE_DIGI_LAB; "デジモンラボ" in STAGSLCT's list of scenes),...
ScrollBar * STGDGLAB_createScrollBar(void)
#define FILE_LAB_SPRITES
The lab's sprite sheet; the next file is its texture archive.
Definition digimon_lab.h:25
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
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
void STGDGLAB_drawEntryList(LabEntryList *panel, LabEntryListWindows *windows)
Draws the panel's frames, its scroll arrows and the icons of the skills of the id under the cursor.
Definition entry_list.c:241
void STGDGLAB_showEntryList(LabEntryList *panel, LabEntryListWindows *windows, s32 show)
Shows the list of ids and the stats and skills of the one under the cursor; or hides the panel's wind...
Definition entry_list.c:36
void STGDGLAB_closeEntryList(LabEntryList *panel)
The entry list's close: fades it out and hides its windows and cursor.
Definition entry_list.c:134
LabEntryList * STGDGLAB_createEntryList(s32 partner, s32 allEntries, s32 closable)
Creates the list of a partner's entries (task): only its slots unless ALLENTRIES; CLOSABLE lets trian...
Definition entry_list.c:339
void STGDGLAB_updateEntryList(LabEntryList *panel, LabEntryListWindows *windows)
The entry list's task: lists the partner's slots and, with allEntries, its other entries,...
Definition entry_list.c:293
void STGDGLAB_runEntryList(LabEntryList *panel, LabEntryListWindows *windows)
The panel's states: fades in, moves the cursor through the ids and scrolls the list; triangle closes ...
Definition entry_list.c:145
void STGDGLAB_createEntryListWindows(LabEntryList *panel, LabEntryListWindows *windows)
Creates the panel's windows.
Definition entry_list.c:7
#define TEXT_DIGI_LAB
DGLABO: STGDGLAB's.
Definition file.h:208
#define TEXT_SKILL_NAMES
SKLNAM.
Definition file.h:223
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_DIGIMON_NAMES
DIGNAM.
Definition file.h:211
#define FILE_MENU_SPRITES
Files the engine loads by number.
Definition file.h:188
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define SKILL_MARKED
marked in the lab (STGDGLAB_updateSkillPanel)
Definition game_state.h:257
#define SKILL_LAST
the sixth skill
Definition game_state.h:258
#define SKILL_ID
PartnerEntry.skills.
Definition game_state.h:255
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
#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
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
LabData STGDGLAB_data
Definition lab.c:611
#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
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_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...
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setVisible)()
(cursor, visible)
Definition text.h:33
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
u16 battleStats[6]
Definition game_state.h:88
u16 resistances[7]
Definition game_state.h:89
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getPartnerEntry)()
-1 if it hasn't the Digimon
Definition game_state.h:36
void(* computeStats)(s32 partner, union PartnerTotals *out)
Definition game_state.h:31
s32(* getPartnerSlots)()
(partner, s16 *out): the count
Definition game_state.h:32
s32(* listPartnerEntries)()
(partner, s16 *out): the count
Definition game_state.h:34
Partner partners[PARTNER_COUNT]
Definition game_state.h:517
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
LabFuncs funcs
TextWindow * levelLabel
"Skill LV", left of values[13]
TextWindow * skills[6]
TextWindow * values[14]
the battle stats, the resistances, the level
TextWindow * options[3]
ScrollBar * scrollBar
TextWindow * digimonName
TextWindow * title
A panel of the main menu (STGDGLAB_createEntryList)
void(* close)(struct LabEntryList *panel)
PanelAnim titlePanel
their levels follow fade's
void * children
PanelAnim listPanel
void(* setState)(struct LabEntryList *task, s32 state)
s32 ids[50]
the partner's slots, then (allEntries) its other entries
s32 allEntries
list the other entries after the slots
s32 closable
triangle closes it
void(* nextState)(struct LabEntryList *task)
s32 blink
the scroll arrows
PanelAnim fade
s32(* updateFade)(PanelAnim *fade)
void(* startFade)(PanelAnim *fade, s32 fadeIn)
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
One of a partner's Digimon (getPartnerEntry, setPartnerEntry)
Definition game_state.h:247
s8 level
shown in the lab; 1 when added
Definition game_state.h:249
s16 skills[6]
SKILL_ID and the flags below, 0 for none.
Definition game_state.h:251
One of the eight partner Digimon.
Definition game_state.h:345
s32 battleDigivolve
an entry id, compared with the slots': the Digimon the battle starts it as, 0 for its own
Definition game_state.h:348
void(* setCount)(struct ScrollBar *bar, s32 pageSize, s32 count)
Definition menu.h:57
void(* setPos)(struct ScrollBar *bar, s32 pos)
Definition menu.h:58
void(* setRange)(struct ScrollBar *bar, s32 top, s32 bottom)
Definition menu.h:56
s32 state
Definition menu.h:39
void(* setX)(struct ScrollBar *bar, s32 x, s32 width)
Definition menu.h:55
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(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
u8 icon
a frame of the menu sprites, from 0x37
Definition game_state.h:113
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(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setNumber)()
Definition text.h:166
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_PURPLE
Definition text.h:118
#define PALETTE_WHITE
The text windows' palettes (TextWindow.palette, setPalette): rows of the font's CLUTs,...
Definition text.h:112
#define PALETTE_YELLOW
Definition text.h:115
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
computeStats' result: the stats with the equipment added, by STAT_* or by name.
Definition game_state.h:409
s16 lowered[3]
taken from battle[0], [1] and [4]
Definition game_state.h:421
s16 battle[6]
strength (raised by weapons), defense (by armour), spirit, wisdom, speed and charisma (by all equipme...
Definition game_state.h:418
s16 stats[24]
Definition game_state.h:410
struct PartnerTotals::@10 fields