diff --git a/runtime/cfg.c b/runtime/cfg.c index ee0d0fe8..12b6c33b 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -462,6 +462,13 @@ static void screen_default(void) { sh, screen_res); } +int cfg_screen_size(unsigned out[2]) { + unsigned w = 0, h = 0; + if (raw_get(PREFIX "OUTPUT_RES") || !screen_res[0] || sscanf(screen_res, "%ux%u", &w, &h) != 2) return 0; + out[0] = w, out[1] = h; + return 1; +} + const char *cfg_get(const char *name) { const char *v = raw_get(name); if (v || strncmp(name, PREFIX, PREFIX_LEN)) return v; diff --git a/runtime/cfg.h b/runtime/cfg.h index add5828b..53f6a7b3 100644 --- a/runtime/cfg.h +++ b/runtime/cfg.h @@ -26,6 +26,12 @@ int cfg_is_set(const char *name); // The folder size of w x h's shape (cfg.c SHAPED: the closest aspect ratio within 1%, the first of equal ones), the // one romfs-patches-x the setup writes for it. 0 for 16:9 and for a shape without a UI layout. int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]); +// The size output_res defaults to on this display (its shape, cfg.c screen_default) while the player set no +// output_res, also when the default stays 1920x1080 because that shape lacks the prompts' folder. The generator the game +// starts for missing folders (romfs.c romfs_folders_prepare) makes them for this size, so after a prompts change the +// next start takes the display's shape again. 0 when the player set output_res, a device profile is in use or the +// display is 16:9. +int cfg_screen_size(unsigned out[2]); // The device profile in use, "deck" or "desktop" (TOTK_DEVICE_PROFILE, else what the machine is). const char *cfg_device_profile(void); // Writes the keys cfg_set changed since the last save into totk.ini next to totk.exe (cfg_save_to: the file at path). diff --git a/runtime/romfs.c b/runtime/romfs.c index 4cb4f0ff..648fce82 100644 --- a/runtime/romfs.c +++ b/runtime/romfs.c @@ -1110,10 +1110,11 @@ static void overlay_init(void) { // A folder the settings in effect ask for and the install lacks (an older setup, a failed setup step, a display // of another shape): its generator starts in the background for the next start when the setup's tools are next to // the game (romfs_folders_prepare). The size is the one output_res asks for: without its shape's layout the game - // draws 16:9 this time (resolution.c shape_fallback). Nothing with TOTK_ROMFS_PATCHES set; a source build has no - // build-cache/rebuild.txt and keeps the lines above. + // draws 16:9 this time (resolution.c shape_fallback). Without an output_res it is the display's shape, which the + // default keeps only while that shape has the prompts' folder (cfg.c cfg_screen_size). Nothing with + // TOTK_ROMFS_PATCHES set; a source build has no build-cache/rebuild.txt and keeps the lines above. unsigned asked[2]; - res_asked(asked); + if (!cfg_screen_size(asked)) res_asked(asked); romfs_folders_prepare(asked[0], asked[1], prompts_wanted); size_t prompts_end = noverlay; char plain[2100]; // romfs-patches, when it has a manifest diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index 27fd6756..c3947b15 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -531,14 +531,17 @@ static int folders_tick(bool now) { unsigned v = cfg_version(); if (v != g_folders.seen) { g_folders.seen = v; - const char *res = cfg_value("TOTK_OUTPUT_RES"), *layout = cfg_value("TOTK_PAD_LAYOUT"); + const char *layout = cfg_value("TOTK_PAD_LAYOUT"); const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout); + // Without an output_res the display's shape: the default falls back to 1920x1080 while that shape lacks the + // prompts' folder, and the folders made for it bring the shape back at the next start (cfg_screen_size). + unsigned s[2] = {0, 0}; + if (!cfg_screen_size(s) && sscanf(cfg_value("TOTK_OUTPUT_RES"), "%ux%u", &s[0], &s[1]) != 2) s[0] = s[1] = 0; char request[sizeof g_folders.request]; - snprintf(request, sizeof request, "%s|%s|%s", res, cfg_value("TOTK_HUD_WIDTH"), want ? want : ""); + snprintf(request, sizeof request, "%ux%u|%s|%s", s[0], s[1], cfg_value("TOTK_HUD_WIDTH"), want ? want : ""); if (strcmp(request, g_folders.request)) { snprintf(g_folders.request, sizeof g_folders.request, "%s", request); - unsigned w = 0, h = 0; - if (sscanf(res, "%ux%u", &w, &h) != 2) w = h = 0; + unsigned w = s[0], h = s[1]; g_folders.w = w, g_folders.h = h, g_folders.want = want; g_folders.missing = w && h ? romfs_folders_missing(w, h, want) : 0; g_folders.at = g_folders.missing && strcmp(request, g_folders.asked) && romfs_folders_can_prepare() diff --git a/tools/make_romfs_patches.py b/tools/make_romfs_patches.py index 3ca906ca..8364b1be 100644 --- a/tools/make_romfs_patches.py +++ b/tools/make_romfs_patches.py @@ -77,11 +77,11 @@ left by a run that was stopped is removed by the next run for that folder once i """ import argparse import compression.zstd as zstd +import ctypes +import glob import hashlib import importlib.util import json -import ctypes -import glob import os import re import shutil