Skip to content

docs(src): readable names, simple comments and moby labels for USA v1.01 - #464

Merged
Lynder063 merged 1 commit into
masterfrom
docs/readable-names-us101
Nov 15, 2026
Merged

Lynder063 merged 1 commit into
masterfrom
docs/readable-names-us101

Conversation

@Lynder063

Copy link
Copy Markdown
Member

What

A readability pass over every USA v1.01 C unit (src/core, src/game, src/levels, 3,500+ files, about 8,150 functions):

  • Function comments: a short plain-English comment above each function saying what it does in the game. Existing matching notes are kept unchanged.
  • Local names: decompiler-style locals and parameters (s0, arg0, temp_v0, var_a1, ...) and unkXX fields of file-local structs are renamed to meaningful names (moby, vars, pathPoint, ...).
  • Moby labels: moby class ids in code are labelled from docs/game/moby-dispatch.tsv, e.g. 0x10D0 /* Y.E.T.I. */, or /* moby class N */ when the class has no label.
  • Function and data names: include/names.h gains 7,463 descriptive aliases (8,508 in all), following the file's own rule. Definitions and extern declarations keep the catalogue names (func_…, D_…), and bodies use the readable ones (about 156k call sites).
    • Examples: UpdateArcticLeviathanMoby, UpdateYetiMoby, GlowAllMystics, gActiveYetiCount.
    • The names describe what the code does; they are not recovered original names.
    • When two functions got the same name, each one gets a level or address suffix (_L11, _00115250).
    • A name that already exists as an identifier anywhere in src/, include/ or nonmatching/ is also suffixed, so no new macro can change another unit or release.
    • About 280 catalogue functions, mostly ASM_FUNC/handwritten routines, have no alias yet.
  • Small fixes:
    • Files that used an alias before including common.h now include names.h near the top.
    • src/game/0029B658-rc2.c keeps its call by address because test_rectangle_forwarding compiles it against a mock common.h.
    • config/fakematch.tsv has one row reordered by tools/fakematch.py --write.

Only identifiers and comments changed. No types, expressions, constants or statement order were touched. A token-level diff of every file against master showed differences only at identifier positions.

Checked

  • tools/check.py on every function in every changed file: all places match
  • python3 tools/build.py all --strict: 28 of 28 programs OK
  • python3 tools/build.py all --strict --version pal: 28 of 28 OK
  • python3 tools/build.py all --strict --version us2: 28 of 28 OK
  • python3 -m unittest discover -s tests: 719 tests OK (1 skipped)
  • python3 tests/check_repository.py: passes
  • python3 tools/progress.py --check: report current, 8527 matched functions

This PR adds no functions and leaves progress/report.json untouched. JP and KR sources were not changed or built.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E5SuSWfsnhvdxHUytjjSze

Every USA v1.01 C unit (src/core, src/game, src/levels):
- a short plain-English comment above each function saying what it does;
- decompiler-style locals and parameters (s0, arg0, temp_v0, var_a1, ...)
  and unkXX fields of file-local structs renamed to meaningful names;
- moby class ids in code labelled from docs/game/moby-dispatch.tsv, e.g.
  `0x1366 /* Miniturret */`, or `/* moby class N */` when unlabelled.

include/names.h gains 7,463 descriptive aliases (8,508 in all) for USA v1.01
functions and data, following its rule: definitions and extern declarations
keep the catalogue names, bodies use the readable ones. Duplicate names carry
a level or address suffix; a name that already exists as an identifier
anywhere in src/, include/ or nonmatching/ was suffixed so no macro changes
another unit. 156k call sites now use the aliases; files that used an alias
before reaching common.h include names.h. src/game/0029B658-rc2.c keeps its
call by address: test_rectangle_forwarding compiles it with a mock common.h.
config/fakematch.tsv: one row reordered by tools/fakematch.py --write.

