From 23cd3a43a5bd3c0cba9e0a7fbc1e3f081dedaa13 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:51:29 -0600 Subject: [PATCH] =?UTF-8?q?feat(decomp):=20bank=20main:func=5F8005DCA0=20(?= =?UTF-8?q?118=20ins)=20=E2=80=94=20and=20SaveLoadRoutine's=20body=20is=20?= =?UTF-8?q?BYTE-IDENTICAL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One clean-rebuild gate_main pass over main's stored drafts. 35 drafts on the slate -> 20 compatible after in-TU declaration resolution -> 1 byte-correct, found by bisection in 24 rebuilds. main SHA1 143dbb89... BYTE-IDENTICAL. banked: func_8005DCA0 src/800c3.c 118 ins THE HEADLINE IS NOT THE BANK. gate_main's per-function verdicts separate a BODY reject from a PLUMBING reject, and they say: SaveLoadRoutine: PLUMBING REJECT — SaveLoadRoutine is BYTE-IDENTICAL; all 3989 differing bytes are ELSEWHERE IN CODE. The substitution perturbed other functions (§376 — a stale forward declaration changes caller codegen). SaveLoadRoutine is 1,165 instructions -- the largest function left in the project, 9.2% of everything remaining, and carried as the §434 WALL. Its body is already correct. What rejects it is a forward declaration perturbing OTHER functions' codegen, which is exactly what fix_arity_callers -> cast_self_callers exist to repair. That is a plumbing job, not a matching job. Three genuine BODY rejects, correctly distinguished by the same verdict layer (divergence confined to the function itself): func_8001EFE0 (495 bytes), func_80015B6C (151), func_80011380 (8). Those drafts are really wrong. Honest read of the yield: 1 of 20 substituted drafts was byte-correct, so main's stored drafts are mostly NOT right. This tempers the "the endgame is integration, not drafting" line from the previous commit -- true for the overlays, only partly true for main, where several drafts need redrafting or permuter work. The distinction is now measured per function rather than assumed. Deferred to the reconcile chain, not discarded (11 dropped for in-TU decl conflict + 4 dropped across rounds to let the TU compile at all): func_800226C0 (670), func_800215F4 (465), func_8001FC08 (400), func_8005F290 (61) and the gate's own 11. All drafts remain on disk. --- src/800c3.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/src/800c3.c b/src/800c3.c index 90d7760249..a19b318ddc 100644 --- a/src/800c3.c +++ b/src/800c3.c @@ -987,7 +987,79 @@ void func_8005DBD8(void) { } -INCLUDE_ASM("asm/nonmatchings/800c3", func_8005DCA0); +extern s32 *D_800729BC; +extern s32 *D_800729C0; +extern volatile s32 D_80078F24; +extern volatile s32 D_800C5320; + +s32 func_8005FBC8(void); + +s32 func_8005DCA0(s32 ctx, s32 cmd) { + u8 tmp; + s32 first; + u16 t; + s32 hw; + u16 status; + s32 c; + u16 *port; + + if (cmd < 0) { + tmp = *(u8 *)D_800729C0; + *(u8 *)(ctx + 0x44) = 0xFF; + *(u8 *)(ctx + 0x45) = 1; + *(u8 *)*(s32 *)(ctx + 0x40) = ~cmd; + first = tmp; + if ((*(volatile u16 *)((s8 *)D_800729C0 + 0x4) & 1) == 0) { + do {} while ((*(volatile u16 *)((s8 *)D_800729C0 + 0x4) & 1) == 0); + } + while (func_8005FBC8() == 0) {} + { + register u8 nv __asm__("$2"); + nv = ~cmd; + *(u8 *)D_800729C0 = nv; + } + return first; + } + t = 0x88; + c = *(u8 *)*(s32 *)(ctx + 0x3C); + if ((c >> 4) == 8 && *(u8 *)(ctx + 0x44) >= 9) { + t = 0x22; + } + port = (u16 *)0x1F801120; + __asm__("" : "=r"(port) : "0"(port)); + hw = *port; + status = *(volatile u16 *)((s8 *)D_800729C0 + 0x4); + D_800C5320 = 0x1AE; + D_80078F24 = hw; + if ((status & 2) == 0) { + do {} while ((*(volatile u16 *)((s8 *)D_800729C0 + 0x4) & 2) == 0); + } + { + s32 *ptr = D_800729BC; + tmp = *(u8 *)D_800729C0; + *(u16 *)((s8 *)D_800729C0 + 0xE) = t; + first = tmp; + if ((*ptr & 0x80) == 0) { + do { + if (func_8005FBC8() != 0) { + goto err; + } + } while ((*D_800729BC & 0x80) == 0); + } + } + *(u8 *)D_800729C0 = cmd; + *(u8 *)(ctx + 0x45) += 1; + *(u8 *)(*(s32 *)(ctx + 0x3C) + *(u8 *)(ctx + 0x44)) = first; + { + register u8 inc __asm__("$2"); + inc = *(u8 *)(ctx + 0x44); + inc += 1; + *(u8 *)(ctx + 0x44) = inc; + } + return first; +err: + return -20; +} INCLUDE_ASM("asm/nonmatchings/800c3", func_8005DE78);