Skip to content

iPhone: Hades fills the screen edge to edge (general output size, profile key aspect any) - #117

Closed
v0lumehi wants to merge 3 commits into
seedds:mainfrom
v0lumehi:hades-wide-pr
Closed

v0lumehi wants to merge 3 commits into
seedds:mainfrom
v0lumehi:hades-wide-pr

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Switch games render 16:9 and current iPhones are about 19.5:9, so the picture is pillarboxed (#93). This PR adds a general way for a game to render at the screen's aspect and turns it on for Hades.

How it's general. A stub in a profile's patches.py can replace the game's output size with the host's. The stub names itself in main's rewriter table (OUTPUT_W / OUTPUT_H), and the loader writes the size (DM_OUTPUT_SIZE, or the screen's aspect) into the state page only for such a build. A profile with aspect any then gets width = height × the screen's aspect, rounded to a multiple of 8 and never narrower than 16:9 (1568x720 on an iPhone 17 Pro Max). The iOS game view covers the whole screen, and touches map onto the same canvas. Only the profile key and the rewriter table decide; the host knows no game. The launcher's Picture switch (Wide / 16:9) turns it back. Other games' main rewrite byte-identically.

Hades. A stub replaces its fixed 1280x720 window size. At a wider output the game uses its own ultrawide layout, as on PC: the 16:9 view and HUD stay in the middle, and its side-bar art fills both sides. There are no black bars, no crop and no stretch. A truly wider view would need the game's UI scripts and layouts changed as well; that would be a separate PR.

