diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8017F950.c b/src/ov_SC02_000/ov_SC02_000_jr_8017F950.c index 209db63b5e..d0b85d3a6b 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8017F950.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8017F950.c @@ -1,3 +1,79 @@ #include "common.h" -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8017F950", func_8017F950); + +void func_8017F950(s32 arg0) +{ + typedef struct { u32 w[4]; } St801D9204; + extern void func_80019064(void *a0); + extern void func_8012A828(s32 a0, void *a1); + extern void func_8012B23C(s32 a0); + extern void func_8012B2CC(s32 a0); + extern void func_8012E9C0(s32 a0); + extern s32 func_80143B6C(s32 a0, s32 a1); + extern void func_8017FC9C(s32 a0); + extern void func_8017FCB0(s32 a0); + extern void func_8017FD2C(s32 a0); + extern void func_8017FD44(s32 a0); + extern void func_8017FD80(s32 a0); + extern void func_8017FDE8(s32 a0); + extern void func_8017FE68(s32 a0); + extern void func_801801EC(s32 a0); + extern void func_80180A64(s32 a0); + extern u8 D_80062BDC; + extern char D_801A681C[]; + extern St801D9204 D_801E6A00; + St801D9204 local = D_801E6A00; + + if (*(u8 *)(arg0 + 0x5E) == 5) { + func_80019064(&D_80062BDC); + } + if (*(u16 *)(arg0 + 0x5E) == 0x1F) { + func_80180A64(arg0); + return; + } + *(u8 *)(arg0 + 0xC1) = 0; + func_8012E9C0(arg0); + *(u16 *)(arg0 + 0x76) = *(u16 *)(arg0 + 0x76) - *(u16 *)(arg0 + 0x60); + *(u16 *)(arg0 + 0x5C) &= 0xFFFE; + *(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12) = (*(u16 *)(arg0 + 0x62) + 0x800) & 0xFFF; + func_8012B2CC(arg0); + func_8012B23C(arg0); + *(s16 *)(arg0 + 2) = 3; + func_80143B6C(arg0, 0); + switch (*(u8 *)(arg0 + 0x5E)) { + case 13: + func_8017FC9C(arg0); + return; + case 14: + func_8017FCB0(arg0); + return; + case 10: + func_8017FD44(arg0); + return; + case 9: + func_8017FD80(arg0); + return; + case 17: + func_8017FDE8(arg0); + return; + case 33: + func_8017FD2C(arg0); + return; + case 15: + if (*(s16 *)(arg0 + 0x76) > 0) { + func_801801EC(arg0); + return; + } + break; + default: + if (*(s16 *)(arg0 + 0x76) > 0) { + *(u16 *)(arg0 + 0x34) = 0; + *(s32 *)(arg0 + 0x1C) = 0x10; + func_8012A828(arg0, D_801A681C); + return; + } + break; + } + func_8017FE68(arg0); +} + diff --git a/tools/jtbl_carve.py b/tools/jtbl_carve.py index afaeba830a..c894c3828e 100644 --- a/tools/jtbl_carve.py +++ b/tools/jtbl_carve.py @@ -1018,6 +1018,19 @@ def migrated_tables(ov, funcs): def apply(ov, funcs): mig = migrated_tables(ov, funcs) + # THE PROBE OVERRIDES THE CLASSIFIER FOR 'tail' (P31 S70). `migrated_tables` can flag a function + # whose table is actually in the DATA TAIL, and the island branch below then refuses the whole + # batch — even though `island_probe` classifies it 'tail' and its own detail says "standard §8a + # carve at gate time", i.e. it names the ordinary lane as the owner (R43: each kind names its + # lane). That refusal reads as a permanent wall while the function is simply in the wrong branch: + # measured on ov_SC02_000/func_8017F950, which is 'tail' yet died on the LEADING-ISLAND exit. + # Consult the probe FIRST and let a tail function fall through to build_carve below. + if mig: + _tail = [f for f in mig if island_probe(ov, f)[0] == "tail"] + if _tail: + print(f"jtbl_carve {ov}: {sorted(_tail)} probe as 'tail' (data-tail table) — routing to " + f"the standard §8a carve, not the §154-A island branch") + mig = [f for f in mig if f not in _tail] if mig: # §154-A migrated tables. Two states, byte-distinguished by island_probe: # * 'covered' — the §260 island split is IN PLACE (the fn is isolated into its own