Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion sdk/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
},
{
"id": "kits",
"version": "0.1.1-experimental",
"version": "0.1.2-experimental",
"addedAt": "2026-11-16T21:00:00Z"
},
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/octatrack/modules/kits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A Kit holds what a Part holds, and no more. Samples are referred to by slot numb
| Reload the pattern's Kit as saved (KIT RELOADED) | FUNC+CUE | FUNC+CUE |
| After a pattern paste: the pasted pattern plays a copy of its Kit in the next empty Kit | PART while STOP is still held | FUNC+MIDI while STOP is still held |
| Save the Kit, copy it and the pattern to the next empty ones and play the copy | PTN+FUNC+RIGHT | PTN+FUNC+RIGHT |
| Copy, paste or clear another pattern of the current bank (paste or clear again: undo) | hold PTN, FUNC and its TRIG; REC, STOP or PLAY | the same |
| Copy, paste or clear another pattern of the current bank (the same paste or clear again, with no other copy, paste or clear between: undo) | hold PTN, FUNC and its TRIG; REC, STOP or PLAY | the same |

In the LOAD KIT and SAVE KIT lists:

Expand Down
40 changes: 40 additions & 0 deletions sdk/octatrack/modules/kits/TESTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Kits testing

## Kits 0.1.2-experimental: the stale PTN+FUNC+TRIG undo, emulator only, 30 November 2026

