mirror of
https://github.com/ruppert/fmini-1.git
synced 2026-12-06 12:54:23 +01:00
MENU > LARGE keeps one size per knob (#251): each knob shows all its values in the size its longest value fits, so a value no longer jumps between sizes while it is turned. No new fonts. Updates check the package's size on the device: the update entry and the update loader take only a package whose firmware area is exactly the FM-1's. Another device's package is refused before anything is erased (the update screen shows FAILED -15; the loader answers -14). Second core (beta, PR #247): MENU > SYSTEM > 2ND CORE, OFF by default. ON (BETA) applies from the next power-on: the second core renders some of the four parts of each block, bit for bit the one-core sound. A unit whose second core misreads goes on with one core and sets it back to OFF. FELUCCA_CPU2=0 builds none of it. Start, mailbox and guards from X0X (with Melodee's dual-core findings), the split and hardening after Jangada. Felucca-Engines: ANALOG, LOFI, TRIO, WHEEL and NOISE, the engine interface, the shared DSP helpers and their table generator move to https://github.com/hugelton/Felucca-Engines under the MIT licence, included as the git submodule firmware/engines. The firmware stays GPL-3.0-only; clone with --recurse-submodules. The sound is unchanged (the same golden renders); the engines' own tests run with Felucca's. Co-authored-by: Кирилл Сапфиров <gospodindilly@gmail.com>
83 lines
2.4 KiB
Python
83 lines
2.4 KiB
Python
# SPDX-License-Identifier: GPL-3.0-only
|
|
# Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
|
"""Minimal LZ4 *block* format (no frame), written for the Felucca loader
|
|
wrapper: greedy hash-chain-free compressor and a decoder for self-checks.
|
|
Spec: https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md
|
|
(min match 4, last 5 bytes literals, last match starts >= 12 bytes before the end)."""
|
|
|
|
|
|
def _len_bytes(n):
|
|
out = bytearray()
|
|
while n >= 255:
|
|
out.append(255)
|
|
n -= 255
|
|
out.append(n)
|
|
return out
|
|
|
|
|
|
def compress(src: bytes) -> bytes:
|
|
n, out, table = len(src), bytearray(), {}
|
|
anchor, i = 0, 0
|
|
limit = n - 12 # matches must start before this
|
|
while i < limit:
|
|
key = src[i:i + 4]
|
|
cand = table.get(key)
|
|
table[key] = i
|
|
if cand is None or i - cand > 65535:
|
|
i += 1
|
|
continue
|
|
mlen = 4 # extend; leave the last 5 bytes as literals
|
|
while i + mlen < n - 5 and src[cand + mlen] == src[i + mlen]:
|
|
mlen += 1
|
|
lit = src[anchor:i]
|
|
tok = (min(len(lit), 15) << 4) | min(mlen - 4, 15)
|
|
out.append(tok)
|
|
if len(lit) >= 15:
|
|
out += _len_bytes(len(lit) - 15)
|
|
out += lit
|
|
off = i - cand
|
|
out += bytes((off & 0xFF, off >> 8))
|
|
if mlen - 4 >= 15:
|
|
out += _len_bytes(mlen - 4 - 15)
|
|
i += mlen
|
|
anchor = i
|
|
lit = src[anchor:] # final literal run
|
|
out.append(min(len(lit), 15) << 4)
|
|
if len(lit) >= 15:
|
|
out += _len_bytes(len(lit) - 15)
|
|
out += lit
|
|
return bytes(out)
|
|
|
|
|
|
def decompress(blk: bytes, prefix: bytes = b"") -> bytes:
|
|
out, i = bytearray(prefix), 0
|
|
while i < len(blk):
|
|
tok = blk[i]
|
|
i += 1
|
|
ll = tok >> 4
|
|
if ll == 15:
|
|
while True:
|
|
b = blk[i]
|
|
i += 1
|
|
ll += b
|
|
if b != 255:
|
|
break
|
|
out += blk[i:i + ll]
|
|
i += ll
|
|
if i >= len(blk):
|
|
break
|
|
off = blk[i] | blk[i + 1] << 8
|
|
i += 2
|
|
ml = tok & 15
|
|
if ml == 15:
|
|
while True:
|
|
b = blk[i]
|
|
i += 1
|
|
ml += b
|
|
if b != 255:
|
|
break
|
|
ml += 4
|
|
for _ in range(ml):
|
|
out.append(out[-off])
|
|
return bytes(out[len(prefix):])
|