Checked:

  • An iPhone 17 Pro Max ran a build of the same changes on top of Breath of the Wild above 60 fps and above 1080p (reworked from #62) #76. Hades filled the screen edge to edge, with the side-bar art at the sides.
  • On the Mac at 1568x720: the title, the save choice and the House of Hades.
  • The main of Breath of the Wild 1.9.0, Mario Kart 8 Deluxe 4.0.0 and Super Smash Bros. Ultimate 13.0.5 rewrites byte-identically to main.
  • The host unit tests pass, and the Mac host and the iOS app build.

Not checked: Tears of the Kingdom, Age of Calamity and Paper Mario (no NSPs here), an iPad, and a room of a run.

Relation to #76. The output-size part comes out of #76 (Breath of the Wild above 60 fps), with the same form and names. #76 needs it and will rebase onto this.

🤖 Generated with Claude Code

…ed by the build's rewriter table

A stub in a profile's patches.py (an entry in FRAME_STEP) can replace the game's own output size with the host's. The build then names itself in main's rewriter table: the
stub sets ctx.keys (OUTPUT_W / OUTPUT_H, the game's own size), patch_nso.py writes them as rows of the fixups table, and the loader reads them into module_t (out_w / out_h).
dm_fps_state_apply writes DM_OUTPUT_SIZE (WxH from 640x360 to 7680x4320, 1080p, 1440p or 4k) to the state page at +0x40 (u64 width | height << 32) and +0x48 (float width)
only for such a build, and refuses it with a red line for any other, so no other game's state page is touched and no game's size is in the host. The state page the loader
checks grows from 0x40 to 0x50 bytes. Names and form are those of draft PR seedds#76 (Breath of the Wild above 60 fps and 1080p), whose general part this is without its variable
frame step, render buffer pool and view sizes, so seedds#76 can rebase onto it.

Checked: main of Breath of the Wild 1.9.0 (the one build here with frame-step stubs), Mario Kart 8 Deluxe 4.0.0 and Super Smash Bros. Ultimate 13.0.5 rewrites byte-identically
to upstream (patched main, cuts, fixups, gates, obs and sites; only build_src.sha256 differs, the hash of the rewriter's sources); the host unit tests pass with Hades's,
Breath of the Wild's and Super Mario Bros. Wonder's profiles; the Mac host builds. Not checked: Tears of the Kingdom, Age of Calamity and Paper Mario: The Thousand-Year Door
(their NSPs are not here; their stubs set no keys, and the larger state page bound only moves an assert that still holds within the page)
Hades sets its window size once at startup (main+0x2492b0: 1280x720 into the window settings, docked and handheld alike), and The Forge makes the swap chain and the render
targets from it, ignoring the Vulkan surface's extent. Its patches.py has an entry in FRAME_STEP that only sets the output size stub (so the build gets a state page; Hades has
no frame step): the movk of that pair is replaced by a load of the host's size from state +0x40, 0 = the game's 1280x720, and the build's rewriter table names it
(OUTPUT_W 0x500 / OUTPUT_H 0x2d0). DM_OUTPUT_SIZE then renders the whole frame at that size, not an upscale; the prerendered character sprites stay at their 720p packages.

Checked: Hades's main rewrites with the stub (one cut at main+0x2492e0, the two rows in the fixups table) byte-identically to the main the earlier Mac and iPhone runs of this
work used; on the Mac (M2 Max) with DM_OUTPUT_SIZE=1568x720 the title, the save choice and the House of Hades render at 1568x720 at 60 fps, with one red line as before
(Vulkan dynamic state 3)
…to edge at the screen's aspect (Hades, issue seedds#93)

A build whose output size stub takes any size (OUTPUT_W / OUTPUT_H) gets the screen's landscape aspect: loader.c output_aspect keeps the height the game or DM_OUTPUT_SIZE
gives and sets the width to height x aspect rounded to a multiple of 8, never narrower than 16:9 (1568x720 on an iPhone 17 Pro Max). The aspect comes from the front end
(front_screen_aspect: front_ios.m, from the view's bounds before the host starts the game; the Mac has none, so its window keeps 16:9), or from DM_ASPECT=W:H; DM_ASPECT=16:9
keeps the game's size. The iOS game view then covers the whole screen, behind the Dynamic Island and the rounded corners, as the 16:9 picture already covered the whole height
(the controls keep to the safe area); present_encode fills it, as the aspect ratios differ by less than 1%. Touches are normalized on the same canvas (DmGamepad.m). The
launcher's Picture switch (Wide / 16:9, Wide by default) shows for a profile with the key and a build with the stub, a condition of two parts, which settings.tsv now writes
joined by & (settings.py). The host knows no game: only the profile key and the rewriter table decide.

Hades sets the key. At a wider output it uses its own ultrawide layout, as the PC version does: the engine's CalculateViewportForAspectRatio (main+0x47c1b0) keeps a 16:9 view
and HUD over a logical 1920x1080 screen and fills both sides with its side bar art, so the picture has no black bars, crop or stretch, but the 3D view itself is not wider.
Setting the logical width (the float 1920.0 at main+0x6a1f5c) to 1080 x aspect did widen the view with nothing stretched, but menus and overlays laid out for 1920 (the pause
menu, its dimming, the right-anchored counters) stayed in the left 1920 units, so the profile does not do that.

t_nro tests the size math (1568x720 at 2868:1320, DM_OUTPUT_SIZE's height kept, never below 16:9, off without the key).

Checked: on the Mac (M2 Max) with DM_OUTPUT_SIZE=1568x720 and DM_ASPECT=2868:1320 the title, the save choice and the House of Hades, HUD inside the 16:9 middle and the side
bar art at both sides, 60 fps; on an iPhone 17 Pro Max Hades fills the screen edge to edge with the side bar art (user, with the same changes on an earlier base); the host unit
tests pass with Hades's, Breath of the Wild's and Super Mario Bros. Wonder's profiles; the Mac host builds and the iOS app for Hades compiles and links (unsigned); the
launcher settings show Picture for Hades and not for Breath of the Wild. Not checked: a room of a run, an iPad (it keeps 16:9 by the rule), and this exact build on an iPhone
@v0lumehi

Copy link
Copy Markdown
Contributor Author

Parking this for now to keep the open PRs focused on the optimization stack. I'll reopen it if it's needed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant