Files
BFM-decomp/cookbook/C0370.md
T

1.3 KiB

§330 — THE NEIGHBOUR-SHAPE LEVER IS THE CHEAPEST FIRST MOVE, AND IT IS UNDER-USED (P31 S67; four independent instances in one 20-function wave)

Before any codegen reasoning, read an ALREADY-BANKED function in the same TU and copy its SPELLING, not just its structure. Measured this wave:

  • md_MAIN_031/func_800CAE0C — the neighbour 6 lines away contained the same 3-call body verbatim (same symbols, same (void*) casts). Copied its call spelling -> MATCH on first compile.
  • ov_SC01_084/func_8017EF28 — the neighbour's memory-to-memory house form (*(u16*)(p+0xE2) = *(u16*)(p+0xE2) + 0x70) replaced a reused int v local and dissolved ALL 18 $v0/$v1 REGALLOC-PERM rows in ONE compile — no §137 arithmetic, no pins.
  • ov_SC01_084/func_80183244 — neighbour gave the exact TU shape, 70 -> 30, nins exact.
  • main/func_8002A088 + func_8002A7B4 — mirroring the already-banked in-TU twin func_8002A2D4's local shape (separate i/off locals, subtraction inlined as the call arg) produced the correct 0x18 frame; the warm-start body had been 4-off on frame size alone. The corollary that costs functions when ignored: a warm-start body from ANOTHER binary is often worth less than the neighbour 20 lines away. func_8017FAAC's warm start was a different function entirely and was discarded.