Skip to content

The Legend of Zelda: Ocarina of Time renders native ultrawide (21:9) with DM_ULTRAWIDE - #1460

Open
vladbondarenko97 wants to merge 1 commit into
seedds:mainfrom
vladbondarenko97:oot-ultrawide
Open

vladbondarenko97 wants to merge 1 commit into
seedds:mainfrom
vladbondarenko97:oot-ultrawide

Conversation

@vladbondarenko97

Copy link
Copy Markdown

What and why

On a 21:9 screen (3440x1440) Ocarina of Time showed a 16:9 picture with black bars: the game sizes its output from fixed 2560x1440 (docked) constants. This adds opt-in cuts for main e0f3ccfaf50065ae (dm/games/0400486024DEC000/patches.py), registered only when the NSP script runs with DM_ULTRAWIDE=<width>x<height>. They give these widths from the screen's ratio at the game's own heights:

  • the graphics setup output size (main+0x1202ee0)
  • the docked and handheld render sizes (main+0x31f39f4, +0x31f3a00)
  • the float copy of the output width (main+0xecbc80)
  • the output resolution table (main+0x3f58540)

The 3D view takes its aspect from the render size, so the view widens (Hor+) and nothing is stretched. The HUD and subtitles stay centred, and movies stay 16:9 in the middle. Without DM_ULTRAWIDE, no cut is registered and nothing changes. The game note has a new "Ultrawide" section, and docs/agents/game-patches.md was regenerated.

