Skip to content

Match 26 small US functions (4 net, 6 game, 2 core, 14 overlay) - #138

Open
GarfTornion wants to merge 6 commits into
OpenRAC:mainfrom
GarfTornion:decomp/us-batch52-dl
Open

GarfTornion wants to merge 6 commits into
OpenRAC:mainfrom
GarfTornion:decomp/us-batch52-dl

Conversation

@GarfTornion

@GarfTornion GarfTornion commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Matches 26 US functions of reservation batch 52: 4 in net.text, 6 in game, 2 in core, and 14 in overlays (7 l00_multiplayer_menu, 7 shared/L11/L15). All are small (16-128 bytes). The first commit also stages 24 near misses in nonmatching/ with their measured verdicts; three are updated by later commits.

func_01EACEF0, func_01EB4DD0, func_01EA8BD0, func_01EDA958 (net); func_00547DC8, func_00547E00, func_00548040, func_00548078, func_00548DA0, func_00501988 (game); func_00154010, func_0012E8C8 (core); func_L00_00519CF0, func_L00_00709290, func_L00_00709980, func_L00_00710750, func_L00_00753158, func_L00_007099A0, func_L00_0077A2F8 (l00 overlay); func_L01_003C90CC, func_L01_0043C180, func_L01_0048AD68, func_L01_004BDD78, func_L01_00573B60, func_L11_003C5088, func_L15_004E38C4 (shared overlays).

