Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
partner_info.c
Go to the documentation of this file.
1/* FIGHTSTG's partner info, the pages of a partner's stats and techniques. */
2
4
5/* Draws the PartnerInfo's blinking page arrows */
7 SpriteDrawer drawer;
8 void *sheet = FILE_CACHE.getEntry(FILE_BATTLE_MENU << 16);
9
10 initSpriteDrawer(&drawer);
12 drawer.setTexture(0x200, 0);
13 if (GFX.funcs.getTime() & 0x10) {
14 drawer.draw(sheet, 0x1F, 0x18, 0xAB);
15 drawer.draw(sheet, 0x20, 0x48, 0xAB);
16 }
17}
18
19/* Shows the PartnerInfo's page buttons (texts 0x11 and 0x12) */
22
23 windows[1] = createTextWindow(BATTLE_LAYER_MENUS, 3, 0x22, 0xAB);
24 windows[1]->setString(windows[1], text, 0x11);
25 windows[1]->setPalette(windows[1], PALETTE_DARK_BLUE);
26 windows[2] = createTextWindow(BATTLE_LAYER_MENUS, 3, 0x38, 0xAB);
27 windows[2]->setString(windows[2], text, 0x12);
28 windows[2]->setPalette(windows[2], PALETTE_DARK_BLUE);
29}
30
31/* Draws the frame of the stats page */
33 SpriteDrawer drawer;
34 void *sheet;
35
36 initSpriteDrawer(&drawer);
39 drawer.setTexture(0x140, 0);
40 drawer.draw(sheet, 0x23, 0x18, 0x51);
42 drawer.setTexture(0x200, 0);
43 drawer.draw(sheet, 0x25, 0x10, 0x4A);
44}
45
46/* the stat numbers of FIGHTSTG_showStats */
48 { 60, 82, 6 },
49 { 60, 96, 7 },
50 { 60, 110, 8 },
51 { 60, 124, 9 },
52 { 60, 138, 10 },
53 { 60, 152, 11 },
54 { 126, 82, 12 },
55 { 126, 96, 13 },
56 { 126, 110, 14 },
57 { 126, 124, 15 },
58 { 126, 138, 16 },
59 { 126, 152, 17 },
60 { 126, 166, 18 },
61};
62
63/* Creates the thirteen stat numbers of FIGHTSTG_statLines (up to 999), right
64 * aligned, in palette 6 for windows 5, 6 and 9 when stats 19, 20 and 21 are
65 * set. The match depends on reading the stat through a pointer sum. */
67 s32 i;
68 s32 value;
69
70 for (i = 0; i < 13; i++) {
72 value = *(task->stats + FIGHTSTG_statLines[i].stat);
73 if (value >= 1000) {
74 value = 999;
75 }
76 windows[i + 5]->setNumber(windows[i + 5], 0, value);
77 windows[i + 5]->setRightAlign(windows[i + 5], 1);
78 }
79 if (task->stats[19]) {
80 windows[5]->setPalette(windows[5], PALETTE_PURPLE);
81 }
82 if (task->stats[20]) {
83 windows[6]->setPalette(windows[6], PALETTE_PURPLE);
84 }
85 if (task->stats[21]) {
86 windows[9]->setPalette(windows[9], PALETTE_PURPLE);
87 }
88}
89
90/* Draws the techniques page's icons and frame */
92 SpriteDrawer drawer;
93 void *sheet;
94 s32 i;
95 s32 tech;
96
97 initSpriteDrawer(&drawer);
100 drawer.setTexture(0x140, 0);
101 for (i = 0; i < 6; i++) {
102 tech = task->techs[i] & SKILL_ID;
103 if (tech != 0) {
104 drawer.draw(sheet, TECHS[tech - 1].icon + 0x37, 0x18, 0x51 + i * 0xE);
105 }
106 }
107 sheet = FILE_CACHE.getEntry(FILE_BATTLE_MENU << 16);
108 drawer.setTexture(0x200, 0);
109 drawer.draw(sheet, 0x26, 0x10, 0x4A);
110}
111
112/* Shows the techniques page: the level (text 0x1A for none) and the six
113 techniques' names, the partner's own in yellow and those it can pass on
114 in green */
117 s32 i;
118 s32 tech;
119
120 windows[3] = createTextWindow(BATTLE_LAYER_MENUS, 1, 0x5A, 0xA9);
121 windows[3]->setString(windows[3], text, 0x19);
122 windows[4] = createTextWindow(BATTLE_LAYER_MENUS, 1, 0x93, 0xA9);
123 if (task->level >= 0) {
124 windows[4]->setNumber(windows[4], 0, task->level);
125 } else {
126 windows[4]->setString(windows[4], text, 0x1A);
127 }
128 windows[4]->setRightAlign(windows[4], 1);
129 for (i = 0; i < 6; i++) {
130 windows[i + 18] = createTextWindow(BATTLE_LAYER_MENUS, 1, 0x26, 0x51 + i * 0xE);
131 tech = task->techs[i];
132 if (tech != 0) {
133 windows[i + 18]->setString(windows[i + 18], FILE_CACHE.load(TEXT_FILE(TEXT_SKILL_NAMES)), tech & SKILL_ID);
134 if (tech & 0x8000) {
135 windows[i + 18]->setPalette(windows[i + 18], PALETTE_YELLOW);
136 } else if (tech & SKILL_MARKED) {
137 windows[i + 18]->setPalette(windows[i + 18], PALETTE_GREEN);
138 }
139 }
140 }
141}
142
143/* The PartnerInfo's task: works out its page (the stats with the slot's
144 Digimon's added, that Digimon's techniques, or those the partner's other
145 Digimon can pass on) and makes its windows, then draws the page each frame */
147 s32 list[10];
148 s32 partner;
149 DigimonData *data;
150 s32 count;
151 s32 tech;
152 s32 n;
153 s32 k;
154 s32 m;
155 s32 i;
156 s32 j;
157
158 switch (task->state) {
159 case 0:
160 default:
161 partner = task->partner;
162 switch (task->page) {
163 case 0:
164 GAME.funcs.computeStats(partner, (PartnerTotals *)task->stats);
165 if (task->slot != 0) {
166 GAME.funcs.getPartnerSlots(partner, task->slots);
167 data = GET_DIGIMON(task->slots[task->slot - 1]);
168 /* the match depends on indexing from &task->stats[STAT_STRENGTH] and [STAT_RESISTS] */
169 for (j = 0; j < 6; j++) {
170 (&task->stats[STAT_STRENGTH])[j] += data->battleStats[j];
171 }
172 for (j = 0; j < 7; j++) {
173 (&task->stats[STAT_RESISTS])[j] += data->resistances[j];
174 }
175 }
176 break;
177 case 1:
178 if (task->slot == 0) {
179 data = &DIGIMON_DATA[partner];
180 task->techs[0] = data->skills[6] | 0x8000;
181 task->level = -1;
182 } else {
183 GAME.funcs.getPartnerSlots(partner, task->slots);
184 GAME.funcs.getPartnerEntry(partner, task->slots[task->slot - 1], &task->entries[0]);
185 task->level = task->entries[0].level;
186 for (j = 0, n = 0; j < 6; j++) {
187 if (task->entries[0].skills[j] != 0) {
188 task->techs[n++] = task->entries[0].skills[j];
189 }
190 }
191 }
192 break;
193 case 2:
194 if (task->slot == 0) {
195 task->level = -1;
196 } else {
197 for (k = 0; k < 10; k++) {
198 list[k] = 0;
199 }
200 k = 0;
201 count = GAME.funcs.getPartnerSlots(partner, task->slots);
202 for (i = 0; i < count; i++) {
203 if (GAME.funcs.getPartnerEntry(partner, task->slots[i], &task->entries[i]) >= 0 &&
204 i != task->slot - 1) {
205 for (j = 0; j < 6; j++) {
206 tech = task->entries[i].skills[j];
207 if (tech != 0 && (tech & SKILL_MARKED)) {
208 list[k++] = tech & SKILL_ID;
209 }
210 }
211 }
212 }
213 n = 0;
214 for (m = 0; m < 10; m++) {
215 tech = list[m];
216 for (k = 0; k < 6; k++) {
217 if (task->techs[k] == list[m]) {
218 tech = 0;
219 break;
220 }
221 }
222 if (tech != 0) {
223 task->techs[n++] = tech;
224 }
225 }
226 task->level = task->entries[task->slot - 1].level;
227 }
228 break;
229 }
230 FIGHTSTG_showPageButtons(task, windows);
231 switch (task->page) {
232 case 0:
233 FIGHTSTG_showStats(task, windows);
234 break;
235 case 1:
236 case 2:
237 FIGHTSTG_showTechs(task, windows);
238 break;
239 }
240 task->nextState(task);
241 break;
242 case 1:
244 switch (task->page) {
245 case 0:
247 break;
248 case 1:
249 case 2:
251 break;
252 }
253 break;
254 case 2:
256 switch (task->page) {
257 case 0:
259 break;
260 case 1:
261 case 2:
263 break;
264 }
265 task->nextState(task);
266 break;
267 case 3:
268 break;
269 }
270}
271
272/* Shows page page about the partner in slot (0 for itself) */
275
276 task->partner = partner;
277 task->page = page;
278 task->slot = slot;
279 return task;
280}
#define BATTLE_LAYER_MENUS
the HUD, the menus and the messages
Definition types.h:31
FIGHTSTG.PRO: the battle.
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
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 TEXT_BATTLE_MENU
MFIGHT: WFIGHTMN's.
Definition file.h:218
#define TEXT_SKILL_NAMES
SKLNAM.
Definition file.h:223
#define TEXT_FILE(file)
Definition file.h:190
#define FILE_BATTLE_MENU
The battle menu's files (WFIGHTMN, WFIGHTTS): FILE_BATTLE_IMAGES is an archive whose entries go throu...
Definition file.h:294
#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 STAT_STRENGTH
the six battle stats
Definition game_state.h:286
#define SKILL_MARKED
marked in the lab (STGDGLAB_updateSkillPanel)
Definition game_state.h:257
#define STAT_RESISTS
the first of the seven resistances
Definition game_state.h:292
#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
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
void FIGHTSTG_drawPageArrows(PartnerInfo *task)
Draws the PartnerInfo's blinking page arrows.
Definition partner_info.c:6
PartnerInfo * FIGHTSTG_createPartnerInfo(s32 partner, s32 page, s32 slot)
Shows page page about the partner in slot (0 for itself)
void FIGHTSTG_updatePartnerInfo(PartnerInfo *task, TextWindow **windows)
The PartnerInfo's task: works out its page (the stats with the slot's Digimon's added,...
void FIGHTSTG_showStats(PartnerInfo *task, TextWindow **windows)
Creates the thirteen stat numbers of FIGHTSTG_statLines (up to 999), right aligned,...
void FIGHTSTG_drawTechIcons(PartnerInfo *task)
Draws the techniques page's icons and frame.
void FIGHTSTG_showPageButtons(PartnerInfo *task, TextWindow **windows)
Shows the PartnerInfo's page buttons (texts 0x11 and 0x12)
StatLine FIGHTSTG_statLines[13]
the stat numbers of FIGHTSTG_showStats
void FIGHTSTG_showTechs(PartnerInfo *task, TextWindow **windows)
Shows the techniques page: the level (text 0x1A for none) and the six techniques' names,...
void FIGHTSTG_drawStatsFrame(PartnerInfo *task)
Draws the frame of the stats page.
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
Definition game_state.h:86
u16 skills[7]
[1]-[6] are learnt at skillLevels
Definition game_state.h:90
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
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
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
A page about a partner in one of its Digimon (FIGHTSTG_createPartnerInfo): its stats,...
Definition menu.h:200
s32 page
what it shows: 0 the stats, 1 and 2 techniques
Definition menu.h:204
s32 slot
from 1, or 0 for the partner itself
Definition menu.h:205
s32 state
Definition menu.h:201
s16 slots[4]
GAME.funcs.getPartnerSlots's.
Definition menu.h:208
s32 partner
Definition menu.h:203
s32 level
the Digimon's (PartnerEntry.level), or -1 for none: text 0x1A
Definition menu.h:206
s16 stats[0x16]
the 22 of a PartnerTotals computeStats fills, shown up to 999
Definition menu.h:207
void(* nextState)(struct PartnerInfo *task)
Definition menu.h:201
PartnerEntry entries[3]
skills with SKILL_MARKED can be passed on
Definition menu.h:209
s32 techs[6]
a technique in the low 13 bits
Definition menu.h:210
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(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
A line of FIGHTSTG_showStats's stat list (FIGHTSTG_statLines): where its number goes and the stat it ...
Definition menu.h:215
u8 stat
of PartnerInfo.stats
Definition menu.h:218
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 * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
#define PALETTE_DARK_BLUE
Definition text.h:114
#define PALETTE_GREEN
Definition text.h:116
#define PALETTE_PURPLE
Definition text.h:118
#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