Repository navigation
Conversation
v0lumehi
marked this pull request as ready for review
October 23, 2026 13:08
…ofiles (GitHub issue seedds#63) patch_nso.py held the general rewriter and every game's build-specific patches in one file, so work on different games kept editing the same lines. Now: - dm/tools/nso_asm.py: the instruction encoders (B, ADRP, LDRX, ...), shared by the rewriter and the patches. - dm/games/<id>/patches.py: a game's CUTS, OBS and, for builds with a frame-step state page, FRAME_STEP with apply(p), which adds the stubs through p.emit / p.here / p.fs_site / p.fs_put / p.fs_state_off and sets p.render_scale. 16 profiles have one; a game without patches has none. - dm/games/sdk_patches.py: the cuts of SDK builds (15), which several games can ship (nine of them are shared, one by four games); each entry names the games whose build rows list it. - patch_nso.py (1,711 → 1,103 lines) loads every file (load_patches; a build in two files stops it), applies what belongs to the build it rewrites and keeps the state page and its fs_site / fs_put. build_src.sha256 lists every source, and the NSP script's rewrite fingerprint covers the new files. Lines moved verbatim, comments included; the only rewrites are "if FS_STATE_OFF and BUILD_ID == '<id>':" → "def apply(p):" with one line binding the helpers, and "RENDER_SCALE = 1" → "p.render_scale = 1". Checked: CUTS (30 builds), OBS (2) and FRAME_STEP (4) equal to the old file's tables; each of the four frame-step blocks (Tears of the Kingdom, Breath of the Wild, Age of Calamity, Paper Mario) replayed old and new against a recording context gives the same calls (sites, emitted words, puts, render scale); Breath of the Wild (main, sdk, subsdk0) and Hades (main, sdk) rewrite byte-identically (all 30 output files but build_src.sha256).
…file it now lives in (the game's patches.py, or sdk_patches.py for SDK builds)
Contributor
Author
Owner
|
Thanks for putting this together, and for the careful checks. Replaying the four frame-step blocks against a recording context was a good way to cover the games you don't have files for. As you said when closing, f4f0a85 landed the same split, so this stays closed. It differs from the PR in a few places (full write-up on #63: #63 (comment)):
Thanks also for rebasing #76 onto it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the split proposed in #63. The change is mechanical, so it can be reviewed by checking it rather than by reading every line.
Layout
dm/tools/nso_asm.py: the instruction encoders (B,ADRP,LDRX, …), shared by the rewriter and the patches.dm/games/<id>/patches.py: one game'sCUTS,OBSand, for builds with a frame-step state page,FRAME_STEPwithapply(p). The stubs go throughp.emit,p.here,p.fs_site,p.fs_putandp.fs_state_off, and a render-scale stub setsp.render_scale = 1. 16 profiles have one; a game without patches has none.dm/games/sdk_patches.py: the cuts of SDK builds (15 builds). These can't live in one game's file: nine of them are shared between games, and one between four (Odyssey, Raging Loop, DQ XI S, Luigi's Mansion 3). Each entry names the games whosebuildrows list it.dm/tools/patch_nso.py(1,711 → 1,103 lines): it loads every file (load_patches; a build in two files is an error), applies what belongs to the build it rewrites, and keeps the state page and itsfs_site/fs_put.build_src.sha256now lists every source file, and the NSP script's rewrite fingerprint covers the new files, so editing apatches.pytriggers a rewrite.dm/games/README.mddescribes the format. Every place inAGENTS.md,docs/development.mdanddocs/agentsthat namedpatch_nso.pyfor a specific cut, gate or frame-step stub now names the file it lives in: the game'spatches.py, orsdk_patches.pyfor SDK builds (33 places, second commit). References to the general rewriter (spin waits, jump tables,pieces,half_count) still namepatch_nso.py.What stays the same
Lines moved verbatim, comments included. There are only two rewrites:
if FS_STATE_OFF and BUILD_ID == '<id>':→def apply(p):, plus one line binding the helpers.RENDER_SCALE = 1→p.render_scale = 1.Checks:
CUTS(30 builds),OBS(2) andFRAME_STEP(4) are equal to the old file's tables.main,sdk,subsdk0) and Hades (main,sdk) rewrite byte-identically: all 30 output files match, exceptbuild_src.sha256.Note
This conflicts with #76 in Breath of the Wild's frame-step block, since #76 adds stubs there. Whichever lands second, I'll rebase it: #76's stubs would move into
dm/games/01007EF00011E000/patches.py, and itsFS_KEYSwould become a field ofp.