Only identifiers and comments changed; no types, expressions or statement
order. Checked:
- tools/check.py on every function in every changed file: all places match
- tools/build.py all --strict: 28 of 28 programs OK
- tools/build.py all --strict --version pal: 28 of 28 OK
- tools/build.py all --strict --version us2: 28 of 28 OK
- python3 -m unittest discover -s tests: 719 tests OK (1 skipped)
- tests/check_repository.py: passes; tools/progress.py --check: current
No functions added (8527 of 8527 USA v1.01 already matched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5SuSWfsnhvdxHUytjjSze
@bytematchdev

bytematchdev Bot commented Nov 15, 2026

Copy link
Copy Markdown

ByteMatch progress report

SCPS_150.56

Code matched 63.09% · 3.47 MB of 5.50 MB
Fuzzy match 63.09%
Functions 7,314 / 8,534
Units complete 894 / 1,140

No function changes.

SCKA_200.11

Code matched 62.70% · 3.46 MB of 5.52 MB
Fuzzy match 62.70%
Functions 7,296 / 8,545
Units complete 892 / 1,144

No function changes.

SCUS_972.68_v2

Code matched 100.00% · 5.58 MB of 5.58 MB
Fuzzy match 100.00%
Functions 8,579 / 8,579
Units complete 1,295 / 1,295

No function changes.

SCES_516.07

Code matched 100.00% · 5.70 MB of 5.70 MB
Fuzzy match 100.00%
Functions 8,607 / 8,607
Units complete 1,370 / 1,370

No function changes.

SCUS_972.68

Code matched 100.00% · 5.52 MB of 5.52 MB
Fuzzy match 100.00%
Functions 8,527 / 8,527
Units complete 1,127 / 1,127

No function changes.

Commit 1a9bd7d · Ratchet & Clank: Going Commando on ByteMatch

@Lynder063
Lynder063 merged commit 1c71328 into master Nov 15, 2026
2 checks passed
@Lynder063
Lynder063 deleted the docs/readable-names-us101 branch November 15, 2026 19:10
Lynder063 added a commit that referenced this pull request Nov 15, 2026
…nitions too

Carry rac1-decomp's naming scheme (docs/contributing/names.md, style.md):
- config/names.tsv is the table (symbol, name, tier, source, evidence,
  alternatives); config/names_local.tsv holds names given from reading the
  code; tools/names.py (local, header, apply-defs, apply, check, rename,
  lookup) generates include/names.h and include/names/*.h, one part per
  level plus executable.h and shared_levels.h.
- Definitions, bodies, extern lines and prototypes use the readable name;
  INCLUDE_ASM/ASM_FUNC lines, __asm__ labels and SDATA() keep the address.
  tools/srcnames.py maps readable names back for the tools that look for a
  definition by address: check.py, progress.py, fakematch.py, fcheck.py and
  tests/check_repository.py read source through it.
- The 7,463 names PR #464 gave are respelled snake_case, system first
  (UpdateYetiMoby -> yeti_update, gActiveYetiCount -> g_active_yeti_count);
  a level's copy of a shared routine puts the level after the system
  (hero_l04_update_state_machine). Library routines keep their own
  spelling. The 1,045 names from before (recovered names and RAC1
  counterparts) keep theirs. A name that is already an identifier in src/
  is left out instead of suffixed (12: memcpy, strlen, rand, ...).
- AGENTS.md's naming rule now points at the rac1 scheme; new
  docs/contributing/names.md and style.md.
- test_rectangle_forwarding's mock common.h includes the real names.h.

8,495 names in names.h; 7,944 definitions and about 415k uses renamed.
Checked:
- tools/build.py all --strict: 28 of 28 programs OK
- tools/build.py all --strict --version pal: 28 of 28 OK
- tools/build.py all --strict --version us2: 28 of 28 OK
- python3 -m unittest discover -s tests: 719 tests OK (1 skipped)
- tests/check_repository.py, tools/progress.py --check, tools/names.py
  check, tools/fakematch.py: pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5SuSWfsnhvdxHUytjjSze
Lynder063 added a commit that referenced this pull request Nov 15, 2026
…s ids

- The camelCase locals, parameters and file-local struct fields PR #464
  introduced are respelled snake_case (pathPoint -> path_point), as
  rac1-decomp's style asks: 6,043 names in 1,091 files. Only names whose
  every use in the file came from PR #464 were changed, and none that would
  clash with a readable name, a header identifier or another name in the file.
- include/moby_classes.h (included by common.h) names the 198 moby class
  ids that have a label in docs/game/moby-dispatch.tsv; a label several ids
  share gets _2, _3 ... in id order. The 661 `0x10D0 /* Y.E.T.I. */`
  labels in code become MOBY_CLASS_YETI and so on. Unlabelled classes keep
  their number and `/* moby class N */` comment.

Only identifiers and literals spelled through macros changed. Checked:
- tools/build.py all --strict: 28 of 28 programs OK
- tools/build.py all --strict --version pal: 28 of 28 OK
- tools/build.py all --strict --version us2: 28 of 28 OK
- python3 -m unittest discover -s tests: 719 tests OK (1 skipped)
- tests/check_repository.py, tools/progress.py --check, tools/names.py
  check, tools/fakematch.py: pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5SuSWfsnhvdxHUytjjSze
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