Skip to content

Lock halves: SEND FX P1..P4 and the AMP page's SFX1 / SFX2 p-lock each knob on its own - #28

Closed
twwwy wants to merge 3 commits into
trigcondition:devfrom
twwwy:feat/lock-halves-up
Closed

twwwy wants to merge 3 commits into
trigcondition:devfrom
twwwy:feat/lock-halves-up

Conversation

@twwwy

@twwwy twwwy commented Nov 23, 2026 •

Copy link
Copy Markdown

Closes #29 (draft until the go there).

Topic 3 of the roadmap, trigcondition/sidecar-firmware#66. Rytm mods only, with no host change. It's based on dev and doesn't need #18 / #19. Those only touch the same mod.toml, design.md and sfu_emu.py lines, as text.

Why

Some Rytm parameter words hold two knobs, one in each half:

  • FX words 38..41: SEND FX P1..P4 (two words, a knob a half);
  • sound index 0: the AMP page's SFX1 (hi) and SFX2 (lo).

The live lock array has one word a step. So a p-lock on one knob froze its partner's current value into the step, and clearing the lock cleared both. Turning the partner's base value while such a step played also replaced the locked half until the next trig.

What

The lock word now says which halves are locked, with no mask and no RAM:

  • hi << 8 | lo << 1: both halves (stock's form, so every lock saved before reads the same);
  • hi << 8 | 1: the hi half only;
  • lo << 8 | 3: the lo half only;
  • 0xffff: none.

The file format is stock's: SEND FX types 42..45 (hi) and 46..49 (lo), and type 41 plus its fine slot for SFX1 / SFX2, with 0xff in an unlocked half.

  1. SEND FX P1..P4
    • 0025: the loader merges each lock type into its own half, and the full rebuild writes only the locked halves.
    • 0025: a new detour in the audio interrupt's trig loop (0x40120968) turns a one-half FX 38..41 entry into the locked half merged with the kit's word. That needs the elekloader area now.
    • 0029: the FX set's lock get answers the knob's own half, lock set sets only its half, and a new lock-clear wrapper clears only its half. A base turn writes only its half.
  2. AMP SFX1 / SFX2: the same encoding for sound index 0 on tracks 1..12.
    • 0025: a loader detour for its fine slot (0x400090d8). The rebuild and incremental-save stubs take a voice track's index 0, and the trig-loop detour merges its one-half lock.
    • 0029: the Sound set's lock get / set / clear, through the same helpers.
  3. Base turns keep a one-half lock: after stock's Sound set write, sfu_s_write restores the row's other half when the row still holds what it wrote, as the FX write already does for 38..41.

Each stub.s is regenerated by its mod's build.sh. The design notes are in 0029 design.md sections 12 and 13. The addresses are 1.73's, and 1.74.toml has the 1.74 ones.

On a stock (unmodded) Rytm: a project with one-half SFX1 / SFX2 locks degrades. A hi-only lock comes back with SFX2 locked to 0, and a lo-only lock is dropped when stock saves the file. SEND FX locks are unaffected, since they have a type per half.

Tests

rytm-emu, OS 1.74, DTEMU_STRICT=1, the Makefile's release set. tools/emu/suites.py --full, dev (95886ee) vs this branch:

  • New tests in sfu_emu.py:
    • halves: 10 / 0, and 6 of the 10 fail without this series;
    • amphalves: 13 / 0;
    • ampold: 5 / 0. A stock-saved project loads into the same words, plays the same, and saves back byte for byte.
  • sfu: 333 / 0, against dev's 235 / 0. The difference is the new checks.
  • sfx_emu fx38 now expects 7e01 (the hi half only) for its type-45-only step.
  • Every other suite has the same passes and failures as dev, check by check.
  • Elekloader RAM spare: 13,432 -> 12,228 B (−1,204). 0025 goes from 1,098 to 1,624 B of code and 0029 from 10,126 to 10,808 B, with no new state.
  • Knob latency: 12 tracks of 16ths, knobs turning, the emulator held to 122 M instructions a second (mean / max):
image scene edit open no scene edit
stock 1.74 + Overbridge 32.4 / 63 ms 25.3 / 53 ms
dev 460.5 / 941 ms 26.8 / 48 ms
this branch 460.2 / 941 ms 26.7 / 48 ms
with the performance PR (#25) 30.7 / 53 ms 21.1 / 43 ms
this branch on top of #25 30.7 / 53 ms 21.1 / 43 ms

On top of #25, the CPU busy figure is the same too (0.976 / 0.965), and the elekloader spare goes from 12,704 to 11,496 B. The two branches conflict only in 0025's design.md (two new sections in the same place) and in stub.s, which is regenerated. Whichever lands second, I'll rebase.

The latency pattern has ordinary locks but no one-half ones, so it measures the new trig-loop detour's check on every lock entry (one bit test), not the merge a one-half lock runs. This hasn't been on hardware yet, and the detour in the audio interrupt is what I'd most want checked on a unit.

🤖 Generated with Claude Code

twwwy and others added 3 commits November 23, 2026 23:35
FX words 38..41 hold two SEND FX knobs each (hi / lo half), and the live lock array has one word a step, so
a lock on P1 froze P2's value into the step and a clear cleared both. The lock word now says which halves
are locked (no mask, no RAM): hi << 8 | lo << 1 both (the stock form, every lock saved before),
hi << 8 | 1 the hi half only, lo << 8 | 3 the lo half only, 0xffff none. The file format is unchanged
(types 42..45 hi, 46..49 lo).

- 0025: the loader merges each lock type into its own half (one-half form when the step has one type);
  the full rebuild writes only the locked halves (0xff elsewhere); new detour 0x40120968 (1.74 0x401209d4)
  in the audio interrupt's trig loop, over a trig's lock list: a one-half FX 38..41 entry becomes the
  locked half merged with the trig array's word (the kit's), written back into the entry. Needs the
  elekloader area now (1482 B of code).
- 0029: FX set lock get answers the knob's half (-1 when only the other half is locked), lock set sets
  only its half, and the new +0x44 lock clear wrapper (ptr patch 0x401dcc34, 1.74 hash added) clears only
  its half; a base turn writes only its half into the FX trig array. Design section 2's table renamed to
  P1..P4 with independent halves; section 12.
- Tests: sfu_emu.py TAG halves (new, 10 checks); sfx_emu.py fx38 expects 7e01 (the hi half only) for its
  type-45-only step.

Tests (rytm-emu 1.74, DTEMU_STRICT=1, the Makefile's release set on OS 1.74 with this and the next two
changes): halves 10 / 0; 6 of 10 fail without them. Suites: see the last commit of the series.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alves)

