Build the wide UI overlays for 1.4.3 only and share the 16:9 test between resolution.c and romfs.c

1.2.1 has no camera aspect patch, so the installer no longer builds romfs-patches-<w>x<h> for it (the layout tool is checked against 1.4.3 and could fail the whole install), and romfs.c overlay_init skips that overlay on 1.2.1 through res_wants_wide_overlay. overlay_init and res_init now both call res_is_16x9 (1% tolerance), so 1366x768 counts as 16:9 and logs no missing overlay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-31 07:44:30 +03:00
1 parent 582f675e88
commit 583f4b45c2
4 files changed
+23 -5

No files matched your search

+5 -2
View File
@@ -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))
+2
View File
@@ -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
+13 -1
View File
@@ -224,7 +224,7 @@ void res_init(void) {
// for that shape come from romfs-patches-<w>x<h> (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-<w>x<h> 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;
+3 -2
View File
@@ -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-<w>x<h> 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;