Merge pull request #1459: lay the UI out for screen shapes from 4:3 to 32:9, offer 4:3 and phone sizes, keep the 16:9 width at narrower shapes (itaskaev2) (#632, #1453)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-25 16:22:24 +03:00
commit 73aafc3c12
12 files changed
+262 -60

No files matched your search

+20 -6
View File
@@ -66,7 +66,7 @@ static const char *const known[] = {
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX",
"SHOTS_FULL", "SKIP_CS", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS",
"SWKBD_ANSWER", "SYNC_AHEAD",
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT",
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VERT_PLUS", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT",
"VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MASK_BIAS", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
"WALK_KEY", "WALK_SCALE", "WB_EAGER", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
"ZSTD_CHECK", "ZSTD_NATIVE",
@@ -81,7 +81,7 @@ static const struct { const char *key, *section; } sections[] = {
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
{"HUD_WIDTH", "display"},
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"VERT_PLUS", "display"}, {"ANISO", "display"},
{"LOD_STEADY", "display"}, {"COLOR_PRESET", "display"},
{"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"},
{"COLOR_GAMMA", "display"}, {"HDR", "display"}, {"HDR_PEAK_NITS", "display"}, {"HDR_GAME_NITS", "display"},
@@ -149,6 +149,7 @@ static const CfgMeta metas[] = {
{"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|auto|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE},
{"LOD_STEADY", "0", "0|1", RESTART}, // sets steady
{"ASPECT", "fit", "fit|stretch", LIVE}, {"MOVIE_ASPECT", "keep", "keep|stretch", LIVE}, {"FOV", "100", "70..140", LIVE},
{"VERT_PLUS", "1", "0|1", LIVE}, // resolution.c res_fov_live
{"ANISO", "game", "game|2|4|8|16", RESTART}, // vk_texture.c sampler_features
// colour adjustment (vk_color.c); the preset is the menu's, the four values are what the present uses
{"COLOR_PRESET", "default", "default|vivid|clarity|custom", LIVE}, {"COLOR_BRIGHTNESS", "0", "-30..30", LIVE},
@@ -407,15 +408,24 @@ static const char *raw_get(const char *name) {
// the Switch ones.
static const unsigned SHAPED[][2] = {
{2560, 1080}, {3440, 1440}, {3840, 1600}, {5120, 2160}, // 21:9
{3840, 1080}, {5120, 1440}, // 32:9
{3840, 1080}, {5120, 1440}, {7680, 2160}, // 32:9
{1280, 800}, {1680, 1050}, {1920, 1200}, {2560, 1600}, // 16:10
{1920, 1280}, {2160, 1440}, {2256, 1504}, {2880, 1920}, {3000, 2000}, // 3:2
{1440, 1080}, {1600, 1200}, {2048, 1536}, {2732, 2048}, // 4:3 (CRT monitors, iPads)
{2340, 1080}, {3120, 1440}, {2400, 1080}, {3200, 1440}, // 19.5:9 and 20:9 (phones, streamed)
};
// The shapes a UI layout can be made for (tools/ultrawide_layout.py works on any aspect ratio between these): from 4:3
// to 32:9, 1% either side. A shape between them that SHAPED does not list takes a folder of its own exact size.
#define SHAPE_MIN (4.0 / 3.0 * 0.99)
#define SHAPE_MAX (32.0 / 9.0 * 1.01)
// The folder size of w x h's shape: of SHAPED within 1% of its aspect ratio, the closest, the first of equal ones
// (5120x2160 takes 2560x1080). The UI layout depends on the aspect ratio alone (tools/ultrawide_layout.py apply), so
// the setup writes one romfs-patches-<w>x<h> per shape, named after this size (installer/screens.py shape_size, the
// same rule), and romfs.c overlay_init looks for it. 0 for 16:9 and for a shape without a layout.
// same rule), and romfs.c overlay_init looks for it. A shape SHAPED does not list but within SHAPE_MIN..SHAPE_MAX (a
// phone's 13:6 screen streamed to, say) is its own folder, w x h itself, which the setup and the game's background
// generator make as they make the listed ones. 0 for 16:9 and outside that range (portrait screens).
int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]) {
if (!w || !h) return 0;
double r = (double)w / h, err = 0;
@@ -425,8 +435,12 @@ int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]) {
double e = fabs((double)SHAPED[i][0] / SHAPED[i][1] / r - 1);
if (e <= 0.01 && (best < 0 || e < err)) best = i, err = e;
}
if (best < 0) return 0;
out[0] = SHAPED[best][0], out[1] = SHAPED[best][1];
if (best >= 0) {
out[0] = SHAPED[best][0], out[1] = SHAPED[best][1];
return 1;
}
if (r < SHAPE_MIN || r > SHAPE_MAX) return 0;
out[0] = w, out[1] = h;
return 1;
}
+3 -2
View File
@@ -23,8 +23,9 @@ unsigned cfg_version(void);
int cfg_from_env(const char *name);
// 1 when the player set name (the environment or totk.ini), 0 when cfg_get gives a device profile's default or NULL.
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-<w>x<h> the setup writes for it. 0 for 16:9 and for a shape without a UI layout.
// The folder size of w x h's shape (cfg.c SHAPED: the closest aspect ratio within 1%, the first of equal ones; an
// unlisted shape from 4:3 to 32:9 keeps w x h), the one romfs-patches-<w>x<h> the setup writes for it. 0 for 16:9 and
// for a shape without a UI layout (portrait, narrower than 4:3, wider than 32:9).
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
+13 -4
View File
@@ -357,16 +357,25 @@ int probe_cfg(void) {
"prompts: the PlayStation folder puts A on the circle exactly when the layout puts A on the east button");
}
// One folder per screen shape (cfg.c cfg_shape_size, installer/screens.py shape_size): the closest aspect ratio of
// SHAPED within 1%, the first of equal ones; 16:9 and unlisted shapes have none.
// SHAPED within 1%, the first of equal ones; an unlisted shape from 4:3 to 32:9 its own size; 16:9, portrait and
// shapes narrower than 4:3 none.
unsigned sz[2] = {0, 0};
CHECK(cfg_shape_size(5120, 2160, sz) && sz[0] == 2560 && sz[1] == 1080, "shape: 5120x2160 takes 2560x1080's folder");
CHECK(cfg_shape_size(3440, 1440, sz) && sz[0] == 3440 && sz[1] == 1440, "shape: 3440x1440 keeps its own (0.8% off 2560x1080)");
CHECK(cfg_shape_size(1920, 800, sz) && sz[0] == 3840 && sz[1] == 1600, "shape: 1920x800 takes 3840x1600's folder");
CHECK(cfg_shape_size(2560, 1600, sz) && sz[0] == 1280 && sz[1] == 800 && cfg_shape_size(3000, 2000, sz) &&
sz[0] == 1920 && sz[1] == 1280 && cfg_shape_size(5120, 1440, sz) && sz[0] == 3840 && sz[1] == 1080,
sz[0] == 1920 && sz[1] == 1280 && cfg_shape_size(5120, 1440, sz) && sz[0] == 3840 && sz[1] == 1080 &&
cfg_shape_size(7680, 2160, sz) && sz[0] == 3840 && sz[1] == 1080,
"shape: 16:10, 3:2 and 32:9 take their first size");
CHECK(!cfg_shape_size(1920, 1080, sz) && !cfg_shape_size(2560, 1440, sz) && !cfg_shape_size(1024, 768, sz),
"shape: none for 16:9 and 4:3");
CHECK(cfg_shape_size(1024, 768, sz) && sz[0] == 1440 && sz[1] == 1080 && cfg_shape_size(2048, 1536, sz) &&
sz[0] == 1440 && sz[1] == 1080 && cfg_shape_size(3120, 1440, sz) && sz[0] == 2340 && sz[1] == 1080,
"shape: 4:3 and 19.5:9 take their first size");
CHECK(cfg_shape_size(2560, 1200, sz) && sz[0] == 2560 && sz[1] == 1200 && cfg_shape_size(2000, 1080, sz) &&
sz[0] == 2000 && sz[1] == 1080,
"shape: an unlisted shape between 4:3 and 32:9 keeps its own size");
CHECK(!cfg_shape_size(1920, 1080, sz) && !cfg_shape_size(2560, 1440, sz) && !cfg_shape_size(1280, 1024, sz) &&
!cfg_shape_size(1080, 1920, sz) && !cfg_shape_size(7680, 1440, sz),
"shape: none for 16:9, narrower than 4:3, portrait and wider than 32:9");
// romfs.c shaped_name: the exact size's folder (an older setup wrote every size) wins, else the shape's
{
char dir[1100], f[1200];
+34 -9
View File
@@ -44,6 +44,8 @@
#include "ov.h"
#include "platform/platform.h"
static void vert_plus_init(double ratio_over_16x9);
#define BASE_W 1920
#define BASE_H 1080
#define SCENE_W 1600
@@ -643,6 +645,7 @@ void res_init(void) {
memcpy(page + 56, &r, sizeof r);
rt_patch_switch(aspect, 1);
rt_log("resolution: camera aspect ratio %.4f (16:9 is %.4f)", ratio, game);
if (ratio < game) vert_plus_init(ratio / game);
}
} else {
rt_patch_switch(aspect, 0); // the page holds no ratio
@@ -673,25 +676,47 @@ int res_wants_wide_overlay(const unsigned out[2]) {
// Field of view (TOTK_FOV, percent of the game's own, 70..140, live): the camera's vertical view angle times the factor
// on page +60 (recomp/patches-v110.txt, patches-v121.txt and patches-v143.txt, set fov). The horizontal angle follows
// through the aspect ratio. 100 switches the set off, so the camera code is the game's own. Runs on a settings change
// (gfx_present.c window_settings_live), the first time at the first present.
// through the aspect ratio. A factor of 1 switches the set off, so the camera code is the game's own. Runs on a settings
// change (gfx_present.c window_settings_live), the first time at the first present.
//
// Vert+ (TOTK_VERT_PLUS, on by default): the camera keeps the game's vertical view angle at every shape, so a shape
// narrower than 16:9 (16:10, 3:2, 4:3) showed less of the world at the sides than 16:9 does. The factor is then also
// multiplied by the one that gives the game's default view the horizontal angle it has at 16:9: tan(v'/2) = tan(v/2)
// * (16/9) / aspect, so v' / v = 2 atan(tan(v/2) k) / v with k = 16:9 over the aspect. v is the game's default
// vertical angle, 51.2 degrees, measured on 1.4.3 at Lookout Landing: a 4:3 frame at TOTK_FOV=130 is a 16:9 frame of
// the same moment scaled by 0.730 about its middle (tan(v/2) / tan(1.3 v/2) = 0.730 gives v = 51.2). The patch scales
// the angle linearly, so a zoomed view (the bow, the scope) gets the same factor, a few percent short of the exact one.
#define FOV_MIN 70
#define FOV_MAX 140
#define VERT_PLUS_V (51.2 * 3.14159265358979 / 180)
static float vert_plus_k = 1; // set by res_init (vert_plus_init) for a camera narrower than 16:9
static void vert_plus_init(double ratio_over_16x9) {
double k = 1 / ratio_over_16x9, v = VERT_PLUS_V;
vert_plus_k = (float)(2 * atan(tan(v / 2) * k) / v);
}
void res_fov_live(void) {
static int set = -2, shown = 100;
static int set = -2, shown = 100, shown_vp = -1;
if (set == -2) set = rt_patch_set("fov");
int pct = cfg_int("TOTK_FOV");
pct = pct < FOV_MIN ? FOV_MIN : pct > FOV_MAX ? FOV_MAX : pct;
if (pct == shown) return;
shown = pct;
int vp = vert_plus_k != 1 && cfg_bool("TOTK_VERT_PLUS");
if (pct == shown && vp == shown_vp) return;
shown = pct, shown_vp = vp;
if (set < 0) {
rt_log("resolution: this game version has no field-of-view patch; TOTK_FOV=%d does nothing", pct);
if (pct != 100 || vp)
rt_log("resolution: this game version has no field-of-view patch; TOTK_FOV=%d and Vert+ do nothing", pct);
return;
}
float k = pct / 100.0f;
float k = pct / 100.0f * (vp ? vert_plus_k : 1);
memcpy((uint8_t *)rt_patch_page() + 60, &k, sizeof k); // before the switch: a site that sees it on reads k
rt_patch_switch(set, pct != 100);
rt_log("resolution: field of view %d%% of the game's", pct);
rt_patch_switch(set, k != 1);
if (vp)
rt_log("resolution: field of view %d%% of the game's, times %.4f for Vert+ (the 16:9 width at this narrower "
"shape)", pct, vert_plus_k);
else
rt_log("resolution: field of view %d%% of the game's", pct);
}
// TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (patches-v110.txt, patches-v121.txt and patches-v143.txt,
+9 -6
View File
@@ -571,15 +571,18 @@ static void folders_retry(const char *id, int need) {
}
// The game resolution (resolution.c): 16:9 sizes from its smallest, 1280x720 (for weak GPUs), up, the common 21:9 and
// 32:9 monitor sizes, the 16:10 screens of the Steam Deck, handhelds and laptops and the 3:2 screens of laptops and
// tablets (Surface, Framework; the camera and the HUD follow
// another shape, resolution.c res_init; the installer lays the HUD out for each, installer/steps.py ASPECT_SIZES), and
// the current value when it is another size.
// 32:9 monitor sizes (7680x2160: the 57-inch dual-4K ones), the 16:10 screens of the Steam Deck, handhelds and laptops, the 3:2 screens of laptops and
// tablets (Surface, Framework), the 4:3 screens of CRT monitors and iPads and the 19.5:9 and 20:9 screens of phones a
// game is streamed to (the camera and the HUD follow another shape, resolution.c res_init; the installer lays the HUD
// out for each, installer/screens.py ASPECT_SIZES), and the current value when it is another size: any shape from 4:3
// to 32:9 gets a layout of its own (cfg.c cfg_shape_size).
static void row_output_res(void) {
static const char *const vals[] = {"1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160",
"2560x1080", "3440x1440", "3840x1600", "5120x2160", "3840x1080", "5120x1440",
"2560x1080", "3440x1440", "3840x1600", "5120x2160", "3840x1080", "5120x1440", "7680x2160",
"1280x800", "1680x1050", "1920x1200", "2560x1600",
"1920x1280", "2160x1440", "2256x1504", "2880x1920", "3000x2000"};
"1920x1280", "2160x1440", "2256x1504", "2880x1920", "3000x2000",
"1440x1080", "1600x1200", "2048x1536", "2732x2048",
"2340x1080", "3120x1440", "2400x1080", "3200x1440"};
enum { N = sizeof vals / sizeof *vals };
char shown[N][32];
const char *names[N];