Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Ocarina of Time v131072 renders at the launcher's Resolution (DM_REND…
…ER_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>
  • Loading branch information
padsiwono and vladbondarenko97 committed Nov 9, 2026
commit 4e2b993fc6564a441c79ba4bd97877971ca7fa8d
6 changes: 6 additions & 0 deletions dm/games/0400486024DEC000/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
55 changes: 55 additions & 0 deletions dm/games/0400486024DEC000/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)'},
]
2 changes: 1 addition & 1 deletion dm/games/settings.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dm/tools/patch_nso.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/agents/game-patches.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down Expand Up @@ -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` |

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/env_switches.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ DM_QOS_MAP switch `=1` maps guest thread priority to QoS class: ≤ 44 user-inte
DM_REC diagnostic `=<file>`: 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=@<file>`)
DM_REGIONS diagnostic `=<file>` 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 `<width>x<height>` (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 `<width>x<height>` (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
Expand Down
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading