feat(phase-29): bank func_80174CB0 (123 ins) — the §65g verdict was a wrong SIGNATURE

SESSION-17 filed this as §65g-class: "not 'run one more tool', but 'needs a transform that does
not exist yet'". Refuted. It needed the correct self-declaration.

- The TU expands DEFINE_func_80174C80() carrying `extern s32 func_80174CB0(s32, s32);`, while all
  ~100 prior drafts defined `void func_80174CB0(s32, s16)` — matches perfectly STANDALONE, dies in
  the real TU with `conflicting types`. Defining it `s32 (s32, s32)` and recovering param_2's
  s16-ness with an explicit (s16) cast at the func_80012558 use site is byte-identical.
- Drafted by an isolated agent (Opus 5 @ High, 65k tok) pointed at the NAMED blocker with the
  canonical callee sigs supplied — not asked to re-derive the C. It self-verified through the real
  cpp->cc1->maspsx->as chain (cc1 rc=0, 123/123 ins, 0 diffs) before reporting, so the bank was
  first-try clean.
- make check BINARY=ov_SC07_006 BYTE-IDENTICAL (7ca772be); R22 clean-fleet 140/140, 0 failed.
- Propagation ×138 follows as a separate targeted step (§55b: bank -> commit -> dedup_propagate --addr).
- FOLLOW-UP LOGGED: the recovery ladder also relaxed `extern s32 func_80174CB0(s32,s32)` -> `()` in
  src/shared/engine_core.h (+2 overlay files), escalating a binary-local bank to FLEET tier. The
  banked def AGREES with the original prototype, so that edit looks unnecessary — to be tested.
