fix(fps): the battle music stops after a fight above a 60 fps cap #1224

Merged
HumanBean merged 5 commits from CraftyCorvid/Longshot:fix/bgm-high-fps into main 2026-11-16 23:44:57 +00:00
Contributor

Type: fix · Risk: low · Tested on: Linux, RTX 5090 · Needs: Windows, any GPU (a build and a fight at a cap above 60)

Why

With a Frame rate cap above 60, the battle music often keeps playing after a fight is over: it follows you into other
areas and only a reload stops it, until the next fight. Sometimes it instead stays at the lower volume it had while you
walked away from the enemy. Fixes #112. See #414 (the same battle music report, beside other high-fps sound issues) and
https://git.notrexed.dev/Hookshot/Hookshot/issues/2961.

The cause: the game marks each change to the fight (it started, it ended, the enemy's distance changed the volume) with a
flag it sets for a single frame. Since #2470 the music manager runs at most 60 times a second above a 60 cap, so at 120 fps
it sees about half of those flags, and a quarter at 240. When it misses the "fight over" one, the battle music never stops.

How to reproduce

Seen on: Linux (CachyOS), RTX 5090, NVIDIA 620.70
Settings and switches: Frame rate cap 240 (the game ran at about 120 fps), defaults otherwise
Steps: start a fight (the battle music comes in), then end it by beating the enemy or walking away; repeat a few times
Expected: the battle music stops at each fight's end
Actual: at some ends (about half at 120 fps) it keeps playing until the next fight or a reload; once it stayed at a
lower volume

What changed

The music manager now gets every one-frame change flag, even on frames where the 60 Hz limit holds it back: on those frames
the sound job's gate saves the flags, and the music manager's next update handles them. It also counts a whole 60 Hz step
on each update instead of the frame's own fraction of one, so its own timers keep real time.

  • Change flags: the battle manager's flag byte ([[0x84c9dda0]]+0x4898: bit 5 the battle music's name, bit 1 its distance
    volume, bits 2 and 6) is read by the music manager's update f_83373400 (game::Bgm), which runs inside the sound job
    f_80435300. hos_oot_sound_gate (host/oot_high_fps.c) ORs the byte into a latch on every phase of a frame it holds;
    the update's head takes the latch (hos_oot_bgm_begin) and its four reads of the byte get it (hos_oot_bgm_flags),
    hooked by patch_bgm_flags in nx2/oot_patches.py. A flag the update saw on a frame it ran is not latched, so none is
    handled twice (bit 6 counts down). At a cap of 60 the gate holds no frame and nothing changes.
  • Clock: the update read the frame step and seconds from the game's time object itself (+16, +24), so at 60 Hz with the
    frame's own time its clock ran at 60 / fps of real time (0.56 measured at 120 fps): stop delays, fades, the rest counter
    and the time-of-day property at half speed at 120. Its two loads now go through hos_oot_sound_step and the new
    hos_oot_sound_seconds (patch_bgm_time): a whole step and that step's seconds while the gate holds the job.
  • host/oot_high_fps.h: the why, and oot_sound_seconds. Both patches warn when the update is not found once.

Measurements

Verdict: fixed: every one-frame change flag reaches the music manager (30 of 72 were lost in the check before), its
clock keeps real time (0.576 of it before), and in a played session at a cap of 240 every fight end stopped the battle
music (one of four was lost before).

