Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
game_state.h
Go to the documentation of this file.
1#ifndef DW3_GAME_STATE_H
2#define DW3_GAME_STATE_H
3
4/* The game state: modes, party, items, cards, flags (game/) */
5
6#include "common.h"
7#include <sys/types.h>
8#include <libgte.h>
9#include <libgpu.h>
10#include "engine/gfx.h" /* Vec2 */
11#include "engine/story.h"
12
13union PartnerTotals;
14
15/* The game state's methods (GAME.funcs) */
16typedef struct GameFuncs {
17 /* 0x00 */ void (*newGame)();
18 /* 0x04 */ void (*commitMode)();
19 /* 0x08 */ s32 (*getMode)(void);
20 /* 0x0C */ s32 (*getModeArg)();
21 /* 0x10 */ void (*requestMode)(s32 mode, s32 arg);
22 /* 0x14 */ s32 (*isModeChangePending)();
23 /* 0x18 */ s32 (*getPrevMode)();
24 /* 0x1C */ s32 (*getPartyMember)(u32 index);
25 /* 0x20 */ void (*setParty)();
26 /* 0x24 */ void (*addCards)(s32 card, s32 count);
27 /* 0x28 */ void (*giveStarterDeck)(void);
28 /* 0x2C */ s32 (*getPartyPartner)();
29 /* 0x30 */ void (*setStat)(s32 partner, u32 stat, s16 value);
30 /* 0x34 */ void (*addStat)();
31 /* 0x38 */ void (*computeStats)(s32 partner, union PartnerTotals *out);
32 /* 0x3C */ s32 (*getPartnerSlots)(); /* (partner, s16 *out): the count */
33 /* 0x40 */ void (*setPartnerSlots)();
34 /* 0x44 */ s32 (*listPartnerEntries)(); /* (partner, s16 *out): the count */
35 /* 0x48 */ s32 (*addPartnerEntry)(); /* (partner, id): 0 if it has it or has no room */
36 /* 0x4C */ s32 (*getPartnerEntry)(); /* -1 if it hasn't the Digimon */
37 /* 0x50 */ s32 (*setPartnerEntry)();
38 /* 0x54 */ struct PartnerStats *(*getPartnerStats)(s32 partner);
39 /* 0x58 */ void (*resetPlayTime)();
40 /* 0x5C */ void (*updatePlayTime)();
41} GameFuncs;
42
43/*
44 * FLAGS_00, the first flag bitset, followed by the event functions: FIELDSTG
45 * and the stages call them through here (+0xC applies an action, +0x10 checks
46 * a condition).
47 */
48typedef struct GameFlags {
49 /* 0x00 */ u8 bits[4];
50 /* 0x04 */ s32 cardBattleWon; /* 1 when the player won the card battle; updateModeFlags copies it to FLAG_CARD_BATTLE_WON */
51 /* 0x08 */ s32 (*checkConditions)(u16 *list);
52 /* 0x0C */ void (*applyAction)(s32 code, s32 value);
53 /* 0x10 */ s32 (*checkCondition)(u16 code, u16 value);
54 /* 0x14 */ void (*applyActions)(u16 *list);
55 /* 0x18 */ void (*updateModeFlags)(void);
56} GameFlags;
57
58/*
59 * The codes of the (code, value) pairs that FLAGS_00 checks as conditions
60 * and applies as actions (events.c's checkCondition and applyAction): the
61 * talks' and characters' lists, which end with CODES_END, and a StageSlot's
62 * two conditions, CODES_END for none. code >> 8 & 0xFE is the kind, code &
63 * 0x1FF the flag, value or item. A condition holds when the flag is value,
64 * or when the test is (1) or isn't (0) true; an action sets the flag to
65 * value. The kinds the stages use and these don't name (0x7A, 0x7C and
66 * 0x94, actions that change the mode) stay numbers.
67 */
68#define FLAG(group, id) ((group) << 8 | (id)) /* group 0x00-0x40: FLAGS_00, GAME.flags02-flags40 */
69#define PROGRESS(n) (0x6000 | (n)) /* GAME.progress is n */
70#define SPECIAL(id) (0x7000 | (id)) /* SPECIAL_CONDITIONS entry id */
71#define PARTY_STAT(id) (0x7200 | (id)) /* checkPartyStat */
72#define EVENT_BATTLE(id) (0x7400 | (id)) /* action: FIELDSTG_battleFuncs.startEventBattle */
73#define CARD_BATTLE(opponent, kind) ((0x7600 + (kind) * 0x200) | (opponent)) /* action: startCardBattle */
74/* the place and its argument the last exit or warp set (checkWarpArg): the
75 numbers of the stage's StagePoints, place 1-30 */
76#define PLACE(n) (0x7E00 | ((n) - 1)) /* GAME.place is n */
77#define PLACE_ARG(n) (0x7E00 | ((n) + 29)) /* GAME.placeArg is n */
78/* an item, in the bag or equipped; kind (bits 9-11) isn't read, and the
79 scripts set it after the item's kind loosely */
80#define ITEM(kind, id) (0x8000 | (kind) << 9 | (id))
81#define START_EVENT(index) (0x9000 | (index)) /* action: FIELDSTG_startListedEvent */
82#define CARD(id) (0x9200 | (id)) /* a card: the player has one, or gets or loses one */
83#define CODES_END 0xFFFF
84
85/* Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners) */
86typedef struct DigimonData {
87 /* 0x00 */ u16 id;
88 /* 0x02 */ u16 battleStats[6];
89 /* 0x0E */ u16 resistances[7];
90 /* 0x1C */ u16 skills[7]; /* [1]-[6] are learnt at skillLevels */
91 /* 0x2A */ u16 pairTech; /* its pair technique, with pairPartner */
92 /* 0x2C */ u8 statusResists[5]; /* against poison, paralysis, confusion, sleep and knock-outs */
93 /* 0x31 */ u8 skillLevels[6];
94 /* 0x37 */ u8 knownLevels[5]; /* the levels that mark an entry's skills[0]-[4] known */
95 /* 0x3C */ u8 expLevel; /* the level after which its exp grows faster */
96 /* 0x3D */ u8 pairPartner; /* the Digimon (from 1) it does pairTech with, 0 for none */
97 /* 0x3E */ u8 expRate; /* a partner's exp per level, in tenths */
98 /* 0x3F */ u8 hp;
99 /* 0x40 */ u8 mp;
100 /* 0x41 */ u8 hpGrowth; /* what a partner's max HP grows by a level */
101 /* 0x42 */ u8 mpGrowth;
102 /* 0x43 */ u8 statGrowth[6]; /* columns of the growth tables */
103 /* 0x49 */ u8 resistGrowth[7]; /* 1-5: how fast the gyms raise them */
104 /* 0x50 */ u8 blastForms[5]; /* what a blast turns a partner into (from 1), by its level's tier */
105 /* 0x55 */ u8 nameId; /* string in file 0x4F */
106 /* 0x56 */ u8 family; /* the family it fights as (BattleStats.family) */
108
109/* A technique (TECHS, from 1: technique n is TECHS[n - 1]) */
110typedef struct TechData {
111 /* 0x00 */ u16 mp; /* its cost */
112 /* 0x02 */ u16 power; /* its damage, times the user's attack over the target's defense */
113 /* 0x04 */ u8 icon; /* a frame of the menu sprites, from 0x37 */
114 /* 0x05 */ u8 kind; /* 3: heals the target */
115 /* 0x06 */ u8 accuracy;
116 /* 0x07 */ u8 element; /* ELEMENT_FIRST and up, under it none */
117 /* 0x08 */ u8 elementPower; /* how much the element adds, against the target's resistance */
118 /* 0x09 */ u8 family; /* FAMILY_FIRST and up, under it none */
119 /* 0x0A */ u8 effect; /* TECH_EFFECT_* (fightstg/battle.h), under TECH_EFFECT_FIRST none */
120 /* 0x0B */ u8 effectChance;
121 /* 0x0C */ u8 effectPower; /* the effect's strength (a boost's amount, a drain's 128ths) */
122 /* 0x0D */ u8 scriptStage; /* its script's stage (BattleScript.stage) */
123 /* 0x0E */ u8 scriptEffect; /* its script's sprite effect (BattleScript.effect) */
124 /* 0x0F */ u8 scriptSound; /* its script's hit sound (BattleScript.sound) */
125 /* 0x10 */ u8 script; /* its script in the user's archive (BattleScript.index); 5 and 12 are special */
126 /* 0x11 */ u8 hitCount;
127} TechData;
128
129/*
130 * Where an equipment item goes (its record's kind), as the shop's and
131 * STSTATUS's strings name the kinds: the slots of PartnerStats.equip are
132 * 0 head, 1 body, 2 right hand, 3 left hand, 4 and 5 accessories
133 */
134#define EQUIP_KIND_RIGHT_HAND 1
135#define EQUIP_KIND_LEFT_HAND 2
136#define EQUIP_KIND_EITHER_HAND 3
137#define EQUIP_KIND_HEAD 4
138#define EQUIP_KIND_BODY 5
139#define EQUIP_KIND_ACCESSORY 6
140#define EQUIP_KIND_BOTH_HANDS 7 /* takes slots 2 and 3 */
141#define EQUIP_KIND_GROUP_ACCESSORY 8 /* one of its group at a time */
142
143/* ItemInfo.data's record for a weapon (types 2-14, WEAPON_DATA) */
144typedef struct WeaponData {
145 /* 0x00 */ s16 charisma; /* what it adds to STAT_CHARISMA (computeStats); armour and accessories too */
146 /* 0x02 */ u8 kind; /* EQUIP_KIND_* */
147 /* 0x03 */ u8 group;
148 /* 0x04 */ u8 partners; /* 1 << partner for each partner who can equip it (STSTATUS_canEquip) */
149 /* 0x06 */ u16 amounts[2]; /* what it adds to stats[] */
150 /* 0x0A */ u16 atk;
151 /* 0x0C */ u8 stats[2];
152 /* 0x0E */ u8 accuracy; /* added to the battle's (FIGHTSTG_computeStats) */
153 /* 0x0F */ u8 hitEffect; /* 1 none, 2 poison, 3 paralysis, 4 confusion, 6 knock-out, 8 drain,
154 11 criticals; nothing reads it: FIGHTSTG_computeStats tests the
155 items' ids */
156 /* 0x10 */ u8 statusChance; /* of the status its hits inflict */
157 /* 0x11 */ u8 statusPower; /* the status's, or the critical bonus */
158 /* 0x12 */ u8 family; /* its hits': FAMILY_FIRST and up, under it none */
159} WeaponData;
160
161/* An armour's (types 15-20, ARMOR_DATA) */
162typedef struct ArmorData {
163 /* 0x00 */ s16 charisma;
164 /* 0x02 */ u8 kind;
165 /* 0x03 */ u8 group;
166 /* 0x04 */ u8 partners;
167 /* 0x06 */ u16 amounts[2];
168 /* 0x0A */ u8 stats[2];
169 /* 0x0C */ s16 def;
170 /* 0x0E */ u8 padE[2]; /* 0 on every armour */
171 /* 0x10 */ u8 evasion; /* added to the battle's (FIGHTSTG_computeStats) */
172 /* 0x11 */ u8 unused11; /* 1 on every armour; nothing reads it */
173 /* 0x12 */ u8 pad12[2]; /* 0 on every armour; never read: ARMOR_DATA's entries are 0x14 bytes */
174} ArmorData;
175
176/* An accessory's (types 21-24, ACCESSORY_DATA) */
177typedef struct AccessoryData {
178 /* 0x0 */ s16 charisma;
179 /* 0x2 */ u8 kind; /* EQUIP_KIND_ACCESSORY or EQUIP_KIND_GROUP_ACCESSORY */
180 /* 0x3 */ u8 group;
181 /* 0x4 */ u8 partners;
182 /* 0x6 */ u16 amount;
183 /* 0x8 */ u8 stat;
184 /* 0x9 */ u8 pad[3]; /* 0 on every accessory; never read: ACCESSORY_DATA's entries are 0xC bytes */
186
187/* ItemInfo.data's record, by ItemInfo.type */
193
194/* ItemEffect.flags */
195#define ITEM_USE_MENU 1 /* usable from the status menu (STSTATUS) */
196#define ITEM_USE_BATTLE 2 /* usable in battle (FIGHTSTG's item menu) */
197#define ITEM_CARD_PACK 4 /* on the card boosters, which nothing tests it on */
198
199/* What a usable item does (its ItemInfo.data, an ITEM_EFFECT_*) */
200typedef struct ItemEffect {
201 /* 0x0 */ u8 flags; /* ITEM_USE_* */
202 /* 0x1 */ u8 kind; /* 1 heals amount HP, 2-17 raise a stat by up to amount (STSTATUS_useItem) */
203 /* 0x2 */ u16 amount; /* the HP it heals, the gauge it fills, a boost in 128ths */
204} ItemEffect;
205
206/* What ItemInfo.data points to: a weapon's, an armour's or an accessory's
207 record, or a usable item's effect. The overlays read both byte by byte. */
216
217/* ItemInfo.kind: the item list (ITEM_LISTS) an item is in, from 1 */
218#define ITEM_KIND_KEY 1 /* the key items, and the ids no item uses */
219#define ITEM_KIND_USABLE 2
220#define ITEM_KIND_WEAPON 3
221#define ITEM_KIND_ARMOR 4
222#define ITEM_KIND_ACCESSORY 5
223
224/* An item (ITEMS, ITEM_FUNCS) */
225typedef struct ItemInfo {
226 /* 0x0 */ ItemRecord data; /* the type's record, or the usable items' effect */
227 /* 0x4 */ u16 price;
228 /* 0x6 */ u16 sellPrice; /* 0: cannot be sold */
229 /* 0x8 */ u8 kind; /* ITEM_KIND_* (ITEM_FUNCS.isKind) */
230 /* 0x9 */ u8 type; /* 2-14 weapons, 15-20 armour, 21-24 accessories */
231} ItemInfo;
232
233/* ItemInfo.type's ranges: 2-14 weapons, 15-20 armour, 21-24 accessories,
234 each tested as one unsigned byte compare */
235#define IS_WEAPON_TYPE(type) ((u8)((type) - 2) < 13)
236#define IS_ARMOR_TYPE(type) ((u8)((type) - 15) < 6)
237#define IS_ACCESSORY_TYPE(type) ((u8)((type) - 21) < 4)
238
239/* The Digimon a partner can have, and the ones it takes to battle */
240#define PARTNER_ENTRY_COUNT 44
241#define PARTNER_SLOT_COUNT 3
242
243/* The first PartnerEntry.id of a Digimon: 0 is a free entry, 1 and 2 unused ones */
244#define FIRST_ENTRY_ID 3
245
246/* One of a partner's Digimon (getPartnerEntry, setPartnerEntry) */
247typedef struct PartnerEntry {
248 /* 0x00 */ s16 id; /* FIRST_ENTRY_ID and up */
249 /* 0x02 */ s8 level; /* shown in the lab; 1 when added */
250 /* 0x04 */ s32 exp;
251 /* 0x08 */ s16 skills[6]; /* SKILL_ID and the flags below, 0 for none */
253
254/* PartnerEntry.skills */
255#define SKILL_ID 0x1FFF /* the skill, from 1 (TECHS[id - 1]) */
256#define SKILL_KNOWN 0x2000
257#define SKILL_MARKED 0x4000 /* marked in the lab (STGDGLAB_updateSkillPanel) */
258#define SKILL_LAST 0x8000 /* the sixth skill */
259
260/* The cards of a deck, and the decks the player has */
261#define DECK_SIZE 40
262#define DECK_COUNT 3
263
264/* The copies of a card the player can have */
265#define CARD_COPIES_MAX 9
266
267/* A partner's equipment set: the four items computeStats compares with equip[0-3] */
268typedef struct EquipSet {
270} EquipSet;
271
272/* A card deck */
273typedef struct Deck {
274 /* 0x00 */ char name[0x16];
275 /* 0x16 */ s16 cards[DECK_SIZE];
276} Deck;
277
278/* Indices of a partner's stats (PartnerStats.stats, computeStats, setStat) */
279#define STAT_LEVEL 0
280#define STAT_TP 1 /* what the training's intensities cost */
281#define STAT_HP 2
282#define STAT_MAX_HP 3
283#define STAT_MP 4
284#define STAT_MAX_MP 5
285/* the six battle stats */
286#define STAT_STRENGTH 6
287#define STAT_DEFENSE 7
288#define STAT_SPIRIT 8
289#define STAT_WISDOM 9
290#define STAT_SPEED 10
291#define STAT_CHARISMA 11
292#define STAT_RESISTS 12 /* the first of the seven resistances */
293#define STAT_COUNT 19
294
295/*
296 * A partner Digimon from its name on (Partner.info), as getPartnerStats gives
297 * it. Stats (computeStats and setStat order): 0 level, 1 TP, 2 HP, 3 max HP,
298 * 4 MP, 5 max MP, 6-11 the battle stats strength, defense, spirit, wisdom,
299 * speed and charisma (STSTATUS's messages for the items that raise them;
300 * weapons raise 6, armour 7, all equipment 11), 12-18 seven resistances;
301 * the totals add 19-21, which are subtracted from 6, 7 and 10.
302 */
303typedef struct PartnerStats {
304 /* 0x000 */ char name[0x18];
305 /* 0x018 */ s32 exp;
306 /* 0x01C */ s16 stats[STAT_COUNT];
307 /* 0x042 */ s16 status[3];
308 /* 0x048 */ s16 slots[4]; /* PARTNER_SLOT_COUNT entries picked from entries[] */
310 /* 0x3C0 */ s16 equip[6];
311 /* 0x3CC */ u8 lastBonus; /* the training whose bonus try last worked, 0 for
312 none: its try can't work again at once */
314
315/* PartnerStats.equip as a whole: STSTATUS and STITSHOP save it with a struct
316 copy before they equip an item to compute the stats with it, and put it
317 back */
318typedef struct PartnerEquip {
321
322/* PartnerStats' stats[] and the status[] after them as one block, which
323 computeStats and STITSHOP_computeStats copy whole */
324typedef struct StatBlock {
325 /* 0x00 */ s16 stats[STAT_COUNT];
326 /* 0x26 */ s16 penalties[3]; /* subtracted from STAT_STRENGTH, STAT_DEFENSE and STAT_SPEED */
327} StatBlock;
328
329/* GameState's play time, which a memory card save copies whole */
330typedef struct PlayTime {
331 /* 0x0 */ s32 frames; /* 8.8, counted by the vsync callback */
332 /* 0x4 */ s16 hours;
333 /* 0x6 */ s16 minutes;
334 /* 0x8 */ s16 seconds;
335 /* 0xA */ s16 maxed; /* stopped at 999:59:59 */
336} PlayTime;
337
338/* A partner Digimon's animation in a menu: up to seven sprite ids, -1
339 ending it early (the sprites are each overlay's own) */
340typedef struct PartnerAnim {
343
344/* One of the eight partner Digimon */
345typedef struct Partner {
346 /* 0x000 */ u8 pad[4]; /* nothing reads or writes it */
347 /* 0x004 */ s32 unlocked; /* partner id + 3, 0 while locked */
348 /* 0x008 */ s32 battleDigivolve; /* an entry id, compared with the slots': the Digimon the battle starts it as, 0 for its own */
349 /* 0x00C */ PartnerStats info;
350} Partner;
351
352/* An enemy of a battle (FIELDSTG's encounter table points to these) */
353typedef struct BattleEnemy {
354 /* 0x0 */ s32 fighter; /* 0 for none */
355 /* 0x4 */ s16 level;
356 /* 0x6 */ s16 hp;
357 /* 0x8 */ s16 mp;
358 /* 0xA */ s16 strength; /* its stats and techniques' power, in 16ths */
360
361/* BattleSetup.blocks' indices: the encounter keeps the player from
362 inflicting a status, draining, stealing, lowering a stat of the enemy's
363 or running away */
364#define BATTLE_BLOCK_POISON 0
365#define BATTLE_BLOCK_PARALYSIS 1
366#define BATTLE_BLOCK_CONFUSION 2
367#define BATTLE_BLOCK_SLEEP 3
368#define BATTLE_BLOCK_KNOCK_OUT 4
369#define BATTLE_BLOCK_DRAIN 5
370#define BATTLE_BLOCK_STEAL 7
371#define BATTLE_BLOCK_LOWER_ATTACK 8 /* to 10: attack, defense, speed (a technique's boost stat + 8) */
372#define BATTLE_BLOCK_LOWER_DEFENSE 9
373#define BATTLE_BLOCK_LOWER_SPEED 10
374#define BATTLE_BLOCK_RUN_AWAY 11
375
376/* The next battle: FIELDSTG_startEncounter fills it (the stage select its
377 first words), FIGHTSTG and WFIGHTMN read it; the gauges carry over from
378 battle to battle */
379typedef struct BattleSetup {
380 /* 0x00 */ s32 randomBattles; /* the field starts random battles; the stage select toggles it (Select) */
381 /* 0x04 */ s32 debugUpDown; /* -1 to 3, set by the stage select (pad 2's up/down); nothing reads it */
382 /* 0x08 */ s32 debugLeftRight; /* -1 to 7, set by the stage select (pad 2's left/right); nothing reads it */
383 /* 0x0C */ s32 stage; /* the battle's fight stage */
384 /* 0x10 */ s32 battle; /* the battle (BattleResult.battle) */
385 /* 0x14 */ s32 music; /* the battle's music */
386 /* 0x18 */ BattleEnemy enemies[3];
387 /* 0x3C */ u8 ambushChance; /* a chance that WFIGHTMN scales by level */
388 /* 0x3D */ u8 encounterKind; /* Encounter.kind; only the enemies' condition 13 reads it */
389 /* 0x3E */ u8 blocks[12]; /* by BATTLE_BLOCK_*: what the player can't do in the battle */
390 /* 0x4C */ s32 hasPrize; /* 1: the battle always gives prize */
391 /* 0x50 */ s32 prize; /* an item (BattleResult.item) */
392 /* 0x54 */ void (*clearGauges)(void);
393 /* 0x58 */ s16 gauges[8]; /* filled in battle, up to 1000 */
395
396/* What the battle left for the report (BATTLE_RESULT, cleared by WFIGHTMN) */
397typedef struct BattleResult {
398 /* 0x00 */ s16 battle; /* row of STFGTREP_rewards */
399 /* 0x02 */ s16 item; /* the item won, 0 for none */
400 /* 0x04 */ s16 member; /* the party member whose accessory adds money */
401 /* 0x06 */ struct {
403 u8 used[3]; /* the Digimon of each slot was used */
406
407/* computeStats' result: the stats with the equipment added, by STAT_* or
408 by name. computeStats fills the first 22 (0x2C bytes). */
409typedef union PartnerTotals {
411 struct {
412 /* 0x00 */ s16 level;
413 /* 0x02 */ s16 tp; /* what the training's intensities cost */
414 /* 0x04 */ s16 hp;
415 /* 0x06 */ s16 maxHp;
416 /* 0x08 */ s16 mp;
417 /* 0x0A */ s16 maxMp;
418 /* 0x0C */ s16 battle[6]; /* strength (raised by weapons), defense (by armour), spirit,
419 wisdom, speed and charisma (by all equipment) */
420 /* 0x18 */ s16 resist[7];
421 /* 0x26 */ s16 lowered[3]; /* taken from battle[0], [1] and [4] */
422 /* 0x2C */ s32 spare; /* not filled: STGTRAIN's result keeps its yes/no answer here, 0 yes */
424 StatBlock block; /* the first 0x2C bytes, which computeStats copies whole */
426
427/* Game modes (GameState: mode >> 8 is the overlay) that more than their own
428 overlay asks for */
429#define MODE_NEW_GAME 0x2D7 /* FIELDSTG, where a new game starts */
430#define MODE_DECK_EDITOR 0x400 /* STCRDDEK */
431#define MODE_PLAYER_NAME 0x500 /* STPLNMET: the player's name entry */
432#define MODE_BATTLE 0x600 /* FIGHTSTG */
433#define MODE_CARD_GAME 0x700 /* CARDGAME: a card battle */
434#define MODE_TRAINING 0xA00 /* STGTRAIN */
435#define MODE_NAMING 0xB00 /* STDGNAME */
436#define MODE_CONTINUE 0xC00 /* STGMCARD, to load a game */
437#define MODE_DIGI_LAB 0xD00 /* STGDGLAB */
438#define MODE_TITLE 0xE00 /* STDWTITL's title screen; its movies follow */
439#define MODE_OPENING 0xE01 /* STDWTITL's first movie */
440#if VERSION_US
441#define MODE_BATTLE_MOVIE 0xE09 /* STDWTITL's movie before each battle at GAME.progress 0x2B */
442#define MODE_ENDING 0xE0A /* STDWTITL's movie after the last battle */
443#elif VERSION_EU || VERSION_JP
444#define MODE_OPENING_2 0xE02 /* STDWTITL's second opening movie: LANGUAGE 0
445 alternates the two, the others play only it */
446#define MODE_BATTLE_MOVIE 0xE0A
447#define MODE_ENDING 0xE0B
448#endif
449#define MODE_ITEM_SHOP 0xF00 /* STITSHOP */
450#define MODE_STATUS 0x1000 /* STSTATUS: the field menu's screens (FIELD_MENU_CHOICE) */
451#define MODE_CARD_ALBUM 0x1200 /* STCRDABM */
452#define MODE_CARD_SHOP 0x1300 /* STCRDSHP */
453#define MODE_BATTLE_REPORT 0x1400 /* STFGTREP */
454#define MODE_STAGE_SELECT 0x1500 /* STAGSLCT, the debug stage select */
455#define MODE_COUNTRY_SELECT 0x1600 /* CNTY_SEL, where the European version starts */
456
457/* The first mode of a mode's overlay: MODE_OVERLAY(mode) == MODE_TITLE for
458 all of STDWTITL's */
459#define MODE_OVERLAY(mode) ((mode) & 0xFF00)
460
461/* The partner Digimon (GAME.partners' index): partner i is DIGNAM's string
462 i + 1, as the registration's choice shows them */
474/* How many partners the party holds */
475#define PARTY_SIZE 3
476
477/* The registration's starter packs (GAME.partySet, STARTER_PARTIES' rows):
478 NAMEET's strings 10-12 name them */
480
481/* The most money the player can have */
482#define MONEY_MAX 9999999
483
484/*
485 * The game state (GAME): the first 0x26BC bytes are what newGame clears (the
486 * save data), then the current game mode and the methods.
487 * Game modes: mode >> 8 selects the overlay (MODE_OVERLAY_FILES); a mode
488 * change is requested with requestMode and applied by commitMode when main
489 * recreates the mode task.
490 */
491typedef struct GameState {
492 /* 0x0000 */ u8 checksum; /* a save's, of its bytes from 0x4 (STGMCARD_runSaves) */
493 /* 0x0001 */ u8 pad1; /* never read or written */
494 /* 0x0002 */ u8 version; /* a save's MEMCARD_SAVE_VERSION (stgmcard.h) */
495 /* 0x0003 */ u8 pad3; /* never read or written */
496 /* 0x0004 */ u8 digivolveDemo;
497 /* 0x0005 */ u8 pad5[7]; /* never read or written */
498 /* 0x000C */ s32 unusedC; /* newGame sets it to -1; nothing reads it */
499 /* 0x0010 */ u8 pad10[0x18]; /* never read or written */
500 /* 0x0028 */ s32 stageSelectTop; /* the debug stage select's first line */
501 /* 0x002C */ s32 stageSelectCursor;
502 /* 0x0030 */ s32 battleSteps; /* to the next random battle, which each step lowers */
503 /* 0x0034 */ s32 fieldMode; /* where the menu returns to */
504 /* 0x0038 */ Vec2 fieldPos; /* the player's, there */
505 /* 0x0040 */ s32 fieldDir;
506 /* 0x0044 */ u16 place; /* where the last warp or trigger put the player (FieldBattles.id) */
507 /* 0x0046 */ u16 placeArg; /* the place's argument, which the stage reads with it */
508 /* 0x0048 */ PlayTime playTime;
509 /* 0x0054 */ char name[0x18]; /* the player's */
510 /* 0x006C */ s32 money;
511 /* 0x0070 */ s32 party[PARTY_SIZE]; /* partner indices */
512 /* 0x007C */ s8 items[0x193]; /* counts, up to 99 */
513 /* 0x020F */ s8 equippedItems[0x193];
514 /* 0x03A2 */ s8 cards[0x13D]; /* counts, up to CARD_COPIES_MAX */
515 /* 0x04DF */ u8 cardsSeen[0x149];
516 /* 0x0628 */ Deck decks[DECK_COUNT];
518 /* 0x263C */ s32 progress;
519 /* 0x2640 */ s32 partySet; /* setParty's: the starter pack (enum StarterPack) */
520 /*
521 * flags02-flags40: the event flag groups 0x02-0x40 (checkCondition,
522 * applyAction), bitsets packed one after the other, so most start at an
523 * odd byte. The Japanese version's state is the European one's: its
524 * newGame clears 0x26C4 bytes and its code reads the same offsets
525 */
526#if VERSION_US
527 /* 0x2644 */ u8 flags02[0xD];
528 /* 0x2651 */ u8 flags04[0x2];
529 /* 0x2653 */ u8 flags06[0x1];
530 /* 0x2654 */ u8 flags08[0x1];
531 /* 0x2655 */ u8 flags0A[0x2];
532 /* 0x2657 */ u8 flags0C[0x8];
533 /* 0x265F */ u8 flags0E[0xC];
534 /* 0x266B */ u8 flags10[0x2];
535 /* 0x266D */ u8 flags18[0x1];
536 /* 0x266E */ u8 flags1A[0x9];
537 /* 0x2677 */ u8 flags1C[0xB];
538 /* 0x2682 */ u8 flags20[0x1E];
539 /* 0x26A0 */ u8 flags40[0x1C];
540 /* 0x26BC */ s32 mode;
541 /* 0x26C0 */ s32 nextMode;
542 /* 0x26C4 */ s32 prevMode;
543 /* 0x26C8 */ s32 modeArg;
544 /* 0x26CC */ u8 countdown[4]; /* three digits of seconds, then frames */
545 /* 0x26D0 */ s32 clearTempFlags;
546 /* 0x26D4 */ s32 lastFieldMode; /* the field mode FIELDSTG last started */
547 /* 0x26D8 */ s32 mapIndex; /* which of the stage's maps the field uses */
548 /* 0x26DC */ s32 altTriggers; /* WSTAG810: its second triggers map is in use */
549 /* 0x26E0 */ s32 playerDepth; /* the player's depth, kept while in the mode */
550 /* 0x26E4 */ s32 prizeSpot; /* the hidden spot that has the prize */
551 /* 0x26E8 */ s32 dark; /* the Dark Dungeon's darkness is on (WSTAG745, WSTAG746) */
552 /* 0x26EC */ s32 flightZ; /* the flying player's height, kept while in the mode */
553 /* 0x26F0 */ GameFuncs funcs;
554#elif VERSION_EU || VERSION_JP
555 /* 0x2644 */ u8 flags02[0x12];
556 /* 0x2656 */ u8 flags04[0x2];
557 /* 0x2658 */ u8 flags06[0x1];
558 /* 0x2659 */ u8 flags08[0x1];
559 /* 0x265A */ u8 flags0A[0x4];
560 /* 0x265E */ u8 flags0C[0x8];
561 /* 0x2666 */ u8 flags0E[0xC];
562 /* 0x2672 */ u8 flags10[0x4];
563 /* 0x2676 */ u8 flags18[0x2];
564 /* 0x2678 */ u8 flags1A[0x9];
565 /* 0x2681 */ u8 flags1C[0xB];
566 /* 0x268C */ u8 flags20[0x1E];
567 /* 0x26AA */ u8 flags40[0x1A];
568 /* 0x26C4 */ s32 mode;
569 /* 0x26C8 */ s32 nextMode;
570 /* 0x26CC */ s32 prevMode;
571 /* 0x26D0 */ s32 modeArg;
572 /* 0x26D4 */ u8 countdown[4];
573 /* 0x26D8 */ s32 clearTempFlags;
574 /* 0x26DC */ s32 lastFieldMode;
575 /* 0x26E0 */ s32 mapIndex;
576 /* 0x26E4 */ s32 altTriggers;
577 /* 0x26E8 */ s32 playerDepth;
578 /* 0x26EC */ s32 prizeSpot;
579 /* 0x26F0 */ s32 dark;
580 /* 0x26F4 */ s32 flightZ;
581 /* 0x26F8 */ s32 randomGauges; /* gauge games left with random rows, reset with each new mode */
582 /* 0x26FC */ GameFuncs funcs;
583#endif
584} GameState;
585
586/* The saved part of the game state, GAME up to mode: a save's data section
587 (stgmcard.h's GameSave) */
588#if VERSION_US
589#define GAME_SAVE_SIZE 0x26BC
590#elif VERSION_EU || VERSION_JP
591#define GAME_SAVE_SIZE 0x26C4
592#endif
593
594void newGame(void);
595void commitMode(void);
596s32 getPrevMode(void);
597s32 getMode(void);
598s32 getModeArg(void);
599void requestMode(s32 mode, s32 arg);
601s32 unequipItem(s32 slot, s32 item);
602void changeItem(s32 item, s32 add);
603void changeCard(s32 card, s32 add);
604void startCardBattle(s32 opponent, s32 kind);
605s32 checkPartner(u32 op, s32 arg);
606s32 checkMoney(s32 op, s32 item);
607s32 checkProgressRange(s32 unused, s32 index);
608s32 checkFlagCount(s32 unused, s32 mode);
609s32 showActorIcon(s32 op, s32 arg);
610s32 checkSpecialCondition(s32 id, s32 expected);
611s32 checkProgress(s32 value, s32 mode);
612s32 checkItem(s32 index, s32 mode);
613s32 checkCard(s32 card, s32 have);
614s32 checkPartyStat(s32 index, s32 mode);
615s32 checkWarpArg(s32 id, s32 mode);
617void clearBattleGauges(void);
618ItemInfo *getItem(s32 id);
620s32 isItemKind(s32 item, s32 kind);
621s32 listItems(s32 type, s16 *out);
623void initNewGameData(void);
624void addCards(s32 card, s32 count);
625s32 findPartnerEntry(s32 slot, s32 id);
626void applyAction(s32 code, s32 value);
627s32 checkConditions(u16 *list);
628void applyActions(u16 *list);
629void updateModeFlags(void);
631s32 testBit(u8 *bits, s32 index, s32 set);
632void setBit(u8 *bits, s32 index, s32 set);
633s32 checkItemSet(s32 op, s32 arg);
634s32 getPartnerSlots(s32 partner, s16 *out);
635void setPartnerSlots(s32 partner, s16 *ids);
636s32 listPartnerEntries(s32 partner, u16 *out);
637s32 addPartnerEntry(s32 partner, s32 id);
638s32 getPartnerEntry(s32 partner, s32 id, PartnerEntry *out);
639s32 setPartnerEntry(s32 partner, s32 id, PartnerEntry *in);
640void addStatBonus(s16 *p, s32 stat, s32 delta);
642s32 getPartyMember(u32 index);
643void setParty(s32 set);
644void giveStarterDeck(void);
645void resetPlayTime(void);
646void updatePlayTime(void);
647s32 getPartyPartner(u32 index);
648void setStat(s32 partner, u32 stat, s16 value);
649void addStat(s32 partner, u32 stat, s32 delta);
650void computeStats(s32 partner, PartnerTotals *out);
651
653extern DigimonData *(*GET_DIGIMON)(s32 id); /* getDigimon */
656extern ItemInfo ITEMS[];
657extern TechData TECHS[];
658
659/* A special condition (SPECIAL(id)): checkSpecialCondition runs the check
660 function of kind `check >> 4` (checkItemSet, checkPartner, ...) with
661 `check & 0xF` and arg */
662typedef struct SpecialCondition {
663 /* 0x0 */ u8 id;
664 /* 0x1 */ u8 check;
665 /* 0x2 */ u8 arg;
667
668/* The item functions (ITEM_FUNCS) */
669typedef struct ItemFuncs {
670 /* 0x0 */ struct ItemInfo *(*get)(s32 item); /* getItem */
671 /* 0x4 */ s32 (*getCategory)(s32 item); /* getItemCategory */
672 /* 0x8 */ s32 (*isKind)(s32 item, s32 kind); /* ItemInfo.kind == kind */
673 /* 0xC */ s32 (*list)(s32 type, s16 *out); /* listItems */
674} ItemFuncs;
675extern ItemFuncs ITEM_FUNCS;
676extern u8 ITEM_TYPE_CATEGORIES[];
677extern s32 MONEY_REQUIRED[];
679extern s32 MONEY_GAINS[];
680extern s32 MONEY_LOSSES[];
681extern GameFlags FLAGS_00;
684extern u8 PROGRESS_RANGES[][2];
686extern EquipSet EQUIP_SETS[];
687extern s16 EQUIP_SET_BONUSES[][6];
688extern u16 *ITEM_LISTS[]; /* listItems' lists, 0-terminated */
689extern GameState GAME;
690
691#endif /* DW3_GAME_STATE_H */
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
signed char s8
Definition common.h:7
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
s32 checkProgressRange(s32 unused, s32 index)
Special conditions 0x30: whether GAME.progress is within PROGRESS_RANGES[index].
Definition events.c:182
s32 findDigimon(s32 id)
The index in DIGIMON_DATA of Digimon id (the first 52 entries are searched), or -1.
Definition digimon.c:121
s32 getPartyPartner(u32 index)
The partner id of party member index (its unlocked value - 3), or -1.
Definition stats.c:5
s32 addPartnerEntry(s32 partner, s32 id)
Gives a partner Digimon id at level 1; 0 if it has it already or has no room.
Definition partner.c:74
u16 * ITEM_LISTS[]
listItems' lists, 0-terminated
Definition items.c:903
s32 testBit(u8 *bits, s32 index, s32 set)
Whether bit index of a bitset is set (set != 0) or clear (set 0)
Definition events.c:5
DigimonData DIGIMON_DATA[]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
Definition digimon.c:7
s32 getItemCategory(s32 id)
The category of an item's type (ITEM_TYPE_CATEGORIES); an s32, as the menus that call it through ITEM...
Definition items.c:27
void newGame(void)
Clears the save data and sets up a new game.
Definition state.c:5
s32 checkPartner(u32 op, s32 arg)
Special conditions 0x10: tests partners (unlocked, in the party, levels) or unlocks one; the European...
Definition events.c:65
ItemFuncs ITEM_FUNCS
Definition items.c:890
s32 checkItemSet(s32 op, s32 arg)
Special condition 0x00: the player has every item of a set (the European and Japanese versions have a...
Definition events.c:29
s32 checkCard(s32 card, s32 have)
Conditions 0x92: whether the player has card item (have != 0) or not.
Definition events.c:353
void startCardBattle(s32 opponent, s32 kind)
Actions 0x76 and 0x78: a card battle (MODE_CARD_GAME) against an opponent.
Definition events.c:497
DigimonData * getDigimon(s32 id)
The DIGIMON_DATA entry of Digimon id, or NULL.
Definition digimon.c:134
void addCards(s32 card, s32 count)
Gives count copies of a card (up to CARD_COPIES_MAX) and marks it seen.
Definition party.c:63
void applyActions(u16 *list)
Runs every (code, value) action until 0xFFFF.
Definition events.c:665
s32 MONEY_LOSSES[]
Definition events.c:768
void giveStarterDeck(void)
Gives the starter deck's cards and puts them in every deck.
Definition party.c:72
PartnerStats * getPartnerStats(s32 partner)
A partner's name, stats and Digimon.
Definition partner.c:117
u8 STARTER_PARTIES[][3]
setParty's partners, by starter pack
Definition party.c:87
#define PARTY_SIZE
How many partners the party holds.
Definition game_state.h:475
s32 PARTY_STAT_THRESHOLDS[]
checkPartyStat's thresholds
Definition events.c:811
s32 checkConditions(u16 *list)
All the (code, value) pairs until 0xFFFF must hold.
Definition events.c:652
void requestMode(s32 mode, s32 arg)
Asks for a mode change, applied when main recreates the mode task.
Definition state.c:53
s32 isItemKind(s32 item, s32 kind)
ITEM_FUNCS.isKind.
Definition items.c:32
void resetPlayTime(void)
Sets the play time to zero.
Definition play_time.c:5
s32 STARTER_DECK[40]
The cards of giveStarterDeck's deck.
Definition party.c:94
u8 PROGRESS_RANGES[][2]
checkProgressRange's ranges of GAME.progress: { min, max }; 0x63 is past the end of the story
Definition events.c:773
s32 checkWarpArg(s32 id, s32 mode)
Conditions 0x7E: the values a warp leaves for its stage (GAME.place for ids under 30,...
Definition events.c:397
s32 findPartnerEntry(s32 slot, s32 id)
The index of Digimon id among a partner's entries, or -1.
Definition partner.c:4
s32 checkSpecialCondition(s32 id, s32 expected)
Runs SPECIAL_CONDITIONS entry id; whether its result equals expected
Definition events.c:285
ItemInfo ITEMS[]
The items, from 1: getItem(id) is ITEMS[id - 1].
Definition items.c:481
void updatePlayTime(void)
Turns the vsync-counted frames into seconds, minutes and hours, stopping at 999:59:59.
Definition play_time.c:14
void computeStats(s32 partner, PartnerTotals *out)
A partner's stats with its equipment (and its equipment set bonus) added.
Definition stats.c:65
#define DECK_COUNT
Definition game_state.h:262
s32 checkMoney(s32 op, s32 item)
Special conditions 0x20: whether the player has MONEY_REQUIRED[item], or gives or takes an amount.
Definition events.c:156
s32 getPartnerSlots(s32 partner, s16 *out)
Copies the ids of the Digimon a partner takes to battle; returns how many there are.
Definition partner.c:19
BattleSetup BATTLE_SETUP
Definition items.c:886
void applyAction(s32 code, s32 value)
Actions: the same flag groups (set to value), 0x70 special actions, 0x74 an overlay hook,...
Definition events.c:563
BattleResult BATTLE_RESULT
Definition items.c:888
s32 unequipItem(s32 slot, s32 item)
Takes item item off a partner (one of type 7 empties slots 2 and 3 both); 1 if it had it.
Definition events.c:436
#define STAT_COUNT
Definition game_state.h:293
TechData TECHS[]
The techniques, from 1: technique n is TECHS[n - 1].
Definition items.c:906
void clearBattleGauges(void)
Empties the battle gauges (BATTLE_SETUP.gauges, up to 1000 in a battle)
Definition items.c:7
void initNewGameData(void)
The new game's player name, deck names, starter deck and partners.
Definition party.c:5
s32 MONEY_REQUIRED[]
checkMoney's amounts, by its argument
Definition events.c:762
s32 getPartyMember(u32 index)
The partner index of party member index, or -1.
Definition party.c:42
SpecialCondition SPECIAL_CONDITIONS[]
checkSpecialCondition's conditions, up to an id of 0xFF
Definition events.c:706
s32 getPrevMode(void)
The game mode before the current one.
Definition state.c:38
s32 listPartnerEntries(s32 partner, u16 *out)
Copies the ids of a partner's Digimon, zero-filled; returns how many there are.
Definition partner.c:55
void setParty(s32 set)
Gives the party STARTER_PARTIES[set], unlocking its partners.
Definition party.c:50
void changeCard(s32 card, s32 add)
Actions 0x92: gives or takes a copy of a card.
Definition events.c:485
s16 EQUIP_SET_BONUSES[][6]
Definition stats.c:180
void addStat(s32 partner, u32 stat, s32 delta)
Adds to a partner's stat, kept within the same limits as setStat.
Definition stats.c:39
void setPartnerSlots(s32 partner, s16 *ids)
Picks the Digimon a partner takes to battle (-1 for ids it does not have)
Definition partner.c:40
s32 MONEY_GAINS[]
Definition events.c:765
EquipSet EQUIP_SETS[]
Each partner's equipment set and what wearing it whole adds (computeStats)
Definition stats.c:174
void addStatBonus(s16 *p, s32 stat, s32 delta)
Adds an equipment bonus to a stat of computeStats' result (7 raises every battle stat)
Definition stats.c:146
s32 getMode(void)
The current game mode.
Definition state.c:43
#define DECK_SIZE
The cards of a deck, and the decks the player has.
Definition game_state.h:261
s32 isModeChangePending(void)
Whether a mode change was requested.
Definition state.c:59
s32 checkFlagCount(s32 unused, s32 mode)
Special conditions 0x40: group 0 as in the USA version; group 1 whether four flags of group 0x10 are ...
Definition events.c:231
ItemInfo * getItem(s32 id)
The ITEMS entry of item id (from 1), or NULL.
Definition items.c:16
StarterPack
The registration's starter packs (GAME.partySet, STARTER_PARTIES' rows): NAMEET's strings 10-12 name ...
Definition game_state.h:479
@ STARTER_PACK_MANIAC
Definition game_state.h:479
@ STARTER_PACK_BALANCED
Definition game_state.h:479
@ STARTER_PACK_POWERFUL
Definition game_state.h:479
void changeItem(s32 item, s32 add)
Actions 0x80-0x8E: gives an item (up to 99) or takes one, from the bag or else off a partner.
Definition events.c:457
s32 showActorIcon(s32 op, s32 arg)
Special condition 0x50: the field actor's icon (FIELDSTG's task 0x16, FIELD_TASK_ICON) plays its anim...
Definition events.c:277
s32 checkPartyStat(s32 index, s32 mode)
Conditions 0x72: whether the party's total of battle stat 5 reaches PARTY_STAT_THRESHOLDS[index] (mod...
Definition events.c:370
s32 checkCondition(u16, u16)
Event scripts test conditions and run actions given as (code, value) pairs.
Definition events.c:509
s32 listItems(s32 type, s16 *out)
Copies the items of ITEM_LISTS[type] the player has (with the top bit, equipped ones too); returns ho...
Definition items.c:40
void commitMode(void)
Makes the requested mode current (main calls it before recreating the mode task)
Definition state.c:26
void setStat(s32 partner, u32 stat, s16 value)
Sets a partner's stat, kept within 0-99 (level, TP), 0-9999 (HP, MP) or 0-999.
Definition stats.c:13
u8 ITEM_TYPE_CATEGORIES[]
The categories' strings, by item type.
Definition items.c:898
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
void setBit(u8 *bits, s32 index, s32 set)
Sets or clears bit index of a bitset.
Definition events.c:16
void updateModeFlags(void)
On a mode change: clears the temporary flags if asked, and sets flags 0x10-0x12 after a card battle.
Definition events.c:678
s32 setPartnerEntry(s32 partner, s32 id, PartnerEntry *in)
Overwrites a partner's Digimon id; returns its index, or -1.
Definition partner.c:107
s32 getModeArg(void)
The argument the current mode was requested with.
Definition state.c:48
s32 getPartnerEntry(s32 partner, s32 id, PartnerEntry *out)
Copies a partner's Digimon id; returns its index, or -1.
Definition partner.c:97
s32 checkProgress(s32 value, s32 mode)
Conditions 0x60: whether GAME.progress is value (mode != 0) or not.
Definition events.c:322
#define PARTNER_ENTRY_COUNT
The Digimon a partner can have, and the ones it takes to battle.
Definition game_state.h:240
s32 checkItem(s32 index, s32 mode)
Conditions 0x80-0x8E: whether the player has item index, in the bag or equipped (mode !...
Definition events.c:339
PartnerId
The partner Digimon (GAME.partners' index): partner i is DIGNAM's string i + 1, as the registration's...
Definition game_state.h:463
@ PARTNER_PATAMON
Definition game_state.h:471
@ PARTNER_VEEMON
Definition game_state.h:468
@ PARTNER_KOTEMON
Definition game_state.h:464
@ PARTNER_GUILMON
Definition game_state.h:469
@ PARTNER_RENAMON
Definition game_state.h:470
@ PARTNER_AGUMON
Definition game_state.h:467
@ PARTNER_MONMON
Definition game_state.h:466
@ PARTNER_KUMAMON
Definition game_state.h:465
@ PARTNER_COUNT
Definition game_state.h:472
GameFlags FLAGS_00
The flag bitset FLAGS_00 and the event functions.
Definition events.c:701
Display, drawing layers, the drawing helpers and the screen fade (gfx/)
The story: the points of GAME.progress, and the event flags by name.
An accessory's (types 21-24, ACCESSORY_DATA)
Definition game_state.h:177
u8 pad[3]
0 on every accessory; never read: ACCESSORY_DATA's entries are 0xC bytes
Definition game_state.h:184
u8 kind
EQUIP_KIND_ACCESSORY or EQUIP_KIND_GROUP_ACCESSORY.
Definition game_state.h:179
An armour's (types 15-20, ARMOR_DATA)
Definition game_state.h:162
u8 padE[2]
0 on every armour
Definition game_state.h:170
u16 amounts[2]
Definition game_state.h:167
u8 stats[2]
Definition game_state.h:168
u8 evasion
added to the battle's (FIGHTSTG_computeStats)
Definition game_state.h:171
u8 unused11
1 on every armour; nothing reads it
Definition game_state.h:172
u8 pad12[2]
0 on every armour; never read: ARMOR_DATA's entries are 0x14 bytes
Definition game_state.h:173
An enemy of a battle (FIELDSTG's encounter table points to these)
Definition game_state.h:353
s32 fighter
0 for none
Definition game_state.h:354
s16 strength
its stats and techniques' power, in 16ths
Definition game_state.h:358
What the battle left for the report (BATTLE_RESULT, cleared by WFIGHTMN)
Definition game_state.h:397
s16 member
the party member whose accessory adds money
Definition game_state.h:400
s16 battle
row of STFGTREP_rewards
Definition game_state.h:398
struct BattleResult::@9 partners[3]
u8 used[3]
the Digimon of each slot was used
Definition game_state.h:403
s16 item
the item won, 0 for none
Definition game_state.h:399
The next battle: FIELDSTG_startEncounter fills it (the stage select its first words),...
Definition game_state.h:379
s32 debugUpDown
-1 to 3, set by the stage select (pad 2's up/down); nothing reads it
Definition game_state.h:381
s32 prize
an item (BattleResult.item)
Definition game_state.h:391
u8 ambushChance
a chance that WFIGHTMN scales by level
Definition game_state.h:387
s32 randomBattles
the field starts random battles; the stage select toggles it (Select)
Definition game_state.h:380
void(* clearGauges)(void)
Definition game_state.h:392
s32 battle
the battle (BattleResult.battle)
Definition game_state.h:384
s16 gauges[8]
filled in battle, up to 1000
Definition game_state.h:393
s32 debugLeftRight
-1 to 7, set by the stage select (pad 2's left/right); nothing reads it
Definition game_state.h:382
BattleEnemy enemies[3]
Definition game_state.h:386
u8 encounterKind
Encounter.kind; only the enemies' condition 13 reads it.
Definition game_state.h:388
u8 blocks[12]
by BATTLE_BLOCK_*: what the player can't do in the battle
Definition game_state.h:389
s32 music
the battle's music
Definition game_state.h:385
s32 stage
the battle's fight stage
Definition game_state.h:383
s32 hasPrize
1: the battle always gives prize
Definition game_state.h:390
A card deck.
Definition game_state.h:273
char name[0x16]
Definition game_state.h:274
s16 cards[40]
Definition game_state.h:275
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
Definition game_state.h:86
u8 statusResists[5]
against poison, paralysis, confusion, sleep and knock-outs
Definition game_state.h:92
u8 nameId
string in file 0x4F
Definition game_state.h:105
u8 resistGrowth[7]
1-5: how fast the gyms raise them
Definition game_state.h:103
u8 pairPartner
the Digimon (from 1) it does pairTech with, 0 for none
Definition game_state.h:96
u16 pairTech
its pair technique, with pairPartner
Definition game_state.h:91
u8 blastForms[5]
what a blast turns a partner into (from 1), by its level's tier
Definition game_state.h:104
u16 skills[7]
[1]-[6] are learnt at skillLevels
Definition game_state.h:90
u8 expLevel
the level after which its exp grows faster
Definition game_state.h:95
u8 expRate
a partner's exp per level, in tenths
Definition game_state.h:97
u8 hpGrowth
what a partner's max HP grows by a level
Definition game_state.h:100
u8 skillLevels[6]
Definition game_state.h:93
u8 statGrowth[6]
columns of the growth tables
Definition game_state.h:102
u8 knownLevels[5]
the levels that mark an entry's skills[0]-[4] known
Definition game_state.h:94
u8 family
the family it fights as (BattleStats.family)
Definition game_state.h:106
u16 battleStats[6]
Definition game_state.h:88
u16 resistances[7]
Definition game_state.h:89
A partner's equipment set: the four items computeStats compares with equip[0-3].
Definition game_state.h:268
s16 items[4]
Definition game_state.h:269
FLAGS_00, the first flag bitset, followed by the event functions: FIELDSTG and the stages call them t...
Definition game_state.h:48
void(* applyActions)(u16 *list)
Definition game_state.h:54
s32 cardBattleWon
1 when the player won the card battle; updateModeFlags copies it to FLAG_CARD_BATTLE_WON
Definition game_state.h:50
void(* applyAction)(s32 code, s32 value)
Definition game_state.h:52
s32(* checkCondition)(u16 code, u16 value)
Definition game_state.h:53
u8 bits[4]
Definition game_state.h:49
s32(* checkConditions)(u16 *list)
Definition game_state.h:51
void(* updateModeFlags)(void)
Definition game_state.h:55
The game state's methods (GAME.funcs)
Definition game_state.h:16
s32(* getMode)(void)
Definition game_state.h:19
void(* setStat)(s32 partner, u32 stat, s16 value)
Definition game_state.h:29
s32(* getModeArg)()
Definition game_state.h:20
void(* resetPlayTime)()
Definition game_state.h:39
void(* addStat)()
Definition game_state.h:30
s32(* setPartnerEntry)()
Definition game_state.h:37
void(* giveStarterDeck)(void)
Definition game_state.h:27
void(* commitMode)()
Definition game_state.h:18
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
void(* updatePlayTime)()
Definition game_state.h:40
s32(* addPartnerEntry)()
(partner, id): 0 if it has it or has no room
Definition game_state.h:35
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
void(* setPartnerSlots)()
Definition game_state.h:33
void(* setParty)()
Definition game_state.h:25
s32(* getPartyPartner)()
Definition game_state.h:28
s32(* getPrevMode)()
Definition game_state.h:23
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
void(* addCards)(s32 card, s32 count)
Definition game_state.h:26
void(* newGame)()
Definition game_state.h:17
s32(* getPartnerSlots)()
(partner, s16 *out): the count
Definition game_state.h:32
s32(* listPartnerEntries)()
(partner, s16 *out): the count
Definition game_state.h:34
s32(* isModeChangePending)()
Definition game_state.h:22
The game state (GAME): the first 0x26BC bytes are what newGame clears (the save data),...
Definition game_state.h:491
s8 cards[0x13D]
counts, up to CARD_COPIES_MAX
Definition game_state.h:514
u8 flags02[0x12]
flags02-flags40: the event flag groups 0x02-0x40 (checkCondition, applyAction), bitsets packed one af...
Definition game_state.h:555
u8 flags04[0x2]
Definition game_state.h:556
s8 items[0x193]
counts, up to 99
Definition game_state.h:512
u8 flags10[0x4]
Definition game_state.h:562
u16 place
where the last warp or trigger put the player (FieldBattles.id)
Definition game_state.h:506
s32 altTriggers
Definition game_state.h:576
u8 checksum
a save's, of its bytes from 0x4 (STGMCARD_runSaves)
Definition game_state.h:492
u8 flags0E[0xC]
Definition game_state.h:561
char name[0x18]
the player's
Definition game_state.h:509
u8 cardsSeen[0x149]
Definition game_state.h:515
Deck decks[3]
Definition game_state.h:516
Partner partners[PARTNER_COUNT]
Definition game_state.h:517
s8 equippedItems[0x193]
Definition game_state.h:513
s32 unusedC
newGame sets it to -1; nothing reads it
Definition game_state.h:498
PlayTime playTime
Definition game_state.h:508
u16 placeArg
the place's argument, which the stage reads with it
Definition game_state.h:507
s32 lastFieldMode
Definition game_state.h:574
s32 party[3]
partner indices
Definition game_state.h:511
u8 pad3
never read or written
Definition game_state.h:495
u8 flags0C[0x8]
Definition game_state.h:560
u8 flags18[0x2]
Definition game_state.h:563
u8 flags06[0x1]
Definition game_state.h:557
u8 flags20[0x1E]
Definition game_state.h:566
u8 countdown[4]
Definition game_state.h:572
s32 partySet
setParty's: the starter pack (enum StarterPack)
Definition game_state.h:519
u8 pad1
never read or written
Definition game_state.h:493
s32 battleSteps
to the next random battle, which each step lowers
Definition game_state.h:502
u8 flags1C[0xB]
Definition game_state.h:565
u8 pad10[0x18]
never read or written
Definition game_state.h:499
s32 stageSelectTop
the debug stage select's first line
Definition game_state.h:500
s32 clearTempFlags
Definition game_state.h:573
s32 fieldMode
where the menu returns to
Definition game_state.h:503
u8 version
a save's MEMCARD_SAVE_VERSION (stgmcard.h)
Definition game_state.h:494
s32 randomGauges
gauge games left with random rows, reset with each new mode
Definition game_state.h:581
s32 prizeSpot
Definition game_state.h:578
s32 playerDepth
Definition game_state.h:577
u8 digivolveDemo
Definition game_state.h:496
u8 pad5[7]
never read or written
Definition game_state.h:497
u8 flags0A[0x4]
Definition game_state.h:559
u8 flags40[0x1A]
Definition game_state.h:567
Vec2 fieldPos
the player's, there
Definition game_state.h:504
GameFuncs funcs
Definition game_state.h:582
u8 flags08[0x1]
Definition game_state.h:558
s32 stageSelectCursor
Definition game_state.h:501
u8 flags1A[0x9]
Definition game_state.h:564
What a usable item does (its ItemInfo.data, an ITEM_EFFECT_*)
Definition game_state.h:200
u8 flags
ITEM_USE_*.
Definition game_state.h:201
u16 amount
the HP it heals, the gauge it fills, a boost in 128ths
Definition game_state.h:203
u8 kind
1 heals amount HP, 2-17 raise a stat by up to amount (STSTATUS_useItem)
Definition game_state.h:202
The item functions (ITEM_FUNCS)
Definition game_state.h:669
s32(* getCategory)(s32 item)
getItemCategory
Definition game_state.h:671
s32(* isKind)(s32 item, s32 kind)
ItemInfo.kind == kind.
Definition game_state.h:672
s32(* list)(s32 type, s16 *out)
listItems
Definition game_state.h:673
An item (ITEMS, ITEM_FUNCS)
Definition game_state.h:225
u8 type
2-14 weapons, 15-20 armour, 21-24 accessories
Definition game_state.h:230
u8 kind
ITEM_KIND_* (ITEM_FUNCS.isKind)
Definition game_state.h:229
u16 sellPrice
0: cannot be sold
Definition game_state.h:228
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
s32 frames[7]
Definition game_state.h:341
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
s16 id
FIRST_ENTRY_ID and up.
Definition game_state.h:248
PartnerStats.equip as a whole: STSTATUS and STITSHOP save it with a struct copy before they equip an ...
Definition game_state.h:318
A partner Digimon from its name on (Partner.info), as getPartnerStats gives it.
Definition game_state.h:303
s16 slots[4]
PARTNER_SLOT_COUNT entries picked from entries[].
Definition game_state.h:308
PartnerEntry entries[44]
Definition game_state.h:309
s16 stats[19]
Definition game_state.h:306
u8 lastBonus
the training whose bonus try last worked, 0 for none: its try can't work again at once
Definition game_state.h:311
s16 status[3]
Definition game_state.h:307
char name[0x18]
Definition game_state.h:304
One of the eight partner Digimon.
Definition game_state.h:345
PartnerStats info
Definition game_state.h:349
u8 pad[4]
nothing reads or writes it
Definition game_state.h:346
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
s32 unlocked
partner id + 3, 0 while locked
Definition game_state.h:347
GameState's play time, which a memory card save copies whole.
Definition game_state.h:330
s16 maxed
stopped at 999:59:59
Definition game_state.h:335
s16 seconds
Definition game_state.h:334
s32 frames
8.8, counted by the vsync callback
Definition game_state.h:331
s16 minutes
Definition game_state.h:333
A special condition (SPECIAL(id)): checkSpecialCondition runs the check function of kind check >> 4 (...
Definition game_state.h:662
PartnerStats' stats[] and the status[] after them as one block, which computeStats and STITSHOP_compu...
Definition game_state.h:324
s16 stats[19]
Definition game_state.h:325
s16 penalties[3]
subtracted from STAT_STRENGTH, STAT_DEFENSE and STAT_SPEED
Definition game_state.h:326
A technique (TECHS, from 1: technique n is TECHS[n - 1])
Definition game_state.h:110
u8 effectChance
Definition game_state.h:120
u8 scriptSound
its script's hit sound (BattleScript.sound)
Definition game_state.h:124
u8 scriptEffect
its script's sprite effect (BattleScript.effect)
Definition game_state.h:123
u8 effect
TECH_EFFECT_* (fightstg/battle.h), under TECH_EFFECT_FIRST none.
Definition game_state.h:119
u8 family
FAMILY_FIRST and up, under it none.
Definition game_state.h:118
u16 mp
its cost
Definition game_state.h:111
u8 effectPower
the effect's strength (a boost's amount, a drain's 128ths)
Definition game_state.h:121
u16 power
its damage, times the user's attack over the target's defense
Definition game_state.h:112
u8 kind
3: heals the target
Definition game_state.h:114
u8 element
ELEMENT_FIRST and up, under it none.
Definition game_state.h:116
u8 icon
a frame of the menu sprites, from 0x37
Definition game_state.h:113
u8 elementPower
how much the element adds, against the target's resistance
Definition game_state.h:117
u8 scriptStage
its script's stage (BattleScript.stage)
Definition game_state.h:122
u8 script
its script in the user's archive (BattleScript.index); 5 and 12 are special
Definition game_state.h:125
Definition gfx.h:352
ItemInfo.data's record for a weapon (types 2-14, WEAPON_DATA)
Definition game_state.h:144
u8 statusChance
of the status its hits inflict
Definition game_state.h:156
u16 amounts[2]
what it adds to stats[]
Definition game_state.h:149
u8 kind
EQUIP_KIND_*.
Definition game_state.h:146
u8 stats[2]
Definition game_state.h:151
u8 family
its hits': FAMILY_FIRST and up, under it none
Definition game_state.h:158
u8 hitEffect
1 none, 2 poison, 3 paralysis, 4 confusion, 6 knock-out, 8 drain, 11 criticals; nothing reads it: FIG...
Definition game_state.h:153
u8 partners
1 << partner for each partner who can equip it (STSTATUS_canEquip)
Definition game_state.h:148
u8 accuracy
added to the battle's (FIGHTSTG_computeStats)
Definition game_state.h:152
u8 statusPower
the status's, or the critical bonus
Definition game_state.h:157
s16 charisma
what it adds to STAT_CHARISMA (computeStats); armour and accessories too
Definition game_state.h:145
ItemInfo.data's record, by ItemInfo.type.
Definition game_state.h:188
ArmorData armor
Definition game_state.h:190
AccessoryData acc
Definition game_state.h:191
WeaponData weapon
Definition game_state.h:189
What ItemInfo.data points to: a weapon's, an armour's or an accessory's record, or a usable item's ef...
Definition game_state.h:208
ItemData * record
Definition game_state.h:210
ArmorData * armor
Definition game_state.h:213
ItemEffect * effect
Definition game_state.h:211
WeaponData * weapon
WEAPON_DATA's, for ITEMS.
Definition game_state.h:212
AccessoryData * acc
Definition game_state.h:214
computeStats' result: the stats with the equipment added, by STAT_* or by name.
Definition game_state.h:409
StatBlock block
the first 0x2C bytes, which computeStats copies whole
Definition game_state.h:424
s16 tp
what the training's intensities cost
Definition game_state.h:413
s32 spare
not filled: STGTRAIN's result keeps its yes/no answer here, 0 yes
Definition game_state.h:422
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