Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 33 additions & 0 deletions dm/games/01007EF00011E000/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,36 @@ General host changes first needed here; each applies to every game:
- `game.tsv` still says "In bring-up", and its memory comment "until measured".
- 05's `DM_PROBE_POLL` paragraph cites `PlacementMgr` in `main+0x5aaac0` as the one thread in guest code "for that flag" without naming the game; `PlacementMgr` is this game's.
- Motion on iOS (a controller's gyro, and the phone's own while no controller supplies fresh samples) has not been tested on a device. Source arbitration, concurrent startup and upright orientation were corrected during review and are covered by unit tests; see [Live controller motion](../../../docs/reference/services.md#live-controller-motion). Motion shrines from issue #389 still need a device gameplay check.


## Optional Mac display settings

The exact 1.9.0 build exposes CAMERA_ASPECT and RENDER_RESOLUTION capabilities. Original 16:9 and the game's original resolution remain the defaults. The camera implementation is adapted from ComicBit's zelda-native-widescreen branch, which credits MacNativeGames. The resolution and render-pool sites are adapted from v0lumehi's PR #76.

Camera state uses +0xa0 for the requested ratio and +0xa4 for the game-camera acknowledgement. Optional output dimensions, docked width pair, render-pool factor and heap allowance use +0xb0, +0xb8, +0xc0 and +0xc8. This avoids the existing dynamic-resolution and taller-screen fields. A zero field preserves the original instruction path.

The renderer identifies layout quads through profile-owned shader prefixes. Their uniform transforms distinguish full-width backing rectangles from centered controls. Full-width backgrounds and fades retain their screen coverage. This classification requires menu, loading, dialogue and map regression checks before publication.

Local checks passed for the camera, resolution state, layout math, settings and patch documentation. The game booted with real audio and the loading fade covered the full output. Inventory, System and Adventure Log were exercised on a copied save. L/R transition polish remains under review. Full-game compatibility and other game versions are unverified.

### Widescreen follow-up (Mac, 2026-11-16; experimental)

The map background used the full-width-layout exemption while its markers used
the centered viewport. Only texture-free full-width backings now expand; textured
map layers and icons share the centered 16:9 region. Checked with panning, zooming,
recentring, and the Album tab at a 1290x540 drawable on an M4 Pro. This intentionally
uses black side margins for the Slate rather than distorting its decoration.

Decoded movies retain their source aspect: the existing movie-pacing flag at
frame state +4 suppresses the anamorphic present/UI correction. Verified by
replaying Return of Calamity Ganon (memory 15), which previously filled 21:9
stretched and now presents 16:9. In-engine event cameras are not covered by the
decoder flag and remain unverified.

**Open:** inventory Link uses a separate camera, and captured pause-menu layers
still show L/R transition/compositing defects. Treating every GPU-rendered picture
as ordinary UI improved portrait proportions but introduced duplicate layers;
that experiment was rejected. The GPU-picture exemption is retained. A robust
fix needs explicit provenance of scene, portrait and captured UI textures, rather
than inferring their semantics from size alone. Widescreen remains experimental;
the original-ratio setting avoids these optional-path defects.
6 changes: 6 additions & 0 deletions dm/games/01007EF00011E000/game.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ app_pool 0xCD500000
# ---- Shader split (shader_split.py) ----
shader_groups /Shader/=shader /Effect/=effect /Layout/=layout /System/=gsys /Terrain/=terrain
shader_note Breath of the Wild shaders

# Optional docked resolution stubs: original view, output, and each render pool.
render_dimensions 1600 900 1920 1080 0x7300000

# Unit layout quads with projection/model/rectangle in vertex uniform slot 0.
aspect_ui_rect_prefixes 9f8de486 71018be4 5275c47b 86208e96 51deaed0 4fb3d55c 78a4ace2 a983fef9
106 changes: 105 additions & 1 deletion dm/games/01007EF00011E000/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ def frame_step(ctx):
# 3D views (1600 wide docked, scaled from the output size) grow in height too. x16 is free at every site: nnMain's sites follow a call through the PLT
def taller(site, orig, load, apply, why):
fs_site(site, orig)
start = here(); emit(struct.unpack('<I', bytes.fromhex(orig))[0]) # the original instruction
start = here()
if site in (0xc61ef4, 0xc61f28, 0x12618c4, 0x12660d4):
dest = 8 if site == 0x12660d4 else 9
emit(ADRP(16, here(), FS_STATE_OFF))
emit(0xf9405a10) # ldr x16,[x16,#0xb0]: optional packed output dimensions
emit(0xb4000070) # cbz x16,+12: original screen-shape path
emit(0xaa1003e0 | dest) # mov xDest,x16
emit(B(here(), site + 4))
emit(struct.unpack('<I', bytes.fromhex(orig))[0]) # the original instruction
emit(ADRP(16, here(), FS_STATE_OFF))
for w in (load, 0x34000050, apply): # ldr w16,[x16,#off]; cbz w16,+8 (0: the game's size); the host's height
emit(w)
Expand Down Expand Up @@ -470,9 +478,101 @@ def vt(r, off): emit(ADRP(r, here(), off)); emit(ADDI(r, r, off & 0xfff)) # x<
emit(w)
emit(B(here(), 0xed81f4))
fs_put(0xf75ba4, [B(0xf75ba4, start) | 0x80000000], 'screen copy into a 16:9 picture (camera photo): the screen\'s middle 16:9 band, not the whole taller screen squashed into it')
camera_aspect(ctx)
render_resolution(ctx)



def render_resolution(ctx):
# Resolution sites adapted from v0lumehi/nxnative PR #76 (MIT).
# Fields +0xb0 output size, +0xb8 output/base widths, +0xc0 pool factor,
# +0xc8 heap allowance. Zero preserves each original instruction.
start = ctx.here()
ctx.site(0x12660cc, '680a09f9')
ctx.emit(0xf9090a68) # original output/base widths
ctx.emit(ADRP(8, ctx.here(), ctx.state))
for w in (0xf9405d08, 0xb4000048, 0xf9090a68): ctx.emit(w)
ctx.emit(B(ctx.here(), 0x12660d0))
ctx.put(0x12660cc, [B(0x12660cc, start)], 'optional docked output and view widths (+0xb8)')

start = ctx.here()
ctx.site(0x1266104, '03f08052')
ctx.emit(ADRP(3, ctx.here(), ctx.state))
for w in (0xf9405863, 0xb4000083, 0xd360fc64, 0x2a0303e3): ctx.emit(w)
ctx.emit(B(ctx.here(), 0x1266108))
ctx.emit(0x5280f003)
ctx.emit(B(ctx.here(), 0x1266108))
ctx.put(0x1266104, [B(0x1266104, start)], 'optional docked crop (+0xb0)')

start = ctx.here()
ctx.site(0x106d328, '686e42f9')
ctx.emit(ADRP(10, ctx.here(), ctx.state))
for w in (0xb940c14b, 0xf9426e68, 0x3400004b, 0x9b0b7d08): ctx.emit(w)
ctx.emit(B(ctx.here(), 0x106d32c))
ctx.put(0x106d328, [B(0x106d328, start)], 'optional render pool factor (+0xc0)')

for site, original, reg, load, original_word, add in (
(0x71c, '0060b852', 16, 0xf9406610, 0x52b86000, 0x8b100000),
(0xc617c0, '0820b852', 9, 0xf9406529, 0x52b82008, 0x8b090108),
):
start = ctx.here()
ctx.site(site, original)
ctx.emit(ADRP(reg, ctx.here(), ctx.state))
for w in (load, original_word, add): ctx.emit(w)
ctx.emit(B(ctx.here(), site + 4))
ctx.put(site, [B(site, start)], 'optional render heap allowance (+0xc8)')


def camera_aspect(ctx):
# Adapted from MacNativeGames games/totk/runtime/game_patches_botw.c:
# https://github.com/ly05010419/MacNativeGames (MIT).
# Copyright (c) 2026 MacNativeGames contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Camera update main+0x10eda5c rewrites the aspect each world frame. x19+0x10
# is its PerspectiveProjection (dirty +8, near/far +0x98/+0x9c, aspect +0xb0).
# Replay all original dirty/near/far/rectangle operations, then replace only
# the aspect. x8/x9 are dead here; NZCV and the other registers stay intact.
original = (0xbd406e80, 0x39006276, 0xbd00aa60, 0xbd407280, 0x39006276,
0xbd00ae60, 0x2d4806a0, 0x2d470ea2, 0x39006276, 0x1e233821,
0x1e223800, 0x1e211800, 0xbd00c260)
site = 0x10edae0
ctx.site(site, struct.pack('<13I', *original).hex())
start = ctx.here()
for w in original[:-1]: ctx.emit(w)
ctx.emit(ADRP(8, ctx.here(), ctx.state))
for w in (0x91028108, # add x8,x8,#0xa0 desired ratio, 0 = original
0x88dffd09, # ldar w9,[x8] acquire host's desired float bits
0x34000049, # cbz w9,store (+2) also acknowledges disabling
0x1e270120, # fmov s0,w9
original[-1], # store: str s0,[x19,#0xc0]
0x91001108, # add x8,x8,#4 effective acknowledgement +0xa4
0x889ffd09): # stlr w9,[x8] publish only after the aspect write
ctx.emit(w)
ctx.emit(B(ctx.here(), site + 4 * len(original)))
ctx.put(site, [B(site, start)] + [0xd503201f] * (len(original) - 1),
'camera aspect = host drawable ratio (state +0xa0; 0 = original), acknowledged at +0xa4')


FRAME_STEP = {'cd57b23fa4bbad65803d9788c01821ee': frame_step}
CAPABILITIES = {'cd57b23fa4bbad65803d9788c01821ee': ('CAMERA_ASPECT', 'RENDER_RESOLUTION')}

# 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)
Expand All @@ -485,4 +585,8 @@ def vt(r, off): emit(ADRP(r, here(), off)); emit(ADDI(r, r, off & 0xfff)) # x<
'functions recur)',
'checked': 'nso_fnmap of its 44 sites into those 13 mains (2026-11-09)',
'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'},
{'what': 'BOTW perspective camera aspect and projection acknowledgement', 'now': 'build', 'goal': 'game', 'purpose': 'rendering',
'why': "the game's camera update and projection-object layout; drawable publication and presentation are general host behavior",
'blocked': 'camera update has no reviewed function fingerprint yet',
'checked': 'all 13 original words checked in main cd57b23fa4bbad65803d9788c01821ee; pre-refresh native/wide outdoor Mac gameplay and camera acknowledgement (chain fda42ce035db); exact-branch runtime unrun'},
]
2 changes: 2 additions & 0 deletions dm/games/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,5 @@ These are not profile keys: the tools read them from the game files each time, b
4. **Shaders.** `DM_GAME=<id> [IOSOUT=…] dmsh_build.py <pkg> <cache>`, with a cache directory of the game's own. A full build also writes `c1_full.tsv` and `cb_extent.tsv` (local files, not committed). The chain version needs nothing: it is the same for every game.
5. **Host bring-up.** Run `make -C dm/host GAME=<id>`, then work through the bring-up loop in docs/agents. Code that only fits one game is gated by its build ID (`dm_main_build()`), never left to run on every game.
6. **IPA.** Use `GAME=<id> dm/ios/tools/build_ipa.sh`, or the NSP script, which now finds the profile.

