Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
info.c
Go to the documentation of this file.
1/* The details window of the save under the cursor */
2
3#include "menus/memory_card.h"
4
5/* Starts fading the details window in (info->show) */
7 info->setSubstate(info, 1);
8}
9
10/* Hides the details window's text and starts fading it out (info->hide) */
12 TextWindow **windows;
13 s32 i;
14
15 info->setSubstate(info, 2);
16 windows = info->children;
17 for (i = 0; i < info->childCount; i++, windows++) {
18 if (*windows != NULL) {
19 (*windows)->setVisible(*windows, 0);
20 }
21 }
22}
23
24/* Fills the details window with the selected save, or hides it */
26 MemCardSave *save;
27 TextWindow **windows;
28 TextWindow **w;
29 s32 *partners;
30 s32 i;
31
32 save = &info->saves->file.saves[STGMCARD_funcs.slot];
33 windows = info->children;
34 if (info->shown == 0) {
35 for (i = 0, w = windows; i < info->childCount; i++, w++) {
36 (*w)->setVisible(*w, 0);
37 }
38 } else if (save->name[0] == 0) {
39 for (i = 0, w = windows; i < info->childCount; i++, w++) {
40 (*w)->setString(*w, FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), STGMCARD_detailWindows[i].text);
41 if (STGMCARD_detailWindows[i].isNumber != 0) {
42 (*w)->setNumber(*w, 1, 0);
43 (*w)->setRightAlign(*w, 1);
44 (*w)->setPos(*w, STGMCARD_detailWindows[i].x, STGMCARD_detailWindows[i].y);
45 }
46 }
47 } else {
48 windows[0]->setString(windows[0], save, -1);
49 windows[1]->setString(windows[1], FILE_CACHE.load(TEXT_FILE(TEXT_AREA_NAMES)), save->area);
50 windows[2]->setString(windows[2], FILE_CACHE.load(TEXT_FILE(TEXT_SHOP_NAMES)), save->place);
51 for (i = 0; i < 2; i++) {
52 windows[i + 3]->setString(windows[i + 3], FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), 0x15);
53 }
54 windows[5]->setNumber(windows[5], 0, save->money);
55 windows[5]->setRightAlign(windows[5], 1);
56 windows[12]->setNumber(windows[12], 0, save->time.hours);
57 windows[13]->setNumber(windows[13], 0, save->time.minutes);
58 windows[14]->setNumber(windows[14], 0, save->time.seconds);
59 for (i = 0, w = &windows[12]; i < 3; i++, w++) {
60 (*w)->setRightAlign(*w, 1);
61 }
62 if (save->time.minutes < 10) {
63 windows[17]->setNumber(windows[17], 0, 0);
64 windows[17]->setRightAlign(windows[17], 1);
65 windows[17]->setPos(windows[17], 0x111, 0xB2);
66 } else {
67 windows[17]->setVisible(windows[17], 0);
68 }
69 if (save->time.seconds < 10) {
70 windows[18]->setNumber(windows[18], 0, 0);
71 windows[18]->setRightAlign(windows[18], 1);
72 windows[18]->setPos(windows[18], 0x124, 0xB2);
73 } else {
74 windows[18]->setVisible(windows[18], 0);
75 }
76 for (i = 0; i < 2; i++) {
77 windows[i + 15]->setString(windows[i + 15], FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), 0x13);
78 }
79 partners = info->saves->file.saves[STGMCARD_funcs.slot].partners;
80 for (i = 0; i < 3; i++) {
81 windows[i + 6]->setString(windows[i + 6], FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), 0x14);
82 if (partners[i] - 3 < 0) {
83 windows[i + 9]->setString(windows[i + 9], FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), 0x23);
84 } else {
85 windows[i + 9]->setNumber(windows[i + 9], 0, save->levels[i]);
86 }
87 windows[i + 9]->setRightAlign(windows[i + 9], 1);
88 info->frames[i] = 0;
89 }
90 info->time = 0;
91 }
92}
93
94/* The details window's task: creates its text windows, fades it in and out,
95 and draws the selected save's partners and frame */
97 SpriteDrawer sprite;
98 TextWindow **windows;
99 s32 *partners;
100 s32 i;
101 s32 j;
102
103 switch (info->state) {
104 case TASK_INIT:
105 default:
106 info->nextState(info);
107#if VERSION_US
109#elif VERSION_EU || VERSION_JP
110 STGMCARD_detailWindows[0].text = LANGUAGE != 0 ? 0x21 : 0x20;
111#endif
112 windows = info->children;
113 for (i = 0; i < info->childCount; i++, windows++) {
114 if (*windows == NULL) {
116 }
117 /* the match depends on the unsigned compare, which GCC makes a sltiu */
118 if (i < 3U) {
119 (*windows)->setPalette(*windows, PALETTE_BLUE);
120 }
121 }
122 info->fade.duration = 8;
123 break;
124 case TASK_RUN:
125 switch (info->substate) {
126 case 0:
127 default:
128 break;
129 case 1:
130 switch (info->step) {
131 case 0:
132 default:
133 STGMCARD_funcs.startFade(&info->fade, 1);
134 info->step++;
135 break;
136 case 1:
137 if (STGMCARD_funcs.updateFade(&info->fade) != 0) {
138 info->setSubstate(info, 0);
139 }
140 break;
141 }
142 break;
143 case 2:
144 switch (info->step) {
145 case 0:
146 default:
147 STGMCARD_funcs.startFade(&info->fade, 0);
148 info->shown = 0;
150 info->step++;
151 break;
152 case 1:
153 if (STGMCARD_funcs.updateFade(&info->fade) != 0) {
154 info->drawing = 0;
155 info->setSubstate(info, 0);
156 }
157 break;
158 }
159 break;
160 }
161 if (info->drawing == 0) {
162 break;
163 }
164 initSpriteDrawer(&sprite);
165 sprite.setTexture(0x280, 0);
166 sprite.setLayerId(info->layer, info->depth);
167 if (info->fade.level != ONE) {
168 sprite.setScale(ONE, info->fade.level, ONE);
169 sprite.setPivot(160, 148);
170 }
171 partners = info->saves->file.saves[STGMCARD_funcs.slot].partners;
172 if (GFX.funcs.getTime() - info->time >= 13) {
173 info->time = GFX.funcs.getTime();
174 for (j = 0; j < 3; j++) {
175 if (partners[j] - 3 >= 0) {
176 info->frames[j]++;
177 if (info->frames[j] >= 8) {
178 info->frames[j] = 0;
179 }
180 if (STGMCARD_partnerAnims[partners[j] - 3][info->frames[j]] == -1) {
181 info->frames[j] = 0;
182 }
183 }
184 }
185 }
186 for (j = 0; j < 3; j++) {
187 if (partners[j] - 3 >= 0) {
188 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), STGMCARD_partnerAnims[partners[j] - 3][info->frames[j]], 154 + j * 52, 133);
189 }
190 }
191 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 36, 16, 116);
192 sprite.setLayerId(info->layer, info->depth - 1);
193 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 37, 16, 116);
194 break;
195 case TASK_DONE:
196 case TASK_KILL:
197 break;
198 }
199}
200
201/* Creates the details window (task) of the save list */
204
205 info->show = STGMCARD_showInfo;
206 info->hide = STGMCARD_hideInfo;
208 info->layer = SCREEN_LAYER;
209 info->saves = saves;
210 info->depth = 1;
211 return info;
212}
#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
#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
s32 LANGUAGE
The European version's settings, in the small data (.sdata) between file/file_table....
Definition eu_settings.c:13
#define TEXT_MEMORY_CARD
MEMCRD.
Definition file.h:217
#define TEXT_AREA_NAMES
STAREA.
Definition file.h:224
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_SHOP_NAMES
SHPNAM.
Definition file.h:221
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#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 STGMCARD_hideInfo(MemCardInfo *info)
Hides the details window's text and starts fading it out (info->hide)
Definition info.c:11
void STGMCARD_showInfo(MemCardInfo *info)
Starts fading the details window in (info->show)
Definition info.c:6
void STGMCARD_refreshInfo(MemCardInfo *info)
Fills the details window with the selected save, or hides it.
Definition info.c:25
MemCardInfo * STGMCARD_createInfo(MemCardSaves *saves)
Creates the details window (task) of the save list.
Definition info.c:202
void STGMCARD_updateInfo(MemCardInfo *info)
The details window's task: creates its text windows, fades it in and out, and draws the selected save...
Definition info.c:96
STGMCARD.PRO: the memory card screen (MODE_CONTINUE).
#define FILE_GMCARD_SHEET
Definition memory_card.h:19
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
MemCardWindowSpec STGMCARD_detailWindows[]
the details' text windows: their text, type and place
Definition stgmcard.c:6
MemCardScreenFuncs STGMCARD_funcs
STGMCARD's data (data/stgmcard.c)
Definition stgmcard.c:127
s32 STGMCARD_partnerAnims[][7]
the partners' sprites while they wait, by partner (from 3): -1 ends a loop
Definition stgmcard.c:29
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
MemCardSave saves[3]
Definition memory_card.h:89
The window with the selected save's details (STGMCARD_updateInfo)
MemCardSaves * saves
s32 frames[3]
of the three partners' animations
void(* hide)(struct MemCardInfo *info)
void(* refresh)(struct MemCardInfo *info)
void(* nextState)(struct MemCardInfo *task)
PanelAnim fade
void(* setSubstate)(struct MemCardInfo *task, s32 substate)
s32 drawing
the partners and frame are drawn
void(* show)(struct MemCardInfo *info)
void * children
A save of the memory card, as the list shows it.
Definition memory_card.h:71
u8 name[0x18]
empty for a free slot
Definition memory_card.h:72
s16 levels[3]
Definition memory_card.h:79
PlayTime time
Definition memory_card.h:76
s32 area
MemCardScreen's.
Definition memory_card.h:73
s32 partners[3]
3 and up: a partner, whose animation the details show
Definition memory_card.h:77
The saves of a memory card (STGMCARD_updateSaves)
MemCardFile file
the card's
s32(* updateFade)(PanelAnim *fade)
s32 slot
the selected one
void(* startFade)(PanelAnim *fade, s32 fadeIn)
s32 text
a string of text file 0x79
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
s16 seconds
Definition game_state.h:334
s16 minutes
Definition game_state.h:333
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
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131
void(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setNumber)()
Definition text.h:166
void(* setPos)(struct TextWindow *obj, s16 x, s16 y)
Definition text.h:173
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
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)