From 800d958b553289f6b685b197422378dec7e796f7 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:10:33 -0500 Subject: [PATCH 01/18] btlrand.c labels complete --- config/symbols.main.us.txt | 2 ++ src/main/110B8.c | 2 +- src/main/btlrand.c | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/config/symbols.main.us.txt b/config/symbols.main.us.txt index 9fc99d78..90e5fdee 100644 --- a/config/symbols.main.us.txt +++ b/config/symbols.main.us.txt @@ -765,3 +765,5 @@ g_AkaoMusicAltMask = 0x8009A12C; g_ReverbMode = 0x8009A140; g_ReverbAttr = 0x8009C564; // type:SpuReverbAttr size:0x14 D_8009D44C = 0x8009D44C; +g_KernelRandomTable = 0x80083084; +SysInitRndTablePos = 0x80014C44; \ No newline at end of file diff --git a/src/main/110B8.c b/src/main/110B8.c index 6a8e0cbb..e520db51 100644 --- a/src/main/110B8.c +++ b/src/main/110B8.c @@ -6,7 +6,7 @@ void SysGzipSetDataBlock(u8* arg0); u8* func_80014C80(s32 arg0); u16 SysGzipGetType(void); u16 SysGzipGetSize(void); -extern u8 D_80083084[]; +extern u8 g_KernelRandomTable[]; extern u8 D_80062D98; extern s32 D_80062D9C; diff --git a/src/main/btlrand.c b/src/main/btlrand.c index 69e1ff89..7ed71240 100644 --- a/src/main/btlrand.c +++ b/src/main/btlrand.c @@ -2,40 +2,40 @@ #include "main_private.h" // Functions used by the battle module for formulas requiring random nummbers. -// D_80083084 is the random number table from KERNEL.BIN section 3 and belongs +// g_KernelRandomTable is the random number table from KERNEL.BIN section 3 and belongs // to a larger struct. -static u32 D_80062D4C = 0; -static u8 D_80062E10[8]; -static s32 D_80062E18; +static u32 g_KernelRandomCallCount = 0; +static u8 g_KernelRandomTablePos[8]; +static s32 g_KernelRandomTableIndex; -extern u8 D_80083084[256]; +extern u8 g_KernelRandomTable[256]; void SysIncSeedForRandom(void) { - D_80062E18++; - D_80062E18 &= 7; + g_KernelRandomTableIndex++; + g_KernelRandomTableIndex &= 7; } -u8 SysGetRandomByteFromTable(void) { return D_80083084[D_80062E10[D_80062E18]++]; } +u8 SysGetRandomByteFromTable(void) { return g_KernelRandomTable[g_KernelRandomTablePos[g_KernelRandomTableIndex]++]; } -u8 SysGetRandomByteRange(s32 arg0) { return (SysGetRandomByteFromTable() * arg0) >> 8; } +u8 SysGetRandomByteRange(s32 upperBound) { return (SysGetRandomByteFromTable() * upperBound) >> 8; } u16 SysRandomTwoBytes(void) { u8 lo; lo = SysGetRandomByteFromTable(); - if (D_80062D4C++ & 7) { + if (g_KernelRandomCallCount++ & 7) { SysIncSeedForRandom(); } return (SysGetRandomByteFromTable() << 8) | lo; } -void func_80014C44(s32 arg0) { +void SysInitRndTablePos(s32 seed) { s32 i; for (i = 0; i < 8; i++) { - D_80062E10[i] = arg0; - arg0 >>= 1; + g_KernelRandomTablePos[i] = seed; + seed >>= 1; } - D_80062E18 = 0; + g_KernelRandomTableIndex = 0; } From e7f0a3adcbc7ac4b47f9a70b2b7643d72c8e1dd9 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:13:47 -0500 Subject: [PATCH 02/18] btlrand.c kernel labels --- config/symbols.main.us.txt | 2 +- src/main/110B8.c | 2 +- src/main/btlrand.c | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/symbols.main.us.txt b/config/symbols.main.us.txt index 90e5fdee..f23d5fb6 100644 --- a/config/symbols.main.us.txt +++ b/config/symbols.main.us.txt @@ -765,5 +765,5 @@ g_AkaoMusicAltMask = 0x8009A12C; g_ReverbMode = 0x8009A140; g_ReverbAttr = 0x8009C564; // type:SpuReverbAttr size:0x14 D_8009D44C = 0x8009D44C; -g_KernelRandomTable = 0x80083084; +g_KernRndTable = 0x80083084; SysInitRndTablePos = 0x80014C44; \ No newline at end of file diff --git a/src/main/110B8.c b/src/main/110B8.c index e520db51..9c6161fa 100644 --- a/src/main/110B8.c +++ b/src/main/110B8.c @@ -6,7 +6,7 @@ void SysGzipSetDataBlock(u8* arg0); u8* func_80014C80(s32 arg0); u16 SysGzipGetType(void); u16 SysGzipGetSize(void); -extern u8 g_KernelRandomTable[]; +extern u8 g_KernRndTable[]; extern u8 D_80062D98; extern s32 D_80062D9C; diff --git a/src/main/btlrand.c b/src/main/btlrand.c index 7ed71240..cfa0b030 100644 --- a/src/main/btlrand.c +++ b/src/main/btlrand.c @@ -2,21 +2,21 @@ #include "main_private.h" // Functions used by the battle module for formulas requiring random nummbers. -// g_KernelRandomTable is the random number table from KERNEL.BIN section 3 and belongs +// g_KernRndTable is the random number table from KERNEL.BIN section 3 and belongs // to a larger struct. -static u32 g_KernelRandomCallCount = 0; -static u8 g_KernelRandomTablePos[8]; -static s32 g_KernelRandomTableIndex; +static u32 g_KernRndCallCount = 0; +static u8 g_KernRndTablePos[8]; +static s32 g_KernRndTableIndex; -extern u8 g_KernelRandomTable[256]; +extern u8 g_KernRndTable[256]; void SysIncSeedForRandom(void) { - g_KernelRandomTableIndex++; - g_KernelRandomTableIndex &= 7; + g_KernRndTableIndex++; + g_KernRndTableIndex &= 7; } -u8 SysGetRandomByteFromTable(void) { return g_KernelRandomTable[g_KernelRandomTablePos[g_KernelRandomTableIndex]++]; } +u8 SysGetRandomByteFromTable(void) { return g_KernRndTable[g_KernRndTablePos[g_KernRndTableIndex]++]; } u8 SysGetRandomByteRange(s32 upperBound) { return (SysGetRandomByteFromTable() * upperBound) >> 8; } @@ -24,7 +24,7 @@ u16 SysRandomTwoBytes(void) { u8 lo; lo = SysGetRandomByteFromTable(); - if (g_KernelRandomCallCount++ & 7) { + if (g_KernRndCallCount++ & 7) { SysIncSeedForRandom(); } return (SysGetRandomByteFromTable() << 8) | lo; @@ -34,8 +34,8 @@ void SysInitRndTablePos(s32 seed) { s32 i; for (i = 0; i < 8; i++) { - g_KernelRandomTablePos[i] = seed; + g_KernRndTablePos[i] = seed; seed >>= 1; } - g_KernelRandomTableIndex = 0; + g_KernRndTableIndex = 0; } From 0b6dff0837708709fea5cc824cf7de17300396f8 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 18:55:26 -0500 Subject: [PATCH 03/18] BattleInitMain --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 1 + src/battle/batini.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index ddf91d64..79a0f716 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1,4 +1,4 @@ -func_801B0050 = 0x801b0050; +BattleInitMain = 0x801b0050; func_801B0490 = 0x801b0490; func_801B0668 = 0x801b0668; func_801B085C = 0x801b085c; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 1d23a731..b6b1d3ba 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -1 +1,2 @@ g_BattleState = 0x800F83AC; // size:0x444 +BattleInitMain = 0x801B0050; diff --git a/src/battle/batini.c b/src/battle/batini.c index 698ec672..4f2f0473 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -7,7 +7,7 @@ void BATTLE_RunFrame(void); // battle callback for batini, move to battle.h void func_801B2308(void); // entrypoint -INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B0050); +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitMain); static void func_801B23E0(s32 sceneID, void (*cb)(void)); void func_801B0490(s32 sceneID) { From 8a8ea5b341dee3d20552298201d9c64046c3234b Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 20:49:27 -0500 Subject: [PATCH 04/18] BattleInitSetup --- config/sym_ovl_export.us.txt | 18 +++++----- config/symbols.batini.txt | 6 ++++ config/symbols.battle.txt | 4 +++ config/symbols.main.us.txt | 4 +-- src/battle/batini.c | 46 ++++++++++++------------ src/battle/battle.c | 68 ++++++++++++++++++------------------ 6 files changed, 78 insertions(+), 68 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 79a0f716..3c96222d 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1,9 +1,9 @@ BattleInitMain = 0x801b0050; -func_801B0490 = 0x801b0490; +BattleInitSetup = 0x801b0490; func_801B0668 = 0x801b0668; func_801B085C = 0x801b085c; func_801B08C0 = 0x801b08c0; -func_801B0F08 = 0x801b0f08; +BattleInitPartyFromSavemap = 0x801b0f08; func_801B1120 = 0x801b1120; func_801B11BC = 0x801b11bc; func_801B137C = 0x801b137c; @@ -13,10 +13,10 @@ func_801B1530 = 0x801b1530; func_801B1598 = 0x801b1598; func_801B1734 = 0x801b1734; func_801B18F8 = 0x801b18f8; -func_801B19AC = 0x801b19ac; +BattleInitFormation = 0x801b19ac; func_801B1CB0 = 0x801b1cb0; -func_801B1E0C = 0x801b1e0c; -func_801B2308 = 0x801b2308; +BattleInitEnemyUnits = 0x801b1e0c; +BattleInitEnemyAI = 0x801b2308; func_801B2738 = 0x801b2738; func_801B2770 = 0x801b2770; func_801B0000 = 0x801b0000; @@ -74,7 +74,7 @@ func_800A3ED0 = 0x800a3ed0; func_800A4350 = 0x800a4350; func_800A4480 = 0x800a4480; func_800A44D8 = 0x800a44d8; -func_800A4540 = 0x800a4540; +BattleUpdateUnitMasks = 0x800a4540; func_800A4844 = 0x800a4844; BATTLE_RunToResultScreen = 0x800a4860; BATTLE_RunEscapeSequence = 0x800a4954; @@ -151,7 +151,7 @@ func_800A7130 = 0x800a7130; func_800A71E0 = 0x800a71e0; func_800A71E8 = 0x800a71e8; func_800A71F4 = 0x800a71f4; -func_800A7254 = 0x800a7254; +BattleQueueEvent = 0x800a7254; func_800A72C8 = 0x800a72c8; BATTLE_ResolveMagicActionIndex = 0x800a73c0; BATTLE_ResolveSummonActionIndex = 0x800a73d8; @@ -249,7 +249,7 @@ func_800AE42C = 0x800ae42c; func_800AE6C0 = 0x800ae6c0; func_800AE764 = 0x800ae764; func_800AE82C = 0x800ae82c; -func_800AE954 = 0x800ae954; +BattleRecalcUnitSpeed = 0x800ae954; func_800AEB20 = 0x800aeb20; func_800AEB80 = 0x800aeb80; func_800AEBF0 = 0x800aebf0; @@ -286,7 +286,7 @@ func_800B0EB4 = 0x800b0eb4; func_800B0F04 = 0x800b0f04; func_800B0FFC = 0x800b0ffc; func_800B1060 = 0x800b1060; -func_800B108C = 0x800b108c; +BattleInitUnitAction = 0x800b108c; BATTLE_QueueEffect = 0x800b10f0; func_800B1218 = 0x800b1218; func_800B1268 = 0x800b1268; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index b6b1d3ba..dde3121e 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -1,2 +1,8 @@ g_BattleState = 0x800F83AC; // size:0x444 BattleInitMain = 0x801B0050; +BattleInitSetup = 0x801B0490; +BattleInitPartyFromSavemap = 0x801B0F08; +BattleInitFormation = 0x801B19AC; +BattleInitEnemyUnits = 0x801B1E0C; +BattleInitEnemyAI = 0x801B2308; +BattleInitLoadSceneData = 0x801B23E0; diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index b69843e5..2a314cec 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -3,6 +3,7 @@ BATTLE_SetFocusedActor = 0x800A22C0; BATTLE_CheckAllLucky7s = 0x800A2894; BATTLE_DropSupersededQueuedActions = 0x800A304C; BATTLE_RunFrame = 0x800A3354; +BattleUpdateUnitMasks = 0x800A4540; BATTLE_RunToResultScreen = 0x800A4860; BATTLE_RunEscapeSequence = 0x800A4954; BATTLE_PickRandomThrowItem = 0x800A5990; @@ -10,6 +11,7 @@ BATTLE_ExpandScriptToBuffer = 0x800A5EB0; BATTLE_ClearStatusBit = 0x800A6CC0; BATTLE_ExpireDeathSentence = 0x800A6D10; BATTLE_TickPoison = 0x800A6D88; +BattleQueueEvent = 0x800A7254; BATTLE_ResolveMagicActionIndex = 0x800A73C0; BATTLE_ResolveSummonActionIndex = 0x800A73D8; BATTLE_SetupThrowAction = 0x800A7458; @@ -27,11 +29,13 @@ BATTLE_ApplyDefaultAbsorbEffect = 0x800AD420; BATTLE_ApplySadnessReduction = 0x800AD890; BATTLE_ApplyKillCountBonus = 0x800AE318; BATTLE_CalcMateriaSlotScore = 0x800AE378; +BattleRecalcUnitSpeed = 0x800AE954; BATTLE_TryApplyHitEffect = 0x800AF1D4; BATTLE_ApplyRegenPoisonTick = 0x800AF3AC; BATTLE_ClearActorSlotReferences = 0x800AF594; BATTLE_RollPhysicalHit = 0x800B079C; BATTLE_ApplyConditionalReduction = 0x800B0E5C; +BattleInitUnitAction = 0x800B108C; BATTLE_QueueEffect = 0x800B10F0; BATTLE_InvalidateQueuedMessages = 0x800B1304; BATTLE_ScriptReadU16 = 0x800B1368; diff --git a/config/symbols.main.us.txt b/config/symbols.main.us.txt index f23d5fb6..e978a4a2 100644 --- a/config/symbols.main.us.txt +++ b/config/symbols.main.us.txt @@ -34,6 +34,7 @@ SysIncSeedForRandom = 0x80014B54; SysGetRandomByteFromTable = 0x80014B70; SysGetRandomByteRange = 0x80014BA8; SysRandomTwoBytes = 0x80014BE4; +SysInitRndTablePos = 0x80014C44; SysGetPointerToTextInKernWithBlockAndTextId = 0x80014D9C; SysDecompKernStringWithF9 = 0x800150E4; SysGetPtrToKernBattleTxtWithId = 0x800151F4; @@ -753,6 +754,7 @@ g_ArmorTable = 0x80071E44; g_WeaponTable = 0x800738A0; g_AkaoVoiceAttr = 0x8007EBE4; g_AkaoVoiceAttrMask = 0x8007EBE8; +g_KernRndTable = 0x80083084; g_isFieldLoading = 0x800965E8; g_AkaoSoundActiveMaskStored = 0x80099FDC; g_AkaoNoiseMask = 0x80099FEC; @@ -765,5 +767,3 @@ g_AkaoMusicAltMask = 0x8009A12C; g_ReverbMode = 0x8009A140; g_ReverbAttr = 0x8009C564; // type:SpuReverbAttr size:0x14 D_8009D44C = 0x8009D44C; -g_KernRndTable = 0x80083084; -SysInitRndTablePos = 0x80014C44; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 4f2f0473..acfcc8eb 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -4,13 +4,13 @@ extern Unk801B2308 D_80163624; extern u16 D_8016376C; void BATTLE_RunFrame(void); // battle callback for batini, move to battle.h -void func_801B2308(void); +void BattleInitEnemyAI(void); // entrypoint INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitMain); -static void func_801B23E0(s32 sceneID, void (*cb)(void)); -void func_801B0490(s32 sceneID) { +static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)); +void BattleInitSetup(s32 sceneID) { Unk800F83E0* c; s32 i; s32 var_s1; @@ -18,8 +18,8 @@ void func_801B0490(s32 sceneID) { var_s1 = 4; if (D_8016376C) { var_s1 = 0; - func_800A7254(0, 0, 15, 0); - func_800A7254(0, 0, 14, 0); + BattleQueueEvent(0, 0, 15, 0); + BattleQueueEvent(0, 0, 14, 0); } for (i = 0; i < 0x40; i++) { if (D_800F6936[i][0] >= var_s1) { @@ -30,13 +30,13 @@ void func_801B0490(s32 sceneID) { D_800F5E60[i].unk6 = 0; } if (D_8016376C) { - func_801B0F08(); + BattleInitPartyFromSavemap(); } - func_801B23E0(sceneID, BATTLE_RunFrame); - func_801B1E0C(); + BattleInitLoadSceneData(sceneID, BATTLE_RunFrame); + BattleInitEnemyUnits(); g_BattleState.presentMask = 0; for (i = 0; i < 10; i++) { - func_800AE954(i); + BattleRecalcUnitSpeed(i); c = &g_BattleState.combatant[i]; if (c->unk8 != -1) { g_BattleState.presentMask |= 1 << i; @@ -44,13 +44,13 @@ void func_801B0490(s32 sceneID) { } g_BattleState.sceneID = sceneID; D_800F83A8 = D_80163624.unk2; - func_801B19AC(); - func_800A4540(); - func_801B2308(); - func_800A4540(); + BattleInitFormation(); + BattleUpdateUnitMasks(); + BattleInitEnemyAI(); + BattleUpdateUnitMasks(); for (i = 4; i < 10; i++) { D_800F5BBC[i][0] = ((u8)SysGetRandomByteRange(0x40) + 0x80) << 8; - func_800B108C(i); + BattleInitUnitAction(i); } } @@ -157,7 +157,7 @@ s32 func_801B1734(s32 slot); // Seeds the three live party slots from the save data: finds each slot's // party member record, copies HP/MP and the derived battle stats across, then // applies the equipped accessory, the command list and the row/limit setup. -void func_801B0F08(void) { +void BattleInitPartyFromSavemap(void) { Unk800F5E60* party; ActiveCharacterData* rec; Unk800F83E0* c; @@ -201,7 +201,7 @@ void func_801B0F08(void) { func_801B11BC(i); func_800A4BA4(i); if (func_801B1734(i) == 0) { - func_800B108C(i); + BattleInitUnitAction(i); } break; } @@ -430,7 +430,7 @@ const s32 D_801B001C[] = {0x0000, 0x1000, 0x0008, 0x0800}; const s32 D_801B002C[] = {0x0000, 0x000A, 0x0027, 0x000A}; extern u8 D_800F9DA0; // pending battle-start status flags, one bit per entry // of D_801B001C / D_801B002C (bit 4 = full-heal) -void func_800A7254(s32, s32, s32, s32); +void BattleQueueEvent(s32, s32, s32, s32); // Applies the pending battle-start effects in D_800F9DA0 to party member // `slot`: bit 4 restores half its max HP, bits 0-3 inflict the matching status @@ -452,12 +452,12 @@ s32 func_801B1734(s32 slot) { if (g_BattleState.combatant[slot].curHP > g_BattleState.combatant[slot].maxHP) { g_BattleState.combatant[slot].curHP = g_BattleState.combatant[slot].maxHP; } - func_800A7254(2, slot, 0x17, 0); + BattleQueueEvent(2, slot, 0x17, 0); } for (i = 0; i < 4; i++) { if ((D_800F9DA0 >> i) & 1) { g_BattleState.combatant[slot].status |= D_801B001C[i] & ~mask; - func_800A7254(2, slot, 0x17, D_801B002C[i]); + BattleQueueEvent(2, slot, 0x17, D_801B002C[i]); ret = 1; } } @@ -499,7 +499,7 @@ void func_800B1060(s32); // start "turned around" (bit 0x80 of unk4) -- back attacks, side attacks and // pincers each split the party differently. Finally the front/back row bit is // re-derived for the three party slots. -void func_801B19AC(void) { +void BattleInitFormation(void) { u16 row[3]; s32 enemyMask; s32 partyMask; @@ -654,9 +654,9 @@ void func_801B1CB0(void) { D_80166F74 = rows; } -INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1E0C); +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitEnemyUnits); -void func_801B2308(void) { +void BattleInitEnemyAI(void) { s32 i; for (i = 0; i < 6; i++) { @@ -672,7 +672,7 @@ void func_801B2308(void) { } static const s8 D_801B0044[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x05, 0x6E, 0x64, 0x62}; -static void func_801B23E0(s32 sceneID, void (*cb)(void)) { +static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { u8 dummy[0x100]; SceneContainer scene; s32 chunkID; diff --git a/src/battle/battle.c b/src/battle/battle.c index fb8df203..49ea7667 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -53,7 +53,7 @@ void BATTLE_SetFocusedActor(s32 arg0) { if (i == 64) { g_CombatantTurnState[D_800E7A38].unk2A++; func_800A56B0(*(s16*)&D_800E7A38); - func_800A7254(0, D_800E7A38, 0, 0); + BattleQueueEvent(0, D_800E7A38, 0, 0); } } D_800E7A38 = arg0; @@ -260,7 +260,7 @@ void func_800A329C(void) { } } -void func_800A7254(s32, s32, s32, s32); +void BattleQueueEvent(s32, s32, s32, s32); s32 func_800A37F8(s32); static void func_800A32C0(s32 arg0) { @@ -273,10 +273,10 @@ static void func_800A32C0(s32 arg0) { if (D_800F5F44.D_800F6B9A != D_800F5F44.D_800F6BA1) { var_a3 = 3; } - func_800A7254(0, 0, 7, var_a3); + BattleQueueEvent(0, 0, 7, var_a3); } } else if (func_800A37F8(-1) != 0) { - func_800A7254(0, 0, 7, 0); + BattleQueueEvent(0, 0, 7, 0); } } } @@ -482,7 +482,7 @@ s32 func_800A44D8(s32 arg0) { return arg0; } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4540); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", BattleUpdateUnitMasks); void func_800A4844(s32 arg0) { s32 var_v0 = arg0 ? 3 : 1; @@ -497,7 +497,7 @@ s32 BATTLE_RunToResultScreen(void) { D_800F39EC = 0; g_BattleState.setupFlags |= 2; for (i = 0; i < 3; i++) { - func_800A7254(0, i, 4, 0); + BattleQueueEvent(0, i, 4, 0); } for (i = 0; i < 4; i++) { BATTLE_RunFrame(); @@ -522,7 +522,7 @@ s32 BATTLE_RunEscapeSequence(void) { D_800F39EC = 0; g_BattleState.setupFlags |= 2; for (i = 0; i < 3; i++) { - func_800A7254(0, i, 4, 0); + BattleQueueEvent(0, i, 4, 0); } for (i = 0; i < 4; i++) { BATTLE_RunFrame(); @@ -534,7 +534,7 @@ s32 BATTLE_RunEscapeSequence(void) { } g_BattleState.setupFlags &= ~2; for (i = 0; i < 3; i++) { - func_800A7254(0, i, 6, 0); + BattleQueueEvent(0, i, 6, 0); } if (D_800F39EC & 2) { ret = 1; @@ -776,7 +776,7 @@ s32 BATTLE_PickRandomThrowItem(void) { if (n != 0) { pick = list[SysGetRandomByteRange(n)]; if (pick >= 0x80 && pick < 0x100) { - func_800A7254(0, 0, 0x10, pick); + BattleQueueEvent(0, 0, 0x10, pick); ret = pick; } } @@ -1018,7 +1018,7 @@ void func_800A6C04(s32 arg0) { } void func_800A6C5C(s32 arg0, s32 arg1) { - func_800A7254(2, arg0, 0x14, arg1); + BattleQueueEvent(2, arg0, 0x14, arg1); *(u16*)((u8*)&g_BattleState.combatant[arg0].unk44 + 0xE) = arg1; } @@ -1055,12 +1055,12 @@ void func_800A6E0C(s32 arg0) { if (arg0 < 3) { D_800F5E60[arg0].limitBarUI = 0; D_800F5E60[arg0].limitBar = 0; - func_800A7254(0, arg0, 1, 0); + BattleQueueEvent(0, arg0, 1, 0); } } -void func_800A7254(s32, s32, s32, s32); -void func_800A6E6C(s32 arg0, s32 arg1) { func_800A7254(0, arg0, 13, arg1); } +void BattleQueueEvent(s32, s32, s32, s32); +void func_800A6E6C(s32 arg0, s32 arg1) { BattleQueueEvent(0, arg0, 13, arg1); } INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6E9C); @@ -1070,7 +1070,7 @@ void func_800A7034(s32 arg0, s16 arg1) { func_800B0FFC(arg0, 0x53, 1, &out); } -void func_800A7060(s32 arg0, s32 arg1) { func_800A7254(0, arg0, 12, arg1); } +void func_800A7060(s32 arg0, s32 arg1) { BattleQueueEvent(0, arg0, 12, arg1); } void func_800A7090(s32 arg0) { g_CombatantTurnState[arg0].unk29 |= 0x40; } @@ -1097,7 +1097,7 @@ void func_800A71F4(void) { } } -void func_800A7254(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { +void BattleQueueEvent(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { s32* base; s32* temp_s0; s32 temp_t0; @@ -1206,7 +1206,7 @@ void BATTLE_ResolveLimitActionIndex(void) { *(u16*)((u8*)D_800F5E60 + off + 8) = 0; // ideally D_800F5E60[actorId].limitBar = 0; D_800F5E60[actorId].limitCount++; if (!(g_BattleState.setupFlags & 8)) { - func_800A7254(2, actorId, 0x11, 0); + BattleQueueEvent(2, actorId, 0x11, 0); } } } @@ -1554,7 +1554,7 @@ void BATTLE_LearnEnemySkill(void) { *flags = mask | bit; id = (u16)g_CurrentAction->absoluteActionIndex; func_800B0FFC(g_CurrentAction->unk208, 0x73, 1, &id); - func_800A7254(2, g_CurrentAction->unk208, 0x12, id); + BattleQueueEvent(2, g_CurrentAction->unk208, 0x12, id); g_CurrentAction->unk224 = 0xA; } } @@ -2306,8 +2306,8 @@ void func_800AE764(s32 mask, s32 arg1, s32 arg2) { INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE82C); -void func_800AE954(int index); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE954); +void BattleRecalcUnitSpeed(int index); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", BattleRecalcUnitSpeed); const u8 D_800A04BC[] = {0x1E, 0x14, 0x3C, 0x1E, 0x7F, 0x7F, 0x0A, 0x64, 0x7F, 0x7F, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x0D, 0x00, 0x00}; @@ -2339,7 +2339,7 @@ int (* const D_800A04E0[])() = { }; // ___end -void func_800B108C(s32 arg0); +void BattleInitUnitAction(s32 arg0); void func_800AEB80(s32 arg0, s32 arg1, s32 arg2) { s32 index; @@ -2350,12 +2350,12 @@ void func_800AEB80(s32 arg0, s32 arg1, s32 arg2) { p = (u8*)&g_CombatantTurnState[arg0].unk10; p[index] = 0; if ((0xD8B >> index) & 1) { - func_800B108C(arg0); + BattleInitUnitAction(arg0); } } } -void func_800AEBF0(int index) { func_800AE954(index); } +void func_800AEBF0(int index) { BattleRecalcUnitSpeed(index); } INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEC10); @@ -2363,7 +2363,7 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEF68); void func_800AF0C4(s32 arg0, s32 arg1, s32 arg2) { if (!(g_BattleState.combatant[arg0].status & 0x2804444)) { - func_800A7254(0, arg0, 6, 0); + BattleQueueEvent(0, arg0, 6, 0); } if (!(g_BattleState.combatant[arg0].status & 0x2004404)) { if ((D_800F5F44.D_800F7DC2 >> arg0) & 1) { @@ -2375,15 +2375,15 @@ void func_800AF0C4(s32 arg0, s32 arg1, s32 arg2) { } } -void func_800A7254(s32, s32, s32, s32); -void func_800AF1A8(s32 arg0) { func_800A7254(0, arg0, 8, 0); } +void BattleQueueEvent(s32, s32, s32, s32); +void func_800AF1A8(s32 arg0) { BattleQueueEvent(0, arg0, 8, 0); } void func_800AF0C4(s32, s32, s32); // skips (does nothing) while combatant[arg0].status has Berserk or Confusion void BATTLE_TryApplyHitEffect(s32 arg0, s32 arg1, s32 arg2) { if (!(g_BattleState.combatant[arg0].status & (STATUS_BERSERK | STATUS_CONFU))) { - func_800A7254(0, arg0, 9, 0); + BattleQueueEvent(0, arg0, 9, 0); func_800AF0C4(arg0, arg1, arg2); } } @@ -2393,7 +2393,7 @@ void func_800AF264(s32 arg0, s32 arg1, s32 arg2) { func_800AEBF0(arg0); func_800AEB20(arg0, arg1, arg2); - func_800A7254(0, arg0, 4, 0); + BattleQueueEvent(0, arg0, 4, 0); status = g_BattleState.combatant[arg0].status & 0xFFBFFFFF; g_BattleState.combatant[arg0].status = status; @@ -2409,7 +2409,7 @@ void func_800AF320(s32 arg0, s32 arg1, s32 arg2) { func_800AF0C4(arg0, arg1, arg2); } -void func_800AF380(s32 arg0) { func_800A7254(2, arg0, 0x15, 0xF); } +void func_800AF380(s32 arg0) { BattleQueueEvent(2, arg0, 0x15, 0xF); } void BATTLE_ApplyRegenPoisonTick(s32 arg0, s32 arg1, s32 arg2) { s32 amount; @@ -2445,7 +2445,7 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF494); void BATTLE_ClearActorSlotReferences(s32 arg0, s32 arg1, s32 arg2) { s32 i; - func_800A7254(0, arg0, 0xA, arg2); + BattleQueueEvent(0, arg0, 0xA, arg2); if (arg2 != 0) { func_800A23BC(arg0); return; @@ -2453,14 +2453,14 @@ void BATTLE_ClearActorSlotReferences(s32 arg0, s32 arg1, s32 arg2) { for (i = 0; i < LEN(D_800F5E60); i++) { if (D_800F5E60[i].unk6 == arg0) { D_800F5E60[i].unk6 = 0; - func_800A7254(0, i, 6, 0); + BattleQueueEvent(0, i, 6, 0); } } - func_800B108C(arg0); + BattleInitUnitAction(arg0); } -void func_800B108C(s32 arg0); -void func_800AF63C(s32 arg0) { func_800B108C(arg0); } +void BattleInitUnitAction(s32 arg0); +void func_800AF63C(s32 arg0) { BattleInitUnitAction(arg0); } INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF65C); @@ -2576,7 +2576,7 @@ void func_800B0FFC(s32 arg0, s32 arg1, s32 arg2, s16* arg3) { void func_800B1060(s32 arg0) { func_800A31A0(10, 2, 1, arg0); } -void func_800B108C(s32 arg0) { func_800A31A0(arg0, 5, 0, 0); } +void BattleInitUnitAction(s32 arg0) { func_800A31A0(arg0, 5, 0, 0); } // true when the combatant's HP is at or below a quarter of max -- the "Near // Death" threshold used by weapon-specific damage formulas (e.g. Powersoul's From 629f95d67e7fd349a938d9d1dbca6f9efaed3783 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 21:21:07 -0500 Subject: [PATCH 05/18] isMultiBattle --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 1 + config/symbols.battle.txt | 1 + src/battle/batini.c | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 3c96222d..2da8eae1 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1307,7 +1307,7 @@ D_80163762 = 0x80163762; D_80163766 = 0x80163766; D_80163768 = 0x80163768; D_8016376A = 0x8016376a; -D_8016376C = 0x8016376c; +g_IsMutiBattle = 0x8016376c; D_8016376E = 0x8016376e; D_80163770 = 0x80163770; D_80163772 = 0x80163772; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index dde3121e..1881d342 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -6,3 +6,4 @@ BattleInitFormation = 0x801B19AC; BattleInitEnemyUnits = 0x801B1E0C; BattleInitEnemyAI = 0x801B2308; BattleInitLoadSceneData = 0x801B23E0; + diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 2a314cec..410d70f0 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -76,3 +76,4 @@ D_8016360C = 0x8016360C; // size:0xAC D_801636B8 = 0x801636B8; // size:0xA0 D_80163798 = 0x80163798; // size:0x300 D_80163C80 = 0x80163C80; // size:0xC +g_IsMutiBattle = 0x8016376C; diff --git a/src/battle/batini.c b/src/battle/batini.c index acfcc8eb..7a9f1ace 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -2,7 +2,7 @@ #include "unzip.h" extern Unk801B2308 D_80163624; -extern u16 D_8016376C; +extern u16 g_IsMutiBattle; void BATTLE_RunFrame(void); // battle callback for batini, move to battle.h void BattleInitEnemyAI(void); @@ -16,7 +16,7 @@ void BattleInitSetup(s32 sceneID) { s32 var_s1; var_s1 = 4; - if (D_8016376C) { + if (g_IsMutiBattle) { var_s1 = 0; BattleQueueEvent(0, 0, 15, 0); BattleQueueEvent(0, 0, 14, 0); @@ -29,7 +29,7 @@ void BattleInitSetup(s32 sceneID) { for (i = 0; i < 3; i++) { D_800F5E60[i].unk6 = 0; } - if (D_8016376C) { + if (g_IsMutiBattle) { BattleInitPartyFromSavemap(); } BattleInitLoadSceneData(sceneID, BATTLE_RunFrame); From 223fe4d7455d54220aabf7d9f529a2b4c85a5397 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 22:17:40 -0500 Subject: [PATCH 06/18] BattleInitATBTimers --- config/sym_ovl_export.us.txt | 6 +++--- config/symbols.batini.txt | 1 + config/symbols.battle.txt | 3 +++ src/battle/batini.c | 24 ++++++++++++------------ src/battle/battle.c | 10 +++++----- src/battle/battle.h | 2 +- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 2da8eae1..eda127d2 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1,6 +1,6 @@ BattleInitMain = 0x801b0050; BattleInitSetup = 0x801b0490; -func_801B0668 = 0x801b0668; +BattleInitATBTimers = 0x801b0668; func_801B085C = 0x801b085c; func_801B08C0 = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; @@ -308,7 +308,7 @@ func_800B2C60 = 0x800b2c60; func_800B2CFC = 0x800b2cfc; BATTLE_GetAttackData = 0x800b2ebc; func_800B2F30 = 0x800b2f30; -func_800B2F50 = 0x800b2f50; +BattleGetRndU16 = 0x800b2f50; func_800B3030 = 0x800b3030; func_800B30E4 = 0x800b30e4; func_800B33A4 = 0x800b33a4; @@ -1300,7 +1300,7 @@ D_80163608 = 0x80163608; D_8016360C = 0x8016360c; D_801636B8 = 0x801636b8; D_80163758 = 0x80163758; -D_8016375A = 0x8016375a; +g_BattleUnitPresentMask = 0x8016375a; D_8016375C = 0x8016375c; D_8016375E = 0x8016375e; D_80163762 = 0x80163762; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 1881d342..b08bd178 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -6,4 +6,5 @@ BattleInitFormation = 0x801B19AC; BattleInitEnemyUnits = 0x801B1E0C; BattleInitEnemyAI = 0x801B2308; BattleInitLoadSceneData = 0x801B23E0; +BattleInitATBTimers = 0x801B0668; diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 410d70f0..84efb7bc 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -77,3 +77,6 @@ D_801636B8 = 0x801636B8; // size:0xA0 D_80163798 = 0x80163798; // size:0x300 D_80163C80 = 0x80163C80; // size:0xC g_IsMutiBattle = 0x8016376C; + +BattleGetRndU16 = 0x800B2F50; +g_BattleUnitPresentMask = 0x8016375A; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 7a9f1ace..b56a13f5 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -54,15 +54,15 @@ void BattleInitSetup(s32 sceneID) { } } -extern u16 D_8016375A; +extern u16 g_BattleUnitPresentMask; extern u16 D_8009D864[][0x220]; // stride 0x440, one per Unk8009D84C record -u16 func_800B2F50(void); // random, 16-bit +u16 BattleGetRndU16(void); // random, 16-bit // Rolls the initial ATB timer of every present combatant and writes it into -// D_800F5BBC. The battle type (D_800F7DC8) then biases those timers: a +// D_800F5BBC. The battle type (battleType) then biases those timers: a // preemptive-style opening zeroes the party's, an ambush pushes it towards the // enemies, and a Battle Square opening (setup flag 8) overrides both. -void func_801B0668(void) { +void BattleInitATBTimers(void) { s32 timer[10]; s32 presentMask; s32 max; @@ -70,13 +70,13 @@ void func_801B0668(void) { s32 t; s32 i; - presentMask = D_8016375A; + presentMask = g_BattleUnitPresentMask; max = 0; for (i = 0; i < 10; i++) { D_800F5BBC[i][0] = 0; val = 0; if ((presentMask >> i) & 1) { - val = func_800B2F50() >> 1; + val = BattleGetRndU16() >> 1; if (max < val) { max = val; } @@ -85,7 +85,7 @@ void func_801B0668(void) { } for (i = 0; i < 10; i++) { if ((presentMask >> i) & 1) { - switch (D_800F5F44.D_800F7DC8) { + switch (D_800F5F44.battleType) { case 0: case 5: t = timer[i] + 0xE000; @@ -515,7 +515,7 @@ void BattleInitFormation(void) { if (D_8016360C.setup.type == SETUP_SIDE_ATTACK_3) { sideMask = ~5; } - intro = D_801B003C[D_800F5F44.D_800F7DC8]; + intro = D_801B003C[D_800F5F44.battleType]; if (intro != 0xFF && g_BattleState.sceneID != 0x3D6) { func_800B1060(intro); } @@ -523,7 +523,7 @@ void BattleInitFormation(void) { row[0] = 0; row[1] = 0; row[2] = 0; - switch (D_800F5F44.D_800F7DC8) { + switch (D_800F5F44.battleType) { case 0: mask = enemyMask; /* fallthrough */ @@ -572,7 +572,7 @@ void BattleInitFormation(void) { for (i = 0; i < 3; i++) { back = g_BattleState.combatant[i].unk4 >> 6; back &= 1; - switch (D_800F5F44.D_800F7DC8) { + switch (D_800F5F44.battleType) { case 0: case 1: break; @@ -716,7 +716,7 @@ static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { D_8016360C.setup.type = SETUP_PREEMPTIVE; } } - D_800F5F44.D_800F7DC8 = (u8)D_801B0044[D_8016360C.setup.type]; + D_800F5F44.battleType = (u8)D_801B0044[D_8016360C.setup.type]; if (D_8016376A & EVENT_BATTLE_SQUARE) { D_8016360C.setup.stageID = 37; D_8016360C.setup.flags |= SETUP_CANNOT_ESCAPE; @@ -735,7 +735,7 @@ static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { D_8016376A |= 8; } D_800F5F44.D_800F7DB2 = D_8016360C.setup.escapeCounter; - if (D_800F5F44.D_800F7DC8 == 1 || D_800F5F44.D_800F7DC8 == 3) { + if (D_800F5F44.battleType == 1 || D_800F5F44.battleType == 3) { D_800F5F44.D_800F7DB2 = 1; } D_800F5F44.D_800F7DB6 = D_800F5F44.D_800F7DB2; diff --git a/src/battle/battle.c b/src/battle/battle.c index 49ea7667..97085f00 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -2654,13 +2654,13 @@ void func_800B1268(s32 arg0, s32 arg1, s32 arg2) { } } -// nonzero if D_800F5F44.D_800F7DC8 is < 3 +// nonzero if D_800F5F44.battleType is < 3 static u32 func_800B12DC(void) { u32 result = 0; - s32 cmp = (s32)D_800F5F44.D_800F7DC8; + s32 cmp = (s32)D_800F5F44.battleType; if (cmp < 3) { - result = (u32)~D_800F5F44.D_800F7DC8 >> 0x1F; + result = (u32)~D_800F5F44.battleType >> 0x1F; } return result; } @@ -2910,10 +2910,10 @@ AttackData* BATTLE_GetAttackData(s32 id) { u8 func_800B2F30(void) { return SysGetRandomByteFromTable(); } -u16 func_800B2F50(void) { return SysRandomTwoBytes(); } +u16 BattleGetRndU16(void) { return SysRandomTwoBytes(); } // scale a 16-bit value into the range 1..100 -static s32 func_800B2F70(void) { return (((func_800B2F50() & 0xFFFF) * 0x63) / 0xFFFF) + 1; } +static s32 func_800B2F70(void) { return (((BattleGetRndU16() & 0xFFFF) * 0x63) / 0xFFFF) + 1; } static s32 func_800B2FC4(s32 arg0) { return (arg0 * (func_800B2F30() + 0xF01)) >> 12; } diff --git a/src/battle/battle.h b/src/battle/battle.h index 42101e8a..a144ef03 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -279,7 +279,7 @@ typedef struct { /* 0x1E7E */ u16 D_800F7DC2; /* 0x1E80 */ u16 D_800F7DC4; /* 0x1E72 */ u16 D_800F7DC6; - /* 0x1E84 */ u16 D_800F7DC8; + /* 0x1E84 */ u16 battleType; /* 0x1E84 */ u16 D_800F7DCA; /* 0x1E88 */ u8 unk1E88[0x12]; /* 0x1E9A */ s16 D_800F7DDE; From ff77f7d4d35df1f0d044c1d70d803eceae57119e Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 22:32:36 -0500 Subject: [PATCH 07/18] BattleInitSetSpeed --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 1 + src/battle/batini.c | 10 +++++----- src/battle/battle.c | 2 +- src/battle/battle.h | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index eda127d2..98dd42b5 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -1,7 +1,7 @@ BattleInitMain = 0x801b0050; BattleInitSetup = 0x801b0490; BattleInitATBTimers = 0x801b0668; -func_801B085C = 0x801b085c; +BattleInitSetSpeed = 0x801b085c; func_801B08C0 = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; func_801B1120 = 0x801b1120; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index b08bd178..5161e2a2 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -8,3 +8,4 @@ BattleInitEnemyAI = 0x801B2308; BattleInitLoadSceneData = 0x801B23E0; BattleInitATBTimers = 0x801B0668; +BattleInitSetSpeed = 0x801B085C; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index b56a13f5..67f8cac4 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -86,13 +86,13 @@ void BattleInitATBTimers(void) { for (i = 0; i < 10; i++) { if ((presentMask >> i) & 1) { switch (D_800F5F44.battleType) { - case 0: - case 5: + case SETUP_DEFAULT: + case SETUP_PINCER_2: t = timer[i] + 0xE000; timer[i] = t - max; break; - case 2: - case 4: + case SETUP_BACK_ATTACK: + case SETUP_PINCER: if (i < 4) { timer[i] = 0; } else { @@ -123,7 +123,7 @@ void BattleInitATBTimers(void) { } } -void func_801B085C(s32 arg0) { D_800F5F44.D_800F7DA6 = 0x10000 / ((arg0 * 480 / 256 + 0x78) * 2); } +void BattleInitSetSpeed(s32 speed) { D_800F5F44.battleSpeed = 0x10000 / ((speed * 480 / 256 + 0x78) * 2); } INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B08C0); diff --git a/src/battle/battle.c b/src/battle/battle.c index 97085f00..19ebf3e1 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -356,7 +356,7 @@ s32 func_800A37F8(s32 arg0) { s32 func_800A3828(void) { s32 ret = 0; if (D_800F39E0 == 3) { - D_800F39E4 += D_800F5F44.D_800F7DA6; + D_800F39E4 += D_800F5F44.battleSpeed; } if (D_800F5F44.D_800F7DAA == 2) { switch (D_800F3896) { diff --git a/src/battle/battle.h b/src/battle/battle.h index a144ef03..83fcbcff 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -262,7 +262,7 @@ typedef struct { /* 0x0C60 */ Unk800F5F44_5 _5; /* 0x0E60 */ u8 script[0x1000]; /* 0x1E60 */ u16 D_800F7DA4; - /* 0x1E62 */ u16 D_800F7DA6; + /* 0x1E62 */ u16 battleSpeed; /* 0x1E64 */ u16 D_800F7DA8; /* 0x1E66 */ u16 D_800F7DAA; /* 0x1E68 */ u16 D_800F7DAC; From 64937653515149c5b5de0a01d373d395307a5e11 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 22:40:02 -0500 Subject: [PATCH 08/18] BattleInitPlayer --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 3 ++- src/battle/batini.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 98dd42b5..8fffd5bd 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -2,7 +2,7 @@ BattleInitMain = 0x801b0050; BattleInitSetup = 0x801b0490; BattleInitATBTimers = 0x801b0668; BattleInitSetSpeed = 0x801b085c; -func_801B08C0 = 0x801b08c0; +BattleInitPlayer = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; func_801B1120 = 0x801b1120; func_801B11BC = 0x801b11bc; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 5161e2a2..4b6ae194 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -8,4 +8,5 @@ BattleInitEnemyAI = 0x801B2308; BattleInitLoadSceneData = 0x801B23E0; BattleInitATBTimers = 0x801B0668; -BattleInitSetSpeed = 0x801B085C; \ No newline at end of file +BattleInitSetSpeed = 0x801B085C; +BattleInitPlayer = 0x801B08C0; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 67f8cac4..a1efbdf1 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -125,7 +125,7 @@ void BattleInitATBTimers(void) { void BattleInitSetSpeed(s32 speed) { D_800F5F44.battleSpeed = 0x10000 / ((speed * 480 / 256 + 0x78) * 2); } -INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B08C0); +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitPlayer); // The per-party work area at 0x800F5BB8: the turn state, the three party // records (D_800F5E60) and their setup config (D_800F5EFC) are one object, so From ee33e5310d6b369c47a849429a5289ca5c15a82b Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 22:57:12 -0500 Subject: [PATCH 09/18] BattleUnitAttackSetup --- src/battle/batini.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/battle/batini.c b/src/battle/batini.c index a1efbdf1..0d6090de 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -131,20 +131,27 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitPlayer); // records (D_800F5E60) and their setup config (D_800F5EFC) are one object, so // BATINI reaches all three off a single base. typedef struct { - /* 0x00 */ u8 unk0; - /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; - /* 0x03 */ u8 unk3; - /* 0x04 */ u8 unk4[0xA]; - /* 0x0E */ u16 unkE; - /* 0x10 */ u8 unk10[4]; - /* 0x14 */ s32 unk14; -} Unk800F5EFC; // size:0x18 + /* 0x00 */ u8 targetFlags; + /* 0x01 */ u8 attackEffectId; + /* 0x02 */ u8 damageFormulaId; + /* 0x03 */ u8 hitChance; + /* 0x04 */ u8 impactEffectId; + /* 0x05 */ u8 criticalHitChance; + /* 0x06 */ u8 unk06; + /* 0x07 */ u8 unk07; + /* 0x08 */ u16 normalAttackSound; + /* 0x0A */ u16 criticalAttackSound; + /* 0x0C */ u16 missAttackSound; + /* 0x0E */ u16 attackElement; + /* 0x10 */ u16 cameraMovementId; + /* 0x12 */ u16 specialAttackFlags; + /* 0x14 */ s32 attackStatusMask; +} BattleUnitAttackSetup; // size:0x18 typedef struct { /* 0x000 */ Unk800AF470 turn[10]; /* 0x2A8 */ Unk800F5E60 party[3]; - /* 0x344 */ Unk800F5EFC setup[3]; + /* 0x344 */ BattleUnitAttackSetup setup[3]; } BattleWork; // size:0x38C extern BattleWork g_CombatantTurnState; @@ -162,7 +169,7 @@ void BattleInitPartyFromSavemap(void) { ActiveCharacterData* rec; Unk800F83E0* c; Unk800AF470* t; - Unk800F5EFC* setup; + BattleUnitAttackSetup* setup; SavePartyMember* m; s32 id; s32 i; @@ -186,15 +193,15 @@ void BattleInitPartyFromSavemap(void) { t->unk3E = c->unk28; func_801B18F8(rec, party, c); t->unk34 = rec->immuneStatuses; - setup->unkE = rec->weapon.attackElement | rec->physicalAttackElements; - setup->unk14 = rec->physicalAttackStatuses; - setup->unk3 = rec->weapon.attackPercent; - setup->unk0 = rec->weapon.targetFlags; + setup->attackElement = rec->weapon.attackElement | rec->physicalAttackElements; + setup->attackStatusMask = rec->physicalAttackStatuses; + setup->hitChance = rec->weapon.attackPercent; + setup->targetFlags = rec->weapon.targetFlags; t->unk29 &= 0xFD; if (rec->characterFlags & 4) { - setup->unk0 &= 0xDF; + setup->targetFlags &= 0xDF; } - if (!(setup->unk0 & 0x20)) { + if (!(setup->targetFlags & 0x20)) { t->unk29 |= 2; } func_801B1598(i, m->accessory); From d60201c870f4b4c86f6514e4778e692c7f24c12d Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 23:19:58 -0500 Subject: [PATCH 10/18] BattlePartyWork --- config/sym_ovl_export.us.txt | 14 +++++++++++++- config/symbols.batini.txt | 2 +- config/symbols.battle.txt | 6 ++++-- src/battle/batini.c | 28 ++++++++++++++-------------- src/battle/batres.c | 6 +++--- src/battle/battle.c | 32 ++++++++++++++++---------------- src/battle/battle.h | 17 +++++++---------- 7 files changed, 58 insertions(+), 47 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 8fffd5bd..25e66bd4 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -890,7 +890,19 @@ D_800F5B73 = 0x800f5b73; D_800F5B74 = 0x800f5b74; g_CombatantTurnState = 0x800f5bb8; D_800F5C84 = 0x800f5c84; -D_800F5E60 = 0x800f5e60; +g_BattlePartyWork = 0x800f5e60; +D_800F5E64 = 0x800f5e64; +D_800F5E65 = 0x800f5e65; +D_800F5E66 = 0x800f5e66; +D_800F5E67 = 0x800f5e67; +D_800F5E68 = 0x800f5e68; +D_800F5E6A = 0x800f5e6a; +D_800F5E6C = 0x800f5e6c; +D_800F5E70 = 0x800f5e70; +D_800F5E72 = 0x800f5e72; +D_800F5E74 = 0x800f5e74; +D_800F5E76 = 0x800f5e76; +D_800F5E78 = 0x800f5e78; D_800F5EFC = 0x800f5efc; D_800F5F01 = 0x800f5f01; D_800F5F44 = 0x800f5f44; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 4b6ae194..151fd257 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -9,4 +9,4 @@ BattleInitLoadSceneData = 0x801B23E0; BattleInitATBTimers = 0x801B0668; BattleInitSetSpeed = 0x801B085C; -BattleInitPlayer = 0x801B08C0; \ No newline at end of file +BattleInitPlayer = 0x801B08C0; diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 84efb7bc..2678e075 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -57,7 +57,6 @@ g_AtbBarPulseColor = 0x800F32C4; // size:0x2 g_AtbBarPulseValue = 0x800F32C6; // size:0x2 g_ActiveCharsHPMPInited = 0x800F32C8; // size:0x2 g_CombatantTurnState = 0x800F5BB8; // size:0xCC -D_800F5E60 = 0x800F5E60; // size:0x9C D_800F5F44 = 0x800F5F44; // size:0x1E88 g_dbIndex = 0x800F8368; g_BattleState = 0x800F83AC; // size:0x444 @@ -79,4 +78,7 @@ D_80163C80 = 0x80163C80; // size:0xC g_IsMutiBattle = 0x8016376C; BattleGetRndU16 = 0x800B2F50; -g_BattleUnitPresentMask = 0x8016375A; \ No newline at end of file +g_BattleUnitPresentMask = 0x8016375A; + + +g_BattlePartyWork = 0x800F5E60; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 0d6090de..6e0af4c2 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -27,7 +27,7 @@ void BattleInitSetup(s32 sceneID) { } } for (i = 0; i < 3; i++) { - D_800F5E60[i].unk6 = 0; + g_BattlePartyWork[i].unk6 = 0; } if (g_IsMutiBattle) { BattleInitPartyFromSavemap(); @@ -128,7 +128,7 @@ void BattleInitSetSpeed(s32 speed) { D_800F5F44.battleSpeed = 0x10000 / ((speed INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitPlayer); // The per-party work area at 0x800F5BB8: the turn state, the three party -// records (D_800F5E60) and their setup config (D_800F5EFC) are one object, so +// records (g_BattlePartyWork) and their setup config (D_800F5EFC) are one object, so // BATINI reaches all three off a single base. typedef struct { /* 0x00 */ u8 targetFlags; @@ -150,7 +150,7 @@ typedef struct { typedef struct { /* 0x000 */ Unk800AF470 turn[10]; - /* 0x2A8 */ Unk800F5E60 party[3]; + /* 0x2A8 */ BattlePartyWork party[3]; /* 0x344 */ BattleUnitAttackSetup setup[3]; } BattleWork; // size:0x38C @@ -165,7 +165,7 @@ s32 func_801B1734(s32 slot); // party member record, copies HP/MP and the derived battle stats across, then // applies the equipped accessory, the command list and the row/limit setup. void BattleInitPartyFromSavemap(void) { - Unk800F5E60* party; + BattlePartyWork* party; ActiveCharacterData* rec; Unk800F83E0* c; Unk800AF470* t; @@ -389,16 +389,16 @@ extern u8 D_80071C29[][0x10]; // accessory table, 0x10 stride // status is ORed into the combatant, its turn state and the party record. void func_801B1598(s32 slot, s32 accessory) { Unk800AF470* t; - Unk800F5E60* party; + BattlePartyWork* party; Unk800F83E0* c; u8 effect; t = &g_CombatantTurnState.turn[slot]; party = &g_CombatantTurnState.party[slot]; c = &g_BattleState.combatant[slot]; - c->status &= ~party->unk20; - t->unk34 &= ~party->unk20; - party->unk20 = 0; + c->status &= ~party->accessoryStatusMask; + t->unk34 &= ~party->accessoryStatusMask; + party->accessoryStatusMask = 0; t->unkD = 0xFF; if (accessory != 0xFF) { effect = D_80071C29[accessory][0]; @@ -407,27 +407,27 @@ void func_801B1598(s32 slot, s32 accessory) { case 0: c->status |= STATUS_HASTE; t->unk34 |= STATUS_HASTE; - party->unk20 |= STATUS_HASTE; + party->accessoryStatusMask |= STATUS_HASTE; break; case 1: c->status |= STATUS_BERSERK; t->unk34 |= STATUS_BERSERK; - party->unk20 |= STATUS_BERSERK; + party->accessoryStatusMask |= STATUS_BERSERK; break; case 2: c->status |= STATUS_D_SENTENCE; t->unk34 |= STATUS_D_SENTENCE; - party->unk20 |= STATUS_D_SENTENCE; + party->accessoryStatusMask |= STATUS_D_SENTENCE; t->unk12 = 0xFF; break; case 3: c->status |= STATUS_REFLECT; t->unk34 |= STATUS_REFLECT; - party->unk20 |= STATUS_REFLECT; + party->accessoryStatusMask |= STATUS_REFLECT; break; case 6: c->status |= STATUS_BARRIER | STATUS_M_BARRIER; - party->unk20 |= STATUS_BARRIER | STATUS_M_BARRIER; + party->accessoryStatusMask |= STATUS_BARRIER | STATUS_M_BARRIER; break; } } @@ -471,7 +471,7 @@ s32 func_801B1734(s32 slot) { return ret; } -void func_801B18F8(ActiveCharacterData* arg0, Unk800F5E60* arg1, Unk800F83E0* arg2) { +void func_801B18F8(ActiveCharacterData* arg0, BattlePartyWork* arg1, Unk800F83E0* arg2) { arg2->unk14 = arg0->dexterity; arg2->unk15 = arg0->luck; arg2->maxHP = arg0->baseHp; diff --git a/src/battle/batres.c b/src/battle/batres.c index 1f42ce11..ebfb319b 100644 --- a/src/battle/batres.c +++ b/src/battle/batres.c @@ -31,7 +31,7 @@ typedef struct { /* 0x00 */ u8 unk0[8]; /* 0x08 */ u16 limitCharge; /* 0x0A */ u8 unkA[0x2A]; -} Unk800F5E60; // size:0x34 +} BattlePartyWork; // size:0x34 extern u8 D_80082268[]; extern u8 D_80082460[3][12]; // one 12-entry roll table per gauge kind @@ -43,7 +43,7 @@ extern u8 D_8009D7ED[][12]; extern s16 D_8009D7EE[][6]; // same 12-byte record as D_8009D7ED extern SavePartyMember D_8009C738[]; extern u8 D_8009D58A[]; // gil, stored unaligned, so it is copied a byte at a time -extern Unk800F5E60 D_800F5E60[3]; +extern BattlePartyWork g_BattlePartyWork[3]; extern u16 D_800F7DD2; extern u8 D_80163790[]; // the char_id occupying each of the three party slots extern SavePartyMember D_80167938; @@ -90,7 +90,7 @@ void CommitBattleResults(s32 hpOverride, s32 mpOverride) { if (id == c->char_id) { c->hp_cur = hp; c->mp_cur = mp; - c->limit_charge = D_800F5E60[slot].limitCharge; + c->limit_charge = g_BattlePartyWork[slot].limitCharge; c->status_flags = g_BattleState.combatant[slot].status & 0x30; if (g_BattleState.setupFlags & 0x10) { if (c->char_id == 0) { diff --git a/src/battle/battle.c b/src/battle/battle.c index 19ebf3e1..82146856 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -461,7 +461,7 @@ void func_800A4480(void) { } // Manipulate redirect: if arg0 (an enemy id) is currently manipulated -// (D_800F7DCA bit), return the party slot whose D_800F5E60[].unk6 is +// (D_800F7DCA bit), return the party slot whose g_BattlePartyWork[].unk6 is // tracking it in place of arg0; otherwise arg0 passes through unchanged. s32 func_800A44D8(s32 arg0) { s32 i; @@ -472,8 +472,8 @@ s32 func_800A44D8(s32 arg0) { if (!((D_800F5F44.D_800F7DCA >> arg0) & 1)) { goto end; } - for (i = 0; i < LEN(D_800F5E60); i++) { - if (D_800F5E60[i].unk6 == arg0) { + for (i = 0; i < LEN(g_BattlePartyWork); i++) { + if (g_BattlePartyWork[i].unk6 == arg0) { arg0 = i; goto end; } @@ -593,7 +593,7 @@ s32 func_800A4CC8(s32 arg0) { s32 temp_v1; if (arg0 < 3) { - temp_v1 = D_800F5E60[arg0].unk6; + temp_v1 = g_BattlePartyWork[arg0].unk6; if ((temp_v1 >= 4) && ((D_800F5F44.D_800F7DCA >> temp_v1) & 1)) { arg0 = temp_v1; } @@ -1053,8 +1053,8 @@ void func_800A6E04(void) {} void func_800A6E0C(s32 arg0) { if (arg0 < 3) { - D_800F5E60[arg0].limitBarUI = 0; - D_800F5E60[arg0].limitBar = 0; + g_BattlePartyWork[arg0].limitBarUI = 0; + g_BattlePartyWork[arg0].limitBar = 0; BattleQueueEvent(0, arg0, 1, 0); } } @@ -1182,7 +1182,7 @@ void func_800A76CC(void) { void func_800A7784(void) {} -// actorId here is the live party slot (0-2, indexes D_800F5E60's 3-element +// actorId here is the live party slot (0-2, indexes g_BattlePartyWork's 3-element // gauge table below) -- NOT the per-character Limit-name block index. Each // of the 9 playable characters has a uniform 7-slot block in the shared // name table (relativeActionIndex 0x00=Cloud, 0x07=Barret, 0x0E=Aerith, @@ -1203,8 +1203,8 @@ void BATTLE_ResolveLimitActionIndex(void) { if (relativeActionIndex < 0x60) { s32 off = actorId * 0x34; g_CurrentAction->absoluteActionIndex = relativeActionIndex + 0x80; - *(u16*)((u8*)D_800F5E60 + off + 8) = 0; // ideally D_800F5E60[actorId].limitBar = 0; - D_800F5E60[actorId].limitCount++; + *(u16*)((u8*)g_BattlePartyWork + off + 8) = 0; // ideally g_BattlePartyWork[actorId].limitBar = 0; + g_BattlePartyWork[actorId].limitCount++; if (!(g_BattleState.setupFlags & 8)) { BattleQueueEvent(2, actorId, 0x11, 0); } @@ -1707,8 +1707,8 @@ void func_800ABB0C(s32 arg0, s32 arg1) { // clamp the computed damage to this target's HP or MP cap if (arg1 < 3) { - cap = D_800F5E60[arg1].capHP; - capMP = D_800F5E60[arg1].capMP; + cap = g_BattlePartyWork[arg1].capHP; + capMP = g_BattlePartyWork[arg1].capMP; } else { cap = 9999; capMP = 999; @@ -2231,7 +2231,7 @@ void BATTLE_ApplyKillCountBonus(void) { var_v1 = 0; if (g_CurrentAction->unk208 < 3) { - var_v1 = D_800F5E60[g_CurrentAction->unk208].partyMember->kill_count; + var_v1 = g_BattlePartyWork[g_CurrentAction->unk208].partyMember->kill_count; } g_CurrentAction->unk214 = var_v1 * 0xA; } @@ -2248,7 +2248,7 @@ void BATTLE_CalcMateriaSlotScore(void) { if (slot < 3) { i = 0; none = -1; - pm = D_800F5E60[slot].partyMember; + pm = g_BattlePartyWork[slot].partyMember; for (; i < 8; i++) { if (pm->materia_weapon[i] != none) { count++; @@ -2450,9 +2450,9 @@ void BATTLE_ClearActorSlotReferences(s32 arg0, s32 arg1, s32 arg2) { func_800A23BC(arg0); return; } - for (i = 0; i < LEN(D_800F5E60); i++) { - if (D_800F5E60[i].unk6 == arg0) { - D_800F5E60[i].unk6 = 0; + for (i = 0; i < LEN(g_BattlePartyWork); i++) { + if (g_BattlePartyWork[i].unk6 == arg0) { + g_BattlePartyWork[i].unk6 = 0; BattleQueueEvent(0, i, 6, 0); } } diff --git a/src/battle/battle.h b/src/battle/battle.h index 83fcbcff..fe810aca 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -431,7 +431,7 @@ typedef struct { typedef struct { /* 0x00 */ SavePartyMember* partyMember; /* 0x04 */ u8 limitCount; // inferred: bumped when a Limit Break executes - /* 0x05 */ u8 unk5; + /* 0x05 */ u8 limitLevel; /* 0x06 */ u8 unk6; /* 0x07 */ u8 killCount; // enemy kills this battle; reconciled into // SavePartyMember.kill_count after battle @@ -446,21 +446,18 @@ typedef struct { /* 0x16 */ u16 capHP; /* 0x18 */ u16 unk18; /* 0x1A */ u16 unk1A; - /* 0x1C */ u16 unk1C; - /* 0x1E */ u16 unk1E; - /* 0x20 */ u32 unk20; // status mask granted by the equipped accessory - /* 0x24 */ u16 unk24; - /* 0x26 */ u16 unk26; - /* 0x28 */ u16 unk28; - /* 0x2A */ u16 unk2A; + /* 0x1C */ u32 limitBreakHPDivisor; + /* 0x20 */ u32 accessoryStatusMask; // status mask granted by the equipped accessory + /* 0x24 */ u32 enemySkillMateriaData; + /* 0x28 */ u32 enemySkillMateriaData2; /* 0x2C */ u16 unk2C; /* 0x2E */ u16 unk2E; /* 0x30 */ u16 unk30; /* 0x32 */ u16 unk32; -} Unk800F5E60; // size:0x34 +} BattlePartyWork; // size:0x34 extern u16 D_800F5BBC[10][0x22]; -extern Unk800F5E60 D_800F5E60[3]; +extern BattlePartyWork g_BattlePartyWork[3]; extern Unk800F5F44 D_800F5F44; extern s8 D_800F6936[0x40][8]; extern u8 D_800F83A8; From cdd68f4a18146cbf76556c08e0d64ebffa0fb533 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Mon, 7 Sep 2026 23:42:21 -0500 Subject: [PATCH 11/18] BattleInitApplyAccStatus --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 3 +++ src/battle/batini.c | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 25e66bd4..07794f7f 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -10,7 +10,7 @@ func_801B137C = 0x801b137c; func_801B13DC = 0x801b13dc; func_801B14E8 = 0x801b14e8; func_801B1530 = 0x801b1530; -func_801B1598 = 0x801b1598; +BattleInitApplyAccStatus = 0x801b1598; func_801B1734 = 0x801b1734; func_801B18F8 = 0x801b18f8; BattleInitFormation = 0x801b19ac; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 151fd257..d596a218 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -10,3 +10,6 @@ BattleInitATBTimers = 0x801B0668; BattleInitSetSpeed = 0x801B085C; BattleInitPlayer = 0x801B08C0; + + +BattleInitApplyAccStatus = 0x801B1598; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 6e0af4c2..0ded17e0 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -156,7 +156,7 @@ typedef struct { extern BattleWork g_CombatantTurnState; extern SavePartyMember D_8009C738[]; -void func_801B1598(s32 slot, s32 accessory); +void BattleInitApplyAccStatus(s32 slot, s32 accessory); void func_801B11BC(s32 slot); void func_800A4BA4(s32 slot); s32 func_801B1734(s32 slot); @@ -204,7 +204,7 @@ void BattleInitPartyFromSavemap(void) { if (!(setup->targetFlags & 0x20)) { t->unk29 |= 2; } - func_801B1598(i, m->accessory); + BattleInitApplyAccStatus(i, m->accessory); func_801B11BC(i); func_800A4BA4(i); if (func_801B1734(i) == 0) { @@ -387,7 +387,7 @@ extern u8 D_80071C29[][0x10]; // accessory table, 0x10 stride // Applies party member `slot`'s equipped accessory: the status the previously // equipped one granted is cleared first, then the new accessory's permanent // status is ORed into the combatant, its turn state and the party record. -void func_801B1598(s32 slot, s32 accessory) { +void BattleInitApplyAccStatus(s32 slot, s32 accessory) { Unk800AF470* t; BattlePartyWork* party; Unk800F83E0* c; From 741dd68cd002c4b0ac57f5d81907992155cc7661 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 00:25:00 -0500 Subject: [PATCH 12/18] BattleInitCharCmdMenu --- config/sym_ovl_export.us.txt | 4 ++-- config/symbols.batini.txt | 5 ++++- config/symbols.battle.txt | 4 +++- src/battle/batini.c | 10 +++++----- src/battle/battle.c | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 07794f7f..12960c10 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -5,7 +5,7 @@ BattleInitSetSpeed = 0x801b085c; BattleInitPlayer = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; func_801B1120 = 0x801b1120; -func_801B11BC = 0x801b11bc; +BattleInitCharCmdMenu = 0x801b11bc; func_801B137C = 0x801b137c; func_801B13DC = 0x801b13dc; func_801B14E8 = 0x801b14e8; @@ -83,7 +83,7 @@ func_800A4ACC = 0x800a4acc; func_800A4AF4 = 0x800a4af4; func_800A4B3C = 0x800a4b3c; func_800A4B9C = 0x800a4b9c; -func_800A4BA4 = 0x800a4ba4; +BattleInitCharCmdState = 0x800a4ba4; func_800A4CA8 = 0x800a4ca8; func_800A4CC8 = 0x800a4cc8; func_800A4D2C = 0x800a4d2c; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index d596a218..19fefa6d 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -12,4 +12,7 @@ BattleInitSetSpeed = 0x801B085C; BattleInitPlayer = 0x801B08C0; -BattleInitApplyAccStatus = 0x801B1598; \ No newline at end of file +BattleInitApplyAccStatus = 0x801B1598; + +BattleInitCharCmdMenu = 0x801B11BC; + diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 2678e075..fa3e54f6 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -81,4 +81,6 @@ BattleGetRndU16 = 0x800B2F50; g_BattleUnitPresentMask = 0x8016375A; -g_BattlePartyWork = 0x800F5E60; \ No newline at end of file +g_BattlePartyWork = 0x800F5E60; + +BattleInitCharCmdState = 0x800A4BA4; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 0ded17e0..bb92d730 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -157,8 +157,8 @@ typedef struct { extern BattleWork g_CombatantTurnState; extern SavePartyMember D_8009C738[]; void BattleInitApplyAccStatus(s32 slot, s32 accessory); -void func_801B11BC(s32 slot); -void func_800A4BA4(s32 slot); +void BattleInitCharCmdMenu(s32 slot); +void BattleInitCharCmdState(s32 slot); s32 func_801B1734(s32 slot); // Seeds the three live party slots from the save data: finds each slot's @@ -205,8 +205,8 @@ void BattleInitPartyFromSavemap(void) { t->unk29 |= 2; } BattleInitApplyAccStatus(i, m->accessory); - func_801B11BC(i); - func_800A4BA4(i); + BattleInitCharCmdMenu(i); + BattleInitCharCmdState(i); if (func_801B1734(i) == 0) { BattleInitUnitAction(i); } @@ -240,7 +240,7 @@ extern u8 D_800F5BE1[][0x44]; // same records as D_800F5BBC // unk21 ends up as the number of command rows in use. The second pass clears // the "usable" byte of every equipped materia whose attack is not flagged // battle-usable. -void func_801B11BC(s32 arg0) { +void BattleInitCharCmdMenu(s32 arg0) { ActiveCharacterData* e; s32 cmd; s32 flags; diff --git a/src/battle/battle.c b/src/battle/battle.c index 82146856..ecb6c5c7 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -585,7 +585,7 @@ u8 func_800A4B3C(s32 index, s32 arg1) { void func_800A4B9C(void) {} -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4BA4); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", BattleInitCharCmdState); s32 func_800A4CA8(s32 arg0) { return D_800F39F0[arg0][0]; } From a507a27c27f1a2fcc063b92afb40a0847ddd679a Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 00:34:56 -0500 Subject: [PATCH 13/18] BattleInitApplyStartFX --- config/sym_ovl_export.us.txt | 4 ++-- config/symbols.batini.txt | 2 ++ config/symbols.battle.txt | 4 +++- src/battle/batini.c | 14 +++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 12960c10..f6e537b8 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -11,7 +11,7 @@ func_801B13DC = 0x801b13dc; func_801B14E8 = 0x801b14e8; func_801B1530 = 0x801b1530; BattleInitApplyAccStatus = 0x801b1598; -func_801B1734 = 0x801b1734; +BattleInitApplyStartFX = 0x801b1734; func_801B18F8 = 0x801b18f8; BattleInitFormation = 0x801b19ac; func_801B1CB0 = 0x801b1cb0; @@ -1050,7 +1050,7 @@ D_800F99F6 = 0x800f99f6; D_800F9D94 = 0x800f9d94; D_800F9D98 = 0x800f9d98; D_800F9D9C = 0x800f9d9c; -D_800F9DA0 = 0x800f9da0; +g_BattleStartFXFlags = 0x800f9da0; D_800F9DA4 = 0x800f9da4; D_800F9DA8 = 0x800f9da8; D_800F9DAA = 0x800f9daa; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 19fefa6d..0aab6c9f 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -16,3 +16,5 @@ BattleInitApplyAccStatus = 0x801B1598; BattleInitCharCmdMenu = 0x801B11BC; +BattleInitApplyStartFX = 0x801B1734; + diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index fa3e54f6..eaa75c06 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -83,4 +83,6 @@ g_BattleUnitPresentMask = 0x8016375A; g_BattlePartyWork = 0x800F5E60; -BattleInitCharCmdState = 0x800A4BA4; \ No newline at end of file +BattleInitCharCmdState = 0x800A4BA4; + +g_BattleStartFXFlags = 0x800F9DA0; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index bb92d730..b1fbac72 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -159,7 +159,7 @@ extern SavePartyMember D_8009C738[]; void BattleInitApplyAccStatus(s32 slot, s32 accessory); void BattleInitCharCmdMenu(s32 slot); void BattleInitCharCmdState(s32 slot); -s32 func_801B1734(s32 slot); +s32 BattleInitApplyStartFX(s32 slot); // Seeds the three live party slots from the save data: finds each slot's // party member record, copies HP/MP and the derived battle stats across, then @@ -207,7 +207,7 @@ void BattleInitPartyFromSavemap(void) { BattleInitApplyAccStatus(i, m->accessory); BattleInitCharCmdMenu(i); BattleInitCharCmdState(i); - if (func_801B1734(i) == 0) { + if (BattleInitApplyStartFX(i) == 0) { BattleInitUnitAction(i); } break; @@ -435,15 +435,15 @@ void BattleInitApplyAccStatus(s32 slot, s32 accessory) { const s32 D_801B001C[] = {0x0000, 0x1000, 0x0008, 0x0800}; const s32 D_801B002C[] = {0x0000, 0x000A, 0x0027, 0x000A}; -extern u8 D_800F9DA0; // pending battle-start status flags, one bit per entry +extern u8 g_BattleStartFXFlags; // pending battle-start status flags, one bit per entry // of D_801B001C / D_801B002C (bit 4 = full-heal) void BattleQueueEvent(s32, s32, s32, s32); -// Applies the pending battle-start effects in D_800F9DA0 to party member +// Applies the pending battle-start effects in g_BattleStartFXFlags to party member // `slot`: bit 4 restores half its max HP, bits 0-3 inflict the matching status // from D_801B001C unless the member's turn state already carries it. Returns // nonzero if any status was inflicted. -s32 func_801B1734(s32 slot) { +s32 BattleInitApplyStartFX(s32 slot) { s32 mask; s32 ret; s32 i; @@ -454,7 +454,7 @@ s32 func_801B1734(s32 slot) { if (g_CombatantTurnState.turn[slot].unk29 & 8) { mask |= STATUS_FROG; } - if (D_800F9DA0 & 0x10) { + if (g_BattleStartFXFlags & 0x10) { g_BattleState.combatant[slot].curHP += g_BattleState.combatant[slot].maxHP >> 1; if (g_BattleState.combatant[slot].curHP > g_BattleState.combatant[slot].maxHP) { g_BattleState.combatant[slot].curHP = g_BattleState.combatant[slot].maxHP; @@ -462,7 +462,7 @@ s32 func_801B1734(s32 slot) { BattleQueueEvent(2, slot, 0x17, 0); } for (i = 0; i < 4; i++) { - if ((D_800F9DA0 >> i) & 1) { + if ((g_BattleStartFXFlags >> i) & 1) { g_BattleState.combatant[slot].status |= D_801B001C[i] & ~mask; BattleQueueEvent(2, slot, 0x17, D_801B002C[i]); ret = 1; From ab0c3761d8e6f2864dc0b93e57907c6749ce1ce4 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 00:47:55 -0500 Subject: [PATCH 14/18] BattleRunUnitScript --- config/sym_ovl_export.us.txt | 4 ++-- config/symbols.batini.txt | 1 + config/symbols.battle.txt | 4 +++- src/battle/batini.c | 8 ++++---- src/battle/battle.c | 6 +++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index f6e537b8..a1f227a4 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -4,7 +4,7 @@ BattleInitATBTimers = 0x801b0668; BattleInitSetSpeed = 0x801b085c; BattleInitPlayer = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; -func_801B1120 = 0x801b1120; +BattleInitPartyScripts = 0x801b1120; BattleInitCharCmdMenu = 0x801b11bc; func_801B137C = 0x801b137c; func_801B13DC = 0x801b13dc; @@ -109,7 +109,7 @@ func_800A5AC8 = 0x800a5ac8; func_800A5BC8 = 0x800a5bc8; BATTLE_ExpandScriptToBuffer = 0x800a5eb0; func_800A5FB0 = 0x800a5fb0; -func_800A6000 = 0x800a6000; +BattleRunUnitScript = 0x800a6000; func_800A61D4 = 0x800a61d4; func_800A6278 = 0x800a6278; func_800A64A0 = 0x800a64a0; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 0aab6c9f..ee5b81fa 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -18,3 +18,4 @@ BattleInitCharCmdMenu = 0x801B11BC; BattleInitApplyStartFX = 0x801B1734; +BattleInitPartyScripts = 0x801B1120; \ No newline at end of file diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index eaa75c06..382f0861 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -85,4 +85,6 @@ g_BattlePartyWork = 0x800F5E60; BattleInitCharCmdState = 0x800A4BA4; -g_BattleStartFXFlags = 0x800F9DA0; \ No newline at end of file +g_BattleStartFXFlags = 0x800F9DA0; + +BattleRunUnitScript = 0x800A6000; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index b1fbac72..00df2641 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -217,14 +217,14 @@ void BattleInitPartyFromSavemap(void) { } } -extern void func_800A6000(s32, s32, s32); +extern void BattleRunUnitScript(s32, s32, s32); -void func_801B1120(void) { +void BattleInitPartyScripts(void) { s32 i; for (i = 0; i < 3; i++) { if (((s8)D_80163624.unk94[i][0] != -1) && !(g_BattleState.combatant[i].status & 1)) { - func_800A6000(i, 0, 0); + BattleRunUnitScript(i, 0, 0); } } } @@ -668,7 +668,7 @@ void BattleInitEnemyAI(void) { for (i = 0; i < 6; i++) { if (D_80163624.unk34[i].unk0 != -1) { - func_800A6000(i + 4, 0, 0); + BattleRunUnitScript(i + 4, 0, 0); } }; for (i = 0; i < 6; i++) { diff --git a/src/battle/battle.c b/src/battle/battle.c index ecb6c5c7..20f722b8 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -841,7 +841,7 @@ s32 func_800A5FB0(u16* arg0, s32 arg1, s32 arg2) { return var_v1; } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6000); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", BattleRunUnitScript); void func_800B1D48(s32, s32, s32); void func_800B2A2C(s32, s32); @@ -1282,14 +1282,14 @@ void BATTLE_QueueCurrentActionEffect(void) { void func_800A8528(void) { g_CurrentAction->unkB4 = 4; } -void func_800A6000(s32, s32, s32); +void BattleRunUnitScript(s32, s32, s32); void func_800A853C(void) { s32 var_s0; for (var_s0 = 0; var_s0 < 0xA; var_s0 += 1) { if ((g_CurrentAction->allowedTargetsMask >> var_s0) & 1) { - func_800A6000(var_s0, g_CurrentAction->relativeActionIndex, 0); + BattleRunUnitScript(var_s0, g_CurrentAction->relativeActionIndex, 0); } } } From c92d1bc1d1d515c6f276879c085526c414eb25d0 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 01:12:02 -0500 Subject: [PATCH 15/18] BattleGetEquipMateriaVal --- config/sym_ovl_export.us.txt | 8 ++++---- config/symbols.batini.txt | 10 +++++++++- src/battle/batini.c | 26 +++++++++++++------------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index a1f227a4..505a0d03 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -6,10 +6,10 @@ BattleInitPlayer = 0x801b08c0; BattleInitPartyFromSavemap = 0x801b0f08; BattleInitPartyScripts = 0x801b1120; BattleInitCharCmdMenu = 0x801b11bc; -func_801B137C = 0x801b137c; -func_801B13DC = 0x801b13dc; -func_801B14E8 = 0x801b14e8; -func_801B1530 = 0x801b1530; +BattleInitResetExtraCmds = 0x801b137c; +BattleResolveMateriaSlots = 0x801b13dc; +BattleGetMateriaValue = 0x801b14e8; +BattleGetEquipMateriaVal = 0x801b1530; BattleInitApplyAccStatus = 0x801b1598; BattleInitApplyStartFX = 0x801b1734; func_801B18F8 = 0x801b18f8; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index ee5b81fa..d20e3e12 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -18,4 +18,12 @@ BattleInitCharCmdMenu = 0x801B11BC; BattleInitApplyStartFX = 0x801B1734; -BattleInitPartyScripts = 0x801B1120; \ No newline at end of file +BattleInitPartyScripts = 0x801B1120; + +BattleInitResetExtraCmds = 0x801B137C; + +BattleResolveMateriaSlots = 0x801B13DC; + +BattleGetMateriaValue = 0x801B14E8; + +BattleGetEquipMateriaVal = 0x801B1530; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 00df2641..8e607a17 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -300,7 +300,7 @@ void BattleInitCharCmdMenu(s32 arg0) { } } -void func_801B137C(s32 arg0) { +void BattleInitResetExtraCmds(s32 arg0) { s32 i; ActiveCharacterData* data; @@ -328,37 +328,37 @@ typedef struct { u8 unk0; u8 unk1[0x1B]; } unk14[3]; -} Unk801B13DC; // size:0x68 +} BattleMateriaSlotData; // size:0x68 // Resolves up to three materia slots of character arg0 against the equipment // mask arg1: a slot whose bit is set copies its paired value into unk3 and // counts towards unk6. -void func_801B13DC(s32 arg0, s32 arg1, Unk801B13DC* arg2) { +void BattleResolveMateriaSlots(s32 slot, s32 materiaMask, BattleMateriaSlotData* data) { s32 count; s32 i; s32 j; count = 0; for (i = 0; i < 3; i++) { - if (arg2->materiaID[i] != 0xFF) { + if (data->materiaID[i] != 0xFF) { for (j = 0; j < 12; j++) { - if (SysGetLimitCmdId(arg0, j) == arg2->materiaID[i]) { + if (SysGetLimitCmdId(slot, j) == data->materiaID[i]) { break; } } if (j == 12) { func_800155A4(0x26); - } else if ((arg1 >> j) & 1) { + } else if ((materiaMask >> j) & 1) { count++; - arg2->unk3[i] = arg2->unk14[i].unk0; + data->unk3[i] = data->unk14[i].unk0; } } } - arg2->unk7 = 0; - arg2->count = count; + data->unk7 = 0; + data->count = count; } -s32 func_801B14E8(u32 arg0) { +s32 BattleGetMateriaValue(u32 arg0) { u8 temp_v1; s32 ret; @@ -370,14 +370,14 @@ s32 func_801B14E8(u32 arg0) { return ret; } -s32 func_801B1530(u32* arg0) { +s32 BattleGetEquipMateriaVal(u32* arg0) { s32 ret; s32 i; ret = 0; for (i = 0; i < 8; i++) { - ret |= func_801B14E8(arg0[0x10 + i]); - ret |= func_801B14E8(arg0[0x18 + i]); + ret |= BattleGetMateriaValue(arg0[0x10 + i]); + ret |= BattleGetMateriaValue(arg0[0x18 + i]); } return ret; } From f037330f78930485100257f6dc24eb7d5079bf0a Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 01:27:41 -0500 Subject: [PATCH 16/18] BattleUnit struct work --- config/sym_ovl_export.us.txt | 2 +- config/symbols.batini.txt | 31 +++++++---------- config/symbols.battle.txt | 20 ++++------- src/battle/batini.c | 64 ++++++++++++++++++------------------ src/battle/battle.h | 6 ++-- 5 files changed, 54 insertions(+), 69 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 505a0d03..99b2bef7 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -12,7 +12,7 @@ BattleGetMateriaValue = 0x801b14e8; BattleGetEquipMateriaVal = 0x801b1530; BattleInitApplyAccStatus = 0x801b1598; BattleInitApplyStartFX = 0x801b1734; -func_801B18F8 = 0x801b18f8; +BattleInitCharStats = 0x801b18f8; BattleInitFormation = 0x801b19ac; func_801B1CB0 = 0x801b1cb0; BattleInitEnemyUnits = 0x801b1e0c; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index d20e3e12..1f95e617 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -1,29 +1,20 @@ g_BattleState = 0x800F83AC; // size:0x444 BattleInitMain = 0x801B0050; BattleInitSetup = 0x801B0490; -BattleInitPartyFromSavemap = 0x801B0F08; -BattleInitFormation = 0x801B19AC; -BattleInitEnemyUnits = 0x801B1E0C; -BattleInitEnemyAI = 0x801B2308; -BattleInitLoadSceneData = 0x801B23E0; BattleInitATBTimers = 0x801B0668; - BattleInitSetSpeed = 0x801B085C; BattleInitPlayer = 0x801B08C0; - - -BattleInitApplyAccStatus = 0x801B1598; - +BattleInitPartyFromSavemap = 0x801B0F08; +BattleInitPartyScripts = 0x801B1120; BattleInitCharCmdMenu = 0x801B11BC; - -BattleInitApplyStartFX = 0x801B1734; - -BattleInitPartyScripts = 0x801B1120; - BattleInitResetExtraCmds = 0x801B137C; - BattleResolveMateriaSlots = 0x801B13DC; - -BattleGetMateriaValue = 0x801B14E8; - -BattleGetEquipMateriaVal = 0x801B1530; \ No newline at end of file +BattleGetMateriaValue = 0x801B14E8; +BattleGetEquipMateriaVal = 0x801B1530; +BattleInitApplyAccStatus = 0x801B1598; +BattleInitApplyStartFX = 0x801B1734; +BattleInitCharStats = 0x801B18F8; +BattleInitFormation = 0x801B19AC; +BattleInitEnemyUnits = 0x801B1E0C; +BattleInitEnemyAI = 0x801B2308; +BattleInitLoadSceneData = 0x801B23E0; diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 382f0861..1a6299db 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -6,8 +6,10 @@ BATTLE_RunFrame = 0x800A3354; BattleUpdateUnitMasks = 0x800A4540; BATTLE_RunToResultScreen = 0x800A4860; BATTLE_RunEscapeSequence = 0x800A4954; +BattleInitCharCmdState = 0x800A4BA4; BATTLE_PickRandomThrowItem = 0x800A5990; BATTLE_ExpandScriptToBuffer = 0x800A5EB0; +BattleRunUnitScript = 0x800A6000; BATTLE_ClearStatusBit = 0x800A6CC0; BATTLE_ExpireDeathSentence = 0x800A6D10; BATTLE_TickPoison = 0x800A6D88; @@ -42,6 +44,7 @@ BATTLE_ScriptReadU16 = 0x800B1368; BATTLE_ScriptCompare = 0x800B1B64; BATTLE_ScriptCollapseVarBank = 0x800B1C94; BATTLE_GetAttackEntry = 0x800B2EBC; +BattleGetRndU16 = 0x800B2F50; BattleEffectRegister = 0x800BBEAC; BATTLE_EnqueueLoadImage = 0x800D2538; BATTLE_FlushImageQueue = 0x800D25E8; @@ -57,9 +60,11 @@ g_AtbBarPulseColor = 0x800F32C4; // size:0x2 g_AtbBarPulseValue = 0x800F32C6; // size:0x2 g_ActiveCharsHPMPInited = 0x800F32C8; // size:0x2 g_CombatantTurnState = 0x800F5BB8; // size:0xCC +g_BattlePartyWork = 0x800F5E60; D_800F5F44 = 0x800F5F44; // size:0x1E88 g_dbIndex = 0x800F8368; g_BattleState = 0x800F83AC; // size:0x444 +g_BattleStartFXFlags = 0x800F9DA0; D_800FA63C = 0x800FA63C; // size:0x38 D_800FA6D8 = 0x800FA6D8; // size:0xA8 D_800FA958 = 0x800FA958; // size:0x20 @@ -73,18 +78,7 @@ D_801621F0 = 0x801621F0; // size:0x780 D_80162978 = 0x80162978; // size:0xC80 D_8016360C = 0x8016360C; // size:0xAC D_801636B8 = 0x801636B8; // size:0xA0 +g_BattleUnitPresentMask = 0x8016375A; +g_IsMutiBattle = 0x8016376C; D_80163798 = 0x80163798; // size:0x300 D_80163C80 = 0x80163C80; // size:0xC -g_IsMutiBattle = 0x8016376C; - -BattleGetRndU16 = 0x800B2F50; -g_BattleUnitPresentMask = 0x8016375A; - - -g_BattlePartyWork = 0x800F5E60; - -BattleInitCharCmdState = 0x800A4BA4; - -g_BattleStartFXFlags = 0x800F9DA0; - -BattleRunUnitScript = 0x800A6000; \ No newline at end of file diff --git a/src/battle/batini.c b/src/battle/batini.c index 8e607a17..f45e9cc7 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -11,7 +11,7 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitMain); static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)); void BattleInitSetup(s32 sceneID) { - Unk800F83E0* c; + BattleUnit* c; s32 i; s32 var_s1; @@ -56,7 +56,7 @@ void BattleInitSetup(s32 sceneID) { extern u16 g_BattleUnitPresentMask; extern u16 D_8009D864[][0x220]; // stride 0x440, one per Unk8009D84C record -u16 BattleGetRndU16(void); // random, 16-bit +u16 BattleGetRndU16(void); // random, 16-bit // Rolls the initial ATB timer of every present combatant and writes it into // D_800F5BBC. The battle type (battleType) then biases those timers: a @@ -135,10 +135,10 @@ typedef struct { /* 0x01 */ u8 attackEffectId; /* 0x02 */ u8 damageFormulaId; /* 0x03 */ u8 hitChance; - /* 0x04 */ u8 impactEffectId; - /* 0x05 */ u8 criticalHitChance; - /* 0x06 */ u8 unk06; - /* 0x07 */ u8 unk07; + /* 0x04 */ u8 impactEffectId; + /* 0x05 */ u8 criticalHitChance; + /* 0x06 */ u8 unk06; + /* 0x07 */ u8 unk07; /* 0x08 */ u16 normalAttackSound; /* 0x0A */ u16 criticalAttackSound; /* 0x0C */ u16 missAttackSound; @@ -167,7 +167,7 @@ s32 BattleInitApplyStartFX(s32 slot); void BattleInitPartyFromSavemap(void) { BattlePartyWork* party; ActiveCharacterData* rec; - Unk800F83E0* c; + BattleUnit* c; Unk800AF470* t; BattleUnitAttackSetup* setup; SavePartyMember* m; @@ -191,7 +191,7 @@ void BattleInitPartyFromSavemap(void) { c->unk28 = m->mp_cur; t->unk3C = c->curHP; t->unk3E = c->unk28; - func_801B18F8(rec, party, c); + BattleInitCharStats(rec, party, c); t->unk34 = rec->immuneStatuses; setup->attackElement = rec->weapon.attackElement | rec->physicalAttackElements; setup->attackStatusMask = rec->physicalAttackStatuses; @@ -370,14 +370,14 @@ s32 BattleGetMateriaValue(u32 arg0) { return ret; } -s32 BattleGetEquipMateriaVal(u32* arg0) { +s32 BattleGetEquipMateriaVal(u32* equipment) { s32 ret; s32 i; ret = 0; for (i = 0; i < 8; i++) { - ret |= BattleGetMateriaValue(arg0[0x10 + i]); - ret |= BattleGetMateriaValue(arg0[0x18 + i]); + ret |= BattleGetMateriaValue(equipment[0x10 + i]); + ret |= BattleGetMateriaValue(equipment[0x18 + i]); } return ret; } @@ -390,7 +390,7 @@ extern u8 D_80071C29[][0x10]; // accessory table, 0x10 stride void BattleInitApplyAccStatus(s32 slot, s32 accessory) { Unk800AF470* t; BattlePartyWork* party; - Unk800F83E0* c; + BattleUnit* c; u8 effect; t = &g_CombatantTurnState.turn[slot]; @@ -436,7 +436,7 @@ void BattleInitApplyAccStatus(s32 slot, s32 accessory) { const s32 D_801B001C[] = {0x0000, 0x1000, 0x0008, 0x0800}; const s32 D_801B002C[] = {0x0000, 0x000A, 0x0027, 0x000A}; extern u8 g_BattleStartFXFlags; // pending battle-start status flags, one bit per entry - // of D_801B001C / D_801B002C (bit 4 = full-heal) + // of D_801B001C / D_801B002C (bit 4 = full-heal) void BattleQueueEvent(s32, s32, s32, s32); // Applies the pending battle-start effects in g_BattleStartFXFlags to party member @@ -471,27 +471,27 @@ s32 BattleInitApplyStartFX(s32 slot) { return ret; } -void func_801B18F8(ActiveCharacterData* arg0, BattlePartyWork* arg1, Unk800F83E0* arg2) { - arg2->unk14 = arg0->dexterity; - arg2->unk15 = arg0->luck; - arg2->maxHP = arg0->baseHp; - arg2->unk2A = arg0->baseMp; - arg2->unkD = arg0->physAttack; - arg2->unkE = arg0->magAttack; - arg2->unk20 = arg0->physDefence; - arg2->unk22 = arg0->magDefence; - if (arg2->unkD == 0) { - arg2->unkD = 1; - } - arg1->maxHP = arg2->maxHP; - arg1->maxMP = arg2->unk2A; +void BattleInitCharStats(ActiveCharacterData* character, BattlePartyWork* partyWork, BattleUnit* battleUnit) { + battleUnit->unk14 = character->dexterity; + battleUnit->unk15 = character->luck; + battleUnit->maxHP = character->baseHp; + battleUnit->unk2A = character->baseMp; + battleUnit->unkD = character->physAttack; + battleUnit->unkE = character->magAttack; + battleUnit->unk20 = character->physDefence; + battleUnit->unk22 = character->magDefence; + if (battleUnit->unkD == 0) { + battleUnit->unkD = 1; + } + partyWork->maxHP = battleUnit->maxHP; + partyWork->maxMP = battleUnit->unk2A; // 8 = HP_MP_SWAP - if (arg0->characterFlags & 8) { - arg1->capHP = 999; - arg1->capMP = 9999; + if (character->characterFlags & 8) { + partyWork->capHP = 999; + partyWork->capMP = 9999; } else { - arg1->capHP = 9999; - arg1->capMP = 999; + partyWork->capHP = 9999; + partyWork->capMP = 999; } } diff --git a/src/battle/battle.h b/src/battle/battle.h index fe810aca..73d5e755 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -26,7 +26,7 @@ typedef enum { } BattleEventType; // full standard FF7 status bitmask (wiki.ffrtt.ru/FF7/Battle/Status_Effects) -// for Unk800F83E0.status. NOTE: the standard table's bit 0x2 (Near Death) +// for BattleUnit.status. NOTE: the standard table's bit 0x2 (Near Death) // does not appear to be set here -- this engine computes Near Death live // from curHP/maxHP instead (see func_800B10B4), not via this flag. Bits // actually confirmed live in decompiled code so far: Death, Confu, Silence, @@ -107,7 +107,7 @@ typedef struct { /* 0x4E */ u8 unk4E; /* 0x4F */ u8 unk4F; /* 0x50 */ u32 unk50[6]; -} Unk800F83E0; // size:0x68 +} BattleUnit; // size:0x68 typedef struct { /* 0x000 */ u16 unk0; @@ -128,7 +128,7 @@ typedef struct { /* 0x026 */ u16 unk26; // D_800F83D2 /* 0x028 */ u16 unk28; // D_800F83D4 /* 0x02A */ u8 unk2A[0xA]; // D_800F83D8..D_800F83DC - /* 0x034 */ Unk800F83E0 combatant[10]; + /* 0x034 */ BattleUnit combatant[10]; } BattleState; // size:0x444 typedef struct { From 413efacdedde63cac340e12662456bad264f3f47 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 01:42:39 -0500 Subject: [PATCH 17/18] BattleUnit struct updated --- src/battle/batini.c | 26 +++++++++++++------------- src/battle/battle.c | 2 +- src/battle/battle.h | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/battle/batini.c b/src/battle/batini.c index f45e9cc7..a58521ee 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -11,7 +11,7 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/batini", BattleInitMain); static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)); void BattleInitSetup(s32 sceneID) { - BattleUnit* c; + BattleUnit* unit; s32 i; s32 var_s1; @@ -37,8 +37,8 @@ void BattleInitSetup(s32 sceneID) { g_BattleState.presentMask = 0; for (i = 0; i < 10; i++) { BattleRecalcUnitSpeed(i); - c = &g_BattleState.combatant[i]; - if (c->unk8 != -1) { + unit = &g_BattleState.combatant[i]; + if (unit->unk8 != -1) { g_BattleState.presentMask |= 1 << i; } } @@ -472,19 +472,19 @@ s32 BattleInitApplyStartFX(s32 slot) { } void BattleInitCharStats(ActiveCharacterData* character, BattlePartyWork* partyWork, BattleUnit* battleUnit) { - battleUnit->unk14 = character->dexterity; - battleUnit->unk15 = character->luck; + battleUnit->dexterity = character->dexterity; + battleUnit->luck = character->luck; battleUnit->maxHP = character->baseHp; - battleUnit->unk2A = character->baseMp; - battleUnit->unkD = character->physAttack; - battleUnit->unkE = character->magAttack; - battleUnit->unk20 = character->physDefence; - battleUnit->unk22 = character->magDefence; - if (battleUnit->unkD == 0) { - battleUnit->unkD = 1; + battleUnit->maxMP = character->baseMp; + battleUnit->physAttack = character->physAttack; + battleUnit->magAttack = character->magAttack; + battleUnit->physDefence = character->physDefence; + battleUnit->magDefence = character->magDefence; + if (battleUnit->physAttack == 0) { + battleUnit->physAttack = 1; } partyWork->maxHP = battleUnit->maxHP; - partyWork->maxMP = battleUnit->unk2A; + partyWork->maxMP = battleUnit->maxMP; // 8 = HP_MP_SWAP if (character->characterFlags & 8) { partyWork->capHP = 999; diff --git a/src/battle/battle.c b/src/battle/battle.c index 20f722b8..9d231e40 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -2509,7 +2509,7 @@ void BATTLE_RollPhysicalHit(void) { if (!(g_CurrentAction->unk218 & 1)) { acc = 0xFF; if (!(g_CurrentAction->unkC8 & 0x40000000)) { - v = (g_CurrentAction->characterLevel + g_BattleState.combatant[attacker].unk15) - + v = (g_CurrentAction->characterLevel + g_BattleState.combatant[attacker].luck) - g_BattleState.combatant[target].unk9; acc = v / 4; if (attacker < 3) { diff --git a/src/battle/battle.h b/src/battle/battle.h index 73d5e755..a6e08c0d 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -79,25 +79,25 @@ typedef struct { /* 0x0A */ s8 unkA; /* 0x0B */ s8 unkB; /* 0x0C */ s8 unkC; - /* 0x0D */ u8 unkD; - /* 0x0E */ s8 unkE; + /* 0x0D */ u8 physAttack; + /* 0x0E */ s8 magAttack; /* 0x0F */ s8 unkF; /* 0x10 */ s8 unk10; // cached "Near Death" display flag; see func_800B10B4 // for the live check /* 0x11 */ u8 unk11; /* 0x12 */ s8 unk12; /* 0x13 */ s8 unk13; - /* 0x14 */ s8 unk14; - /* 0x15 */ u8 unk15; + /* 0x14 */ s8 dexterity; + /* 0x15 */ u8 luck; /* 0x16 */ s8 unk16; /* 0x17 */ u8 unk17; /* 0x18 */ s32 unk18; /* 0x1C */ s32 unk1C; - /* 0x20 */ s16 unk20; - /* 0x22 */ s16 unk22; + /* 0x20 */ s16 physDefence; + /* 0x22 */ s16 magDefence; /* 0x24 */ s32 unk24; /* 0x28 */ s16 unk28; - /* 0x2A */ s16 unk2A; + /* 0x2A */ s16 maxMP; /* 0x2C */ u32 curHP; /* 0x30 */ u32 maxHP; /* 0x34 */ u32 unk34[4]; From 53a63560518da96b46fb35306f589cb562ce6742 Mon Sep 17 00:00:00 2001 From: halkun <37340407+joshuanwalker@users.noreply.github.com> Date: Tue, 8 Sep 2026 02:20:46 -0500 Subject: [PATCH 18/18] final functions --- config/sym_ovl_export.us.txt | 8 +-- config/symbols.batini.txt | 4 ++ config/symbols.battle.txt | 1 + config/symbols.main.us.txt | 1 + src/battle/batini.c | 102 +++++++++++++++++------------------ src/battle/battle3.c | 2 +- src/battle/battle_private.h | 2 +- src/main/110B8.c | 2 +- src/main/144D8.c | 4 +- src/main/1CDA4.c | 2 +- src/main/1F6B4.c | 2 +- src/main/btlinit.c | 2 +- 12 files changed, 69 insertions(+), 63 deletions(-) diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt index 99b2bef7..a518e902 100644 --- a/config/sym_ovl_export.us.txt +++ b/config/sym_ovl_export.us.txt @@ -14,11 +14,11 @@ BattleInitApplyAccStatus = 0x801b1598; BattleInitApplyStartFX = 0x801b1734; BattleInitCharStats = 0x801b18f8; BattleInitFormation = 0x801b19ac; -func_801B1CB0 = 0x801b1cb0; +BattleInitItemList = 0x801b1cb0; BattleInitEnemyUnits = 0x801b1e0c; BattleInitEnemyAI = 0x801b2308; -func_801B2738 = 0x801b2738; -func_801B2770 = 0x801b2770; +BattleGetScenePackId = 0x801b2738; +BattleBoostVal25Percent = 0x801b2770; func_801B0000 = 0x801b0000; CommitBattleResults = 0x801b09c0; GiveMateriaAp = 0x801b0c74; @@ -1320,7 +1320,7 @@ D_80163766 = 0x80163766; D_80163768 = 0x80163768; D_8016376A = 0x8016376a; g_IsMutiBattle = 0x8016376c; -D_8016376E = 0x8016376e; +g_CharacterMask = 0x8016376e; D_80163770 = 0x80163770; D_80163772 = 0x80163772; D_80163774 = 0x80163774; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt index 1f95e617..1b9fd7d3 100644 --- a/config/symbols.batini.txt +++ b/config/symbols.batini.txt @@ -1,4 +1,6 @@ +BattleBoostVal25Percent = 0x001B2770; g_BattleState = 0x800F83AC; // size:0x444 +g_BattleTypeMap = 0x801B0044; BattleInitMain = 0x801B0050; BattleInitSetup = 0x801B0490; BattleInitATBTimers = 0x801B0668; @@ -15,6 +17,8 @@ BattleInitApplyAccStatus = 0x801B1598; BattleInitApplyStartFX = 0x801B1734; BattleInitCharStats = 0x801B18F8; BattleInitFormation = 0x801B19AC; +BattleInitItemList = 0x801B1CB0; BattleInitEnemyUnits = 0x801B1E0C; BattleInitEnemyAI = 0x801B2308; BattleInitLoadSceneData = 0x801B23E0; +BattleGetScenePackId = 0x801B2738; diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt index 1a6299db..b60c9d5d 100644 --- a/config/symbols.battle.txt +++ b/config/symbols.battle.txt @@ -80,5 +80,6 @@ D_8016360C = 0x8016360C; // size:0xAC D_801636B8 = 0x801636B8; // size:0xA0 g_BattleUnitPresentMask = 0x8016375A; g_IsMutiBattle = 0x8016376C; +g_CharacterMask = 0x8016376E; D_80163798 = 0x80163798; // size:0x300 D_80163C80 = 0x80163C80; // size:0xC diff --git a/config/symbols.main.us.txt b/config/symbols.main.us.txt index e978a4a2..8e0cc779 100644 --- a/config/symbols.main.us.txt +++ b/config/symbols.main.us.txt @@ -26,6 +26,7 @@ SysBattleSwirlRender = 0x800140A4; SysBattleSwirlInit = 0x800140F4; SysLoadUncompressImg = 0x80014980; SysLoadDrawSync = 0x800149E0; +SysMemCopy32 = 0x80014A00; SysGetLsbNumber = 0x80014A38; SysCountActiveBits = 0x80014A58; SysSelectRandomBit = 0x80014A84; diff --git a/src/battle/batini.c b/src/battle/batini.c index a58521ee..84dda09c 100644 --- a/src/battle/batini.c +++ b/src/battle/batini.c @@ -234,20 +234,20 @@ extern u8 D_800708D0[][0x1C]; // attack table, 0x1C stride extern u8 D_800F5EFC[][0x18]; // per-slot formation-setup config extern u8 D_800F5BE1[][0x44]; // same records as D_800F5BBC -// Fixes up party member arg0's battle command list: each of the 16 command +// Fixes up party member sceneID's battle command list: each of the 16 command // slots gets its target flags from the command table (falling back to the // formation setup), with extra flags for the Enemy Skill / W- commands, and // unk21 ends up as the number of command rows in use. The second pass clears // the "usable" byte of every equipped materia whose attack is not flagged // battle-usable. -void BattleInitCharCmdMenu(s32 arg0) { +void BattleInitCharCmdMenu(s32 sceneID) { ActiveCharacterData* e; s32 cmd; s32 flags; s32 id; s32 i; - e = &g_ActiveCharacters[arg0]; + e = &g_ActiveCharacters[sceneID]; e->unk21 = 1; for (i = 0; i < 16; i++) { flags = 0xFF; @@ -255,7 +255,7 @@ void BattleInitCharCmdMenu(s32 arg0) { if (cmd != 0xFF) { flags = D_800707C5[cmd][0]; if (flags == 0xFF) { - flags = D_800F5EFC[arg0][0]; + flags = D_800F5EFC[sceneID][0]; } if (cmd < 0x1C) { if (cmd >= 0x18) { @@ -263,7 +263,7 @@ void BattleInitCharCmdMenu(s32 arg0) { } } if (e->commandMenu[i].initialCursorAction == 7) { - if (D_800F5BE1[arg0][0] & 2) { + if (D_800F5BE1[sceneID][0] & 2) { e->commandMenu[i].initialCursorAction = 0; } if (e->commandMenu[i].allCount != 0) { @@ -300,11 +300,11 @@ void BattleInitCharCmdMenu(s32 arg0) { } } -void BattleInitResetExtraCmds(s32 arg0) { +void BattleInitResetExtraCmds(s32 sceneID) { s32 i; ActiveCharacterData* data; - data = &g_ActiveCharacters[arg0]; + data = &g_ActiveCharacters[sceneID]; data->unk21 = 1; for (i = 1; i < 4; i++) { data->commandMenu[i].id = 0xFF; @@ -330,7 +330,7 @@ typedef struct { } unk14[3]; } BattleMateriaSlotData; // size:0x68 -// Resolves up to three materia slots of character arg0 against the equipment +// Resolves up to three materia slots of character sceneID against the equipment // mask arg1: a slot whose bit is set copies its paired value into unk3 and // counts towards unk6. void BattleResolveMateriaSlots(s32 slot, s32 materiaMask, BattleMateriaSlotData* data) { @@ -358,14 +358,14 @@ void BattleResolveMateriaSlots(s32 slot, s32 materiaMask, BattleMateriaSlotData* data->count = count; } -s32 BattleGetMateriaValue(u32 arg0) { +s32 BattleGetMateriaValue(u32 sceneID) { u8 temp_v1; s32 ret; - temp_v1 = arg0; + temp_v1 = sceneID; ret = 0; if (temp_v1 != 0xFF && (D_800730CC[temp_v1].unk11 & 0xF) == 7) { - ret = (arg0 >> 8) | 0x80000000; + ret = (sceneID >> 8) | 0x80000000; } return ret; } @@ -496,7 +496,7 @@ void BattleInitCharStats(ActiveCharacterData* character, BattlePartyWork* partyW } const u8 D_801B003C[] = {0xFF, 0x32, 0x33, 0x34, 0x35, 0xFF, 0x48, 0x07}; -extern u16 D_8016376E[3]; +extern u16 g_CharacterMask[3]; extern s16 D_801636BE[][8]; // stride 0x10 void func_800B1060(s32); @@ -594,9 +594,9 @@ void BattleInitFormation(void) { } D_801636BE[i][0] = back; } - D_8016376E[0] = row[0]; - D_8016376E[1] = row[1]; - D_8016376E[2] = row[2]; + g_CharacterMask[0] = row[0]; + g_CharacterMask[1] = row[1]; + g_CharacterMask[2] = row[2]; } extern u16 D_8009CBE0[]; // item inventory (320 slots; (count << 9) | id) @@ -614,7 +614,7 @@ extern BattleItemEntry D_801671B8[]; // flags pulled from the item / weapon / armor / accessory table the id falls // in. D_80166F74 ends up as half the number of slots up to the last used one // (at least 3) -- the row count the item widget scrolls over. -void func_801B1CB0(void) { +void BattleInitItemList(void) { BattleItemEntry* entry; s32 i; s32 last; @@ -678,52 +678,52 @@ void BattleInitEnemyAI(void) { } } -static const s8 D_801B0044[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x05, 0x6E, 0x64, 0x62}; +static const s8 g_BattleTypeMap[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x05, 0x6E, 0x64, 0x62}; static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { u8 dummy[0x100]; SceneContainer scene; - s32 chunkID; - s32 temp_s1; + s32 sceneChunkID; + s32 scenePackID; s32 formationIndex; s32 i; u_long* var_s2; - s32* var_s5; + s32* scenePackBuffer; s32* var_s3_2; - var_s5 = (s32*)0x801C0000; - chunkID = sceneID / 4; - temp_s1 = func_801B2738(chunkID); // sector modified based on the Chunk ID - SystemLoadFileBySector( // load file from disk - func_800144D8(BATTLE_SCENE) + temp_s1 * 4, // Disk sector where to load the file from - 0x800 * 4, // Size in bytes to copy - (u_long*)var_s5, // Destination + scenePackBuffer = (s32*)0x801C0000; + sceneChunkID = sceneID / 4; + scenePackID = BattleGetScenePackId(sceneChunkID); // sector modified based on the Chunk ID + SystemLoadFileBySector( // load file from disk + func_800144D8(BATTLE_SCENE) + scenePackID * 4, // Disk sector where to load the file from + 0x800 * 4, // Size in bytes to copy + (u_long*)scenePackBuffer, // Destination NULL); - formationIndex = chunkID - D_80083184[temp_s1]; + formationIndex = sceneChunkID - D_80083184[scenePackID]; func_800145BC(cb); // wait until all data is read, keep executing the vsync // callback until then - i = var_s5[formationIndex]; - var_s3_2 = &var_s5[i]; + i = scenePackBuffer[formationIndex]; + var_s3_2 = &scenePackBuffer[i]; var_s2 = (u_long*)&scene; Unzip( // gzip decompress var_s3_2, // src var_s2); // dst - formationIndex = sceneID - chunkID * 4; - func_80014A00(D_8016360C.enemyModelIDs, scene.enemyModelIDs, sizeof(scene.enemyModelIDs)); - func_80014A00((s32*)&D_8016360C.setup, &scene.setup[formationIndex], sizeof(BattleSetup)); - func_80014A00((s32*)&D_8016360C.camera, &scene.camera[formationIndex], sizeof(CameraPlacement) * 4); - func_80014A00((s32*)&D_8016360C.formation, &scene.formation[formationIndex], sizeof(FormationEntry) * 6); - func_80014A00((s32*)&D_800F5F44.enemy, &scene.enemy, sizeof(scene.enemy)); - func_80014A00((s32*)&D_800F5F44.attacks, &scene.attacks, sizeof(scene.attacks)); - func_80014A00((s32*)&D_800F5F44.attackIDs, scene.attackIDs, sizeof(scene.attackIDs)); - func_80014A00((s32*)&D_800F5F44.attackNames, &scene.attackNames, sizeof(scene.attackNames)); - func_80014A00((s32*)&D_800F5F44._5, &scene.unkC80, sizeof(Unk800F5F44_5)); - func_80014A00((s32*)&D_800F5F44.script, &scene.script, sizeof(scene.script)); + formationIndex = sceneID - sceneChunkID * 4; + SysMemCopy32(D_8016360C.enemyModelIDs, scene.enemyModelIDs, sizeof(scene.enemyModelIDs)); + SysMemCopy32((s32*)&D_8016360C.setup, &scene.setup[formationIndex], sizeof(BattleSetup)); + SysMemCopy32((s32*)&D_8016360C.camera, &scene.camera[formationIndex], sizeof(CameraPlacement) * 4); + SysMemCopy32((s32*)&D_8016360C.formation, &scene.formation[formationIndex], sizeof(FormationEntry) * 6); + SysMemCopy32((s32*)&D_800F5F44.enemy, &scene.enemy, sizeof(scene.enemy)); + SysMemCopy32((s32*)&D_800F5F44.attacks, &scene.attacks, sizeof(scene.attacks)); + SysMemCopy32((s32*)&D_800F5F44.attackIDs, scene.attackIDs, sizeof(scene.attackIDs)); + SysMemCopy32((s32*)&D_800F5F44.attackNames, &scene.attackNames, sizeof(scene.attackNames)); + SysMemCopy32((s32*)&D_800F5F44._5, &scene.unkC80, sizeof(Unk800F5F44_5)); + SysMemCopy32((s32*)&D_800F5F44.script, &scene.script, sizeof(scene.script)); if (D_8016376A & 4 && D_8016360C.setup.flags & SETUP_NO_PREEMPTIVE_STRIKE) { if (D_8016360C.setup.type == SETUP_DEFAULT) { D_8016360C.setup.type = SETUP_PREEMPTIVE; } } - D_800F5F44.battleType = (u8)D_801B0044[D_8016360C.setup.type]; + D_800F5F44.battleType = (u8)g_BattleTypeMap[D_8016360C.setup.type]; if (D_8016376A & EVENT_BATTLE_SQUARE) { D_8016360C.setup.stageID = 37; D_8016360C.setup.flags |= SETUP_CANNOT_ESCAPE; @@ -732,8 +732,8 @@ static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { // enemy strength and magic is 25% higher at battle square for (i = 0; i < 3; i++) { D_800F5F44.enemy[i].unk90[5] *= 2; - D_800F5F44.enemy[i].strength = func_801B2770(D_800F5F44.enemy[i].strength); - D_800F5F44.enemy[i].magic = func_801B2770(D_800F5F44.enemy[i].magic); + D_800F5F44.enemy[i].strength = BattleBoostVal25Percent(D_800F5F44.enemy[i].strength); + D_800F5F44.enemy[i].magic = BattleBoostVal25Percent(D_800F5F44.enemy[i].magic); } } else if (D_8016376A & 8) { D_8016360C.setup.flags &= ~SETUP_CANNOT_ESCAPE; @@ -748,11 +748,11 @@ static void BattleInitLoadSceneData(s32 sceneID, void (*cb)(void)) { D_800F5F44.D_800F7DB6 = D_800F5F44.D_800F7DB2; } -s32 func_801B2738(s32 arg0) { +s32 BattleGetScenePackId(s32 sceneID) { u32 i; for (i = 1; i < LEN(D_80083184); i++) { - if (arg0 < D_80083184[i]) { + if (sceneID < D_80083184[i]) { break; } } @@ -760,10 +760,10 @@ s32 func_801B2738(s32 arg0) { } // increase param by 25% -s32 func_801B2770(s32 arg0) { - arg0 = (arg0 * 125) / 100; - if (arg0 > 255) { - arg0 = 255; +s32 BattleBoostVal25Percent(s32 value) { + value = (value * 125) / 100; + if (value > 255) { + value = 255; } - return arg0; + return value; } diff --git a/src/battle/battle3.c b/src/battle/battle3.c index e2021cdf..6b4846d6 100644 --- a/src/battle/battle3.c +++ b/src/battle/battle3.c @@ -963,7 +963,7 @@ static s32 func_800E6B40(void) { s32 i; for (i = 0; i < 3; i++) { - if ((1 << D_800F38A7) & D_801516F8 & D_8016376E[i]) { + if ((1 << D_800F38A7) & D_801516F8 & g_CharacterMask[i]) { return i; } } diff --git a/src/battle/battle_private.h b/src/battle/battle_private.h index d464bda8..58ded01a 100644 --- a/src/battle/battle_private.h +++ b/src/battle/battle_private.h @@ -526,7 +526,7 @@ extern u16 D_80163762; // part of a struct // Cait Sith's 3 landed Slots reel symbols (see func_800E5358, and // BATTLE_ResolveCaitSithSlotsResult in battle.c) extern u8 D_80163774[4]; -extern u16 D_8016376E[]; +extern u16 g_CharacterMask[]; extern u8 D_80163784[3]; extern s8 D_80163787; // suspicious, very likely part of a struct extern u8 D_8016378C[]; diff --git a/src/main/110B8.c b/src/main/110B8.c index 9c6161fa..852b8980 100644 --- a/src/main/110B8.c +++ b/src/main/110B8.c @@ -46,7 +46,7 @@ extern s16 D_80062E08; extern s16 D_80062E0A; extern s32 D_80062E0C; void SysBgRender(void); -void func_80014A00(s32* dst, s32* src, s32 len); +void SysMemCopy32(s32* dst, s32* src, s32 len); u16* SysGetPointerToTextInKernWithBlockAndTextId(s32, s32, s32); s32 SysDecompKernStringWithF9(u16*, u16*); u16* SysGetPtrToKernBattleTxtWithId(s32); diff --git a/src/main/144D8.c b/src/main/144D8.c index d93791a3..938793bf 100644 --- a/src/main/144D8.c +++ b/src/main/144D8.c @@ -1,7 +1,7 @@ //! G=0 #include "main_private.h" -void func_80014A00(s32* dst, s32* src, s32 len); +void SysMemCopy32(s32* dst, s32* src, s32 len); u8* func_80014C80(s32 arg0); void SysGzipBinDecompress(GzHeader* src, s32* dst); void SysGzipSetDataBlock(u8* arg0); @@ -38,7 +38,7 @@ void func_80014610(void) { u8 buf[2048]; SystemLoadFileBySector(LBA_INIT_YAMADA, sizeof(buf), (u_long*)&buf, NULL); func_800145BC(0); - func_80014A00((s32*)D_80048D84, (s32*)&buf, sizeof(Yamada) * YAMADA_FILE_NUM); + SysMemCopy32((s32*)D_80048D84, (s32*)&buf, sizeof(Yamada) * YAMADA_FILE_NUM); } void func_80014658(s32 file_no, void (*cb)(void)) { diff --git a/src/main/1CDA4.c b/src/main/1CDA4.c index c4a7dacb..38ba73a2 100644 --- a/src/main/1CDA4.c +++ b/src/main/1CDA4.c @@ -40,7 +40,7 @@ s32 D_80062F9C; s32 D_80062FF0; void SysBgRender(void); -void func_80014A00(s32* dst, s32* src, s32 len); +void SysMemCopy32(s32* dst, s32* src, s32 len); u16* SysGetPointerToTextInKernWithBlockAndTextId(s32, s32, s32); s32 SysDecompKernStringWithF9(u16*, u16*); u16* SysGetPtrToKernBattleTxtWithId(s32); diff --git a/src/main/1F6B4.c b/src/main/1F6B4.c index b04ac71d..f45bf197 100644 --- a/src/main/1F6B4.c +++ b/src/main/1F6B4.c @@ -36,7 +36,7 @@ u32 D_80062EC8; s32 D_80062ECC; void SysBgRender(void); -void func_80014A00(s32* dst, s32* src, s32 len); +void SysMemCopy32(s32* dst, s32* src, s32 len); u16* SysGetPointerToTextInKernWithBlockAndTextId(s32, s32, s32); s32 SysDecompKernStringWithF9(u16*, u16*); u16* SysGetPtrToKernBattleTxtWithId(s32); diff --git a/src/main/btlinit.c b/src/main/btlinit.c index e375767e..09fb36ac 100644 --- a/src/main/btlinit.c +++ b/src/main/btlinit.c @@ -20,7 +20,7 @@ INCLUDE_ASM("asm/us/main/nonmatchings/btlinit", SysLoadUncompressImg); void SysLoadDrawSync(void) { DrawSync(0); } -void func_80014A00(s32* dst, s32* src, s32 len) { +void SysMemCopy32(s32* dst, s32* src, s32 len) { int i; for (i = 0; i < len >> 2; i++) { *dst++ = *src++;