How they were matched

  • 9 from m2c plus flag/compiler sweeps: func_01EACEF0 (@ee296 -O2 -G0), func_L11_003C5088 (-fno-schedule-insns -fno-schedule-insns2), and func_01EB4DD0, func_L00_00519CF0, func_L00_00709290, func_L00_00709980, func_L00_00753158, func_L01_003C90CC, func_L15_004E38C4 from their drafts.
  • 6, four of them through the permuter: the 0x44-stride accessor family func_00547DC8, func_00547E00, func_00548040, func_00548078 (C written as T *p = &param; on a clamped index, which is what the allocator needs), plus func_00154010 (@ee296 -O2 -G0 with a u32 counter for sltiu) and func_L00_00710750 (store order).
  • 3 from a hint or a matched neighbour: func_00548DA0 (permuter hint rewritten as plain C), func_01EA8BD0 (the 16-byte argument slots turned out to be the 8-byte-aggregate ABI of src/net/01EB4DE8.c, and the handler is read as a struct member), func_L01_0043C180.
  • 4 from statement order and the hazard-nop compiler: func_01EDA958 and func_00501988 build with @ee296 -O2 -G8, the only compiler that emits the R5900 sllv/div.s latency nops retail carries (-G0 moves the globals off $gp and does not match); func_01EDA958 also needs a u32 counter copied from its u16 parameter, otherwise GCC re-truncates inside the loop. func_L00_007099A0 is a statement order (the unconditional store before the final if), func_L00_0077A2F8 a store order (the pairwise reverse of retail's).
  • 4 from C-shape rules: func_L01_004BDD78 (comparing the masked value signedly blocks GCC's single-bit sra+andi fold), func_0012E8C8 (the function returns 0 - retail's daddu $v0,$zero,$zero - and the tail written as an array index keeps %hi in a register; @ee29 -O2 -G0 like its neighbours), func_L01_00573B60 (a mode(TI) 16-byte copy), func_L01_0048AD68 (u128 tmp[1] homes a TImode local on the stack, which a scalar does not).

No #define aliases, volatile, inline asm or hard-coded addresses.

Verification

upstream/main at 0bddadfd is merged in (the merge commit regenerates the derived files), and the branch tip is 6672aa1a:

  • full tools/build.sh: 8,414 objects;
  • tools/audit_matches.py: 5,650 exact, 164 pre-existing non-exact; no line names any of the 26;
  • tools/audit_relocs.py: 27 records and no unresolved target, none of them ours;
  • config/us/map.tsv 7,741 match, config/pal/map.tsv 8,327 match;
  • tools/progress.py --check for US and PAL: US 7,695 of 18,170 functions / 745,840 of 5,781,432 bytes (12.90%), PAL 8,062 of 18,134 / 850,424 of 5,810,856 (14.64%).

Reserved in #112. Independent of #121 and #137 (no file in common).

The remaining 24 functions of the reservation stay in nonmatching/ with their measurements: 6 are not functions (four catalogue fragments, a shared entry point and a hardware-register routine), 10 are closed by measured compiler or layout behaviour, and 8 are one register-allocation choice away from exact.

GarfTornion and others added 6 commits November 8, 2026 22:05
Landed, each re-checked in place by tools/try_func.py and exact in
tools/audit_matches.py:

  func_01EB4DD0  net
  func_01EACEF0  net
  func_L00_00519CF0  level 00 overlay
  func_L00_00709290  level 00 overlay
  func_L00_00709980  level 00 overlay
  func_L00_00753158  level 00 overlay
  func_L01_003C90CC  shared overlay (46 levels)
  func_L11_003C5088  shared overlay
  func_L15_004E38C4  shared overlay

Two of them are decided by the compiler choice rather than by the C:
-fno-schedule-insns -fno-schedule-insns2 and @ee296 -O2 -G0, found by sweeping
the batch's near misses over 21 flag sets (private/tools/flagsweep.py). Both
files carry the cflags line that matters.

The 24 functions that did not match are staged in nonmatching/ with the verdict
each reached, three of them at a better flag set than their first attempt.

config/us/map.tsv, config/pal/map.tsv and both progress reports regenerated
with this src/: US 7,168 of 18,170 functions, PAL 7,642 of 18,134.
tools/progress.py --check passes for both discs; tools/audit_relocs.py reports
none of the nine among its pre-existing mismatches.

Co-Authored-By: Cline <noreply@cline.bot>
Landed, each EXACT through tools/try_func.py, exact in tools/audit_matches.py
and absent from tools/audit_relocs.py's mismatches:

  func_00154010      core, the byte-table lookup
  func_00547E00      game, halfword getter of the 0x44-stride slots
  func_00548078      game, word getter of the same slots
  func_00547DC8      game, halfword setter of the same slots
  func_00548040      game, word setter of the same slots
  func_L00_00710750  level 00 overlay, the constructor

Two levers decided this batch. The lookups came from the flag sweep: 21 sets
plus @sn107/@sn114/-G2 left them at 1-2 bytes, and func_00154010 closed when the
loop counter became u32 (sltiu, not slti) under @ee296 -O2 -G0. The four slot
accessors came from OpenRAC's permuter (profile rac4/ntsc-win), which needed its
compile step build/cc_win.sh back (git-ignored, missing in this checkout) and
candidates without file-scope declarations; its hint is the address of the
clamped index (`s32 *index = &a1;`), which keeps the index in $a1 as retail
does. The permuter's asm-pass output for the setters was rejected by tools/wave.py
("refused: inline assembly") and reproduced by hand in plain C instead.

The five functions that did not match are staged in nonmatching/ with the verdict
each reached.

config/us/map.tsv, config/pal/map.tsv and both progress reports regenerated with
this src/: 5,905,00 of 5,781,432 US bytes (7,192 functions), PAL 725,320 of
5,810,856. tools/progress.py --check passes for both discs.

Co-Authored-By: Cline <noreply@cline.bot>
Co-Authored-By: Cline <noreply@cline.bot>
Co-Authored-By: Cline <noreply@cline.bot>
Co-Authored-By: Cline <noreply@cline.bot>
Co-Authored-By: Cline <noreply@cline.bot>
@bytematchdev

bytematchdev Bot commented Nov 9, 2026

Copy link
Copy Markdown

ByteMatch progress report

SCES_532.85

Code matched 14.64% (+0.01%) · 850.42 KB of 5.81 MB
Fuzzy match 15.35% (−0.01%)
Functions 8,062 (+18) / 18,134
Units complete 4,389 (+12) / 4,447
✅ Newly matched (18)
  • func_0012E8C8 (76 bytes)
  • func_00154010 (72 bytes)
  • func_00549330 (56 bytes)
  • func_005495A8 (56 bytes)
  • func_01EA8BD0 (56 bytes)
  • func_01EACEF0 (56 bytes)
  • func_005029F8 (52 bytes)
  • func_0054A308 (52 bytes)
  • func_01EDA958 (52 bytes)
  • func_L00_00714570 (52 bytes)
  • func_00549368 (44 bytes)
  • func_005495E0 (44 bytes)
  • func_L00_0077F6D8 (40 bytes)
  • func_L01_00576758 (32 bytes)
  • func_L01_0048C410 (28 bytes)
  • func_01EB4DD0 (24 bytes)
  • func_L01_004BFA10 (24 bytes)
  • func_L00_00757F40 (12 bytes)
📈 Improved (2)
  • func_01EA9950 0.00% → 82.69%
  • func_L01_00596FA8 0.00% → 34.38%
📉 Worse (4)
  • func_L00_005477D0 97.12% → 0.00%
  • func_L00_00535B80 97.20% → 0.00%
  • func_L00_005392E0 92.12% → 0.00%
  • func_L01_006B95B0 82.86% → 0.00%

SCUS_974.65

Code matched 12.90% (+0.02%) · 745.84 KB of 5.78 MB
Fuzzy match 13.74% (−0.01%)
Functions 7,695 (+22) / 18,170
Units complete 4,237 (+12) / 4,296
✅ Newly matched (22)
  • func_0012E8C8 (76 bytes)
  • func_00154010 (72 bytes)
  • func_00547DC8 (56 bytes)
  • func_00548040 (56 bytes)
  • func_01EA8BD0 (56 bytes)
  • func_01EACEF0 (56 bytes)
  • func_00501988 (52 bytes)
  • func_00548DA0 (52 bytes)
  • func_01EDA958 (52 bytes)
  • func_L00_00710750 (52 bytes)
  • func_00547E00 (44 bytes)
  • func_00548078 (44 bytes)
  • func_L00_0077A2F8 (40 bytes)
  • func_L00_007099A0 (36 bytes)
  • func_L01_0043C180 (32 bytes)
  • func_L01_00573B60 (32 bytes)
  • func_L00_00709290 (32 bytes)
  • func_L00_00709980 (32 bytes)
  • func_L01_0048AD68 (28 bytes)
  • func_01EB4DD0 (24 bytes)
  • func_L01_004BDD78 (24 bytes)
  • func_L00_00753158 (12 bytes)
📈 Improved (2)
  • func_01EA9950 0.00% → 82.69%
  • func_L01_00592CD0 0.00% → 34.38%
📉 Worse (4)
  • func_L00_005472D0 97.12% → 0.00%
  • func_L00_00535680 97.20% → 0.00%
  • func_L00_00538DE0 92.12% → 0.00%
  • func_L01_006B3FE8 82.86% → 0.00%

Commit 6672aa1 · Ratchet: Deadlocked on ByteMatch

@GarfTornion
GarfTornion marked this pull request as ready for review November 9, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant