Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
helpers.c
Go to the documentation of this file.
1/* The helpers the screens call through STSTATUS_data and STSTATUS_areaFuncs:
2 the towns, the item lists, equipping, the area; and the last object's data,
3 which all the objects read */
4
5#include "menus/field_menu.h"
6
7/* The towns the map shows (a list up to 0), by STSTATUS_getGameHalf and
8 GAME.progress (STSTATUS_townLists) */
9s32 *STSTATUS_getTowns(s32 list, s32 index) {
10 return STSTATUS_townLists[list][index];
11}
12
13/* Puts the owned items of a list in OUT and returns how many: below 5 the
14 item lists of ITEM_FUNCS, 5 the equipment of STSTATUS_equipKinds, 6 and 7
15 the items of kinds 4 and 5 (STSTATUS_slotLists) */
17 if (list < 5) {
18 return ITEM_FUNCS.list(list, out);
19 }
20 switch (list) {
21 case 5:
22 default:
23 return STSTATUS_listEquipItems(out);
24 case 6:
25 return STSTATUS_listItemsOfKind(4, out);
26 case 7:
27 return STSTATUS_listItemsOfKind(5, out);
28 }
29}
30
31/* The items whose kind (WeaponData.kind) is one of STSTATUS_equipKinds's four */
33 s32 i;
34 s32 j;
35 s32 count;
36 ItemData *data;
37
40 count = 0;
41 for (i = 0; i < STSTATUS_data.itemCount; i++) {
43 for (j = 0; j < 4; j++) {
44 if (data->weapon.kind == STSTATUS_equipKinds[j]) {
45 out[count++] = STSTATUS_data.items[i];
46 }
47 }
48 }
49 for (i = 0; i < STSTATUS_data.item2Count; i++) {
51 for (j = 0; j < 4; j++) {
52 if (data->weapon.kind == STSTATUS_equipKinds[j]) {
53 out[count++] = STSTATUS_data.items2[i];
54 }
55 }
56 }
57 return count;
58}
59
60/* The items of one kind (WeaponData.kind) */
62 s32 i;
63 s32 count;
64
67 count = 0;
68 for (i = 0; i < STSTATUS_data.itemCount; i++) {
70 out[count++] = STSTATUS_data.items[i];
71 }
72 }
73 for (i = 0; i < STSTATUS_data.item2Count; i++) {
75 out[count++] = STSTATUS_data.items2[i];
76 }
77 }
78 return count;
79}
80
81/* Whether a partner can put an item in an equipment slot (-1: none): its
82 partners has a bit per partner; kind 1 can't go in slot 3, nor 2 in slot 2 */
83s32 STSTATUS_canEquip(s32 partner, s32 slot, s32 item) {
84 ItemData *data;
85
86 if (item != -1) {
87 data = ITEM_FUNCS.get(item)->data.record;
88 if (!((data->weapon.partners >> partner) & 1)) {
89 return 0;
90 }
91 if (data->weapon.kind == EQUIP_KIND_RIGHT_HAND) {
92 if (slot == 3) {
93 return 0;
94 }
95 } else if (data->weapon.kind == EQUIP_KIND_LEFT_HAND) {
96 if (slot == 2) {
97 return 0;
98 }
99 }
100 }
101 return 1;
102}
103
104/* Puts an item in a partner's equipment slot (0 or less: empties it), moving
105 the counts between GAME.items and GAME.equippedItems. Kind 7 takes slots 2
106 and 3; kind 8 replaces one in slots 4 and 5 with the same group */
107void STSTATUS_equip(s32 partner, s32 slot, s32 item) {
108 PartnerStats *stats = GAME.funcs.getPartnerStats(partner);
109 s16 *equip;
110 s16 *pair;
111 ItemData *data;
112 s32 group;
113 s32 old;
114 s32 i;
115 s32 id = item; /* the match depends on this copy and on *(stats->equip + slot) */
116
117 old = *(stats->equip + slot);
118 if (old != 0) {
119 GAME.equippedItems[old]--;
120 GAME.items[old]++;
121 data = ITEM_FUNCS.get(old)->data.record;
122 if (data->weapon.kind == EQUIP_KIND_BOTH_HANDS) {
123 stats->equip[2] = 0;
124 stats->equip[3] = 0;
125 } else {
126 *(stats->equip + slot) = 0;
127 }
128 }
129 if (id > 0) {
130 data = ITEM_FUNCS.get(id)->data.record;
131 if (data->weapon.kind == EQUIP_KIND_BOTH_HANDS) {
132 pair = &stats->equip[2];
133 if (stats->equip[2] == 0) {
134 pair = NULL;
135 if (stats->equip[3] != 0) {
136 pair = &stats->equip[3];
137 }
138 }
139 if (pair != NULL) {
140 GAME.equippedItems[*pair]--;
141 GAME.items[*pair]++;
142 *pair = 0;
143 }
144 } else if (data->weapon.kind == EQUIP_KIND_GROUP_ACCESSORY) {
145 group = data->weapon.group;
146 for (i = 0; i < 2; i++) {
147 equip = &stats->equip[i + 4];
148 if (*equip != 0) {
149 data = ITEM_FUNCS.get(*equip)->data.record;
150 if (data->weapon.group == group) {
151 GAME.equippedItems[*equip]--;
152 GAME.items[*equip]++;
153 *equip = 0;
154 }
155 }
156 }
157 }
158 GAME.equippedItems[id]++;
159 GAME.items[id]--;
160 data = ITEM_FUNCS.get(id)->data.record;
161 if (data->weapon.kind == EQUIP_KIND_BOTH_HANDS) {
162 stats->equip[2] = id;
163 stats->equip[3] = id;
164 } else {
165 *(stats->equip + slot) = id;
166 }
167 }
168}
169
170/* 1 on the field maps of the second half of the game (0x270 on), 0 on those of
171 the first, -1 past them (0x2D7 on) */
173 if (GAME.fieldMode >= 0x2D7) {
174 return -1;
175 }
176 return GAME.fieldMode >= 0x270;
177}
178
179/* The map's area of the current field map (STSTATUS_mapAreas) */
181 return STSTATUS_mapAreas[(u8)GAME.fieldMode] & 0x7F;
182}
183
184/* Sets OUT[area] to 1 for the map's areas of this half of the game that have a
185 field map whose flag (0x2000 + the map's low byte) is set */
187 s32 first;
188 s32 last;
189 s32 i;
190 s32 area;
191 s32 found;
192
193 if (STSTATUS_getGameHalf() == 0) {
194 first = 0x200;
195 last = 0x26F;
196 } else {
197 first = 0x270;
198 last = 0x2D6;
199 }
200 for (i = first; i <= last; i++) {
201 area = STSTATUS_mapAreas[i & 0xFF] & 0x7F;
202 found = FLAGS_00.checkCondition((i & 0xFF) | 0x2000, 1);
203 if (found == 1) {
204 out[area] = found;
205 }
206 }
207}
208
209/* The map cursor's frames */
211 0, 1, 2, 1,
212};
213
214/* The field menu's screens, by FIELD_MENU_CHOICE */
219/* The partners' portrait animations */
221 { { 7, 8, 9, 10, 9, 8, -1 } },
222 { { 14, 15, 16, 15, -1, -1, -1 } },
223 { { 11, 12, 13, 12, -1, -1, -1 } },
224 { { 3, 4, 5, 6, 5, 4, -1 } },
225 { { 25, 26, 27, 28, 27, 26, -1 } },
226 { { 0, 1, 2, 1, -1, -1, -1 } },
227 { { 17, 18, 19, 20, 19, 18, -1 } },
228 { { 21, 22, 23, 24, 23, 22, -1 } },
229};
230/* Where the screens' windows go, and their strings */
232 { 12, 55, 0, 19 },
233 { 1, 16, 0, 28 },
234 { 2, 16, 0, 37 },
235 { 4, 61, 0, 37 },
236 { 3, 16, 0, 46 },
237 { 4, 61, 0, 46 },
238 { 13, 44, 0, 28 },
239 { 14, 59, 0, 37 },
240 { 14, 94, 0, 37 },
241 { 14, 59, 0, 46 },
242 { 14, 94, 0, 46 },
243 { 14, 152, 0, 19 },
244 { 14, 20, 0, 198 },
245 { 3, 265, 0, 212 },
246 { 14, 300, 0, 212 },
247 { 22, 189, 0, 49 },
248};
249/* The map's areas (STSTATUS_mapAreas), from 1 */
251 { 0, 0, 0 },
252 { 1, 60, 53 },
253 { 2, 100, 59 },
254 { 3, 126, 74 },
255 { 4, 174, 79 },
256 { 4, 208, 61 },
257 { 5, 209, 36 },
258 { 6, 288, 52 },
259 { 7, 59, 98 },
260 { 8, 116, 102 },
261 { 9, 149, 104 },
262 { 10, 204, 85 },
263 { 10, 251, 152 },
264 { 10, 253, 220 },
265 { 11, 259, 99 },
266 { 12, 303, 115 },
267 { 13, 340, 105 },
268 { 14, 57, 123 },
269 { 15, 162, 138 },
270 { 15, 158, 223 },
271 { 16, 186, 119 },
272 { 17, 251, 126 },
273 { 17, 224, 127 },
274 { 18, 279, 130 },
275 { 19, 304, 141 },
276 { 20, 330, 130 },
277 { 21, 60, 169 },
278 { 22, 122, 162 },
279 { 22, 109, 205 },
280 { 22, 89, 163 },
281 { 23, 185, 143 },
282 { 24, 332, 153 },
283 { 24, 294, 190 },
284 { 25, 199, 167 },
285 { 26, 47, 199 },
286 { 27, 72, 213 },
287 { 28, 185, 221 },
288 { 29, 265, 194 },
289 { 30, 319, 234 },
290 { 31, 35, 254 },
291 { 32, 69, 248 },
292 { 33, 191, 247 },
293 { 34, 224, 227 },
294 { 35, 297, 215 },
295 { 35, 276, 233 },
296 { 36, 296, 253 },
297 { 37, 225, 253 },
298};
299/* Where the map's towns are, from 1 */
301 { 0, 0 },
302 { 171, 65 },
303 { 154, 123 },
304 { 230, 104 },
305 { 182, 174 },
306 { 286, 129 },
307 { 285, 56 },
308 { 316, 133 },
309 { 262, 161 },
310 { 249, 193 },
311 { 253, 251 },
312 { 172, 221 },
313 { 160, 221 },
314 { 21, 242 },
315 { 25, 160 },
316 { 67, 151 },
317 { 30, 106 },
318 { 32, 45 },
319 { 114, 78 },
320 { 55, 34 },
321 { 128, 88 },
322 { 165, 43 },
323 { 198, 36 },
324};
325/* The towns the map shows at each stage of the game, up to 0 */
327 1, 2, 3, 4,
328 5, 7, 0,
329};
331 1, 2, 3, 4,
332 5, 7, 8, 9,
333 10, 11, 12, 0,
334};
336 1, 2, 3, 4,
337 5, 7, 8, 9,
338 10, 11, 12, 6,
339 13, 14, 15, 16,
340 17, 0,
341};
343 1, 2, 3, 4,
344 5, 7, 8, 9,
345 10, 11, 12, 6,
346 13, 14, 15, 16,
347 17, 18, 19, 20,
348 21, 22, 0,
349};
351/* The towns the map shows, by STSTATUS_getGameHalf and GAME.progress */
370/* The item kinds (WeaponData.kind) of item list 5 */
375/* The map's area of each field map, by GAME.fieldMode's low byte (bit 7
376 marks the late game's maps, 0x70 on; 0xFF: none) */
378 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
379 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
380 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
381 0x13, 0x13, 0x13, 0x13, 0x13, 0x1D, 0x15, 0x20,
382 0x11, 0x14, 0x14, 0x0B, 0x0B, 0x0D, 0x0D, 0x16,
383 0x06, 0x17, 0x18, 0x0F, 0x1E, 0x1E, 0x0E, 0x0E,
384 0x0E, 0x0E, 0x1F, 0x2A, 0x2A, 0x25, 0x25, 0x2B,
385 0x0C, 0x24, 0x2C, 0x2D, 0x28, 0x12, 0x29, 0x29,
386 0x29, 0x29, 0x23, 0x23, 0x23, 0x23, 0x23, 0x1B,
387 0x22, 0x19, 0x1C, 0x1A, 0x10, 0x07, 0x07, 0x07,
388 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x22,
389 0x27, 0x27, 0x26, 0x26, 0x26, 0x21, 0x21, 0x21,
390 0x21, 0x09, 0x03, 0x0A, 0x04, 0x02, 0x01, 0x00,
391 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x05, 0x05,
392 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93,
393 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93,
394 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93,
395 0x93, 0x93, 0x93, 0x93, 0x9D, 0x95, 0xA0, 0x91,
396 0x94, 0x94, 0x8B, 0x8B, 0x8D, 0x8D, 0x96, 0x86,
397 0x97, 0x98, 0x8F, 0x9E, 0x8E, 0x8E, 0x8E, 0x8E,
398 0x9F, 0xAA, 0xAA, 0xA5, 0xAB, 0x8C, 0xA4, 0xAC,
399 0xAD, 0xA8, 0x92, 0xA9, 0xA9, 0xA9, 0xA9, 0xA3,
400 0xA3, 0x9B, 0xA2, 0x99, 0x9C, 0x9A, 0x90, 0x87,
401 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87,
402 0xA2, 0xA7, 0xA7, 0xA6, 0xA6, 0xA6, 0xA1, 0xA1,
403 0xA1, 0x89, 0x83, 0x8A, 0x84, 0x82, 0x81, 0x80,
404 0x88, 0x88, 0x88, 0x88, 0x88, 0x85, 0x85, 0xFF,
405 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
406 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
407 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
408};
409/* Where the game is */
Task * STSTATUS_createCardScreen(FieldMenuScreen *menu, s32 extra)
Creates the screen with the party's pages (task) whose two options go to the card album (MODE_CARD_AL...
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned char u8
Definition common.h:8
Task * STSTATUS_createDemoScreen(FieldMenuScreen *menu, s32 extra)
Creates the second screen with the party's pages (task), whose two options set GAME....
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
STSTATUS.PRO: the field menu's screens.
void STSTATUS_startFade(PanelAnim *fade, s32 fadeIn)
s32 STSTATUS_updateFade(PanelAnim *fade)
s32 STSTATUS_updateLerp(MenuLerp *lerp)
#define EQUIP_KIND_RIGHT_HAND
Where an equipment item goes (its record's kind), as the shop's and STSTATUS's strings name the kinds...
Definition game_state.h:134
#define EQUIP_KIND_LEFT_HAND
Definition game_state.h:135
#define EQUIP_KIND_GROUP_ACCESSORY
one of its group at a time
Definition game_state.h:141
#define EQUIP_KIND_EITHER_HAND
Definition game_state.h:136
#define EQUIP_KIND_BOTH_HANDS
takes slots 2 and 3
Definition game_state.h:140
s32 STSTATUS_noTowns
Definition helpers.c:350
s32 STSTATUS_cursorFrames[]
The map cursor's frames.
Definition helpers.c:210
s32 STSTATUS_townList0[]
The towns the map shows at each stage of the game, up to 0.
Definition helpers.c:326
s32 STSTATUS_listItems(s32 list, s16 *out)
Puts the owned items of a list in OUT and returns how many: below 5 the item lists of ITEM_FUNCS,...
Definition helpers.c:16
void STSTATUS_getVisitedAreas(s32 *out)
Sets OUT[area] to 1 for the map's areas of this half of the game that have a field map whose flag (0x...
Definition helpers.c:186
u8 STSTATUS_equipKinds[]
The item kinds (WeaponData.kind) of item list 5.
Definition helpers.c:371
s32 STSTATUS_listEquipItems(s16 *out)
The items whose kind (WeaponData.kind) is one of STSTATUS_equipKinds's four.
Definition helpers.c:32
StatusAreaFuncs STSTATUS_areaFuncs
Where the game is.
Definition helpers.c:410
PartnerAnim STSTATUS_partnerAnims[]
The partners' portrait animations.
Definition helpers.c:220
s32 STSTATUS_canEquip(s32 partner, s32 slot, s32 item)
Whether a partner can put an item in an equipment slot (-1: none): its partners has a bit per partner...
Definition helpers.c:83
s32 STSTATUS_getArea(void)
The map's area of the current field map (STSTATUS_mapAreas)
Definition helpers.c:180
Task *(* STSTATUS_screens[2][7])(FieldMenuScreen *menu, s32 extra)
The field menu's screens, by FIELD_MENU_CHOICE.
Definition helpers.c:215
s32 STSTATUS_townList1[]
Definition helpers.c:330
s32 STSTATUS_listItemsOfKind(s32 kind, s16 *out)
The items of one kind (WeaponData.kind)
Definition helpers.c:61
u8 STSTATUS_mapAreas[]
The map's area of each field map, by GAME.fieldMode's low byte (bit 7 marks the late game's maps,...
Definition helpers.c:377
s32 * STSTATUS_getTowns(s32 list, s32 index)
The towns the map shows (a list up to 0), by STSTATUS_getGameHalf and GAME.progress (STSTATUS_townLis...
Definition helpers.c:9
StatusMapPoint STSTATUS_towns[]
Where the map's towns are, from 1.
Definition helpers.c:300
StatusMapSpot STSTATUS_spots[]
The map's areas (STSTATUS_mapAreas), from 1.
Definition helpers.c:250
s32 STSTATUS_townList3[]
Definition helpers.c:342
void STSTATUS_equip(s32 partner, s32 slot, s32 item)
Puts an item in a partner's equipment slot (0 or less: empties it), moving the counts between GAME....
Definition helpers.c:107
s32 * STSTATUS_townLists[][5]
The towns the map shows, by STSTATUS_getGameHalf and GAME.progress.
Definition helpers.c:352
s32 STSTATUS_getGameHalf(void)
1 on the field maps of the second half of the game (0x270 on), 0 on those of the first,...
Definition helpers.c:172
StatusData STSTATUS_data
Definition helpers.c:356
s32 STSTATUS_townList2[]
Definition helpers.c:335
WindowPos STSTATUS_layout[]
Where the screens' windows go, and their strings.
Definition helpers.c:231
Task * STSTATUS_createItemScreen(FieldMenuScreen *menu, s32 extra)
Creates the field menu's first screen (task), the items.
ItemFuncs ITEM_FUNCS
Definition items.c:890
Task * STSTATUS_createMapScreen(FieldMenuScreen *menu, s32 extra)
Creates the map screen (task): the map of the first half of the game or, in the late game,...
Definition map_screen.c:322
void STSTATUS_startLerp(MenuLerp *lerp, s32 from, s32 to, s32 frames)
Starts moving a value from FROM to TO in FRAMES frames, playing SOUND_MENU_OPEN; nothing when they ar...
Definition menu.c:173
void STSTATUS_loadFiles(void)
Loads the menu's textures and requests its strings: the menu's, the items', the Digimon's and the ski...
Definition menu.c:130
s32 STSTATUS_filesLoading(void)
Whether the menu's strings are still loading.
Definition menu.c:146
Task * STSTATUS_createSortScreen(FieldMenuScreen *menu, s32 extra)
Creates the field menu's party order screen (task), where two members swap places.
Task * STSTATUS_createStatusScreen(FieldMenuScreen *menu, s32 extra)
Creates the field menu's fifth screen (task), the party's stats, slots and equipment.
The mode's main task (STSTATUS_createMenu)
Definition field_menu.h:25
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
struct PartnerStats *(* getPartnerStats)(s32 partner)
Definition game_state.h:38
s8 items[0x193]
counts, up to 99
Definition game_state.h:512
s8 equippedItems[0x193]
Definition game_state.h:513
s32 fieldMode
where the menu returns to
Definition game_state.h:503
GameFuncs funcs
Definition game_state.h:582
struct ItemInfo *(* get)(s32 item)
getItem
Definition game_state.h:670
s32(* list)(s32 type, s16 *out)
listItems
Definition game_state.h:673
ItemRecord data
the type's record, or the usable items' effect
Definition game_state.h:226
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
A partner Digimon from its name on (Partner.info), as getPartnerStats gives it.
Definition game_state.h:303
Where the game is (STSTATUS_areaFuncs)
Definition field_menu.h:286
The screens' tables, item lists and helpers, in one object: the functions that use two of them keep i...
Definition field_menu.h:436
s16 items[404]
ITEM_FUNCS.list(2)
Definition field_menu.h:441
s16 items2[404]
ITEM_FUNCS.list(3)
Definition field_menu.h:443
An area on the map screen.
Definition field_menu.h:423
Any task, seen through its header.
Definition task.h:62
u8 kind
EQUIP_KIND_*.
Definition game_state.h:146
u8 partners
1 << partner for each partner who can equip it (STSTATUS_canEquip)
Definition game_state.h:148
Where a window goes, and the string it shows.
Definition menu.h:102
Task * STSTATUS_createTechScreen(FieldMenuScreen *menu, s32 extra)
Creates the field menu's technique screen (task)
ItemInfo.data's record, by ItemInfo.type.
Definition game_state.h:188
WeaponData weapon
Definition game_state.h:189
ItemData * record
Definition game_state.h:210