Files
JIANT/web/emu/wt-api.h
T
Claude 484643ecc2 Emulator: ADD found by the firmware's own report; WAVE's user tables work in the browser
- browser-additive-test.py: V10.8.87's engine order ends STRING ADD WAVE INPUT, so two
  steps back from DRUM landed on WAVE (9), not ADD (13), and run 47552111627 failed. KNOB 2
  now steps one detent at a time, asking the device after each, until it reports 13 (the
  engines passed are printed; same checks after: ADD, keyboard audio, edition, storage).
- wt-api.h (appended to a pin with editor_wt.c, as pm-api.h): the emulator never ran wt_boot
  (main.c does, FELUCCA_OTA only), so every WT_LIST / WT_BEGIN answered rc 4 and Studio
  could not upload a table; and WAVE reads the tables through hostsim.c's host_wt[], not
  the emulator's NOR, so a table stored there played silent. web_wt_boot after web_boot,
  web_wt_sync (host_wt = NOR 0xD0000..0xD7FFF when the flash was written) before each render.
- wavetable-test.mjs: a .jwt uploaded (102..104), listed, read back (106), played by WAVE
  from U1 (not as SINE), kept and played after a reboot; run by emulator.yml / emulator-beta.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-12-05 18:20:58 +00:00

43 lines
2.5 KiB
C

/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* (WAVE, editor protocol 1.7) the user wavetables U1..U6 in the emulator. Two things the FM-1 has and a pinned
* felucca_web.c does not:
* - the power-on check: main.c fm1_main runs editor_wt.c wt_boot (the directory's current copy, each table's CRC, which
* slots play); web_power_on does not (FELUCCA_OTA is 0 here), so eng_wave.c's wvs.sec[] stays all 0 ("a table in
* sector 0" for every slot): wt_dir then finds slots stored but no directory, and every WT_LIST / WT_BEGIN / WT_OP
* answers rc 4 (no flash): Studio cannot upload a table, and one restored from the page's saved flash never plays.
* - what WAVE reads: eng_wave.c reads the tables through XIP, WV_FLASH(off); the web build takes tests/hostsim.c's
* WV_FLASH, a host_wt[] of its own, not this file's NOR (nor[], which editor_wt.c writes through st_erase / st_prog):
* a table uploaded was stored and listed but played as zeros (silence). The FM-1 reads the flash itself, so here
* host_wt[] is kept the NOR's 0xD0000..0xD7FFF: copied whole whenever the flash was written since the last copy.
* The worklet calls web_wt_sync() before each render; every write to that area comes from a request (web_ed,
* web_sysex) handled between renders, so the audio always reads the NOR as it is, as on the device.
* web_wt_boot() the copy, then wt_boot, once the device is up and the page's saved flash restored (worklet.js
* calls it right after web_boot); again is harmless (it only reads the flash)
* web_wt_sync() the copy, only when the flash was written since the last one (a counter compare otherwise)
* Appended to a pinned felucca_web.c by the site's build (.github/workflows/emulator.yml, emulator-beta.yml) when the
* pin has editor_wt.c, as additive-api.h and pm-api.h are; once (the guard). Nothing of the firmware changes for this
* file. */
#ifndef JIANT_WT_API
#define JIANT_WT_API 1
_Static_assert(sizeof host_wt == 0x8000u && sizeof nor >= 0xD8000u, "the user wavetables' flash, 0xD0000..0xD7FFF");
static uint32_t web_wt_seen, web_wt_ever;
static void web_wt_copy(void)
{
memcpy(host_wt, nor + 0xD0000u, sizeof host_wt);
web_wt_seen = web_flash_writes;
web_wt_ever = 1;
}
EXPORT void web_wt_sync(void)
{
if (!web_wt_ever || web_wt_seen != web_flash_writes)
web_wt_copy();
}
EXPORT void web_wt_boot(void)
{
web_wt_copy();
if (web_booted && flash_ok)
wt_boot();
}
#endif