Skip to content

Ocarina: clothes and hair sway at real speed with FPS Unlock above 60 fps - #1793

Merged
capy-ai[bot] merged 1 commit into
zortos293:nx2from
atk3001:fix/oot-cloth-speed-above-60
Nov 15, 2026
Merged

capy-ai[bot] merged 1 commit into
zortos293:nx2from
atk3001:fix/oot-cloth-speed-above-60

Conversation

@atk3001

@atk3001 atk3001 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Changes

With FPS Unlock above 60 fps, clothes, hair and other cloth sway too fast in the wind: about 1.4x at
86 fps and 2x at 120 fps. At 60 fps they look right.

The cloth update (Havok cloth, entry main+0x166A00) gets its time step as
T[0x168] * T[0x1C0] * (1/60) (T = *[main+0x4E94B20], the game's timing table). Unlike the other
users of that table, it never multiplies in the frame step at T+0x10, so every frame simulates
1/60 s however long the frame really was. Four sites load the 1/60 before that multiply:

Site (main+) Original In
0x14632C ldr s0, [x8, #0x66c] 0x146100
0x2AB804 fmov s0, w8 (0x3C888889) 0x2AA820
0x2C207A4 ldr s0, [x8, #0x66c] 0x2C1FAB0
0x2C2208C ldr s2, [x8, #0x66c] 0x2C1FAB0

FPS Unlock (built-in) replaces each with bl to a 48-byte routine at 0x3C46B00 (result in s0)
or 0x3C46B30 (in s2). It returns min(T+0x18, 1/60), where T+0x18 is the frame step / 60, or
1/60 when the step is not positive. The comparison runs on the float bits, so at 60 fps and below the
value is the original constant bit for bit. The routines use only x16 and x17; the four functions
save x30 in their prologue. Both caves are guarded zero-filled executable padding after the Scarecrow
caves, and each hook checks its original word, so another build or a user mod skips all of FPS Unlock
as before. Dynamic FPS by Dark (built-in) never lowers the step below 1.0 and is unchanged.

Upstream check: nothing in Djihads80/Eglantine, zortos293/Lichii (PRs, issues) or Hookshot's
oot_patches.py touches cloth or these sites, and no open PR uses the caves at 0x3C46B00..0x3C46B5F.
This appends to FPS_UNLOCK_RECORDS like the other FPS Unlock fixes.

Testing

Windows 10, RTX 5080, Ryzen 7 9800X3D, MSVC 14.50.

[patch_manager],[addon_config] unit tests pass on this branch (380 assertions in 23 test cases). New checks: the four hooks and both
routines with FPS Unlock, the game's words with Dynamic FPS, and a wrong original or a non-zero cave
skips all of FPS Unlock.

In game (Kakariko Village, FPS Unlock at about 83-86 fps, debug server and GDB stub):

  • The timing table read live: frame step 0.72-0.76, T[0x168] and T[0x1C0] both 1.0. The original
    cloth step is 0.0167 s; the patched one 0.0120-0.0126 s, the real frame time.
  • GDB breakpoints on the four sites: in 40 stops, 0x2C2208C was hit 22 times and 0x2AB804 18
    times, several times a frame. 0x14632C and 0x2C207A4 did not run in that scene.
  • A/B in the running game: with the patch, clothes and hair sway at the 60 fps pace; after writing the
    original words back at the four sites, they visibly sway faster; with the patch written again they
    are back to normal.

Not tested: scenes that use the other two sites, and 120 fps or above.

ðŸĪ– Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • FPS Unlock now adjusts cloth and wind simulation timing for smoother behavior at higher frame rates. At 60 FPS and below, the original timing is preserved.
  • Documentation
    • Added details about how cloth and wind timing behaves with FPS Unlock, including the existing frame-rate scaling for drifting dust fog.

â€Ķ fps

The cloth update builds its time step as scale * 1/60 at four sites,
without the frame step, so above 60 fps clothes and hair sway too fast
(about 1.4x at 86 fps, 2x at 120 fps). FPS Unlock now returns
min(step / 60, 1/60) there; 60 fps and below keep the original value.

Confirmed live: 0x2C2208C and 0x2AB804 run several times a frame, and
restoring the original bytes at ~86 fps visibly sped cloth up again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The FPS Unlock patch adds cloth timestep routines at four game instruction sites. Tests check that the patch is applied only when enabled and that invalid patch data leaves the NSO unchanged. Documentation describes the timestep calculation and the existing dust fog behavior.

Changes: Cloth timestep patch

Layer / File(s) Summary
Add cloth timestep hooks
src/core/file_sys/patch_manager.cpp, docs/nx2/ocarina-dynamic-fps.md
FPS Unlock registers four cloth timestep call-site patches and two executable-padding routines. The documentation describes the capped timestep calculation and dust fog behavior.
Test cloth timestep patching
src/tests/core/builtin_patches.cpp
Tests check the patched and unpatched states, routine contents, and validation cases that must leave the NSO unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: zortos293, auz466, crueter

Merge Risk: Minimal · up to 3aae1

This change makes cloth and hair sway at real speed when FPS Unlock runs above 60 fps, and leaves behavior unchanged at 60 fps and below. The hooks apply only when the original instructions and zero-filled caves match, so a mismatched build is left unpatched. No concrete defect was established, so no merge-blocking risk remains. Testing was limited to roughly 83–86 fps and two of the four hook sites.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the primary change: cloth and hair sway at real speed when FPS Unlock runs above 60 fps. The raw summary and objectives both describe fixing the fixed 1/60-second cloth step with FPS Uâ€Ķ
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the primary change: cloth and hair sway at real speed when FPS Unlock runs above 60 fps. The raw summary and objectives both describe fixing the fixed 1/60-second cloth step with FPS Unlock hooks at four sites, plus the supporting patch records and tests. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

src/core/file_sys/patch_manager.cpp

Cppcheck timed out; analysis of this file is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dec09bc7-e4cc-4cd3-85cb-55de45e52a54
Commits

Reviewing files that changed from the base of the PR and between 58e418d and 3aae14b.

Files selected for processing: 3

  • docs/nx2/ocarina-dynamic-fps.md
  • src/core/file_sys/patch_manager.cpp
  • src/tests/core/builtin_patches.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

conongnang added a commit to conongnang/Lichii that referenced this pull request Nov 15, 2026
â€Ķ and cloth speed

Ports zortos293/Lichii zortos293#1743 (movie frame count by the step), zortos293#1745 (Scarecrow's Song
recording lengths) and open PR zortos293#1793 (cloth and hair sway at real speed above 60 fps).
Routines that branch back into the game are marked fixed; the cloth leaf routines can
move if a mod takes their cave. Docs carry the sound feed at 0x3C462E0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atmanli added a commit to atmanli/Lichii that referenced this pull request Nov 15, 2026
@capy-ai
capy-ai Bot merged commit f440923 into zortos293:nx2 Nov 15, 2026
4 checks passed
JalenJaceX2 pushed a commit to JalenJaceX2/duckbuds that referenced this pull request Nov 15, 2026
@atk3001
atk3001 deleted the fix/oot-cloth-speed-above-60 branch November 15, 2026 14:08
Darkfiredoom added a commit to Darkfiredoom/PhoenixEmu that referenced this pull request Nov 18, 2026
Frizti added a commit to Frizti/Fritchii that referenced this pull request Nov 18, 2026
Port of zortos293/Lichii zortos293#1793 (cloth and hair at real speed under FPS Unlock), adapted
to Fritchii's high refresh mode. The cloth update (clothes, hair, the wind action's
phase) builds its time step as scale * 1/60 without the frame step, so above 60 fps
every frame still simulates 1/60 s and cloth sways too fast (twice at 120 fps).

The four 1/60 loads (main+0x14632C, 0x2AB804, 0x2C207A4, 0x2C2208C) each branch to
their own stub (0x3C46830, 0x3C46890, 0x3C468F0, 0x3C46950) that returns
min(step / 60, 1/60) in the high refresh mode (1/60 when not positive, so a step of 1
and more gives the game's constant exactly) and runs the game's own load in Dark's
mode. Plain branches instead of bl (x30 untouched), x16/x17 saved.

Credit: zortos293/Lichii PR zortos293#1793 (atk3001).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frizti added a commit to Frizti/Fritchii that referenced this pull request Nov 18, 2026
â€Ķs293#1679 zortos293#1743 zortos293#1745 zortos293#1793 as 'High refresh fixes (built-in)')

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant