Skip to content

feat(pal,us2): port four functions, mark three original assembly, retain one near miss - #441

Open
nominalsan wants to merge 1 commit into
OpenRAC:masterfrom
nominalsan:match/pal-us2-medium
Open

nominalsan wants to merge 1 commit into
OpenRAC:masterfrom
nominalsan:match/pal-us2-medium

Conversation

@nominalsan

@nominalsan nominalsan commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Four functions of the PAL (SCES_516.07) and USA v2.00 releases ported as C from their matched counterparts, three marked original assembly, and one PAL near miss retained in nonmatching/.

Function Bytes Places From
func_US2_002D3138 592 boot + 27 levels func_002D2188 with text id 0x2BE5 for 0x2D4F. New src/us2/game/002D3138-g8.c with its original's profile
func_US2_00349C00 644 boot + 27 levels func_00348EC0 with the menu fields 0x70 further in and 88-byte label slots. New src/us2/game/00349368-g8.c
func_US2_L02_00400E04 716 level 02 func_PAL_L02_00403FF0 (#437) with v2.00's data (D_US2_L02_<address>) and text ids 0x2DDB, 0x2DDC, 0x2DF8, 0x2DF4, 0x2DDD. New L02_00400E04-g8.c
func_PAL_L08_003DF82C 988 levels 08, 19 func_L08_003DB518 with the fade step scaled by 1.2f (50 Hz). New src/pal/levels/shared/L08_003DF82C-g8.c

Marked ASM_FUNC under the second criterion of AGENTS.md, "Handwritten assembly", so these need a maintainer's agreement:

  • func_PAL_002A0F68 (792): func_002A05A8 (already ASM_FUNC, feat(src): four functions in C (sky renderers, level-8 emitter, beam), three original assembly routines #425) plus two mul.s by 1.2f. Like it: 26 trapping add/addi/sub/dsub, $at as a working register, and two cvt.w.s words in an encoding the compiler never emits.
  • func_PAL_L01_00305C50 and func_US2_L01_00305170 (804 each, 6 levels): the first 720 bytes are func_0029D4D0 (already ASM_FUNC: qmtc2, 15 trapping ops, three alternate entries), followed by an 84-byte tail with a fourth alternate entry, a trapping addi and two teq.

Retained near miss (marker kept): func_PAL_L09_0040FD68 (984/984 bytes, 0/1), the PAL copy of func_L09_0040AC48. Only case 3's tick test differs, a $v0/$v1 and $f3/$f4 swap. A private instrumented local-alloc dump and the sched1 trace pin it to quantity priorities. The note records the measured model (one extra instruction tied to the counter, emitting no code, reproduces retail's whole assignment) and the next hypothesis. There is a new docs/contributing/matching-blockers.md entry, "A PAL constant that reorders local allocation".

Checked

  • tools/check.py: func_US2_002D3138 28 of 28, func_US2_00349C00 28 of 28, func_US2_L02_00400E04 1 of 1, func_PAL_L08_003DF82C 2 of 2.
  • tools/build.py all --strict: 28 programs OK.
  • tools/build.py all --version pal --strict: 28 programs OK.
  • tools/build.py all --version us2 --strict: 28 programs OK.
  • placed.json: each new C function is placed at all its places (28, 28, 1, 2); none fell back.
  • python3 -m unittest discover -s tests: 540 tests, OK (1 skipped).
  • python3 tests/check_repository.py: repository checks passed.
  • python3 tools/progress.py --check: passes (the reports of us, pal, us2 agree).
  • git ls-files --eol: all 15 changed files i/lf w/lf.

The strict builds ran on the branch's sources. Only documentation changed after them: the near-miss note, its README row and the blockers entry. tools/progress.py was not run, and progress/report.json and the README are not touched.

Adds 3 PAL functions (1 C, 2 original assembly) and 4 USA v2.00 functions (3 C, 1 original assembly); no USA v1.01 functions.

🤖 Generated with Claude Code

…ain one near miss

C ports of matched USA v1.01 functions, each its own -g8.c unit with its
original's profile:
- func_US2_002D3138: func_002D2188 with text id 0x2BE5 for 0x2D4F.
- func_US2_00349C00: func_00348EC0 with the menu fields 0x70 further in
  and 88-byte label slots.
- func_US2_L02_00400E04: func_PAL_L02_00403FF0 with v2.00's data and text
  ids 0x2DDB, 0x2DDC, 0x2DF8, 0x2DF4, 0x2DDD.
- func_PAL_L08_003DF82C (levels 8 and 19): func_L08_003DB518 with the fade
  step scaled by 1.2f.

Marked ASM_FUNC under AGENTS.md's second criterion (needs a maintainer's
agreement): func_PAL_002A0F68 is func_002A05A8 plus two mul.s by 1.2f, with
the same 26 trapping add/addi/sub/dsub, $at as a working register and two
cvt.w.s words the compiler never emits; func_PAL_L01_00305C50 and
func_US2_L01_00305170 are func_0029D4D0 (qmtc2, 15 trapping ops, three
alternate entries) plus an 84-byte tail with a fourth alternate entry, a
trapping addi and two teq.

Near miss: func_PAL_L09_0040FD68 (984/984 bytes, 0/1) differs only by a
$v0/$v1 and $f3/$f4 swap in case 3. Instrumented local-alloc and the sched1
trace pin it to quantity priorities; the notes record the measured model
and the next hypothesis, with a matching-blockers.md entry.

Checks:
- tools/check.py: func_US2_002D3138 28 of 28, func_US2_00349C00 28 of 28,
  func_US2_L02_00400E04 1 of 1, func_PAL_L08_003DF82C 2 of 2.
- tools/build.py all --strict: 28 programs OK in each of USA v1.01, PAL
  and USA v2.00; each new C function is in every carrying placed.json.
- python3 -m unittest discover -s tests: 540 tests OK (1 skipped);
  tests/check_repository.py: passed; tools/progress.py --check: passed.
Report not regenerated.

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

bytematchdev Bot commented Nov 10, 2026

Copy link
Copy Markdown

ByteMatch progress report

SCES_516.07

Code matched 96.60% · 5.50 MB of 5.70 MB
Fuzzy match 96.60%
Functions 8,526 / 8,607
Units complete 1,314 / 1,354

No function changes.

SCUS_972.68

Code matched 98.83% · 5.46 MB of 5.52 MB
Fuzzy match 98.83%
Functions 8,491 / 8,527
Units complete 1,090 / 1,111

No function changes.

SCUS_972.68_v2

Code matched 97.53% · 5.44 MB of 5.58 MB
Fuzzy match 97.53%
Functions 8,515 / 8,579
Units complete 1,243 / 1,279

No function changes.

Commit d56e6bc · Ratchet & Clank: Going Commando on ByteMatch

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