From a372b648ef2d969624cb0529f583b42e174f35ec Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Tue, 25 Aug 2026 14:51:13 -0600 Subject: [PATCH] chore(decomp): commit in-tree banked work before the next gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uncommitted src/ changes found at gate entry. These are banked functions from a lane that gates with commit=False, not residue — preserved, not reverted. Top-level src/*.c (main TUs) are excluded by construction (S59). --- src/ov_SC02_005/ov_SC02_005_jr_80181D30.c | 148 +++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/src/ov_SC02_005/ov_SC02_005_jr_80181D30.c b/src/ov_SC02_005/ov_SC02_005_jr_80181D30.c index c5b730d6f..164ca08b9 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_80181D30.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_80181D30.c @@ -3360,7 +3360,153 @@ void func_80182998(void) { } -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_80181D30", func_80182A8C); +extern u16 D_801E4BBC; +extern s16 D_80195B24[]; +extern u8 D_80195B2C[]; +extern void func_80186BB8(void *a0); +extern void func_80186304(); +extern void func_801840E8(s32 a0); +extern s32 func_8012BEE8(s32 a0); +extern void func_801856E4(void); +extern void func_8018415C(void *a0); +extern void func_80182810(void *a0); +extern void func_801828D8(); +extern void func_8012B23C(s32 a0); +extern void func_8012AD44(s32 *a0, s16 a1); +extern void func_80186F14(void *a0); +extern void func_80186C0C(void *a0); + +// @class: plumbing +// @stuck: none — MATCH (189/189, pin-free, zero asm). Sole residual is the §81 +// jr carve chain (operator step); see BANKING below. +// +/* func_80182A8C — ov_SC02_005_jr_80181D30, 189 ins, MATCH (match_one x14). + * + * §81 jr family: switch on *(u16*)(s0+0x34), bound sltiu $v0,$v1,6. + * jtbl_801E2E58 = 6 entries [0]->0x80182AC8 [1]->0x80182B04 [2]->0x80182B50 + * [3]->0x80182B84 [4]->0x80182BA0 [5]->0x80182C84; default -> .L80182D6C. + * Raw copy: asm/ov_SC02_005/data/tail20.data.s:9 (compiler jump table — not + * named in C; the plain switch emits gcc's own table; splat dlabel name can + * never appear in the draft reloc set — §81 FALSE POSITIVE, cf. func_8015B950 + * symcheck in ov_SC02_005_jr_8015AE2C.c:1531). + * + * BANKING — §53/§62/§81 3-step carve chain applies AT BANK TIME; each step + * byte-gated on its own BEFORE building the next: + * 1. tools/jr_isolate_all.py ov_SC02_005 --only func_80182A8C + * make extract BINARY=ov_SC02_005 && make build BINARY=ov_SC02_005 -> byte-identical + * 2. tools/jtbl_carve.py ov_SC02_005 --func func_80182A8C + * make extract BINARY=ov_SC02_005 && make build BINARY=ov_SC02_005 -> byte-identical + * 3. tools/harvest_verify.py --binary ov_SC02_005 --drafts --chunk 1 + * then FULL R22 (config changed => T2). + * NB do NOT harvest .run/backlog_drafts/ — docs/autopsy.md:64 shows this + * card's stored backlog draft was a stale near-miss (IMM-OFFSET/-3, + * close=1). After banking, re-run tools/autopsy.py collect so the record + * upgrades structural/near -> MATCH/integration. + * Sibling tables in the same tail20 object — jtbl_801E2E78 (:32, + * func_80185060), jtbl_801E2ED0 (:89, func_80185E80), jtbl_801E2F68 (:210, + * func_8018EA04) — belong to STILL-STUBBED functions: they stay raw and keep + * assembling byte-correct from there; do NOT carve them now. No existing + * carves in this subseg => step 2 cannot hit NON-CONTIGUOUS. Second jr here + * later => §8b additive regenerate-from-config carve. + * + * Load-bearing spellings, do NOT "clean up": + * - case 4 caches flags into local `a0` whose LAST USE precedes the call; the RMW + * re-reads memory fresh. Collapsing to one call site w/ computed arg (ternary or + * join var) re-joins the 0x80000 constant across the jal -> phantom $s1, frame 0x20. + * - case-4 join is two plain stores; a named join local moves the li's to $v1. + * - table compare reads the entry UNSIGNED: (*(u16 *)&D_80195B24[D_801E4BBC]<<16)>>17 + * (decl stays s16[]); signed spelling folds to one sra and loses an instruction. + * - *(s16 *)(s0 + 0xAE) = -1 via s16 lvalue; u16 lvalue emits ori instead of addiu -1. + */ +void func_80182A8C(s32 s0) { + u32 a0; + + switch (*(u16 *)(s0 + 0x34)) { + case 0: + if (*(s16 *)(s0 + 0x98) == 0) { + func_80186BB8((void *)s0); + *(u16 *)(s0 + 0x34) = 3; + if (*(u32 *)(s0 + 0xE8) & 0x40000) { + func_80186304((u8 *)s0, 0x16, 2); + *(u16 *)(s0 + 0x34) = 2; + } + } + break; + case 1: + if (*(s16 *)(s0 + 0x98) == 0) { + func_80186BB8((void *)s0); + *(u16 *)(s0 + 0x34) = 3; + if (*(u32 *)(s0 + 0xE8) & 0x20000) { + func_80186304((u8 *)s0, 0x18, 2); + *(u16 *)(s0 + 0x34) = 2; + } + } + break; + case 2: + if (*(s16 *)(s0 + 0x98) == 0) { + func_80186BB8((void *)s0); + *(u16 *)(s0 + 0x34) = 3; + *(u32 *)(s0 + 0xE8) |= 0x80000; + } + break; + case 3: + func_801840E8(*(s32 *)(s0 + 0xD4)); + *(u32 *)(s0 + 0x1C) = 0; + *(u16 *)(s0 + 0x34) = 4; + break; + case 4: + if (func_8012BEE8(s0)) { + if (D_801E4BBC == 0 && *(s16 *)(s0 + 0x76) == D_80195B24[0]) { + func_801856E4(); + *(u32 *)(s0 + 0x1C) = 0x180; + } + } + a0 = *(u32 *)(s0 + 0xE8); + if ((a0 & 0x80000) == 0 && + *(s16 *)(s0 + 0x76) <= ((*(u16 *)&D_80195B24[D_801E4BBC] << 16) >> 17)) { + if ((a0 & 0x20000) != 0) { + func_80186304(s0, -0x15, 1); + } else { + func_80186304(s0, -0x17, 1); + } + *(u32 *)(s0 + 0xE8) = (*(u32 *)(s0 + 0xE8) & 0xFFF9FFFF) | 0x80000; + func_8018415C(*(void **)(s0 + 0xD4)); + *(u16 *)(s0 + 0x34) = 5; + } + break; + case 5: + if (*(s16 *)(s0 + 0x98) == 0) { + if (*(u32 *)(s0 + 0xE8) & 0x1000) { + func_80182810((void *)s0); + if (*(u32 *)(s0 + 0xE8) & 0x2000) { + *(u32 *)(s0 + 0x1C) = 0x18; + } else { + *(u32 *)(s0 + 0x1C) = 0x30; + } + func_801828D8((void *)s0); + *(u32 *)(s0 + 0xE8) &= ~0x80; + *(s32 *)(s0 + 0x1C) = (s32)(s16)*(u16 *)(s0 + 0x104); + } else { + func_8012B23C(s0); + *(u32 *)(s0 + 0xE8) |= 1; + func_80186304((u8 *)s0, 0, 0); + if (*(u32 *)(s0 + 0xE8) & 0x2000) { + *(u32 *)(s0 + 0x1C) = 0x10; + } else { + *(u32 *)(s0 + 0x1C) = 0x20; + } + *(u32 *)(s0 + 0x58) = (s32)D_80195B2C | 0x40000000; + *(u16 *)(s0 + 0x5C) = 0; + *(s16 *)(s0 + 0xAE) = -1; + func_8012AD44((s32 *)s0, 1); + func_80186F14((void *)s0); + } + func_80186C0C((void *)s0); + } + break; + } +} + INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_80181D30", func_80182D80);