mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
- pm.js the device-neutral core (bank, names, files; the adapter interface in its header), pm-ui.js the panel (EN/ES, mobile-first, imported only when first opened), pm-fm.js JIANT FM's adapter: JIANT BYTE can mount the same panel with its own - pm-api.h: SAVE > PROJECT n (song_save_as) and LOAD (song_select), which the editor protocol has no command for; appended to the pinned felucca_web.c by emulator.yml as additive-api.h is, either edition, when the pin has song_save_as; worklet.js pmServe on the "edport" channel - emulator.yml / build.sh ship pm.js, pm-fm.js, pm-ui.js beside transfer.js - tests: pm_test.mjs (model + the firmware on both sides: 57 checks, Studio's readers included), browser_pm_test.mjs (Chromium: 26 checks, phone width, no Web MIDI, SMK-37, MPC) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
51 lines
2.6 KiB
C
51 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
|
|
/* (pm) The emulator page's Project Manager (web/emu/pm-ui.js, pm-fm.js) does everything else through the editor
|
|
* protocol (PROJ_LIST / PROJ_NAME / PROJ_OP 95..97, UP_LIST / UP_STORE / UP_LOAD / UP_ERASE 16..21, the backup objects
|
|
* 65..67, all answered by web_ed); two things the protocol has no command for, and the device's SAVE page does, are here,
|
|
* with the firmware's own functions:
|
|
* web_pm_name() 12 bytes + NUL: the name the next save gives the project ("" keeps the device's own choice)
|
|
* web_pm_save(n) SAVE > PROJECT n: the music as it plays now, its parts A..D and its song rows, into project n
|
|
* (song_save_as, the whole SONG: what SAVE does with NAME's KNOB 3 on SONG). The transport is
|
|
* stopped first, as the editor's saves stop it. 0 done, 1 refused (n, no flash), 2 failed, 3 playing
|
|
* web_pm_load(n) PROJECT n opened and its part A playing (song_select: the song layer's LOAD). 0 done, 1 refused,
|
|
* 3 playing, 5 already the open project
|
|
* web_pm_cur() the open project (bit 7: a generator draft, not saved yet)
|
|
* Appended to a pinned felucca_web.c by the site's build (.github/workflows/emulator.yml), as additive-api.h and
|
|
* transfer-api.h are; once (the guard). Nothing of the firmware changes for this file. */
|
|
#ifndef JIANT_PM_API
|
|
#define JIANT_PM_API 1
|
|
static char web_pm_nm[PROJ_NAME_LEN + 4u];
|
|
static void web_ms(void);
|
|
static uint32_t web_pm_stop(void) /* (editor.c ed_flash_stop's wait: the device's own clock) */
|
|
{
|
|
uint32_t t0 = fm1_ms;
|
|
if (!transport_busy()) return 0;
|
|
transport_req = 2;
|
|
while ((song.playing || chain_busy()) && fm1_ms - t0 < 200u) web_ms();
|
|
return transport_busy() ? 1u : 0u;
|
|
}
|
|
EXPORT char *web_pm_name(void) { return web_pm_nm; }
|
|
EXPORT uint32_t web_pm_save(uint32_t n)
|
|
{
|
|
uint32_t i;
|
|
web_pm_nm[PROJ_NAME_LEN] = 0;
|
|
for (i = 0; web_pm_nm[i]; i++)
|
|
if ((uint8_t)web_pm_nm[i] < 32u || (uint8_t)web_pm_nm[i] > 126u) return 1;
|
|
if (n >= NSONG) return 1;
|
|
if (web_pm_stop()) return 3;
|
|
song_save_loop = 0;
|
|
i = (uint32_t)song_save_as(n, web_pm_nm[0] ? web_pm_nm : 0);
|
|
proj_wire_gen++;
|
|
return i == 0 ? 0u : i == 1u ? 1u : 2u;
|
|
}
|
|
EXPORT uint32_t web_pm_load(uint32_t n)
|
|
{
|
|
if (n >= NSONG) return 1;
|
|
if (n == song_cur && !song_draft) return 5;
|
|
if (web_pm_stop()) return 3;
|
|
return song_select(n) ? 1u : 0u;
|
|
}
|
|
EXPORT uint32_t web_pm_cur(void) { return song_cur | (song_draft ? 128u : 0u); }
|
|
#endif
|