**What was wrong (0.1.1 and octabam's module).** A PTN+FUNC+TRIG paste or clear repeated on the same pattern is an
undo: Kits writes stock's undo buffer (`0x460bf218`) back into the pattern. Kits remembered only the op and the pattern
of its last paste or clear, never that stock had refilled that buffer since. In OS 1.40C about two dozen routines
between `0x40026768` and `0x4002c166` write stock's undo record (`0x460c80f0`, `0x460c80f4`, `0x460c80f8`) and fill
the buffer: the pattern paste and clear through `0x40026ef0` (Kits' `kits_psnap` site), the others not through it.
So a stock pattern paste or clear (or another edit with an undo) between two Kits
ops made the "undo" write another pattern's bytes, its Part byte included, into the target. A bank change between
the two ops would do the same (the target was the pattern number only); not reproduced, see below.

**The fix.** After its snapshot Kits keeps the CRC-32 of the undo buffer (its own `crc32`) and the target as
bank * 16 + pattern; a repeat undoes only when op, bank, pattern and CRC still match, else it pastes or clears again.
The pattern copy (`kits_pcopy`, stock's and Kits' own) forgets the pending undo, as stock's copy clears its own undo
record. A pattern trig pressed with PTN but without FUNC forgets PTN+FUNC+TRIG's target. Cost: two CRCs over 36,568
bytes per paste or clear on the UI task (estimated 1 to 3 ms each, not measured).

A first attempt that used stock's own undo check (`0x4002ba2c`, the repeat-is-undo of stock's FUNC+STOP and FUNC+PLAY)
was discarded: Kits' clear (eight `0x40039df4` track clears) leaves stock's undo record zeroed, so the control below
failed with it (run5 in the local log).

**Build.** Source `fix/kits-stale-undo` on `main` `d5f759a98`. `npm run module:dev -- kits --build-only`: package
`84f4c5c89a98dce4…`, 11,340 bytes of code and data, 38,968 of bss, 319 relocations, 15 hooks, 15 stock-code sites.
Before: Kits 0.1.1 `c1cb63e5…`.

**Emulator (`ot_emu --frame`, not hardware).** A development twin of base `724dba4cc` (`build_core.py` with the beta
flags and `--dev`, MAIN `276500fc…`), the TEMPLATE project, Kits installed alone with `device try --accept`. Bank A's
patterns 1-8 given trigs on tracks 1-4 (pattern n: steps 1-16 as `nnnn`), patterns 9-16 empty; each check read the
bank's 16 patterns, their Part bytes and Kits' state over the emulator's `peek`. Transport stopped.

| Case | Steps | 0.1.1 `c1cb63e5` (30 Nov, run3) | 0.1.2 `84f4c5c8` (30 Nov, run6) |
| --- | --- | --- | --- |
| Clear | Kits clear A03; stock copy A05, paste A12; Kits clear A03 again | the undo ran and wrote A12's pre-paste snapshot into A03 (empty, so A03 stayed empty) | no undo: A03 cleared again, A12 untouched; the copy forgot the pending undo |
| Paste | copy A01, Kits paste onto A03; stock clear A06; Kits paste onto A03 again | A03 got A06's trigs and A06's Part byte (Part 3) | no undo (the buffer's CRC had changed): A03 got A01's trigs and Part 1 again |
| Control | Kits clear A04 twice, nothing between | trigs back | trigs back (undo) |

**Not tested:** anything on a unit (the owner tests this exact build before it leaves draft); the bank case (the
TEMPLATE card has no bank B: `BANK`, `TRIG2` showed BANK UNAVAILABLE); a stock track or trig edit between two Kits ops
(covered by the CRC by reading, not run); the PTGT reset; the CRC's time on the ColdFire; playing transport; the MKI.

## Kits 0.1.1-experimental on base 0.8: agent's run, 24 November 2026

Build: this branch with `main` `29c22d7a5` merged (base 0.8, with the Part Edit popup fixes of #1947). A development
Expand Down
35 changes: 28 additions & 7 deletions sdk/octatrack/modules/kits/kits.s
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ cpkit: lea %sp@(-8),%sp
| ---- the pattern clipboard carries the pattern's Kit ----------------------
| 0x40026eb0 (pattern): the pattern copy (FUNC+REC), current bank.
kits_pcopy:
clrl PUNDO_OP | a new copy: the next paste pastes (as stock)
lea %sp@(-12),%sp
movem.l %d0-%d1/%a0,%sp@
tstl READY
Expand Down Expand Up @@ -1358,7 +1359,9 @@ kits_ptrig:
movel %sp@(4),%d0
movel %d0,PTGT
rts
9: movel %a2,%sp@- | displaced
9: moveq #-1,%d0 | a trig without FUNC: no target from an
movel %d0,PTGT | earlier PTN+FUNC+TRIG stays armed
movel %a2,%sp@- | displaced
movel %d2,%sp@-
movel %sp@(12),%d2
jmp 0x40056b34
Expand Down Expand Up @@ -1394,28 +1397,45 @@ inactive_op:
addql #4,%sp
lea T_PCOPY,%a0
bra.w 5f
1: cmpl PUNDO_OP,%d3 | the same op on the same pattern: undo
1: cmpl PUNDO_OP,%d3 | the same op on the same pattern of the same
bne.s 2f | bank, while stock's undo buffer still holds
moveq #0,%d0 | Kits' snapshot: undo. About two dozen stock
moveb CUR_BANK,%d0 | routines refill that buffer, most not through
lsll #4,%d0 | 0x40026ef0, so its CRC is the check, not a
addl %d2,%d0 | hook on one of them
cmpl PUNDO_T,%d0
bne.s 2f
cmpl PUNDO_T,%d2
lea UNDOBUF,%a0
movel #PSTRIDE,%d0
bsr.w crc32
cmpl PUNDO_SUM,%d0
bne.s 2f
movel %d2,%sp@-
pea UNDOBUF
jsr 0x4002b9b0
addql #8,%sp
clrl PUNDO_OP
lea T_UNDONE,%a0
bra.s 5f
bra.w 5f
2: cmpil #1,%d3
bne.s 3f
movel 0x460d0ffa,%d0 | paste: a pattern on the clipboard
cmpil #14,%d0
bne.s 4f
bne.w 4f
3: movel %d2,%sp@- | the target's undo snapshot
pea 0x11
jsr 0x40026ef0
addql #8,%sp
movel %d3,PUNDO_OP
movel %d2,PUNDO_T
moveq #0,%d0
moveb CUR_BANK,%d0
lsll #4,%d0
addl %d2,%d0
movel %d0,PUNDO_T | bank * 16 + pattern
lea UNDOBUF,%a0
movel #PSTRIDE,%d0
bsr.w crc32
movel %d0,PUNDO_SUM
cmpil #1,%d3
bne.s 10f
movel %d2,%sp@-
Expand Down Expand Up @@ -3822,7 +3842,8 @@ LASTPASTE: .long -1 | bank*16 + pattern of the last pattern paste
FRIGHT_BUSY: .long 0
PTGT: .long -1 | PTN+FUNC+TRIG's target pattern
PUNDO_OP: .long 0
PUNDO_T: .long -1
PUNDO_T: .long -1 | bank * 16 + pattern
PUNDO_SUM: .long 0 | CRC-32 of stock's undo buffer after the snapshot
SAVEK: .long 0
V3MGEN: .long 0
V3MHAVE: .long 0
Expand Down
2 changes: 1 addition & 1 deletion sdk/octatrack/modules/kits/octamod.module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "kits",
"key": "KITS",
"name": "Kits",
"version": "0.1.1-experimental",
"version": "0.1.2-experimental",
"category": "scenes",
"author": {
"github": "sambanks",
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/module-documents.json
Original file line number Diff line number Diff line change
Expand Up @@ -15290,7 +15290,7 @@
"id": "kits",
"key": "KITS",
"name": "Kits",
"version": "0.1.1-experimental",
"version": "0.1.2-experimental",
"category": "scenes",
"access": {
"location": "PART (MKII) or FUNC+MIDI (MKI) from any page",
Expand Down
9 changes: 9 additions & 0 deletions src/community/module-changelogs/kits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "0.1.2-experimental",
"date": "2026-11-30",
"changes": [
"Fixes a repeated PTN+FUNC+TRIG paste or clear filling the pattern with another pattern's trigs and Part after a stock copy, paste or clear in between.",
"Repeating the same paste or clear right away still undoes it. After another edit in between, the repeat pastes or clears again.",
"A new pattern copy means the next paste pastes, as on a stock Octatrack."
]
},
{
"version": "0.1.1-experimental",
"date": "2026-11-21",
Expand Down
8 changes: 4 additions & 4 deletions src/engine/assets/octatrack-module-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,17 +691,17 @@
"id": "kits",
"octabam": true,
"usbOnly": true,
"version": "0.1.1-experimental",
"version": "0.1.2-experimental",
"abi": 8,
"features": 129,
"sites": 15,
"copies": 0,
"fills": 0,
"name": "Kits",
"module": "9ea848b6",
"bytes": 13546,
"sha256": "c1cb63e556add9aaf39eea5bfcdafc1ece923b51d9723c49f5caf6fd215ed072",
"path": "octatrack-modules/kits/0.1.1-experimental.mwrm"
"bytes": 13654,
"sha256": "84f4c5c89a98dce47cb0e77cbf0d492d78dd83c71511990cd61e86818328f715",
"path": "octatrack-modules/kits/0.1.2-experimental.mwrm"
},
{
"id": "tuner",
Expand Down
Loading