diff --git a/docs/emu2/felucca.wasm b/docs/emu2/felucca.wasm
new file mode 100755
index 0000000..fc7f7fe
Binary files /dev/null and b/docs/emu2/felucca.wasm differ
diff --git a/docs/emu2/fonts/DotGothic16-subset.woff b/docs/emu2/fonts/DotGothic16-subset.woff
new file mode 100644
index 0000000..9b14546
Binary files /dev/null and b/docs/emu2/fonts/DotGothic16-subset.woff differ
diff --git a/docs/emu2/fonts/OFL.txt b/docs/emu2/fonts/OFL.txt
new file mode 100644
index 0000000..e283767
--- /dev/null
+++ b/docs/emu2/fonts/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The DotGothic16 Project Authors (https://github.com/fontworks-fonts/DotGothic16/)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/docs/emu2/index.html b/docs/emu2/index.html
new file mode 100644
index 0000000..793af3f
--- /dev/null
+++ b/docs/emu2/index.html
@@ -0,0 +1,593 @@
+
+
+
+
+ Z–'Q–O keys
+ 1–= FX … REC
+ Turn the knobs: drag, scroll or arrow keys
+ [] OCT
+ ↑↓ SELECT
+ ←→ ALGORITHM
+ Shift-click holds a button
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/emu2/worklet.js b/docs/emu2/worklet.js
new file mode 100644
index 0000000..fcebeb4
--- /dev/null
+++ b/docs/emu2/worklet.js
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
+// Felucca in an AudioWorklet: felucca.wasm is the whole FM-1 firmware against a simulated FM-1
+// (web/emu/felucca_web.c). Each render quantum asks it for 128 frames, which runs the device's clock forward;
+// between quanta the page's input goes in and, about 30 times a second (4 when the page is hidden), the screen,
+// the lights and any changed flash go out. After X0X's web/emu/worklet.js (charlesvestal/fm1-x0x, GPL-3.0).
+
+// The flash the page keeps: storage.c's areas (projects, user presets and their FM6 patches, the user sample
+// slots 0x97000..0xDFFFF; the autosave 0xE5000..0xE6FFF (1.2) and FM6's voice bank 0xE7000 (1.4.1); the settings and
+// the second FM6 copy 0xFC000..0xFFFFF), only the sectors that hold something (an erased sector is all 0xFF). {offset: bytes}
+export const STORE_AREAS = [[0x97000, 0xE0000], [0xE5000, 0xE8000], [0xFC000, 0x100000]];
+export function storeSectors(nor) {
+ const out = {};
+ for (const [a, b] of STORE_AREAS)
+ for (let off = a; off < b; off += 4096) {
+ const s = nor.subarray(off, off + 4096);
+ if (s.some((v) => v !== 0xFF)) out[off] = s.slice();
+ }
+ return out;
+}
+export function restoreSectors(nor, sectors) {
+ for (const [k, v] of Object.entries(sectors || {})) {
+ const off = +k, b = v instanceof Uint8Array ? v : new Uint8Array(v);
+ if (STORE_AREAS.some(([a, e]) => off >= a && off + 4096 <= e && off % 4096 === 0) && b.length === 4096)
+ nor.set(b, off);
+ }
+}
+
+export const HOLD_MS = 24;
+
+// The panel's knobs from a MIDI controller (the page's Web MIDI in): CC 20..26 turn SELECT, ALGORITHM, PRESETS,
+// KNOB 1..4 (the encoder roles), a detent a step; CC 27 sets MASTER (a pot on the FM-1: absolute in every mode). The
+// firmware's CC map (midi_control.c) has none of them, so they stay here. mode, as the controller sends a turn:
+// abs absolute (the default): by how far the value moves, so it takes over from anywhere without a jump; last:
+// the value each knob CC sent before (the first one only takes its place)
+// bin relative, 64 +- n (65 = +1, 63 = -1)
+// twos relative, two's complement (1 = +1, 127 = -1)
+// sign relative, sign bit (1 = +1, 65 = -1)
+// -> {role, n} | {master: 0..1023} | null (not one of them: on to the firmware)
+export const KNOB_CC = 20, MASTER_CC = 27, KNOB_MODES = ["abs", "bin", "twos", "sign"];
+export function midiKnob(last, cc, value, mode = "abs") {
+ if (cc === MASTER_CC) return { master: Math.round(value * 1023 / 127) };
+ const role = cc - KNOB_CC;
+ if (role < 0 || role >= 7) return null;
+ if (mode === "bin") return { role, n: value - 64 };
+ if (mode === "twos") return { role, n: value < 64 ? value : value - 128 };
+ if (mode === "sign") return { role, n: value < 64 ? value : 64 - value };
+ const was = last[role];
+ last[role] = value;
+ return { role, n: was === undefined ? 0 : value - was };
+}
+
+// The same processor also runs on the page's main thread (FeluccaCore) while the browser keeps the AudioContext suspended
+// (no click yet): the firmware boots and shows its screen silently, and the page hands over to the worklet at the first click.
+const clock = globalThis.performance ? () => globalThis.performance.now() : () => Date.now();
+const nowSec = () => (typeof currentTime === "number" ? currentTime : clock() / 1000);
+const Base = typeof AudioWorkletProcessor === "function" ? AudioWorkletProcessor : class { constructor() { this.port = { postMessage() {}, onmessage: null }; } };
+{
+ class Felucca extends Base {
+ constructor() {
+ super();
+ this.ex = null;
+ this.sentDraws = -1;
+ this.sentWrites = -1;
+ this.sentLeds = "";
+ this.lastFrame = 0;
+ this.period = 1 / 30;
+ this.busy = 0;
+ this.frames = 0;
+ this.queue = []; // button / key changes, each held >= HOLD_MS of device time
+ this.nextOk = 0;
+ this.port.onmessage = (e) => this.onMessage(e.data);
+ }
+
+ async onMessage(m) {
+ if (m.type === "load") {
+ try {
+ const { instance } = await WebAssembly.instantiate(m.wasm, {});
+ const ex = instance.exports;
+ ex._initialize();
+ ex.web_nor_erase();
+ restoreSectors(new Uint8Array(ex.memory.buffer, ex.web_nor(), ex.web_nor_size()), m.sectors);
+ ex.web_master(m.master ?? 700);
+ ex.web_boot();
+ this.ex = ex;
+ this.sentWrites = ex.web_flash_writes_count();
+ this.port.postMessage({ type: "ready", rate: ex.web_sample_rate() });
+ } catch (err) {
+ this.port.postMessage({ type: "error", message: String(err && err.message || err) });
+ }
+ return;
+ }
+ const ex = this.ex;
+ if (!ex) return;
+ if (m.type === "buttons" || m.type === "keys") this.queue.push(m);
+ else if (m.type === "enc") ex.web_enc(m.role, m.n | 0);
+ else if (m.type === "master") ex.web_master(m.value | 0);
+ else if (m.type === "midi") ex.web_midi(m.data[0] | 0, m.data[1] | 0, m.data[2] | 0);
+ else if (m.type === "visible") this.period = m.on ? 1 / 30 : 1 / 4;
+ }
+
+ publish() {
+ const ex = this.ex, mem = ex.memory.buffer;
+ const msg = { type: "frame" };
+ const leds = [ex.web_lit_buttons(), ex.web_lit_keys(), ex.web_dim_buttons(), ex.web_dim_keys(), ex.web_dim_level(),
+ ex.web_breath_buttons(), ex.web_breath_keys(), ex.web_mid_keys ? ex.web_mid_keys() : 0];
+ const an = ex.web_anim_levels ? ex.web_anim_levels() : 0; // the power-on sweep: each LED's level
+ const anim = an ? Array.from(new Uint8Array(mem, an, 41)) : null;
+ const key = leds.join(",") + (anim ? ";" + anim.join(",") : "");
+ if (key !== this.sentLeds) {
+ this.sentLeds = key;
+ msg.leds = leds;
+ msg.anim = anim;
+ }
+ if (this.frames >= 44100) { // the share of real time spent running the device
+ msg.load = this.busy / (this.frames / 44.1);
+ this.busy = this.frames = 0;
+ }
+ const transfer = [];
+ const draws = ex.web_screen_draws();
+ if (draws !== this.sentDraws) {
+ this.sentDraws = draws;
+ msg.fb = new Uint16Array(mem, ex.web_screen(), 240 * 240).slice();
+ transfer.push(msg.fb.buffer);
+ }
+ const writes = ex.web_flash_writes_count();
+ if (writes !== this.sentWrites) { // a save is done within one main-loop pass: whole here
+ this.sentWrites = writes;
+ msg.sectors = storeSectors(new Uint8Array(mem, ex.web_nor(), ex.web_nor_size()));
+ }
+ if (msg.leds || msg.fb || msg.sectors || msg.load !== undefined) this.port.postMessage(msg, transfer);
+ }
+
+ // A click's down and up can arrive within one render quantum, but the FM-1's contacts never close for less than
+ // its debounce, and the UI reads them once a frame: each change of the buttons or the keys stays HOLD_MS of the
+ // device's time before the next one goes in (a tap: down for a frame and more, then up).
+ input() {
+ const ex = this.ex, now = ex.web_now_ms();
+ while (this.queue.length && now - this.nextOk >= 0) {
+ const m = this.queue.shift();
+ if (m.type === "buttons") ex.web_buttons(m.mask >>> 0);
+ else ex.web_keys(m.mask >>> 0);
+ this.nextOk = now + HOLD_MS;
+ }
+ }
+
+ process(inputs, outputs) {
+ const ex = this.ex;
+ if (!ex) return true;
+ if (this.queue.length) this.input();
+ const out = outputs[0], n = out[0].length;
+ const t0 = clock();
+ ex.web_render(n);
+ this.busy += clock() - t0;
+ this.frames += n;
+ out[0].set(new Float32Array(ex.memory.buffer, ex.web_out_l(), n));
+ if (out[1]) out[1].set(new Float32Array(ex.memory.buffer, ex.web_out_r(), n));
+ if (nowSec() - this.lastFrame >= this.period) {
+ this.lastFrame = nowSec();
+ this.publish();
+ }
+ return true;
+ }
+ }
+ if (typeof registerProcessor === "function") registerProcessor("felucca", Felucca);
+ globalThis.FeluccaCore = Felucca;
+}
+export const FeluccaCore = globalThis.FeluccaCore;