From 02220fc8794d5fc04e8e68cc4a6415b20ab5d9ac Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Thu, 19 Nov 2026 22:02:34 +0300 Subject: [PATCH] The Tenbez Shrine launcher set has its own switch, shutter_fix, and sits at the end of the 1.4.3 table, so the sets after it keep their numbers and a lift changes one chunk; the comment names the second AI file that uses the node (#1215) Co-Authored-By: Claude Opus 5.5 --- docs/settings.md | 1 + recomp/patches-v143.txt | 52 +++++++++++++++++++++-------------------- runtime/cfg.c | 5 ++-- totk.ini.example | 3 +++ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 0a7ea222..fe38aea3 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -238,3 +238,4 @@ These names are code patch sets built into the generated game code (`recomp/patc | `patch_output` (default `0`) | Patch set that makes the game use the configured output size for its swapchain and display configuration. | The resolution code switches this set whenever the output differs from the base size; a manual value is replaced. | Unknown | | `patch_scene` (default `0`) | Patch set that makes the game use the configured scene render size. | The resolution code switches this set from the render size setting; a manual value is replaced. | Unknown | | `report_guard` (default `1`) | Patch set on 1.4.3 only: in the model scene's report loop (main+0xa22d8, main+0xa2310) an object whose report handle is negative or whose row index is 0x8000 or more gets coverage 0 for that frame and its handle reset, the path the game takes after every read, instead of reading past the report rows. On valid rows the game's code runs unchanged. | `0` runs the game's code as shipped: a bad row index reads far past the rows and crashes, the class Weeping of the Empire met while using Ultrahand and aiming. | Risky | +| `shutter_fix` (default `1`) | Patch set on 1.4.3 only (set `shutter`, main+0x25e55d0): the speed the AI node QueryBlackboardGetF32FromActorForOunce returns is scaled by 1 + 0.065 x (1 - frame ratio)^2 when the actor's shouldUseOunceSpeed flag is set, which only the two launchers of Tenbez Shrine (Dungeon034) set (#1215). Every other actor gets its value unchanged; 1.0 at 30 fps and below. | `0` runs the game's code: above about 45 fps the ball leaves the launcher too slowly and stays on the rim of the other launcher or falls into the pit. Measured: on dev at 60 fps the ball stuck from the first shots; with the set at 60 and 120 fps it went back and forth as at 30. | Safe | diff --git a/recomp/patches-v143.txt b/recomp/patches-v143.txt index 259fa27e..3265ff7a 100644 --- a/recomp/patches-v143.txt +++ b/recomp/patches-v143.txt @@ -86,31 +86,6 @@ site fade main 95dd24 1e380008 1e380008 5ac0110a 53057d4a 0b0a0108 # the same, site fade main 6155e4 1e38000a 1e38000a 5ac0114b 53057d6b 0b0b014a # fcvtzs w10, s0; clz w11, w10; lsr w11, w11, #5; add w10, w10, w11 site fade main 615660 1e38000a 1e38000a 5ac0114b 53057d6b 0b0b014a # the same, second pre-actor fade path -# Tenbez Shrine launchers (issue #1215). The two DgnObj_BoxShutter_4x4x4 that throw the stone ball across the room move -# 3 m at Speed (1.0 m per 30 Hz frame, 30 m/s): their AI (AI/ShutterFence.root.ainb) advances the target by Speed * -# frame ratio each frame and sets the kinematic body's velocity to reach it. The shorter the frame, the slower the ball -# leaves. Measured on the flight's apex (the ball rests at y = -4.42): 6.33 at 30 fps, 6.11 at 45, 6.00 at 60, 5.79 at -# 90, 5.61 at 120. Below about 6.1 the ball lands more and more often on the rim of the receiving launcher instead -# of its seat, and the next shots juggle it there or knock it into the pit. The data suggest Nintendo tuned this by -# hand for a 60 fps build ("Ounce", which looks like the Switch 2): in -# the shrine's map both actors carry SpeedForOunce = 1.01 and shouldUseOunceSpeed, read by the node -# QueryBlackboardGetF32FromActorForOunce, which only that AI uses. The Switch build of the node ignores the pair: its -# evaluation (main+0x25e557c) looks up the base key alone. With 1.01 the apex is 6.20 at 60 fps, but 5.96 at 90 and -# 5.81 at 120, so the site scales by the frame instead. It is where the evaluation loads the value: when the node's -# shouldUseOunceKey input (+0x58) is true, the value is multiplied by 1 + 0.065 * (1 - ratio)^2, ratio being the time -# object's +0x38 (the frame in 30 Hz frames; [[main+0x3ad27c8] + 0xc8], the object the set bounce reads) clamped to -# 0..1. That is 1.016 at 60 fps and 1.037 at 120, and exactly 1 at 30 fps and below. Measured apex with it: 6.25 at -# 45 fps, 6.33 at 60, 6.23 at 90, 6.33 at 120, 6.35 at 144. Every other user of the node has the input false and gets -# its value unchanged. x9, x10 and s1-s4 are free: after the site the function only moves x19 to x0, restores the -# saved registers and tail-calls the output setter (main+0xb9b818), which reads x0 and s0. -set shutter TOTK_HIGHFPS_FIX 1 -site shutter main 25e55d0 bc605900 bc605900 f9402ea9 927ef529 39400129 1e230123 b000a76a f943e54a f940654a bd403941 1e2e1002 1e213841 2f00e404 1e246821 1e227821 1e210821 5283d709 72a7b0a9 1e270124 1e240821 1e230821 1f010000 -# ldr s0, [x8, w0, uxtw #2]; ldr x9, [x21, #0x58]; and x9, x9, #~3; ldrb w9, [x9]; ucvtf s3, w9 (the input, 0 or 1); -# adrp x10, main+0x3ad2000; ldr x10, [x10, #0x7c8]; ldr x10, [x10, #0xc8]; ldr s1, [x10, #0x38] (ratio); -# fmov s2, #1.0; fsub s1, s2, s1; movi d4, #0; fmaxnm s1, s1, s4; fminnm s1, s1, s2; fmul s1, s1, s1; -# mov w9, #0x1eb8; movk w9, #0x3d85, lsl #16; fmov s4, w9 (0.065); fmul s1, s1, s4; fmul s1, s1, s3; -# fmadd s0, s0, s1, s0 - # Output size (upstream game_patches_v143.c patch_output_res; runtime/resolution.c switches the set on). The swapchain # size nnMain writes comes from page +48; the display configuration's canvas (+0x10) and active output (+0x508) from # page +32, and the configuration goes to page +40. x9 is dead at the publication point. @@ -1239,3 +1214,30 @@ hook main 585bd0 # off (silent from the pause on) and 51 of 59 with it on; a pause of 2 s with the set off, 4 of 59. set audiodrain TOTK_AUDIO_DRAIN_FIX 1 site audiodrain main 149244 17fffe34 f9400268 17fffe2a # b 0x148b14 -> ldr x8, [x19]; b 0x148aec + +# Tenbez Shrine launchers (issue #1215). The two DgnObj_BoxShutter_4x4x4 that throw the stone ball across the room move +# 3 m at Speed (1.0 m per 30 Hz frame, 30 m/s): their AI (AI/ShutterFence.root.ainb) advances the target by Speed * +# frame ratio each frame and sets the kinematic body's velocity to reach it. The shorter the frame, the slower the ball +# leaves. Measured on the flight's apex (the ball rests at y = -4.42): 6.33 at 30 fps, 6.11 at 45, 6.00 at 60, 5.79 at +# 90, 5.61 at 120. Below about 6.1 the ball lands more and more often on the rim of the receiving launcher instead +# of its seat, and the next shots juggle it there or knock it into the pit. The data suggest Nintendo tuned this by +# hand for a 60 fps build ("Ounce", which looks like the Switch 2): in +# the shrine's map both actors carry SpeedForOunce = 1.01 and shouldUseOunceSpeed, read by the node +# QueryBlackboardGetF32FromActorForOunce (also in AI/ShutterFence_WithVibration.root.ainb of the +# FldObj_RuinStoneWall_A_20/30_Shutter walls, where the flag is never set). The Switch build of the node ignores the +# pair: its evaluation (main+0x25e557c) looks up the base key alone. With 1.01 the apex is 6.20 at 60 fps, but 5.96 at 90 and +# 5.81 at 120, so the site scales by the frame instead. It is where the evaluation loads the value: when the node's +# shouldUseOunceKey input (+0x58) is true, the value is multiplied by 1 + 0.065 * (1 - ratio)^2, ratio being the time +# object's +0x38 (the frame in 30 Hz frames; [[main+0x3ad27c8] + 0xc8], the object the set bounce reads) clamped to +# 0..1. That is 1.016 at 60 fps and 1.037 at 120, and exactly 1 at 30 fps and below. Measured apex with it: 6.25 at +# 45 fps, 6.33 at 60, 6.23 at 90, 6.33 at 120, 6.35 at 144. Every other user of the node has the input false and gets +# its value unchanged. x9, x10 and s1-s4 are free: after the site the function only moves x19 to x0, restores the +# saved registers and tail-calls the output setter (main+0xb9b818), which reads x0 and s0. Its own switch, +# shutter_fix (TOTK_SHUTTER_FIX); 0 runs the game's instruction. +set shutter TOTK_SHUTTER_FIX 1 +site shutter main 25e55d0 bc605900 bc605900 f9402ea9 927ef529 39400129 1e230123 b000a76a f943e54a f940654a bd403941 1e2e1002 1e213841 2f00e404 1e246821 1e227821 1e210821 5283d709 72a7b0a9 1e270124 1e240821 1e230821 1f010000 +# ldr s0, [x8, w0, uxtw #2]; ldr x9, [x21, #0x58]; and x9, x9, #~3; ldrb w9, [x9]; ucvtf s3, w9 (the input, 0 or 1); +# adrp x10, main+0x3ad2000; ldr x10, [x10, #0x7c8]; ldr x10, [x10, #0xc8]; ldr s1, [x10, #0x38] (ratio); +# fmov s2, #1.0; fsub s1, s2, s1; movi d4, #0; fmaxnm s1, s1, s4; fminnm s1, s1, s2; fmul s1, s1, s1; +# mov w9, #0x1eb8; movk w9, #0x3d85, lsl #16; fmov s4, w9 (0.065); fmul s1, s1, s4; fmul s1, s1, s3; +# fmadd s0, s0, s1, s0 diff --git a/runtime/cfg.c b/runtime/cfg.c index a3b8f5f1..1c40f239 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -63,7 +63,7 @@ static const char *const known[] = { "RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHUNKS", "REPLAY_CHUNK_DRAWS", "REPLAY_SKEW_US", "REPLAY_STATE_CHECK", "REPLAY_WORKERS", "REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES", "ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SHADER_CACHE", - "SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", + "SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX", "SHOTS_FULL", "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", @@ -76,7 +76,7 @@ static const char *const known[] = { static const struct { const char *key, *section; } sections[] = { {"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"FRAME_QUEUE", "frame rate"}, {"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"}, - {"CLIMB_FIX", "frame rate"}, {"AUDIO_DRAIN_FIX", "frame rate"}, + {"CLIMB_FIX", "frame rate"}, {"AUDIO_DRAIN_FIX", "frame rate"}, {"SHUTTER_FIX", "frame rate"}, {"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"}, @@ -165,6 +165,7 @@ static const CfgMeta metas[] = { {"MODS_REBUILD", "auto", "auto|off", RESTART}, {"MODS_WITHOUT_CODE", "0", "0|1", RESTART}, // 1: a mod is used without the code module it cannot run (mods.c) {"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART}, {"AUDIO_DRAIN_FIX", "1", "0|1", RESTART}, + {"SHUTTER_FIX", "1", "0|1", RESTART}, {"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART}, {"OPERATION_MODE", "docked", "docked|handheld", RESTART}, {"ASSUME_FOCUS", "1", "0|1", LIVE}, // read on every focus change (ov_system.c) diff --git a/totk.ini.example b/totk.ini.example index e41e38cf..3799578f 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -33,6 +33,9 @@ # audio = none and after the game's audio stream was paused for 2 s and for 5 s in test runs, not while a device plays. # 0 = the game's own code. # audio_drain_fix = 1 +# Game 1.4.3: the two launchers in Tenbez Shrine throw the stone ball into the other launcher's seat above 30 fps. +# 0 = the game's own speed, tuned for 30 fps. +# shutter_fix = 1 [performance] # The keys of this section and of [diagnostics] are for testing and troubleshooting, and take effect at the next start.