Optional display-profile fields render_dimensions (view width/height, output width/height, each pool size), aspect_ui_prefixes (float-canvas UI shader prefixes) and aspect_ui_rect_prefixes (unit layout-quad shader prefixes) support the exact-build display capabilities. Empty fields preserve existing behavior.
21 changes: 21 additions & 0 deletions dm/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ def header_one(g):
sys.exit(f'{g.id}: shader_key_skip takes <offset>+<length> within the first 0x880 bytes of the control section, past its header (+0x30) and clear of +0x700..+0x75f: {sks}')
sko, skl = (int(m[1], 0), int(m[2], 0)) if m else (0, 0)
if g.get('render_cond', ''): print(f'{g.id}: render_cond is ignored: the host evaluates NVN conditional rendering for every game', file=sys.stderr) # a profile written before the key went (a build folder's derived one)
rd = g.words('render_dimensions', '0 0 0 0 0')
if len(rd) != 5 or any(not re.fullmatch(r'(?:0x[0-9a-fA-F]+|[0-9]+)', v) for v in rd):
sys.exit(f'{g.id}: render_dimensions needs view W H, output W H, pool bytes')
rd = [int(v, 0) for v in rd]
aur = g.words('aspect_ui_rect_prefixes', '')
if any(not re.fullmatch(r'[0-9a-f]{8}', p) for p in aur):
sys.exit(f'{g.id}: aspect_ui_rect_prefixes takes eight lowercase hexadecimal characters')
aui = g.words('aspect_ui_prefixes', '') # float-canvas layout vertex identities; prefix matching is fixed at eight characters
if any(not re.fullmatch(r'[0-9a-f]{8}', p) for p in aui):
sys.exit(f'{g.id}: aspect_ui_prefixes takes eight lowercase hexadecimal characters per prefix')
tfu = g.get('tex_flush_upload', 'off') # textures written by the CPU into a pool and published with nvnMemoryPoolFlushMappedRange are uploaded like packaged ones (hle_nvn.c): on / off
if tfu not in ('on', 'off'): sys.exit(f'{g.id}: tex_flush_upload must be on or off: {tfu}')
tdu = g.get('tex_dirty_upload', 'off') # with tex_flush_upload: a registered texture the CPU writes after init without any flush is uploaded too (dirty pages, hle_nvn.c nvn_ft_written): on / off
Expand Down Expand Up @@ -259,6 +269,17 @@ def header_one(g):
f'#define DM_GAME_PERF_BOOST {int(pm == "boost")}',
f'#define DM_GAME_TEX_FLUSH_UPLOAD {int(tfu == "on")}',
f'#define DM_GAME_SHADER_KEY_SKIP_OFF {sko:#x}', f'#define DM_GAME_SHADER_KEY_SKIP_LEN {skl:#x}',
f'#define DM_GAME_ASPECT_UI_PREFIXES {{{", ".join(map(q, aui)) if aui else q("")}}}',
f'#define DM_GAME_ASPECT_UI_PREFIX_COUNT {len(aui)}',
f'#define DM_GAME_ASPECT_UI_RECT_PREFIXES {{{", ".join(map(q, aur)) if aur else q("")}}}',
f'#define DM_GAME_ASPECT_UI_RECT_PREFIX_COUNT {len(aur)}',

