Make the PC prompts for every game resolution the setup lays the UI out for

The setup wrote romfs-patches-pc for 16:9 only, so prompts = pc on a 21:9, 32:9, 16:10 or 3:2 screen kept the game
resolution at 1920x1080 (cfg.c) or, with output_res set to the screen's shape, fell back to the Switch prompts.

- make_romfs_patches.py --reuse <folder>: a file of an earlier overlay whose contents match is hard-linked (copied
  where links fail) instead of compressed again; the output is byte for byte the same.
- The setup builds romfs-patches-pc-<w>x<h> for each of ASPECT_SIZES from romfs-patches-pc with --reuse: only the
  Common archive is compressed, so the fifteen folders take about two minutes and 6 MiB each instead of 22 minutes
  and 73 MiB each.
- cfg.c: the display-shaped output_res default applies with prompts = pc when romfs-patches-pc-<w>x<h> is there
  (romfs_shaped_pc_ready); Xbox prompts keep 1920x1080 as before.
This commit is contained in:
Wintego committed 2026-11-08 13:20:17 +03:00
1 parent ae30a61b7b
commit ceece5683a
10 files changed
+125 -26

No files matched your search

+14 -6
View File
@@ -337,8 +337,10 @@ static const char *raw_get(const char *name) {
// picture between black bars. The sizes are the ones the installer lays the HUD out for (installer/steps.py
// ASPECT_SIZES, ui/menu.cpp row_output_res): of the display's shape within 1%, the smallest at least 1080 high that fits
// the display, else the largest that fits. A 16:9 display, an unknown one or one of another shape keeps 1920x1080.
// Xbox or keyboard prompts keep 1920x1080 too: the setup builds their folders for 16:9 only (romfs.c overlay_init), so
// a default of another shape would trade the prompts the player chose for the Switch ones.
// Xbox prompts keep 1920x1080 too: the setup builds their folders for 16:9 only (romfs.c overlay_init), so a default of
// another shape would trade the prompts the player chose for the Switch ones. Keyboard prompts have a folder for each
// of these sizes (romfs-patches-pc-<w>x<h>, installer/steps.py Prepare): they keep 1920x1080 only when the one for
// the display's size is missing, as in a source build without make_romfs_patches.py --prompts pc --aspect.
static const unsigned SHAPED[][2] = {
{2560, 1080}, {3440, 1440}, {3840, 1600}, {5120, 2160}, // 21:9
{3840, 1080}, {5120, 1440}, // 32:9
@@ -346,10 +348,14 @@ static const unsigned SHAPED[][2] = {
{1920, 1280}, {2160, 1440}, {2256, 1504}, {2880, 1920}, {3000, 2000}, // 3:2
};
static char screen_res[16]; // set once by cfg_init, "" for none
static int screen_pc; // romfs-patches-pc-<screen_res> has a manifest (set once by cfg_init)
static int switch_prompts(void) {
// Whether the prompts in effect have their folder at screen_res. The same picks as input_map.c input_prompts_pick: an
// unknown or empty value is the Nintendo prompts, an unset one Xbox while the pad layout is "xbox_prompts".
static int shape_keeps_prompts(void) {
const char *p = raw_get(PREFIX "PROMPTS"), *l = raw_get(PREFIX "PAD_LAYOUT");
return (!p || !strcasecmp(p, "nintendo")) && !(l && !strcasecmp(l, "xbox_prompts"));
if (p && *p) return !strcasecmp(p, "pc") ? screen_pc : strcasecmp(p, "xbox") != 0;
return !(l && !strcasecmp(l, "xbox_prompts"));
}
static void screen_default(void) {
@@ -367,7 +373,8 @@ static void screen_default(void) {
if (best < 0) best = fit;
if (best < 0) return;
snprintf(screen_res, sizeof screen_res, "%ux%u", SHAPED[best][0], SHAPED[best][1]);
if (!raw_get(PREFIX "OUTPUT_RES") && switch_prompts())
screen_pc = romfs_shaped_pc_ready(SHAPED[best][0], SHAPED[best][1]);
if (!raw_get(PREFIX "OUTPUT_RES") && shape_keeps_prompts())
rt_log("cfg: the display is %dx%d: output_res defaults to %s, its shape (totk.ini output_res sets another)", sw,
sh, screen_res);
}
@@ -376,7 +383,8 @@ const char *cfg_get(const char *name) {
const char *v = raw_get(name);
if (v || strncmp(name, PREFIX, PREFIX_LEN)) return v;
if (!profile_of())
return screen_res[0] && !strcasecmp(name + PREFIX_LEN, "OUTPUT_RES") && switch_prompts() ? screen_res : NULL;
return screen_res[0] && !strcasecmp(name + PREFIX_LEN, "OUTPUT_RES") && shape_keeps_prompts() ? screen_res
: NULL;
for (size_t i = 0; i < sizeof DECK / sizeof *DECK; i++)
if (!strcasecmp(DECK[i].key, name + PREFIX_LEN)) return DECK[i].value;
return NULL;
+1
View File
@@ -280,6 +280,7 @@ int res_is_16x9(unsigned w, unsigned h); // within 1% of 16:9
int res_wants_wide_overlay(const unsigned out[2]); // not 16:9 on a game version with the camera aspect patch
int romfs_shaped_ready(unsigned w, unsigned h); // romfs-patches-<w>x<h> has a manifest (romfs.c; works
// before fs_init)
int romfs_shaped_pc_ready(unsigned w, unsigned h); // the same for romfs-patches-pc-<w>x<h>
void res_wanted(unsigned out[2]); // the output size TOTK_OUTPUT_RES asks for
void res_fov_live(void); // TOTK_FOV to the camera (set fov); on a settings change
// ---- code patches (patches.c) and the frame step (frame_rate.c)
+12 -5
View File
@@ -1080,19 +1080,26 @@ static void index_path(char *out, size_t cap) {
strcpy(out + k, "romfs-index.bin");
}
// 1 when the game resolution w x h has the UI layout of its shape: romfs-patches-<w>x<h> next to romfs-index.bin with a
// manifest, the folder overlay_init looks for. Works before fs_init: index_dir is not set that early (res_init and
// resolution.c decide run first), so the index path is worked out again here.
int romfs_shaped_ready(unsigned w, unsigned h) {
// 1 when <prefix>-<w>x<h> has a manifest next to romfs-index.bin. Works before fs_init: index_dir is not set that early
// (cfg_init, res_init and resolution.c decide run first), so the index path is worked out again here.
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h) {
char dir[2100], path[2200];
index_path(dir, sizeof dir);
char *sep = plat_last_sep(dir);
if (sep) *sep = 0;
else strcpy(dir, ".");
return snprintf(path, sizeof path, "%s/romfs-patches-%ux%u/manifest.tsv", dir, w, h) < (int)sizeof path &&
return snprintf(path, sizeof path, "%s/%s-%ux%u/manifest.tsv", dir, prefix, w, h) < (int)sizeof path &&
plat_file_exists(path);
}
// 1 when the game resolution w x h has the UI layout of its shape: romfs-patches-<w>x<h>, the folder overlay_init
// looks for.
int romfs_shaped_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches", w, h); }
// 1 when it has the PC prompts with that layout too: romfs-patches-pc-<w>x<h>, which overlay_init loads in its place
// with prompts = pc.
int romfs_shaped_pc_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches-pc", w, h); }
static void load_index(void) {
char path[2100];
index_path(path, sizeof path);
+2 -2
View File
@@ -791,8 +791,8 @@ static const char *prompts_note(bool *restart) {
const char *layout = cfg_value("TOTK_PAD_LAYOUT"), *used = romfs_prompts();
const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout);
if (want == used || (want && used && !strcmp(want, used))) return nullptr;
// A game resolution of another shape needs a folder of its own for the PC prompts (romfs-patches-pc-<w>x<h>), which
// the setup does not write: the shape is the reason then, not the setup.
// A game resolution of another shape needs a folder of its own for the PC prompts (romfs-patches-pc-<w>x<h>). The
// setup writes one for each size the Screen tab offers; at any other size the shape is the reason, not the setup.
int off = romfs_prompts_off(want);
if (want && !romfs_prompts_ready(want) && off != ROMFS_PROMPTS_SHAPE) return menu_text(UI_MENU_PROMPTS_MISSING);
switch (off) {