From fe494aa0d0671a0b044966e92ac8c29a8c9e6b12 Mon Sep 17 00:00:00 2001 From: padsiwono <169828080+padsiwono@users.noreply.github.com> Date: Sun, 8 Nov 2026 20:04:47 +0100 Subject: [PATCH 1/4] patch_nso.py: room for the frame step state page when the key page ends on a 64 KB boundary Symptom: adding a FRAME_STEP stub for Hades II 1.0.131248's main stopped the rewrite with "AssertionError: frame step state page". Cause: the state page is the page after the key page, and the appended patch area starts at the next 64 KB boundary after the key page. This main's key page is 0x590c000-0x5910000, so the patch area started at 0x5910000, exactly where the state page goes. Fix: when a main has frame step stubs (FRAME_STEP or MATCH_FRAME_STEP) and the key page ends there, the patch area starts 64 KB later. Modules without stubs, and those whose rounding already leaves the page free, keep their layout. Checked: dm/tools/tests/test_frame_step_page.py (new; a synthetic main whose key page ends on 64 KB fails without the change, and with it gets state page 0x10000 and patch area 0x20000; the two other layouts are unchanged); test_nso_match, test_patches, test_exclusive_windows, test_rewrite_parallel, test_spin_waits, test_jump_copies, test_acquire_lock and test_docs pass; lint_python.py: no new finding of its own (main's ue_cvar.py:65 shows on main too). Hades II 1.0.131248's main with the render-size stub: state page 0x5910000, patch area 0x5920000. Reference entry in docs/reference/rewriter.md, symptom index regenerated. Co-Authored-By: Claude Opus 5.5 --- dm/tools/patch_nso.py | 3 ++ dm/tools/tests/test_frame_step_page.py | 55 ++++++++++++++++++++++++++ docs/agents/symptoms.md | 1 + docs/reference/rewriter.md | 7 ++++ 4 files changed, 66 insertions(+) create mode 100644 dm/tools/tests/test_frame_step_page.py diff --git a/dm/tools/patch_nso.py b/dm/tools/patch_nso.py index c0594bb86a..5c90c262b3 100644 --- a/dm/tools/patch_nso.py +++ b/dm/tools/patch_nso.py @@ -246,6 +246,9 @@ def load_patches(): print(f'{NAME}: {ue_ring_why}') elif ue_ring_why.startswith('[RED] '): print(f'[RED] {NAME}: {ue_ring_why[6:]}: its dynamic buffers keep 3 copies') +# A main with frame step stubs takes the page after the key page as its state page ("Frame step in whole vsyncs"). The appended layout rounds the patch area up to 64 KB, which leaves +# that page free unless the key page ends on a 64 KB boundary (Hades II 1.0.131248: key page 0x590c000, patch area 0x5910000); the patch area then starts 64 KB later +if not FAR and NAME == 'main' and (BUILD_ID in PATCHES['FRAME_STEP'] or FS_MATCH) and KEY_PAGE_OFF + 0x8000 > PATCH_OFF: PATCH_OFF += 0x10000 md = Cs(CS_ARCH_ARM64, CS_MODE_ARM); md.detail = True patch = bytearray(); fix = []; gates = []; stats = {} patch_front, patch_back, PATCH_BASE = patch, bytearray(), PATCH_OFF # the area emit() writes into and its offset: the front one unless TWO puts a site in the back one diff --git a/dm/tools/tests/test_frame_step_page.py b/dm/tools/tests/test_frame_step_page.py new file mode 100644 index 0000000000..27b55aa4b6 --- /dev/null +++ b/dm/tools/tests/test_frame_step_page.py @@ -0,0 +1,55 @@ +"""dm/tools/patch_nso.py: the frame step state page (the page after the key page) stays free when the key page ends on a 64 KB boundary, where the appended patch area would start +right after it (Hades II 1.0.131248: key page 0x590c000, patch area 0x5910000, and the rewrite stopped with 'frame step state page'); modules without frame step stubs keep their layout""" +import os +from pathlib import Path +import struct +import subprocess +import sys +import tempfile +import unittest + +REPO = Path(__file__).resolve().parents[3] +sys.path.insert(0, str(REPO / 'dm/tools/tests')) +from test_nso import make_nso + +BUILD_ID = bytes(range(0x10)).hex() # make_nso's build ID + + +def module(bss): + """A main of 0x1000 of NOPs, an empty eh_frame_hdr in ro and 0x1000 of data: image 0x3000, then bss""" + text = bytearray(struct.pack(' Date: Sun, 8 Nov 2026 20:05:56 +0100 Subject: [PATCH 2/4] Hades II 1.0.131248 renders natively above 720p: a Resolution setting (DM_RENDER_SIZE) sets the size its app init takes Symptom: Hades II renders a fixed 1280x720 on the Mac too, and the Mac scales that up (issue #772). Cause: the app's init (main+0x2a4d20 in 1.0.131248, the function that also runs the main loop) writes the size as one constant right after nn::vi::CreateLayer, mov x8,#0x500; movk x8,#0x2d0,lsl #32 at main+0x2a4eb0, and stores it to the app settings and the window rectangle. The swapchain and every screen-sized target follow it. Fix: a frame-step stub at that site takes the size from the state page (+0x38, u32 width and height), written by the loader from DM_RENDER_SIZE=x (16:9, 1280x720 to 3840x2160; 0 keeps 1280x720). The stub declares the RENDER_SIZE capability, which offers the launcher's Resolution row. The profile registers 1.0.131248's build (v196608) for it; its shaders are not in the tables, so it is packed from a derived profile as before. Needs the previous commit (room for the state page). Checked: built from the base game and 1.0.131248 NSPs (main and sdk rewritten, state page 0x5910000, patch area 0x5920000, the stub at main+0x2a4eb0, Resolution in launcher.json). Headless on an M5 Max, the opening into Erebus, 110 s per size at DM_PRESENT_HZ=120: 1280x720, 1920x1080 and 3840x2160 without a fault, the swap chain at the size, every 300-frame window at 8.33 ms, GPU per frame 2.18 / 3.31 / 3.75 ms; a 4K still shows the scene and HUD at 3840x2160, the painted art as soft as its textures. Host unit tests, test_patches, test_settings, test_launcher_settings, test_player_env, test_game_profile and test_docs pass; lint_python.py: no new finding of its own. v0 has no stub. Co-Authored-By: Claude Opus 5.5 --- dm/games/0100A00019DE0000/README.md | 1 + dm/games/0100A00019DE0000/game.tsv | 2 ++ dm/games/0100A00019DE0000/patches.py | 32 ++++++++++++++++++++++++++++ dm/games/settings.tsv | 1 + dm/host/loader.c | 10 +++++++++ dm/tools/patch_nso.py | 3 ++- docs/agents/game-patches.md | 12 +++++++++++ docs/env_switches.tsv | 1 + docs/settings.md | 6 +++++- 9 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 dm/games/0100A00019DE0000/patches.py diff --git a/dm/games/0100A00019DE0000/README.md b/dm/games/0100A00019DE0000/README.md index 9058fe3502..9738d4916b 100644 --- a/dm/games/0100A00019DE0000/README.md +++ b/dm/games/0100A00019DE0000/README.md @@ -19,6 +19,7 @@ Base game v0 (the NACP's display version is 0.0.126424), SDK 19.3.9. Supergiant ## Rendering +- **Current: native render size on 1.0.131248 (Mac).** The game renders a fixed 1280x720, set by one constant in its app init: `mov x8,#0x500; movk x8,#0x2d0,lsl #32` at `main+0x2a4eb0` (v196608), stored to the app settings and the window rectangle; the swapchain and every screen-sized target follow it. A frame-step stub there takes the size from `DM_RENDER_SIZE` (the launcher's Resolution: 1280x720, 1920x1080, 2560x1440, 3840x2160). Headless on an M5 Max (macOS 26.6.2), opening into Erebus, one run per size: 45 full-size and 16 half-size targets follow the size, the HUD is laid out for it, no fault at 1600x900 to 3840x2160; GPU per frame (median of 43 windows of 300 frames, `DM_PRESENT_HZ=120`) 2.25 ms at 720p, 3.26 ms at 1080p, 4.83 ms at 1440p, 6.72 ms at 4K. In a 4K still at 1:1 the painted art is as soft as an upscale (its textures look made for 1080p or less; their sizes not read): the gain is in the HUD, text and edges. A player who applied the same change confirmed 1080p at a locked 60 fps on an M1 MacBook Air with 8 GB, version not stated ([issue 772](https://github.com/seedds/nxnative/issues/772)). v0 has no stub: PR 485 reports it crashing at 1600x900 (`main+0x48e5a4`) with the same two instructions patched at `main+0x2a6080`. - **Current: textures at fixed, sparse slots.** Its 88 shaders bind combined textures at slots 0, 1, 3, 6, 8, 11, 15, 21, 25, 26, 30, 31 and 34. Slot 34 (`SceneFade.frag`, c2 0x130; `fp_t_tcb_4C`: c2 word 0x4C = 0x20 + 8 × 34) lies past the driver's 32 combined slots, inside the image table at 0x120. With a 32-slot table, `dmsh_build.py` reported that binding as not decoded (`shaders with a binding whose slot was not decoded 1`, which prints a red line when the shader loads). The combined table now runs up to the separate textures at 0x168 (41 slots); past slot 31 it shares its words with the image table, and the replay writes a bound texture there when the image slot is unbound (`nvn_mtl.m`). The game has no image bindings, so a bound texture there wins. The census of `fp_t_*` names in the translated libraries gives the slots in use. - **Not a bug: two long lines through Melinoë.** While the staff's Omega attack charges, two thin white lines run from her to the screen edges, one forward and one back. They are that weapon's aim lines (`WeaponStaffSwing5`: `AimLineCountOverride = 2`, `AimLineAngleOffsetOverride = 180`, animation `AuraAimLineNoMovementStaff`). The sprite is a long arrow with white edges, a dark fill drawn emissive and its tip off-screen, and the game hides it while she moves. Traced with `DM_NVN_CBDUMP` vertex dumps and `DM_PROBE` on the aim-line update (`main+0x39ade0`); a scripted run that taps Y shows them often. diff --git a/dm/games/0100A00019DE0000/game.tsv b/dm/games/0100A00019DE0000/game.tsv index aca851d67f..65720df59d 100644 --- a/dm/games/0100A00019DE0000/game.tsv +++ b/dm/games/0100A00019DE0000/game.tsv @@ -17,6 +17,8 @@ pad_layout full # ---- Versions ---- build v0 0.0.126424 main=5219053e5eb156be80fbb2f303779531 sdk=d83a56a5558798414c78ec722867a7da +# 1.0.131248 (v196608): registered for its render-size stub (patches.py); its shaders are not in the tables, so the NSP script packs it from a derived profile +build v196608 1.0.131248 main=e4f736641889b26f3194847d2b9dce57 sdk=190030518b5d64e5d87b84bc54661af9 package v0 shader_versions v0 diff --git a/dm/games/0100A00019DE0000/patches.py b/dm/games/0100A00019DE0000/patches.py new file mode 100644 index 0000000000..3e111aa1da --- /dev/null +++ b/dm/games/0100A00019DE0000/patches.py @@ -0,0 +1,32 @@ +# Hades II (0100A00019DE0000): the rewriter's patches of this game's own builds. dm/tools/patch_nso.py loads every profile's patches.py and applies those of a module's NSO build ID; +# FRAME_STEP as described there ("Registered patches"). Patches of Nintendo SDK module builds are in dm/tools/sdk_patches.py +from nso_asm import ADRP, B, LDRX, NOP + +# Render size. Supergiant's engine sizes the swapchain and every screen-sized target from the app settings' width and height. On the Switch the app's init (main+0x2a4d20 in +# 1.0.131248 = v196608, the function that also runs the main loop) writes them as one constant right after nn::vi::CreateLayer: mov x8,#0x500; movk x8,#0x2d0,lsl #32 +# (1280 | 720 << 32) at main+0x2a4eb0, stored to settings +8 and to the window's rectangle {0, 0, w, h}. Next to it the init stores a pointer to the PC version's resolution +# table (main+0x6c837c: 1280x720, 1920x1080, 2560x1440, 3840x2160), which nothing reads. The stub takes the size from the state page (+0x38: u32 width, u32 height; DM_RENDER_SIZE, +# written by the loader) and keeps 1280x720 when it is 0. x8 is written by the stub before its only read. Measured headless on the Mac (M5 Max): at 1600x900, 1920x1080, 2560x1440 +# and 3840x2160 the swapchain and the 45 full-size and 16 half-size targets of a frame follow the size, the HUD is laid out for it, and the game runs the opening into Erebus +# without a fault. PR #485 reports v0 crashing at 1600x900 (main+0x48e5a4) with the same two instructions patched at main+0x2a6080; that did not happen on this build +def frame_step_v196608(ctx): + ctx.site(0x2a4eb0, '08a080d2085ac0f2') + start = ctx.here(); ctx.emit(ADRP(8, ctx.here(), ctx.state)); ctx.emit(LDRX(8, 8, 0x38 // 8)) # ldr x8,[state,#0x38] width | height << 32 + for w in (0xb5000068, # cbnz x8,back (+3) + 0xd280a008, # mov x8,#0x500 1280 (the original) + 0xf2c05a08): # movk x8,#0x2d0,lsl #32 720 + ctx.emit(w) + ctx.emit(B(ctx.here(), 0x2a4eb8)) + ctx.put(0x2a4eb0, [B(0x2a4eb0, start), NOP], 'app settings width and height: the state page\'s render size (DM_RENDER_SIZE), 1280x720 when it is 0') + ctx.capabilities.add('RENDER_SIZE') + +FRAME_STEP = {'e4f736641889b26f3194847d2b9dce57': frame_step_v196608} + +# How general each patch is and could be (dm/tools/docs_patches.py "Binding", listed in docs/agents/game-patches.md): what, its binding now, the loosest it could have (goal), +# purpose, why; blocked or kept: why the gap stays open (cannot close yet, or left open on purpose); checked: what was checked on game files (else a judgement) +BINDING = [ + {'what': 'render size: the app settings\' width and height from the state page', 'now': 'build', 'goal': 'game', 'purpose': 'rendering', + 'why': "the game's own init constant; the same two instructions sit at main+0x2a6080 in v0, so a function-matched rule could carry it over the updates", + 'kept': 'tested on 1.0.131248 only; PR #485 saw v0 crash at 1600x900 with the same change, so each build needs its own run first', + 'checked': '1.0.131248 headless at 1600x900, 1920x1080, 2560x1440 and 3840x2160 (M5 Max, macOS 26.6.2)'}, +] diff --git a/dm/games/settings.tsv b/dm/games/settings.tsv index 15f4824107..7de392cfe3 100644 --- a/dm/games/settings.tsv +++ b/dm/games/settings.tsv @@ -17,6 +17,7 @@ DM_FPS_TARGET choice 30=30 fps,60=60 fps,120=120 fps?DM_GAME_FPS_MAX==120&platform:mac DM_GAME_FPS_TARGET DM_GAME_FPS_TARGET!=0 Game Frame rate level=basic DM_DYNAMIC_RESOLUTION toggle - 0 fixups:DYNAMIC_RESOLUTION Game Dynamic resolution Lets the game lower its resolution under load. Turn off to keep full resolution for the selected console mode. DM_RENDER_SCALE range 0.5:1.0:0.05 1.0 fixups:RENDER_SCALE Game Render scale level=basic +DM_RENDER_SIZE choice 0=1280 × 720 (Switch),1920x1080=1920 × 1080,2560x1440=2560 × 1440,3840x2160=3840 × 2160 0 fixups:RENDER_SIZE Game Resolution Higher sizes take more GPU time per frame level=basic DM_OPMODE choice 1=Docked,0=Handheld DM_GAME_OPMODE always Game Console mode level=basic DM_PRESENT_UPSCALE choice off=Standard,metalfx=MetalFX off always Game Upscaling Uses more GPU time and can increase heat. DM_UPSCALER choice game=Game's own,metalfx=MetalFX game DM_GAME_UPSCALER_N!=0 Game Game's upscaler diff --git a/dm/host/loader.c b/dm/host/loader.c index da3a970c9e..1ba2825098 100644 --- a/dm/host/loader.c +++ b/dm/host/loader.c @@ -326,6 +326,16 @@ void dm_fps_state_apply(void) { const char *dr = getenv("DM_DYNAMIC_RESOLUTION"); uint32_t dyn = dr && !strcmp(dr, "1"); if (dr && strcmp(dr, "0") && strcmp(dr, "1")) LOG("[RED] DM_DYNAMIC_RESOLUTION=%s: must be 0 or 1; keeping full resolution", dr); memcpy(dm_fps_state + 0x40, &dyn, sizeof dyn); + // Render size, for builds whose stub reads it (the RENDER_SIZE capability: Hades II 1.0.131248's app init): DM_RENDER_SIZE=x, 16:9 from 1280x720 to 3840x2160, sets the + // game's own swapchain and screen-sized targets; unset or 0 keeps the game's size. Builds without such a stub ignore the field + const char *rz = getenv("DM_RENDER_SIZE"); uint32_t wh[2] = {0, 0}; + if (rz && strcmp(rz, "0")) { + unsigned w = 0, h = 0; char tail = 0; + if (sscanf(rz, "%ux%u%c", &w, &h, &tail) != 2 || w * 9 != h * 16 || w < 1280 || w > 3840) + LOG("[RED] DM_RENDER_SIZE=%s: must be x, 16:9, from 1280x720 to 3840x2160; keeping the game's size", rz); + else { wh[0] = w; wh[1] = h; LOG("%s: render size %ux%u (DM_RENDER_SIZE)", g_fps_mod, w, h); } + } + memcpy(dm_fps_state + 0x38, wh, sizeof wh); // Screen shape: DM_SCREEN_ASPECT, the screen's width / height between 1.3 and 1.77, makes the builds with screen-shape stubs // (Breath of the Wild 1.9.0's patches.py) render that shape: the output keeps its width (1920) and takes the height that gives the ratio, a multiple of 48 so the // 2/3-size layout space (1280 wide) stays whole: 1.43 → 1920x1344 and 1280x896. State +0x48 u32 output height, +0x4c u32 layout height, +0x50 its float; 0 = 16:9 diff --git a/dm/tools/patch_nso.py b/dm/tools/patch_nso.py index 5c90c262b3..e39c72f2f9 100644 --- a/dm/tools/patch_nso.py +++ b/dm/tools/patch_nso.py @@ -1557,7 +1557,8 @@ def stdalloc_gates(): # runs the original instructions), +4 30 fps movie/cinematic flag, +8 double lead (TOTK), +0x10 float render scale (TOTK, BotW), +0x18 double game seconds (TOTK), # +0x20 u32 step in vsyncs (host; 0 = not decided yet), +0x24 u32 a step the game fixes itself (BotW's VFR override; 0 = none), +0x28 u32 AoC's vsyncs per update, marked by # its first stub (0 = off), +0x30 u64 vsyncs stepped (the stubs; logged by the host to check the game's speed), +0x40 u32 1 = the game's own dynamic resolution runs, 0 = its -# stub holds full resolution (DM_DYNAMIC_RESOLUTION, written by the loader; the stub declares the DYNAMIC_RESOLUTION capability). Stub bodies assembled with clang +# stub holds full resolution (DM_DYNAMIC_RESOLUTION, written by the loader; the stub declares the DYNAMIC_RESOLUTION capability), +0x38 u32 width, u32 height of the game's render size +# (Hades II 1.0.131248; DM_RENDER_SIZE, written by the loader, 0 = the game's own; the stub declares the RENDER_SIZE capability). Stub bodies assembled with clang # A build's stubs are FRAME_STEP[build ID](ctx) in its patches.py: ctx.here() / ctx.emit(word) assemble into the patch area, ctx.site(offset, original bytes) asserts a site and that it is # no rewrite site, ctx.put(offset, words, reason) writes it (listed with the cuts), ctx.state is the state page's offset, ctx.render_scale = 1 marks a render-scale stub, # ctx.others the other functions a MATCH_FRAME_STEP rule names, ctx.address(offset) the data address an adrp there and the add / load / store after it make (in the original diff --git a/docs/agents/game-patches.md b/docs/agents/game-patches.md index 308d350a66..170f46c522 100644 --- a/docs/agents/game-patches.md +++ b/docs/agents/game-patches.md @@ -49,6 +49,7 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep | `build` → `game` | 60 fps frame step (112 sites) | frame rate | kept: 1.0.1 (2019) is the last update; a function match would serve no other build of this game | checked: nso_fnmap of its 112 sites into those four mains (2026-11-09) | 1 | [ASTRAL CHAIN](../../dm/games/01007300020FA000/README.md) | the game's own clock and timers (a community 60 fps mod on the host's frame step). PlatinumGames' other games do not share them: none of its 15 functions has an exact match in Bayonetta, Bayonetta 2, Bayonetta 3 or NieR:Automata | | `build` → `game` | 60 fps frame step and render scale (ksys::VFR) | frame rate | kept: 44 sites in 34 functions to fingerprint for an update that may not come (1.9.0, the Switch 2 Edition release); convert when a new build appears | checked: nso_fnmap of its 44 sites into those 13 mains (2026-11-09) | 1 | [The Legend of Zelda: Breath of the Wild](../../dm/games/01007EF00011E000/README.md) | the game's own frame code; the frame-step state page is general. No engine sibling shares it: none of its 34 functions has an exact match in Tears of the Kingdom, SMO, MK8D, ACNH, Splatoon 2 / 3, Kirby, Mario Party, Ocarina, Smash, Metroid Dread or Origami King (only the widescreen stubs' sead::PerspectiveProjection functions recur) | | `build` → `game` | Hagi coroutine stack region 1 GB → 64 MB | memory | kept: 1.1.4 is the last update; a match over Hagi would serve no other build of this game | checked: the final build 1.1.4 (the only one the profile packs), 2026-11-04 | 1 | [Super Mario 3D All-Stars: Super Mario Sunshine](../../dm/games/010049900F546002/README.md) | a size inside Hagi's own code: nothing the host sees tells a 1 GB reservation it can shrink from one it cannot | +| `build` → `game` | render size: the app settings' width and height from the state page | rendering | kept: tested on 1.0.131248 only; PR #485 saw v0 crash at 1600x900 with the same change, so each build needs its own run first | checked: 1.0.131248 headless at 1600x900, 1920x1080, 2560x1440 and 3840x2160 (M5 Max, macOS 26.6.2) | 1 | [Hades II](../../dm/games/0100A00019DE0000/README.md) | the game's own init constant; the same two instructions sit at main+0x2a6080 in v0, so a function-matched rule could carry it over the updates | ## Summary @@ -61,6 +62,7 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep | [EA SPORTS FC 27](#ea-sports-fc-27) | 0 | 0 | 0 | 0 | 1 | `build` → `engine` | | [FINAL FANTASY TACTICS - The Ivalice Chronicles](#final-fantasy-tactics---the-ivalice-chronicles) | 2 | 0 | 0 | 0 | 0 | `build` → `game` | | [Fire Emblem: Three Houses](#fire-emblem-three-houses) | 7 | 0 | 0 | 0 | 0 | `build` → `game` | +| [Hades II](#hades-ii) | 0 | 0 | 1 | 0 | 0 | `build` → `game` | | [Hyrule Warriors: Age of Calamity](#hyrule-warriors-age-of-calamity) | 0 | 0 | 10 | 0 | 0 | `game`, `build` → `game` | | [Luigi's Mansion 3](#luigis-mansion-3) | 0 | 0 | 0 | 0 | 1 | `build` → `engine` | | [Mario + Rabbids® Sparks of Hope](#mario--rabbids-sparks-of-hope) | 1 | 0 | 0 | 0 | 0 | `build` → `game` | @@ -296,6 +298,16 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep - cut `+0x50f8f0`: render thread wait timeout: adrp x8,#0xcb7000 → fdiv s0,s8,s0 (1000/fps; the fmul by s8 that follows makes it µs) - cut `+0x50f8f4`: render thread wait timeout: ldr s8,[x8,#0xb50] → nop (moved up) +### Hades II + +[Hades II](../../dm/games/0100A00019DE0000/README.md), `0100A00019DE0000`, [patches.py](../../dm/games/0100A00019DE0000/patches.py). + +- **`build` → `game`**, rendering, kept: tested on 1.0.131248 only; PR #485 saw v0 crash at 1600x900 with the same change, so each build needs its own run first, checked: 1.0.131248 headless at 1600x900, 1920x1080, 2560x1440 and 3840x2160 (M5 Max, macOS 26.6.2): render size: the app settings' width and height from the state page. The game's own init constant; the same two instructions sit at main+0x2a6080 in v0, so a function-matched rule could carry it over the updates + +- **1.0.131248 `main`** `e4f73664…` ([patches.py:23](../../dm/games/0100A00019DE0000/patches.py#L23)) + - frame step `+0x2a4eb0`: app settings width and height: the state page's render size (DM_RENDER_SIZE), 1280x720 when it is 0 + - launcher capabilities: RENDER_SIZE + ### Hyrule Warriors: Age of Calamity [Hyrule Warriors: Age of Calamity](../../dm/games/01002B00111A2000/README.md), `01002B00111A2000`, [patches.py](../../dm/games/01002B00111A2000/patches.py). diff --git a/docs/env_switches.tsv b/docs/env_switches.tsv index 6e4fe5a52a..57ea22de5d 100644 --- a/docs/env_switches.tsv +++ b/docs/env_switches.tsv @@ -293,6 +293,7 @@ DM_QOS_MAP switch `=1` maps guest thread priority to QoS class: ≤ 44 user-inte DM_REC diagnostic `=`: writes player 1's physical input (keyboard, mouse touches, controllers; never `DM_KEYS` / `DM_CTL`) to the file as `DM_KEYS` steps in presented frames, for replaying a run (`DM_KEYS=@`) DM_REGIONS diagnostic `=` writes the table of the SDK's address regions every 2 s (alias offset, size, where the request returns to in the game, bytes mapped, the part opened, the SDK offset the request came through; `hle_svc.c` "Address regions"); the NSP script's address region check sets it DM_RENDER_SCALE player `0.5` to `1.0`: fixes the game's 3D views at that fraction of their size and turns its dynamic resolution off, for builds with a render scale stub; `1.0` (the default) keeps it +DM_RENDER_SIZE player `x` (16:9, `1280x720` to `3840x2160`): the size the game renders at, its swapchain and screen-sized targets, for builds with a render-size stub (the RENDER_SIZE capability: Hades II 1.0.131248); `0` or unset keeps the game's own DM_RESOURCE_AOC path The add-on content folder the iOS build copies into the app's `aoc/` (empty for none); written by `gen_resources.py`, read by `stage_resources.sh` DM_RESOURCE_BUILD switch Package version (for example `v327680`), written to `Gen/resources.env` by `gen_resources.py`; with `DM_COPY_ROMFS=NO` the copy phase puts it in the `build=` field of the app's `romfs.id` DM_RESOURCE_CHAIN_H path Path of `dm/gfx/nvn/dmsh_chain.h`, written to `Gen/resources.env` by `build_ipa.sh`; the Xcode copy phase (`stage_resources.sh`) stops when the prepared shaders are not of its chain version diff --git a/docs/settings.md b/docs/settings.md index a826eeeacf..f613816daf 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -3,7 +3,7 @@ The screen before the game starts shows the settings the game supports. A setting that only matters while another is on appears under it and disappears when that one is turned off. Tap **Play** to start; the app remembers your choices for the next start. All settings are on one scrollable screen, under **Game**, **Controls** and **Performance**. Tap a menu or move a slider there; no settings page needs opening. **Upscaling** is in **Game**, beside **Console mode**. A Mac app shows the same settings in a [window of its own](#the-mac-settings-window). - [Tested defaults](#tested-defaults) -- [Game](#game): [Frame rate](#frame-rate), [Render scale](#render-scale), [Console mode](#console-mode), [Upscaling](#upscaling), [Game's upscaler](#games-upscaler), [Game language](#game-language), [Picture](#picture), [Frame-rate counter](#frame-rate-counter) +- [Game](#game): [Frame rate](#frame-rate), [Render scale](#render-scale), [Resolution](#resolution), [Console mode](#console-mode), [Upscaling](#upscaling), [Game's upscaler](#games-upscaler), [Game language](#game-language), [Picture](#picture), [Frame-rate counter](#frame-rate-counter) - [Controls](#controls): [Touch feedback](#touch-feedback), [Game rumble](#game-rumble), [Rumble strength](#rumble-strength), [Rumble cutoff](#rumble-cutoff), [Press a button to join](#press-a-button-to-join) - [Performance](#performance): [Frame buffering](#frame-buffering), [Metal 4 pipelines](#metal-4-pipelines), [Pipeline prebuild](#pipeline-prebuild), [Encode thread](#encode-thread), [Hold frames when late](#hold-frames-when-late), [Performance HUD](#performance-hud), [Reset to tested defaults](#reset-to-tested-defaults) - [The Mac settings window](#the-mac-settings-window): [Display mode](#display-mode) @@ -35,6 +35,10 @@ Off, the default, keeps the 3D picture at full size. On lets the game lower its The size of the 3D picture, from 50 to 100 %. Below 100 % the size is fixed there and the game's own dynamic resolution is off; 100 % keeps the game's own. Lower can be lighter on the GPU but is blurrier; the HUD and text keep their sharpness. Only games the app can scale offer it. +### Resolution + +The size the game renders at, for games the app can resize (Hades II 1.0.131248): **1280 × 720** as on the Switch, **1920 × 1080**, **2560 × 1440** or **3840 × 2160**. A larger size is sharper on a larger screen and takes more GPU time per frame; the HUD and text are laid out for the size. + ### Console mode **Docked** renders at the Switch's TV resolution, **Handheld** at its lower handheld resolution, which is lighter on the phone and can give a higher frame rate. From 43316a4883f65a606977f54545968f917b5a5981 Mon Sep 17 00:00:00 2001 From: padsiwono <169828080+padsiwono@users.noreply.github.com> Date: Sun, 8 Nov 2026 21:10:18 +0100 Subject: [PATCH 3/4] Hades II note: the art's stored scale, read from the package manifests The note said the art only looked made for 1080p or less. The manifests (Packages/NVN/*.pkg_manifest) give each sprite its original and stored size and a scale: 1.5 for 3,764 of 4,797 sprites read, 1.48 to 1.52 for most others. So 1.0.131248 stores its art at 2/3 of its original size, and a larger render size magnifies it 1.5x at 1080p and 3x at 4K while the HUD, text and edges get sharper. Co-Authored-By: Claude Opus 5.5 --- dm/games/0100A00019DE0000/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/games/0100A00019DE0000/README.md b/dm/games/0100A00019DE0000/README.md index 9738d4916b..1f63d9c6e1 100644 --- a/dm/games/0100A00019DE0000/README.md +++ b/dm/games/0100A00019DE0000/README.md @@ -19,7 +19,7 @@ Base game v0 (the NACP's display version is 0.0.126424), SDK 19.3.9. Supergiant ## Rendering -- **Current: native render size on 1.0.131248 (Mac).** The game renders a fixed 1280x720, set by one constant in its app init: `mov x8,#0x500; movk x8,#0x2d0,lsl #32` at `main+0x2a4eb0` (v196608), stored to the app settings and the window rectangle; the swapchain and every screen-sized target follow it. A frame-step stub there takes the size from `DM_RENDER_SIZE` (the launcher's Resolution: 1280x720, 1920x1080, 2560x1440, 3840x2160). Headless on an M5 Max (macOS 26.6.2), opening into Erebus, one run per size: 45 full-size and 16 half-size targets follow the size, the HUD is laid out for it, no fault at 1600x900 to 3840x2160; GPU per frame (median of 43 windows of 300 frames, `DM_PRESENT_HZ=120`) 2.25 ms at 720p, 3.26 ms at 1080p, 4.83 ms at 1440p, 6.72 ms at 4K. In a 4K still at 1:1 the painted art is as soft as an upscale (its textures look made for 1080p or less; their sizes not read): the gain is in the HUD, text and edges. A player who applied the same change confirmed 1080p at a locked 60 fps on an M1 MacBook Air with 8 GB, version not stated ([issue 772](https://github.com/seedds/nxnative/issues/772)). v0 has no stub: PR 485 reports it crashing at 1600x900 (`main+0x48e5a4`) with the same two instructions patched at `main+0x2a6080`. +- **Current: native render size on 1.0.131248 (Mac).** The game renders a fixed 1280x720, set by one constant in its app init: `mov x8,#0x500; movk x8,#0x2d0,lsl #32` at `main+0x2a4eb0` (v196608), stored to the app settings and the window rectangle; the swapchain and every screen-sized target follow it. A frame-step stub there takes the size from `DM_RENDER_SIZE` (the launcher's Resolution: 1280x720, 1920x1080, 2560x1440, 3840x2160). Headless on an M5 Max (macOS 26.6.2), opening into Erebus, one run per size: 45 full-size and 16 half-size targets follow the size, the HUD is laid out for it, no fault at 1600x900 to 3840x2160; GPU per frame (median of 43 windows of 300 frames, `DM_PRESENT_HZ=120`) 2.25 ms at 720p, 3.26 ms at 1080p, 4.83 ms at 1440p, 6.72 ms at 4K. The art is stored at 2/3 of its original size: the package manifests (`Packages/NVN/*.pkg_manifest`) give each sprite a scale of original / stored size, 1.5 for 3,764 of 4,797 sprites read and 1.48 to 1.52 for most others (720p-sized art if the originals were made for 1080p). A larger size sharpens the HUD, text and edges; the art is magnified 1.5x at 1080p and 3x at 4K (soft in a 4K still at 1:1). A player who applied the same change confirmed 1080p at a locked 60 fps on an M1 MacBook Air with 8 GB, version not stated ([issue 772](https://github.com/seedds/nxnative/issues/772)). v0 has no stub: PR 485 reports it crashing at 1600x900 (`main+0x48e5a4`) with the same two instructions patched at `main+0x2a6080`. - **Current: textures at fixed, sparse slots.** Its 88 shaders bind combined textures at slots 0, 1, 3, 6, 8, 11, 15, 21, 25, 26, 30, 31 and 34. Slot 34 (`SceneFade.frag`, c2 0x130; `fp_t_tcb_4C`: c2 word 0x4C = 0x20 + 8 × 34) lies past the driver's 32 combined slots, inside the image table at 0x120. With a 32-slot table, `dmsh_build.py` reported that binding as not decoded (`shaders with a binding whose slot was not decoded 1`, which prints a red line when the shader loads). The combined table now runs up to the separate textures at 0x168 (41 slots); past slot 31 it shares its words with the image table, and the replay writes a bound texture there when the image slot is unbound (`nvn_mtl.m`). The game has no image bindings, so a bound texture there wins. The census of `fp_t_*` names in the translated libraries gives the slots in use. - **Not a bug: two long lines through Melinoë.** While the staff's Omega attack charges, two thin white lines run from her to the screen edges, one forward and one back. They are that weapon's aim lines (`WeaponStaffSwing5`: `AimLineCountOverride = 2`, `AimLineAngleOffsetOverride = 180`, animation `AuraAimLineNoMovementStaff`). The sprite is a long arrow with white edges, a dark fill drawn emissive and its tip off-screen, and the game hides it while she moves. Traced with `DM_NVN_CBDUMP` vertex dumps and `DM_PROBE` on the aim-line update (`main+0x39ade0`); a scripted run that taps Y shows them often. From 4e2b993fc6564a441c79ba4bd97877971ca7fa8d Mon Sep 17 00:00:00 2001 From: padsiwono <169828080+padsiwono@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:18:17 +0100 Subject: [PATCH 4/4] Ocarina of Time v131072 renders at the launcher's Resolution (DM_RENDER_SIZE), docked The game sizes its docked output and render targets from fixed 2560x1440 constants. Stubs at those sites (the ones PR #1460 found for its ultrawide cuts: main+0x1202ee0, +0x31f39f4, the display mode table's 2560x1440 entry read at +0x112c604, and the float output size at +0xecbc80 / +0xecbcb4) take the state page's render size instead and keep the original for 0. Placed only when the frame-step function sits at v131072's place; they declare the RENDER_SIZE capability, so the launcher offers Resolution. The Resolution row's 0 now reads "Game's own (as on the Switch)", since the game's own size differs per game. Measured on an M5 Max (macOS 26.6.2), headless, n=1 each: 60 fps held at the game's own size, 2560x1440 and 3840x2160 (GPU p50 8.9 / 9.2 / 9.6 ms); in play at 2560x1440 and 3024x1702. Co-authored-by: vladbondarenko97 <12616782+vladbondarenko97@users.noreply.github.com> --- dm/games/0400486024DEC000/README.md | 6 +++ dm/games/0400486024DEC000/patches.py | 55 ++++++++++++++++++++++++++++ dm/games/settings.tsv | 2 +- dm/tools/patch_nso.py | 2 +- docs/agents/game-patches.md | 4 +- docs/env_switches.tsv | 2 +- docs/settings.md | 2 +- 7 files changed, 68 insertions(+), 5 deletions(-) diff --git a/dm/games/0400486024DEC000/README.md b/dm/games/0400486024DEC000/README.md index 98e00ecae0..8328bd4607 100644 --- a/dm/games/0400486024DEC000/README.md +++ b/dm/games/0400486024DEC000/README.md @@ -52,6 +52,12 @@ Measured on an M6 Mac with 16 GB, headless, on one walk with camera turns (`walk - With a window, the first start on a new chain runs the pipeline prebuild first: 33,190 shader pairs, 691 s on this Mac. A run with no window skips it. - The opening movie runs at the movie's own 24 fps pace during the story section and cannot be skipped: about 8 minutes on a new file. +## Render size + +- The launcher's **Resolution** (`DM_RENDER_SIZE`, v131072, docked): the game sizes its docked output and render targets from fixed 2560x1440 constants, and stubs at those sites (`patches.py`, the sites [PR 1460](https://github.com/seedds/nxnative/pull/1460) found for its ultrawide cuts) take the chosen size instead. The swapchain and every target that follows the output take it; the game still draws 80 % of the output (`nvnWindowSetCrop`, 3072x1728 at 3840x2160) and its 3D at most at its top level, ×0.75 of that. Handheld (1920x1080) is left alone. +- Measured (M5 Max, macOS 26.6.2, 2026-11-08, a 1-minute headless route from a save, n=1 each): every size held 60 fps (frame p50 16.7 ms); GPU p50 8.9 ms at the game's own size, 9.2 ms at 2560x1440 through the stubs, 9.6 ms at 3840x2160. On this Mac the frame hardly follows the size (see Dynamic resolution). In play, 2026-11-08 and 09: 2560x1440 (three sessions, 2 to 14 minutes) and 3024x1702 (a size not in the launcher's list; five sessions, up to 28 minutes), through Kakariko, Death Mountain Trail, Hyrule Field and Castle Town. +- Not checked: 1920x1080 docked (below the game's own size), handheld, other builds. + ## Dynamic resolution - The controller (v131072; found by fingerprint, so the addresses are only for reading): the parameters are `game__gfx__DynamicResolutionParam` (`LoadThreshold`, `ReduceCounterMax`, `IncreaseCounterMax`, and a list of levels, each a `ResolutionReduceScale` and a `Priority`). Once a frame the update (`main+0x805aa0`) reads the frame's GPU time, subtracts what its cost model predicts at the current size and keeps the trend of that residual. The level function (`main+0x8065e0`) adds the residual to the model's cost at each level and returns the best level under the threshold: 0, the full 1536x864, when the current size fits. The update moves down after `ReduceCounterMax` frames that ask for it and back up after `IncreaseCounterMax`. Scripted `GPULoad` hints from event data (`main+0x31c3de0`) and `OneshotSetDynamicResolutionLoadThreshold` adjust it in cutscenes. diff --git a/dm/games/0400486024DEC000/patches.py b/dm/games/0400486024DEC000/patches.py index cade577a2e..dde835329e 100644 --- a/dm/games/0400486024DEC000/patches.py +++ b/dm/games/0400486024DEC000/patches.py @@ -32,6 +32,7 @@ def frame_step(ctx): emit(0x1e201828); emit(B(here(), site + 4)) # orig: fdiv s8,s1,s0; back fs_put(site, [B(site, start)], 'frame ratio: the host\'s step × base rate / 60 instead of base rate / the game\'s frame rate (state page target fps; 0 = the game\'s ratio)') dynamic_resolution(ctx) + if base == 0x6e6be0: render_size(ctx) # v131072's main (the only build the render-size sites are known for) # The game's dynamic resolution (game__gfx__DynamicResolutionParam: LoadThreshold, ReduceCounterMax, IncreaseCounterMax and a list of levels, each a ResolutionReduceScale and a # Priority; on v131072 levels 0..9 at 0.75..0.333 of 2048x1152, 1536x864 to 683x384). Its update (main+0x805aa0) reads the frame's GPU load (about 0.2 ms a unit) into +0x8, subtracts @@ -71,6 +72,57 @@ def dynamic_resolution(ctx): fs_put(site, [B(site, start)], 'dynamic resolution level: 0 (full resolution), or with state +0x40 (DM_DYNAMIC_RESOLUTION) a climb on the load measured at each level') ctx.capabilities.add('DYNAMIC_RESOLUTION') +# Render size (DM_RENDER_SIZE, the launcher's Resolution; v131072 only, guarded by the matched frame-step function's place): the game sizes its docked output and render +# targets from fixed 2560x1440 constants (the sites upstream PR #1460 found for its ultrawide cuts); these stubs take the state page's size instead (+0x38: u32 width, +# u32 height, read as one x = width | height << 32; 0 = the game's own). Each keeps the original instructions for size 0. Handheld (1920x1080) is left alone. +# main+0x1202ee0 the graphics setup config's output size (swap chain), x8 = 2560 | 1440 << 32 (mov/movk), stored at [x21+0x14] +# main+0x31f39f4 the docked render size, the same pattern, stored at [x19+0xb68] +# main+0x112c604 the display mode's output size, read from the table at main+0x3f58540: its 2560x1440 entry becomes the size +# main+0xecbc80 / +0xecbcb4 the float copies of the output width (w9 = 2560.0f) and height (w8 = 1440.0f) in the same object's init +# The float stubs convert through s31, saved below sp and restored (no FP register is known free there) +NOP = 0xd503201f +def render_size(ctx): + here, emit, fs_site, fs_put, ST = ctx.here, ctx.emit, ctx.site, ctx.put, ctx.state + for site in (0x1202ee0, 0x31f39f4): # mov x8,#0xa00; movk x8,#0x5a0,lsl #32 + fs_site(site, '084081d208b4c0f2') + start = here(); emit(ADRP(8, here(), ST)) + for w in (0xf9401d08, # ldr x8,[x8,#0x38] width | height << 32 + 0xb5000068, # cbnz x8,+12 set: keep it + 0xd2814008, # mov x8,#0xa00 2560 + 0xf2c0b408): # movk x8,#0x5a0,lsl #32 1440 + emit(w) + emit(B(here(), site + 8)) + fs_put(site, [B(site, start), NOP], 'render size: %s from the state page (DM_RENDER_SIZE), 2560x1440 when it is 0' % ('output (swap chain) size' if site == 0x1202ee0 else 'docked render size')) + site = 0x112c604 # ldr x8,[x9,x8,lsl #3] the display mode's output size from the table + fs_site(site, '287968f8') + start = here(); emit(0xf8687928) # ldr x8,[x9,x8,lsl #3] + emit(ADRP(16, here(), ST)) + for w in (0xf9401e10, # ldr x16,[x16,#0x38] + 0xb40000b0, # cbz x16,+20 not set: the table's entry + 0xd2814011, # mov x17,#0xa00 + 0xf2c0b411, # movk x17,#0x5a0,lsl #32 + 0xeb11011f, # cmp x8,x17 the 2560x1440 entry (docked) + 0x9a880208): # csel x8,x16,x8,eq + emit(w) + emit(B(here(), site + 4)) + fs_put(site, [B(site, start)], 'render size: the display mode\'s 2560x1440 output entry becomes the state page\'s size (DM_RENDER_SIZE)') + for site, orig, ldr, cbz, fmov, name in ((0xecbc80, 0x52a8a409, 0xb9403929, 0x340000c9, 0x1e2603e9, 'width'), # mov w9,#0x45200000 (2560.0f) + (0xecbcb4, 0x52a89688, 0xb9403d08, 0x340000c8, 0x1e2603e8, 'height')): # mov w8,#0x44b40000 (1440.0f) + r = 9 if name == 'width' else 8 + fs_site(site, orig.to_bytes(4, 'little').hex()) + start = here(); emit(ADRP(r, here(), ST)) + for w in (ldr, # ldr wR,[xR,#0x38 / 0x3c] + cbz, # cbz wR,orig (+24) + 0xfc1f0fff, # str d31,[sp,#-16]! + 0x1e23001f | r << 5, # ucvtf s31,wR + fmov, # fmov wR,s31 + 0xfc4107ff): # ldr d31,[sp],#16 + emit(w) + emit(B(here(), site + 4)) + emit(orig); emit(B(here(), site + 4)) + fs_put(site, [B(site, start)], 'render size: output %s as a float from the state page (DM_RENDER_SIZE)' % name) + ctx.capabilities.add('RENDER_SIZE') + MATCH_FRAME_STEP = {'main': [ {'name': 'frame ratio from the host\'s step', 'size': 0x9b4, 'fingerprints': ['6ae2aff5344d14568e4dbaf93455e2d8278384bf892ed6c6eca87fef98fbcd1d'], 'stub': frame_step, # v131072 main+0x6e6be0 'others': {'dynamic resolution': {'size': 0x294, 'fingerprints': ['7af6ceb0aedf8e0c17dc08ce17fcd6a7cba6d394a0d09e3b504c6d668dc418e7']}, # v131072 main+0x8065e0 @@ -84,4 +136,7 @@ def dynamic_resolution(ctx): {'what': 'dynamic resolution: full size, or a climb on the load measured at each level', 'now': 'game', 'goal': 'game', 'purpose': 'rendering', 'why': "the game's own dynamic-resolution level function and update, found by their functions' fingerprints on any build that keeps both; switchable (DM_DYNAMIC_RESOLUTION)", 'checked': 'v131072 main: one function with each fingerprint (the level function a leaf, x2..x11 / x16 / x17 / s0..s2 free), its callers, the update and the controller fields read by disassembly, the fields read in play (2026-11-08); the climb run natively against a model of the update and in play to full size (2026-11-09)'}, + {'what': 'render size: the docked output and render size, the display mode\'s 2560x1440 entry and the float output size from the state page', 'now': 'build', 'goal': 'game', 'purpose': 'rendering', + 'why': "five fixed 2560x1440 constants in v131072's main (the sites PR #1460 found for its ultrawide cuts), placed by address and only when the frame-step function sits at v131072's place; a function-matched rule could carry them to other builds", + 'checked': 'v131072 headless at 2560x1440 and 3840x2160 (swapchain at the size, no crash, 60 fps held), in play at 2560x1440 and 3024x1702 (M5 Max, macOS 26.6.2, 2026-11-08 and 09)'}, ] diff --git a/dm/games/settings.tsv b/dm/games/settings.tsv index 7de392cfe3..2940f9276b 100644 --- a/dm/games/settings.tsv +++ b/dm/games/settings.tsv @@ -17,7 +17,7 @@ DM_FPS_TARGET choice 30=30 fps,60=60 fps,120=120 fps?DM_GAME_FPS_MAX==120&platform:mac DM_GAME_FPS_TARGET DM_GAME_FPS_TARGET!=0 Game Frame rate level=basic DM_DYNAMIC_RESOLUTION toggle - 0 fixups:DYNAMIC_RESOLUTION Game Dynamic resolution Lets the game lower its resolution under load. Turn off to keep full resolution for the selected console mode. DM_RENDER_SCALE range 0.5:1.0:0.05 1.0 fixups:RENDER_SCALE Game Render scale level=basic -DM_RENDER_SIZE choice 0=1280 × 720 (Switch),1920x1080=1920 × 1080,2560x1440=2560 × 1440,3840x2160=3840 × 2160 0 fixups:RENDER_SIZE Game Resolution Higher sizes take more GPU time per frame level=basic +DM_RENDER_SIZE choice 0=Game's own (as on the Switch),1920x1080=1920 × 1080,2560x1440=2560 × 1440,3840x2160=3840 × 2160 0 fixups:RENDER_SIZE Game Resolution Higher sizes take more GPU time per frame level=basic DM_OPMODE choice 1=Docked,0=Handheld DM_GAME_OPMODE always Game Console mode level=basic DM_PRESENT_UPSCALE choice off=Standard,metalfx=MetalFX off always Game Upscaling Uses more GPU time and can increase heat. DM_UPSCALER choice game=Game's own,metalfx=MetalFX game DM_GAME_UPSCALER_N!=0 Game Game's upscaler diff --git a/dm/tools/patch_nso.py b/dm/tools/patch_nso.py index e39c72f2f9..17481dcc4f 100644 --- a/dm/tools/patch_nso.py +++ b/dm/tools/patch_nso.py @@ -1558,7 +1558,7 @@ def stdalloc_gates(): # +0x20 u32 step in vsyncs (host; 0 = not decided yet), +0x24 u32 a step the game fixes itself (BotW's VFR override; 0 = none), +0x28 u32 AoC's vsyncs per update, marked by # its first stub (0 = off), +0x30 u64 vsyncs stepped (the stubs; logged by the host to check the game's speed), +0x40 u32 1 = the game's own dynamic resolution runs, 0 = its # stub holds full resolution (DM_DYNAMIC_RESOLUTION, written by the loader; the stub declares the DYNAMIC_RESOLUTION capability), +0x38 u32 width, u32 height of the game's render size -# (Hades II 1.0.131248; DM_RENDER_SIZE, written by the loader, 0 = the game's own; the stub declares the RENDER_SIZE capability). Stub bodies assembled with clang +# (Hades II 1.0.131248, Ocarina of Time v131072; DM_RENDER_SIZE, written by the loader, 0 = the game's own; the stub declares the RENDER_SIZE capability). Stub bodies assembled with clang # A build's stubs are FRAME_STEP[build ID](ctx) in its patches.py: ctx.here() / ctx.emit(word) assemble into the patch area, ctx.site(offset, original bytes) asserts a site and that it is # no rewrite site, ctx.put(offset, words, reason) writes it (listed with the cuts), ctx.state is the state page's offset, ctx.render_scale = 1 marks a render-scale stub, # ctx.others the other functions a MATCH_FRAME_STEP rule names, ctx.address(offset) the data address an adrp there and the add / load / store after it make (in the original diff --git a/docs/agents/game-patches.md b/docs/agents/game-patches.md index 170f46c522..f5497f4e98 100644 --- a/docs/agents/game-patches.md +++ b/docs/agents/game-patches.md @@ -33,6 +33,7 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep | `build` → `game` | malloc region 60 GB → 4 GB and its first arena | address space | gap | judgement | 1 | [Xenoblade Chronicles 3](../../dm/games/010074F013262000/README.md) | Monolith's own allocator; its constants span two functions (a multi-function rule). The cause, an iPhone's address space, is a platform limit | | `build` → `game` | PhysX completion task release | race | gap | judgement | 1 | [The Legend of Zelda: Link's Awakening](../../dm/games/01006BB00C6F0000/README.md) | a lifetime race in the game's own completion task (its release slot serves this one vtable) | | `build` → `game` | render intervals, the forced-interval flag and the render-wait timeout | frame rate | gap | judgement | 1 | [Fire Emblem: Three Houses](../../dm/games/010055D009F78000/README.md) | the game's own tables, flag and timeout | +| `build` → `game` | render size: the docked output and render size, the display mode's 2560x1440 entry and the float output size from the state page | rendering | gap | checked: v131072 headless at 2560x1440 and 3840x2160 (swapchain at the size, no crash, 60 fps held), in play at 2560x1440 and 3024x1702 (M5 Max, macOS 26.6.2, 2026-11-08 and 09) | 1 | [The Legend of Zelda: Ocarina of Time](../../dm/games/0400486024DEC000/README.md) | five fixed 2560x1440 constants in v131072's main (the sites PR #1460 found for its ultrawide cuts), placed by address and only when the frame-step function sits at v131072's place; a function-matched rule could carry them to other builds | | `build` → `game` | task ring push and pop barriers | race | gap | judgement | 1 | [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md) | a data race in the game's own task ring | | `build` → `game` | UE3's GMalloc setup skipped, the host allocator in (hle_uemalloc.c) | address space | gap | judgement | 1 | [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md) | UE3 inlines the allocator's constructor into the GMalloc setup and has its own vtable layout (25 slots, 32-bit sizes), so the Unreal 4/5 discovery does not apply | | `build` → `game` | unused 272-byte slot pool: 4,194,304 → 65,536 slots | address space | gap | judgement | 1 | [Mario + Rabbids® Sparks of Hope](../../dm/games/0100317013770000/README.md) | Sparks of Hope's own init (Kingdom Battle has none) | @@ -78,7 +79,7 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep | [Taiko Risshiden V DX](#taiko-risshiden-v-dx) | 1 | 0 | 0 | 2 | 0 | `game` | | [The Legend of Zelda: Breath of the Wild](#the-legend-of-zelda-breath-of-the-wild) | 7 | 0 | 43 | 0 | 0 | `build` → `game` ×2 | | [The Legend of Zelda: Link's Awakening](#the-legend-of-zelda-links-awakening) | 1 | 0 | 0 | 0 | 0 | `build` → `game` | -| [The Legend of Zelda: Ocarina of Time](#the-legend-of-zelda-ocarina-of-time) | 0 | 0 | 2 | 0 | 0 | `game` ×2 | +| [The Legend of Zelda: Ocarina of Time](#the-legend-of-zelda-ocarina-of-time) | 0 | 0 | 2 | 0 | 0 | `game` ×2, `build` → `game` | | [The Legend of Zelda: Tears of the Kingdom](#the-legend-of-zelda-tears-of-the-kingdom) | 0 | 0 | 9 | 0 | 0 | `game` | | [Xenoblade Chronicles 3](#xenoblade-chronicles-3) | 6 | 0 | 0 | 0 | 0 | `build` → `game` | @@ -550,6 +551,7 @@ Every patch bound tighter than it could be: the open gaps, then the blocked, kep - **`game`**, frame rate, at goal, checked: v131072 main: one function with this fingerprint, the site and its free registers read by disassembly (2026-11-08): frame ratio from the host's step. The game's own frame-ratio division, found by its function's fingerprint on any build that keeps the function - **`game`**, rendering, at goal, checked: v131072 main: one function with each fingerprint (the level function a leaf, x2..x11 / x16 / x17 / s0..s2 free), its callers, the update and the controller fields read by disassembly, the fields read in play (2026-11-08); the climb run natively against a model of the update and in play to full size (2026-11-09): dynamic resolution: full size, or a climb on the load measured at each level. The game's own dynamic-resolution level function and update, found by their functions' fingerprints on any build that keeps both; switchable (DM_DYNAMIC_RESOLUTION) +- **`build` → `game`**, rendering, gap, checked: v131072 headless at 2560x1440 and 3840x2160 (swapchain at the size, no crash, 60 fps held), in play at 2560x1440 and 3024x1702 (M5 Max, macOS 26.6.2, 2026-11-08 and 09): render size: the docked output and render size, the display mode's 2560x1440 entry and the float output size from the state page. Five fixed 2560x1440 constants in v131072's main (the sites PR #1460 found for its ultrawide cuts), placed by address and only when the frame-step function sits at v131072's place; a function-matched rule could carry them to other builds - **function-matched frame step** (`main` of builds without FRAME_STEP): frame ratio from the host's step: a function of 0x9b4 bytes, `+0xe4` in it; dynamic resolution, a function of 0x294 bytes, `+0x0` in it; dynamic resolution update, a function of 0xb24 bytes, in it; launcher capabilities: DYNAMIC_RESOLUTION diff --git a/docs/env_switches.tsv b/docs/env_switches.tsv index 57ea22de5d..abfcfa5f09 100644 --- a/docs/env_switches.tsv +++ b/docs/env_switches.tsv @@ -293,7 +293,7 @@ DM_QOS_MAP switch `=1` maps guest thread priority to QoS class: ≤ 44 user-inte DM_REC diagnostic `=`: writes player 1's physical input (keyboard, mouse touches, controllers; never `DM_KEYS` / `DM_CTL`) to the file as `DM_KEYS` steps in presented frames, for replaying a run (`DM_KEYS=@`) DM_REGIONS diagnostic `=` writes the table of the SDK's address regions every 2 s (alias offset, size, where the request returns to in the game, bytes mapped, the part opened, the SDK offset the request came through; `hle_svc.c` "Address regions"); the NSP script's address region check sets it DM_RENDER_SCALE player `0.5` to `1.0`: fixes the game's 3D views at that fraction of their size and turns its dynamic resolution off, for builds with a render scale stub; `1.0` (the default) keeps it -DM_RENDER_SIZE player `x` (16:9, `1280x720` to `3840x2160`): the size the game renders at, its swapchain and screen-sized targets, for builds with a render-size stub (the RENDER_SIZE capability: Hades II 1.0.131248); `0` or unset keeps the game's own +DM_RENDER_SIZE player `x` (16:9, `1280x720` to `3840x2160`): the size the game renders at, its swapchain and screen-sized targets, for builds with a render-size stub (the RENDER_SIZE capability: Hades II 1.0.131248; Ocarina of Time v131072, docked); `0` or unset keeps the game's own DM_RESOURCE_AOC path The add-on content folder the iOS build copies into the app's `aoc/` (empty for none); written by `gen_resources.py`, read by `stage_resources.sh` DM_RESOURCE_BUILD switch Package version (for example `v327680`), written to `Gen/resources.env` by `gen_resources.py`; with `DM_COPY_ROMFS=NO` the copy phase puts it in the `build=` field of the app's `romfs.id` DM_RESOURCE_CHAIN_H path Path of `dm/gfx/nvn/dmsh_chain.h`, written to `Gen/resources.env` by `build_ipa.sh`; the Xcode copy phase (`stage_resources.sh`) stops when the prepared shaders are not of its chain version diff --git a/docs/settings.md b/docs/settings.md index f613816daf..c0ba5925ad 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -37,7 +37,7 @@ The size of the 3D picture, from 50 to 100 %. Below 100 % the size is fixed ther ### Resolution -The size the game renders at, for games the app can resize (Hades II 1.0.131248): **1280 × 720** as on the Switch, **1920 × 1080**, **2560 × 1440** or **3840 × 2160**. A larger size is sharper on a larger screen and takes more GPU time per frame; the HUD and text are laid out for the size. +The size the game renders at, for games the app can resize (Hades II 1.0.131248; Ocarina of Time v131072, docked): **Game's own**, the size it renders on the Switch (Hades II 1280 × 720, Ocarina of Time 2560 × 1440, of which it draws 80 % and scales up), **1920 × 1080**, **2560 × 1440** or **3840 × 2160**. A larger size is sharper on a larger screen and takes more GPU time per frame; the HUD and text are laid out for the size. ### Console mode