f'#define DM_GAME_RENDER_VIEW_W {rd[0]}',
f'#define DM_GAME_RENDER_VIEW_H {rd[1]}',
f'#define DM_GAME_RENDER_OUTPUT_W {rd[2]}',
f'#define DM_GAME_RENDER_OUTPUT_H {rd[3]}',
f'#define DM_GAME_RENDER_POOL_BYTES {rd[4]}',

f'#define DM_GAME_TEX_DIRTY_UPLOAD {int(tdu == "on")}',
f'#define DM_GAME_TEX_DYN_SLOTS {int(tds == "on")}',
f'#define DM_GAME_DRAW_BARRIERS_GAME {int(dbr == "game")}',
Expand Down
1 change: 1 addition & 0 deletions dm/games/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def macro(name, n):
return macros[name].strip('"')

def shown(cond, n):
if '&' in cond: return all(shown(part, n) for part in cond.split('&'))
if cond == 'always': return True
if cond == 'languages>1': return len(langs) > 1
if cond.startswith('fixups:'): return cond[7:] in keys
Expand Down
4 changes: 4 additions & 0 deletions dm/games/settings.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# variable the environment variable the setting sets
# kind choice: values value=label,..., an option only some games have with ?<shown>&<shown> after its label (languages: the game's own, from its control data; every language when it has none, with a note); range: values low:high:step, shown as a percentage;
# toggle: values - (on sets 1, off 0) or <on>/<off>, the two values the variable takes (on/off)
# shown conditions can be combined with &.
# default a value (a toggle's: 1 on, 0 off); DM_GAME_<NAME>: the host's own default from the game profile (game_profile.h, game.py); build:<VAR>: the IPA build's setting (build_ipa.sh)
# <ios>|<mac> selects the platform's default before resolving a profile macro or build variable
# shown always; DM_GAME_<NAME>!=<value> or ==<value>; fixups:<KEY>: main's rewriter table has that key (a stub in the game's build, patch_nso.py); languages>1 (more than one to pick, so also when the control data lists none); gfxapi:<API>: the packer's GFXAPI;
Expand Down Expand Up @@ -37,3 +38,6 @@ DM_PSO_PREBUILD toggle - 1 gfxapi:nvn Performance Pipeline prebuild The first st
DM_NVN_ENC_THREAD toggle - 1|DM_GAME_ENC_THREAD gfxapi:nvn Performance Encode thread
DM_FPS_HOLD toggle on/off DM_GAME_FPS_HOLD DM_GAME_FPS_TARGET!=0 Performance Hold frames when late
DM_METAL_HUD toggle - 0 always Performance Performance HUD

DM_WIDESCREEN choice 0=Original (16:9),1=Match window (ultrawide) 0 fixups:CAMERA_ASPECT&platform:mac Game Aspect ratio Wider camera view with a centered HUD. level=basic
DM_RENDER_RESOLUTION choice 0=Original (1600 x 900),1080=1920 x 1080,1200=2133 x 1200,1440=2560 x 1440 0 fixups:RENDER_RESOLUTION&platform:mac Game 3D resolution Docked mode. Higher resolutions use more GPU time and memory. level=basic
Loading
Loading