14 if (stat < 1 || stat > 5) {
17 value = &stats->
stats[stat + 5];
41 if (stat < 1 || stat > 5 || (
RANDOM.
next() & 1)) {
44 value = &stats->
stats[stat + 5];
69 s32 resist = stat - 8;
71 if (resist < 0 || resist >= 7) {
76 value = &stats->
stats[stat + 4];
79 }
else if (*value < 300) {
94 if (gains[column].range != 0) {
97 gained = gains[column].
base;
100 if (*value >= 1000) {
119 if (stat < 15 || stat > 16) {
124 value = &stats->
stats[3];
126 current = &stats->
stats[2];
129 value = &stats->
stats[5];
131 current = &stats->
stats[4];
149 if (*value >= 10000) {
154 if (*current > *value) {
174 if (stat >= 1 && stat <= 5) {
180 if (stat >= 1 && stat <= 5) {
190 if (entry->
stat >= 1 && entry->
stat <= 5) {
203 other = entry->
other;
205 if (other >= 1 && other <= 5) {
206 if (result->
losses[i] != 0) {
233 if (stats->
equip[4] == 0x151 || stats->
equip[5] == 0x151) {
236 if (stats->
equip[4] == 0x152 || stats->
equip[5] == 0x152) {
286 for (i = 0; i < 5; i++) {
292 }
else if (result->
trained[i] == 0) {
328#if VERSION_EU || VERSION_JP
379#if VERSION_EU || VERSION_JP
391 if (entry->
stat != 0) {
393 for (i = 0; i < 5; i++) {
394 sums[0] += result->
gains[i];
396 if (entry->
stat >= 8 && entry->
stat <= 14) {
397 if (entry->
other != 0) {
399 for (i = 0; i < 5; i++) {
400 sums[1] += result->
losses[i];
407 if (sums[0] == 0 && sums[1] == 0) {
410#if VERSION_EU || VERSION_JP
411 for (i = 0; i < 2; i++) {
415 if (entry->
stat >= 1 && entry->
stat <= 5) {
430 other = entry->
other;
431 if (other >= 1 && other <= 5) {
437 }
else if (other >= 8 && other <= 14) {
443 }
else if (other == 15) {
449 }
else if (other == 16) {
458 if (entry->
stat >= 1 && entry->
stat <= 5) {
462#elif VERSION_EU || VERSION_JP
465 }
else if (sums[1] != 0) {
469#elif VERSION_EU || VERSION_JP
474#elif VERSION_EU || VERSION_JP
481#elif VERSION_EU || VERSION_JP
556 if (result->
trained[3] != -1) {
694 switch (result->
state) {
703 for (i = 0; i < 5; i++) {
757 switch (task->
state) {
787 {1, 2}, {7, 2}, {14, 3},
788 {2, 0}, {10, 0}, {20, 0},
789 {1, 2}, {6, 3}, {11, 5},
790 {4, 0}, {22, 0}, {48, 0},
794 {1, 0}, {2, 3}, {4, 3},
798 {1, 0}, {1, 0}, {2, 0},
799 {4, 2}, {8, 0}, {12, 0},
800 {8, 2}, {20, 0}, {30, 0},
803 {1, 2}, {2, 0}, {3, 0},
804 {6, 3}, {12, 0}, {18, 0},
805 {12, 4}, {30, 0}, {40, 0},
808 {2, 0}, {2, 0}, {4, 0},
809 {8, 4}, {12, 0}, {25, 0},
810 {16, 5}, {30, 0}, {50, 0},
822 {1, 2}, {2, 0}, {4, 0},
823 {6, 4}, {10, 0}, {20, 0},
824 {13, 5}, {20, 0}, {40, 0},
DigimonData DIGIMON_DATA[55]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
GfxState GFX
GFX: the graphics state and its methods.
GameState GAME
The save data, the game mode and the methods.
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
#define FILE_MENU_SPRITES
Files the engine loads by number.
FileCache FILE_CACHE
The file cache.
TrainState STGTRAIN_state
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
STGTRAIN.PRO: the gyms, where the partners train their stats.
#define STGTRAIN_SPRITES
its sprite bank
#define STGTRAIN_TEXT
The overlay's files: the discs number them differently.
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
#define PAD_REPEATED(button)
void STGTRAIN_applyTry(TrainResult *result, s32 i)
Applies the i-th try of a training (if it worked) and shows what it changed: the stat it raises,...
TrainGain STGTRAIN_resistGainsMid[]
TrainGain STGTRAIN_statLosses[]
What a training may lower another battle stat by, by level.
void STGTRAIN_runIdle(TrainIdle *task, void *children)
Left empty.
s32 STGTRAIN_raiseMaxHpMp(TrainResult *result, s32 stat)
Raises the maximum HP (stat 15) or MP (16) by the training's gain, up to 9999; the US version also ra...
void STGTRAIN_runTraining(TrainResult *result, TrainResultWindows *win)
Runs a training: the partner tries it three times (five at the gyms' second half),...
static void STGTRAIN_startBonusTry(TrainResult *result, TrainResultWindows *win)
Once the question's panels close: yes makes the bonus try with its sound (a sure fail when the traini...
void STGTRAIN_drawResult(TrainResult *result)
Draws the training result: the blinking arrow, a mark for each try (0x45 worked, 0x46 failed) and the...
static s16 getResistance(PartnerTotals *totals, s32 stat)
static void STGTRAIN_takeTry(TrainResult *result, TrainResultWindows *win)
Takes the result of a try: plays its sound and applies it, then plays the next try,...
void STGTRAIN_initIdle(TrainIdle *task, void *children)
Left empty, as are the idle task's other steps.
s32 STGTRAIN_lowerStat(TrainResult *result, s32 stat)
Lowers a battle stat (1-5) by the training's loss, half of the time, down to 0.
void STGTRAIN_showIdle(TrainIdle *task, void *children, s32 show)
Left empty.
s32 STGTRAIN_getAccessoryBonus(TrainResult *result)
The bonus of the accessories 0x151 (3) and 0x152 (6)
static void STGTRAIN_takeBonusTry(TrainResult *result, TrainResultWindows *win)
Takes the result of the bonus try: a good one makes the training the partner's last bonus one and the...
TrainGain STGTRAIN_maxHpMpGains[]
The max HP and MP gains, indexed like the resistances.
void STGTRAIN_drawIdle(TrainIdle *task)
Only sets up a sprite drawer.
static void STGTRAIN_askBonusTry(TrainResult *result, TrainResultWindows *win)
Moves the cursor between yes and no of the bonus try's question, and takes the answer (triangle: no)
static s16 getStat(PartnerTotals *totals, s32 stat)
A battle stat (1-5) or a resistance (8-14) of TOTALS: the match depends on reading them through these...
void STGTRAIN_updateIdle(TrainIdle *task, void *children)
A task that does nothing: its steps are empty, and nothing creates it.
void STGTRAIN_createResultWindows(TrainResult *result, TrainResultWindows *win)
Creates the training result's text windows and cursor.
static void STGTRAIN_showGains(TrainResult *result, TrainResultWindows *win)
Once cross is pressed, shows what the training gave: the stat's gain, and the other stat's loss or ga...
TrainResult * STGTRAIN_createResult(TrainScreen *screen, s32 partner, s32 training)
Creates the results of a training of a partner.
s32 STGTRAIN_raiseStat(TrainResult *result, s32 stat)
Raises a battle stat (1-5) by the training's gain, up to 999.
TrainGain STGTRAIN_statGains[]
The battle stats a training raises, by [training >= 13][bonusWorked][level].
TrainGain STGTRAIN_resistGainsHigh[]
void STGTRAIN_updateResult(TrainResult *result, TrainResultWindows *win)
The training result's task.
TrainIdle * STGTRAIN_createIdle(TrainScreen *screen)
Creates the idle task for the screen.
TrainGain STGTRAIN_resistGainsLow[]
The resistance gains, by [bonusWorked ? (training < 13 ? 1 : 2) : 0][level].
s32 STGTRAIN_raiseResistance(TrainResult *result, s32 stat)
Raises a resistance (stat 8-14) by the training's gain, up to 999: the table goes by the Digimon's gr...
TrainGain * STGTRAIN_resistGainTables[]
The resistance gain tables, by the Digimon's affinity and the resistance's value (under 100,...
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
#define SOUND_MENU_CONFIRM
SYSTEM07.
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
#define SOUND_MENU_CANCEL
SYSTEM01.
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
void(* setPos)()
(cursor, x, y)
void(* setVisible)()
(cursor, visible)
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
u8 resistGrowth[7]
1-5: how fast the gyms raise them
void *(* getEntry)(u32 fileAndIndex)
struct PartnerStats *(* getPartnerStats)(s32 partner)
void(* computeStats)(s32 partner, union PartnerTotals *out)
A partner Digimon from its name on (Partner.info), as getPartnerStats gives it.
u8 lastBonus
the training whose bonus try last worked, 0 for none: its try can't work again at once
s32(* next)(void)
0 to RANDOM_COUNT - 1
short(* playSound)(s32 id)
returns the voice of a key-on
void(* keyOff)(s32 id, s16 voice)
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
void(* setScale)()
(x, y, z), ONE = 1.0
void(* setLayerId)()
(id, depth)
void(* setClutRow)()
(row)
void(* draw)()
(sheet, frame, x, y)
void(* setTexture)()
(x, y)
s32(* isWaitingForButton)()
void(* setPalette)(struct TextWindow *obj, u8 arg)
s32(* isFinished)()
s32: callers don't truncate the result to a byte
void(* setLines)()
no prototype: callers would truncate u8 args
void(* setVisible)(struct TextWindow *obj, u8 arg)
void(* play)(struct TrainActor *actor)
void(* setClutPos)(struct TrainActor *actor, s32 x, s32 y)
void(* setScale)(struct TrainActor *actor, s32 scale)
void(* grow)(struct TrainActor *actor)
void(* pause)(struct TrainActor *actor)
void(* end)(struct TrainActor *actor)
void(* setChance)(struct TrainActor *actor, s32 chance)
s32(* getResult)(struct TrainActor *actor)
void(* setPos)(struct TrainActor *actor, s32 x, s32 y)
An entry of a gym level's trainings (STGTRAIN_gymTrainings)
s16 stat
1-5 battle stats, 8-14 resistances
s16 other
1-5: lowered, 15 or 16: max HP or MP raised
A stat change of a training: base plus a random 0..range-1.
A task the overlay creates (STGTRAIN_createIdle) that does nothing.
void(* nextState)(struct TrainIdle *task)
The children of TrainResult.
TextWindow * question[3]
whether to make the bonus try, yes, no
The results of a training (STGTRAIN_createResult)
s16 bonusSound
the slot of the bonus try's sound
void(* nextState)(struct TrainResult *task)
s32 prompting
the blinking arrow: cross goes on
s32 bonusWorked
the gains take their better columns
s32 bonusTrying
the bonus try (the fourth) is on: its mark blinks
void(* setSubstate)(struct TrainResult *task, s32 substate)
The training screen's main task (STGTRAIN_createScreen)
void(* showStats)(struct TrainScreen *screen, PartnerTotals *before)
s32 intensity
the last one picked
s32(* updateFade)(PanelAnim *fade)
void(* startFade)(PanelAnim *fade, s32 fadeIn)
TrainEntry *(* findTableEntry)(s32 index, s32 id)
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
#define PALETTE_BLUE
a light blue: what is highlighted or current
#define PALETTE_WHITE
The text windows' palettes (TextWindow.palette, setPalette): rows of the font's CLUTs,...
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.
s32 spare
not filled: STGTRAIN's result keeps its yes/no answer here, 0 yes
s16 battle[6]
strength (raised by weapons), defense (by armour), spirit, wisdom, speed and charisma (by all equipme...
struct PartnerTotals::@10 fields