This commit is contained in:
Drew T
2026-07-24 23:43:15 -06:00
parent ab67b6980e
commit af59d8a630
5 changed files with 109 additions and 12 deletions
+7 -7
View File
@@ -4,16 +4,16 @@
# cross-binary collapsible-byte leverage: docs/duplicates.cross.md.
# THREE progress metrics (all matter — see the labels):
FLEET fn-count byte-ident: 314725 / 353717 = 88.98% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay)
FLEET instr-weighted : 10501015 / 13141652 = 79.9% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number)
FLEET distinct-code(uniq): 3813214 / 5634875 = 67.7% (64875/87459 unique fns; the DISTINCT-RE number)
FLEET fn-count byte-ident: 314726 / 353717 = 88.98% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay)
FLEET instr-weighted : 10501138 / 13141652 = 79.9% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number)
FLEET distinct-code(uniq): 3813337 / 5634875 = 67.7% (64876/87459 unique fns; the DISTINCT-RE number)
MAIN game-code weighted : 436 / 60201 = 0.7% (INCLUDED in the fleet numbers above since 2026-07-22 — roadmap §1 metrics contract; LINKED-excluding Ghidra sig dated 2026-06-14; caveat is R34: no independent second oracle for a PS-X EXE, NOT drift)
(fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 10500579 / 13081451 = 80.3%)
(fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 10500702 / 13081451 = 80.3%)
FLEET REAL substantive : 312870 (of which dedup-shared 238821 via 1882 groups / 238898 instances)
FLEET REAL substantive : 312871 (of which dedup-shared 238824 via 1882 groups / 238898 instances)
FLEET LINKED PsyQ objs : 959
FLEET NON_MATCHING : 7 (0 in any default build — G4)
FLEET INCLUDE_ASM stubs : 38985
FLEET INCLUDE_ASM stubs : 38984
FLEET matchable : 353717
| binary | REAL | shared | LINKED | byte-ident | matchable | byte-ident % |
@@ -152,7 +152,7 @@ FLEET matchable : 353717
| ov_SC07_000 | 2266 | 1737 | 0 | 2268 | 2521 | 90.0% |
| ov_SC07_001 | 2249 | 1733 | 0 | 2251 | 2454 | 91.7% |
| ov_SC07_002 | 2277 | 1733 | 0 | 2281 | 2579 | 88.4% |
| ov_SC07_006 | 2046 | 1548 | 0 | 2126 | 2455 | 86.6% |
| ov_SC07_006 | 2047 | 1551 | 0 | 2127 | 2455 | 86.6% |
| ov_SC07_007 | 2037 | 1581 | 0 | 2121 | 2613 | 81.2% |
| ov_SC07_008 | 2234 | 1733 | 0 | 2234 | 2386 | 93.6% |
| ov_SC07_009 | 2243 | 1733 | 0 | 2245 | 2430 | 92.4% |
+98 -1
View File
@@ -8702,7 +8702,104 @@ DEFINE_func_80174C60() /* dedup: shared engine-core @0x80174c60 (src/shared) */
DEFINE_func_80174C80() /* dedup: shared engine-core @0x80174c80 (src/shared) */
INCLUDE_ASM("asm/ov_SC07_006/nonmatchings/ov_SC07_006_jr_8015C32C", func_80174CB0);
// @class: regalloc-order
// @stuck: none — MATCH (123 ins)
//
// Sibling of func_801749C8 (already banked in this same TU, ~line 8640): identical 8-call
// clamp/approach prologue and identical trailing MATRIX+SVECTOR / func_8012F14C rotate.
// Two deltas vs that sibling: the single func_80049CAC(p+0x18,&m) is expanded inline here into
// the 4-call matrix build (func_80013F3C / func_800123F0 / func_80012558 / func_800126C4), and
// param_2 is a *short* (hence the sll/sra 16 on $s1) folded into the func_80012558 angle & 0xFFF.
//
// THE ONLY NON-OBVIOUS LEVER (regalloc-order, +2 ins = the $s2 save/restore pair):
// The target keeps &D_80126940 materialized in a callee-saved reg ($s2: lui+addiu once, then
// `lh 0($s2)` on BOTH sides of the 4 matrix calls), while D_80126942/44 are re-emitted as
// lui + `lh %lo(...)` at each of their two uses. Reading D_80126940 as a plain scalar makes gcc
// treat all three uniformly (121 ins, no $s2) -> LENGTH-DRIFT -2. Taking its address ONCE into
// a local pointer (`s16 *pv = &D_80126940;`) forces the address into a call-crossing pseudo,
// which lands in $s2. No `register __asm__` pin is needed.
//
// BANKING NOTES (this draft is written to drop straight into
// src/ov_SC07_006/ov_SC07_006_jr_8015C32C.c):
// * Every callee decl below is VERBATIM the one the TU already carries at file scope —
// func_80012ABC (engine_core.h:28579 / TU:8631), func_80012C6C (TU:1149),
// func_80013F3C/func_80012558/func_800126C4/func_800123F0 (TU:1152-1155),
// func_8012F14C (TU:399). The s16-returning calls therefore go through the
// `((s16 (*)(s32,s32,s32))f)(...)` func-ptr cast idiom already used by func_801749C8,
// so the canonical s32 prototypes are kept and NEVER redeclared.
// * D_80126940/42/44 are already `extern s16` at TU:160-162 — drop the three externs below.
// * Mtx_80174CB0 / Svec_80174CB0 are locally-unique names (== MATRIX / SVECTOR layouts) so
// they cannot collide with engine_types.h; they may be kept as-is or swapped for
// MATRIX / SVECTOR when banking.
// * THE OWN-SIGNATURE BLOCKER (the layer under the func_80012ABC one): the TU expands
// DEFINE_func_80174C80() at line 8702, and that macro carries
// extern s32 func_80174CB0(s32, s32);
// So this function MUST be defined `s32 func_80174CB0(s32, s32)` — a `void`/`s16 param_2`
// draft compiles fine standalone but dies with "conflicting types for `func_80174CB0'"
// in the TU. The s16-ness of param_2 (the sll/sra 16 at 80174DDC) is recovered by the
// explicit `(s16)param_2` cast at the func_80012558 use site; byte-identical either way.
//
// VERIFIED IN-TU: appending this file to a copy of the real TU (with the INCLUDE_ASM line
// removed) compiles cc1-clean (rc=0, same as baseline) and the resulting object's
// func_80174CB0 is 123/123 instructions with 0 diffs vs the target .s.
#include "common.h"
/* --- standalone-only scaffolding (bank-safe: names are unique to this function) --- */
typedef struct { short m[3][3]; long t[3]; } Mtx_80174CB0; /* == MATRIX, 0x20 bytes */
typedef struct { short vx, vy, vz, pad; } Svec_80174CB0; /* == SVECTOR, 0x08 bytes */
extern s16 D_80126940;
extern s16 D_80126942;
extern s16 D_80126944;
/* -------------------------------------------------------------------------------- */
extern s32 func_80012ABC(s32 a0, s32 a1, s32 a2);
extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2);
extern void func_80013F3C(s32 a0);
extern void func_800123F0(s32 a0, s32 a1);
extern void func_80012558(s32 a0, s32 a1);
extern void func_800126C4(s32 a0, s32 a1);
extern void func_8012F14C(s32 a0, s32 a1, s32 a2);
s32 func_80174CB0(s32 param_1, s32 param_2)
{
s16 *pv = &D_80126940;
Mtx_80174CB0 mtx;
Svec_80174CB0 vec;
Svec_80174CB0 out;
*(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4);
*(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4);
*(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4);
*(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4);
*(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4);
*(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10);
*(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10);
*(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10);
*(s32 *)(param_1 + 0x48) = (s32)*(s16 *)(param_1 + 0x28) + (s32)*pv;
*(s32 *)(param_1 + 0x4c) = (s32)*(s16 *)(param_1 + 0x2a) + (s32)D_80126942;
*(s32 *)(param_1 + 0x50) = (s32)*(s16 *)(param_1 + 0x2c) + (s32)D_80126944;
func_80013F3C((s32)&mtx);
func_800123F0((s32)&mtx, (s32)*(s16 *)(param_1 + 0x1c));
func_80012558((s32)&mtx, ((s32)*(s16 *)(param_1 + 0x1a) + (s32)(s16)param_2) & 0xFFF);
func_800126C4((s32)&mtx, (s32)*(s16 *)(param_1 + 0x18));
mtx.t[0] = (s32)*(s16 *)(param_1 + 0x28) + (s32)*pv;
mtx.t[1] = (s32)*(s16 *)(param_1 + 0x2a) + (s32)D_80126942;
mtx.t[2] = (s32)*(s16 *)(param_1 + 0x2c) + (s32)D_80126944;
vec.vx = 0;
vec.vy = 0;
vec.vz = (s16)*(s32 *)(param_1 + 0x10);
func_8012F14C((s32)&mtx, (s32)&vec, (s32)&out);
*(s32 *)(param_1 + 0x3c) = (s32)out.vx;
*(s32 *)(param_1 + 0x40) = (s32)out.vy;
*(s32 *)(param_1 + 0x44) = (s32)out.vz;
}
DEFINE_func_80174E9C() /* dedup: shared engine-core @0x80174e9c (src/shared) */
+1 -1
View File
@@ -3089,7 +3089,7 @@ extern s32 func_801749A8(s32 a0);
extern void func_80174BBC(void *a0);
extern void func_80174BF4(void *a0);
extern void func_80174BF4(void * arg0);
extern s32 func_80174CB0(s32, s32);
extern s32 func_80174CB0();
extern s32 func_80174C60(s32 a0);
extern void func_80174C80(s32 a0);
extern s32 D_8012697C;
+1 -1
View File
@@ -3012,7 +3012,7 @@ extern s32 func_801749A8(s32 a0);
extern void func_80174BBC(void *a0);
extern void func_80174BF4(void *a0);
extern void func_80174BF4(void * arg0);
extern s32 func_80174CB0(s32, s32);
extern s32 func_80174CB0();
extern s32 func_80174C60(s32 a0);
extern void func_80174C80(s32 a0);
extern s32 D_8012697C;
+2 -2
View File
@@ -2033,7 +2033,7 @@
}
#define DEFINE_func_80174C60() \
extern s32 func_80174CB0(s32, s32); \
extern s32 func_80174CB0(); \
s32 func_80174C60(s32 a0) { \
return func_80174CB0(a0, 0); \
}
@@ -4945,7 +4945,7 @@
}
#define DEFINE_func_80174C80() \
extern s32 func_80174CB0(s32, s32); \
extern s32 func_80174CB0(); \
void func_80174C80(s32 a0) { \
s32 v; \
v = (*(u16 *)(a0 + 0xA0) - 0x16) & 0xFFF; \