From cb4cde99c46ecbc00c64f7b7765133773513e812 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Tue, 25 Aug 2026 01:40:14 +0200 Subject: [PATCH 01/19] bc_object4 functions cleanup --- include/battle.h | 2 + include/battle/bc_object4.h | 2 +- src/battle/bc_object4.c | 92 +++++++++++++++---------------------- 3 files changed, 39 insertions(+), 57 deletions(-) diff --git a/include/battle.h b/include/battle.h index 3c0d5872..bf0ef0e3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -197,6 +197,8 @@ typedef struct { u8 pad105[0x4A]; u8 unk14F; /* byte read by func_800AF988. */ u16 unk150[1]; + u8 pad152[0xE]; + u8 unk160[1]; } BattleEntityData; #define ENTITY_FLAG_1 1 diff --git a/include/battle/bc_object4.h b/include/battle/bc_object4.h index 6d306de3..67e4b8a5 100644 --- a/include/battle/bc_object4.h +++ b/include/battle/bc_object4.h @@ -8,7 +8,7 @@ extern void func_800A61CC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 extern void func_800A6218(s32 a0); extern void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3); extern void func_800A62B0(void); -extern void func_800A6310(s32 a0); +extern void func_800A6310(u8 a0); extern void func_800A63C0(s16 a, s16 b, s16 c, s16 d); extern void func_800A64E4(s32 a0, s32 a1); extern void func_800A6574(s32 value); diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 39162b16..3633cee4 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -4,8 +4,7 @@ #include "gamestate.h" #include "battle/bc_object4.h" -extern u8 D_800EE464[]; -extern u8 D_800EE38C[]; + extern u8 D_800EE9B3[]; void decrementItemByType(s32); @@ -32,13 +31,13 @@ void func_800A61CC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 arg5) { * * @param a0 Entity index. */ -void func_800A6218(s32 a0) { - u8 *base = (u8 *)&D_800ED148; - u8 *entity = base + a0 * 0xD0; - if (*(volatile s32 *)(entity + 0x8C) & 0x10) { - *(volatile s32 *)(entity + 0x8C) |= 0x200; - } else { - func_800A62DC(a0, 0x11, 0x80, 0); +void func_800A6218(s32 arg0) { + if ((D_800ED148.entities[arg0].controlFlags & CTRL_FLAG_10)) { + D_800ED148.entities[arg0].controlFlags |= 0x200; + } + + else { + func_800A62DC(arg0, 17, 128, 0); } } @@ -51,7 +50,7 @@ void func_800A6218(s32 a0) { * @param a3 Grid configuration. */ void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3) { - func_800A62DC(a0, 0x12, 0x80, 0); + func_800A62DC(a0, 18, 128, 0); } /** @@ -60,29 +59,15 @@ void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3) { * Calls func_800A62DC with a0=0, a1=0x41, a2=0x80, a3=0. */ void func_800A62B0(void) { - func_800A62DC(0, 0x41, 0x80, 0); + func_800A62DC(0, 65, 128, 0); } -/** - * @brief Forward display parameters to func_800D15B4. - * - * @param a0 First parameter passed through. - * @param a1 Second parameter passed through. - * @param a2 Third parameter passed through. - * @param a3 Fourth parameter passed through. - */ void func_800A62DC(s32 a0, s32 a1, s32 a2, s32 a3) { func_800D15B4(a0, a1, a2, a3); } -/** - * @brief Read a battle state byte from D_800ED148 offset 0x12EB. - * - * @return The byte value at D_800ED148[0x12EB]. - */ s32 func_800A62FC(void) { - volatile u8 *base = (u8 *)&D_800ED148; - return base[0x12EB]; + return D_800ED148.unk12EB; } /** @@ -94,30 +79,24 @@ s32 func_800A62FC(void) { * * @param a0 Value to store at D_800EEBC8. */ -void func_800A6310(s32 a0) { - s32 i = 0; - u8 *base = (u8 *)&D_800ED148; - u8 *status; - u8 *buf; - u8 *entry; - - base[0x131E] = 1; - D_800EEBC8 = a0; - status = base + 0x5C4; - base[0x1300] = 0; - base[0x5C1] = 0; - buf = (u8 *)&D_800EE4C0; - buf[0] = status[0]; - buf[1] = status[1]; - *(u16 *)(buf + 0x1C) = *(u16 *)(status + 4); - if (status[0x10] != 0) { - entry = base + 0x844; - do { - func_800A09D0(entry[0]); - i++; - func_800A5210(entry[0]); - entry += 0x18; - } while (i < status[0x10]); +void func_800A6310(u8 arg0) { + s32 i; + BattleEntry* entry; + SubEntry* subEntry; + + D_800ED148.unk131E = 1; + D_800EEBC8 = arg0; + D_800ED148.unk1300 = 0; + D_800ED148.unk5C1 = 0; + entry = D_800ED148.entries; + D_800EE4C0.unk0 = entry->unk0; + D_800EE4C0.unk1 = entry->unk1; + D_800EE4C0.statusCode = entry->unk4; + + for (i = 0; i < entry->unk10; i++) { + subEntry = &D_800ED148.Array844[i]; + func_800A09D0(subEntry->unk0); + func_800A5210(subEntry->unk0); } } @@ -716,8 +695,9 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7EE0); * @param a1 Offset to add to base. * @return Byte at (a0 + a1 + 0x160) multiplied by 10. */ -s32 func_800A7FB4(s32 a0, s32 a1) { - return *(u8 *)(a0 + a1 + 0x160) * 10; + +s32 func_800A7FB4(BattleEntityData* arg0, s32 arg1) { + return arg0->unk160[arg1] * 10; } INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7FD0); @@ -734,11 +714,11 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A84CC); * @brief Call func_800A84CC for each of 7 battle entities. */ void func_800A853C(void) { - s32 i = 0; - do { + s32 i; + + for (i = 0; i < 7; i++) { func_800A84CC(i); - i++; - } while (i < 7); + } } INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8578); From 1329a76b609c025132dc30f8b18da848becd467e Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Tue, 25 Aug 2026 22:34:44 +0200 Subject: [PATCH 02/19] cleanup functions bc_object4 --- include/battle.h | 32 +++-- include/battle/bc_object4.h | 10 +- include/gamestate.h | 5 +- src/battle/bc_object4.c | 252 +++++++++++++----------------------- 4 files changed, 119 insertions(+), 180 deletions(-) diff --git a/include/battle.h b/include/battle.h index bf0ef0e3..24bc5c75 100644 --- a/include/battle.h +++ b/include/battle.h @@ -180,9 +180,19 @@ typedef struct { u8 padC[4]; volatile s32 unk10; // volatile because func_800A5688, func_800A559C volatile s32 unk14; // volatile because func_800A5688, func_800A559C - u8 pad18[0xA9]; - u8 unkC1; - u8 padC2[0x35]; + u8 pad18[10]; + s32 unk24[7]; + u8 pad40[0x48]; + u8 unk88; + u8 unk89; + u8 unk8A; + u8 pad8B[0x36]; + u8 unkC1; + u8 padC2[5]; + u8 unkC7; + u8 unkC8; + u8 padC9[0x2D]; + u8 unkF6; u8 immunityFlags; /* bit 0 forces status bit 0x40 clear, bit 1 forces flags bit 0x2000 clear (read by @c func_8009AFF0). */ u8 unkF8; u8 unkF9; @@ -242,7 +252,7 @@ typedef struct { u8 unkE; u8 entityRef; BattleEntityData** entityData; - s32 pad14; // func_800A559C to fix + s32 pad14; s32 flags; s32 flagsBackup; s32 unk20; @@ -421,7 +431,8 @@ typedef struct { /* 0x085C */ u8 pad85C[0x0CDC - 0x085C]; /* 0x0CDC */ u8 unkCDC; /* 0x0CDC */ u8 unkCDD; - /* 0x0CDE */ u8 padCDE[0x0CE4 - 0x0CDE]; + /* 0x0CDE */ u8 padCDE[0x0CE3 - 0x0CDE]; + /* 0x0CE3 */ u8 unkCE3; /* 0x0CE4 */ BattleVec3u unkCE4[8]; /**< 8-entry x/y/z position table (read by @c func_8009A528). */ /* 0x0D14 */ u8 unkD14[8]; /**< Hit-type byte table (8 entries). */ /* 0x0D1C */ u8 padD1C[0x0D5C - 0x0D1C]; @@ -438,7 +449,8 @@ typedef struct { /* 0x1290 */ s16 unk1290; /* 0x1292 */ s16 unk1292; /* 0x1294 */ s16 unk1294; - /* 0x1296 */ u8 pad1296[0x12B8 - 0x1296]; + /* 0x1296 */ s16 unk1296; + /* 0x1298 */ u8 pad1298[0x12B8 - 0x1298]; /* 0x12B8 */ u16 array12B8[7]; /* 0x12C6 */ u8 pad12C7[0x12CC - 0x12C6]; /* 0x12CC */ Struct_12CC array12CC[1]; /* used in func_8009D594 */ @@ -456,7 +468,7 @@ typedef struct { /* 0x12EC */ u8 unk12EC; /**< Misc state byte (init to 0xFF). */ /* 0x12ED */ u8 volatile unk12ED; /**< Misc state byte. */ /* 0x12EE */ u8 volatile unk12EE; /**< Misc state byte. */ - /* 0x12EF */ u8 unk12EF; + /* 0x12EF */ u8 volatile unk12EF; /* 0x12EF */ u8 unk12F0; /* 0x12EF */ u8 pad12F1; /* 0x12EF */ u8 unk12F2; @@ -658,7 +670,7 @@ typedef struct { /* 0x1B4 */ u16 abilityValue; /* 0x1B6 */ u16 atkStatusHit; /**< Attack status hit chance. */ /* 0x1B8 */ u8 level; /**< Battle level (from findCharXpLevel). */ - /* 0x1B9 */ u8 pad1B9; + /* 0x1B9 */ u8 unk1B9; /* 0x1BA */ u8 classId; /**< Entity-class index into the @c D_80078E00 ability tables (stride 12 at @c 0x35C1). */ /* 0x1BB */ u8 stats[8]; /**< Battle stats: STR, VIT, MAG, SPR, SPD, ?, hit (0x1C0), eva (0x1C1). 0x1C2 = ? */ /* 0x1C3 */ u8 characterId; @@ -954,7 +966,8 @@ typedef struct { typedef struct { u8 unk0; u8 unk1; - u8 pad2[3]; + u8 pad2[2]; + u8 unk4; u8 unk5; u8 pad6[3]; u8 unk9; @@ -1168,6 +1181,7 @@ extern u8 D_800E3CBC[]; extern u8 D_800E3CE8; extern BattleSystem D_800ED148; extern BattleCmdBuf D_800EE4C0; +extern u8 D_800EE9B3[]; extern BattleAnimTable D_800EE9E8; extern u8 D_800EEBA8[]; extern u8 D_800EEBB0; diff --git a/include/battle/bc_object4.h b/include/battle/bc_object4.h index 67e4b8a5..0d079935 100644 --- a/include/battle/bc_object4.h +++ b/include/battle/bc_object4.h @@ -10,15 +10,15 @@ extern void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3); extern void func_800A62B0(void); extern void func_800A6310(u8 a0); extern void func_800A63C0(s16 a, s16 b, s16 c, s16 d); -extern void func_800A64E4(s32 a0, s32 a1); -extern void func_800A6574(s32 value); +extern void func_800A64E4(s32 a0, u16 a1); +extern void func_800A6574(u8 value); extern void func_800A6724(void); extern s32 func_800A6DD8(void); extern void func_800A7518(s32 idx); extern void func_800A779C(s32 a0); -extern s32 func_800A7A44(s32 a0); -extern s32 func_800A7A8C(s32 idx); -extern s32 func_800A7AB8(s32 a0); +extern u8 func_800A7A44(s32 a0); +extern u8 func_800A7A8C(s32 idx); +extern u8 func_800A7AB8(s32 a0); extern void func_800A853C(void); extern void func_800A890C(s32 a0); extern s32 func_800A8AFC(s32 a0); diff --git a/include/gamestate.h b/include/gamestate.h index 19316b3f..fc2e9793 100644 --- a/include/gamestate.h +++ b/include/gamestate.h @@ -341,14 +341,15 @@ typedef struct { /* 0x00 */ PartyData party; /**< Party/gil/Griever (32 bytes). */ /* 0x20 */ LimitBreakData limitBreaks; /**< Limit break progress (16 bytes). */ /* 0x30 */ u8 battleOrder[32]; /**< Battle item menu ordering. */ - /* 0x50 */ ItemSlot itemSlots[ITEM_SLOT_COUNT]; /**< Item inventory (198 slots). */ + /* 0x50 */ ItemSlot itemSlots[198]; /**< Item inventory (198 slots). */ /* 0x1DC */ volatile s32 frameCounter; /**< @c 0xCD0: game frame counter; incremented ~every 12 frames by @ref VsyncHandler (VSync ISR). */ /* 0x1E0 */ volatile s32 countdownTimer; /**< @c 0xCD4: battle countdown timer. Set/get by field event opcodes, decremented by @ref VsyncHandler while nonzero; battle & color code read it as active / camera-shake state. */ /* 0x1E4 */ u8 pad1E4[0x04]; /* 0x1E8 */ s32 fieldCDC; /**< Snapshotted by @c func_800BFBBC into @c FieldVars.field14. */ /* 0x1EC */ u16 fieldCE0; /**< Snapshotted by @c func_800BFBBC into @c FieldVars.field18. */ /* 0x1EE */ u16 fieldCE2; /**< Snapshotted by @c func_800BFBBC into @c FieldVars.field1A. */ - /* 0x1F0 */ u8 pad1F0[0x28]; /**< Battle vars / misc (continued). */ + /* 0x1F0 */ u8 pad1F0[0x20]; /**< Battle vars / misc (continued). */ + /* 0x210 */ u32 array210[2]; /* 0x218 */ u32 array[1]; /* used in func_8009F52C */ /* 0x21C */ u8 pad21C[0x10]; /**< Battle vars / misc (continued). */ /* 0x22C */ u16 fieldD20; /**< Unknown (zeroed on save init). */ diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 3633cee4..9010d090 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -4,14 +4,8 @@ #include "gamestate.h" #include "battle/bc_object4.h" +extern void func_800E1850(void); -extern u8 D_800EE9B3[]; - -void decrementItemByType(s32); -s32 func_800AA4E8(void); -void func_800E1850(void); -s32 func_8009B74C(s32, s32); /* overlay-conflict: also in field_engine */ -void func_800A8578(void); void func_800A6184(s32 arg0, s32 arg1, s32 arg2, u16 arg3) { @@ -100,20 +94,11 @@ void func_800A6310(u8 arg0) { } } -/** - * @brief Store four halfword values to D_800ED148 at offsets 0x1290-0x1296. - * - * @param a First halfword (offset 0x1290). - * @param b Second halfword (offset 0x1292). - * @param c Third halfword (offset 0x1294). - * @param d Fourth halfword (offset 0x1296). - */ -void func_800A63C0(s16 a, s16 b, s16 c, s16 d) { - u8 *base = (u8 *)&D_800ED148; - *(s16 *)(base + 0x1290) = a; - *(s16 *)(base + 0x1292) = b; - *(s16 *)(base + 0x1296) = d; - *(s16 *)(base + 0x1294) = c; +void func_800A63C0(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { + D_800ED148.unk1290 = arg0; + D_800ED148.unk1292 = arg1; + D_800ED148.unk1296 = arg3; + D_800ED148.unk1294 = arg2; } INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A63DC); @@ -128,18 +113,16 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A63DC); * @param a0 Mode flag (0 = player-initiated, non-zero = triggered). * @param a1 Sound parameter (masked to u16 in mode 0). */ -void func_800A64E4(s32 a0, s32 a1) { - if (a0 == 0) { - u8 *base = (u8 *)&D_800ED148; - func_800B0754(base[0xF], 0xED, base[0x1324], (u16)a1); - decrementItemByType(base[0x1324] + 0x65); - func_8009AF14((s32)func_800E1850); - } else { - s32 result = func_800AA4E8(); - u8 *base = (u8 *)&D_800ED148; - func_800B0754(base[0xF], 0xEE, base[0x1324], result); - func_8009AE08(8); +void func_800A64E4(s32 arg0, u16 arg1) { + if (arg0 == 0) { + func_800B0754(D_800ED148.entities[0].entityRef, 237, D_800ED148.unk1324, arg1); + decrementItemByType(D_800ED148.unk1324 + 0x65); + func_8009AF14(func_800E1850); + return; } + + func_800B0754(D_800ED148.entities[0].entityRef, 238, D_800ED148.unk1324, func_800AA4E8()); + func_8009AE08(8); } /** @@ -147,9 +130,8 @@ void func_800A64E4(s32 a0, s32 a1) { * * @param value Byte value to store. */ -void func_800A6574(s32 value) { - volatile u8 *base = (u8 *)&D_800ED148; - base[0x12EF] = value; +void func_800A6574(u8 arg0) { + D_800ED148.unk12EF = arg0; } void func_800A6588(void) { @@ -159,20 +141,9 @@ void func_800A6588(void) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A65B0); -s32 func_8009A514(s32, s32); - -/** - * @brief Check entity availability and mark as active. - * - * Calls func_8009A514 with D_800ED148[0xCE3] and (7 - a0). - * If the result is non-zero, sets D_800ED148[a0 + 0xD5C] to 1. - * - * @param a0 Entity slot index. - */ -void func_800A66D0(s32 a0) { - u8 *base = (u8 *)&D_800ED148; - if (func_8009A514(base[0xCE3], 7 - a0) != 0) { - base[a0 + 0xD5C] = 1; +void func_800A66D0(s32 arg0) { + if (func_8009A514(D_800ED148.unkCE3, 7 - arg0) != 0) { + D_800ED148.unkD5C[arg0] = 1; } } @@ -184,20 +155,16 @@ void func_800A66D0(s32 a0) { * and set active status. */ void func_800A6724(void) { - s32 i = 7; - s32 base = (s32)&D_800ED148; - base += 7; -top: - *(u8 *)(base + 0xD5C) = 0; - i--; - base--; - if (i >= 0) goto top; - - i = 0; - do { + s32 i; + + for (i = 0; i < 8; i++) { + D_800ED148.unkD5C[i] = 0; + } + + + for (i = 0; i < 8; i++) { func_800A66D0(i); - i++; - } while (i < 8); + } } INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6780); @@ -253,21 +220,14 @@ void func_800A6AE0(void) { * @return 1 if any qualifying entity has the flag set, 0 otherwise. */ s32 func_800A6B08(void) { - s32 i = 3; - volatile u8 *base = (volatile u8 *)&D_800ED148; - u8 *entry = (u8 *)base + 3 * 0xD0; - -top: - if (!(*(u16 *)(entry + 0x90) & 1)) { - u8 *ptr = *(u8 **)(entry + 0x10); - ptr = *(u8 **)ptr; - if (*(u8 *)(ptr + 0xFE) & 4) { + s32 i; + + for (i = 3; i < 7; i++) { + if (!(D_800ED148.entities[i].status & 1) && (*D_800ED148.entities[i].entityData)->unkFE & 4) { return 1; } } - i++; - entry += 0xD0; - if (i < 7) goto top; + return 0; } @@ -283,23 +243,16 @@ s32 func_800A6B08(void) { * @param a1 Value to return if all entities pass the check. * @return 0 if any qualifying entity lacks the flag, a1 if all pass. */ -s32 func_800A6B6C(s32 a0, s32 a1) { - s32 i = 3; - volatile u8 *base = (volatile u8 *)&D_800ED148; - u8 *entry = (u8 *)base + 3 * 0xD0; - -top: - if (!(*(u16 *)(entry + 0x90) & 1)) { - u8 *ptr = *(u8 **)(entry + 0x10); - ptr = *(u8 **)ptr; - if (!(*(u8 *)(ptr + 0xFE) & a0)) { +s32 func_800A6B6C(s32 arg0, s32 arg1) { + s32 i; + + for (i = 3; i < 7; i++) { + if (!(D_800ED148.entities[i].status & 1) && !((*D_800ED148.entities[i].entityData)->unkFE & arg0)) { return 0; } } - i++; - entry += 0xD0; - if (i < 7) goto top; - return a1; + + return arg1; } /** @@ -316,15 +269,19 @@ s32 func_800A6BD0(s32 a0) { if (a0 == 1) { return 0; } + if (a0 == 0) { - if (func_8009B74C(0x80, 0xFF) != 0) { + if (func_8009B74C(128, 255)) { return 3; } + return 4; } - if (func_8009B74C(0x80, 0xFF) != 0) { + + if (func_8009B74C(128, 255)) { return 1; } + return 2; } @@ -377,16 +334,8 @@ s32 func_800A6FB8(void) { return func_8009B15C() % 100 + 1; } -/** - * @brief Add func_800A6E2C() result minus 200 to input. - * - * @param a0 Input value to add to. - * @return a0 + func_800A6E2C() - 0xC8. - */ -s32 func_800A700C(s32 a0) { - s32 result = func_800A6E2C(); - result -= 0xC8; - return result + a0; +s32 func_800A700C(s32 arg0) { + return func_800A6E2C() - (200 - arg0); } /** @@ -421,9 +370,10 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7080); */ s32 func_800A7154(void) { s32 val = func_800A7080(); - if (val >= 101) { + if (val > 100) { return 100; } + return val; } @@ -436,13 +386,12 @@ s32 func_800A7154(void) { * * @param slot Battle slot to clear. */ -void func_800A7188(BattleEntity *slot) { - u8 *p = (u8 *)slot; - p[0x8A] = 0; - p[0x89] = 0; - p[0x88] = 0; - p[0xC7] = 0; - p[0xC8] = 0; +void func_800A7188(BattleEntityData* arg0) { + arg0->unk8A = 0; + arg0->unk89 = 0; + arg0->unk88 = 0; + arg0->unkC7 = 0; + arg0->unkC8 = 0; } /** @@ -454,14 +403,12 @@ void func_800A7188(BattleEntity *slot) { * * @param slot Battle slot whose mid-region words are zeroed. */ -void func_800A71A0(BattleEntity *slot) { - s32 i = 7; - u8 *base = (u8 *)slot + 0x1C; - top: - *(s32 *)(base + 0x24) = 0; - i--; - base -= 4; - if (i >= 0) goto top; +void func_800A71A0(BattleEntityData* arg0) { + s32 i; + + for (i = 0; i < 8; i++) { + arg0->unk24[i] = 0; + } } INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A71C0); @@ -589,13 +536,17 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A774C); * * @param a0 1-based bit position to set. If 0, does nothing. */ -void func_800A779C(s32 a0) { - if (a0 != 0) { - s32 val = a0 - 1; - s32 q = val / 32; - s32 r = val - q * 32; - s32 base = (s32)&g_gameState; - *(s32 *)(base + q * 4 + 0xD04) |= (1 << r); +void func_800A779C(s32 arg0) { + s32 idx; + s32 bit; + s32 temp_v0; + + temp_v0 = arg0 - 1; + if (arg0 != 0) { + idx = temp_v0 / 32; + bit = temp_v0 - (idx * 32); + + g_gameState.mainData.array210[idx] |= 1 << bit; } } @@ -617,11 +568,8 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A79A0); * @param a0 Entity index (stride 0x1D0 in @c g_battleChars). * @return The @c field09 byte for that entity's class. */ -s32 func_800A7A44(s32 a0) { - u8 *table = (u8 *)&g_gfData; - u8 *base = (u8 *)&g_battleChars; - s32 val = *(u8 *)(base + a0 * 464 + 0x1BA); - return *(u8 *)(table + val * 12 + 0x35C1); +u8 func_800A7A44(s32 arg0) { + return D_80078E00.array35BD[g_battleChars.chars[arg0].classId].unk4; } /** @@ -630,12 +578,8 @@ s32 func_800A7A44(s32 a0) { * @param idx Entity index. * @return Byte at offset 0x1B9 within the entity entry. */ -s32 func_800A7A8C(s32 idx) { - u8 *base = (u8 *)&g_battleChars; - u8 *entry; - asm(""); - entry = base + idx * 0x1D0; - return entry[0x1B9]; +u8 func_800A7A8C(s32 arg0) { + return g_battleChars.chars[arg0].unk1B9; } /** @@ -647,12 +591,8 @@ s32 func_800A7A8C(s32 idx) { * @param a0 Entity index. * @return Byte value at the end of the pointer chain. */ -s32 func_800A7AB8(s32 a0) { - s32 base = (s32)&D_800ED148; - s32 entry = base + a0 * 208; - s32 ptr = *(s32 *)(entry + 0x10); - ptr = *(s32 *)ptr; - return *(u8 *)(ptr + 0xF6); +u8 func_800A7AB8(s32 arg0) { + return (*D_800ED148.entities[arg0].entityData)->unkF6; } /** @@ -687,14 +627,6 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7CEC); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7D8C); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7EE0); - -/** - * @brief Look up a byte and multiply by 10. - * - * @param a0 Base pointer. - * @param a1 Offset to add to base. - * @return Byte at (a0 + a1 + 0x160) multiplied by 10. - */ s32 func_800A7FB4(BattleEntityData* arg0, s32 arg1) { return arg0->unk160[arg1] * 10; @@ -762,20 +694,12 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A89B8); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8A48); -/** - * @brief Initialize 3 animation entries for an entity in g_battleChars. - * - * Computes the entity base at g_battleChars + a0 * 0x1D0, then calls - * func_800A8A48 three times to set up entries 0 (id=0x23), 1 (id=0x24), - * and 2 (id=0). - * - * @param a0 Entity index (stride 0x1D0 in g_battleChars). - * @return Always 2. - */ -s32 func_800A8AFC(s32 a0) { - u8 *entry = (u8 *)&g_battleChars + a0 * 0x1D0; - func_800A8A48(entry, 0, 0x23, 0); - func_800A8A48(entry, 1, 0x24, 0); - func_800A8A48(entry, 2, 0, 0); +s32 func_800A8AFC(s32 arg0) { + BattleCharData* ptr = &g_battleChars.chars[arg0]; + + func_800A8A48(ptr, 0, 35, 0); + func_800A8A48(ptr, 1, 36, 0); + func_800A8A48(ptr, 2, 0, 0); + return 2; -} +} \ No newline at end of file From 9788dd37f88d2cd507ebe0d9d10e8dbd40065ce2 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Wed, 26 Aug 2026 03:05:15 +0200 Subject: [PATCH 03/19] added func_800A7FD0 --- include/battle.h | 30 ++++++++++++---- src/battle/bc_object4.c | 80 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 101 insertions(+), 9 deletions(-) diff --git a/include/battle.h b/include/battle.h index 24bc5c75..c2fe2f47 100644 --- a/include/battle.h +++ b/include/battle.h @@ -180,15 +180,31 @@ typedef struct { u8 padC[4]; volatile s32 unk10; // volatile because func_800A5688, func_800A559C volatile s32 unk14; // volatile because func_800A5688, func_800A559C - u8 pad18[10]; + s32 unk18; + s32 unk1C; + u8 pad20[4]; s32 unk24[7]; - u8 pad40[0x48]; + u8 pad40[4]; + u16 unk44[8]; + u8 pad54[0x7C - 0x54]; + volatile s32 unk7C; + u16 unk80; + u8 pad82[6]; u8 unk88; u8 unk89; u8 unk8A; - u8 pad8B[0x36]; - u8 unkC1; - u8 padC2[5]; + u8 pad8B[5]; + u8 unk90[40]; + u8 padB8[0xBB - 0xB8]; + u8 unkBB; + u8 unkBC; + u8 padBD[0xC1 - 0xBD]; + u8 unkC1; + u8 unkC2; + u8 padC3; + u8 unkC4; + u8 padC5; + u8 unkC6; u8 unkC7; u8 unkC8; u8 padC9[0x2D]; @@ -552,7 +568,9 @@ typedef struct { /** @brief 0x47-byte sub-entry in @c BattleAnimTable.subEntries. */ typedef struct { drawSlot array0[4]; /* size related to the index used in func_800A3094 */ - u8 pad10[0x36]; + u8 unk10; + u8 pad11[0x2F]; + u8 unk40[6]; u8 unk46; } BattleAnimSubEntry; /* 0x47 */ diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 9010d090..e7eb47f6 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -368,8 +368,8 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7080); * * @return The result of func_800A7080, capped at 100. */ -s32 func_800A7154(void) { - s32 val = func_800A7080(); +s32 func_800A7154(s32 arg0) { + s32 val = func_800A7080(arg0); if (val > 100) { return 100; } @@ -632,7 +632,81 @@ s32 func_800A7FB4(BattleEntityData* arg0, s32 arg1) { return arg0->unk160[arg1] * 10; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7FD0); +void func_800A7FD0(s32 arg0, s32 arg1, s32 arg2) { + s32 temp_v0; + s32 i; + BattleEntityData* temp_s1; + BattleEntityData* temp_s3; + + + temp_s3 = *D_800ED148.entities[arg0].entityData; + D_800EE9E8.subEntries[arg0 - 3].unk10 = 0; + temp_s1 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; + temp_s1->unkBC = func_800A7154(arg1); + temp_s1->unk7C = 17; + if (temp_s3->immunityFlags & 0x10) { + temp_s1->unk7C |= 0x2000; + } + + if (temp_s3->immunityFlags & 8) { + temp_s1->unk7C |= 0x8000; + } + + if (temp_s3->unkFE & 0x40) { + temp_s1->unk7C |= 0x10000; + } + + if (func_800A7AF4(arg0) != 0) { + temp_s1->unk7C |= 0x20; + } + + temp_s1->unkBB = arg2; + temp_v0 = func_800A7CEC(temp_s1->unkBC, temp_s3); + temp_s1->unk18 = temp_v0; + temp_s1->unk1C = temp_v0; + temp_s1->unkC4 = 0; + temp_s1->unkC2 = 0; + temp_s1->unk80 = 0; + temp_s1->unk8 = 0; + temp_s1->unkC6 = 100; + for (i = 0; i < 8; i++) { + temp_s1->unk44[i] = func_800A7FB4(temp_s3, i); + } + + for (i = 0; i < 40; i++) { + temp_s1->unk90[i] = func_800A7EE0(temp_s3, i); + } + + if (temp_s3->immunityFlags & 1) { + temp_s1->unk90[6] = 255; + temp_s1->unk80 |= 0x40; + } + + if (temp_s3->immunityFlags & 2) { + temp_s1->unk8 |= 0x2000; + } + + if (temp_s3->immunityFlags & 0x20) { + temp_s1->unk8 |= 0x80; + } + + if (temp_s3->immunityFlags & 0x80) { + temp_s1->unk8 |= 0x20; + } + + if (temp_s3->immunityFlags & 0x40) { + temp_s1->unk8 |= 0x40; + } + + for (i = 0; i < 6; i++) { + D_800EE9E8.subEntries[arg0 - 3].unk40[i] = 10; + } + + func_800A7188(temp_s1); + func_800A71A0(temp_s1); + func_800A554C(arg0); + func_800A559C(arg0); +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A82A0); From 0a4b6ecea644d829a664ea289cf7add15a55e849 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Wed, 26 Aug 2026 03:53:02 +0200 Subject: [PATCH 04/19] added func_800A6EBC and func_800A6F64 --- src/battle/bc_object4.c | 43 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index e7eb47f6..93f74038 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -311,16 +311,22 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6E2C); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6EBC); -/** - * @brief Compute random percentage clamped to [1, 100]. - * - * Gets a random number from func_8009B15C, divides by func_800A6E2C - * result, takes the remainder. Clamps: 0 becomes 1, values above - * 100 become 100. - * - * @return Clamped remainder in range [1, 100]. - */ -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6F64); +s32 func_800A6F64(void) { + s32 result; + + result = func_8009B15C() % func_800A6E2C(); + if (result == 0) { + return 1; + } + + else { + if (result > 100) { + return 100; + } + + return result; + } +} /** * @brief Generate random value in range [1, 100]. @@ -755,14 +761,15 @@ void func_800A890C(s32 a0) { } while (i >= 0); } -/** - * @brief Check bit 0 of flags for entities 3-6 and call handler. - * - * Iterates over entities at indices 3 through 6 in the D_800ED148 table - * (stride 0xD0). For each entity whose flags word at offset 0x8C has - * bit 0 set, calls func_800A890C with the entity index. - */ -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8948); +void func_800A8948(void) { + s32 i; + + for (i = 0; i < 4; i++) { + if (D_800ED148.entities[i+3].controlFlags & 1) { + func_800A890C(i + 3); + } + } +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A89B8); From 2a3a10bacf37a5e7d2d8fe8148a2d7d86ad5f838 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Wed, 26 Aug 2026 04:03:23 +0200 Subject: [PATCH 05/19] added func_800A6780 --- src/battle/bc_object4.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 93f74038..7bafaba6 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -167,7 +167,15 @@ void func_800A6724(void) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6780); +void func_800A6780(s32 arg0) { + + if (!(D_800ED148.entities[arg0].status & 1) && !(D_800ED148.entities[arg0].status & 4)) { + D_800ED148.entities[arg0].unk24 = D_800ED148.entities[arg0].unk20; + return; + } + + D_800ED148.entities[arg0].unk24 = 0; +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A67FC); From 276a1b644dba22af1172bfbdab8982f512c9b4ca Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Wed, 26 Aug 2026 22:27:07 +0200 Subject: [PATCH 06/19] added func_800A7934 --- src/battle/bc_object4.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 7bafaba6..930dea04 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -568,7 +568,17 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A77E8); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7884); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7934); +void func_800A7934(void) { + s32 i; + + for (i = 0; i < 3; i++) { + GameState* gs = &g_gameState; + if (D_800ED148.entities[i].linkedIdx != 255) { + CharacterData* character = gs->chars; + character[g_gameState.mainData.party.party[i]].currentHp = D_800ED148.entities[i].unk28; + } + } +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A79A0); From 233a00399aa1d3f6ee74b2085c5b2e5bab87a14d Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Fri, 28 Aug 2026 05:05:17 +0200 Subject: [PATCH 07/19] added many bc_object4 functions --- include/battle.h | 40 ++-- src/battle/bc_object4.c | 411 +++++++++++++++++++++++++++++++++++----- 2 files changed, 394 insertions(+), 57 deletions(-) diff --git a/include/battle.h b/include/battle.h index c2fe2f47..42307983 100644 --- a/include/battle.h +++ b/include/battle.h @@ -207,7 +207,9 @@ typedef struct { u8 unkC6; u8 unkC7; u8 unkC8; - u8 padC9[0x2D]; + u8 padC9[0x2B]; + u8 unkF4; + u8 unkF5; u8 unkF6; u8 immunityFlags; /* bit 0 forces status bit 0x40 clear, bit 1 forces flags bit 0x2000 clear (read by @c func_8009AFF0). */ u8 unkF8; @@ -459,8 +461,7 @@ typedef struct { /* 0x1103 */ TaskLink taskLinks[16]; /**< Task queue link table (16 × 4 bytes). */ /* 0x1143 */ u8 pad1143; /* 0x1144 */ TaskEntry taskData[16]; /**< Task queue data slots (16 × 16 bytes). */ - /* 0x1244 */ Struct_1244 unk1244[1]; - /* 0x125C */ u8 pad125C[0x128C - 0x125C]; + /* 0x1244 */ Struct_1244 unk1244[3]; /* 0x128C */ callback_t unk128C; /**< Cached userData for callback. */ /* 0x1290 */ s16 unk1290; /* 0x1292 */ s16 unk1292; @@ -555,16 +556,20 @@ typedef struct { typedef struct { u8 id; /* lookup key / command byte. */ s8 value; /* signed value byte. */ - u8 pad2[3]; + u8 unk2; + u8 unk3; + u8 unk4; } BattleAnimSlot; /** this struct might be related to draw function. Unk0 accessed in func_800A3094 */ typedef struct { u8 unk0; - u8 pad[3]; + u8 unk1; + u8 pad2[2]; } drawSlot; + /** @brief 0x47-byte sub-entry in @c BattleAnimTable.subEntries. */ typedef struct { drawSlot array0[4]; /* size related to the index used in func_800A3094 */ @@ -585,7 +590,7 @@ typedef struct { /** @brief Battle magic slot entry (5 bytes). */ typedef struct { u8 unk0; - u8 unk1; + s8 unk1; u8 unk2; u8 unk3; u8 unk4; @@ -659,9 +664,17 @@ typedef struct { u8 freeSpace[4]; } BattleOtBuf; +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; +} BattleUnkSlot; + /** @brief Battle character render data (g_battleChars, stride 0x1D0 = 464 bytes). */ typedef struct { - /* 0x000 */ u8 pad0[0x14]; + /* 0x000 */ u8 pad0[0x008 - 0x000]; + /* 0x008 */ BattleUnkSlot unkSlots[3]; /* 0x014 */ u16 unk14; /* 0x016 */ u16 unk16; /* 0x018 */ s16 currentHp; /**< Current HP in battle. */ @@ -786,7 +799,7 @@ typedef struct { * Only byte 0 (abilityId) is read by the known callers. */ typedef struct { - u8 pad0; /* 0x3938 */ + u8 unk0; /* 0x3938 */ u8 abilityId; /**< 0x3939: Ability ID byte (input to ability flag funcs) */ u8 unk2; /* 0x393A */ u8 unk3; /* 0x393B */ @@ -1008,7 +1021,9 @@ typedef struct { typedef struct { u8 unk0; - u8 pad[7]; + u8 pad1; + u8 unk2; + u8 pad3[5]; } structE8; /** @@ -1028,8 +1043,8 @@ typedef struct { /* 0x00D8 */ u8 pad00D8[0x00DC - 0x00D8]; /* 0x00DC */ s32 unk4C0CArg; /**< resolveKernelPtr arg paired with unk4C0C[]. */ /* 0x00E0 */ u8 pad00E0[0x00E8 - 0x00E0]; - /* 0x00E8 */ structE8 unkE8[1]; - /* 0x00F0 */ u8 pad00F0[0x0220 - 0x00F0]; + /* 0x00E8 */ structE8 unkE8[36]; + /* 0x0208 */ u8 pad0208[0x0220 - 0x0208]; /* 0x0220 */ BattleSpellRow spells[1]; /**< 60-byte stride (size unknown, index past). */ /* 0x025C */ u8 pad025C[0x0F78 - 0x025C]; /* 0x0F78 */ BattleSceneRow rows132[1]; /**< 132-byte stride (size unknown, index past). */ @@ -1181,7 +1196,9 @@ extern BattleConfig g_battleConfig; extern s16 D_8005F11C; extern u8 D_80077E58; extern u8 D_80077E92; +extern u8 D_80077E59; extern u8 D_800786D9; +extern u8 D_80078DF8; extern BattleSceneData D_80078E00; extern u16 D_80082C0A; extern u8 D_80082C0F; @@ -1199,7 +1216,6 @@ extern u8 D_800E3CBC[]; extern u8 D_800E3CE8; extern BattleSystem D_800ED148; extern BattleCmdBuf D_800EE4C0; -extern u8 D_800EE9B3[]; extern BattleAnimTable D_800EE9E8; extern u8 D_800EEBA8[]; extern u8 D_800EEBB0; diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 930dea04..52feafe1 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -177,11 +177,51 @@ void func_800A6780(s32 arg0) { D_800ED148.entities[arg0].unk24 = 0; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A67FC); +void func_800A67FC(s32 arg0) { + s32 i; + + if (arg0 == 0) { + for (i = 0; i < 3; i++) { + if (!(D_800ED148.entities[i].status & 1)) { + D_800ED148.entities[i].flags |= 0x800000; + g_battleChars.chars[i].unk188 = D_800ED148.entities[i].flags; + } + } + } + + else { + for (i = 3; i < 7; i++) { + if (!(D_800ED148.entities[i].status & 1)) { + D_800ED148.entities[i].flags |= 0x800000; + } + } + } +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A68AC); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A69BC); +void func_800A69BC(void) { + switch (D_800ED148.unk1308) { + case 1: + func_8009AF3C(getMenuString(0x2E), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + break; + + case 2: + func_8009AF3C(getMenuString(0x2D), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + break; + + case 3: + func_8009AF3C(getMenuString(0x2C), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + break; + + case 4: + func_8009AF3C(getMenuString(0x2F), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + break; + + default: + return; + } +} /** * @brief Process entities 1 and 2, then call func_800A67FC with 0. @@ -293,9 +333,70 @@ s32 func_800A6BD0(s32 a0) { return 2; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6C34); +s32 func_800A6C34(void) { + s32 var_s0; + s32 var_s1; + + + if (D_80082C0A & 0x80) { + return 0; + } + + if (D_80082C0A & 0x20) { + return 1; + } + + if (D_80082C0A & 0x40) { + return 2; + } + + var_s0 = func_800A6B6C(1, 20); + var_s0 += func_800A6B6C(2, -20); + var_s0 += func_8009B15C(); + + if (D_80078DF8 & 1) { + var_s0 -= 20; + } + + var_s1 = 0; + if (var_s0 > 19) { + var_s1 = 2; + if (var_s0 < 236) { + var_s1 = 1; + } + } + + if ((D_80078DF8 & 1) && (var_s1 == 2)) { + var_s1 = 1; + } + + if ((func_800A6B08() != 0) && (var_s1 == 0)) { + var_s1 = 1; + } + + return func_800A6BD0(var_s1); +} + +void func_800A6D30(void) { + D_800ED148.unk1308 = func_800A6C34(); + switch (D_800ED148.unk1308) { + case 1: + func_800A6A88(); + return; + + case 2: + func_800A6A58(); + return; -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6D30); + case 3: + func_800A6AE0(); + return; + + case 4: + func_800A6AB0(); + return; + } +} s32 func_800A6DD8(void) { s32 i; @@ -315,9 +416,56 @@ s32 func_800A6DD8(void) { return var_v1 / var_a2; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6E2C); +s32 func_800A6E2C(void) { + s32 result; -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A6EBC); + result = func_800A6DD8(); + + if (func_8009B15C() & 1) { + result += (result / 5); + } + + else { + result -= (result / 5); + } + + if (result < 1) { + return 1; + } + + if (result > 100) { + return 100; + } + + return result; +} + +s32 func_800A6EBC(void) { + s32 result; + s32 temp_v0; + + result = func_800A6DD8(); + + if (func_8009B15C() & 1) { + temp_v0 = func_8009B15C(); + result += (temp_v0 - (temp_v0 / 4 * 4)); + } + + else { + temp_v0 = func_8009B15C(); + result -= (temp_v0 - (temp_v0 / 4 * 4)); + } + + if (result < 1) { + return 1; + } + + if (result > 65) { + return 65; + } + + return result; +} s32 func_800A6F64(void) { s32 result; @@ -370,18 +518,41 @@ s32 func_800A703C(s32 a0) { return limit; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7080); +s32 func_800A7080(s32 arg0) { + if (arg0 < 101) { + return arg0; + } + + if(arg0 == 255) { + return func_800A6E2C(); + } + + if(arg0 == 254) { + return func_800A6DD8(); + } + + if(arg0 == 253) { + return func_800A6F64(); + } + + if(arg0 == 252) { + return func_800A6FB8(); + } + + if(arg0 == 251) { + return func_800A6EBC(); + } + + if (arg0 > 200 && arg0 < 251) { + return func_800A700C(arg0); + } + + + if (arg0 > 100 && arg0 < 201) { + return func_800A703C(arg0); + } +} -/** - * @brief Clamp func_800A7080 result to maximum 100. - * - * @return min(func_800A7080(), 100). - */ -/** - * @brief Compute a value and clamp to maximum of 100. - * - * @return The result of func_800A7080, capped at 100. - */ s32 func_800A7154(s32 arg0) { s32 val = func_800A7080(arg0); if (val > 100) { @@ -539,7 +710,15 @@ void func_800A7518(s32 idx) { * @param a0 1-based bit position to test. If 0, returns undefined. * @return 1 if the bit is set, 0 if clear. */ -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A774C); +s32 func_800A774C(s32 idx) { + if (idx != 0) { + s32 val = idx - 1; + s32 idx = val / 32; + s32 bit = val - idx * 32; + + return (g_gameState.mainData.array210[idx] & (1 << bit))? 1 : 0; + } +} /** * @brief Set a bit in the g_gameState bitfield at offset 0xD04. @@ -566,7 +745,26 @@ void func_800A779C(s32 arg0) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A77E8); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7884); +void func_800A7884(void) { + s32 i; + + for (i = 0; i < 3; i++) { + g_battleChars.chars[i].unk180 = 0; + g_battleChars.chars[i].unk184 = 0; + } + + func_800A77E8(); + D_80078DF8 = 0; + + for (i = 0; i < 3; i++) { + func_80022E08(g_gameState.mainData.party.party[i], i); + func_800231E0(g_gameState.mainData.party.party[i], i); + func_800A7518(i); + func_800A71C0(i); + } + + recalcAllGfStats(); +} void func_800A7934(void) { s32 i; @@ -580,7 +778,25 @@ void func_800A7934(void) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A79A0); +void func_800A79A0(void) { + s32 i; + + func_800A7934(); + func_800AF7C4(); + func_800A77E8(); + func_800A8794(); + func_800D8A94(); + + if (D_800ED148.unk1318 != 0) { + func_800D8A78(); + D_800ED148.unk1318 = 0; + } + + for (i = 0; i < 3; i++) { + func_800231E0(g_gameState.mainData.party.party[i], i); + func_800A71C0(i); + } +} /** * @brief Look up the per-class @c field09 byte for the entity at @p a0. @@ -644,7 +860,22 @@ s32 func_800A7AF4(s32 a0) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7B48); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7C64); +void func_800A7C64(s32 arg0, s32 arg1) { + BattleEntityData* temp_v1; + u8 result; + + temp_v1 = *D_800ED148.entities[arg0].entityData; + result = 0; + + if (arg1 >= temp_v1->unkF4) { + result = 2; + if (arg1 < temp_v1->unkF5) { + result = 1; + } + } + + D_800EE9E8.subEntries[arg0 - 3].unk46 = result; +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7CEC); @@ -736,7 +967,24 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A82A0); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8320); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8430); +void func_800A8430(s32 arg0) { + BattleEntityData* temp_s0; + BattleEntityData* temp_s1; + s32 result; + + temp_s0 = *D_800ED148.entities[arg0].entityData; + temp_s1 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; + + func_800A7C64(arg0, temp_s1->unkBC); + result = func_800A7CEC(temp_s1->unkBC, temp_s0); + temp_s1->unk1C = result; + + if (result < temp_s1->unk18) { + temp_s1->unk18 = result; + } + + func_800A8320(arg0); +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A84CC); @@ -751,32 +999,73 @@ void func_800A853C(void) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8578); +void func_800A8578(void) { + s32 i; -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A864C); + for (i = 0; i < 32; i++) { + D_800EE9E8.animSlots[i].unk4 = 0; + + if (D_80078E00.abilities[D_800EE9E8.animSlots[i].id].unk2 & 0x80) { + D_800EE9E8.animSlots[i].unk4 = 1; + } + + if (!(D_80078E00.abilities[D_800EE9E8.animSlots[i].id].unk2 & 0x20)) { + D_800EE9E8.animSlots[i].unk4 |= 2; + } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A86F0); + D_800EE9E8.animSlots[i].unk3 = D_80078E00.abilities[D_800EE9E8.animSlots[i].id].abilityId; + D_800EE9E8.animSlots[i].unk2 = D_80078E00.abilities[D_800EE9E8.animSlots[i].id].unk0; + } +} + +void func_800A864C(void) { + BattleAnimSlot* temp_v0; + s32 i; + s32 idx; + + for (i = 0; i < 32; i++) { + D_800EE9E8.animSlots[i].value = 0; + D_800EE9E8.animSlots[i].id = 0; + } + + for (i = 0; i < 198; i++) { + idx = g_gameState.mainData.itemSlots[i].id; + + if ((idx != 0) && (idx < 33)) { + temp_v0 = &D_800EE9E8.animSlots[g_gameState.mainData.limitBreaks.angeloPoints[idx+7]]; // not much sense, size 8 + temp_v0->value = g_gameState.mainData.itemSlots[i].count; + temp_v0->id = idx; + } + } + + func_800A8578(); +} + +void func_800A86F0(s32 arg0) { + s32 i; + + func_8009B208(&D_800ED148.unkD64[arg0][0], &D_800ED148.unk1100[arg0], 11); + + for (i = 0; i < 11; i++) { + func_800A5948(i, arg0); + } + + for (i = 0; i < 3; i++) { + D_800ED148.unk1244[i].unk0[2].unk7 = 0; + D_800ED148.unk1244[i].unk0[1].unk7 = 0; + D_800ED148.unk1244[i].unk0[0].unk7 = 0; + } +} INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8794); -/** - * @brief Clear 4 status bytes in an entity's sub-table. - * - * Computes D_800EE9B3 + a0 * 71 as base, then clears bytes - * at offsets 0xD, 0x9, 0x5, and 0x1 (stride -4, 4 iterations). - * - * @param a0 Entity index (stride 71). - */ -void func_800A890C(s32 a0) { - s32 i = 3; - s32 offset = a0 * 71; - s32 base = (s32)D_800EE9B3; - u8 *ptr = (u8 *)(offset + base + 0xC); - do { - *(u8 *)(ptr + 1) = 0; - i--; - ptr -= 4; - } while (i >= 0); +void func_800A890C(s32 arg0) { + s32 i; + drawSlot* var_v0 = D_800EE9E8.subEntries[arg0 - 3].array0; + + for (i = 0; i < 4; i++) { + var_v0[i].unk1 = 0; + } } void func_800A8948(void) { @@ -789,9 +1078,41 @@ void func_800A8948(void) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A89B8); +s32 func_800A89B8(s32 arg0, s32 arg1) { + BattleCharData* temp_a0; + s32 i; + + temp_a0 = &g_battleChars.chars[arg0]; + + for (i = 0; i < 32; i++) { + if (temp_a0->magicSlots[i].unk0 == arg1) { + return temp_a0->magicSlots[i].unk1 == 100; + } + } + + for (i = 0; i < 32; i++) { + if (temp_a0->magicSlots[i].unk0 == 0) { + return 0; + } + } + + return 1; +} -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8A48); +void func_800A8A48(BattleCharData* arg0, s32 arg1, u8 arg2, s32 arg3) { + arg0->unkSlots[arg1].unk0 = arg2; + arg0->unkSlots[arg1].unk2 = D_80078E00.unkE8[arg0->unkSlots[arg1].unk0].unk2; + + if (arg3 == 0) { + arg0->unkSlots[arg1].unk1 = arg0->cmdSlots[findCommandSlot(arg0, 0xD)].unk1; + arg0->unkSlots[arg1].unk3 = arg0->cmdSlots[findCommandSlot(arg0, 0xD)].unk3; + } + + else { + arg0->unkSlots[arg1].unk1 = arg0->cmdSlots[findCommandSlot(arg0, 2)].unk1; + arg0->unkSlots[arg1].unk3 = arg0->cmdSlots[findCommandSlot(arg0, 2)].unk3; + } +} s32 func_800A8AFC(s32 arg0) { BattleCharData* ptr = &g_battleChars.chars[arg0]; From f5de8c87652d92bb52ea73b2f8121b0ef9cc1b08 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Fri, 28 Aug 2026 20:22:43 +0200 Subject: [PATCH 08/19] added func_800A77E8 --- src/battle/bc_object4.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 52feafe1..be2a6568 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -743,7 +743,20 @@ void func_800A779C(s32 arg0) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A77E8); +void func_800A77E8(void) { + s32 j; + s32 i; + u8 idx; + + for (i = 0; i < 3; i++) { + idx = g_gameState.mainData.party.party[i]; // uses party.party as the index for chars + if (idx != 255) { // not party member 3 + for (j = 0; j < 32; j++) { + func_800A779C(g_gameState.chars[idx].magic[j].magicId); + } + } + } +} void func_800A7884(void) { s32 i; From f9a7ba196b8d5a7864dd3ad81f81e81d841cffed Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Fri, 28 Aug 2026 21:07:26 +0200 Subject: [PATCH 09/19] cleanup --- src/battle/bc_object4.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index be2a6568..530e5996 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -116,7 +116,7 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A63DC); void func_800A64E4(s32 arg0, u16 arg1) { if (arg0 == 0) { func_800B0754(D_800ED148.entities[0].entityRef, 237, D_800ED148.unk1324, arg1); - decrementItemByType(D_800ED148.unk1324 + 0x65); + decrementItemByType(D_800ED148.unk1324 + 101); func_8009AF14(func_800E1850); return; } @@ -203,19 +203,19 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A68AC); void func_800A69BC(void) { switch (D_800ED148.unk1308) { case 1: - func_8009AF3C(getMenuString(0x2E), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + func_8009AF3C(getMenuString(0x2E), (D_80077E59 * 8) + 8, 3, 128, 86); break; case 2: - func_8009AF3C(getMenuString(0x2D), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + func_8009AF3C(getMenuString(0x2D), (D_80077E59 * 8) + 8, 3, 128, 86); break; case 3: - func_8009AF3C(getMenuString(0x2C), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + func_8009AF3C(getMenuString(0x2C), (D_80077E59 * 8) + 8, 3, 128, 86); break; case 4: - func_8009AF3C(getMenuString(0x2F), (D_80077E59 * 8) + 8, 3, 0x80, 0x56); + func_8009AF3C(getMenuString(0x2F), (D_80077E59 * 8) + 8, 3, 128, 86); break; default: @@ -1117,8 +1117,8 @@ void func_800A8A48(BattleCharData* arg0, s32 arg1, u8 arg2, s32 arg3) { arg0->unkSlots[arg1].unk2 = D_80078E00.unkE8[arg0->unkSlots[arg1].unk0].unk2; if (arg3 == 0) { - arg0->unkSlots[arg1].unk1 = arg0->cmdSlots[findCommandSlot(arg0, 0xD)].unk1; - arg0->unkSlots[arg1].unk3 = arg0->cmdSlots[findCommandSlot(arg0, 0xD)].unk3; + arg0->unkSlots[arg1].unk1 = arg0->cmdSlots[findCommandSlot(arg0, 13)].unk1; + arg0->unkSlots[arg1].unk3 = arg0->cmdSlots[findCommandSlot(arg0, 13)].unk3; } else { From a6819ee832342034485154eebf4aa155b65056fa Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Fri, 28 Aug 2026 22:02:39 +0200 Subject: [PATCH 10/19] added func_800A63DC --- src/battle/bc_object4.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 530e5996..2d03b2ae 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -101,7 +101,45 @@ void func_800A63C0(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { D_800ED148.unk1294 = arg2; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A63DC); +void func_800A63DC(void) { + BattleEntry* entry; + SubEntry* subEntry; + + if (D_800ED148.unk1290 != 0) { + entry = &D_800ED148.entries[0]; + D_800EE4C0.unk1 = entry->unk1; + + if (D_800ED148.unk1292 == 1) { + if (entry->unk1 == 12) { + D_800EE4C0.unk1 = 248; + } + + else if (entry->unk1 == 28) { + D_800EE4C0.unk1 = 243; + } + + else { + D_800EE4C0.unk1 = 253; + } + } + + else { + D_800EE4C0.unk1 = 251; + } + + D_800EE4C0.unk0 = entry->unk0; + subEntry = &D_800ED148.Array844[0]; + + if ((D_800ED148.unk1292 == 1) && (D_800ED148.entities[D_800EE4C0.unk0].status & 8)) { + D_800ED148.unk1294 = 1; + } + + D_800ED148.unk5C1 = 0; + func_800A09D0(subEntry->unk0); + func_800A5210(subEntry->unk0); + D_800ED148.unk1290 = 0; + } +} /** * @brief Initiate battle sequence based on mode flag. From f105be3eaff25294ff39a71dafd21f6f21b4815c Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sat, 29 Aug 2026 00:25:17 +0200 Subject: [PATCH 11/19] added func_800A8320 --- include/battle.h | 7 +++++-- src/battle/bc_object4.c | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/battle.h b/include/battle.h index 42307983..7177914a 100644 --- a/include/battle.h +++ b/include/battle.h @@ -198,10 +198,13 @@ typedef struct { u8 padB8[0xBB - 0xB8]; u8 unkBB; u8 unkBC; - u8 padBD[0xC1 - 0xBD]; + u8 unkBD; + u8 unkBE; + u8 unkBF; + u8 unkC0; u8 unkC1; u8 unkC2; - u8 padC3; + u8 unkC3; u8 unkC4; u8 padC5; u8 unkC6; diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 2d03b2ae..73e1b2d4 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -1016,7 +1016,22 @@ void func_800A7FD0(s32 arg0, s32 arg1, s32 arg2) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A82A0); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8320); +void func_800A8320(s32 arg0) { + BattleEntityData* temp_s2; + BattleEntityData* temp_s0; + drawSlot* temp_s1; + + temp_s1 = D_800EE9E8.subEntries[arg0 - 3].array0; + temp_s2 = *D_800ED148.entities[arg0].entityData; + temp_s0 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; + + temp_s0->unkBD = func_800A82A0(temp_s1, temp_s2, temp_s0, 0); + temp_s0->unkBE = func_800A82A0(temp_s1, temp_s2, temp_s0, 1); + temp_s0->unkBF = func_800A82A0(temp_s1, temp_s2, temp_s0, 2); + temp_s0->unkC0 = func_800A82A0(temp_s1, temp_s2, temp_s0, 3); + temp_s0->unkC1 = func_800A82A0(temp_s1, temp_s2, temp_s0, 4); + temp_s0->unkC3 = func_800A82A0(temp_s1, temp_s2, temp_s0, 5); +} void func_800A8430(s32 arg0) { BattleEntityData* temp_s0; From 42b32d65a18d77e0c0e195dfeea22165b4167ff6 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sat, 29 Aug 2026 02:32:03 +0200 Subject: [PATCH 12/19] added func_800A7B48 --- include/battle.h | 8 +++-- src/battle/bc_object4.c | 67 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/include/battle.h b/include/battle.h index 7177914a..96819125 100644 --- a/include/battle.h +++ b/include/battle.h @@ -452,11 +452,15 @@ typedef struct { /* 0x085C */ u8 pad85C[0x0CDC - 0x085C]; /* 0x0CDC */ u8 unkCDC; /* 0x0CDC */ u8 unkCDD; - /* 0x0CDE */ u8 padCDE[0x0CE3 - 0x0CDE]; + /* 0x0CDE */ u8 padCDE[0x0CE0 - 0x0CDE]; + /* 0x0CE0 */ u8 unkCE0; + /* 0x0CE1 */ u8 unkCE1; + /* 0x0CE2 */ u8 unkCE2; /* 0x0CE3 */ u8 unkCE3; /* 0x0CE4 */ BattleVec3u unkCE4[8]; /**< 8-entry x/y/z position table (read by @c func_8009A528). */ /* 0x0D14 */ u8 unkD14[8]; /**< Hit-type byte table (8 entries). */ - /* 0x0D1C */ u8 padD1C[0x0D5C - 0x0D1C]; + /* 0x0D1C */ u8 padD1C[0x0D54 - 0x0D1C]; + /* 0x0D54 */ u8 unkD54[8]; /* 0x0D5C */ u8 unkD5C[8]; /**< Per-trigger flag array (8 entries). */ /* 0x0D64 */ TaskLink unkD64[3][11]; /* 0x0DE8 */ BattleUnkDE8 arrayDE8[3][11][2]; /**< (792 bytes: 0x318) size tied to func_800A5948 */ diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 73e1b2d4..594304e1 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -236,7 +236,40 @@ void func_800A67FC(s32 arg0) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A68AC); +void func_800A68AC(s32 arg0) { + s32 i; + + switch (arg0) { + case 0: + for (i = 0; i < 3; i++) { + func_800A6780(i); + } + break; + + case 1: + for (i = 0; i < 3; i++) { + if (!(g_battleChars.chars[i].statusFlags & 0x10000)) { + D_800ED148.entities[i].unk24 = 0; + } + } + break; + + case 2: + for (i = 3; i < 7; i++) { + func_800A6780(i); + } + break; + + case 3: + for (i = 3; i < 7; i++) { + D_800ED148.entities[i].unk24 = 0; + } + break; + + default: + break; + } +} void func_800A69BC(void) { switch (D_800ED148.unk1308) { @@ -909,7 +942,37 @@ s32 func_800A7AF4(s32 a0) { return *(u8 *)ptr; } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7B48); +void func_800A7B48(void) { + s32 temp_s1; + s32 i; + s32 j; + + for (j = 3, i = 0; i < 8; i++) { + if (D_800ED148.unkD5C[i] != 0) { + func_800A7FD0(j, D_800ED148.unkD54[i], D_800ED148.unkD14[i]); + func_800A8430(j); + + temp_s1 = 7 - i; + if (func_8009A514(D_800ED148.unkCE0, temp_s1) != 0) { + D_800ED148.entities[j].controlFlags |= 2; + } + + if (func_8009A514(D_800ED148.unkCE2, temp_s1) != 0) { + D_800ED148.entities[j].controlFlags |= 0x40; + } + + if (func_8009A514(D_800ED148.unkCE1, temp_s1) != 0) { + D_800ED148.entities[j].controlFlags |= 0x80; + } + + + j++; + } + } + + func_800A8948(); + func_800A8794(); +} void func_800A7C64(s32 arg0, s32 arg1) { BattleEntityData* temp_v1; From ae7969bffccde4aa748de283ac4b1ee6aed021f0 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sat, 29 Aug 2026 21:51:52 +0200 Subject: [PATCH 13/19] added bc_object4 functions --- include/battle.h | 20 +++++++-- src/battle/bc_object2.c | 9 ++-- src/battle/bc_object4.c | 95 +++++++++++++++++++++++++++++++---------- 3 files changed, 93 insertions(+), 31 deletions(-) diff --git a/include/battle.h b/include/battle.h index 96819125..54f4b9d2 100644 --- a/include/battle.h +++ b/include/battle.h @@ -167,6 +167,16 @@ typedef enum { CTRL_FLAG_400 = 0x400 } ControlFlags; + +typedef struct { + u8 unk0; + u8 unk1; +} subStruct; + +typedef struct { + subStruct unk0[4]; +} Struct_func_800A8794; + /** * @brief Data block reached two indirections away through * @c BattleEntity.linkedPtr->data. @@ -224,12 +234,13 @@ typedef struct { u8 unkFE; u8 unkFF; u8 pad100[4]; - u8 unk104[1]; /* size unknown, probably struct, used in func_8009F65C */ - u8 pad105[0x4A]; + Struct_func_800A8794 unk104[1]; /* size unknown, probably struct, used in func_8009F65C */ + u8 pad10C[0x14F - 0x10C]; u8 unk14F; /* byte read by func_800AF988. */ u16 unk150[1]; u8 pad152[0xE]; - u8 unk160[1]; + u8 unk160[8]; + u8 unk168[40];// possibly size taken from func_800A7FD0 while calling func_800A7EE0 } BattleEntityData; #define ENTITY_FLAG_1 1 @@ -573,7 +584,8 @@ typedef struct { typedef struct { u8 unk0; u8 unk1; - u8 pad2[2]; + u8 unk2; + u8 pad3; } drawSlot; diff --git a/src/battle/bc_object2.c b/src/battle/bc_object2.c index 54865ed0..25833bb6 100644 --- a/src/battle/bc_object2.c +++ b/src/battle/bc_object2.c @@ -1750,16 +1750,15 @@ void func_8009F5B4(s32 arg0) { } s32 func_8009F65C(s32 arg0, s32 arg1) { - s32 offset; s32 i; BattleEntityData* data; data = *D_800ED148.entities[arg0].entityData; - offset = D_800EE9E8.subEntries[arg0 - 3].unk46 * 8; - for (i = 0; i < 4; i++, offset += 2) { - if (arg1 == data->unk104[offset]) { - return data->unk104[offset + 1]; + + for (i = 0; i < 4; i++) { + if (arg1 == data->unk104[D_800EE9E8.subEntries[arg0 - 3].unk46].unk0[i].unk0) { + return data->unk104[D_800EE9E8.subEntries[arg0 - 3].unk46].unk0[i].unk1; } } diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 594304e1..260d5cbd 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -163,11 +163,6 @@ void func_800A64E4(s32 arg0, u16 arg1) { func_8009AE08(8); } -/** - * @brief Store a byte to D_800ED148 offset 0x12EF. - * - * @param value Byte value to store. - */ void func_800A6574(u8 arg0) { D_800ED148.unk12EF = arg0; } @@ -177,7 +172,38 @@ void func_800A6588(void) { func_8009AE08(8); } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A65B0); +void func_800A65B0(void) { + u8 val; + + val = D_800ED148.unk12EF; + if (val == 255) { + D_800ED148.unk12EF = 254; + func_800B0754(D_800ED148.entities[0].entityRef, 241, 65532, D_800ED148.unk12E2); + func_800A6588(); + return; + } + + if (val == 254) { + func_8009AF14(func_800A65B0); + return; + } + + D_800ED148.unk131A = D_800ED148.unk12EF; + val = D_80078E00.unk49F8[D_800ED148.unk131A]; + D_800ED148.unk12EF = 254; + D_800ED148.unk131B = val; + + if (val < 6) { + func_800B0754(D_800ED148.entities[0].entityRef, 241, D_800ED148.unk131B, D_800ED148.unk12E2); + func_8009AF14(func_800A65B0); + return; + } + + func_800A30F8(D_800ED148.entities[0].entityRef, 241, 65530, D_800ED148.unk131B, D_800ED148.entities[0].entityRef, D_800ED148.unk12E2, 0); + func_800B06DC(D_800ED148.unk12E2); + func_800B0754(D_800ED148.entities[0].entityRef, 239, D_800ED148.unk131B, func_8009BA5C(D_800ED148.unk131B, D_800ED148.unk12E2)); + func_800A6588(); +} void func_800A66D0(s32 arg0) { if (func_8009A514(D_800ED148.unkCE3, 7 - arg0) != 0) { @@ -294,35 +320,23 @@ void func_800A69BC(void) { } } -/** - * @brief Process entities 1 and 2, then call func_800A67FC with 0. - */ void func_800A6A58(void) { func_800A68AC(1); func_800A68AC(2); func_800A67FC(0); } -/** - * @brief Process battle entities 1 and 2 via func_800A68AC. - */ void func_800A6A88(void) { func_800A68AC(1); func_800A68AC(2); } -/** - * @brief Process entities 0 and 3, then call func_800A67FC with 1. - */ void func_800A6AB0(void) { func_800A68AC(0); func_800A68AC(3); func_800A67FC(1); } -/** - * @brief Process battle entities 0 and 3 via func_800A68AC. - */ void func_800A6AE0(void) { func_800A68AC(0); func_800A68AC(3); @@ -1117,9 +1131,6 @@ void func_800A8430(s32 arg0) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A84CC); -/** - * @brief Call func_800A84CC for each of 7 battle entities. - */ void func_800A853C(void) { s32 i; @@ -1186,7 +1197,47 @@ void func_800A86F0(s32 arg0) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A8794); +void func_800A8794(void) { + BattleEntityData* temp_s2; + s32 j; + s32 i; + s32 idx; + drawSlot* arr0; + + for (i = 0; i < 4; i++) { + if (D_800ED148.entities[i + 3].controlFlags & 1) { + temp_s2 = *D_800ED148.entities[i + 3].entityData; + arr0 = D_800EE9E8.subEntries[i].array0; + + for (j = 0; j < 4; j++) { + idx = temp_s2->unk104[D_800EE9E8.subEntries[i].unk46].unk0[j].unk0; + if (idx < 64) { + arr0[j].unk0 = idx; + arr0[j].unk2 = 0; + + if (func_800A774C(arr0[j].unk0) == 0) { + arr0[j].unk1 |= 8; + } + + else { + arr0[j].unk1 &= 0xF7; + } + } + + else { + arr0[j].unk2 = 0; + if (!(g_gameState.gfs[idx - 64].exists & 1)) { + arr0[j].unk0 = idx; + } + + else { + arr0[j].unk0 = 0; + } + } + } + } + } +} void func_800A890C(s32 arg0) { s32 i; From 291a11d8ca81349a77c5ee9a130a29809b3258c1 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sun, 30 Aug 2026 02:19:14 +0200 Subject: [PATCH 14/19] added func_800A7518 --- include/battle.h | 6 +- src/battle/bc_object4.c | 143 ++++++++++++++-------------------------- 2 files changed, 53 insertions(+), 96 deletions(-) diff --git a/include/battle.h b/include/battle.h index 54f4b9d2..c88e2473 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1019,7 +1019,8 @@ typedef struct { u8 pad2[2]; u8 unk4; u8 unk5; - u8 pad6[3]; + u8 unk6; + u8 pad7[2]; u8 unk9; u8 padA[2]; } Struct_35BD; /* 12 bytes */ @@ -1027,7 +1028,8 @@ typedef struct { typedef struct { u8 unk0; - u8 pad1[2]; + u8 unk1; + u8 pad2; u8 unk3; u8 pad4[32]; } Struct_37A6; /* 36 bytes */ diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 260d5cbd..a181a5fa 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -683,107 +683,62 @@ void func_800A71A0(BattleEntityData* arg0) { INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A71C0); -/** - * @brief Initialize a battle slot from its corresponding @c BattleCharData. - * - * Looks up @c g_battleChars[idx] and @c D_800ED158.slots[idx], then: - * - If the source's @c characterId byte (offset @c 0x1C3) is @c 0xFF - * (slot empty), zeroes the slot's flags word at @c 0x7C, sets - * @c linkedIdx2 to @c 0xFF and returns. - * - Otherwise copies @c characterId into the slot's @c linkedIdx2, - * seeds the flags word at @c 0x7C with @c 0x8801, and mirrors - * @c displayStatus from the char data into the slot's halfword at - * @c 0x80. - * - Tests two ability/effect tables in @c D_80078E00 (at offsets - * @c 0x35C3 stride 12 keyed by @c charData[0x1BA], and @c 0x37A7 - * stride 36 keyed by @c characterId); each set bit ORs an extra - * flag (@c 0x1000 / @c 0x100) into @c slot+0x7C. - * - Translates four bits of @c charData->statusFlags (@c 0x190) into - * flags in @c slot+0x8: @c 0x1000 → @c 0x80 (overwrites), then - * @c 0x4000 → @c |= @c 0x20, @c 0x2000 → @c |= @c 0x40, - * @c 0x8000 → @c |= @c 0x2. - * - Calls @c func_800A7188 (clears 5 bytes), @c func_800A71A0 - * (zeroes 8 words), and @c func_800A554C(idx) (a stat/AI hook). - * - If neither @c slot+0x80 bit @c 0x1 nor @c 0x4 is set: when - * @c charData->statusFlags has bit @c 0x10000, copies word at - * @c D_800ED148.entities[idx]+0x20 into @c +0x24; otherwise calls - * @c func_800A559C(idx). - * - Finally fills the 40-byte @c slot+0x90..0xB7 region with @c 100 - * (probably an HP-percent / stat init). - * - * @param idx Battle slot index (0..6 covers the 7 active slots). - */ +void func_800A7518(s32 arg0) { + BattleCharData* temp_s1; + BattleEntityData* temp_s0; + s32 i; -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7518); -/* -void func_800A7518(s32 idx) { - BattleCharData *charData = &g_battleChars.chars[idx]; - BattleEntity *slot = &D_800ED158.slots[idx]; - u8 charId; - s32 i; - - charId = charData->characterId; - if (charId == 0xFF) { - slot->field64.slotInit.slotFlags = 0; - slot->linkedIdx2 = 0xFF; + temp_s1 = &g_battleChars.chars[arg0]; + temp_s0 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; + + if (temp_s1->characterId == 255) { + temp_s0->unk7C = 0; + temp_s0->unkBB = 255; return; } + + temp_s0->unkBB = temp_s1->characterId; + temp_s0->unk80 = temp_s1->displayStatus; + temp_s0->unk7C = 34817; + if (D_80078E00.array35BD[temp_s1->classId].unk6 & 1) { + temp_s0->unk7C |= 0x1000; + } + if (D_80078E00.array37A6[temp_s0->unkBB].unk1 & 1) { + temp_s0->unk7C |= 0x100; + } + temp_s0->unk8 = 0; + if (temp_s1->statusFlags & 0x1000) { + temp_s0->unk8 = 0x80; + } + if (temp_s1->statusFlags & 0x4000) { + temp_s0->unk8 |= 0x20; + } + if (temp_s1->statusFlags & 0x2000) { + temp_s0->unk8 |= 0x40; + } + if (temp_s1->statusFlags & 0x8000) { + temp_s0->unk8 |= 2; + } + + func_800A7188(temp_s0); + func_800A71A0(temp_s0); + func_800A554C(arg0); - { - u16 dispStatus; - slot->linkedIdx2 = charId; - dispStatus = charData->displayStatus; - slot->field64.slotInit.slotFlags = 0x8801; - slot->at0x80.slotDisplay = dispStatus; - } - - if (g_gfData.levelCurve12[charData->classId].field0B & 1) slot->field64.slotInit.slotFlags |= 0x1000; - if (g_gfData.xpCurves36[slot->linkedIdx2].field03 & 1) slot->field64.slotInit.slotFlags |= 0x100; - - slot->slot8.initFlags = 0; - if (charData->statusFlags & 0x1000) slot->slot8.initFlags = 0x80; - if (charData->statusFlags & 0x4000) slot->slot8.initFlags |= 0x20; - if (charData->statusFlags & 0x2000) slot->slot8.initFlags |= 0x40; - if (charData->statusFlags & 0x8000) slot->slot8.initFlags |= 0x02; - - func_800A7188(slot); - func_800A71A0(slot); - func_800A554C(idx); - - { - s32 fillVal; - u8 *p; - - // The level-up sound test reads slot+0x80 as a 32-bit word (the write - above was 16-bit) — pick up the wider view via the same union. // - if (!(slot->at0x80.word & 5)) { - if (charData->statusFlags & 0x10000) { - // The entity table at D_800ED148 starts 0x10 bytes before the - slot table at D_800ED158 — entity[idx] is computed from - the slot table base so gcc reuses the D_800ED158 saved-reg - instead of re-emitting lui+addiu for D_800ED148. // - volatile BattleEntity *entity = - (volatile BattleEntity *)((u8 *)&D_800ED158 - 0x10) + idx; - entity->field24 = entity->field20; - } else { - func_800A559C(idx); - } + if (!(temp_s0->unk80 & 4) && !(temp_s0->unk80 & 1)) { + if (temp_s1->statusFlags & 0x10000) { + D_800ED148.entities[arg0].unk24 = D_800ED148.entities[arg0].unk20; } - - // Fill 40 bytes of @c slot[status..pad96+0x21] with 100, walked in - reverse so gcc 2.7.2 emits @c sb with an immediate displacement - (the offset of @c slot->status) and the walker decrement falls - into the @c bgez delay slot. // - fillVal = 100; - i = 0x27; - p = (u8 *)slot + 0x27; - for (; i >= 0; i--) { - p[(s32)&((BattleEntity *)0)->status] = fillVal; - p--; + + else { + func_800A559C(arg0); } } -} -*/ + + + for (i = 0; i < 40; i++) { + temp_s0->unk90[i] = 100; + } +} /** * @brief Test a bit in the g_gameState bitfield at offset 0xD04. From 9adeda0b8a73ed0cdec9b6d873552c91127e37cd Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sun, 30 Aug 2026 03:02:17 +0200 Subject: [PATCH 15/19] added func_800A84CC --- include/battle.h | 19 ++++++++++++++----- src/battle/bc_object4.c | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/include/battle.h b/include/battle.h index c88e2473..09b737a0 100644 --- a/include/battle.h +++ b/include/battle.h @@ -196,16 +196,21 @@ typedef struct { s32 unk24[7]; u8 pad40[4]; u16 unk44[8]; - u8 pad54[0x7C - 0x54]; + s16 unk54[16]; + u8 pad74[0x7C - 0x74]; volatile s32 unk7C; u16 unk80; - u8 pad82[6]; + u8 pad82[2]; + u16 unk84; + u8 pad86[2]; u8 unk88; u8 unk89; u8 unk8A; u8 pad8B[5]; u8 unk90[40]; - u8 padB8[0xBB - 0xB8]; + u8 unkB8; + u8 unkB9; + u8 padBA; u8 unkBB; u8 unkBC; u8 unkBD; @@ -220,7 +225,11 @@ typedef struct { u8 unkC6; u8 unkC7; u8 unkC8; - u8 padC9[0x2B]; + u8 padC9; + u8 unkCA; + u8 padCB; + u16 unkCC; + u8 padCE[0x26]; u8 unkF4; u8 unkF5; u8 unkF6; @@ -292,7 +301,7 @@ typedef struct { s32 unk28; s32 unk2C; s32 unk30; - u8 pad34[32]; + u8 pad34[0x20]; u16 unk54[1]; /* used in func_8009C598 */ u8 unk56; u8 unk57; diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index a181a5fa..bbdd9f5e 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -1084,7 +1084,23 @@ void func_800A8430(s32 arg0) { func_800A8320(arg0); } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A84CC); +void func_800A84CC(s32 arg0) { + s32 i; + BattleEntityData* temp_v0 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; + + temp_v0->unkBB = 255; + temp_v0->unk7C = 0; + temp_v0->unkB9 = 0; + temp_v0->unkB8 = 0; + temp_v0->unk84 = 0; + temp_v0->unkCA = 0; + temp_v0->unkCC = 0; + temp_v0->unk80 |= 1; + + for (i = 0; i < 16; i++) { + temp_v0->unk54[i] = -1111; + } +} void func_800A853C(void) { s32 i; From 661f253a566c03d15efa6902807323f97ab56c91 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Sun, 30 Aug 2026 03:21:56 +0200 Subject: [PATCH 16/19] added func_800A82A0 --- src/battle/bc_object4.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index bbdd9f5e..d82ea49e 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -700,22 +700,28 @@ void func_800A7518(s32 arg0) { temp_s0->unkBB = temp_s1->characterId; temp_s0->unk80 = temp_s1->displayStatus; temp_s0->unk7C = 34817; + if (D_80078E00.array35BD[temp_s1->classId].unk6 & 1) { temp_s0->unk7C |= 0x1000; } + if (D_80078E00.array37A6[temp_s0->unkBB].unk1 & 1) { temp_s0->unk7C |= 0x100; } + temp_s0->unk8 = 0; if (temp_s1->statusFlags & 0x1000) { temp_s0->unk8 = 0x80; } + if (temp_s1->statusFlags & 0x4000) { temp_s0->unk8 |= 0x20; } + if (temp_s1->statusFlags & 0x2000) { temp_s0->unk8 |= 0x40; } + if (temp_s1->statusFlags & 0x8000) { temp_s0->unk8 |= 2; } @@ -1046,14 +1052,24 @@ void func_800A7FD0(s32 arg0, s32 arg1, s32 arg2) { func_800A559C(arg0); } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A82A0); +s32 func_800A82A0(BattleAnimSubEntry* arg0, BattleEntityData* arg1, BattleEntityData* arg2, s32 arg3) { + s32 result; + + result = (arg0->unk40[arg3] * func_800A7D8C(arg2->unkBC, arg1, arg3)) / 10; + + if (result > 255) { + result = 255; + } + + return result; +} void func_800A8320(s32 arg0) { BattleEntityData* temp_s2; BattleEntityData* temp_s0; - drawSlot* temp_s1; + BattleAnimSubEntry* temp_s1; - temp_s1 = D_800EE9E8.subEntries[arg0 - 3].array0; + temp_s1 = &D_800EE9E8.subEntries[arg0 - 3]; temp_s2 = *D_800ED148.entities[arg0].entityData; temp_s0 = (BattleEntityData*)&D_800ED148.entities[arg0].entityData; From 5af2293ddcbce5b966125876d02fe0c0c984fc4d Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Mon, 31 Aug 2026 21:11:20 +0200 Subject: [PATCH 17/19] added func_800A7EE0 --- config/ff8.yaml | 1 + include/battle.h | 54 ++++++++++++++++++++--------------------- src/battle/bc_object4.c | 52 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 29 deletions(-) diff --git a/config/ff8.yaml b/config/ff8.yaml index 8fcff98c..12d2c7e6 100644 --- a/config/ff8.yaml +++ b/config/ff8.yaml @@ -62,6 +62,7 @@ binaries: - [0x130, .rodata, bc_object2] - [0xA84, .rodata, bc_object3] - [0xECC, .rodata, bc_object4] + - [0xF48, pad] - [0xF4C, .rodata, bc_object5] - [0xF90, .rodata, bc_object6] - [0x14C0, .rodata, bc_object7] diff --git a/include/battle.h b/include/battle.h index 09b737a0..8ce749a3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -613,34 +613,6 @@ typedef struct { /* 0x0A3 */ BattleAnimSubEntry subEntries[3]; /**< 3 × 0x47 = 0xD5 bytes. */ } BattleAnimTable; - - -/** @brief Battle magic slot entry (5 bytes). */ -typedef struct { - u8 unk0; - s8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; -} BattleMagicSlot; - -/** @brief Battle item slot entry (5 bytes). */ -typedef struct { - u8 unk0; - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; -} BattleItemSlot; - -/** @brief Battle command slot entry (4 bytes). */ -typedef struct { - u8 cmdType; - u8 unk1; - u8 unk2; - u8 unk3; -} BattleCmdSlot; - /** @brief Data stream within a battle command (two per entry). */ typedef struct { u8 *start; /* +0x00: pointer to stream data start */ @@ -692,6 +664,32 @@ typedef struct { u8 freeSpace[4]; } BattleOtBuf; +/** @brief Battle magic slot entry (5 bytes). */ +typedef struct { + u8 unk0; + s8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; +} BattleMagicSlot; + +/** @brief Battle item slot entry (5 bytes). */ +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; +} BattleItemSlot; + +/** @brief Battle command slot entry (4 bytes). */ +typedef struct { + u8 cmdType; + u8 unk1; + u8 unk2; + u8 unk3; +} BattleCmdSlot; + typedef struct { u8 unk0; u8 unk1; diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index d82ea49e..f5a920a0 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -970,7 +970,57 @@ INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7CEC); INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7D8C); -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A7EE0); +u8 func_800A7EE0(BattleEntityData* arg0, s32 arg1) { + switch (arg1) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + return arg0->unk168[arg1]; + + case 8: + return arg0->unk168[7]; + + case 9: + return arg0->unk168[8]; + + case 10: + return arg0->unk168[9]; + + case 11: + return arg0->unk168[10]; + + case 12: + return arg0->unk168[11]; + + case 15: + return arg0->unk168[12]; + + case 18: + return arg0->unk168[13]; + + case 20: + return arg0->unk168[14]; + + case 21: + return arg0->unk168[15]; + + case 22: + return arg0->unk168[16]; + + case 23: + return arg0->unk168[17]; + + case 24: + return arg0->unk168[18]; + + default: + return 100; + } +} s32 func_800A7FB4(BattleEntityData* arg0, s32 arg1) { return arg0->unk160[arg1] * 10; From 71a65fb7610f51152572c44e412ab1d2bd17efa7 Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Mon, 31 Aug 2026 22:56:22 +0200 Subject: [PATCH 18/19] added func_800A71C0 --- include/battle.h | 8 ++-- src/battle/bc_object4.c | 102 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/include/battle.h b/include/battle.h index 8ce749a3..4a705463 100644 --- a/include/battle.h +++ b/include/battle.h @@ -192,7 +192,7 @@ typedef struct { volatile s32 unk14; // volatile because func_800A5688, func_800A559C s32 unk18; s32 unk1C; - u8 pad20[4]; + s32 unk20; s32 unk24[7]; u8 pad40[4]; u16 unk44[8]; @@ -202,7 +202,7 @@ typedef struct { u16 unk80; u8 pad82[2]; u16 unk84; - u8 pad86[2]; + u16 unk86; u8 unk88; u8 unk89; u8 unk8A; @@ -210,7 +210,7 @@ typedef struct { u8 unk90[40]; u8 unkB8; u8 unkB9; - u8 padBA; + u8 unkBA; u8 unkBB; u8 unkBC; u8 unkBD; @@ -221,7 +221,7 @@ typedef struct { u8 unkC2; u8 unkC3; u8 unkC4; - u8 padC5; + u8 unkC5; u8 unkC6; u8 unkC7; u8 unkC8; diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index f5a920a0..744bb47d 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -681,7 +681,107 @@ void func_800A71A0(BattleEntityData* arg0) { } } -INCLUDE_ASM("asm/ovl/battle/nonmatchings/bc_object4", func_800A71C0); +void func_800A71C0(s32 idx) { + BattleCharData* temp_a3; + BattleEntityData* temp_a0; + s32 i; + + + temp_a3 = &g_battleChars.chars[idx]; + temp_a0 = (BattleEntityData*)&D_800ED148.entities[idx].entityData; + + if (temp_a3->characterId == 255) { + return; + } + + temp_a0->unk1C = temp_a3->hpRegenCap; + temp_a0->unk18 = temp_a3->unk172; + temp_a0->unkBC = temp_a3->level; + temp_a0->unkBD = temp_a3->stats[0]; + temp_a0->unkBE = temp_a3->stats[1]; + temp_a0->unkBF = temp_a3->stats[2]; + temp_a0->unkC0 = temp_a3->stats[3]; + temp_a0->unkC1 = temp_a3->stats[4]; + temp_a0->unkC2 = temp_a3->stats[5]; + temp_a0->unkC4 = temp_a3->stats[7]; + temp_a0->unkC3 = temp_a3->stats[6]; + + for (i = 0; i < 32; i++) { + if (temp_a3->magicSlots[i].unk0 != 0) { + temp_a0->unk8 |= 0x40000000; + goto found; + } + } + + temp_a0->unk8 &= ~0x40000000; + + found: + for (i = 0; i < 8; i++) { + temp_a0->unk44[i] = temp_a3->elemResistances[i]; + } + + + for (i = 0; i < 40; i++) { + temp_a0->unk90[i] = 100; + } + + + + temp_a0->unk90[2] = temp_a0->unk90[20] = temp_a3->statusResistances[2]; + temp_a0->unk90[0] = temp_a3->statusResistances[0]; + temp_a0->unk90[1] = temp_a3->statusResistances[1]; + temp_a0->unk90[3] = temp_a3->statusResistances[3]; + temp_a0->unk90[4] = temp_a3->statusResistances[4]; + temp_a0->unk90[5] = temp_a3->statusResistances[5]; + temp_a0->unk90[6] = temp_a3->statusResistances[6]; + temp_a0->unk90[22] = temp_a3->statusResistances[11]; + temp_a0->unk90[8] = temp_a3->statusResistances[7]; + temp_a0->unk90[10] = temp_a3->statusResistances[8]; + temp_a0->unk90[11] = temp_a3->statusResistances[9]; + temp_a0->unk90[17] = temp_a3->statusResistances[10]; + temp_a0->unk90[23] = temp_a3->statusResistances[12]; + temp_a0->unk20 = temp_a3->abilityFlags; + temp_a0->unk86 = temp_a3->abilityValue; + temp_a0->unkBA = temp_a3->atkStatusHit; + temp_a0->unkC5 = temp_a3->atkElemBase; + temp_a0->unkC6 = temp_a3->atkElemBonus; + + if (temp_a3->statusFlags & 0x8000) { + temp_a0->unk90[11] = 200; + temp_a0->unk90[10] = 200; + } + + if (temp_a3->statusFlags & 0x80000) { + temp_a0->unk90[24] = 200; + temp_a0->unk90[32] = 200; + temp_a0->unk90[23] = 200; + temp_a0->unk90[22] = 200; + temp_a0->unk90[20] = 200; + temp_a0->unk90[18] = 200; + temp_a0->unk90[17] = 200; + temp_a0->unk90[11] = 200; + temp_a0->unk90[10] = 200; + temp_a0->unk90[8] = 200; + temp_a0->unk90[6] = 200; + temp_a0->unk90[5] = 200; + temp_a0->unk90[4] = 200; + temp_a0->unk90[3] = 200; + temp_a0->unk90[2] = 200; + temp_a0->unk90[1] = 200; + temp_a0->unk90[0] = 200; + } + + func_800A240C(idx, D_800ED148.entities[idx].unk28, &D_800ED148.entities[idx].status); + if (D_800ED148.entities[0].state.word == 4) { + if (D_800ED148.entities[idx].status & 0x100) { + func_8009B088(idx, 0, 8, 1); + } + + else { + func_8009B088(idx, 0, 8, 0); + } + } +} void func_800A7518(s32 arg0) { BattleCharData* temp_s1; From 6ce914c64dccfd883b4e13df2fa6172c2ee3416b Mon Sep 17 00:00:00 2001 From: Eletonyy Date: Tue, 1 Sep 2026 13:48:28 +0200 Subject: [PATCH 19/19] added function prototypes for bc_object4 --- include/battle/bc_object4.h | 170 +++++++++++++++++++++++++++++++----- src/battle/bc_object4.c | 1 - 2 files changed, 147 insertions(+), 24 deletions(-) diff --git a/include/battle/bc_object4.h b/include/battle/bc_object4.h index 0d079935..d32823c8 100644 --- a/include/battle/bc_object4.h +++ b/include/battle/bc_object4.h @@ -1,26 +1,150 @@ #ifndef BATTLE_BC_OBJECT4_H #define BATTLE_BC_OBJECT4_H -#include "common.h" - -extern void func_800A6184(s32 arg0, s32 arg1, s32 arg2, u16 arg3); -extern void func_800A61CC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u16 arg5); -extern void func_800A6218(s32 a0); -extern void func_800A6288(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_800A62B0(void); -extern void func_800A6310(u8 a0); -extern void func_800A63C0(s16 a, s16 b, s16 c, s16 d); -extern void func_800A64E4(s32 a0, u16 a1); -extern void func_800A6574(u8 value); -extern void func_800A6724(void); -extern s32 func_800A6DD8(void); -extern void func_800A7518(s32 idx); -extern void func_800A779C(s32 a0); -extern u8 func_800A7A44(s32 a0); -extern u8 func_800A7A8C(s32 idx); -extern u8 func_800A7AB8(s32 a0); -extern void func_800A853C(void); -extern void func_800A890C(s32 a0); -extern s32 func_800A8AFC(s32 a0); - -#endif /* BATTLE_BC_OBJECT4_H */ +void func_800A6184(s32, s32, s32, u16); + +void func_800A61CC(s32, s32, s32, s32, s32, u16); + +void func_800A6218(s32); + +void func_800A6288(s32, s32, s32, s32); + +void func_800A62B0(void); + +void func_800A62DC(s32, s32, s32, s32); + +s32 func_800A62FC(void); + +void func_800A6310(u8); + +void func_800A63C0(s16, s16, s16, s16); + +void func_800A63DC(void); + +void func_800A64E4(s32, u16); + +void func_800A6574(u8); + +void func_800A6588(void); + +void func_800A65B0(void); + +void func_800A66D0(s32); + +void func_800A6724(void); + +void func_800A6780(s32); + +void func_800A67FC(s32); + +void func_800A68AC(s32); + +void func_800A69BC(void); + +void func_800A6A58(void); + +void func_800A6A88(void); + +void func_800A6AB0(void); + +void func_800A6AE0(void); + +s32 func_800A6B08(void); + +s32 func_800A6B6C(s32, s32); + +s32 func_800A6BD0(s32); + +s32 func_800A6C34(void); + +void func_800A6D30(void); + +s32 func_800A6DD8(void); + +s32 func_800A6E2C(void); + +s32 func_800A6EBC(void); + +s32 func_800A6F64(void); + +s32 func_800A6FB8(void); + +s32 func_800A700C(s32); + +s32 func_800A703C(s32); + +s32 func_800A7080(s32); + +s32 func_800A7154(s32); + +void func_800A7188(BattleEntityData*); + +void func_800A71A0(BattleEntityData*); + +void func_800A71C0(s32); + +void func_800A7518(s32); + +s32 func_800A774C(s32); + +void func_800A779C(s32); + +void func_800A77E8(void); + +void func_800A7884(void); + +void func_800A7934(void); + +void func_800A79A0(void); + +u8 func_800A7A44(s32); + +u8 func_800A7A8C(s32); + +u8 func_800A7AB8(s32); + +s32 func_800A7AF4(s32); + +void func_800A7B48(void); + +void func_800A7C64(s32, s32); + +// func_800A7CEC + +// func_800A7D8C + +u8 func_800A7EE0(BattleEntityData*, s32); + +s32 func_800A7FB4(BattleEntityData*, s32); + +void func_800A7FD0(s32, s32, s32); + +s32 func_800A82A0(BattleAnimSubEntry*, BattleEntityData*, BattleEntityData*, s32); + +void func_800A8320(s32); + +void func_800A8430(s32); + +void func_800A84CC(s32); + +void func_800A853C(void); + +void func_800A8578(void); + +void func_800A864C(void); + +void func_800A86F0(s32); + +void func_800A8794(void); + +void func_800A890C(s32); + +void func_800A8948(void); + +s32 func_800A89B8(s32, s32); + +void func_800A8A48(BattleCharData*, s32, u8, s32); + +s32 func_800A8AFC(s32); + +#endif /* BATTLE_BC_OBJECT4_H */ \ No newline at end of file diff --git a/src/battle/bc_object4.c b/src/battle/bc_object4.c index 744bb47d..1aa6d1c5 100644 --- a/src/battle/bc_object4.c +++ b/src/battle/bc_object4.c @@ -686,7 +686,6 @@ void func_800A71C0(s32 idx) { BattleEntityData* temp_a0; s32 i; - temp_a3 = &g_battleChars.chars[idx]; temp_a0 = (BattleEntityData*)&D_800ED148.entities[idx].entityData;