Baseline: the in-game "before" runs are on base 71b1edd8 (main as of nightly-351) and on this branch's first fix alone
(5576d723, for the played session); host/oot_high_fps.* and nx2/oot_patches.py there are the same as on main
ac778751, so main has the same behaviour. The game-free check is main against this PR.
Hardware: CachyOS Linux 7.3.4, RTX 5090, NVIDIA 620.70, Ryzen 7 9800X3D, 62 GB
Scene: clock: Link's house (Kokiri Forest, child), headless, caps 60 / 120 / 240; played: a dungeon (area music
BGM_Dungeon), windowed, cap 240 (about 120 fps)
Method: clock: the music manager found in guest memory by its vtable through the control bridge, its one-second
accumulator and rest counter read 30 s apart. Played: fights started and ended by hand while a watcher read the game's
memory 2,800 times a second (the flag byte, the battle state and the music's properties), nothing written.
How to reproduce: python -I -B tests/test_high_fps_fixes.py; in the game, a cap of 120 or 240, a few fights ended by
beating the enemy or walking away

Before: main @ ac778751 After: this PR @ 065f5121
one-frame change flags handled once (test, 120 / 240 / cap 60) 42 of 72 72 of 72
music manager's clock (test, step 0.5) 0.5000 of the real steps 1.0
music manager's clock in game, cap 120 / 240 0.576 / 0.551 (117.5 fps both) 1.000 / 1.000 (114.3 / 107.6 fps)
music manager's clock in game, cap 60 not run 0.999 (60.2 fps)
fight ends that stopped the battle music (played, cap 240) 3 of 4 3 of 3
$ python -I -B tests/test_high_fps_fixes.py   (main's host/oot_high_fps.* and nx2/oot_patches.py)
AssertionError: 0.5 != 1.0 within 0.01 delta (0.5 difference) : music manager clock at a step of 0.5: 0.5000 of the real steps
AssertionError: ... 30 of 72 one-frame flags not handled once:
bit 5 set on frame 0 at a step of 0.5: handled 0 times
...
FAILED (failures=2)

$ python -I -B tests/test_high_fps_fixes.py   (this PR)
Ran 5 tests in 0.127s
OK

The played session before the fix (watcher log, ms from its start; 97e464b9 is the music's battle BGM property):

125846.5 ms  flags 0xa7 battle 0 name ''  props 97e464b9='BGM_EnemyBattle' status='Battle'   <- the fight ends: flags for one frame, the music manager not run
125854.7 ms  flags 0x00 battle 0 name ''  props 97e464b9='BGM_EnemyBattle' status='Normal'   <- it runs a frame later: the flags are gone, the battle music plays on
147216.0 ms  flags 0xa7 battle 1 name 'BGM_EnemyBattle' ...                                 <- until the next fight

After:

171707.1 ms  flags 0xa7 battle 0 name ''  battle-bgm prop 'BGM_EnemyBattle' status 'Battle'  <- the same case: not run on the flags' frame
171715.5 ms  flags 0x00 battle 0 name ''  battle-bgm prop '' status 'Normal'                 <- the next run gets the held flags: the battle music stops

Clock, from the probe's log:

before, cap 120: bgm clock: 17.30 BGM seconds in 30.01 s of wall time: 0.576 of real time
before, cap 240: bgm clock: 16.54 BGM seconds in 30.01 s of wall time: 0.551 of real time
after,  cap 60:  bgm clock: 30.00 BGM seconds in 30.02 s of wall time: 0.999 of real time
after,  cap 120: bgm clock: 30.02 BGM seconds in 30.01 s of wall time: 1.000 of real time
after,  cap 240: bgm clock: 30.02 BGM seconds in 30.01 s of wall time: 1.000 of real time
[hos ModuleSystemWorker1] oot: sound job ran 314 of the last 600 frames (step 0.536, held to 60 Hz)
oot_patches: the music manager's whole step above 60 fps in code_045.c
oot_patches: the music manager's change flags kept above 60 fps in code_045.c

Flags and settings

None.

Testing

Tested: Linux (CachyOS), RTX 5090, NVIDIA 620.70: python -I -B tests/test_high_fps_fixes.py fails on main (2 of
5) and passes here; it also fails with the latch removed (30 of 72 lost) and with flags latched on frames the update runs
(42 of 72 handled twice). The game built as a pack over base 71b1edd8 (both patches applied once, no warning); the clock
runs above at caps 60, 120 and 240; a played session at a cap of 240 (about 120 fps) with fights ended by beating the
enemy and by walking away, the music stopping each time by ear and in the watcher's log. host/oot_high_fps.c
syntax-checked with -Wall -Wextra for Windows (x86_64-w64-mingw32-gcc) and Linux (gcc, clang): no warnings, as on main.
python -I -B tests/run_all.py: 594 passed, 16 failed, 83 skipped; the same 16 fail on main on this PC (no zstandard or
Vulkan headers here): test_linux_update, test_make_game_cache, test_crt_options, test_bug_report_defaults,
test_dlss_feature_size, test_failed_compile_keeps_objects, test_guest_imported, test_lift_lookups, test_linux_preflight,
test_missing_nup, test_mods_size_table, test_pending_guest_import, test_run_all_changed, test_walk_key, test_walk,
test_vk_occlusion_queries.

Not tested: a Windows build with llvm-mingw and a Windows run (this PC is Linux); AMD and Intel GPUs (the change is
CPU-side game logic, no GPU path); a game really at 240 fps (this PC reached about 120 under the 240 cap); bit 6 of the
flags (it never fired in the played session).

Must be tested:

  • Windows, any GPU: build, then at a Frame rate cap of 120 or 240 start and end a few fights (beat the enemy, walk away),
    expecting the battle music to stop every time and not to stay at a lower volume (by hand, or Test Farm: @Beanstalk
    windows, a build of this PR and a few fights at a 120 cap, the battle music stopping after each).

Risks

What could break: the music manager above a 60 cap. A flag latched on a held frame is handled one update (one 60 Hz
frame) late; one bit set on two held frames between two updates is handled once (only bit 6 counts, and it did not fire
in play). The latch reads the byte at the address the music manager last read; it is the battle manager's, which lives as
long as the game. At a cap of 60 the gate never holds a frame, so the game runs as before.

Turning it off: revert the commits.

Compatibility: the lifted game changes (two functions' text), so the game is built again; saves,
longshot_options.ini and the shader and pipeline caches are untouched.

Issues

Fixes #112
See #414

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux built and run; Windows only
    syntax-checked with x86_64-w64-mingw32-gcc: needs a Windows build, see Must be tested.)
  • Docs updated.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Linux, RTX 5090 · **Needs:** Windows, any GPU (a build and a fight at a cap above 60) ## Why With a Frame rate cap above 60, the battle music often keeps playing after a fight is over: it follows you into other areas and only a reload stops it, until the next fight. Sometimes it instead stays at the lower volume it had while you walked away from the enemy. Fixes #112. See #414 (the same battle music report, beside other high-fps sound issues) and https://git.notrexed.dev/Hookshot/Hookshot/issues/2961. The cause: the game marks each change to the fight (it started, it ended, the enemy's distance changed the volume) with a flag it sets for a single frame. Since #2470 the music manager runs at most 60 times a second above a 60 cap, so at 120 fps it sees about half of those flags, and a quarter at 240. When it misses the "fight over" one, the battle music never stops. ## How to reproduce **Seen on:** Linux (CachyOS), RTX 5090, NVIDIA 620.70 **Settings and switches:** Frame rate cap 240 (the game ran at about 120 fps), defaults otherwise **Steps:** start a fight (the battle music comes in), then end it by beating the enemy or walking away; repeat a few times **Expected:** the battle music stops at each fight's end **Actual:** at some ends (about half at 120 fps) it keeps playing until the next fight or a reload; once it stayed at a lower volume ## What changed The music manager now gets every one-frame change flag, even on frames where the 60 Hz limit holds it back: on those frames the sound job's gate saves the flags, and the music manager's next update handles them. It also counts a whole 60 Hz step on each update instead of the frame's own fraction of one, so its own timers keep real time. - Change flags: the battle manager's flag byte (`[[0x84c9dda0]]+0x4898`: bit 5 the battle music's name, bit 1 its distance volume, bits 2 and 6) is read by the music manager's update `f_83373400` (game::Bgm), which runs inside the sound job `f_80435300`. `hos_oot_sound_gate` (`host/oot_high_fps.c`) ORs the byte into a latch on every phase of a frame it holds; the update's head takes the latch (`hos_oot_bgm_begin`) and its four reads of the byte get it (`hos_oot_bgm_flags`), hooked by `patch_bgm_flags` in `nx2/oot_patches.py`. A flag the update saw on a frame it ran is not latched, so none is handled twice (bit 6 counts down). At a cap of 60 the gate holds no frame and nothing changes. - Clock: the update read the frame step and seconds from the game's time object itself (+16, +24), so at 60 Hz with the frame's own time its clock ran at 60 / fps of real time (0.56 measured at 120 fps): stop delays, fades, the rest counter and the time-of-day property at half speed at 120. Its two loads now go through `hos_oot_sound_step` and the new `hos_oot_sound_seconds` (`patch_bgm_time`): a whole step and that step's seconds while the gate holds the job. - `host/oot_high_fps.h`: the why, and `oot_sound_seconds`. Both patches warn when the update is not found once. ## Measurements **Verdict:** fixed: every one-frame change flag reaches the music manager (30 of 72 were lost in the check before), its clock keeps real time (0.576 of it before), and in a played session at a cap of 240 every fight end stopped the battle music (one of four was lost before). Baseline: the in-game "before" runs are on base 71b1edd8 (main as of nightly-351) and on this branch's first fix alone (5576d723, for the played session); `host/oot_high_fps.*` and `nx2/oot_patches.py` there are the same as on main ac778751, so main has the same behaviour. The game-free check is main against this PR. Hardware: CachyOS Linux 7.3.4, RTX 5090, NVIDIA 620.70, Ryzen 7 9800X3D, 62 GB Scene: clock: Link's house (Kokiri Forest, child), headless, caps 60 / 120 / 240; played: a dungeon (area music BGM_Dungeon), windowed, cap 240 (about 120 fps) Method: clock: the music manager found in guest memory by its vtable through the control bridge, its one-second accumulator and rest counter read 30 s apart. Played: fights started and ended by hand while a watcher read the game's memory 2,800 times a second (the flag byte, the battle state and the music's properties), nothing written. How to reproduce: `python -I -B tests/test_high_fps_fixes.py`; in the game, a cap of 120 or 240, a few fights ended by beating the enemy or walking away | | Before: main @ ac778751 | After: this PR @ 065f5121 | |---|---|---| | one-frame change flags handled once (test, 120 / 240 / cap 60) | 42 of 72 | 72 of 72 | | music manager's clock (test, step 0.5) | 0.5000 of the real steps | 1.0 | | music manager's clock in game, cap 120 / 240 | 0.576 / 0.551 (117.5 fps both) | 1.000 / 1.000 (114.3 / 107.6 fps) | | music manager's clock in game, cap 60 | not run | 0.999 (60.2 fps) | | fight ends that stopped the battle music (played, cap 240) | 3 of 4 | 3 of 3 | ``` $ python -I -B tests/test_high_fps_fixes.py (main's host/oot_high_fps.* and nx2/oot_patches.py) AssertionError: 0.5 != 1.0 within 0.01 delta (0.5 difference) : music manager clock at a step of 0.5: 0.5000 of the real steps AssertionError: ... 30 of 72 one-frame flags not handled once: bit 5 set on frame 0 at a step of 0.5: handled 0 times ... FAILED (failures=2) $ python -I -B tests/test_high_fps_fixes.py (this PR) Ran 5 tests in 0.127s OK ``` The played session before the fix (watcher log, ms from its start; `97e464b9` is the music's battle BGM property): ``` 125846.5 ms flags 0xa7 battle 0 name '' props 97e464b9='BGM_EnemyBattle' status='Battle' <- the fight ends: flags for one frame, the music manager not run 125854.7 ms flags 0x00 battle 0 name '' props 97e464b9='BGM_EnemyBattle' status='Normal' <- it runs a frame later: the flags are gone, the battle music plays on 147216.0 ms flags 0xa7 battle 1 name 'BGM_EnemyBattle' ... <- until the next fight ``` After: ``` 171707.1 ms flags 0xa7 battle 0 name '' battle-bgm prop 'BGM_EnemyBattle' status 'Battle' <- the same case: not run on the flags' frame 171715.5 ms flags 0x00 battle 0 name '' battle-bgm prop '' status 'Normal' <- the next run gets the held flags: the battle music stops ``` Clock, from the probe's log: ``` before, cap 120: bgm clock: 17.30 BGM seconds in 30.01 s of wall time: 0.576 of real time before, cap 240: bgm clock: 16.54 BGM seconds in 30.01 s of wall time: 0.551 of real time after, cap 60: bgm clock: 30.00 BGM seconds in 30.02 s of wall time: 0.999 of real time after, cap 120: bgm clock: 30.02 BGM seconds in 30.01 s of wall time: 1.000 of real time after, cap 240: bgm clock: 30.02 BGM seconds in 30.01 s of wall time: 1.000 of real time [hos ModuleSystemWorker1] oot: sound job ran 314 of the last 600 frames (step 0.536, held to 60 Hz) oot_patches: the music manager's whole step above 60 fps in code_045.c oot_patches: the music manager's change flags kept above 60 fps in code_045.c ``` ### Flags and settings None. ## Testing **Tested:** Linux (CachyOS), RTX 5090, NVIDIA 620.70: `python -I -B tests/test_high_fps_fixes.py` fails on main (2 of 5) and passes here; it also fails with the latch removed (30 of 72 lost) and with flags latched on frames the update runs (42 of 72 handled twice). The game built as a pack over base 71b1edd8 (both patches applied once, no warning); the clock runs above at caps 60, 120 and 240; a played session at a cap of 240 (about 120 fps) with fights ended by beating the enemy and by walking away, the music stopping each time by ear and in the watcher's log. `host/oot_high_fps.c` syntax-checked with `-Wall -Wextra` for Windows (x86_64-w64-mingw32-gcc) and Linux (gcc, clang): no warnings, as on main. `python -I -B tests/run_all.py`: 594 passed, 16 failed, 83 skipped; the same 16 fail on main on this PC (no zstandard or Vulkan headers here): test_linux_update, test_make_game_cache, test_crt_options, test_bug_report_defaults, test_dlss_feature_size, test_failed_compile_keeps_objects, test_guest_imported, test_lift_lookups, test_linux_preflight, test_missing_nup, test_mods_size_table, test_pending_guest_import, test_run_all_changed, test_walk_key, test_walk, test_vk_occlusion_queries. **Not tested:** a Windows build with llvm-mingw and a Windows run (this PC is Linux); AMD and Intel GPUs (the change is CPU-side game logic, no GPU path); a game really at 240 fps (this PC reached about 120 under the 240 cap); bit 6 of the flags (it never fired in the played session). **Must be tested:** - Windows, any GPU: build, then at a Frame rate cap of 120 or 240 start and end a few fights (beat the enemy, walk away), expecting the battle music to stop every time and not to stay at a lower volume (by hand, or Test Farm: @Beanstalk windows, a build of this PR and a few fights at a 120 cap, the battle music stopping after each). ## Risks **What could break:** the music manager above a 60 cap. A flag latched on a held frame is handled one update (one 60 Hz frame) late; one bit set on two held frames between two updates is handled once (only bit 6 counts, and it did not fire in play). The latch reads the byte at the address the music manager last read; it is the battle manager's, which lives as long as the game. At a cap of 60 the gate never holds a frame, so the game runs as before. **Turning it off:** revert the commits. **Compatibility:** the lifted game changes (two functions' text), so the game is built again; saves, `longshot_options.ini` and the shader and pipeline caches are untouched. ## Issues Fixes #112 See #414 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux built and run; Windows only syntax-checked with x86_64-w64-mingw32-gcc: needs a Windows build, see Must be tested.) - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The music manager's update (f_83373400, game::Bgm) runs inside the sound job, which a Frame rate cap above 60 holds to 60 Hz,
but it reads the frame step and the frame's seconds from the game's time object itself. The check runs its two loads, as the
lift writes them, through oot_patches.patch_file, compiles them with the host's hos_oot_sound_* functions cut from
host/oot_high_fps.c, and calls the update on the frames the gate runs it: the steps and seconds it counts against the real
ones at 120, 240 and 60 fps, on a slow frame, and at a cap of 60.

On main it fails: the update counts 0.5 of the real steps at 120 fps (the frame's own step on the 60 updates a second).

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Above a 60 fps cap the sound job runs at 60 Hz (#2470), and the music manager's update (f_83373400, game::Bgm) runs inside
it, but it read the frame step (+16) and the frame's seconds (+24) from the game's time object itself rather than the whole
step the gate hands the sound engine. Held to 60 Hz and handed each frame's own time, its clock ran at 60 / fps of the real
one: measured in the game at a cap of 120, its one-second counter went up 0.56 a second of wall time. Its stop delays, fades,
the rest counter behind the Resting status and the time-of-day property all ran at half speed at 120 and a quarter at 240.

Its two loads now go through hos_oot_sound_step and hos_oot_sound_seconds (nx2/oot_patches.py patch_bgm_time): while the
gate holds the job to whole steps, a step of 1 and that step's seconds (the frame's seconds over its step); otherwise the
game's own values, so a cap of 60, frames slower than 60 fps and uncapped play below 60 read what they did.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The battle manager sets a byte of change flags ([[0x84c9dda0]]+0x4898) for one game frame, and the music manager's update
(f_83373400) syncs a property for each bit it finds set: the battle music's name (bit 5), its distance volume (bit 1), and
two more (bits 2 and 6, the last running a count down). Held to 60 Hz with the sound job, the update saw a frame's flags only
on the frames it ran.

The check compiles host/oot_high_fps.c whole with stand-ins for guest memory and its lock, runs the update's four flag reads,
as the lift writes them, through oot_patches.patch_file, and plays frames through the gate with one bit set for one frame:
each must be handled once, at 120 and 240 fps and at a cap of 60. Before the fix, 30 of the 72 are handled 0 times (half
at 120 fps, three in four at 240, none at a cap of 60).

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The battle manager sets a byte of change flags ([[0x84c9dda0]]+0x4898) for one game frame, and the music manager's update
(f_83373400) syncs a property for each bit it finds set: bit 5 copies the battle music's name (emptied when the fight ends)
into the property the BGM program plays it by, bit 1 the volume that falls with the distance to the enemy. The update runs in
the sound job, which a cap above 60 holds to 60 Hz (#2470), so it saw only the flags of the frames it ran. Watched in a game
at a cap of 120: the end of a fight set the byte to 0xa7 for one frame (8-9 ms); when the update ran on that frame the
name property emptied and the music stopped, and when it ran on the next frame instead, the status went to Normal but the
property kept BGM_EnemyBattle and the battle music played on until the next fight (issues #112, #414). A lost bit 1 left the
music at a lower volume.

On every phase of a frame the gate holds the job, it now ORs the byte, as the update would have read it then, into a latch,
and the update's head takes the latch for its run; its four reads of the byte get those bits with it (nx2/oot_patches.py
patch_bgm_flags, host hos_oot_bgm_begin and hos_oot_bgm_flags). A bit the update saw on a frame it ran is not latched, so
none is handled twice (bit 6 runs a count down). At a cap of 60 the gate holds no frame: nothing changes.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(tested): the music manager's clock and the battle music above a 60 fps cap, before and after
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 5s
beanstalk/approval approved by llun, mooki (double-reviewed)
beanstalk/windows 1/1 pass
065f512141
Three runs on an RTX 5090 (Linux): the music manager's clock against real time on the base and with the whole-step fix,
and a played session at a cap of 240 with the change flags watched, before and after keeping them.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: RTX 5090, NVIDIA 620.70, Linux (CachyOS): played in a dungeon at a Frame rate cap of 240 (about 120 fps), fights ended by beating the enemy and by walking away: the battle music stopped every time (3 of 3; before, 1 of 4 fight ends left it playing until the next fight, once at a lower volume). The game's memory was watched meanwhile: the one-frame change flags the music manager had missed now reach it on its next run (8.4 ms later). Headless, Link's house: the music manager's clock 1.000 of real time at caps 120 and 240 (0.576 / 0.551 before), 0.999 at a cap of 60.

Tested in game: RTX 5090, NVIDIA 620.70, Linux (CachyOS): played in a dungeon at a Frame rate cap of 240 (about 120 fps), fights ended by beating the enemy and by walking away: the battle music stopped every time (3 of 3; before, 1 of 4 fight ends left it playing until the next fight, once at a lower volume). The game's memory was watched meanwhile: the one-frame change flags the music manager had missed now reach it on its next run (8.4 ms later). Headless, Link's house: the music manager's clock 1.000 of real time at caps 120 and 240 (0.576 / 0.551 before), 0.999 at a cap of 60.
Author
Contributor

@Beanstalk windows, any GPU: build this PR (it needs a Windows llvm-mingw build; I could only build and play it on Linux), set the Frame rate cap to 120, then start and end a few fights (beat the enemy, and walk away from one), expecting the battle music to stop after each fight and not to stay at a lower volume. The music manager's log line to look for: oot_patches: the music manager's change flags kept above 60 fps in code_045.c in the build, and no oot_patches: WARNING about the music manager.

@Beanstalk windows, any GPU: build this PR (it needs a Windows llvm-mingw build; I could only build and play it on Linux), set the Frame rate cap to 120, then start and end a few fights (beat the enemy, and walk away from one), expecting the battle music to stop after each fight and not to stay at a lower volume. The music manager's log line to look for: `oot_patches: the music manager's change flags kept above 60 fps in code_045.c` in the build, and no `oot_patches: WARNING` about the music manager.
Member

@CraftyCorvid only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it.

@CraftyCorvid only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it.
Member

@llun approval of 065f512 recorded. This diff touches sensitive paths, so a second member of BigBeans must approve it too.

@llun approval of `065f512` recorded. This diff touches sensitive paths, so a second member of `BigBeans` must approve it too.
Member

Beanstalk test farm

Commit 065f512 · tier double-reviewed · approved by llun (👍 on CraftyCorvid's request), mooki · dashboard

What will be tested · AI plan (gpt-6.1-terra)

On Windows, timed lift builds compare build times, followed by a short Dodongo's Cavern gameplay smoke test at 60 and 120 FPS caps. The cap comparison exercises the changed high-FPS path and its 60 FPS control; the gameplay runs take about 13 minutes per tester, apart from builds. Crashes, failed map transitions, or a substantial frame-time regression fail the plan. The farm cannot verify battle-music playback, fight outcomes, or the music clock, so the reported audio fix remains unverified by this plan.

  • Where: windows (1 report).
  • Matrix: 2 cells, each on main and the PR: frame_rate_cap 0 or 2.
  • dodongo-smoke: from a new save, then teleport to Dodongo's Cavern, move the stick, press buttons, measure cavern for 20 s (after 5 s warm-up); 1 run on each side for each of 2 cells (1 game start a run).
  • Build times: main and the PR each built 2 times, alternating, each whole in a fresh folder: the lift again (no kept lift, main's compiled objects kept); every stage timed (shader preparation is not), and the lifted C compared.
  • Measured: crashes, frame times, stutters and hitches, draws and frame rate, load times.
  • The PR fails if: it crashes; or frame time (p99) is more than 25% above main.
  • Time: about 14 min of game runs per tester (2 game starts), plus the two builds and 4 timed builds (about 80 min).

Done (started 20:42 UTC, last report 23:00 UTC). Comment @Beanstalk to run it again.

This diff touches sensitive paths, so it needs two members of BigBeans: nx2/oot_patches.py

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
windows · 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4090, 621.14.0 1/1 1 none 19.9 vs 19.2 (+4%) — pass
Scenario · matrix cell Target Frame p99 (ms) vs main Result
dodongo-smoke · frame_rate_cap=0 windows 19.9 vs 19.2 (+4%) pass
dodongo-smoke · frame_rate_cap=2 windows 14.2 vs 13.5 (+6%) pass

Measurements · windows

Verdict: pass on windows (1/1 report): no rule failed and no PR run crashed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4090, 621.14.0 AMD Ryzen 7 7700X 8-Core Processor, 32 GB RAM
Scene: dodongo-smoke, from a new save; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); dodongo-smoke: 1 game start a side, cavern 20 s after 5 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ ac77875 After: this PR @ 065f512
dodongo-smoke · frame_rate_cap=0 · cavern · frame time (p99) (ms) 19.2 19.9 (+4%)
dodongo-smoke · frame_rate_cap=2 · cavern · frame time (p99) (ms) 13.5 14.2 (+6%)

Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))

Before: main @ ac77875 After: this PR @ 065f512
lift · whole build (s) 588.8 586.6 (−0%)
lift · read (s) 371.2 354.6 (−4%)
lift · lift (s) 86.4 93.5 (+8%)
lift · compile (s) 57.3 77.1 (+35%)
lift · finish (s) 57.8 58.6 (+1%)
lift · lifted C main's differs

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (frame time (p99)) Helps / doesn't help / untested
frame_rate_cap menu setting 0, 2 main's default the PR's default dodongo-smoke, the PR at 0 → at 2: 19.9 → 14.2 (−28%) helps
Markdown for the PR description
## Measurements

**Verdict:** pass on windows (1/1 report): no rule failed and no PR run crashed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4090, 621.14.0` `AMD Ryzen 7 7700X 8-Core Processor, 32 GB RAM`  
Scene: dodongo-smoke, from a new save; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); dodongo-smoke: 1 game start a side, cavern 20 s after 5 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ ac77875 | After: this PR @ 065f512 |
|---|---|---|
| dodongo-smoke · `frame_rate_cap=0` · cavern · frame time (p99) (ms) | 19.2 | 19.9 (+4%) |
| dodongo-smoke · `frame_rate_cap=2` · cavern · frame time (p99) (ms) | 13.5 | 14.2 (+6%) |

Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))

| | Before: main @ ac77875 | After: this PR @ 065f512 |
|---|---|---|
| lift · whole build (s) | 588.8 | 586.6 (−0%) |
| lift · read (s) | 371.2 | 354.6 (−4%) |
| lift · lift (s) | 86.4 | 93.5 (+8%) |
| lift · compile (s) | 57.3 | 77.1 (+35%) |
| lift · finish (s) | 57.8 | 58.6 (+1%) |
| lift · lifted C | main's | differs |

### Flags and settings

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `frame_rate_cap` | menu setting | `0`, `2` | main's default | the PR's default | dodongo-smoke, the PR at 0 → at 2: 19.9 → 14.2 (−28%) | helps |
<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `065f512` · tier **double-reviewed** · approved by llun (👍 on CraftyCorvid's request), mooki · [dashboard](https://beanstalk.magicbean.dev/prs/1224) **What will be tested** · AI plan (`gpt-6.1-terra`) On Windows, timed lift builds compare build times, followed by a short Dodongo's Cavern gameplay smoke test at 60 and 120 FPS caps. The cap comparison exercises the changed high-FPS path and its 60 FPS control; the gameplay runs take about 13 minutes per tester, apart from builds. Crashes, failed map transitions, or a substantial frame-time regression fail the plan. The farm cannot verify battle-music playback, fight outcomes, or the music clock, so the reported audio fix remains unverified by this plan. - **Where:** windows (1 report). - **Matrix:** 2 cells, each on main and the PR: frame_rate_cap `0` or `2`. - **dodongo-smoke:** from a new save, then teleport to Dodongo's Cavern, move the stick, press buttons, measure cavern for 20 s (after 5 s warm-up); 1 run on each side for each of 2 cells (1 game start a run). - **Build times:** main and the PR each built 2 times, alternating, each whole in a fresh folder: the lift again (no kept lift, main's compiled objects kept); every stage timed (shader preparation is not), and the lifted C compared. - **Measured:** crashes, frame times, stutters and hitches, draws and frame rate, load times. - **The PR fails if:** it crashes; or frame time (p99) is more than 25% above main. - **Time:** about 14 min of game runs per tester (2 game starts), plus the two builds and 4 timed builds (about 80 min). Done (started 20:42 UTC, last report 23:00 UTC). Comment `@Beanstalk` to run it again. This diff touches sensitive paths, so it needs two members of `BigBeans`: `nx2/oot_patches.py` | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | windows · 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4090, 621.14.0` | 1/1 [1](https://beanstalk.magicbean.dev/reports/rp_d5896850f4095256) | none | 19.9 vs 19.2 (+4%) | — | pass | | Scenario · matrix cell | Target | Frame p99 (ms) vs main | Result | | --- | --- | --- | --- | | dodongo-smoke · `frame_rate_cap=0` | windows | 19.9 vs 19.2 (+4%) | pass | | dodongo-smoke · `frame_rate_cap=2` | windows | 14.2 vs 13.5 (+6%) | pass | #### Measurements · windows **Verdict:** pass on windows (1/1 report): no rule failed and no PR run crashed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4090, 621.14.0` `AMD Ryzen 7 7700X 8-Core Processor, 32 GB RAM` Scene: dodongo-smoke, from a new save; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); dodongo-smoke: 1 game start a side, cavern 20 s after 5 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ ac77875 | After: this PR @ 065f512 | |---|---|---| | dodongo-smoke · `frame_rate_cap=0` · cavern · frame time (p99) (ms) | 19.2 | 19.9 (+4%) | | dodongo-smoke · `frame_rate_cap=2` · cavern · frame time (p99) (ms) | 13.5 | 14.2 (+6%) | Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept)) | | Before: main @ ac77875 | After: this PR @ 065f512 | |---|---|---| | lift · whole build (s) | 588.8 | 586.6 (−0%) | | lift · read (s) | 371.2 | 354.6 (−4%) | | lift · lift (s) | 86.4 | 93.5 (+8%) | | lift · compile (s) | 57.3 | 77.1 (+35%) | | lift · finish (s) | 57.8 | 58.6 (+1%) | | lift · lifted C | main's | differs | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `frame_rate_cap` | menu setting | `0`, `2` | main's default | the PR's default | dodongo-smoke, the PR at 0 → at 2: 19.9 → 14.2 (−28%) | helps | <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** pass on windows (1/1 report): no rule failed and no PR run crashed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4090, 621.14.0` `AMD Ryzen 7 7700X 8-Core Processor, 32 GB RAM` Scene: dodongo-smoke, from a new save; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); dodongo-smoke: 1 game start a side, cavern 20 s after 5 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ ac77875 | After: this PR @ 065f512 | |---|---|---| | dodongo-smoke · `frame_rate_cap=0` · cavern · frame time (p99) (ms) | 19.2 | 19.9 (+4%) | | dodongo-smoke · `frame_rate_cap=2` · cavern · frame time (p99) (ms) | 13.5 | 14.2 (+6%) | Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept)) | | Before: main @ ac77875 | After: this PR @ 065f512 | |---|---|---| | lift · whole build (s) | 588.8 | 586.6 (−0%) | | lift · read (s) | 371.2 | 354.6 (−4%) | | lift · lift (s) | 86.4 | 93.5 (+8%) | | lift · compile (s) | 57.3 | 77.1 (+35%) | | lift · finish (s) | 57.8 | 58.6 (+1%) | | lift · lifted C | main's | differs | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `frame_rate_cap` | menu setting | `0`, `2` | main's default | the PR's default | dodongo-smoke, the PR at 0 → at 2: 19.9 → 14.2 (−28%) | helps | ``` </details>
mooki approved these changes 2026-11-16 20:41:22 +00:00
Member

@Beanstalk wrote in #1224 (comment):

Beanstalk test farm

Commit 065f512 · tier untrusted · approved by llun (👍 on CraftyCorvid's request) · dashboard

This diff touches sensitive paths, so it needs two members of BigBeans: nx2/oot_patches.py

A member of BigBeans can review this commit and comment @Beanstalk to test it.

@Beanstalk

@Beanstalk wrote in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1224#issuecomment-37796: > ### [](#beanstalk-test-farm)Beanstalk test farm > Commit `065f512` · tier **untrusted** · approved by llun (:+1: on CraftyCorvid's request) · [dashboard](https://beanstalk.magicbean.dev/prs/1224) > > This diff touches sensitive paths, so it needs two members of `BigBeans`: `nx2/oot_patches.py` > > A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it. @Beanstalk
HumanBean changed title from WIP: fix(fps): the battle music stops after a fight above a 60 fps cap to fix(fps): the battle music stops after a fight above a 60 fps cap 2026-11-16 23:44:31 +00:00
HumanBean deleted branch fix/bgm-high-fps 2026-11-16 23:44:58 +00:00
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 5s
beanstalk/approval approved by llun, mooki (double-reviewed)
beanstalk/windows 1/1 pass
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1224
No description provided.