Skip to content

cra.py reads the 2021 layout of Camelot's archive (Mario Golf: Super Rush 4.0.0) - #2216

Closed
secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:cra-2021-layout
Closed

secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:cra-2021-layout

Conversation

@secretlemur28

Copy link
Copy Markdown
Contributor

What and why

Mario Golf: Super Rush (0100C9C00E25C000, update v262144 / 4.0.0) keeps its files in one CRA archive, rom:/42, as Mario Tennis Fever does, but in an older layout, so the shader split stopped with "a CRA archive, and no NRO holds its file table" (#814).

cra.py gains that layout (Index2021, index_2021, keys_2021, plain_2021); Index picks it when the NRO has no table of today's layout, and read / head take either kind of entry. The layout, from the game's reader at nro0+0x54b6d4:

  • the file table is in the NRO's read-only data, found by the code that reads a record (the size mask's mov / movk after adrp + add + ldrsw): one i32 per file, records at table - i32[i];
  • a record: +0 u16 how far back the record holding the path's prefix is, +2 u8 the prefix's length, +4 u32 size ^ 0xce462eca, +8 u32 checksum, +0xc u40 offset ^ 0x46f636762a, +0x11 the rest of the path, each character bit-reversed and xored with (i & 15) + 1;
  • a file is xored in 16-byte blocks with two keys built from 8 characters of its last path element, then each byte is bit-reversed; the checksum is the CRC-32 of the plain file ^ 0x12345678.

Checked

  • Tests: dm/gfx/tests/test_cra.py, 11 of 11 (three new, on synthetic data: paths through two prefix records, the keys, read / head and a wrong checksum).
  • Games run: Mario Golf: Super Rush 4.0.0. All 5,101 names decode and every file read passes its checksum; the split finds 25,270 shaders (compute 43, domain 3, geometry 104, hull 3, pixel 16,980, vertex 8,137) and all compile. With A subsdk a provisional profile gains from the NRO collection also goes into its build rows #2215 the game plays to the Rookie Course's first tee at 60 fps on main at 25c2546.
  • Devices and OS: MacBook Pro M1 Pro, 16 GB, macOS 27.0.1.
  • Not checked: Mario Tennis Fever (not on this Mac); its layout is the one Index tries first and its tests pass unchanged. No iOS build.

Docs

  • No game note yet: the game has no registered profile, only the script's provisional one. Happy to add a note and a games-table row if you want them with this.
  • cra.py is not in the chain's file list; dmsh_chain.py --header gives the same header.
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

…Rush 4.0.0): the shader split stopped with 'a CRA archive, and no NRO holds its file table'

The game keeps its 5,101 files in rom:/42 as Mario Tennis Fever does, but its NRO reads another file table and another scramble: i32 record distances, sizes and offsets under other masks, bit-reversed path characters, and files xored in 16-byte blocks with two keys from the last path element, each byte bit-reversed, checked by a CRC-32. Index() returns the layout the NRO's code reads. Checked: all files' names decode, the split finds 25,270 shaders, test_cra.py passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) label Nov 10, 2026
seedds added a commit that referenced this pull request Nov 12, 2026
…r Rush's (PR #2216)

Mario Golf: Super Rush 4.0.0 keeps its 5,101 files in rom:/42 as Mario
Tennis Fever does, but its NRO reads another layout, so the shader split
stopped with "a CRA archive, and no NRO in DM_NRO_DIR holds its file
table". Index2021 reads it: an i32 per file with the records behind the
table, size, CRC-32 checksum and offset under other masks, bit-reversed
path characters, files xored in 16-byte blocks with two keys from the
last path element and each byte bit-reversed (the game's reader at
nro0+0x54b6d4). The table is found by the code that reads it, in any
build.

cra.index(nro) takes the layout the NRO's code reads, and each file's
entry names its layout (LAYOUT / LAYOUT_2021), which read() and head()
take it in. Reference entry: "One scrambled archive indexed by the NRO"
in docs/reference/shaders.md.

Checked on Mario Golf 4.0.0 from its NSPs (--platform mac, with
b9615a1): all 5,101 files (4.1 GB) pass the game's checksums in 37 s,
the split finds 25,270 shaders in 18 s, all translate, and the game
boots with subsdk0 loaded and plays its opening movie at 60 fps.
test_cra.py, test_split_narc.py. Mario Tennis Fever not run (no files
here); its layout keeps its logic and tests.

Co-authored-by: secretlemur28 <354896836+secretlemur28@users.noreply.github.com>
@seedds

seedds commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Landed on main as 275b11a, with you as co-author. Your decoding of the layout is unchanged, and so are your three tests.

Two structural changes:

  • Every entry from cra.py now names its layout in its last field (cra.LAYOUT / cra.LAYOUT_2021), for both layouts, and read/head check that field instead of the tuple's length.
  • A plain factory, cra.index(nro), replaces Index.__new__, so Fever's NRO is no longer searched twice. shader_split.py and the cra.py command use it.

The reference entry "One scrambled archive indexed by the NRO" in docs/reference/shaders.md now covers both layouts.

Checked here on Mario Golf 4.0.0 from its NSPs, with #2215 from main: all 5,101 files (4.1 GB) pass the game's checksums, read in 37 s, and the split finds 25,270 shaders in 18 s (the same count as yours). All of them translate, subsdk0 goes into the build row, and the game boots and plays its opening movie at 60 fps. On the game note: not yet. A note and a games-table row come when the game gets a registered profile.

@seedds seedds closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants