From 0e9b62fa0fcc6ad46419a77b81186106b4a78019 Mon Sep 17 00:00:00 2001 From: Lukas Schmolz Date: Sat, 5 Dec 2026 19:24:36 +0100 Subject: [PATCH 1/5] Fix: Digitone II base: module project data follows the working state (#2683) OS 1.12 keeps the unsaved project as its file image in RAM, writes it to the eMMC at power-off and loads it at boot, but refreshes the header (where core_projdata lives) only on Project::changed with flag 0x40 or all bits. The Digitone II copy of store.c now compares the mods' blocks each UI tick and on a change calls stock's Project::changed with a header-only ProjectDataChangeInfo, as stock's rename does with 0x20. Co-Authored-By: Claude Opus 5.5 --- sdk/machines/digitone-ii/elekloader/base.json | 3 +- .../elekloader/copies/core-dt2/mod.json | 7 ++ .../elekloader/copies/core-dt2/store.c | 73 +++++++++++++++++++ .../elekloader/copies/core-dt2/store.s | 5 +- 4 files changed, 85 insertions(+), 3 deletions(-) diff --git a/sdk/machines/digitone-ii/elekloader/base.json b/sdk/machines/digitone-ii/elekloader/base.json index 92b5782f64..5c849a677b 100644 --- a/sdk/machines/digitone-ii/elekloader/base.json +++ b/sdk/machines/digitone-ii/elekloader/base.json @@ -58,7 +58,8 @@ "PATTERN_OBJ": "0x446488d0", "MODS_STOCK": "0x400db390", "LEDS_CLEAR": "0x4002c3c6", - "FRAME_STRIDE": "101" + "FRAME_STRIDE": "101", + "PROJ_INFO_VTBL": "0x401dd340" }, "sites": [ { diff --git a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json index 823833cf20..f5752e6641 100644 --- a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json +++ b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json @@ -132,6 +132,13 @@ "target": "core_memcpy" } ], + "subscribe": [ + { + "event": "ev_tick", + "fn": "core_projdata_watch", + "order": 0 + } + ], "collections": { "ev_tick": 4, "ev_draw": 4, diff --git a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c index 060652adde..afe7156b85 100644 --- a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c +++ b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c @@ -21,6 +21,7 @@ volatile uint32_t core_store_conflicts; #define KIT_PAD (core_store_layout[2]) #define KIT_ROOM (core_store_layout[3]) #define PATTERN_OBJ (core_store_layout[4]) +#define PROJ_INFO_VTBL (core_store_layout[5]) /* ---- project data: the header's gap, as on core-dn1: 'ELKP', then per block its * tag, its size and its bytes, then a zero tag ---- */ @@ -58,6 +59,9 @@ static void zero(uint8_t *to, uint32_t n) *to++ = 0; } +static volatile uint8_t proj_busy; /* a save or load runs: the watch waits */ +static void proj_seen(void); + void core_projdata_save(uint8_t *file) { uint8_t *p = file + GAP, *end = file + GAP_END; @@ -67,6 +71,7 @@ void core_projdata_save(uint8_t *file) core_store_conflicts++; return; } + proj_busy = 1; zero(p, GAP_END - GAP); put32(p, PROJ_MAGIC); p += 4; @@ -79,12 +84,15 @@ void core_projdata_save(uint8_t *file) copy(p + 8, (*d)->data, n); p += 8 + n; } + proj_seen(); + proj_busy = 0; } void core_projdata_load(const uint8_t *file) { const uint8_t *gap = file + GAP, *end = file + GAP_END; int ours = get32(gap) == PROJ_MAGIC; + proj_busy = 1; if (!ours && !blank(gap, GAP_END - GAP)) core_store_conflicts++; for (const core_projdata_t *const *d = core_projdata; *d; d++) { @@ -105,6 +113,71 @@ void core_projdata_load(const uint8_t *file) if ((*d)->loaded) (*d)->loaded(found); } + proj_seen(); + proj_busy = 0; +} + +/* ---- project data follows the working state (Digitone II copy) ---- + * OS 1.12 keeps the unsaved project as its file image in RAM, refreshes the parts + * of it that change, writes the whole image to the eMMC at power-off and loads it + * at boot. The header, where the blocks above live, is refreshed only when the + * project's changed() runs with flag bit 6 (0x40) or with every bit, and nothing + * calls it when a mod changes its data. So each UI tick core compares the mods' + * blocks with what it last saved or loaded and, when they differ, calls stock's + * Project::changed (the project's vtable + 0x10) with a header-only + * ProjectDataChangeInfo, as stock's rename does with 0x20 (the name). Stock then + * writes the header (the save hook above packs the blocks into the image) and + * marks the project changed, so it asks SAVE ... BEFORE LOADING? as for its own + * edits. Read on a unit, 5 December 2026 (#2683). */ +#define PROJ_HEADER 0x40 + +static uint8_t seen[GAP_END - GAP]; +static uint8_t seen_known; + +/* the blocks as they are into seen; 1 if any byte differed */ +static int proj_sync(void) +{ + uint8_t *s = seen, *end = seen + sizeof seen; + int differ = 0; + for (const core_projdata_t *const *d = core_projdata; *d; d++) { + const uint8_t *p = (const uint8_t *)(*d)->data; + uint32_t n = (*d)->size; + if ((uint32_t)(end - s) < n) + break; /* the save leaves it out too */ + for (uint32_t i = 0; i < n; i++) + if (s[i] != p[i]) { + s[i] = p[i]; + differ = 1; + } + s += n; + } + return differ; +} + +static void proj_seen(void) +{ + proj_sync(); + seen_known = 1; +} + +struct proj_info { + uint32_t vtbl, flags; /* stock's ProjectDataChangeInfo */ +}; + +/* ev_tick (UI task, about 30 a second) */ +void core_projdata_watch(void *ctrl) +{ + uint32_t project; + (void)ctrl; + if (!core_projdata[0] || !seen_known || proj_busy || !proj_sync()) + return; + project = *(volatile uint32_t *)PATTERN_OBJ; + if (project) { + struct proj_info info = {PROJ_INFO_VTBL, PROJ_HEADER}; + void (*changed)(uint32_t, struct proj_info *) = + (void (*)(uint32_t, struct proj_info *))*(volatile uint32_t *)(*(volatile uint32_t *)project + 0x10); + changed(project, &info); + } } /* ---- kit data: after each kit record's end mark, a mark, the layout's id and the diff --git a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.s b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.s index 12756d60ec..e3261c43bf 100644 --- a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.s +++ b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.s @@ -25,9 +25,10 @@ | The device's layout, for store.c: the kit table, its stride, the bytes of a | kit record after its end mark (offset, length), the pattern object's -| pointer (the pattern on at +0x138). +| pointer (the pattern on at +0x138; on the Digitone II the project's), and the +| vtable of stock's ProjectDataChangeInfo (Digitone II copy). core_store_layout: - .long FW_KITS, KIT_SIZE, KIT_PAD, KIT_ROOM, PATTERN_OBJ + .long FW_KITS, KIT_SIZE, KIT_PAD, KIT_ROOM, PATTERN_OBJ, PROJ_INFO_VTBL core_kit_save: move.l %a3, -(%sp) From f9f47ae5376206fa926fa53791f988ad5187c565 Mon Sep 17 00:00:00 2001 From: Lukas Schmolz Date: Sat, 5 Dec 2026 20:06:56 +0100 Subject: [PATCH 2/5] Fix: Digitone II base: the record, changelog and README for #2683 Co-Authored-By: Claude Opus 5.5 --- ...2-05-digitone-ii-projdata-working-state.md | 1 + ...2-05-digitone-ii-projdata-working-state.md | 51 +++++++++++++++++++ sdk/machines/digitone-ii/elekloader/README.md | 11 ++-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 changelog/2026-12-05-digitone-ii-projdata-working-state.md create mode 100644 docs/verification/2026-12-05-digitone-ii-projdata-working-state.md diff --git a/changelog/2026-12-05-digitone-ii-projdata-working-state.md b/changelog/2026-12-05-digitone-ii-projdata-working-state.md new file mode 100644 index 0000000000..4a10cd5077 --- /dev/null +++ b/changelog/2026-12-05-digitone-ii-projdata-working-state.md @@ -0,0 +1 @@ +On the Digitone II base, a module's project setting now survives a power cycle without a save, as the stock settings do, and changing only a module's setting makes the unit ask SAVE … BEFORE LOADING? when you load another project. Before, Voice Spread came back with the values of the last full save, and loading another project dropped its change without asking. diff --git a/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md new file mode 100644 index 0000000000..63d5fa0a51 --- /dev/null +++ b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md @@ -0,0 +1,51 @@ +# Digitone II: module project data across a power cycle, and Voice Spread on a unit, 5 December 2026 + +The contributor's Digitone II (@prodbysmolec), OS 1.12. The agent drove the unit over the development link (keys, encoder turns, the screen) and recorded its sound over USB audio; the developer flashed with YES and power-cycled the unit. Issue #2683. + +- **Images:** + - **A, flashed:** the development base `a158dc917c68d70c61d895085da9f6451dafa6c54ee198a27a50dd061a641583` (the dev stack's package; its record, `2026-12-05-digitone-ii-dev-stack-on-a-unit.md`, is on the stack's branches) with Voice Spread 0.1.0 `9ce8ff19564deedd1531f60a3b4d2be3f898aab0a8e243db1d6aa20a3a17f0f5`, linked by Elekloader 0.11.0's patcher: `.syx` `ef14a48c4fe21da1f06992dfe12edbcb49209dfe71dad3e2b0c39f53b5d26f04`. + - **B, earlier the same day:** the plain base `7a60d82e…` with the same Voice Spread package, `.syx` `156719fd48820ebf7bbc5e5a8eca413abbf25dcb8c8162ac83d6b4392edc3def`, flashed. No link, so the developer ran it by hand. + - **C, booted from RAM:** this branch merged onto #1842's head `4ef2c9abd`, development base `debe5195c0404e5a20aa92be00423de9f836fc4e265512ef37d3d054442688c1` with the same Voice Spread package, `.syx` `90c0374a0a99a6b7af0fffcf8711598ad4c5fde3a54e1c95cc8c5fad0d371981`, through `dn2_link.py ramboot` (nothing written to the flash). +- **This branch's plain base:** `b1f5b05c18bf63524ca83d04dc832b0b290a18fdcfe5d6b33b8b9eafa2eceea3` (.run 3,920, .bss 3,604 bytes, 14 sites), GCC 16.2.0 and binutils 2.47 as `base-binding.json` records. +- **Sound:** the unit's USB audio inputs 0 and 1 (the main out, left and right), 48 kHz, recorded on the host. Pan per note is (R − L) / (R + L) of the two channels' RMS. + +## The bug (images B and A) + +| Check | Result | +| --- | --- | +| B: VOICE SPREAD 75, the developer's save, a power cycle | both rows OFF | +| A: VOICE SPREAD 75, FILTER SPREAD LOW, SAVE PROJECT AS into an empty slot, another project loaded, this one loaded again | 75 / LOW | +| A: a project saved without the module | OFF / OFF | +| A: the project with Attack Time and Voice Spread changed, another project chosen: stock asks SAVE … BEFORE LOADING?, YES, this one loaded again | Attack Time and Voice Spread as changed | +| A: FUNC + SETTINGS | not a save on OS 1.12: it closes the menu (PROJECT has LOAD, SAVE AS and MANAGE) | +| A: saved Attack Time 10 and Voice Spread 100 / OFF, then unsaved Attack Time 20 and Voice Spread 25 / HIGH, a power cycle | Attack Time 20, Voice Spread 100 / OFF: stock kept its unsaved change and lost the module's | +| A: saved, then only Voice Spread changed, another project chosen | no SAVE … BEFORE LOADING?; the change is lost | + +**Why** (read from OS 1.12): stock keeps the unsaved project as its file image in RAM (0x405ce96c), writes the whole block to the eMMC at power-off and loads it at boot, so the base's load hook reads the header from that working image. Stock refreshes parts of the image when they change; the header, where `core_projdata` lives, only when the project's `changed()` runs with flag bit 6 (0x40) or with every bit. Nothing called it after a module changed its data, and nothing set stock's "project changed" flag either. + +## The fix (image C, then image A) + +| Check | Result | +| --- | --- | +| C: SAVE PROJECT AS, then only Voice Spread changed (75 / MID), another project chosen | stock asks SAVE 'NEW PROJECT' BEFORE LOADING? | +| C: YES, the other project loaded, then this one again from the unchanged other project | 75 / MID, and no question when leaving the unchanged project | +| C: unsaved 25 / LOW (Voice Spread only), then a power cycle: image A boots | **25 / LOW**: the working image carried the module's change | +| A (without the fix), the same: SAVE PROJECT AS, only Voice Spread changed, another project chosen | no question, the project loads at once (the control) | + +## Voice Spread's sound (image C) + +Track 1, the project's sound (FM, ALGO 1), C4 notes sent over USB MIDI, one note at a time so each takes the next voice; 16 notes. + +| Setting | Pan of the 16 notes | +| --- | --- | +| VOICE SPREAD OFF, FILTER SPREAD OFF | +0.00 on all 16 | +| VOICE SPREAD 50 | −0.35 +0.36 −0.14 +0.15 −0.24 +0.25 −0.05 +0.05 −0.41 +0.41 −0.20 +0.20 −0.30 +0.31 −0.10 +0.10 | +| VOICE SPREAD 100 | −0.80 +0.83 −0.29 +0.30 −0.52 +0.54 −0.10 +0.10 −0.98 +0.99 −0.40 +0.41 −0.66 +0.67 −0.20 +0.20 | + +Neighbouring voices go to opposite sides, the pairs are symmetric, 100 puts the outermost voices hard left and right, and OFF is the stock sound. For FILTER SPREAD the track's filter frequency was turned down to 62 and C6 notes played, so the voices' cutoffs land near the note: with FILTER SPREAD OFF every note's level was 0.007, with HIGH they ranged from 0.004 to 0.049, voice by voice. The developer listened to chords at A 100 / OFF, B OFF / OFF, C OFF / HIGH and D 100 / HIGH and said it sounded good. + +## Not tested + +- Parameter locks and LFOs on pan and filter frequency together with the spread. +- Kit data (`core_kitdata`): a module-only change to a kit's data is not marked changed either; Voice Spread keeps none, and this fix covers project data only. +- The Digitakt II base, which shares this store.c design: whether OS 1.17 refreshes its header the same way was not checked. diff --git a/sdk/machines/digitone-ii/elekloader/README.md b/sdk/machines/digitone-ii/elekloader/README.md index 235ced38c7..921015e545 100644 --- a/sdk/machines/digitone-ii/elekloader/README.md +++ b/sdk/machines/digitone-ii/elekloader/README.md @@ -15,10 +15,15 @@ exact. On top of that: - **`copies/`**: Digitone II copies of three core-dt2 files. `base.json` names each one's original and its SHA-256, and the build refuses once the original changes, so a copy is redone, never left behind: - `mod.json`: OS 1.12, and no `.fast` area (no `fast.s`, `core_fast` or its copier on `ev_tick`): SRAM is not - qualified on this OS, so the device has no SRAM code area. + qualified on this OS, so the device has no SRAM code area. `core_projdata_watch` on `ev_tick` instead (below). - `store.s`: the kit loader holds the record in a2 and the kit's RAM in a3, the other way round from the - Digitakt II. - - `store.c`: a kit record leaves 337 bytes after its end mark (`KIT_ROOM`), so the room buffer holds 340. + Digitakt II. The layout table also carries stock's `ProjectDataChangeInfo` vtable (`PROJ_INFO_VTBL`). + - `store.c`: a kit record leaves 337 bytes after its end mark (`KIT_ROOM`), so the room buffer holds 340. And + the mods' project data follows the working state (#2683): OS 1.12 keeps the unsaved project as its file image + in RAM, writes it to the eMMC at power-off and loads it at boot, but rewrites the header, where the blocks + live, only when the project's `changed()` runs with flag 0x40 or all bits. `core_projdata_watch` compares the + blocks each UI tick and on a change calls it with 0x40, so the header follows and stock marks the project + changed. One variant, `plain`: none of the Digitakt II base's sequencer and project additions (`add`), whose Digitone II sites are not found yet. No DSP bridge either: the base links mods for the ColdFire only, and Modwerk's linker refuses a mod From 541645d297692659a8f3c1760359c748aafcd638 Mon Sep 17 00:00:00 2001 From: Lukas Schmolz Date: Sat, 5 Dec 2026 20:34:13 +0100 Subject: [PATCH 3/5] Fix: Digitone II base: the record adds Voice Spread with a pan lock and an LFO (#2683) Co-Authored-By: Claude Opus 5.5 --- .../2026-12-05-digitone-ii-projdata-working-state.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md index 63d5fa0a51..39fb87c240 100644 --- a/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md +++ b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md @@ -44,8 +44,17 @@ Track 1, the project's sound (FM, ALGO 1), C4 notes sent over USB MIDI, one note Neighbouring voices go to opposite sides, the pairs are symmetric, 100 puts the outermost voices hard left and right, and OFF is the stock sound. For FILTER SPREAD the track's filter frequency was turned down to 62 and C6 notes played, so the voices' cutoffs land near the note: with FILTER SPREAD OFF every note's level was 0.007, with HIGH they ranged from 0.004 to 0.049, voice by voice. The developer listened to chords at A 100 / OFF, B OFF / OFF, C OFF / HIGH and D 100 / HIGH and said it sounded good. +Then with the pattern playing (trigs on steps 1, 5, 9 and 13 of track 1, image A, pan per trig): + +| Setting | Result | +| --- | --- | +| A pan lock of L24 on step 1, VOICE SPREAD OFF | the locked trig −0.30, the others 0.00 | +| The same lock, VOICE SPREAD 100 | the locked trig −1.00 (held at the end of the range), the others ±0.10 to ±0.99 | +| LFO1 on AMP Pan (depth 63.98), VOICE SPREAD OFF | the pan sweeps from trig to trig: −0.94 −0.52 +0.42 +0.53 +0.20 −0.70 −0.79 −0.19 +0.95 … | +| The same LFO, VOICE SPREAD 100 | each voice's offset on top of the sweep, held between −1.00 and +1.00 | + ## Not tested -- Parameter locks and LFOs on pan and filter frequency together with the spread. +- An LFO or a lock on the filter frequency together with FILTER SPREAD. - Kit data (`core_kitdata`): a module-only change to a kit's data is not marked changed either; Voice Spread keeps none, and this fix covers project data only. - The Digitakt II base, which shares this store.c design: whether OS 1.17 refreshes its header the same way was not checked. From 83f35f7316bebbd92d4eaaabbe56f53a210c620b Mon Sep 17 00:00:00 2001 From: Lukas Schmolz Date: Sat, 5 Dec 2026 22:12:28 +0100 Subject: [PATCH 4/5] Fix: Digitone II base: module kit data follows the working state too (#2683) A stock sound edit writes its value straight into the working image and never runs the kit serializer, so a mod's kit blocks waited for the kit's next serialization. core_store_watch (was core_projdata_watch) now also compares the kit on's blocks each UI tick and on a change has stock's KitActive serialize that one kit (vtable + 0x60, no change info), then marks the project changed. Co-Authored-By: Claude Opus 5.5 --- sdk/machines/digitone-ii/elekloader/README.md | 7 +- .../elekloader/copies/core-dt2/mod.json | 2 +- .../elekloader/copies/core-dt2/store.c | 103 +++++++++++++++--- 3 files changed, 93 insertions(+), 19 deletions(-) diff --git a/sdk/machines/digitone-ii/elekloader/README.md b/sdk/machines/digitone-ii/elekloader/README.md index 921015e545..10af847de5 100644 --- a/sdk/machines/digitone-ii/elekloader/README.md +++ b/sdk/machines/digitone-ii/elekloader/README.md @@ -15,15 +15,16 @@ exact. On top of that: - **`copies/`**: Digitone II copies of three core-dt2 files. `base.json` names each one's original and its SHA-256, and the build refuses once the original changes, so a copy is redone, never left behind: - `mod.json`: OS 1.12, and no `.fast` area (no `fast.s`, `core_fast` or its copier on `ev_tick`): SRAM is not - qualified on this OS, so the device has no SRAM code area. `core_projdata_watch` on `ev_tick` instead (below). + qualified on this OS, so the device has no SRAM code area. `core_store_watch` on `ev_tick` instead (below). - `store.s`: the kit loader holds the record in a2 and the kit's RAM in a3, the other way round from the Digitakt II. The layout table also carries stock's `ProjectDataChangeInfo` vtable (`PROJ_INFO_VTBL`). - `store.c`: a kit record leaves 337 bytes after its end mark (`KIT_ROOM`), so the room buffer holds 340. And the mods' project data follows the working state (#2683): OS 1.12 keeps the unsaved project as its file image in RAM, writes it to the eMMC at power-off and loads it at boot, but rewrites the header, where the blocks - live, only when the project's `changed()` runs with flag 0x40 or all bits. `core_projdata_watch` compares the + live, only when the project's `changed()` runs with flag 0x40 or all bits. `core_store_watch` compares the blocks each UI tick and on a change calls it with 0x40, so the header follows and stock marks the project - changed. + changed. It does the same for the kit on's kit data: on a change it has stock's KitActive serialize that kit into + the working image (a sound edit never runs the kit serializer, so the blocks would wait for the next one). One variant, `plain`: none of the Digitakt II base's sequencer and project additions (`add`), whose Digitone II sites are not found yet. No DSP bridge either: the base links mods for the ColdFire only, and Modwerk's linker refuses a mod diff --git a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json index f5752e6641..af54982086 100644 --- a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json +++ b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/mod.json @@ -135,7 +135,7 @@ "subscribe": [ { "event": "ev_tick", - "fn": "core_projdata_watch", + "fn": "core_store_watch", "order": 0 } ], diff --git a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c index afe7156b85..6c591876f8 100644 --- a/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c +++ b/sdk/machines/digitone-ii/elekloader/copies/core-dt2/store.c @@ -61,6 +61,7 @@ static void zero(uint8_t *to, uint32_t n) static volatile uint8_t proj_busy; /* a save or load runs: the watch waits */ static void proj_seen(void); +static void kit_forget(void); void core_projdata_save(uint8_t *file) { @@ -164,20 +165,14 @@ struct proj_info { uint32_t vtbl, flags; /* stock's ProjectDataChangeInfo */ }; -/* ev_tick (UI task, about 30 a second) */ -void core_projdata_watch(void *ctrl) +/* Project::changed with the header-only flag: the header in the working image is + * written again and stock marks the project changed */ +static void project_changed(uint32_t project) { - uint32_t project; - (void)ctrl; - if (!core_projdata[0] || !seen_known || proj_busy || !proj_sync()) - return; - project = *(volatile uint32_t *)PATTERN_OBJ; - if (project) { - struct proj_info info = {PROJ_INFO_VTBL, PROJ_HEADER}; - void (*changed)(uint32_t, struct proj_info *) = - (void (*)(uint32_t, struct proj_info *))*(volatile uint32_t *)(*(volatile uint32_t *)project + 0x10); - changed(project, &info); - } + struct proj_info info = {PROJ_INFO_VTBL, PROJ_HEADER}; + void (*changed)(uint32_t, struct proj_info *) = + (void (*)(uint32_t, struct proj_info *))*(volatile uint32_t *)(*(volatile uint32_t *)project + 0x10); + changed(project, &info); } /* ---- kit data: after each kit record's end mark, a mark, the layout's id and the @@ -335,9 +330,10 @@ void core_kitdata_load(const uint8_t *kit, const uint8_t *record) return; if (!blank(area, KIT_ROOM) && !ours(area)) core_store_conflicts++; - if (n >= 0) + if (n >= 0) { unpack(n, ours(area) ? area : 0); - else if (ours(area)) + kit_forget(); + } else if (ours(area)) copy(shadow_new((uint32_t)kit), area, KIT_ROOM); else shadow_drop((uint32_t)kit); @@ -359,6 +355,7 @@ void core_kit_copied(uint8_t *dst, const uint8_t *src) if (d >= 0) { if (from) unpack(d, from); + kit_forget(); return; /* from a buffer core never saw filled: the kit's blocks stay */ } if (from) @@ -366,3 +363,79 @@ void core_kit_copied(uint8_t *dst, const uint8_t *src) else shadow_drop((uint32_t)dst); } + +/* ---- kit data follows the working state too (Digitone II copy) ---- + * A stock sound edit writes its one value straight into the kit's record in the + * working image and never runs the kit serializer, so a mod's kit blocks reach the + * image only when that kit is serialized for another reason. So each UI tick core + * compares the kit on's blocks with what it last saw of that kit and, when they + * differ, asks stock's KitActive (project + 0xf4) to serialize that one kit into the + * image (its vtable + 0x60: the kit, the mirror, no change info, which queues + * "KitActive::updateSingleMirror" and runs the kit save hook above, without the + * engine reload its other update calls do on the active kit), then marks the project + * changed as for project data. A kit load, a kit copy or another kit on only takes a + * new copy. Kit data a mod changes in a kit that is not on waits for that kit's next + * serialization, as before. Read on a unit, 5 December 2026 (#2683). */ +#define KITACTIVE 0xf4 +#define KA_KITS 0x10 /* the kit array, 0 before the project is up */ +#define KA_MIRRORS 0x20 /* begin and end of the array mirrors; the first is the image's kits */ +#define KA_UPDATE_ARRAY 0x60 /* vtable slot: (kitactive, kit, mirror, info) */ + +static uint8_t kit_seen[ROOM_MAX]; +static volatile int kit_seen_n = -1; /* -1: take a new copy at the next tick */ + +static void kit_forget(void) +{ + kit_seen_n = -1; +} + +/* 1 if kit n's blocks differ from what core last saw (and keeps them), 0 if not or + * if they are new to it */ +static int kit_sync(int n) +{ + static uint8_t now[ROOM_MAX]; + int differ = 0; + pack(n, now); + for (uint32_t i = 0; i < KIT_ROOM; i++) + if (kit_seen[i] != now[i]) { + kit_seen[i] = now[i]; + differ = 1; + } + if (kit_seen_n != n) { + kit_seen_n = n; + return 0; + } + return differ; +} + +static void kit_serialize(uint32_t project, int n) +{ + uint32_t ka = project + KITACTIVE; + uint32_t *b = *(uint32_t *volatile *)(ka + KA_MIRRORS), *e = *(uint32_t *volatile *)(ka + KA_MIRRORS + 4); + void (*update)(uint32_t, int, uint32_t, void *); + if (b == e || !*b || !*(volatile uint32_t *)(ka + KA_KITS)) + return; + update = (void (*)(uint32_t, int, uint32_t, void *))*(volatile uint32_t *)(*(volatile uint32_t *)ka + KA_UPDATE_ARRAY); + update(ka, n, *b, 0); +} + +/* ev_tick (UI task, about 30 a second) */ +void core_store_watch(void *ctrl) +{ + uint32_t project = *(volatile uint32_t *)PATTERN_OBJ; + int changed = 0, n; + (void)ctrl; + if (!project || proj_busy) + return; + if (core_projdata[0] && seen_known && proj_sync()) + changed = 1; + n = core_kit_on(); + if (!core_kitdata[0] || n < 0) + kit_forget(); + else if (kit_sync(n)) { + kit_serialize(project, n); + changed = 1; + } + if (changed) + project_changed(project); +} From 1df095ea788a1c88f5925a4ed0f8471dc5aa7254 Mon Sep 17 00:00:00 2001 From: Lukas Schmolz Date: Sat, 5 Dec 2026 22:18:13 +0100 Subject: [PATCH 5/5] Fix: Digitone II base: the record adds kit data on the unit (#2683) Co-Authored-By: Claude Opus 5.5 --- ...-12-05-digitone-ii-projdata-working-state.md | 2 +- ...-12-05-digitone-ii-projdata-working-state.md | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/changelog/2026-12-05-digitone-ii-projdata-working-state.md b/changelog/2026-12-05-digitone-ii-projdata-working-state.md index 4a10cd5077..7a974d3656 100644 --- a/changelog/2026-12-05-digitone-ii-projdata-working-state.md +++ b/changelog/2026-12-05-digitone-ii-projdata-working-state.md @@ -1 +1 @@ -On the Digitone II base, a module's project setting now survives a power cycle without a save, as the stock settings do, and changing only a module's setting makes the unit ask SAVE … BEFORE LOADING? when you load another project. Before, Voice Spread came back with the values of the last full save, and loading another project dropped its change without asking. +On the Digitone II base, a module's project and kit settings now survive a power cycle without a save, as the stock settings do, and changing only a module's setting makes the unit ask SAVE … BEFORE LOADING? when you load another project. Before, Voice Spread came back with the values of the last full save, and loading another project dropped its change without asking. diff --git a/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md index 39fb87c240..57b03d869a 100644 --- a/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md +++ b/docs/verification/2026-12-05-digitone-ii-projdata-working-state.md @@ -32,6 +32,20 @@ The contributor's Digitone II (@prodbysmolec), OS 1.12. The agent drove the unit | C: unsaved 25 / LOW (Voice Spread only), then a power cycle: image A boots | **25 / LOW**: the working image carried the module's change | | A (without the fix), the same: SAVE PROJECT AS, only Voice Spread changed, another project chosen | no question, the project loads at once (the control) | +## Kit data (image D) + +The same gap held for module kit data (`core_kitdata`): a stock sound edit writes its value straight into the kit's record in the working image and never runs the kit serializer, so a module's kit blocks waited for that kit's next serialization. Tested with a local test module that is not part of this pull request (`kitdata-test`: one byte per kit, tag `KTST`, a PERSONALIZE row KIT DATA TEST 0–9 for the kit on), using the link's `reboot` (#2685, a draft on top of #1842) in place of a power cycle: + +- **Image D0, before the kit fix:** this branch at `541645d29` merged with #2685, development base `6ee31d89…`, with Voice Spread and `kitdata-test`, `.syx` `2c4d4b77d080f05b96c6a3988a56e1416843544b53c5f658afd4e791d6825fab`, booted from RAM. +- **Image D, with the kit fix:** this branch merged with #2685, development base `e020ad7e32fdbd1ad2fc24751a3d173c30a93fdf3c120b3f012293af750b5a88`, with Voice Spread and `kitdata-test`, `.syx` `42c1c6b51f19c093942562166ed03e2883cea83985e1e7e319a7acb79659816a`, booted from RAM. + +| Check | Result | +| --- | --- | +| D0: KIT DATA TEST 5 (only the module's kit data), `reboot`, image D0 booted from RAM again | 0: lost. Voice Spread's 25 / HIGH, changed earlier, was kept | +| D: KIT DATA TEST 7, `reboot`, image D booted from RAM again | **7** | +| D: SAVE PROJECT AS, then only KIT DATA TEST changed (7 → 5), another project chosen | stock asks SAVE 'NEW PROJECT' BEFORE LOADING? | +| D: YES, then this project loaded again from the unchanged other one | no question; KIT DATA TEST 5 | + ## Voice Spread's sound (image C) Track 1, the project's sound (FM, ALGO 1), C4 notes sent over USB MIDI, one note at a time so each takes the next voice; 16 notes. @@ -56,5 +70,6 @@ Then with the pattern playing (trigs on steps 1, 5, 9 and 13 of track 1, image A ## Not tested - An LFO or a lock on the filter frequency together with FILTER SPREAD. -- Kit data (`core_kitdata`): a module-only change to a kit's data is not marked changed either; Voice Spread keeps none, and this fix covers project data only. +- Kit data a module changes in a kit that is not on: it waits for that kit's next serialization, as before. +- A released module that keeps kit data: none exists on the Digitone II yet. - The Digitakt II base, which shares this store.c design: whether OS 1.17 refreshes its header the same way was not checked.