Repository navigation
fix(oot): scale water surface simulation substeps in float above 60 FPS - #2400
Merged
Merged
Conversation
In update 131072, the water surface simulation dispatcher (main+0x472e0) truncates the VFR step ratio with fcvtzs w9, s0 at main+0x475f8 before multiplying by the base substep count (6) at main+0x4760c. Above 60 FPS (or sub-frame jitter at 60 FPS), s0 < 1 truncates to 0 and skips the compute simulation loop while normal generation keeps reading frozen ripples from the ping-pong heightfields. Add an 8-instruction Mac veneer in patch_oot_timestep() (at text padding +384, between the resolution veneers and OOT_VR_CALL_STUB) that replaces the multiply at main+0x4760c with round-to-nearest-even(w8 * s0), clamped to >= 1 when w8 * s0 > 0 (preserving 0 on pause, s0 <= 0, or NaN). Extend oot_timestep_native to verify the veneer words natively on arm64.
zplzmzmpl
pushed a commit
to zplzmzmpl/MacNativeGames
that referenced
this pull request
Nov 27, 2026
…n float above 60 fps (cherry picked from commit 3e696c2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes frozen / lingering water surface ripples in The Legend of Zelda: Ocarina of Time (update
131072) when running above 60 FPS on Mac withpatch_oot_timestep().Root Cause
In the water surface simulation dispatcher (
main+0x472e0), the game computes the number of PDE simulation substeps per frame as:main+0x475ac:ldr s0, [x19]— loads the VFR step ratio (60 / actual_fps)main+0x475f4:ldr w8, [x19, #0x4c]— loads the base substeps per 60 Hz frame (6)main+0x475f8:fcvtzs w9, s0— truncates the float VFR ratio to an integermain+0x4760c:mul w8, w8, w9main+0x47614..0x47618:cmp w8, #1; b.lt 0x49540When
actual_fps > 60(e.g. 72–90 FPS, or even minor sub-frame jitter at 60 FPS),s0 < 1.0truncates tow9 = 0, givingtotal_substeps = 0. The dispatcher skips the entire compute simulation loop (cs26+N × cs25), leaving existing ripples frozen in the ping-pong heightfields while normal generation (cs29) keeps reading them until frame rate dips below 60 FPS.(Scanning all references to the VFR global
main+0x4c7e890confirmedmain+0x475f8is the only site truncatings0 < 1.0to0.)Fix
patch_oot_timestep()(games/oot/runtime/oot_timestep.h) placed at text padding+384..+416(between the resolution veneers ending at+372andOOT_VR_CALL_STUBat+512), verifying the 10-word context atmain+0x475f4..0x47618and zero padding before patchingmain+0x4760c.mul w8, w8, w9withround_nearest_even(w8 * s0), clamped to>= 1whenw8 * s0 > 0:s0 <= 0/NaN→0substeps (unchanged)s0 = 2.0) →12substeps (360/s, unchanged)s0 ≈ 1.0, including0.99jitter) →6substeps (360/s)s0 = 0.76) →5substepss0 = 0.667) →4substeps (360/s)s0 = 0.50) →3substeps (360/s)main+0x48700..0x4871c) andcs29reads the active index, so odd and even substep counts are safe.TOTK_EXPORT_IOS, and disabled whenOOT_REALTIME=0.games/oot/tests/oot_timestep_native.{py,c}to execute and verify the actual veneer words natively on arm64 (includings0preservation and edge cases).Testing
131072, Apple Silicon Mac):Ocarina of Time.appviaupdate_runtime.py.ocarina.logrecorded zero[RED]/ crash / Metal validation errors.main):python3 games/oot/tests/oot_timestep_native.py --work-dir <tmp>— passed.python3 -m unittest discover -s tests -p "*oot*"— 291 tests OK (1 skipped).xcrun clang -std=c11 -O2 -Wall -Wextra -Werror ... -fsyntax-only games/oot/runtime/game_patches_ns2.c— passed.oot_timestep.his Mac-only and excluded from the iOS project andTOTK_EXPORT_IOS).