diff --git a/.github/workflows/voice-user-check.yml b/.github/workflows/voice-user-check.yml index c73303c4..bc16f3a0 100644 --- a/.github/workflows/voice-user-check.yml +++ b/.github/workflows/voice-user-check.yml @@ -308,6 +308,8 @@ jobs: build/emu/native-check build/emu/native.f32 cc -O2 -ffp-contract=off -w -Wno-implicit-function-declaration -Wno-incompatible-pointer-types -Ibuild/gen -Ifirmware/src web/emu/gen_web_test.c -lm -o build/emu/gen-web-test # (studio's RADIO page: web_gen_info / web_gen_cmd) build/emu/gen-web-test + cc -O2 -ffp-contract=off -w -Wno-implicit-function-declaration -Wno-incompatible-pointer-types -Ibuild/gen -Ifirmware/src web/emu/convert_web_test.c -lm -o build/emu/convert-web-test # (studio's converter: web_proj_load / web_proj_save) + build/emu/convert-web-test node web/emu/emu_test.mjs build/emu/felucca.wasm build/emu/native.f32 sha256sum build/emu/felucca.wasm # (for web/SPLIT_BETA.json emulator_sha256) - uses: actions/upload-artifact@v4 diff --git a/web/emu/convert_web_test.c b/web/emu/convert_web_test.c new file mode 100644 index 00000000..c625c1f5 --- /dev/null +++ b/web/emu/convert_web_test.c @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */ +/* (studio's converter, /emu-convert/: V10.8.50 + web_proj_load / web_proj_save) a project of before V10.7, which + * V10.8.51 refuses (OLD PROJECT: OPEN IN STUDIO), loaded here and saved in this build's FUNC: the saved bytes have + * the SLICER block and no old GM drum part, so V10.8.51's proj_import takes them. argv[1]: the saved bytes written + * there (for a check against the later code). */ +#include "felucca_web.c" +static int bad; +static void ck(const char *what, int ok) { printf("%-66s %s\n", what, ok ? "ok" : "FAIL"); bad += !ok; } +static void run(uint32_t blocks) { while (blocks--) web_render(512); } +static uint32_t old_image(int kind, project_store_t *out) /* kind 0: the old GM drum part; 1: no SLICER block */ +{ + static project_t o1, o2; + static project_store_t a2; + uint32_t at = 0, n2, hz; + project_capture(&o1); + if (kind == 0) { o1.t[3].preset = PROJ_DEF_KEEP; o1.sum = proj_sum(&o1); return proj_pack(out, &o1) ? PROJ_STORE_SIZE : 0u; } + o1.g[G_SLMODE] = 0; o1.sum = proj_sum(&o1); + o2 = o1; o2.g[G_SLMODE] = 1; o2.sum = proj_sum(&o2); + if (!proj_pack(out, &o1) || !proj_pack(&a2, &o2)) return 0; + while (at < PROJ_STORE_SIZE && out->raw[at] == a2.raw[at]) at++; + at -= 2u; + if (out->raw[at] != 'S' || out->raw[at + 1u] != 'L') return 0; + n2 = 2u + G_SL_N; /* (before JIANT 0.6.3) no such block */ + memmove(out->raw + at, out->raw + at + n2, PROJC_PFX_OFF - at - n2); + memset(out->raw + PROJC_PFX_OFF - n2, 0, n2); + hz = proj_hash(out->raw, PROJ_STORE_SIZE - 4u); memcpy(out->raw + PROJ_STORE_SIZE - 4u, &hz, 4); + return PROJ_STORE_SIZE; +} +int main(int argc, char **argv) +{ + static project_store_t old; + static project_t chk; + uint32_t n, len, kind; + web_nor_erase(); + web_boot(); + run(40); + web_gen(1u + 2u, 1791, 60, 2); /* some music to make the old project of */ + run(8); + for (kind = 0; kind < 2u; kind++) { + n = old_image((int)kind, &old); + ck(kind ? "a project of before 0.6.3 (no SLICER block) built" : "a project with the old GM drum part built", n != 0); + memcpy(web_bk_buf(), &old, n); + ck(" web_proj_load(1, len): 0 (converted, loaded)", web_proj_load(1, n) == 0); + run(20); + len = web_proj_save(); + ck(" web_proj_save: PROJ_STORE_SIZE bytes, FUNC", len == PROJ_STORE_SIZE && ((uint32_t *)web_bk_buf())[0] == PROJ_MAGIC); + ck(" the saved bytes load, with their SLICER block (V10.8.51 reads them)", + proj_import(&chk, web_bk_buf(), (int)len) && proj_sl_found == 1 && chk.t[3].preset != PROJ_DEF_KEEP); + if (kind == 1u && argc > 1) { FILE *f = fopen(argv[1], "wb"); if (f) { fwrite(web_bk_buf(), 1, len, f); fclose(f); } } + } + memset(web_bk_buf(), 0x5A, 64); + ck("bytes that are not a project: 2", web_proj_load(0, 64) == 2); + ck("slot 4: 2", web_proj_load(4, 64) == 2); + printf("convert-web: %s\n", bad ? "FAIL" : "all ok"); + return bad != 0; +} diff --git a/web/emu/felucca_web.c b/web/emu/felucca_web.c index 275dfd73..e21df132 100644 --- a/web/emu/felucca_web.c +++ b/web/emu/felucca_web.c @@ -694,6 +694,30 @@ EXPORT uint32_t web_bk_len(uint32_t id) /* the object as it is now, into web_b } return 0; } +/* (V10.8.51) Studio's converter: projects of before V10.7 are no longer read by the firmware (proj_import: OLD PROJECT: + * OPEN IN STUDIO); a build that still reads them (V10.8.50 and before) converts them through these two, without the UI. + * web_proj_load(slot, len): the len bytes in web_bk_buf() (a project as a slot stores it, any format this build reads) + * into section slot (0..3) of the current song, in RAM and flash, then loaded as LOAD does (project_load: it plays). + * 0 = done, 2 = not a project, 3 = too old for this build (OPEN IN STUDIO), 4 = flash error. + * web_proj_save(): the project playing now, packed in this build's format (FUNC, PROJ_STORE_SIZE bytes) into + * web_bk_buf(); its length, 0 = could not be packed. Send those bytes to the FM-1 as a slot (transfer.js). */ +EXPORT uint32_t web_proj_load(uint32_t slot, uint32_t len) +{ + uint8_t *raw = proj_wire_u.raw; + if (slot > 3u || len > sizeof proj_wire_u.raw) return 2; + if (!proj_import(&proj_scratch, raw, (int)len)) return proj_sl_found == 2 || proj_old(raw, (int)len) ? 3u : 2u; + proj_bound(&proj_scratch); + if (!proj_pack((project_store_t *)raw, &proj_scratch)) return 2; + memcpy(&proj_slot[slot], raw, sizeof proj_slot[0]); + if (st_save(proj_obj(slot), raw, sizeof(project_store_t))) return 4; + project_load(slot); + return 0; +} +EXPORT uint32_t web_proj_save(void) +{ + project_capture(&proj_scratch); + return proj_pack((project_store_t *)proj_wire_u.raw, &proj_scratch) ? (uint32_t)sizeof(project_store_t) : 0u; +} EXPORT void web_mix_skip(uint32_t mask) { mix_skip = (uint8_t)mask; } EXPORT uint32_t web_song_select(uint32_t n) { return (uint32_t)song_switch(n, 1); } /* 0 = done (stopped, n < 8) */ EXPORT uint32_t web_song_cur(void) { return song_cur; }