Checked

  • Tests: python3 -m unittest dm.tools.tests.test_docs dm.tools.tests.test_env_switches (OK). Ran patch_nso.py on main v131072 with DM_ULTRAWIDE=3440x1440: all 5 cuts' original bytes matched, and the output was identical to the binary I played.
  • Game: Ocarina of Time 0400486024DEC000 v131072, played through the title screen, the opening and Link's house.
    • Swap chain 3440x1440 (was 2560x1440).
    • WindowCrop 2752x1152 (2.389:1, at the game's 80 % dynamic resolution; was 2048x1152).
    • The picture fills the screen and nothing is stretched (screenshots via DM_CTL shot).
    • About 36 fps in the opening.
  • Device: Mac mini M4 Pro, macOS 27.0.1, CB342CK 3440x1440.
  • Not checked: handheld mode, other 21:9 resolutions such as 2560x1080 (the widths come from the ratio and should hold), 32:9.

Docs

  • The finding is in its game note
  • No game files, keys or data extracted from a game in the change

🤖 Generated with Claude Code

@github-actions github-actions Bot added rewriter The NSO rewriter and per-build patches docs Documentation game: 0400486024DEC000 A game labels Nov 6, 2026
@padsiwono

Copy link
Copy Markdown
Contributor

Thanks for finding these sites. I built on them in #2021: the same five 2560x1440 constants, as stubs that take the size at launch from the launcher's Resolution (through #1849's state page plumbing), with you as co-author. It covers 16:9 sizes only, so your 21:9 cuts are not replaced by it; other shapes also need the camera's aspect and the HUD, which I haven't sent yet.

#2020 removes the game's 80 % crop, the same one your log shows as WindowCrop 2752x1152 at 3440x1440: it is two multiplies in the crop function, not data.

…with DM_ULTRAWIDE

On a 3440x1440 screen the game showed a 16:9 picture with black bars: it sizes its output from fixed
2560x1440 (docked) constants, so the host's fit kept the bars. An opt-in set of cuts for main
e0f3ccfaf50065ae, applied when the NSP script runs with DM_ULTRAWIDE=<width>x<height>, gives the game
widths from the screen's ratio at its own heights: the graphics setup's output size (main+0x1202ee0),
the docked and handheld render sizes (main+0x31f39f4, +0x31f3a00), the float copy of the output width
(main+0xecbc80) and the output resolution table (main+0x3f58540). The 3D view takes its aspect from the
render size, so the field of view widens; nothing is stretched, and the HUD and subtitles stay centred.
Without DM_ULTRAWIDE no cut is registered and nothing changes.

Checked on a Mac mini M4 Pro, macOS 27.0.1, CB342CK at 3440x1440, update v131072: swap chain 3440x1440
(was 2560x1440), WindowCrop 2752x1152 (2.389:1, the game's 80 % dynamic resolution; was 2048x1152), title
screen, the opening and Link's house fill the screen; about 36 fps in the opening at 3440x1440.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rafaeliga pushed a commit to rafaeliga/kid-with-sword-remake that referenced this pull request Nov 11, 2026
…xed, Wide view, and four upstream fixes

The first build of the X line (it would have been V24), on V23:

- Render targets in a GPU-only pool are placed in heaps of their own, and a freed target's heap waits resident for the next target it fits (nxnative 7f50222, DM_NVN_RT_RECYCLE): dynamic-resolution and render-scale changes no longer get new Metal memory each time. Merged by hand into V's texture path: a recycled heap is tried before a fresh allocation, after the Potato recycle bin, and such a texture is not binned again. t_rt_recycle 18 checks pass.
- The main submission may have up to 16 command allocators and visibility buffers in flight instead of 8 (DM_NVN_ALLOC_CAP, 3-32): at 8 the submit thread waited for a free one (log 64: 352 waits).
- A memory pool's texture IDs are marked gone before its CPU-written classification goes (nxnative c229bd7): a draw reaching one in between got the NvPkg wrapper as its texture, and V23 stopped with "-[NvPkg buffer]: unrecognized selector" right after a save (logs 66 and 67). t_cpu_tex's finalize_during_walk fails 2 checks without it.
- Wide view (DM_WIDE_VIEW, a launcher setting, off by default): the game renders the screen's shape instead of 16:9 with bars, Hor+, nothing stretched. The size constants are nxnative PR seedds#1460's; here they are stubs that read the state page, so it needs no rebuild. The present takes the picture's shape from nxnative 2202d61. Shown only for builds with the stubs (fixups WIDE_VIEW).
- From nxnative main, merged with no conflict: a stopped Core Haptics engine no longer ends the app (7238bfd), each audio renderer plays from its own PCM blocks (a334797), a submission's queued writes grow as needed (6d5ed71), and cubes in cube-array and 2D-array slots read every face (c83c48f).

Same shader chain (804433846e4b). Not yet played on a phone.

Co-authored-by: seedds <seedds@gmail.com>
Co-authored-by: Pedro Nascimento <91118+lunks@users.noreply.github.com>
Co-authored-by: vladbondarenko97 <contactvlad1k@gmail.com>
Co-authored-by: dsi-hub <260802842+dsi-hub@users.noreply.github.com>
Co-authored-by: zatteogit <64840342+zatteogit@users.noreply.github.com>
Co-authored-by: Oliver Ames <7366664+oliverames@users.noreply.github.com>
Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ayymeric

Ayymeric commented Nov 15, 2026 •

Copy link
Copy Markdown

Tried on a 2560x1080 screen (base M4 Mac mini, 10-core GPU, macOS 27.2) on main 0def324. Two findings:

1. The view is stretched, not widened. With DM_ULTRAWIDE=2560x1080 the cuts give a 3408x1440 swap chain, but the 3D view keeps the 16:9 field of view and is stretched to the wider picture. Screenshots of the same spot (one save, DM_CTL shot) at 16:9 and with this PR show the same scene edge to edge, horizontally scaled. A variant that also sets the output's height (2560x1080, the movk heights of the two size pairs, 1440.0f at main+0xecbcb4, the mode table) behaves the same, only cheaper (GPU p50 19.9 ms against 22.9 ms at 16:9 and 26.6 ms with this PR at a 30 fps cap). As far as I found, every 3D view's sead::PerspectiveProjection (aspect at +0xb0; constructor main+0x3485bd0, matrix main+0x3485cc0) stays 16:9. Replacing a 16:9 aspect with the screen's ratio in the matrix, the two frustum getters (main+0x3485db8 / +0x3485de4) and getAspect (main+0x33e910) did not change the picture either, so the main view's projection seems to come from elsewhere. The 16:9 constants the cameras' constructors store (main+0x9b5f34, +0x2e1be3c, camera +0x100) aren't it either. Hor+ still needs that found.

2. On current main the wide picture is squeezed back into 16:9 on screen. Since 2202d61 (issue #949), present_shape in nvn_mtl.m shows every picture in the vi layer's shape or the display's 1920x1080. Ocarina sizes no layer, so the 2560x1080 swap chain is drawn into a centred 16:9 rectangle with bars (present: picture shape 1920x1080 (1.778:1) in the log). DM_CTL shot reads the texture before the present, so screenshots don't show it. A stopgap that worked: mtl_present_screen(w, h) from loader.c (I used an env DM_PRESENT_SHAPE=2560x1080; the log then reads picture shape 2560x1080 (2.370:1) and the picture fills the screen). Properly, the cut set could declare the output size so the host sets it without an env.

The same Kokiri Forest spot from one save, 16:9 with this PR, the PR #1460 cuts, and the 2560x1080 variant (DM_CTL shot captures, before the present):

same spot: 16:9, PR #1460, 2560x1080 variant

@padsiwono

Copy link
Copy Markdown
Contributor

@Ayymeric on your point 1: in v131072 the main view's aspect doesn't come from sead::PerspectiveProjection's own value. The camera is copied into the projection in three places, each loading fovy from the camera's +0x13c and aspect from +0x140, then filling the projection's +0x98 to +0xb4:

copy fovy load aspect load
A main+0x4c52f8 main+0x4c5334 (store main+0x4c533c)
B main+0x2e1bb30 main+0x2e1bb64
C main+0x2e1c794 main+0x2e1c7c8

On our fork I stub those six loads: aspect becomes the render size's W / H, and fovy is widened only when the picture is taller than 16:9 (through the game's own tanf / atanf imports, main+0x3c41dd0 / +0x3c41e40), so a wider picture keeps the 16:9 fovy and gets Hor+. One run per size: 3440x1440 is in proportion with more at the sides, a 1.54 picture shows more above and below, 2560x1440 is unchanged, no crash. #2651 takes the other route for taller screens (fovyTan in doUpdateMatrixImpl_); I haven't checked whether that one also widens at 21:9.

Not tried: 2560x1080, and the stubs together with this PR's cuts. The HUD stays a stretched 16:9 canvas with these alone, which is a separate job (#2588). Happy to put the stubs up as a patch on top of this PR if that helps.

@Ayymeric

Copy link
Copy Markdown

Thanks, that matches what I found independently on v131072: the same three camera → projection copies (main+0x4c533c, +0x2e1bb6c, +0x2e1c7d0), plus three other projection setups (+0x653bd4, +0x6545f4, +0x3b50b50) and the camera parameter copy that defaults the aspect to 16:9 (+0x14fc7f0). I replace a 16:9 aspect with the output's ratio at those stores. At 2560x1080 (output and docked render size 2560x1080, so 1920x810 drawn, with the present-shape stopgap from my comment above) the view widens with nothing stretched: top 16:9, bottom 2560x1080, same spot and save (DM_CTL shot, headless runs):

16:9 against 2560x1080 Hor+

That's from scripted runs only so far: I haven't played it yet, and the HUD, menus, cutscenes and other areas still need checking in play. Your patch covers taller screens too, so please do put it up on top of this PR; I'll test it at 2560x1080 on a base M4 and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game rewriter The NSO rewriter and per-build patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants