54 if (unit->
maxHp / 4 >= unit->
hp) {
97 for (i = 0; i < 3; i++) {
106 for (i = 0; i < 3; i++) {
125 switch (task->
state) {
135 switch (task->
step) {
150 switch (task->
step) {
163#if VERSION_EU || VERSION_JP
172#if VERSION_EU || VERSION_JP
237 switch (task->
step) {
247 task->
args[0] = 0x42;
259 task->
args[0] = 0x56;
279 task->
args[0] = 0x41;
324 switch (task->
step) {
357 switch (task->
step) {
361 task->
args[0] = 0x38;
379 task->
args[0] = slot;
389 newSlot = task->
args[0];
400#elif VERSION_EU || VERSION_JP
415 task->
args[0] = 0x39;
432 switch (task->
step) {
441 if (unit->
id != 0 && unit->
hp != 0) {
470 switch (task->
step) {
473#if VERSION_EU || VERSION_JP
484 for (i = 0; i < 3; i++) {
485 if (units[i].
id != 0 && units[i].item != 0) {
491 for (i = 0; i < 3; i++) {
492 if (units[i].
id != 0 && units[i].item != 0) {
512 for (member = 0; member < 3; member++) {
529 end->
start(end, 0, 10);
536#if VERSION_EU || VERSION_JP
582 if (action->
args[0] == 0) {
583 task->
args[0] = 0x43;
586 task->
args[0] = 0x5F;
615 task->
args[0] = 0x5A;
619 if (found->
args[0] == 0) {
639 s32 side = action->
args[0] >> 4;
642 switch (task->
step) {
683 task->
args[0] = 0x6A;
699 switch (task->
step) {
703 side = action->
args[0] >> 4;
707 task->
args[2] = damage;
710 if (action->
args[0] == 0) {
719 if (unit->
hp - task->
args[2] <= 0) {
758 switch (task->
step) {
774 unit->
flags &= ~FIGHTER_PARALYZED;
777 unit->
flags &= ~FIGHTER_CONFUSED;
780 unit->
flags &= ~FIGHTER_ASLEEP;
794 switch (task->
step) {
798 task->
args[0] = action->
args[2] + 0x5B;
817 switch (task->
step) {
843 switch (task->
step) {
847 task->
args[0] = action->
args[2] + 0x57;
856 unit->
flags &= ~(1 << (action->
args[2] + 4));
872#if VERSION_EU || VERSION_JP
876 switch (task->
step) {
880 task->
args[0] = 0x61;
891 }
else if (level < 19) {
893 }
else if (level < 39) {
895 }
else if (level < 70) {
912 if (models->
get(models, 0)->
motion == 13) {
915#if VERSION_EU || VERSION_JP
922 current->
flags &= ~FIGHTER_CONFUSED;
936 switch (task->
step) {
948 task->
args[0] = 0x62;
965 side = action->
args[0] >> 4;
977#elif VERSION_EU || VERSION_JP
981 task->
args[0] = 0x50;
984 task->
args[0] = 0x51;
985 task->
args[1] = 0x10;
1002 if (event->
args[0] == 0) {
1005 task->
args[0] = 0x53;
1013 task->
args[0] = 0x52;
1016 task->
args[2] = 100;
1073 switch (task->
step) {
1079 task->
args[0] = 0x8B;
1094 for (i = 0; i < 3; i++) {
1095 if (unit[i].
id != 0 && unit[i].hp != 0) {
1101 if (event->
args[0] == 0) {
1107 task->
args[0] = slot;
1157 task->
args[0] = 0x59;
1173 switch (task->
step) {
1194 task->
args[0] = 0x47;
1205 switch (task->
step) {
1236 switch (task->
step) {
1259 tech = &
TECHS[
id - 1];
1324 request.
args[0] = -1;
1341#if VERSION_EU || VERSION_JP
1345 if (task->
step == 0) {
1358#if VERSION_EU || VERSION_JP
1363 if (task->
step != 0) {
1369 switch (task->
step) {
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
void FIGHTSTG_queueSpecialEnd(void)
Queues the end of the partner's special state (event 21): the USA version pushes back the one already...
BattleFuncs FIGHTSTG_battleFuncs
the battle's stats and the functions that compute with them
void FIGHTSTG_queueKnockOut(u8 side)
Queues the fall of side's active fighter (event 20), first.
void FIGHTSTG_queueBlastEnd(s32 kind)
Queues the end of the partner's digivolution for the battle (event 19), after delay kind + 3.
#define FIGHTER_PARALYZED
loses turns at random (FIGHTSTG_battleFuncs.testParalysis)
#define BATTLE_KIND_ESCAPE
the enemy runs away under a tenth of its HP
#define TECH_EFFECT_MULTI_HIT
#define EVENT_AUTO_RECOVER_END
#define EVENT_WEAKNESS_END
the end of the enemy's weakness (BATTLE_KIND_FINAL_LAST)
#define EVENT_STATUS_DAMAGE
the damage of a poisoned fighter (FIGHTER_POISONED)
#define TECH_EFFECT_FIRST
A technique's effect (TechData.effect), which FIGHTSTG_applyTechEffect carries out when its hit lands...
#define EVENT_END_BATTLE
The types of the battle's events: WFIGHTMN runs a state for each (WFIGHTMN_runTurn)
#define BATTLE_KIND_NORMAL
The kinds of battle (Battle.kind), which WFIGHTMN picks by the battle and the mode it came from.
#define BATTLE_FLED
How a battle ends (FIGHTSTG_endBattle)
#define BATTLE_STAT_SPEED
physical accuracy, evasion and running away
#define EVENT_DIGIDEVOLVE
#define EVENT_CLEAR_FIELD
#define EVENT_LAST_ENEMY
the last battle's third enemy comes in
#define BATTLE_KIND_UNK2
the enemy keeps an eleventh of its HP
#define EVENT_BOOST_END
13-15: the end of a boost, by the stat
#define TECH_EFFECT_ENEMY_ONLY
does nothing but for the enemy whose battle table entry lists it first
#define BATTLE_KIND_NO_DAMAGE
the partner's hits do no damage
#define ACTIVE_FIGHTER(side)
SIDE's active fighter as its row plus the index, which GCC adds with the row's address first.
#define EVENT_SPECIAL_END
the end of the partner's special state
#define EVENT_STATUS_END
10-12: the end of FIGHTER_PARALYZED, FIGHTER_CONFUSED or FIGHTER_ASLEEP
#define BATTLE_KIND_FINAL
battle 0x144, the last one: its first enemy
#define EVENT_PARTNER_TECH
a technique of the partner's, run as its command
#define BATTLE_KIND_FINAL_LAST
its third enemy; winning plays the ending
#define EVENT_BLAST
the partner's digivolution for the battle
#define BATTLE_KIND_FINAL_SECOND
its second enemy
#define EVENT_RESTRICTION_END
16-17: the end of a restriction (FIGHTER_NO_SWITCH or FIGHTER_NO_DIGIVOLVE)
#define TECH_EFFECT_STEAL
the enemy's item
#define SIDE_PLAYER
The battle's sides, as the functions that take a side want them: side >> 4 is its row of FIGHTSTG_bat...
#define ELEMENT_FIRST
The elements (TechData.element, BattleStats.element) and the families (TechData.family,...
void FIGHTSTG_endBattle(s32 result)
Ends the battle: queues event 1 ahead of the others, with how it ended (BATTLE_FLED,...
void FIGHTSTG_queuePlayerTurn(s32 delay)
Queues the player's turn (event 2) in delay.
void FIGHTSTG_queueRunAway(u8 side)
Queues side's attempt to run away (event 4)
EventQueue FIGHTSTG_events
the battle's events and their functions
void FIGHTSTG_queueEnemyTurn(s32 delay)
Queues the enemy's turn (event 3) in delay.
ScreenFade * FIGHTSTG_createFader(void)
Creates the screen fade, idle until started, on layer BATTLE_LAYER_FRONT.
#define BATTLE_LAYER_CAMERA
The battle's layers, over the screen's (SCREEN_LAYER)
#define BATTLE_TASK_MENU
The ids that the battle's tasks register with, for the others to find them (TASK_REGISTRY....
#define BATTLE_TASK_MODELS
the fighters'
BattleCamera * FIGHTSTG_createBattleCamera(s32 layerId)
Creates the battle camera (BATTLE_TASK_CAMERA) on a layer.
BattleScript * FIGHTSTG_createBattleScript(void)
Creates a battle script, which plays a technique (FIGHTSTG_updateBattleScript)
BattleTableEntry *(* FIGHTSTG_battleTableFunc)(s32 id)
how the fight stage and WFIGHTMN read the battle table
CameraShots * FIGHTSTG_startCameraShots(void)
Starts the European version's own camera.
CameraTurn * FIGHTSTG_startCameraTurn(void)
Starts the camera's turn around the fighters.
DigimonData DIGIMON_DATA[55]
55 entries: the 52 Digimon, then three placeholders (0x1D4-0x1D6)
DigimonChange * FIGHTSTG_startDigimonChange(s32 key1, s32 key2)
Starts a partner's Digimon change (FIGHTSTG_updateDigimonChange)
GfxState GFX
GFX: the graphics state and its methods.
HitEffect * FIGHTSTG_startHitEffect()
WFIGHTMN passes the damage as a third argument, which it doesn't read; its code loads it,...
EnemyAttack * FIGHTSTG_startEnemyAttack(s32 kind, s32 noKnockout)
Starts an attack on the player's active fighter (FIGHTSTG_updateEnemyAttack): kind 0 for the enemy's ...
EnemyTurn * FIGHTSTG_startEnemyTurn(void)
Starts the enemy's turn (FIGHTSTG_updateEnemyTurn)
GameState GAME
The save data, the game mode and the methods.
Entrance * FIGHTSTG_startEntrance(s32 id, s32 side, s32 weak)
Starts a fighter's entrance: Digimon id on the player's side (side 0) or the enemy's.
FirstTech * FIGHTSTG_startFirstTech(s32 side)
Starts side's first technique (FIGHTSTG_updateFirstTech)
#define MODE_BATTLE_REPORT
STFGTREP.
#define MODE_TITLE
STDWTITL's title screen; its movies follow.
#define STAT_LEVEL
Indices of a partner's stats (PartnerStats.stats, computeStats, setStat)
DigimonData *(* GET_DIGIMON)(s32 id)
getDigimon for the overlays, in the small data (.sdata) between game/items.c's and file/file_table....
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
BattleItem * FIGHTSTG_startItem(s32 item)
Starts an item's script (FIGHTSTG_updateItem)
TechData TECHS[443]
The techniques, from 1: technique n is TECHS[n - 1].
BattleResult BATTLE_RESULT
Lights * FIGHTSTG_createLights(s32 layerId)
Creates the stage lights (id 0x13) for layer layerId.
BattleLoader * WFIGHTMN_createLoader(void)
Starts loading the battle menu's files.
BattleMessageBox * FIGHTSTG_createMessage(void)
Creates a battle message box (FIGHTSTG_updateMessage)
Models * FIGHTSTG_createModels(void)
Creates the fighters' models (Models), with no fighters yet.
WFIGHTMN.PRO: the battle's sub-overlay.
#define WFIGHTMN_RECOVERY_ITEM
The item a partner can equip that makes FIGHTSTG's FIGHTSTG_queueRecovery act on it at the start of t...
OneHpTurn * FIGHTSTG_startOneHpTurn(void)
Starts BATTLE_KIND_FINAL_SECOND's enemy turn.
void FIGHTSTG_setPlayerTurnStep(s32 substate)
Sets the player's turn's substate, while it runs (4 picks the next fighter)
s32 FIGHTSTG_isPlayerChoosing(void)
Whether the player's turn has a menu open (its substate isn't 0)
PlayerTurn * FIGHTSTG_startPlayerTurn(void)
Starts the player's turn (FIGHTSTG_updatePlayerTurn, id 0xE)
TaskRegistry TASK_REGISTRY
void WFIGHTMN_createLayers(void)
Sets up the display and the battle's layers.
s32 WFIGHTMN_rollAmbush(void)
Checks the chance in BATTLE_SETUP.ambushChance, scaled by how far the first partner's level and the f...
void WFIGHTMN_markFought(void)
Marks in BATTLE_RESULT that the current partner fought, and with which of its slots' Digimon if it is...
void WFIGHTMN_markPicked(BattleMenu *task, BattleMenuChildren *children)
Records in BATTLE_RESULT that the partner of the player's turn fought, and which of its digivolution ...
void WFIGHTMN_initFighters(s32 digimon)
Fills the battle's fighters: the party's partners (the first one with the id DIGIMON) and the encount...
void WFIGHTMN_checkParty(void)
Checks each of the party's three partners for WFIGHTMN_RECOVERY_ITEM (WFIGHTMN_checkEquip)
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
#define SOUND_WIN_JINGLE
W_JINGLE: a battle won.
#define MUSIC_GAME_OVER
GAMEOVER: a battle lost (WFIGHTMN endBattleOnKnockOut)
#define MUSIC_CONFUSION
The music by where the game plays it (FieldState.music, AreaBattle.music, the screens'),...
FightStage * FIGHTSTG_createStage(s32 id, s32 fadeInTime)
Creates the fight stage (id 0x15), which loads stage id and fades it in over fadeInTime.
CameraView *(* getEnemyView)(struct BattleCamera *task)
void(* set)(struct BattleCamera *task, CameraView *view)
An event of the battle, as it is queued (FIGHTSTG_pushEvent)
s32 type
EVENT_END_BATTLE...
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
u8 paralysis
FIGHTER_PARALYZED's strength.
s16 charge
added in 64ths to its next technique's damage, which uses it up
u8 temporary
id is a temporary Digimon
s16 id
the Digimon (DIGIMON_DATA)
s16 prevId
its own id while id is a temporary one
s16 boosts[4]
added to the stats FIGHTSTG_boostStats picks
u8 sleep
FIGHTER_ASLEEP's.
u8 confusion
FIGHTER_CONFUSED's.
u8 special
the partner's special state (EVENT_SPECIAL_END): doubles its effects
s32(* getHeal)(u8 side, s32 index, s32 big)
a part of its max HP
s32(* testParalysis)(u8 side)
whether side's paralysis costs it the turn
s32(* testRunAway)(u8 side)
s32(* getDamage)(s32 *args)
of the event whose args these are
BattleStats *(* computeStats)(u8 side, s32 which, s32 index)
void(* finish)(struct BattleMessageBox *task)
FIGHTSTG_finishMessage: closes after 0x14 ticks or Cross.
void(* show)()
FIGHTSTG_showMessage: (task, type, data)
s16 member
the party member whose accessory adds money
s16 battle
row of STFGTREP_rewards
struct BattleResult::@9 partners[3]
u8 used[3]
the Digimon of each slot was used
s16 item
the item won, 0 for none
s32 enemy
the script is the enemy's (nonzero) or the partner's
s32 sound
what the sound commands' 0x62 and 0x63 stand for on a hit
s32 effect
the sprite effect the effect command's 9999 stands for
s32 hits[4]
0 a hit, 3 a miss; [3] how it ended
s32 index
the script, in the fighter's archive
s32 stage
what the stage command's 0x38 stands for
s32 prize
an item (BattleResult.item)
s32 battle
the battle (BattleResult.battle)
s16 gauges[8]
filled in battle, up to 1000
s32 music
the battle's music
s32 stage
the battle's fight stage
s32 hasPrize
1: the battle always gives prize
s16 runAttempts
the player's, each of which makes running away likelier (FIGHTSTG_testRunAway)
s8 hitCount
BATTLE_KIND_FINAL_LAST: the partner's hits that did damage.
s32 active[2]
each side's fighter
BattleFighter fighters[2][3]
s16 kind
the kind of battle
u8 weakened
BATTLE_KIND_FINAL_LAST: the enemy is weakened (FIGHTSTG_weakenEnemy)
s16 tech
a technique id, set by WFIGHTMN
A side's stats as FIGHTSTG_computeStats works them out.
s16 stats[5]
with the fighter's boosts
s16 nameId
string in file 0x4F
s16 itemChance
in 1024ths, less one
FIGHTSTG_battle: the battle.
Digimon definition (DIGIMON_DATA, 52 of them; the first 8 are the partners)
u8 nameId
string in file 0x4F
u8 blastForms[5]
what a blast turns a partner into (from 1), by its level's tier
s32 effect
TechData.effect, -1 ends the list.
s16 element
under ELEMENT_FIRST: none
What FIGHTSTG_removeEvents removes the events of: an event's first two args, as FIGHTSTG_queueRecover...
s32(* pop)(void)
the next event due
s32(* getDelay)(u8 side, s32 kind)
FIGHTSTG_getEventDelay: when an event of side's runs.
u8 result
the battle's, for WFIGHTMN (BATTLE_FLED...)
void(* pushFirst)(BattleEvent *event)
before all the others
s32(* find)(s32 type, u8 side, s32 fighter)
void(* remove)(EventKey *key)
the events whose first two args are its
The battle's events (FIGHTSTG_events)
s8 curIndex
and where it is
struct PartnerStats *(* getPartnerStats)(s32 partner)
void(* requestMode)(s32 mode, s32 arg)
s32(* getPartyMember)(u32 index)
s32(* getPartnerSlots)()
(partner, s16 *out): the count
Partner partners[PARTNER_COUNT]
s32 fieldMode
where the menu returns to
struct Layer *(* getLayer)(s32 id)
s32 frameTime
vsyncs that the last frame took
void(* zero)(void *ptr, s32 size)
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
void(* setBgColor)()
no prototype: callers would truncate u8 args
s32 motion
the motion to play
The fighters' models (FIGHTSTG_createModels), registered as BATTLE_TASK_MODELS: up to four,...
void(* setIdleMotion)(struct Models *task, s32 id, s32 motion)
void(* face)(struct Models *task, s32 id)
ids under 0x10 are one side
void(* add)(struct Models *task, s32 id, s32 fighter, s32 visible)
ModelControl *(* get)(struct Models *task, s32 id)
A partner Digimon from its name on (Partner.info), as getPartnerStats gives it.
s32 battleDigivolve
an entry id, compared with the slots': the Digimon the battle starts it as, 0 for its own
s32 arg
the action's: the item, the technique, or the party slot of the partner that digivolves or switches o...
s32 action
what the turn does
s32 pairTech
FIGHTSTG_createPairSwitchMenu's technique, which the outgoing and incoming partners do together (acti...
s32 digimon
the Digimon a partner changes into, or the one it switches to
A queued event: its time counts down to when it runs.
s16 type
0 for a free entry
s32(* next)(void)
0 to RANDOM_COUNT - 1
Fades the whole screen to black and back with a subtractive rectangle.
void(* start)(struct ScreenFade *fade, s32 fadeIn, s32 frames)
TASK_DONE when done.
short(* playSound)(s32 id)
returns the voice of a key-on
void *(* find)(s32 id, s32 key1, s32 key2)
Any task, seen through its header.
void(* setState)(struct Task *task, s32 state)
A technique (TECHS, from 1: technique n is TECHS[n - 1])
u8 scriptSound
its script's hit sound (BattleScript.sound)
u8 scriptEffect
its script's sprite effect (BattleScript.effect)
u8 effect
TECH_EFFECT_* (fightstg/battle.h), under TECH_EFFECT_FIRST none.
u8 effectPower
the effect's strength (a boost's amount, a drain's 128ths)
u8 element
ELEMENT_FIRST and up, under it none.
u8 elementPower
how much the element adds, against the target's resistance
u8 scriptStage
its script's stage (BattleScript.stage)
u8 script
its script in the user's archive (BattleScript.index); 5 and 12 are special
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
TechAction * FIGHTSTG_startTechAction(s32 side, s32 tech)
Starts side's (0 or 0x10) technique or item tech.
BattleScript * WFIGHTMN_startTech(u8 actor, s32 id)
Starts the effect of actor's move id (FIGHTSTG's FIGHTSTG_createBattleScript): its kind and motions f...
void WFIGHTMN_endWeakness(u8 side)
In BATTLE_KIND_FINAL_LAST, anything the partner does but an attack ends the enemy's weakness (FIGHTST...
s32 WFIGHTMN_setIdleMotion(u8 id, s32 damage)
Sets the idle motion of side id >> 4's fighter: 1 (weak) if damage leaves it with a quarter of its HP...
CameraShots * cameraShots
the European version's (FIGHTSTG_startCameraShots)
Entrance * entrance
a fighter's (FIGHTSTG_startEntrance)
BattleMessageBox * message
FIGHTSTG_createMessage.
DigimonChange * change
a partner's Digimon change (FIGHTSTG_startDigimonChange)
ScreenFade * fade
FIGHTSTG_createFader.
HitEffect * hitEffect
effect 0x33, then a script (FIGHTSTG_startHitEffect)
FirstTech * attack
FIGHTSTG_startFirstTech.
BattleScript * script
a technique's (FIGHTSTG_createBattleScript)
TechAction * tech
a technique or an item (FIGHTSTG_startTechAction)
EnemyTurn * enemyTurn
FIGHTSTG_startEnemyTurn.
EnemyAttack * enemyAttack
an attack on the player's fighter (FIGHTSTG_startEnemyAttack)
OneHpTurn * oneHpTurn
BATTLE_KIND_FINAL_SECOND's enemy turn (FIGHTSTG_startOneHpTurn)
BattleItem * item
FIGHTSTG_startItem.
CameraTurn * cameraTurn
when the player loses (FIGHTSTG_startCameraTurn)
ElementLook WFIGHTMN_elementVisuals[]
A technique's look (its scriptEffect, scriptSound and scriptStage) by its element,...
EffectLook WFIGHTMN_effectVisuals[]
A technique's look (its scriptEffect and scriptSound) by its effect, for WFIGHTMN_bringLastEnemy; the...
void(* WFIGHTMN_states[])(BattleMenu *task, BattleMenuChildren *children)
The battle menu's states, by its substate.