diff --git a/installer/steps.py b/installer/steps.py index b22dacf3..787a1050 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -622,11 +622,14 @@ class Prepare(Step): if code: raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log)) # The same overlay with the UI laid out for the 21:9 game resolutions the settings menu offers (runtime/romfs.c - # overlay_init picks the one that matches) + # overlay_init picks the one that matches). Only 1.4.3 has the camera aspect patch (recomp/patches-v143.txt) the + # layouts go with, and ultrawide_layout.py is checked against 1.4.3's layout archive: 1.2.1 builds none. for size in WIDE_SIZES: remove(dest / f'romfs-patches-{size}') + if version_tag(game_version(ctx)) != 'v143': + continue code, log = run_tool(ctx, 'prepare', layout.tools / 'make_romfs_patches.py', - ['--version', version_tag(game_version(ctx)), '--romfs', dest / 'romfs', '--out', + ['--version', 'v143', '--romfs', dest / 'romfs', '--out', dest / f'romfs-patches-{size}', '--aspect', size]) if code: raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log)) diff --git a/runtime/host.h b/runtime/host.h index 7bbfe5ed..7e4a1939 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -242,6 +242,8 @@ void res_heapdef_served(void); // romfs.c serves the void res_init(void); // after rt_patches_init: the patch page and the sets void res_sizes(unsigned out[2], unsigned scene[2]); // the output and scene sizes in effect (the game's own // until res_init switched the sets on) +int res_is_16x9(unsigned w, unsigned h); // within 1% of 16:9 (the test res_init and romfs.c share) +int res_wants_wide_overlay(const unsigned out[2]); // not 16:9 on a game version with the camera aspect patch void res_wanted(unsigned out[2]); // the output size TOTK_OUTPUT_RES asks for // ---- code patches (patches.c) and the frame step (frame_rate.c) void rt_patches_init(void); // after ldr_load: switches from the environment, the patch diff --git a/runtime/resolution.c b/runtime/resolution.c index 11ddd91c..514b3e6e 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -224,7 +224,7 @@ void res_init(void) { // for that shape come from romfs-patches-x (romfs.c overlay_init, tools/make_romfs_patches.py --aspect). double ratio = (double)R.ow / R.oh, game = (double)BASE_W / BASE_H; int aspect = rt_patch_set("aspect"); - if (ratio / game < 0.99 || ratio / game > 1.01) { + if (!res_is_16x9(R.ow, R.oh)) { if (aspect < 0) { rt_log("resolution: output %ux%u is not 16:9 and this game version has no camera aspect patch; the view " "is stretched", R.ow, R.oh); @@ -241,6 +241,18 @@ void res_init(void) { scene_on ? "" : " (the game's own 5/6 of the output)", (unsigned long long)res_heap_extra_kib()); } +// 16:9 within 1% (1366x768 counts): the shape the game's own layouts and camera are made for. +int res_is_16x9(unsigned w, unsigned h) { + double rel = ((double)w / h) / ((double)BASE_W / BASE_H); + return rel >= 0.99 && rel <= 1.01; +} + +// The game resolution asks for a romfs-patches-x overlay: it is not 16:9 and the game version has the camera +// aspect patch (set aspect, 1.4.3 only); the wide UI layouts only fit a camera that follows the same shape. +int res_wants_wide_overlay(const unsigned out[2]) { + return !res_is_16x9(out[0], out[1]) && rt_patch_set("aspect") >= 0; +} + void res_wanted(unsigned out[2]) { decide(); out[0] = R.ow, out[1] = R.oh; diff --git a/runtime/romfs.c b/runtime/romfs.c index e754e8f8..e9594669 100644 --- a/runtime/romfs.c +++ b/runtime/romfs.c @@ -410,12 +410,13 @@ static void heapdef_overlay(void) { static void overlay_init(void) { // TOTK_ROMFS_PATCHES unset: romfs-patches next to romfs-index.bin if it has a manifest (tools/make_romfs_patches.py). // A game resolution that is not 16:9 takes romfs-patches-x instead when it is there: the same overlay with - // the UI laid out for that shape (make_romfs_patches.py --aspect). + // the UI laid out for that shape (make_romfs_patches.py --aspect). 1.2.1 has no camera aspect patch, so it keeps + // the 16:9 layout (res_wants_wide_overlay). char def[2100]; const char *patches = cfg_get("TOTK_ROMFS_PATCHES"); unsigned out[2]; res_wanted(out); - if (!patches && (unsigned long long)out[0] * 9 != (unsigned long long)out[1] * 16) { + if (!patches && res_wants_wide_overlay(out)) { if (snprintf(def, sizeof def, "%s/romfs-patches-%ux%u/manifest.tsv", index_dir, out[0], out[1]) < (int)sizeof def && GetFileAttributesA(def) != INVALID_FILE_ATTRIBUTES) { def[strlen(def) - strlen("/manifest.tsv")] = 0;