Skip to content

Load player RomFS mods, select the official pt-BR text, accept Opus packets without a final range - #32

Merged
ly05010419 merged 2 commits into
ly05010419:mainfrom
zecaro:feat/romfs-mods-ptbr
Oct 19, 2026
Merged

ly05010419 merged 2 commits into
ly05010419:mainfrom
zecaro:feat/romfs-mods-ptbr

Conversation

@zecaro

@zecaro zecaro commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Players on 1.4.3 could not use Nintendo's official Brazilian Portuguese text, and a RomFS mod with more than 16 files could not load at all.

Change

  • Player mods (runtime/romfs.c, app/launcher.m): the runtime loads ~/Library/Application Support/MacNativeGames/TOTK/mods/<version>/manifest.tsv after the build's overlays. The manifest format is the existing one (path, size, SHA-256, original SHA-256), and every listed file is still hashed at start. The fixed 16-entry table is gone. The overlays are sorted by RomFS index and found by binary search, and each overlay file is opened when the game opens it, so a mod with thousands of files does not hold a descriptor per file. TOTK_ROMFS_MODS overrides the folder, and 0 disables it.
  • pt-BR text (runtime/services.c, app/launcher.m): 1.4.3 ships Mals/USpt.Product.142.sarc.zs, the official pt-BR text. A Brazilian locale now selects pt-BR in the 1.4.3 build; other builds keep pt. The launcher passes the app's first preferred language as TOTK_LOCALE, so a per-app language works: defaults write org.macnativegames.totk AppleLanguages -array pt-BR. TOTK_LANG still overrides everything.
  • Opus packets without a final range (runtime/opus_codec.c): a fan dub's encoder writes 0 into the final-range field of every packet, and the runtime aborted with Opus stream integrity on the first dubbed line. A header range of 0 now skips only that comparison. A wrong nonzero range still stops the game.

Tested

1.4.3 (base NSP plus the 1.4.3 update), M4, macOS 27, before this rebase:

Check Result
probe-fs with a 1,560-file voice mod pass, 1,563 overlays verified and read back
One mod file changed by one byte stops with RomFS overlay integrity mismatch
Title screen with AppleLanguages pt-BR "Continuar", "Novo jogo", "Opções"
Real launch from Finder log shows RomFS overlay: 1560 files from .../mods/v143
opus_codec.c decode() over 1,560 dubbed voice files 127,287 packets, no failure (aborted before the change)
Same over the 1,560 original English files 139,079 packets, no failure
Original packet with its final range altered still stops with Opus stream integrity
Dubbed cutscene in game plays

Packet scan of the same files: none of the 280,723 packets in 1.4.3's English voice streams has a final range of 0. All 186,758 packets of the dub do, and all of them decode without error.

After the rebase onto f50f3bf: romfs.c, services.c, opus_codec.c and launcher.m compile with -Wall -Wextra -Werror for v0, v112, v121 and v143, and python -m unittest discover -s tests passes (68 tests). The rebuilt 1.4.3 app (15,321 startup shaders, 6,484 compiled into the app) passes --check, loads the 1,560-file mod with no failure, finishes the warm-up (34,882 items) and shows the pt-BR title screen.

Not tested

  • The pt-BR mapping and mods on 1.0.0, 1.1.2 and 1.2.1 builds in game. Those builds still map Portuguese to pt, as before.
  • iOS: the mods folder is set by the Mac launcher only.

- runtime/romfs.c: overlays have no fixed limit; each file opens when the game opens it.
  Player mods load from TOTK_ROMFS_MODS after the build's overlays, verified by SHA-256 at start.
- app/launcher.m: point TOTK_ROMFS_MODS at <data>/mods/<version> and pass the app's
  preferred language as TOTK_LOCALE, so a per-app language applies.
- runtime/services.c: Brazilian Portuguese maps to pt-BR in the 1.4.3 build (official USpt text).
- README, docs/how-it-works.md: mods folder, manifest format, per-app language.
A fan dub's encoder writes 0 into the final-range field of every Opus packet
(all 186,758 packets of the PKG PT-BR dub; they decode without error), while
none of the 280,723 packets in 1.4.3's English voice streams carries 0. The
runtime aborted with "Opus stream integrity" on the first dubbed line.
A header range of 0 now skips only that comparison; a wrong nonzero range
still stops the game.
ly05010419 added a commit that referenced this pull request Oct 19, 2026
…'s time, name clashing overlays, and get a manifest tool (after PR #32)

- runtime/romfs.c: an overlay file is opened when the game opens it; the device, inode, size and
  modification time from the start check must still match, otherwise the game stops instead of
  serving bytes nobody checked. Each overlay folder logs how much it hashed and how long it took.
  Two overlays replacing one file name both paths.
- scripts/make_mod_manifest.py: writes a mod's manifest.tsv from the app's (or a work folder's)
  RomFS index and image; files equal to the original are left out, unknown paths write nothing.
- Tested: 1.4.3 boots to the world with a mod; a mod clashing with the build's game-over patch
  stops the start and names both files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZC16EYkS2AmLMgumTJaXJ
@ly05010419
ly05010419 merged commit 4a8067c into ly05010419:main Oct 19, 2026
1 check passed
ly05010419 added a commit that referenced this pull request Oct 20, 2026
…ultrawide HUD, 1.4.3 survey, mods, controls.txt) into the Breath of the Wild branch

Resolved by hand: nvn_mtl.m (PR #34's paged-bitmap serial sets keep the serial forgetting of 635fb31: totk_serial_del
clears a bit; the memory line shows both; the BotW frame reset stays in mtl_present), build_app.py (make -j and the
per-game launcher defines), the Makefile (the BotW targets and the Opus test), loader.c (the #57 stale-reference handler
and 1.4.3's survey return address are TOTK-only: Breath of the Wild has no GAME_ADDR for them), world_survey.c (BotW
keeps its stub, with runtime_survey_sync), README (both update-history rows).

Found by the merged build: Breath of the Wild lacked runtime_output_size_current (frontend.m's shortcut text) and
runtime_survey_sync (hle_nvn.c); and the add-on content file handles shared fs_host.c's 0x200000000 range, so closing a
host file at the title ended the game ("close invalid add-on content handle"): they now start at 0x400000000.

Tested on the merged binaries: TOTK 1.2.1 jump session (anomalies 0, occlusion normal, serial set 48,606 / 13 pages),
Breath of the Wild DLC + key 3 (k3a6) and key 2 (k2c, 11 of 12 pairs within 5 px).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.

2 participants