From 13819ab6d83ca110179eb8f4389ca4b12e86b721 Mon Sep 17 00:00:00 2001 From: shinodanpen Date: Mon, 16 Nov 2026 20:46:11 +0000 Subject: [PATCH] Add the field-of-view setting for 1.2.1 recomp/patches-v121.txt gets set fov on the two camera routines the aspect set already patches, at the load of the camera's vertical view angle (+0x13c): camera update main+0xcb4ad8, camera setup main+0x1252194. The update site matches 1.4.3's instruction for instruction around the load; the setup site copies the camera's fields with other instructions and registers before it and matches 1.4.3's from the load on. Both call sinf, cosf and tanf in the same order as on 1.4.3. Each version fills sead's perspective projection this way in ten places, each with its counterpart in the other version: these two camera copies, which are the only places 1.4.3 patches, and eight others (inlined copies, projection routines and four projections on the stack), none patched. The replacement words are those of the 1.1.0 and 1.4.3 sets (x10 kept on the stack, s8 overwritten by the next instruction), so no register liveness is assumed. #621 (ipavlin98, closed by its author) chose the same two sites with x8 and s2 as scratch registers. The setting's text in totk.ini.example and in the four menu languages names 1.2.1, and the comment of runtime/resolution.c res_fov_live names the patch files of all three versions. Co-Authored-By: Claude --- recomp/patches-v121.txt | 16 ++++++++++++++++ runtime/resolution.c | 8 ++++---- runtime/ui_text.c | 10 +++++----- totk.ini.example | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/recomp/patches-v121.txt b/recomp/patches-v121.txt index f1749df4..c624c7c7 100644 --- a/recomp/patches-v121.txt +++ b/recomp/patches-v121.txt @@ -132,6 +132,22 @@ site aspect main 12521cc bd414260 f81f0fea @page:x10 bd403940 f84107ea # ldr s0 site aspect main 19b36f0 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport) site aspect main 1ecdf68 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport) +# Field of view (runtime/resolution.c res_fov_live writes TOTK_FOV / 100 to page +60 and switches the set). The same two +# camera routines as the aspect set (update main+0xcb4208, setup main+0x1252024; 1.4.3 main+0x628460, main+0xb432bc) +# load the camera's vertical view angle (+0x13c, radians) a few words before the ratio and hand it to sead's perspective +# projection (+0xa0, then sinf / cosf / tanf of half of it at +0xa4..+0xac); 1.4.3's setup reads the same fields through +# x22 = camera + 0xd8. Eight more places fill a perspective projection the same way, 1.4.3 has the same eight, and +# neither version patches them: one more inlined copy that scales an angle of another object (main+0x6c5548, 1.4.3 +# main+0x4e9754), three projection routines (main+0xdde89c, main+0x1141ce8, main+0x1a5e994; 1.4.3 main+0xc02690, +# main+0xd42730, main+0x27d53d8) and four that fill a projection on the stack (main+0x7800f0, main+0x7805fc, +# main+0xc764cc, main+0x21ee474; 1.4.3 main+0x63e2b4, main+0x63e744, main+0x79344, main+0x2804fec). The replacement is +# the one of patches-v143.txt (word for word the sites of patches-v110.txt): it loads the angle as before and +# multiplies it by the factor on the page; s8 holds the factor because the next instruction (fmul s8, s0, s1) overwrites +# it, and x10 is kept on the stack. +set fov TOTK_FOV_PATCH 0 +site fov main cb4ad8 bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea # ldr s0, [x19, #0x13c] (camera update) +site fov main 1252194 bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea # ldr s0, [x19, #0x13c] (camera setup) + # Texture pool offsets past 2 GiB (MacNativeGames ca311e2d). The texture loader keeps a texture's place in its pool as a # 32-bit offset (main+0xad4294: sub x25, x9, x10, stored as the word w25) and widens it as a signed number for # nvnTextureBuilderSetStorage's offset and for SetPackagedTextureData's source (the pool's CPU address + offset). The diff --git a/runtime/resolution.c b/runtime/resolution.c index 313967fd..86a23ae3 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -625,10 +625,10 @@ int res_wants_wide_overlay(const unsigned out[2]) { return !res_is_16x9(out[0], out[1]) && rt_patch_set("aspect") >= 0; } -// 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-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. +// 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. #define FOV_MIN 70 #define FOV_MAX 140 void res_fov_live(void) { diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 1c9a5461..13317802 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -86,7 +86,7 @@ static const char *const text_en[UI_TEXT_COUNT] = { "bars, or stretch them over the whole picture. Applies from the next movie.", [UI_MENU_MOVIE_ASPECT_KEEP] = "Black bars", [UI_MENU_MOVIE_ASPECT_STRETCH] = "Stretch", [UI_MENU_FOV] = "Field of view", - [UI_MENU_FOV_DESC] = "How much of the world the camera shows, in percent of the game's own. Game versions 1.1.0 and 1.4.3.", + [UI_MENU_FOV_DESC] = "How much of the world the camera shows, in percent of the game's own. Game versions 1.1.0, 1.2.1 and 1.4.3.", [UI_MENU_SHADOW_RES] = "Shadow map size", [UI_MENU_SHADOW_RES_DESC] = "Size of the sun's shadow map. The game's own size changes with the view, down to about 400 " "near the ground, so leaf shadows look blocky and jump; a fixed size keeps them still and " @@ -663,7 +663,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = { "растянуть их на всю картинку. Действует со следующего ролика.", [UI_MENU_MOVIE_ASPECT_KEEP] = "Чёрные полосы", [UI_MENU_MOVIE_ASPECT_STRETCH] = "Растянуть", [UI_MENU_FOV] = "Поле зрения", - [UI_MENU_FOV_DESC] = "Сколько мира показывает камера, в процентах от игрового. Для версий игры 1.1.0 и 1.4.3.", + [UI_MENU_FOV_DESC] = "Сколько мира показывает камера, в процентах от игрового. Для версий игры 1.1.0, 1.2.1 и 1.4.3.", [UI_MENU_SHADOW_RES] = "Размер карты теней", [UI_MENU_SHADOW_RES_DESC] = "Размер карты теней от солнца. Собственный размер игры меняется вместе с видом, у земли до " "примерно 400, поэтому тени листвы выглядят квадратными и дёргаются; постоянный размер делает " @@ -1564,8 +1564,8 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_OV_FMT_FSR] = "AMD FSR 1, nitidez %d%%", [UI_MENU_OV_SCALE_NONE] = "nenhuma (1:1)", [UI_MENU_OV_SCALE_BILINEAR] = "bilinear", [UI_MENU_FOV] = "Campo de visão", - [UI_MENU_FOV_DESC] = "Quanto do mundo a câmera mostra, em porcentagem do original do jogo. Nas versões 1.1.0 e 1.4.3 do " - "jogo.", + [UI_MENU_FOV_DESC] = "Quanto do mundo a câmera mostra, em porcentagem do original do jogo. Nas versões 1.1.0, 1.2.1 e 1.4.3 " + "do jogo.", [UI_MENU_SHADOW_RES] = "Tamanho do mapa de sombras", [UI_MENU_SHADOW_RES_DESC] = "Tamanho do mapa de sombras do sol. O tamanho do jogo muda com a vista, até cerca de " "400 perto do chão, então as sombras das folhas ficam quadriculadas e pulam; um " @@ -1914,7 +1914,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_MOVIE_ASPECT_STRETCH] = "拉伸", [UI_MENU_FOV] = "视野", [UI_MENU_FOV_DESC] = "镜头能看到多大范围,以游戏自身视野的百分比表示。" - "支持游戏版本 1.1.0 和 1.4.3。", + "支持游戏版本 1.1.0、1.2.1 和 1.4.3。", [UI_MENU_SHARPNESS] = "FSR 锐度", [UI_MENU_SHARPNESS_DESC] = "FSR 缩放后的锐化强度;0 为关闭。", [UI_MENU_COLOR] = "色彩", diff --git a/totk.ini.example b/totk.ini.example index 4f7bfa61..1a2a4539 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -224,7 +224,7 @@ # does. Read when a movie starts, so a change takes effect at the next movie. # movie_aspect = keep # Field of view, in percent of the game's own: 70 to 140, 100 (the default) leaves the camera as it is. Higher shows -# more of the world around Link. Game versions 1.1.0 and 1.4.3. Changes while the game runs take effect at once. +# more of the world around Link. Game versions 1.1.0, 1.2.1 and 1.4.3. Changes while the game runs take effect at once. # fov = 100 # Anisotropic filtering of surface textures: game (the level the game asks for, as on the Switch) or 2, 4, 8, 16. Keeps # ground, roads and walls seen at a shallow angle sharp into the distance. Only filtered, mipmapped textures that tile