Sound index 0 (SFX1 hi, SFX2 lo) on tracks 1..12 now uses lock-halves' lock-word encoding (hi << 8 | lo << 1 both, the
stock form; hi << 8 | 1 hi only; lo << 8 | 3 lo only; 0xffff none). The file format is stock's: type 41 (hi) + its
0x80 0x80 fine slot (lo), 0xff in an unlocked half.

- 0025: new loader detour sfx_fine 0x400090d8 (same on 1.74), the fine slot of a voice track's index 0: coarse + fine
  both, coarse + 0xff hi only, 0xff + fine lo only (stock drops it); lk_load shared with the FX types. The rebuild
  (0x400092aa) and incremental save (0x40009454) stubs take a voice track's index 0 too; sfx_play_c (0x40120968, 1.74
  0x401209d4) merges a voice track's one-half lock with its trig array word 0.
- 0029: Sound set lock get / set through lk_half / lk_put; new +0x44 clear wrapper sfu_s_lclr (ptr 0x401dcbb8, 1.74
  0x401dce68; the FX one made generic); the FX set's dead non-38..41 branches removed.
- Tests: sfu_emu.py amphalves (12 checks) and ampold (5: a stock-saved project loads into the same words,
  plays the same and saves back byte for byte).

Code: 0025 +142 B, 0029 +24 B, no state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Sound set's write stores the whole kit word into track set + 8's trig array row (0x400a9e58 -> 0x4011f3fa,
0x8000e5b0 + 84 t + 2 k) [code], so turning SFX2 while a SFX1-only step plays replaced the locked SFX1 until the next
trig [measured: row 1824 -> 0c30]. sfu_s_write restores the row's other half after the stock write when the row still
holds what it wrote (a trig since keeps its word), as fx_write_hi does for FX 38..41. +84 B.

- Tests: amphalves +1 check (the partner's base turned while step 5's SFX1-only lock plays: row 1830, the lock kept;
  the next trigs play the new kit halves).

Tests (rytm-emu 1.74, DTEMU_STRICT=1, the Makefile's release set on OS 1.74, this series against dev 95886ee):
halves 10 / 0, amphalves 13 / 0, ampold 5 / 0. suites.py --full: sfu 333 / 0 (dev 235 / 0: the new checks); every
other suite the same passes and fails as dev, check by check. Elekloader RAM 13432 -> 12228 B spare (0025 1098 ->
1624 B, 0029 10126 -> 10808 B, no state). Lag (12 tracks of 16ths, knobs turning, 122 M instructions/s): mean / max
knob latency with a scene edit 460.2 / 941 ms (dev 460.5 / 941), without 26.7 / 48 ms (dev 26.8 / 48); CPU busy the
same as dev.

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

twwwy commented Nov 24, 2026

Copy link
Copy Markdown
Author

Closing: per-knob locks move into the elekloader core-ar2 work (see #29). Thanks for the review.

@twwwy twwwy closed this Nov 24, 2026
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