feat(decomp): bank main:func_8005DCA0 (118 ins) — and SaveLoadRoutine's body is BYTE-IDENTICAL

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.
This commit is contained in:
Drew T
2026-09-02 22:51:29 -06:00
parent abea9f0ac2
commit 23cd3a43a5
+73 -1
View File
@@ -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);