mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 12:25:56 +00:00
The game thread hands its sound commands to the audio thread in lists: 16, of which 4 are always held, so at most 12 wait in the command ring. The game thread submits at most one per update (1.2.1 main+0x9bd144), the audio thread takes one per 5 ms audio frame (after a list, main+0x883780 goes on past the ring's check). Above about 200 updates a second the ring stays full. The game's guard (main+0x9bcdc4) counts the updates that find the ring of free lists empty and exactly 12 lists in the command ring (0x9bce1c cmp w9, #0xc); the count returns to 0 only when a free list is there. At every multiple of 300 (10 s at 30 fps, 1.25 s at 240) it clears the sound command switch (main+0x2268bfc) and stops every active voice (main+0x226f29c). Only the switch's constructor sets it to 1 (main+0xf31ce8, from the engine's init main+0xf31530), so the game is silent until it is restarted. Measured on 1.2.1 (Linux, RX 6750 XT), same save and scripted input, mix dumped without a device: with fps_limit 60, 144, 180, 200 and 201 the mix has sound; with 205, 210, 220, 230, 239 and 240 it goes silent after the boot logo and stays silent, also at the 130-148 fps of the scene that follows. The guard is read from the code; the switch going to 0 has not been observed in a run. The set audiodrain (TOTK_AUDIO_DRAIN_FIX, audio_drain_fix, on by default) sends the audio thread back to the ring's check after each list, so it takes every queued list in the pass: one site per version (1.2.1 main+0x883780, 1.4.3 main+0x149244), each going to a target the game's own code already branches to in the same way (1.2.1 main+0x883c18, 1.4.3 main+0x149700). The setting is in runtime/cfg.c, totk.ini.example and docs/settings.md. At fps_limit 240, 120 s runs of one build per game version with the set switched, seconds with sound in the mix: on 1.2.1 5 of 118 with the set off and 108 of 118 with it on; on 1.4.3 2 of 118 off and 110 of 119 on. Not run: Windows. Not covered: 1.1.0, whose main we do not have, so its table has no site and it keeps the game's code. Co-Authored-By: Claude <noreply@anthropic.com>