Skip to content

Match 298 US and 24 PAL functions, mostly shape twins of matched code - #142

Open
farfeduc wants to merge 5 commits into
OpenRAC:mainfrom
farfeduc:decomp/shape-twins
Open

farfeduc wants to merge 5 commits into
OpenRAC:mainfrom
farfeduc:decomp/shape-twins

Conversation

@farfeduc

@farfeduc farfeduc commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Matches 298 US functions and 24 PAL functions. US goes from 7,673 to 7,967 functions (12.88% → 14.18% of the code), PAL from 8,044 to 8,103 (14.62% → 14.89%).

How

Most are shape twins: functions whose instructions are those of a function already matched in C, with other constants and addresses (OpenRAC's tools/mips.py shape fingerprint over the US and PAL catalogues). For each one, the twin's C was copied and then:

  • every constant that differs was set to retail's (from the compiled diff), floats included: the PAL twins of US functions often change 60 Hz values for 50 Hz ones (60.0f → 50.0f, 0.2f → 0.24f);
  • callees and globals were renamed to what the disc reaches, from the relocations of our object against the retail words (for PAL, the PAL addresses, as src/pal/ files do);
  • comments were dropped, since they described the twin.

Fourteen are mid-size functions decompiled by hand.

PAL functions go to src/pal/ with PAL names and addresses; US ones to src/ as usual. Three replace drafts in nonmatching/.

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

Functions the audits do not cover

The first commit kept only functions that config/functions.tsv / config/overlay_functions.tsv know with the same size as config/us/. That was too strict: main already has about 1,900 matched functions those tables do not list. The later commits add 236 more twins:

  • audit_matches.py and audit_relocs.py name none of them (34 that they did name are left out);
  • 78 of the US functions are not in config/functions.tsv, so audit_relocs.py does not check their relocations. I checked those against the retail words myself (calls, HI16/LO16, and GPREL16 with gp 0x22597F), fixed the 32 files that still used the twin's names, and the check now finds no mismatch. Byte equality for all of them is check_func.py MATCH and the match rows match_map.py --write gives.

About the ByteMatch report

  • Worse (2) (func_004D3060, func_0054ACE8): their nonmatching/ drafts (95.69% and 92.41%) are replaced by exact C in src/game/; both are in Newly matched.
  • No longer matching (26) on PAL: these PAL functions were matched by src/pal/ files, and the US C added here builds the same PAL bytes, so the map now credits the US file. The branch drops the src/pal/ copies that had a map row before and have none left (14, then 9 more, five of them files this PR had added); maps and progress do not change. PAL still goes up.

Verification

On main at cf4b0ed (merged in after #143):

  • full tools/build.sh, build_libgcc.sh, build_libm.sh;
  • tools/audit_matches.py and tools/audit_relocs.py: no line names any of these functions;
  • tools/check_func.py --version pal gives MATCH for each PAL file;
  • config/{us,pal}/map.tsv changed only on these rows (match_map --write with and without the new files, applied as a delta), then match_map --check;
  • progress.py --check for US and PAL.

Reserved in #112.

🤖 Generated with Claude Code

Functions whose code is a matched function with other constants and
addresses, ported from that C (constants from retail, callees and
globals renamed to what the disc reaches), plus mid-size functions
decompiled by hand. PAL functions get src/pal/ files with PAL
addresses. Superseded nonmatching/ drafts are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bytematchdev

bytematchdev Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

ByteMatch progress report

SCUS_974.65

Code matched 14.18% (+1.30%) · 819.99 KB of 5.78 MB
Fuzzy match 14.98% (+1.23%)
Functions 7,967 (+294) / 18,170
Units complete 4,388 (+163) / 4,447
✅ Newly matched (294)
  • func_004DA2D8 (780 bytes)
  • func_00460D48 (744 bytes)
  • func_004CBB98 (628 bytes)
  • func_L02_004E6370 (624 bytes)
  • func_L01_005334B0 (624 bytes)
  • func_L05_0050A5F8 (624 bytes)
  • func_L06_004DE3B8 (616 bytes)
  • func_L06_0049AFE8 (604 bytes)
  • func_00484F68 (560 bytes)
  • func_0046CEA0 (552 bytes)
  • func_004FAFE8 (552 bytes)
  • func_004D4C58 (548 bytes)
  • func_00502510 (548 bytes)
  • func_004D9048 (544 bytes)
  • func_0054CC60 (544 bytes)
  • func_L00_00729600 (536 bytes)
  • func_004A1B48 (516 bytes)
  • func_L00_00599710 (516 bytes)
  • func_004F7FD8 (508 bytes)
  • func_004C1FA8 (500 bytes)
  • func_L00_00719248 (488 bytes)
  • func_L00_00644D18 (476 bytes)
  • func_L00_0064DC68 (476 bytes)
  • func_00454420 (468 bytes)
  • func_L01_00500548 (468 bytes)
  • func_L01_003DAF28 (460 bytes)
  • func_L01_005008D8 (460 bytes)
  • func_L00_00721A28 (456 bytes)
  • func_L00_00725188 (456 bytes)
  • func_004363D0 (448 bytes)
  • …and 264 more
📉 Worse (12)
  • func_004CBB98 98.73% → 0.00%
  • func_0046CEA0 89.67% → 0.00%
  • func_004F7FD8 87.01% → 0.00%
  • func_004A06F8 96.81% → 0.00%
  • func_004A8280 89.38% → 0.00%
  • func_004B9440 97.89% → 0.00%
  • func_004A8E78 92.80% → 0.00%
  • func_004D9408 97.46% → 0.00%
  • func_004D3060 95.69% → 0.00%
  • func_0046E9E8 92.41% → 0.00%
  • func_0054ACE8 92.41% → 0.00%
  • func_004C9090 98.61% → 0.00%

SCES_532.85

Code matched 14.89% (+0.27%) · 865.11 KB of 5.81 MB
Fuzzy match 15.63% (+0.27%)
Functions 8,103 (+59) / 18,134
Units complete 4,404 (+27) / 4,462
✅ Newly matched (203)
  • func_L00_006BEA78 (800 bytes)
  • func_004DB1F8 (780 bytes)
  • func_00461588 (744 bytes)
  • func_004AF7A0 (744 bytes)
  • func_004CCA38 (628 bytes)
  • func_005230A8 (612 bytes)
  • func_L01_006B8CC0 (584 bytes)
  • func_00485948 (560 bytes)
  • func_0046D780 (552 bytes)
  • func_004FC068 (552 bytes)
  • func_004D5B70 (548 bytes)
  • func_00503580 (548 bytes)
  • func_004D9F60 (544 bytes)
  • func_0054E1C8 (544 bytes)
  • func_004F9058 (508 bytes)
  • func_004C2DD0 (500 bytes)
  • func_L00_00647FE0 (476 bytes)
  • func_L00_00650F58 (476 bytes)
  • func_00454C38 (468 bytes)
  • func_004368B8 (448 bytes)
  • func_0044AAB8 (436 bytes)
  • func_004C5310 (432 bytes)
  • func_0050D198 (428 bytes)
  • func_004F2F08 (424 bytes)
  • func_00466780 (420 bytes)
  • func_004B4F18 (420 bytes)
  • func_00461340 (412 bytes)
  • func_004C54C0 (400 bytes)
  • func_0048CEF8 (384 bytes)
  • func_00526EA8 (384 bytes)
  • …and 173 more
⚠️ No longer matching (144)
  • func_004DB1F8 100.00% → 0.00%
  • func_00461588 100.00% → 0.00%
  • func_004CCA38 100.00% → 0.00%
  • func_00485948 100.00% → 0.00%
  • func_0046D780 100.00% → 0.00%
  • func_004FC068 100.00% → 0.00%
  • func_004D5B70 100.00% → 0.00%
  • func_00503580 100.00% → 0.00%
  • func_004D9F60 100.00% → 0.00%
  • func_0054E1C8 100.00% → 0.00%
  • func_004F9058 100.00% → 0.00%
  • func_004C2DD0 100.00% → 0.00%
  • func_00454C38 100.00% → 0.00%
  • func_004368B8 100.00% → 0.00%
  • func_0044AAB8 100.00% → 0.00%
  • func_004C5310 100.00% → 0.00%
  • func_0050D198 100.00% → 0.00%
  • func_004F2F08 100.00% → 0.00%
  • func_00466780 100.00% → 0.00%
  • func_004B4F18 100.00% → 0.00%
  • func_00461340 100.00% → 0.00%
  • func_004C54C0 100.00% → 0.00%
  • func_0048CEF8 100.00% → 0.00%
  • func_00526EA8 100.00% → 0.00%
  • func_00454E18 100.00% → 0.00%
  • func_00431308 100.00% → 0.00%
  • func_0049EE78 100.00% → 0.00%
  • func_004A1430 100.00% → 0.00%
  • func_004A15A8 100.00% → 0.00%
  • func_004A1720 100.00% → 0.00%
  • …and 114 more

Commit 2102d4b · Ratchet: Deadlocked on ByteMatch

farfeduc and others added 4 commits November 9, 2026 22:10
These PAL functions were matched by src/pal/ files; the US C added in the
previous commit builds the same PAL bytes, so the maps already credit the
US file and the PAL copies had no row left. Maps and progress unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Same method as the first commit: the matched twin C, constants set to
retail, callees and globals renamed to what the disc reaches (from the
relocations, then from audit_relocs.py lines). Nine src/pal files added
or kept by this branch that the US C now covers are dropped, and four
nonmatching/ drafts are replaced.

Co-Authored-By: Claude <noreply@anthropic.com>
…cover

78 of the new US functions are not in config/functions.tsv, so
audit_relocs.py does not check their relocations. Checked them against
the retail words (calls, HI16/LO16 and GPREL16 with gp 0x22597F): 32
files still named the twin callees or globals. Renamed to what the disc
reaches; the built bytes do not change.

Co-Authored-By: Claude <noreply@anthropic.com>
@farfeduc farfeduc changed the title Match 62 US and 29 PAL functions, mostly shape twins of matched code Match 298 US and 24 PAL functions, mostly shape twins of matched code Nov 10, 2026
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