Files
JIANT/firmware/src/ui_draw.c
T
Claude ceec4ab2cb V10.8.45: the ARP on the transport's grid and recorded on its steps, GEN's sections half as long and each row its own colour, room freed (the owner)
(the owner: "the arp is not quantized, it should be on the 1/16 at least"; "in REC it has to be quantized")
- seq.c arp_step_do: playing (or counting in), a key's first arp step on its RATE's grid of the transport (the step this
  block holds, or one up to 20 ms back at once; armed: never late), then the sequencer's time (seq_n), so it stays there;
  stopped: from the key, as ever. It ran free from the key's block, on the DAC's samples
- rec_note_at: an arp's note recorded at its own step's sample (no key latency, whatever REC Q): on its step, MICRO 0
- tests/arp_grid_test.c (in the workflow): three tempos, four RATEs, 18 moments, every step on the grid; a recorded
  phrase every step its note, on its place, one a step

Room (the owner: "the CPU page out, the little purple bar a number, the velocity diagnostic too"): 720 B
- MENU > ABOUT: the CPU lines gone (clock, rails, crash); AUDIO LOAD stays
- the header's load: its per cent (0..99) in THEME where the five bars were, following the load once 3 away
- the velocity diagnostic out (captures, queue, console, vd_poll); the keys' velocity and pressure as they were; the
  editor's VEL answers as ever with the diagnostic off and nothing to read (web/vel.html: no presses, no captures);
  tests/vel_diag_test.c gone, vel_test / vel_seq_test stay

GEN (the owner: "a section lasts more than twice what it should, loops that do not evolve and come back the same;
every part its timbre, a story in the sound; the envelopes"; "the DJ FILTER's automations too long and abrupt";
"DANCE's decays too long, they cover the other layers"):
- a row half its bars and none over ~24 s (a slow tempo's shorter); RADIO's loop 16 / 8 / 4 bars (over 110 / over 74 /
  slower; were 32 / 16). MY LOOP's rows as they were
- a row its own colour: the scene's macros a row's own values (the first as the piece stands); a section come again
  (its fill row too): the lead's, the arp's and the free drums' lines ARRANGE's VAR 1 / 2 (rows that repeat a row
  before: 31 % -> 0)
- MOOD DANCE: the kit's DECAY a little shorter (was longer), the pump deeper (mood / 2)
- the build's high-pass: its last bar to 30 in eighths (was two bars to 48 in quarters)
- the envelopes: a held chord slower in (32) and longer out (80), a lead some release (32..63), the filter's envelope
  12 .. 27 on a bass, a lead, an arp (was 6 .. 13); towards CALM softer in and longer out
- tests: gen_entry_test (RADIO's 16 bars, MID's reference recorded again), ui_test (an arp with no transport's clock),
  tests/gen_sec.c (a study's tool: rows' seconds, repeats, envelopes)

Layout recorded again (FELUCCA_REPIN=keep: the arp's code in the RAM code); the plain build passes.
Image 583600 B of 584336 (736 B free), RAM 96832, RAM code 32688 of 34816, pool spare 8480 B, BT segment 73564 of
73728. audio.c as V23's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-11-25 16:34:27 +00:00

2332 lines
117 KiB
C

/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
* Portions Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* Felucca UI drawing: the header, the four knob cards, the footer (steps + engine / preset / page)
* and the frame; the panel between the cards and the footer is ui_graph.c. The layout:
* (V10.7.23) the knobs' cards outlined in their value's colour on BG, no box; panels on BG,
* rounded corners, no rules, colours from the theme tokens only (gfx.c T_*). Type: S (12 px) labels,
* M (15 px) values and the header, L (28 px) big numerals. (JIANT 0.6.56: S Chakra Petch, M IBM Plex Mono, L Michroma 18 px;
* the JIANT palette's boxes square with HUD corners, gfx.c cv_rrect). A card value too wide for M is set in S;
* free text (names, messages) is ellipsised at its size. */
static void draw_menu(void);
static int name_on(void); /* NAME (ui_name.c) */
static uint64_t lock_held(void); /* parameter locks: the steps held on STEP (ui_input.c) */
static void name_draw(void);
static void fill_around(const int16_t (*r)[4], uint32_t n); /* (0.9.0) BG round a screen's strips */
/* --------------------------------------------------------- drawing --- */
#define COL_W CARD_W /* a card: 57 x 44 at x 3 + 59 c, y 28 */
#define COL_H CARD_H
static int32_t batt_level(void) /* thresholds 531 / 561 / 591 on ADC ch3 */
{
return song.batt_raw >= 591 ? 3 : song.batt_raw >= 561 ? 2 : song.batt_raw >= 531 ? 1 : 0;
}
/* A USB host powers us; there is no separate charger status line.
* 4 means external power (a steady bolt inside the battery), otherwise its level. */
static int32_t batt_shown(void)
{
if (usb.config && !usb.suspended)
return 4;
return batt_level();
}
#define HEAD_MID 11 /* (0.8.5) the header's middle row: its ink centred on it (the
* rule at 22) */
/* REC: filled, the selected track armed; outlined, another track armed. (0.8.5, the mock-up's skin) a dot, 9 px, its
* ink centred on the header's row 11 in a 16 px cell at x (x + 3 .. x + 11) */
static void draw_rec_mark(int32_t x, uint16_t bg)
{
if (!song.rec)
return;
int ring = !((song.rec >> song.sel) & 1u);
cv_rrect(x + 3, HEAD_MID - 4, 9, 9, 4, T_REC, bg);
if (ring)
cv_rrect(x + 5, HEAD_MID - 2, 5, 5, 2, bg, T_REC);
}
/* the battery: (0.8.5, as the mock-up) an outline 13 x 9 (rows 7..15) and its charge inside, 0..3 thirds of 9 px
* (the stock thresholds); USB power (4): full, THEME. One third left: the accent; else MID */
static uint32_t batt_icon(int32_t lvl)
{
static const uint8_t I[5] = {ICON_X_BAT0, ICON_X_BAT1, ICON_X_BAT3, ICON_X_BAT4, ICON_X_BAT_CHG};
return I[clamp(lvl, 0, 4)];
}
/* (JIANT 0.5) the load: how much of the audio's time the sound takes now (audio.c song.cpu_q8, averaged).
* (V10.8.45, the owner: "the little purple bar a small number, clearer") its per cent, 0 .. 99, in THEME left of the
* battery; the number shown follows the load once it is 3 away (no flicker) */
static uint32_t head_load(void)
{
static uint8_t shown;
uint32_t p = (song.cpu_q8 * 100u) >> 8;
if (p > 99u) p = 99u;
if (p > shown + 2u || p + 2u < shown || !p) shown = (uint8_t)p;
return shown;
}
#define HEAD_LOAD_X 200 /* the load's number: 200 .. 218 */
static void draw_load(int32_t x)
{
char b[12];
fmt_int(b, (int32_t)head_load());
cv_text_r(x + 19, HEAD_MID - AF_X_CAP_H / 2 - AF_X_CAP_Y, &AF_X, b, T_THEME, T_BG);
}
static void draw_battery(int32_t bx)
{
int32_t lvl = batt_shown();
uint16_t c = lvl == 4 ? T_THEME : lvl == 1 ? T_ACCENT : T_MID;
cv_frame(bx, HEAD_MID - 4, 13, 9, c);
if (lvl)
cv_rect(bx + 2, HEAD_MID - 2, lvl >= 3 ? 9 : lvl * 3, 5, c);
}
/* ---------------------------------------------------- rolling digits --- */
/* A number that changes rolls its changed digits like a slot machine; only the drawing: the value, the gauge,
* the hot colour and the sound change at once. Up: the old digit leaves upward and the new one comes from below;
* down: the reverse. ROLL_FRAMES UI frames (ui.frame, ~135 ms) on an integer ease-out (ROLL_EASE: cubic, over
* half-way in a quarter of the time, no overshoot); the ones digit first, each place one frame later, all ending
* together on a frame equal to the static render. Clipped to the value strip, which alone is redrawn while it
* rolls (a card: rows ROLL_Y.., the header: the BPM's columns). Characters other than digits never roll.
* A change during a roll retargets it: it restarts from the value it was going to. Shown at once (no roll):
* a change within ROLL_SNAP frames of the last one (a fast turn reads better as plain numbers), another
* shape (length, sign, a non-digit, a name or an enum, a value set in S), another label or unit, a track /
* engine / palette change (ui.roll[].sig), ui.force (a page change), a card's first draw; MENU > ANIM OFF (#46). */
#define ROLL_FRAMES 9u
#define ROLL_SNAP 3u /* frames (~45 ms) */
#define ROLL_BPM 4u /* ui.roll[]: the four cards, then the header BPM */
#define ROLL_Y (lz_on() ? 14 : 18) /* a card's value strip: rows 18..34, its figures (21..31) in the middle, */
#define ROLL_H 17 /* the label (MONO's chip: to row 17) above it, the gauge (39) below;
* (0.8.5) a lens page's card (38 tall): rows 14..30, the figures
* 17..27, the gauge at 33) */
#define CARD_VY (ROLL_Y - 1) /* the value's line (M) */
#define CARD_XY 2 /* (0.8.5) a lens card's label (AF_X): its line, capitals rows 3..11 */
#define CARD_BG T_BG /* (V10.7.23, the owner) a card: no fill, on the background, its shape a
* line in its value's colour (card_line) */
/* (V10.7.23) a card's shape outlined lw px in c, its inside BG (r: its corners, 0 square). A knob's card: 1 px in its
* value's colour, so the line changes with it (the card's cache key holds that colour); 2 px the knob just turned */
static void card_line(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint16_t c, int32_t lw)
{
cv_rrect(x, y, w, h, r, c, T_BG);
cv_rrect(x + lw, y + lw, w - 2 * lw, h - 2 * lw, r > lw ? r - lw : r > 0, T_BG, c);
}
static const uint8_t ROLL_EASE[17] = {0, 45, 84, 118, 147, 172, 193, 210, 223, 234, 242, 247, 251, 253, 254, 255, 255};
static int roll_digit(char c) { return c >= '0' && c <= '9'; }
/* +1 / -1: b rolls in from a (same length, digits where a has digits, the rest equal and one of + - .),
* the sign of b - a; 0: b is shown at once */
static int roll_dir(const char *a, const char *b)
{
uint32_t i;
int d = 0, neg = 0;
for (i = 0; a[i] || b[i]; i++) {
if (i + 1u >= sizeof ui.roll[0].from || roll_digit(a[i]) != roll_digit(b[i]))
return 0;
if (!roll_digit(a[i]) && (a[i] != b[i] || (a[i] != '-' && a[i] != '+' && a[i] != '.')))
return 0;
neg |= a[i] == '-';
if (!d && a[i] != b[i])
d = b[i] > a[i] ? 1 : -1;
}
return neg ? -d : d;
}
/* field k now shows b instead of a: roll (a retarget mid-roll), or snap */
static void roll_note(uint32_t k, const char *a, const char *b, int snap)
{
uint32_t el = (uint8_t)(ui.frame - ui.roll[k].t0);
int d = roll_dir(a, b);
ui.roll[k].t0 = (uint8_t)ui.frame;
ui.roll[k].from[0] = 0;
if (snap || !d || el < ROLL_SNAP || ANIM_SNAP())
return;
str_cpy(ui.roll[k].from, a, sizeof ui.roll[k].from);
ui.roll[k].dir = (int8_t)d;
}
/* s (M) at x, y with field k's roll: each character at its pen in s (the digits are tabular and never kerned,
* so the old value has the same pens); a rolling digit has moved o of the strip's h rows (ROLL_EASE, one frame
* later per place from the right), clipped to the strip. The roll's last frame clears it: the static text. */
static int32_t roll_text(uint32_t k, int32_t x, int32_t y, const char *s, uint16_t fg, const aafont_t *f) /* (f: M, the
* header's BPM too; V, a card's number) */
{
uint32_t e = (uint8_t)(ui.frame - ui.roll[k].t0) + 1u, i, p = 0;
const char *a = ui.roll[k].from;
int32_t cy = k < ROLL_BPM ? ROLL_Y : 0, h = k < ROLL_BPM ? ROLL_H : HEAD_RULE_Y; /* (above the header's rule) */
uint16_t bg = k < ROLL_BPM ? CARD_BG : T_BG;
char t[8], ch[2] = {0, 0};
if (e >= ROLL_FRAMES)
ui.roll[k].from[0] = 0;
if (!a[0])
return cv_text_on(x, y, f, s, fg, bg);
str_cpy(t, s, sizeof t);
for (i = 0; s[i]; i++)
p += (uint32_t)roll_digit(s[i]);
cv_cy0 = (int16_t)(cy + cv_oy); /* the strip (the static characters lie inside it) */
cv_cy1 = (int16_t)(cy + cv_oy + h);
cv_scroll = 1; /* (the lint: rolling digits are cut on purpose) */
for (i = 0; s[i]; i++) {
int32_t px, ny = y;
t[i] = 0;
px = x + text_w(f, t); /* (its pen: no digit kerns) */
t[i] = s[i];
p -= (uint32_t)roll_digit(s[i]);
if (s[i] != a[i]) { /* p: the places right of it */
int32_t o = 0, dir = ui.roll[k].dir;
if (e > p) /* (e < ROLL_FRAMES: the LUT index stays in 1..16) */
o = (int32_t)((ROLL_EASE[((e - p) * 32u / (ROLL_FRAMES - p) + 1u) >> 1] * (uint32_t)h + 128u) >> 8);
ch[0] = a[i];
cv_text_on(px, y - dir * o, f, ch, fg, bg);
ny = y + dir * (h - o);
}
ch[0] = s[i];
cv_text_on(px, ny, f, ch, fg, bg);
}
cv_cy0 = 0;
cv_cy1 = (int16_t)cv_h;
cv_scroll = 0;
return x + text_w(f, s);
}
/* the header (y 0..24). (0.8.5) The approved mock-up's skin: one quiet line over a LINE rule at row 22,
* left (0.8.9, the skins' mock-up: the 0.6 colours) the selected track's number in an ACCENT box (4..16), the play
* state (x 22: stopped a MID square, playing a THEME triangle, counting in the accent) and the BPM large, in M
* (THEME; the knob turning it: the accent) from x 35, then BPM LOCK's lock and the REC mark (a dot: filled the
* selected track armed, a ring another)
* centre what the page is of, centred on x 120 (MID): "T1 . ANALOG ACID" (the track, its engine and sound), on the
* song's pages (SAVE, ARRANGE, TOOLS, GLOBAL) "P1 NAME" (the project), on FX "T1" (the accent)
* right the octave ("OCT +2"), or the song row while a song plays (the disc and its number), ending at 196; the load
* (five bars 200..218) and the battery (222..234)
* A message or a layer's label replaces the centre and the octave, centred on x 120, up to 158 px; while the BPM is
* being changed (a SELECT turn: bpm_t) or in the GLO layer the BPM stays and the message goes right of it (over the
* right slot). Every element's ink centred on row 11 (HEAD_MID; ui_test.c test_head_centres): S's capitals rows 7..15 */
#define HEAD_SY (HEAD_MID - AF_S_CAP_H / 2 - AF_S_CAP_Y)
#define HEAD_XY (HEAD_MID - AF_X_CAP_H / 2 - AF_X_CAP_Y) /* (0.8.5) the centre's words in AF_X: capitals rows 8..14 */
#define HEAD_MY CAP_IN(M, H_HEAD) /* (the menu's and the calibration's own headers: M) */
#define HEAD_BMY (HEAD_MID - AF_M_CAP_H / 2 - AF_M_CAP_Y) /* (0.8.9) the BPM in M: capitals rows 6..16 */
#define HEAD_TK_X 4 /* (0.8.9) the track's box: 4 .. 16, rows 5 .. 17 */
#define HEAD_TR_X 22 /* the play state's ink: 22 .. 29 */
#define HEAD_BPM_X 35 /* the BPM's pen */
#define HEAD_BAT_X 222 /* the battery's outline: 222 .. 234 */
#define HEAD_GRP_R 196 /* the octave / song row ends here */
#define HEAD_MSG_W 158 /* a message centred on x 120: 41..199 */
#define HEAD_GAP 5 /* ink to ink: the BPM -> the lock -> the REC mark */
/* the BPM's pen and ink (b), the play state's ink (mx0 .. mx1), the BPM's rolling strip (sx0 .. sx1): placed by as many
* 0s as the BPM has digits (tabular figures), so nothing moves while the tempo changes */
typedef struct { int32_t bx, b[4], mx0, mx1, sx0, sx1; } head_geo_t;
static void head_geo(head_geo_t *g, const char *bpm)
{
char z[8] = "0000000";
z[str_len(bpm) < 7u ? str_len(bpm) : 7u] = 0;
g->bx = HEAD_BPM_X;
text_ink(&AF_M, z, g->b);
g->mx0 = HEAD_TR_X;
g->mx1 = HEAD_TR_X + 8;
g->sx0 = g->mx1 + 1;
g->sx1 = g->bx + g->b[2] + 2;
}
static void head_transport(void)
{
int32_t r;
uint16_t c = seq_counting() ? T_ACCENT : song.playing ? T_THEME : T_MID;
if (!song.playing && !seq_counting()) {
cv_rect(HEAD_TR_X, HEAD_MID - 4, 8, 9, c);
return;
}
for (r = 0; r < 11; r++) /* (0.8.9) a triangle, 8 x 11, pointing right */
cv_rect(HEAD_TR_X, HEAD_MID - 5 + r, 1 + (5 - (r < 5 ? 5 - r : r - 5)) * 7 / 5, 1, c);
}
static void sound_name(const track_t *t, char *b);
/* the centre's words (b holds 40) and their colour */
/* (V10.8.10) a page of the selected track: its bar in the header, TRACK N / ENGINE on the track's colour (not HOME,
* MENU, a layer, GLO, SAVE, SLOTS, the song's, TOOLS: their title as before) */
static int head_trk(void)
{
const page_t *pg = cur_page();
return !ui.home && !ui.menu && !ui.layer && !(pg->graph == GR_SLOTS || pg->graph == GR_SONG || pg->graph == GR_TOOLS ||
pg->fam == FAM_GLO || pg->fam == FAM_TRK || pg->fam == FAM_SAVE);
}
static uint16_t head_title(char *b)
{
const page_t *pg = cur_page();
int glob = !ui.home && !ui.layer && (pg->graph == GR_SLOTS || pg->graph == GR_SONG || pg->graph == GR_TOOLS ||
pg->fam == FAM_GLO || pg->fam == FAM_SAVE);
if (ui.menu) { /* (0.8.5) the menu: "MENU . DISPLAY", "ABOUT / CREDITS" */
str_cpy(b, ui.menu == 2 ? "ABOUT / CREDITS" : "MENU \xB7 ", 40);
if ((ui.menu | 2u) == 3u)
str_cpy(b + str_len(b), MTAB_NAME[MI_TAB[ui.menu_sel % MI_COUNT]], 16);
return T_MID;
}
if (head_trk()) { /* (V10.8.10) "TRACK 3 / DRUM-X" */
str_cpy(b, "TRACK 1 / ", 40);
b[6] = (char)('1' + song.sel % NTRK);
str_cpy(b + 10, trk_engp(TSEL)->name, 16);
return trk_col(song.sel);
}
b[0] = 'T';
b[1] = (char)('1' + song.sel % NTRK);
b[2] = 0;
if (glob) {
char nm[16];
b[0] = 'P';
fmt_int(b + 1, (int32_t)song_cur + 1);
if (graph_project_used(0) && graph_project_name(0)[0]) /* (0.8.5) the project's name: its section A's (as the */
str_cpy(nm, graph_project_name(0), sizeof nm); /* library's), else the slot's last loaded / saved */
else
project_cur_name(nm);
str_cpy(b + str_len(b), " ", 2);
str_cpy(b + str_len(b), nm[0] ? nm : "NO NAME", 16);
return T_MID;
}
str_cpy(b, trk_engp(TSEL)->name, 12); /* (it began "T1 . ": the track's number stands in its box at
* the left; the room is the sound's name's) */
sound_name(TSEL, b + str_len(b) + 1u);
if (b[str_len(b) + 1u])
b[str_len(b)] = ' ';
return T_MID;
}
/* a message / a layer's label at x, or centred on x 120 (x < 0), at most maxw px with its
* icon (ui.c MSG_NOFILE: the accent's) */
static void head_msg(int32_t x, int32_t maxw)
{
const char *m = ui.msg_t ? ui.msg : layer_head();
int icon = m[0] == MSG_NOFILE[0];
int32_t iw = icon ? text_w(&AF_X, "!") + KH_GAP : 0;
/* (0.8.9) a message or a layer's name ("[GLO] SET", "[FX] LATCH") in plain words, AF_X as the header's centre
* (was S with a keycap, Felucca's): a message TEXT, a layer THEME */
if (x < 0)
x = 120 - HALF_UP(iw + (text_w(&AF_X, m + icon) < maxw - iw ? text_w(&AF_X, m + icon) : maxw - iw));
if (icon) { /* (0.8.5: no icons; "!" in the accent) */
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
x = cv_text(x, HEAD_XY, &AF_X, "!", T_ACCENT) + KH_GAP;
}
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
cv_free_text(x, HEAD_XY, &AF_X, m + icon, ui.msg_t ? T_TEXT : T_THEME, T_BG, maxw - iw);
}
/* the octave, or the song row while a song plays, its right end at HEAD_GRP_R; its left end */
static int32_t head_group(void)
{
char b[8];
int32_t x, x0;
if (chain.running) {
fmt_int(b, (int32_t)chain.row + 1);
x0 = x = HEAD_GRP_R - (12 + 3 + text_w(&AF_S, b));
cv_rrect(x + 1, HEAD_MID - 5, 10, 10, -5, T_MID, T_BG); /* SONG: the disc (drawn, 0.8.5) */
cv_rect(x + 5, HEAD_MID - 1, 2, 2, T_BG);
x += 12 + 3;
} else {
str_cpy(b, song.octave > 0 ? "+" : "", sizeof b);
fmt_int(b + str_len(b), song.octave);
x0 = x = HEAD_GRP_R - (text_w(&AF_S, "OCT") + 4 + text_w(&AF_S, b));
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
x = cv_text(x, HEAD_SY, &AF_S, "OCT", T_MID) + 4;
}
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
cv_text(x, HEAD_SY, &AF_S, b, T_THEME);
return x0;
}
static void draw_head(void)
{
char b[16], ttl[40];
head_geo_t g;
uint16_t tc = head_title(ttl);
uint32_t rec = (song.rec >> song.sel) & 1u ? 2u : song.rec != 0u; /* 2 the selected track armed, 1 another */
uint32_t sig = (uint32_t)song.playing * 3u + rec * 5u + (uint32_t)(song.octave + 8) * 11u + song.sel * 13131u +
(ui.msg_t ? str_hash(7u, ui.msg) : ui.layer * 7919u) + (uint32_t)song.g[G_BPM] * 101u + (ui.bpm_t != 0) * 31u +
(uint32_t)seq_counting() * 7u + (ui_prefs & PREF_BPM_LOCK) * 4099u +
(uint32_t)batt_shown() * 7777u + (chain.running ? (chain.row + 1u) * 104729u : 0u) +
head_load() * 0x9E3779B1u + str_hash(tc, ttl) * 3u;
int msg = ui.msg_t || ui.layer;
int centre = !msg || ui.bpm_t || ui.layer == LAYER_GLO; /* the BPM being changed: it stays, the message right */
int32_t lx, r = HEAD_LOAD_X - 6;
if (song.g[G_BPM] != ui.roll_bpm) {
char a[8];
fmt_int(a, ui.roll_bpm);
fmt_int(b, song.g[G_BPM]);
roll_note(ROLL_BPM, a, b, ui.force);
ui.roll_bpm = song.g[G_BPM];
} else if (ui.force) {
ui.roll[ROLL_BPM].from[0] = 0;
}
fmt_int(b, song.g[G_BPM]);
head_geo(&g, b);
if (!ui.force && sig == ui.head_sig) {
if (ui.roll[ROLL_BPM].from[0]) { /* rolling: the BPM's strip only (the rule under it again) */
cv_begin((uint32_t)(g.sx1 - g.sx0), H_HEAD, T_BG);
roll_text(ROLL_BPM, g.bx - g.sx0, HEAD_BMY, b, ui.bpm_t ? T_ACCENT : T_THEME, &AF_M);
cv_rect(0, HEAD_RULE_Y, g.sx1 - g.sx0, 1, T_LINE);
cv_blit((uint32_t)g.sx0, Y_HEAD);
}
return;
}
ui.head_sig = sig;
cv_begin(240, H_HEAD, T_BG);
if (!ui.menu) { /* (0.8.9) the track's box, as the 0.6 had it */
char n[2] = {(char)('1' + song.sel % NTRK), 0};
cv_rrect(HEAD_TK_X, HEAD_MID - 6, 13, 13, 3, trk_col(song.sel), T_BG); /* (V10.8.10: the track's colour) */
GFX_HOOK_ALIGN(HEAD_TK_X, HEAD_MID - 6, HEAD_TK_X + 13, HEAD_MID + 7, AL_HV, "header track number in its box");
cv_text_in(HEAD_TK_X, HEAD_XY, 13, &AF_X, n, 0x0000u, trk_col(song.sel));
}
head_transport();
if (!ui.roll[ROLL_BPM].from[0])
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
roll_text(ROLL_BPM, g.bx, HEAD_BMY, b, ui.bpm_t ? T_ACCENT : T_THEME, &AF_M);
lx = g.bx + g.b[2]; /* the right end of the BPM's ink (and what follows it) */
if (ui_prefs & PREF_BPM_LOCK) { /* BPM LOCK ON (#58): the lock right of the BPM */
int32_t x = lx + HEAD_GAP; /* (0.8.5: drawn) a shackle over a body, 8 x 10 */
cv_rect(x + 2, HEAD_MID - 5, 4, 1, T_MID);
cv_rect(x + 1, HEAD_MID - 4, 1, 3, T_MID);
cv_rect(x + 6, HEAD_MID - 4, 1, 3, T_MID);
cv_rect(x, HEAD_MID - 1, 8, 6, T_MID);
lx += HEAD_GAP + 8;
}
if (song.rec) { /* REC: its dot (x + 3 .. x + 11 of its cell) */
draw_rec_mark(lx + HEAD_GAP - 3, T_BG);
lx += HEAD_GAP + 9;
}
if (!msg && (chain.running || song.octave))
r = head_group() - 6;
if (!msg && head_trk()) { /* (V10.8.10) the track's bar: BPM .. load, its colour */
cv_rrect(lx + 6, HEAD_MID - 8, r - lx - 6, 17, 4, tc, T_BG);
cv_text_in(lx + 6, HEAD_XY, r - lx - 6, &AF_X, ttl, trk_ink(song.sel), tc);
} else if (!msg) { /* the centre's words on x 120, between the BPM and the right */
int32_t w = text_w(&AF_X, ttl), x = 120 - HALF_UP(w), l = lx + 8;
if (x + w > r) x = r - w;
if (x < l) x = l;
GFX_HOOK_ALIGN(0, 0, 0, HEAD_RULE_Y, AL_V, "header text on its middle");
cv_free_text(x, HEAD_XY, &AF_X, ttl, tc, T_BG, r - x); /* (0.8.5: AF_X, the mock-up's small mono) */
} else if (centre) { /* right of the BPM, over the right slot */
int32_t x = lx + 9 > 142 ? lx + 9 : 142;
head_msg(x, 236 - x);
} else { /* centred on x 120, clear of the BPM and the REC mark */
head_msg(-1, lx + 8 > 120 - HEAD_MSG_W / 2 ? 2 * (120 - (lx + 8)) : HEAD_MSG_W);
}
if (!(msg && centre)) {
draw_battery(HEAD_BAT_X);
draw_load(HEAD_LOAD_X);
}
cv_rect(0, HEAD_RULE_Y, 240, 1, T_LINE); /* the rule */
GFX_HOOK_RULE(0, HEAD_RULE_Y, 240, 1);
cv_blit(0, Y_HEAD);
}
/* full redraw: the strips (header, cards, panel, footer) cover the rest; only the BG between them is filled.
* (0.8.5, the mock-up's skin) the cards RAISE boxes: no dividers between them (LINE: its rules) */
static void draw_frame(void)
{
uint32_t i, ch = card_h(), gy = graph_y(), gh = graph_h(), cy = card_y(), fy = foot_y(); /* (MENU > LARGE: tall
* cards, a strip; 0.8.5 a lens page: the mock-up's) */
lcd_fill(0, H_HEAD, 240, cy - H_HEAD, T_BG);
lcd_fill(0, cy + ch, 240, gy - cy - ch, T_BG);
lcd_fill(0, gy + gh, 240, fy - gy - gh, T_BG);
lcd_fill(0, cy, (uint32_t)CARD_X(0), ch, T_BG);
for (i = 0; i < 4u; i++) /* right of each card */
lcd_fill((uint32_t)(CARD_X(i) + CARD_W), cy, i < 3u ? (uint32_t)(CARD_X(i + 1u) - CARD_X(i) - CARD_W) :
240u - (uint32_t)(CARD_X(i) + CARD_W), ch, T_BG);
}
/* MOTION on the cards (#63: values that move on their own): the selected track's motion-driven parameters
* (motion.c motion_mask: PLAY ON and an event for the id), once per draw_columns; card_mot_next is set just
* before a draw_column of a track parameter (card_mot_of) and taken by it; card_mot: the cards drawn with it. */
static uint32_t card_mot_mask[(P_COUNT + 31u) / 32u];
static uint8_t card_mot_next, card_mot;
static void card_mot_of(const int16_t *vp)
{
uintptr_t id = ((uintptr_t)vp - (uintptr_t)TSEL->p) / sizeof *vp; /* (not the track's: huge) */
card_mot_next = (uint8_t)(id < P_COUNT && ((card_mot_mask[id / 32u] >> (id % 32u)) & 1u));
}
/* MENU > LARGE, a tall card (ui.c LK_TALL; 57 x LG_CARD_H): which knob it is (a "K1" pill in M, the keycap's colours,
* the accent while it turns, DIM when the knob does nothing here) and the icon at the right of it; the label in M
* centred (S when M is too wide); the value centred in L, its figures twice the height of M (M, then S, when L is too
* wide or the sparse L face lacks a glyph: gen_aa_font.py L_CHARS); the unit (S) centred under it; the gauge. The
* value snaps (no rolling digits). MONO, the knob just turned: the label inverted as on the small cards. */
#ifndef LARGE_HOOK
#define LARGE_HOOK(s, why) ((void)0) /* host: a tall card's value and its face (0 L, 1 M: a glyph not
* in L, 2 M: L too wide, 3 S) */
#endif
#define LG_MY 4 /* the K pill: rows 4..21 */
#define LG_MH 18
#define LG_LY 24 /* the label's line: M capitals rows 28..38 */
#define LG_VB 49 /* the value's band: L capitals rows 49..69 */
#define LG_UY 73 /* the unit's line (S capitals rows 76..84) */
#define LG_GY 92 /* the gauge, 3 px */
/* a card's gauge and value: (0.8.5, the mock-up) the gauge THEME, the value TEXT; only the knob just turned (T_ACCENT)
* stands out. (0.9.5, as the 0.6.36 had it) JIANT (thermal): each card's colour its value as heat, violet low .. cream
* high, the gauge in it and the value lifted a fifth toward the text (so the cold end reads); a bipolar parameter (its
* range across 0) by its distance from the centre, cold in the middle */
static uint8_t card_bip; /* the card being drawn: a bipolar parameter (ratio_of) */
static uint16_t gauge_col(int32_t ratio)
{
return heat_on(ratio) ? card_heat(ratio, card_bip) : T_THEME;
}
static uint16_t value_col(uint16_t vc, int32_t ratio)
{
if (vc != T_THEME)
return vc;
return heat_on(ratio) ? ux_mix(gauge_col(ratio), T_TEXT, 20) : T_TEXT;
}
static uint8_t card_free_next; /* (0.8.5) the next draw_column's value is a name: free text */
static uint8_t card_arm_next; /* (0.8.5) the next draw_column is an action armed (OCT+ does it):
* the card TINT, its label THEME, as the mock-up's */
static void draw_column_tall(uint32_t c, const char *label, const char *val, const char *unit, uint16_t vc, int32_t ratio,
uint32_t icon, int hot, int mot, int32_t kid)
{
uint16_t lc = hot ? T_ACCENT : mot ? T_THEME : T_MID;
const aafont_t *lf = &AF_M, *vf = &AF_L;
int32_t ly = LG_LY, vy, lw = 0, mw;
char k[3] = {'K', (char)('1' + c), 0};
uint32_t ic = mot ? ICON_X_MOTION : icon, isz = 16u;
cv_begin(COL_W, LG_CARD_H, T_BG);
card_line(0, 0, COL_W, LG_CARD_H, 4, label[0] || val[0] ? vc : T_LINE, 1 + (hot && vc != T_DIM)); /* (V10.7.23:
* no box, its line) */
{ /* the knob: "K1" .. "K4" on a pill */
uint16_t fill = hot ? T_ACCENT : label[0] || val[0] ? T_KEY : T_DIM;
mw = ink_w(&AF_M, k) + 10;
cv_rrect(5, LG_MY, mw, LG_MH, 5, fill, T_BG);
GFX_HOOK_ALIGN(5, LG_MY, 5 + mw, LG_MY + LG_MH, AL_HV, "large card knob pill");
cv_text_in(5, LG_MY + CAP_IN(M, LG_MH), mw, &AF_M, k, T_INK, fill);
}
if (!label[0] && !val[0]) { /* a knob that does nothing on this page */
cv_blit((uint32_t)CARD_X(c), card_y());
return;
}
(void)ic; (void)isz;
if (mot && label[0]) { /* (0.8.5: no icons) MOTION: a dot on the pill's line */
GFX_HOOK_ALIGN(0, LG_MY, 0, LG_MY + LG_MH, AL_V, "large card icon on its pill's line");
cv_rrect(COL_W - 5 - 12, LG_MY + HALF_UP(LG_MH - 8), 8, 8, -4, hot ? T_ACCENT : T_THEME, T_BG);
}
if (label[0]) {
if ((lw = ink_w(lf, label)) > COL_W - 6) { /* M too wide: S, on the same capitals' middle */
lf = &AF_S;
ly = LG_LY + AF_M_CAP_Y + HALF_UP(AF_M_CAP_H - AF_S_CAP_H) - AF_S_CAP_Y;
lw = ink_w(lf, label);
}
GFX_HOOK_ALIGN(0, 0, COL_W, 0, AL_H, "large card label centred");
cv_text_in(0, ly, COL_W, lf, label, lc, T_BG);
}
if (kid >= 0) { /* "[OCT+]": the keycap, centred */
GFX_HOOK_ALIGN(0, LG_VB, COL_W, LG_VB + AF_L_CAP_H, AL_HV, "large card keycap centred");
cv_keycap(HALF_UP(COL_W - kc_w((uint32_t)kid)), LG_VB + HALF_UP(AF_L_CAP_H - KC_H), (uint32_t)kid,
vc == T_ACCENT || vc == T_DIM ? vc : T_KEY, T_INK, T_BG);
} else if (val[0]) {
int why = !large_face_has(val) ? 1 : ink_w(vf, val) > COL_W - 6 ? 2 : 0;
if (why) /* (a number L cannot hold: V, the same 14 px capitals, narrower) */
vf = face_has(&AF_V, val) && ink_w(&AF_V, val) <= COL_W - 6 ? &AF_V : &AF_M;
if (vf == &AF_M && ink_w(vf, val) > COL_W - 6)
vf = &AF_S, why = 3;
LARGE_HOOK(val, why);
vy = vf == &AF_L ? LG_VB - AF_L_CAP_Y : vf == &AF_V ? LG_VB + HALF_UP(AF_L_CAP_H - AF_V_CAP_H) - AF_V_CAP_Y :
vf == &AF_M ? LG_VB + HALF_UP(AF_L_CAP_H - AF_M_CAP_H) - AF_M_CAP_Y
: LG_VB + HALF_UP(AF_L_CAP_H - AF_S_CAP_H) - AF_S_CAP_Y;
if (vf == &AF_S && ink_w(vf, val) > COL_W - 2) { /* (a value always fits: the lint reports one cut) */
cv_text_fit(2, vy, vf, val, vc, T_BG, COL_W - 4);
} else {
GFX_HOOK_ALIGN(0, LG_VB, COL_W, LG_VB + AF_L_CAP_H, AL_HV, "large card value centred");
cv_text_in(0, vy, COL_W, vf, val, vc, T_BG);
}
}
if (unit[0]) {
GFX_HOOK_ALIGN(0, 0, COL_W, 0, AL_H, "large card unit centred");
cv_text_in(0, LG_UY, COL_W, &AF_S, unit, T_MID, T_BG);
}
if (ratio >= 0) {
int32_t gw = COL_W - 10, fx = ratio * gw / 1000;
cv_rrect(5, LG_GY, gw, 3, 1, T_LINE, T_BG);
cv_rrect(5, LG_GY, fx < 3 ? 3 : fx, 3, 1, hot ? T_ACCENT : vc == T_DIM ? T_DIM : gauge_col(ratio), T_LINE);
}
cv_blit((uint32_t)CARD_X(c), card_y());
}
/* one card = one knob: [icon] LABEL / value unit / gauge, the card's shape a line in the value's colour (V10.7.23: no box;
* 2 px the knob just turned), redrawn only when it changed (the value's colour is in its cache key).
* The value is M, or S when M is too wide (engine names, long ENUMs); the unit S after it. The gauge is
* a 3 px rounded bar: BG track, THEME fill. The knob just turned (hot): icon, label, value and gauge in
* the accent. ratio: 0..1000 for the gauge, -1 = no gauge. icon: ICON_* (icons.c), ICON_AUTO = by label;
* a label too long to share the card with its icon goes without it. A parameter MOTION drives (card_mot_next):
* the motion icon in place of its own, in the theme colour; a long label moves it left, up to the card's edge;
* a label with no room for it at all (or FELUCCA_ICONS=0): the label in the theme colour.
* vc: the value's colour (T_THEME, T_DIM inactive, T_ACCENT the knob just turned) */
/* (0.8.5) a held layer's cards as drawn (ui_layer.c: its KNOBS level draws them as gauges) */
/* (0.8.9, the skins' mock-up: the 0.6 cards' marks) a 7 x 7 mark before a card's label, by the label (a row a byte, bit 6
* the left column); none for the others (or a label too long to sit after one) */
static const uint8_t CARD_ICO[14][7] = {
{0x70, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01}, {0x08, 0x14, 0x14, 0x62, 0x02, 0x01, 0x01}, /* cut res */
{0x08, 0x14, 0x23, 0x20, 0x40, 0x40, 0x40}, {0x70, 0x08, 0x04, 0x04, 0x02, 0x01, 0x01}, /* atk rel */
{0x04, 0x0C, 0x14, 0x24, 0x44, 0x04, 0x04}, {0x41, 0x22, 0x14, 0x08, 0x14, 0x22, 0x41}, /* wave detune */
{0x22, 0x22, 0x72, 0x27, 0x22, 0x22, 0x22}, {0x20, 0x2A, 0x6B, 0x7F, 0x5D, 0x09, 0x08}, /* mix noise */
{0x7F, 0x41, 0x5D, 0x5D, 0x41, 0x7F, 0x00}, {0x0C, 0x0A, 0x09, 0x08, 0x38, 0x78, 0x30}, /* step note */
{0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, {0x08, 0x1C, 0x3E, 0x08, 0x08, 0x08, 0x08}, /* type accent */
{0x77, 0x41, 0x41, 0x00, 0x41, 0x41, 0x77}, {0x08, 0x08, 0x08, 0x49, 0x2A, 0x1C, 0x08}}; /* size depth */
static const struct { char l[7]; uint8_t i; } CARD_ICO_OF[] = {
{"CUT", 0}, {"FREQ", 0}, {"RES", 1}, {"PEAK", 1}, {"Q", 1}, {"ATK", 2}, {"REL", 3}, {"DEC", 3}, {"DECAY", 3},
{"WAVE", 4}, {"WAVE2", 4}, {"SHAPE", 4}, {"DETUNE", 5}, {"MIX", 6}, {"LEVEL", 6}, {"NOISE", 7}, {"CRUSH", 7},
{"STEP", 8}, {"LEN", 8}, {"NOTE", 9}, {"PITCH", 9}, {"TUNE", 9}, {"ROOT", 9}, {"TYPE", 10}, {"MODE", 10},
{"TIME", 10}, {"ACCENT", 11}, {"FLAG", 11}, {"SIZE", 12}, {"DEPTH", 13}, {"AMT", 13}};
static int32_t card_ico(const char *label) /* its mark, -1 none */
{
uint32_t k;
for (k = 0; k < NELEM(CARD_ICO_OF); k++)
if (str_eq(CARD_ICO_OF[k].l, label))
return CARD_ICO_OF[k].i;
return -1;
}
static void card_ico_draw(int32_t x, int32_t y, uint32_t i, uint16_t c)
{
uint32_t r, b;
for (r = 0; r < 7u; r++)
for (b = 0; b < 7u; b++)
if ((CARD_ICO[i][r] >> (6u - b)) & 1u)
cv_pset(x + (int32_t)b, y + (int32_t)r, c);
}
static struct { int16_t r; uint8_t b; char l[12], v[16]; } ly_card[4]; /* (b: bipolar) */
/* (0.9.1) GLO > MIXER KNOB 4, the DJ FILTER (fx.c djf_block): its value as "OFF", or the cutoff ("800", "1.2k", "12k")
* with its side for unit ("LP" / "HP"); its card draws the response (djf_curve) where the gauge would be */
#define DJF_NOCURVE 0x7FFF
static int16_t card_curve_next __attribute__((section(".bss.djf"))); /* the next draw_column's card: the curve of G_DJF
* value card_curve_next - 256 (0: none; its own section: fx.c djf) */
static void djf_format(int32_t v, char *val, const char **unit)
{
int32_t c = djf_cut(v), i = c >> 8, h;
if (!v) {
str_cpy(val, "OFF", 8);
*unit = "";
return;
}
h = CUTOFF_HZ[i] + (i < 127 ? ((CUTOFF_HZ[i + 1] - CUTOFF_HZ[i]) * (c & 255)) >> 8 : 0);
if (h < 1000)
fmt_int(val, h);
else if (h < 10000)
fmt_fix(val, h / 100, 1);
else
fmt_int(val, h / 1000);
if (h >= 1000)
str_cpy(val + str_len(val), "k", 2);
*unit = v < 0 ? "LP" : "HP";
}
/* the response of G_DJF value v drawn w px wide from (x, y): rows rows (5 or 6), 0 dB on the second (the bump above it),
* 12 dB / oct (2 px an octave of CUTOFF_HZ's scale) down to the last row; flat at 0 dB when off. The unity line under it
* in tc */
static void djf_curve(int32_t x, int32_t y, int32_t w, int32_t rows, int32_t v, uint16_t vc, uint16_t tc)
{
int32_t c = v ? djf_cut(v) : 0, py = y + 1, i;
int32_t bump = v && djf_k(c, v > 0) < (DJF_KMAX + DJF_KMIN) / 2; /* (Q past ~0.9: the peak a row up) */
cv_rect(x, y + 1, w, 1, tc);
for (i = 0; i < w; i++) {
int32_t f = i * (127 << 8) / (w - 1), d = (v < 0 ? f - c : c - f) / 256, cy; /* (octaves below / above: 14 idx) */
cy = !v || d < -3 ? y + 1 : d > 0 ? y + 1 + clamp(d / 7, 0, rows - 2) : y + 1 - (bump && d >= -3);
if (i)
cv_rect(x + i, cy < py ? cy : py, 1, (cy < py ? py - cy : cy - py) + 1, vc);
else
cv_rect(x, cy, 1, 1, vc);
py = cy;
}
}
static void draw_column(uint32_t c, const char *label, const char *val, const char *unit, uint16_t vc,
int32_t ratio, uint32_t icon)
{
card_bip = (uint8_t)(ratio >= 0 && ratio == ratio_last.r && ratio_last.bip); /* (its ratio from RATIO: bipolar?) */
ratio_last.bip = 0;
if (ui.layer && c < 4u) {
ly_card[c].r = (int16_t)ratio;
ly_card[c].b = card_bip;
str_cpy(ly_card[c].l, label, sizeof ly_card[c].l);
str_cpy(ly_card[c].v, val, sizeof ly_card[c].v);
str_cpy(ly_card[c].v + str_len(ly_card[c].v), unit, sizeof ly_card[c].v - str_len(ly_card[c].v));
}
char key[56];
int hot = c == ui.hot_col && ui.hot_t, named = fmt_named, mot = card_mot_next && label[0], strip, snap;
int arm = card_arm_next, free = card_free_next;
int32_t curve = card_curve_next ? card_curve_next - 256 : DJF_NOCURVE;
card_curve_next = 0;
uint32_t kind = large_kind(); /* MENU > LARGE: tall (draw_column_tall), or the label in M */
uint8_t sig;
uint16_t lc = hot ? T_ACCENT : arm || mot ? T_THEME : T_MID, cb = T_BG, gk = 0, oc;
int32_t x, lx = 5, uw, room = COL_W - 8, ch = (int32_t)card_h(), ry = ROLL_Y, lw;
const aafont_t *vf = &AF_M;
uint32_t n, kn;
int32_t kid = kc_tag(val, &kn);
/* (0.8.9, the 0.6 colours) a lens card's value and gauge in its knob's colour. (0.9.5) JIANT: the knob's colour its
* value's heat (knob_col), the value lifted a fifth toward the text, as the 0.6's. (V10.7.23) Its label MID: the value
* and the card's line stand out */
if (lz_on() && kind != LK_TALL) {
if (kid < 0 && (vc == T_THEME || vc == T_ACCENT)) {
gk = knob_col(c, ratio, card_bip); /* (the gauge's) */
vc = heat_on(ratio) ? ux_mix(gk, T_TEXT, 20) : gk;
}
lc = arm || mot ? T_THEME : T_MID;
}
if (!gk)
vc = value_col(vc, ratio);
oc = label[0] || val[0] ? vc : T_LINE; /* (V10.7.23, the owner) no box: the card's line in its value's
* colour (none: LINE), */
lw = 1 + (hot && vc != T_DIM); /* 2 px the knob just turned (it was framed) */
fmt_named = 0; /* (params.c: a name, for this card only) */
card_mot_next = 0; /* (the same: MOTION, this card only) */
card_arm_next = card_free_next = 0;
card_mot = (uint8_t)((card_mot & ~(1u << c)) | (uint32_t)mot << c);
if (str_eq(unit, label))
unit = ""; /* "BPM 124 BPM", "USB OFF USB": the label says it */
(void)icon; /* (0.8.5, the mock-up: no icons on the cards) */
str_cpy(key, label, 12); /* cache key: texts + colour + gauge */
str_cpy(key + str_len(key), "|", 2);
str_cpy(key + str_len(key), val, 14);
str_cpy(key + str_len(key), "|", 2);
str_cpy(key + str_len(key), unit, 8);
n = str_len(key);
/* every RGB565 bit: status colours can change with identical text */
key[n] = (char)('A' + (vc & 15u));
key[n + 1] = (char)('A' + ((vc >> 4) & 15u));
key[n + 2] = (char)('A' + ((vc >> 8) & 15u));
key[n + 3] = (char)('A' + (vc >> 12));
key[n + 4] = (char)(' ' + (ratio < 0 ? 0 : 1 + clamp(ratio, 0, 1000) * (COL_W - 10) / 1000)); /* (the gauge's px) */
key[n + 5] = (char)('!' + arm + 2 * (int)lz_on());
key[n + 6] = (char)('0' + hot + 2 * mot + 4 * (int)kind);
{ /* (0.6.10) the gauge's colour too */
uint16_t gc = ratio < 0 ? 0u : gk ? gk : gauge_col(ratio);
key[n + 7] = (char)('A' + (gc & 15u));
key[n + 8] = (char)('A' + ((gc >> 4) & 15u));
key[n + 9] = (char)('A' + ((gc >> 8) & 15u));
key[n + 10] = (char)('A' + (gc >> 12));
}
key[n + 11] = 'A';
key[n + 12] = (char)(curve == DJF_NOCURVE ? '#' : 0x80 | ((curve + 64) & 127)); /* (0.9.1) the DJ FILTER's curve */
key[n + 13] = 0;
uw = unit[0] ? text_w(&AF_S, unit) + 3 : 0;
if (face_has(&AF_V, val) && val[0] && text_w(&AF_V, val) + uw <= room) /* a number: in V (capitals 14 px) where it and
* its unit fit the card; else M (11), else S (9) */
vf = &AF_V;
else if (text_w(vf, val) + uw > room)
vf = &AF_S;
sig = (uint8_t)str_hash(str_hash(song.sel + TSEL->eng_req * 4u + ux.gen * 64u + lz_on() * 16u, label), unit);
snap = ui.force || sig != ui.roll[c].sig; /* what the value is of: label, unit, track, engine, palette */
if (kind == LK_TALL)
ui.roll[c].from[0] = 0; /* (a tall card: no rolling digits) */
strip = !snap && str_eq(key, ui.col[c]);
if (strip && !ui.roll[c].from[0])
return;
if (strip) { /* rolling: the value strip only */
cv_begin(COL_W, ROLL_H, cb);
cv_oy = -ry;
cv_rect(0, ry, lw, ROLL_H, oc); /* (V10.7.23) the card's line, its sides */
cv_rect(COL_W - lw, ry, lw, ROLL_H, oc);
} else {
char ov[16]; /* the value drawn before (in the cache key) */
const char *k = ui.col[c];
uint32_t i = 0;
while (*k && *k != '|')
k++;
while (*k && k[1] && k[1] != '|' && i + 1u < sizeof ov)
ov[i++] = *++k;
ov[i] = 0;
ui.roll[c].sig = sig;
if (!str_eq(ov, val))
roll_note(c, ov, val, snap || named || vf == &AF_S || kid >= 0 || kind == LK_TALL);
else if (snap)
ui.roll[c].from[0] = 0;
str_cpy(ui.col[c], key, sizeof ui.col[c]);
if (kind == LK_TALL) {
draw_column_tall(c, label, val, unit, vc, ratio, icon, hot, mot, kid);
return;
}
cv_begin(COL_W, (uint32_t)ch, T_BG);
card_line(0, 0, COL_W, ch, lz_on() ? 5 : 0, oc, lw); /* (the lens's rounded, the others' square) */
}
if (label[0] || val[0]) {
cv_scroll = (uint8_t)strip; /* (0.9.0) rolling: the label again where it reaches into the value's
* strip (MONO's chip, LARGE's M labels), clipped to it */
if (label[0]) {
/* the label (S, MID) at the top left, its capitals rows 4..12; MENU > LARGE on a list / graph page, a lens
* page or a layer (LK_LABEL): in M where it fits the card (capitals rows 4..14), else in S. A parameter
* MOTION drives, an armed action: THEME */
const aafont_t *lf = lz_on() ? &AF_X : &AF_S; /* (MENU > LARGE on a list / graph page had it in M: the value
* is the big one now, V) */
int32_t ly = lf == &AF_M ? 0 : lf == &AF_X ? CARD_XY : 1; /* (0.8.5 a lens card: AF_X, capitals rows 5..11) */
int32_t cy = ly + (lf == &AF_M ? AF_M_CAP_Y : lf == &AF_X ? AF_X_CAP_Y : AF_S_CAP_Y);
{
int32_t ic = lf == &AF_X && lz_on() && kind != LK_TALL ? card_ico(label) : -1;
if (ic >= 0 && 10 + text_w(lf, label) <= COL_W - 2 - 5) { /* (0.8.9) its mark, then the label */
card_ico_draw(lx, cy, (uint32_t)ic, lc);
cv_text_fit(lx + 10, ly, lf, label, lc, cb, COL_W - 2 - 15);
} else
cv_text_fit(lx, ly, lf, label, lc, cb, COL_W - 2 - 5);
}
}
cv_scroll = 0;
if (kid >= 0) /* "[OCT+]": the keycap (accent: it would act; DIM: it would not) */
x = cv_keycap(5, ry + 2, (uint32_t)kid, vc == T_ACCENT || vc == T_DIM ? vc : T_KEY, T_INK, cb);
else if (vf != &AF_S) { /* (M: its capitals rows ry + 3 .. 13; V: its figures ry .. ry + 15,
* inside the strip that rolls; its unit a row lower, on its line) */
if (!ui.roll[c].from[0] && val[0] && vf == &AF_M)
GFX_HOOK_ALIGN(0, ry, COL_W, ry + ROLL_H, AL_V, "card value in its roll window");
x = roll_text(c, 5, vf == &AF_V ? ry - AF_V_CAP_Y + 1 : ry - 1, val, vc, vf);
} else if (free) /* (a name: ellipsised where it must be) */
x = cv_free_text(5, ry + 2, vf, val, vc, cb, room - uw);
else
x = cv_text_fit(5, ry + 2, vf, val, vc, cb, room - uw);
if (unit[0]) {
int32_t uy = vf == &AF_V ? ry - AF_V_CAP_Y + 1 + AF_V.asc - AF_S.asc : ry + 2;
GFX_HOOK_ALIGN(0, 0, 0, uy + AF_S.asc, AL_B, "card unit on its value's baseline");
cv_text_on(x + 3, uy, &AF_S, unit, T_MID, cb); /* on the value's baseline (S) */
}
if (!strip && curve != DJF_NOCURVE && kind != LK_TALL) { /* (0.9.1) the DJ FILTER: its response */
uint16_t gc = hot && !lz_on() ? T_ACCENT : vc == T_DIM ? T_DIM : lz_on() ? (gk ? gk : vc) : gauge_col(ratio);
djf_curve(5, ch - 8, COL_W - 10, 6, curve, curve ? gc : T_MID, T_LINE);
} else if (!strip && ratio >= 0) { /* the gauge: a 2 px LINE track, the value THEME on it */
int32_t gw = COL_W - 10, fx = ratio * gw / 1000;
uint16_t gc = hot && !lz_on() ? T_ACCENT : vc == T_DIM ? T_DIM : lz_on() ? (gk ? gk : vc) : gauge_col(ratio);
if (lz_on() && kind != LK_TALL) { /* COLORS: 3 px, rounded, as the 0.6's */
cv_rrect(5, ch - 6, gw, 3, 1, T_LINE, cb);
cv_rrect(5, ch - 6, fx < 3 ? 3 : fx, 3, 1, gc, T_LINE);
} else {
cv_rect(5, ch - 5, gw, 2, T_LINE);
cv_rect(5, ch - 5, fx < 2 ? 2 : fx, 2, gc);
}
}
}
cv_oy = 0;
cv_blit((uint32_t)CARD_X(c), card_y() + (strip ? (uint32_t)ry : 0u));
}
/* Gauge cards without units share their constant renderer arguments. */
static __attribute__((noinline)) void gauge_column(uint32_t c, const char *label, const char *value, uint16_t color, int32_t ratio)
{
draw_column(c, label, value, "", color, ratio, ICON_NONE);
}
static __attribute__((noinline)) void hot_gauge_column(uint32_t c, const char *label, const char *value, int32_t ratio)
{
gauge_column(c, label, value, VAL(c), ratio);
}
static __attribute__((noinline)) void unit_column(uint32_t c, const char *label, const char *value, const char *unit, uint16_t color)
{
draw_column(c, label, value, unit, color, -1, ICON_NONE);
}
static __attribute__((noinline)) void hot_unit_column(uint32_t c, const char *label, const char *value, const char *unit)
{
unit_column(c, label, value, unit, VAL(c));
}
/* Cards without units or a gauge share argument setup. Icons are unused by draw_column. */
static __attribute__((noinline)) void text_column(uint32_t c, const char *label, const char *value, uint16_t color)
{
gauge_column(c, label, value, color, -1);
}
static __attribute__((noinline)) void hot_text_column(uint32_t c, const char *label, const char *value)
{
text_column(c, label, value, VAL(c));
}
/* Shared empty card: keep the renderer and all of its state-reset behavior. */
static __attribute__((noinline)) void empty_column(uint32_t c)
{
text_column(c, "", "", T_THEME);
}
/* an action's column (act_cols): picked, the OCT+ keycap (accent while it would do something); else "--" */
static void draw_act_column(uint32_t c, const char *label, uint16_t vc, uint32_t icon) /* icon: ICON_AUTO = by label */
{
int picked = act_col() == c + 1u;
card_arm_next = (uint8_t)picked; /* (0.8.5, the mock-up: the armed card TINT, OCT+ its value) */
text_column(c, label, picked ? "OCT+" : "", picked ? (act_ready() ? T_TEXT : T_DIM) : vc);
}
/* action pages: the footer's first row says what OCT+ and OCT- do ("OCT+ LOAD OCT- BACK") */
static void foot_hint(char *a, char *b)
{
uint32_t c = act_col();
str_cpy(a, "OCT+ ", 8);
str_cpy(a + 5, c ? act_name(c - 1u) : "--", 8);
str_cpy(b, ui.act && 1 ? "OCT- CANCEL" : "OCT- BACK", 16);
}
/* the sound's name on the track: a user preset or the engine's preset (b holds 16) */
static void sound_name(const track_t *t, char *b)
{
const engine_t *e = trk_engp(t);
b[0] = 0;
if (user_of(t) < UP_SLOTS)
up_name(user_of(t), b);
else if (e->npresets)
str_cpy(b, e->presets[t->preset % e->npresets].name, 16);
}
/* (0.9.2, rule 6) the tabs on top, as the approved mock-up (navegacion.html): the section's groups (the menu's tabs, a
* layer's MAP KNOBS STATE, a dialog's three), the one shown lit, under each name a dot a page (the page shown: its dot
* marked). COLORS: n rounded tabs (r 4) in a row, x 4 .. 236, 2 apart (three: 76 wide at x 4 + 78 l, as 0.8.5's), y 26,
* 13 tall; the group shown THEME with INK text, the others RAISE with MID; the name (its short form where it does not
* fit) centred, capitals rows 29..35; the dots on row 37, 2 x 1, 4 apart (INK on the lit tab, the others a mix; DIM on the
* rest). Drawn when what it shows changes */
#define LT_W 76
#define LT_X(l) (4 + (int32_t)(l) * 78)
#define TAB_X(i, n) (4 + (int32_t)(i) * 234 / (int32_t)(n)) /* tab i of n (COLORS): from here, TAB_X(i + 1) - 2 wide */
static void tabs_paint(uint32_t n, uint32_t lv, const char *const *nm, const char *const *tab, const uint8_t *cnt, uint32_t at)
{
uint32_t l, d;
cv_begin(240, LT_H, T_BG);
for (l = 0; l < n; l++) {
int32_t x = TAB_X(l, n), w = TAB_X(l + 1u, n) - 2 - x, nd = cnt ? cnt[l] : 0, dx = x + HALF_UP(w - (nd * 4 - 2));
const char *s = nm[l];
uint16_t bg = l == lv ? T_THEME : T_RAISE;
if (tab && tab[l] && text_w(&AF_X, s) > w - 8) /* (3 px clear at either side) */
s = tab[l];
cv_rrect(x, 0, w, LT_H, 4, bg, T_BG);
GFX_HOOK_ALIGN(x, 0, x + w, LT_H, AL_HV, "group tab name centred in its tab");
cv_text_in(x, CAP_IN(X, LT_H), w, &AF_X, s, l == lv ? T_INK : T_MID, bg);
for (d = 0; d < (uint32_t)nd; d++)
cv_rect(dx + (int32_t)d * 4, LT_H - 2, 2, 1, l != lv ? T_DIM : d == at ? T_INK : ux_mix(T_THEME, T_INK, 40));
}
cv_blit(0, LT_Y);
}
/* what the tabs show (lz_on): the groups' names (short forms), each one's pages, the one lit, its page; how many */
static uint32_t tabs_now(const char **nm, const char **tab, uint8_t *cnt, uint32_t *lv, uint32_t *at)
{
uint32_t f = lz_fam(), n, k, i, m;
uint8_t gi[8];
if (f == LZ_MENU) { /* the menu: its four tabs, a dot a row */
for (k = 0; k < MTAB_COUNT; k++) {
nm[k] = MTAB_NAME[k];
tab[k] = 0;
cnt[k] = (uint8_t)mtab_rows(k);
}
*lv = menu_tab();
*at = ui.menu_sel - mtab_first(*lv);
return MTAB_COUNT;
}
if (f == LZ_LAYER) { /* a layer: its views (ALGORITHM), no dots */
nm[0] = "MAP"; /* (V10.7.66: KNOBS / STATE gone) */
tab[0] = 0;
cnt[0] = 0;
*lv = 0;
*at = 0;
return 1;
}
n = nav_groups(cnt, gi, lv, at, &i, &m);
for (k = 0; k < n; k++) {
nm[k] = nav_group_name(gi[k]);
tab[k] = nav_group_tab(gi[k]);
}
return n;
}
/* the tabs shown: at most TAB_SHOWN, wide enough for their words in the labels' face (SEQ's and FX's eight were 27 px
* each); with more groups, the five round the one lit */
#define TAB_SHOWN 5u
static uint32_t tab_first(uint32_t n, uint32_t lv)
{
return n <= TAB_SHOWN ? 0u : lv < 2u ? 0u : lv + 3u > n ? n - TAB_SHOWN : lv - 2u;
}
static void draw_tabs(void)
{
static uint32_t drawn;
const char *nm[8], *tab[8];
uint8_t cnt[8];
uint32_t lv, at, n = tabs_now(nm, tab, cnt, &lv, &at), k,
sig = (lv + 1u) * 2654435761u + at * 40503u + ux.gen * 977u + lz_fam() * 131u + 1u +
n * 7919u;
for (k = 0; k < n; k++)
sig = (sig ^ str_hash(cnt[k], nm[k])) * 16777619u;
if (!ui.force && sig == drawn)
return;
drawn = sig;
k = tab_first(n, lv); /* (more than TAB_SHOWN groups: those round the one lit) */
tabs_paint(n > TAB_SHOWN ? TAB_SHOWN : n, lv - k, nm + k, tab + k, cnt + k, at);
if (n > TAB_SHOWN) { /* .. and a mark at the side where more lie */
if (k)
lcd_fill(0, LT_Y + 4, 2, 6, T_DIM);
if (k + TAB_SHOWN < n)
lcd_fill(238, LT_Y + 4, 2, 6, T_DIM);
}
}
/* (0.9.2, rule 6) the footer's breadcrumb, as the mock-up's: small, DIM, from x 6, its parts apart by " . ": SECTION .
* GROUP . page ("FX . DELAY . DLY 2"; the menu "MENU . DISPLAY . COLOR", a layer "FX . MAP"), the group THEME, the page
* TEXT (`last`: a flash TEXT; the DRUM grid with ACC held: ACCENT, "ACCENT"); its place n/N in the chain at the right */
static const char *const FAM_CRUMB[FAM_COUNT] = {"HOME", "ENV", "LFO", "FX", "SCL", "EDIT", "GLO", "SAVE", "ARP", "SEQ",
"GLO"};
static __attribute__((noinline)) void foot_crumbs(char *b, uint32_t n) /* b holds n (48) */
{
char ti[24];
uint32_t f;
if (!lz_on() && ui.home) {
str_cpy(b, "HOME", n);
return;
}
if (!lz_on()) {
page_title(ti);
str_cpy(b, FAM_CRUMB[cur_page()->fam % FAM_COUNT], n);
str_cpy(b + str_len(b), " \xB7 ", 4);
str_cpy(b + str_len(b), ti, 20);
return;
}
f = lz_fam();
if (f == LZ_MENU) {
str_cpy(b, "MENU \xB7 ", n);
str_cpy(b + str_len(b), MTAB_NAME[menu_tab()], 12);
str_cpy(b + str_len(b), " \xB7 ", 4);
str_cpy(b + str_len(b), MI_NAME[ui.menu_sel % MI_COUNT], 16);
return;
}
if (f == LZ_LAYER) {
static const char *const LN[LAYER_N] = {"", "FX", "GLO", "SCL", "EDIT", "SEQ", "REC", "SAVE", "LFO"};
str_cpy(b, LN[ui.layer % LAYER_N], n);
str_cpy(b + str_len(b), " \xB7 MAP", 8);
return;
}
{
uint8_t cnt[8], gi[8];
uint32_t g, p, i, m;
(void)nav_groups(cnt, gi, &g, &p, &i, &m);
str_cpy(b, SEC_NAME[nav_sec()], n);
str_cpy(b + str_len(b), " \xB7 ", 4);
str_cpy(b + str_len(b), nav_group_name(gi[g]), 16);
str_cpy(b + str_len(b), " \xB7 ", 4);
if (grid_on() && black_held(GK_ACC))
str_cpy(ti, "ACCENT", sizeof ti);
else
str_cpy(ti, nav_page_name(), sizeof ti);
str_cpy(b + str_len(b), ti, n - str_len(b));
}
}
#define CRUMB_Y 3 /* (0.8.5) a lens footer's breadcrumb (AF_X): capitals rows 4..12 */
/* the page's place in its chain at the footer's right, "6/16" (the menu: the row among all; a layer: its view) */
static int32_t crumb_count(char *b)
{
uint32_t k, n;
b[0] = 0;
if (!lz_on())
return 0;
if (lz_fam() == LZ_MENU) {
k = ui.menu_sel % MI_COUNT;
n = MI_COUNT;
} else if (lz_fam() == LZ_LAYER) {
k = 0;
n = 1;
} else {
uint8_t cnt[8], gi[8];
uint32_t g, p;
(void)nav_groups(cnt, gi, &g, &p, &k, &n);
}
if (n < 2u)
return 0;
fmt_frac(b, (int32_t)k + 1, (int32_t)n);
return text_w(&AF_X, b);
}
/* (0.9.9-seq2g: the 0.6's footer back, as the owner asked) the 16 steps of the bar the cursor is in, on every page: a step
* with a note (DRUM: any lane hitting there) a lit bar (THEME; accented ACCENT), an empty one a stub (a tie MID), under
* them the step sounding (TEXT; it moves a step at a time: a function of the step, never of the frame) and in SEQ the
* step edited (ACCENT, over it); the bars of the pattern as tiny 3 x 3 dots at the strip's right end (the one shown TEXT,
* the one playing THEME when it is another). The normal footer: row 1, x 12 .. 228 as 0.6's (the dots in a column at
* x 233); a lens footer (one row of 15 px): a compact strip before the breadcrumb, which shortens to the page's name */
static uint32_t foot_ph(const track_t *t, uint32_t *len)
{
*len = t->p[P_SLEN] > 0 ? (uint32_t)t->p[P_SLEN] : 1u;
return song.playing ? seq_src(t, t->seq_idx) : 0xFFu;
}
static uint32_t foot_strip_sig(void)
{
const track_t *t = TSEL;
uint32_t len, ph = foot_ph(t, &len), bk = ui.bank;
return steps_hash(t) + (len * 131u + bk) * 2654435761u + (ph / 16u == bk ? ph % 16u + 1u : 0u) * 40503u +
(ph < len ? ph / 16u + 1u : 0u) * 977u + (song.seq_mode ? ui.cursor + 1u : 0u) * 3001u;
}
static int32_t foot_strip(int32_t x0, int32_t y, int lens)
{
const track_t *t = TSEL;
uint32_t len, ph = foot_ph(t, &len), nb = (len + 15u) / 16u, i;
int32_t w = lens ? 4 : 9, hb = lens ? 7 : 11, my = lens ? y + 9 : y + 13, x = x0;
for (i = 0; i < 16u; i++) {
uint32_t si = ui.bank * 16u + i;
const step_t *st = &seq_steps(t)[si];
x = lens ? x0 + (int32_t)i * 5 + (int32_t)(i / 4u) * 2 : 12 + (int32_t)i * 13 + (int32_t)(i / 4u) * 4;
if (si >= len)
continue;
if (step_on(st))
cv_rect(x, y, w, hb, (st->flags & SF_ACCENT) || st->acc ? T_ACCENT : T_THEME);
else
cv_rect(x, y + hb - 3, w, 3, st->time == ST_TIE ? T_MID : T_RAISE);
if (song.seq_mode && si == ui.cursor)
cv_rect(x, my, w, 2, T_ACCENT);
else if (si == ph)
cv_rect(x, my, w, 2, T_TEXT);
}
x += w + 4;
for (i = 0; nb > 1u && i < nb; i++) {
uint16_t c = i == ui.bank ? T_TEXT : ph < len && i == ph / 16u ? T_THEME : T_RAISE;
if (lens)
cv_rect(x + (int32_t)i * 4, y + 2, 3, 3, c);
else
cv_rect(233, y + (int32_t)i * 4, 3, 3, c);
}
return lens ? x + (nb > 1u ? (int32_t)nb * 4 + 3 : 0) : x;
}
/* (0.9.9-seq2h) SEQ's clipboard holding n steps: "[n]" at the footer's right, before the count (ui_input.c cp_copy) */
static int clip_tag(char *b)
{
if (!clip.n || ui.home || ui.menu || !song.seq_mode)
return 0;
b[0] = '[';
fmt_int(b + 1, clip.n);
str_cpy(b + str_len(b), "]", 2);
return 1;
}
static __attribute__((noinline)) void draw_crumbs(int32_t y, uint16_t fg, uint16_t last)
{
char cnt[8], ct[8];
int32_t cw = crumb_count(cnt), mx = cw ? 234 - cw - 8 : 234;
char b[48];
uint32_t i, k = 0;
int32_t x, x0;
const aafont_t *f = lz_on() ? &AF_X : &AF_S; /* (0.8.5: a lens page, the mock-up's small mono) */
x0 = f == &AF_X ? foot_strip(6, y + AF_X_CAP_Y, 1) : 8; /* (seq2g, a lens footer: the steps first, on the capitals) */
foot_crumbs(b, sizeof b);
for (i = 0; b[i]; i++) /* (the last part: after the last dot) */
if ((uint8_t)b[i] == 0xB7u)
k = i + 2u;
if (k > str_len(b))
k = 0;
if (f == &AF_X)
GFX_HOOK_ALIGN(0, y + AF_X_CAP_Y, 0, y + AF_X_CAP_Y + AF_X_CAP_H, AL_V, "footer breadcrumb on its line");
else
GFX_HOOK_ALIGN(0, y + AF_S_CAP_Y, 0, y + AF_S_CAP_Y + AF_S_CAP_H, AL_V, "footer breadcrumb on its line");
if (cw)
cv_text_r(234, y, f, cnt, f == &AF_X ? T_TEXT : fg, T_BG); /* (0.8.9, the skins' mock-up: the count TEXT) */
if (clip_tag(ct))
mx = cv_text_r(mx, y, f, ct, T_THEME, T_BG) - 6; /* (seq2h) the clipboard's [n] */
if (f == &AF_X && k) { /* (seq2g) a lens footer: the page's name alone after the steps
* (TEXT, as `last` if that is not DIM) */
cv_free_text(x0, y, f, b + k, last == fg ? T_TEXT : last, T_BG, mx - x0);
return;
}
if (last == fg || !k) {
cv_free_text(x0, y, f, b, fg, T_BG, mx - x0);
return;
}
{
char c = b[k];
b[k] = 0;
x = cv_text_on(x0, y, f, b, fg, T_BG);
b[k] = c;
cv_free_text(x, y, f, b + k, last, T_BG, mx - x);
}
}
static void draw_foot(void)
{
char s[48], ti[20];
const track_t *t = TSEL;
uint32_t sig;
int lz = (int)lz_on(), accw = grid_on() && black_held(GK_ACC);
int32_t ry = lz ? CRUMB_Y + LZ_FOOT_Y - (int32_t)foot_y() : 19; /* the breadcrumb's line (a lens page: the footer is it) */
foot_crumbs(s, sizeof s);
if (ui.home)
str_cpy(ti, "HOME", sizeof ti);
else
page_title(ti);
sig = str_hash(0x9E3779B9u, s) + str_hash(7u, ti) + (uint32_t)lz * 104729u + foot_strip_sig(); /* (seq2g) the steps */
if (act_cols() && !lz) { /* the hint, and whether OCT+ would act */
char ha[16], hb[16];
foot_hint(ha, hb);
sig += str_hash(str_hash(act_ready() ? 7u : 3u, ha), hb);
}
sig += (uint32_t)accw * 977u + (uint32_t)clip.n * 7919u; /* (seq2h) the clipboard's [n] */
if (!ui.force && sig == ui.foot_sig)
return;
ui.foot_sig = sig;
cv_begin(240, foot_h(), T_BG);
if (lz) {
; /* (0.8.5) a lens page: the breadcrumb alone, as the mock-up */
} else if (act_cols()) { /* row 1: the OCT+ / OCT- hint in place of the steps */
char ha[16], hb[16];
khint_t kh[2];
foot_hint(ha, hb); /* "OCT+ LOAD", "OCT- BACK": keycaps and their words */
kh[0] = (khint_t){KC_OCTUP, ha + 5};
kh[1] = (khint_t){KC_OCTDN, hb + 5};
cv_key_row(8, 232, 2, kh, 2, act_ready() ? 3u : 2u, T_BG);
} else { /* row 1: the cursor's bar, 16 steps in 4 groups (seq2g, 0.6's) */
if ((ui.bank + 1u) * 16u <= (uint32_t)t->p[P_SLEN])
GFX_HOOK_ALIGN(0, 0, 240, 0, AL_H | AL_CELLS | AL_N(16), "footer step bars centred");
(void)foot_strip(12, 1, 0);
}
draw_crumbs(ry, T_DIM, accw ? T_ACCENT : T_DIM); /* (0.8.5) row 2: the breadcrumb (the track's engine and sound:
* the header's centre) */
cv_blit(0, foot_y());
}
/* the EDIT layer's cards (ui_layer.c; 0.9.9-seq2f): ENG, No. (the engine's sounds: PRESETS' list, ui.c eng_list_pos),
* FAV (PRESETS' KNOB 3 marks it), an empty card. KNOB 1..4 are MOMENTARY there (ui_layer.c mom_knob); SELECT the dice */
static void engine_columns(void)
{
uint32_t total, cur = eng_list_pos(&total), e = trk_eng(TSEL);
char val[8], u[8];
fmt_int(val, (int32_t)cur + 1);
str_cpy(u, "/", 8);
fmt_int(u + 1, (int32_t)total);
if (cur + 1u >= 100u && total >= 100u) u[0] = 0;
draw_column(0, "ENG", ENGINES[e]->name, "", VAL(0u), (int32_t)eng_rank(e) * 1000 / (NENG_SHOWN > 1 ? NENG_SHOWN - 1 : 1),
engine_icon(ENGINES[e]->name));
draw_column(1, "No.", val, u, VAL(1u), total > 1u ? (int32_t)(cur * 1000u / (total - 1u)) : 0, ICON_NONE);
hot_text_column(2, "FAV", preset_favorite() ? "ON" : "OFF");
empty_column(3);
}
/* (0.9.9-seq2d / seq2f) the step components' cards: GLO > COMPS / COMPS 2, SEQ > COMP / COMP 2. (gen3) Its own function,
* out of draw_columns: new code lands past the pinned sound (tools/build.py), draw_columns' run before it stays as long */
/* (gen3) KNOB 4's card: ARP's ORDER DOWN UP-DN as DN UD, the RATE beside them (here: comp_vname's code pinned in its run,
* its ORD ui_input.c ENT_ORD's twin, one table) */
static void comp_value(const step_t *s, uint32_t a, uint32_t v, char *lb, char *val, char *un)
{
comp_vname(TSEL, s, a, v, lb, val, un);
if (a == CA_ARP && (val[0] == 'D' || val[2] == '-'))
val[1] = val[0] == 'D' ? 'N' : 'D', val[2] = 0;
}
static __attribute__((noinline)) void comp_columns(void)
{
char val[12];
{ /* (seq2d) the cursor step's C1 / C2: ACTION LENGTH COND VALUE */
const step_t *cs = &TSEL->step[ui.cursor];
uint32_t a = comp_view(), k = comp_slot(), c = CO_COND(k ? cs->comp2 : cs->comp), l = cs->clen[k & 1u];
char lb[10], un[8];
text_column(0, k ? "ACTION 2" : "ACTION", CA_NAMES[a], a ? VAL(0u) : T_DIM);
if (a) {
fmt_int(val, (int32_t)(l < CL_MAX ? l + 1u : 1u));
hot_unit_column(1, "LENGTH", val, a == CA_RAMP && (comp_arg(cs) & CV_RAMP_BARS) ? "BAR" : "ST");
} else
text_column(1, "LENGTH", "-", T_DIM);
if (a) {
cond_name(c, cs->cnm[k & 1u], val);
/* (gen3) MONO / POLY the label (it took the value's room as its unit: "AL..", "!1.."), the condition whole */
text_column(2, CO_COND(cs->comp2) == CC_ELSE && CO_ACT(cs->comp2) ? "MONO" : CO_ACT(cs->comp) && CO_ACT(cs->comp2) ?
"POLY" : "COND", val, c ? VAL(2u) : T_DIM);
comp_value(cs, a, comp_arg(cs), lb, val, un);
unit_column(3, lb, val, un, lb[0] ? VAL(3u) : T_DIM);
} else {
text_column(2, "COND", "", T_DIM);
empty_column(3);
}
return;
}
}
/* (V10.30, flash) a parameter's card: its value formatted, its gauge (d's ratio of v) */
/* (V10.7.66, the owner) M1..M4 as cards: "M1 CUT", by its first route's destination; 0 OFF */
static __attribute__((noinline)) void macro_cards(void)
{
char val[12];
uint32_t c;
for (c = 0; c < 4u; c++) {
uint32_t r, d = 0;
char nm[10] = {'M', (char)('1' + c), 0};
for (r = 0; r < MX_N && !d; r++)
if ((mx_r[r].m & 3u) == c && mx_r[r].d && mx_r[r].a)
d = mx_r[r].d;
if (d && d < NELEM(N_MDST)) { nm[2] = ' '; str_cpy(nm + 3, N_MDST[d], 6); }
fmt_int(val, macro_v[c] * 100 / 127);
draw_column(c, nm, macro_v[c] ? val : "OFF", macro_v[c] ? "%" : "", macro_v[c] ? VAL(c) : T_DIM,
macro_v[c] * 1000 / 127, ICON_MIX);
}
}
static void pf_column(uint32_t c, const char *label, const param_desc_t *d, int32_t v, uint16_t col, uint32_t icon)
{
char val[12];
const char *unit;
param_format(d, v, val, &unit);
draw_column(c, label, val, unit, col, RATIO(d, v), icon);
}
static const char *const JAM_Q_N[6] = {"AT ONCE", "1/16", "1/8", "1/4", "1/2", "BAR"}; /* (V10.8) JAM's CAMBIO */
/* (V10.8, the owner) SEQ > STEP's KNOB 1: the track's sequence A..D (JAM), the one asked for after it (in on CAMBIO's
* step), else where the cursor is */
static void jam_card(void)
{
uint32_t k = song.sel % NTRK, g = clip_go[k];
char v[4] = "A", u[8];
v[0] = (char)('A' + jam_cur(k));
if (g - 1u < 4u) { u[0] = '>'; u[1] = (char)('A' + g - 1u); u[2] = 0; }
else { fmt_int(u, (int32_t)ui.cursor + 1); str_cpy(u + str_len(u), "/", 2); fmt_int(u + str_len(u), TSEL->p[P_SLEN]); }
hot_unit_column(0, "SEQ", v, u);
}
static void draw_columns(void)
{
uint32_t c;
char val[12];
const char *unit;
(void)motion_mask(song.sel, card_mot_mask); /* (PLAY OFF: no scan) */
if (home_macros() || (!ui.home && cur_page()->graph == GR_PUNCH && cur_page()->id[0] == 0xFF)) { /* (0.8.5) HOME's
* MACROS / ROUTES, (V10.7.66) FX > PUNCH IN: M1..M4, 0..100 % */
macro_cards();
return;
}
if (ui.home) {
for (c = 0; c < 4u; c++) {
int16_t *vp;
const param_desc_t *d = home_param(c, &vp);
param_format(d, *vp, val, &unit);
card_mot_of(vp);
draw_column(c, d->label, val, unit, VAL(c), RATIO(d, enum_rank(d, *vp)), param_icon(d, *vp));
}
return;
}
if (cur_page()->graph == GR_SWARM) { /* (V10.6z6) EDIT > SWARM, SWARM 2 (ui_dx.c) */
if (bt_hw_seg())
sw_ui_cards_bt(cur_page());
return;
}
if (cur_page()->graph == GR_FOCUS) { /* (0.8.5) EDIT > FOCUS: PARAM, its value, SRC, AMT */
uint32_t k = focus_k();
int32_t j = focus_slot(k);
int16_t *vp = &TSEL->p[P_E0 + k];
const param_desc_t *d = track_desc(TSEL, P_E0 + k);
param_format(d, *vp, val, &unit);
hot_gauge_column(0, "PARAM", d->label, (int32_t)k * 1000 / 7);
card_mot_of(vp);
draw_column(1, d->label, val, unit, VAL(1u), RATIO(d, enum_rank(d, *vp)), ICON_NONE);
text_column(2, "SRC", j < 0 ? "OFF" : N_MSRC[clamp(TSEL->p[P_M1SRC + 3u * (uint32_t)j], 0, MS_N - 1)], j < 0 ? T_DIM : VAL(2u));
if (j < 0)
text_column(3, "AMT", "--", T_DIM);
else {
const param_desc_t *da = track_desc(TSEL, P_M1AMT + 3u * (uint32_t)j);
int16_t a = TSEL->p[P_M1AMT + 3u * (uint32_t)j];
pf_column(3, "AMT", da, a, a ? VAL(3u) : T_DIM, ICON_NONE);
}
return;
}
if (cur_page()->graph == GR_DXSND) { /* EDIT > SOUND (ui_dx.c) */
dx_cards(cur_page());
return;
}
if (SONG_PARTS(cur_page())) { /* (V10.6o) PARTS: PART, its ROW in the song, its loop's BARS, PLAY */
uint32_t s = ui.part & 3u, r = ui.song_row;
val[0] = (char)('A' + s); val[1] = 0;
hot_text_column(0, "PART", val);
if (r < chain_config.count && chain_config.row[r].slot == s) fmt_frac(val, (int32_t)r + 1, (int32_t)chain_config.count);
else str_cpy(val, "--", sizeof val);
text_column(1, "ROW", val, val[0] != '-' ? VAL(1u) : T_DIM);
if (song_bars(s)) fmt_int(val, (int32_t)song_bars(s));
else str_cpy(val, "--", sizeof val);
text_column(2, "BARS", val, T_DIM);
text_column(3, "PLAY", live.mode ? "SONG" : "LOOP", VAL(3u));
return;
}
if (SONG_CLIPS(cur_page())) { /* (V10.6s) CLIPS: TRACK, PART (the cell), SONG REC */
val[0] = 'T'; val[1] = (char)('1' + song.sel % NTRK); val[2] = 0;
hot_text_column(0, "TRACK", val);
val[0] = (char)('A' + (ui.part & 3u)); val[1] = 0;
text_column(1, "SEQ", val, sec_col(ui.part & 3u));
text_column(2, "CAMBIO", JAM_Q_N[jam_q % 6u], VAL(2u)); /* (V10.8) */
text_column(3, "TAKE", live.srec == 2u || jam_tr & 8u ? "REC" : live.srec || jam_tr ? "ARM" : jam_lock ? "LOCK" : "FREE",
live.srec || jam_tr ? T_ACCENT : jam_lock ? T_THEME : T_DIM); /* (V10.8.2: LOCK's REC, one track) */ /* (V10.8) the JAM
* take: REC (the REC key), LOCK (KNOB 4) */
return;
}
if (SONG_TAKE(cur_page())) { /* (V10.8.2) TAKE: the change (n/N), WHEN (bar.beat.16th), its
* SEQ, the take's BARS */
uint32_t e = jam_end(), len = jam_len(), i = take_i < e ? take_i : 0u, p = JE_POS(live.jam[i]), s = JE_S(live.jam[i]);
char w[12];
if (!len) {
for (i = 0; i < 4u; i++) text_column(i, "TAKE", "--", T_DIM);
return;
}
fmt_frac(val, (int32_t)i + 1, (int32_t)e);
text_column(0, "CHANGE", val, VAL(0u));
fmt_int(w, (int32_t)(p >> 4) + 1);
e = str_len(w);
w[e] = '.'; w[e + 1u] = (char)('1' + (p >> 2 & 3u)); w[e + 2u] = '.'; w[e + 3u] = (char)('1' + (p & 3u)); w[e + 4u] = 0;
text_column(1, "WHEN", w, VAL(1u));
val[0] = (char)('A' + s); val[1] = 0;
text_column(2, "SEQ", val, sec_col(s));
fmt_int(w, (int32_t)(len >> 4));
text_column(3, "BARS", w, VAL(3u));
return;
}
if (SONG_TRK(cur_page())) { /* (V10.6o) TIMELINE: ROW, PART, BARS, the ALGORITHM track's VAR */
uint32_t row = ui.song_row < chain_config.count ? ui.song_row : chain_config.count - 1u, v;
if (!chain_config.count) {
hot_text_column(0, "ROW", "--");
empty_column(1); empty_column(2); empty_column(3);
return;
}
fmt_frac(val, (int32_t)row + 1, (int32_t)chain_config.count);
hot_text_column(0, "ROW", val);
val[0] = (char)('A' + (chain_config.row[row].slot & 3u)); val[1] = 0;
text_column(1, "PART", val, VAL(1u));
fmt_int(val, chain_config.row[row].bars);
text_column(2, "BARS", val, VAL(2u));
v = row_var(row, song.sel % NTRK);
val[0] = 'T'; val[1] = (char)('1' + song.sel % NTRK); str_cpy(val + 2, " VAR", 5);
text_column(3, val, RV_NAME[v < RV_N ? v : 0], v ? VAL(3u) : T_DIM);
return;
}
if (cur_page()->graph == GR_SONG) {
uint32_t row = ui.song_row < CHAIN_ROWS ? ui.song_row : CHAIN_ROWS - 1u;
int used = row < chain_config.count;
if (ui.song_row >= song_end_row()) { /* (0.6.22) the song's END: STOP / x2 .. x8 / LOOP */
uint32_t e = SONG_END(&chain_config);
hot_text_column(0, "ROW", "END");
if (e == SONG_FOREVER) str_cpy(val, "LOOP", sizeof val);
else if (e >= 2u) { val[0] = 'x'; fmt_int(val + 1, (int32_t)e); }
else str_cpy(val, "STOP", sizeof val);
hot_text_column(1, "END", val);
empty_column(2);
empty_column(3);
return;
}
if (row == chain_config.count) str_cpy(val, "ADD", sizeof val);
else { /* (0.8.5, the mock-up: "2/6") */
fmt_frac(val, (int32_t)row + 1, (int32_t)chain_config.count);
}
hot_text_column(0, "ROW", val);
if (used) { val[0] = (char)('A' + chain_config.row[row].slot); val[1] = 0; }
else str_cpy(val, "--", sizeof val);
text_column(1, "PART", val, used ? VAL(1u) : T_DIM);
if (used) fmt_int(val, chain_config.row[row].bars);
else str_cpy(val, "--", sizeof val);
text_column(2, "BARS", val, used ? VAL(2u) : T_DIM);
text_column(3, "SCENE", used && song_idx.scene[song_cur][row].on ? "ON" : "--", used && song_idx.scene[song_cur][row].on ? VAL(3u) : T_DIM); /* (JIANT) */
return;
}
if (cur_page()->graph == GR_FUGUE) { /* (0.6.52) HEAD RATE DIR INTERVAL */
const fg_set_t *f = &fg_set[song.sel % NTRK][fg_ui % FG_HEADS];
fmt_int(val, (int32_t)(fg_ui % FG_HEADS) + 2);
hot_gauge_column(0, "HEAD", val, (int32_t)(fg_ui % FG_HEADS) * 500);
gauge_column(1, "RATE", N_FGRATE[f->rate % FG_NRATE], f->rate ? VAL(1u) : T_DIM, (int32_t)f->rate * 1000 / (FG_NRATE - 1));
gauge_column(2, "DIR", N_FGDIR[f->dir & 3u], f->rate ? VAL(2u) : T_DIM, (int32_t)(f->dir & 3u) * 333);
val[0] = f->ivl > 0 ? '+' : 0;
fmt_int(val + (f->ivl > 0), f->ivl);
draw_column(3, "INTVL", val, "DEG", f->rate ? VAL(3u) : T_DIM, (int32_t)(f->ivl + 14) * 1000 / 28, ICON_PITCH);
return;
}
if (cur_page()->graph == GR_COMP) {
comp_columns();
return;
}
if (cur_page()->graph == GR_EVENTS) { /* AUTO LIST (ui_events.c): ROW STEP PARAM VALUE */
const track_t *t = TSEL;
uint8_t idx[MOTION_MAX];
uint32_t n = ev_rows(idx), r = ev_row(n), step, id;
int16_t v;
char nm[12];
const param_desc_t *d;
if (r < n) {
const motion_event_t *e = &motion.event[idx[r]];
fmt_frac(val, (int32_t)r + 1, (int32_t)n);
step = MOTION_STEP(e);
id = MOTION_ID(e);
v = MOTION_VAL(e);
} else {
ev_fix();
str_cpy(val, "ADD", sizeof val);
step = ui.ev_step;
id = ui.ev_id;
v = id < P_COUNT ? motion_base_value(t, id) : 0;
}
hot_text_column(0, "ROW", val);
fmt_int(val, (int32_t)step + 1);
text_column(1, "STEP", val, r < n || step < (uint32_t)t->p[P_SLEN] ? VAL(1u) : T_DIM);
if ((id >= P_COUNT && id != MOT_DJF) || !ev_id_ok(t, id)) {
text_column(2, "PARAM", "--", T_DIM);
text_column(3, "VALUE", "--", T_DIM);
return;
}
ev_name(t, id, nm);
hot_text_column(2, "PARAM", nm);
d = track_desc(t, id);
param_format(d, v, val, &unit);
draw_column(3, r == n ? "VALUE" : (motion.event[idx[r]].param & MOTION_LOCK) ? "LOCK" : MOTION_RAMP(&motion.event[idx[r]]) ? "RAMP" : "AUTO", val, unit,
r < n ? VAL(3u) : T_DIM, RATIO(d, enum_rank(d, v)), param_icon(d, v));
return;
}
if (cur_page()->graph == GR_MOTION) {
hot_text_column(0, "PLAY", motion_enabled(TSEL) ? "ON" : "OFF");
fmt_int(val, (int32_t)(motion_count(TSEL) - motion_lock_count(TSEL)));
text_column(1, "EVENT", val, T_MID);
fmt_int(val, (int32_t)motion_lock_count(TSEL)); /* parameter locks (SEQ > STEP: a step held, a knob) */
text_column(2, "LOCK", val, T_MID);
draw_act_column(3, "CLEAR", T_MID, ICON_X_MOTION_DEL);
return;
}
if (cur_page()->graph == GR_TOOLS) { /* (V10.24) KNOB 1 the scope, KNOB 2 the action; OCT+ held */
static const char *const SC[5] = {"PROJECT", "TRACK", "SOUND", "SONG", "SYSTEM"};
static const char *const AC[6] = {"CLEAR", "CLEAR", "INIT", "DEL ROW", "CLEAR", "CPU"};
uint32_t a = ui.act ? ui.act - 1u : 0u;
text_column(0, "TARGET", ui.act ? SC[TL_SC[a]] : "--", ui.act ? VAL(0u) : T_DIM); /* (codex/coherence: was SCOPE,
* MENU's oscilloscope) */
text_column(1, "ACTION", ui.act ? AC[a] : "--", ui.act ? VAL(1u) : T_DIM);
empty_column(2);
text_column(3, "DO", "OCT+", ui.act && act_ready() ? T_ACCENT : T_DIM);
return;
}
if (cur_page()->scope == SC_TRK) { /* LEVEL PAN MUTE of the selected track, the tempo */
const track_t *t = TSEL;
uint32_t lvl = trk_level(song.sel);
param_format(&TP[P_LEVEL], (int32_t)lvl, val, &unit); /* (0: OFF) */
card_mot_of(&TSEL->p[P_LEVEL]);
draw_column(0, "LEVEL", val, unit, lvl && !t->p[P_MUTE] ? VAL(0u) : T_DIM, (int32_t)lvl * 1000 / 127, ICON_AUTO);
card_mot_of(&TSEL->p[P_PAN]);
pf_column(1, "PAN", &TP[P_PAN], t->p[P_PAN], VAL(1u), param_icon(&TP[P_PAN], t->p[P_PAN]));
pf_column(2, "MUTE", &TP[P_MUTE], t->p[P_MUTE], t->p[P_MUTE] ? T_ACCENT : VAL(2u), ICON_AUTO); /* (codex/coherence: was
* REV, SENDS' beside it) */
pf_column(3, mix_k4 ? "DJ FILT" : "BPM", &GP[mix_k4 ? G_DJF : G_BPM], song.g[mix_k4 ? G_DJF : G_BPM], VAL(3u), ICON_AUTO); /* (V10.8.38: OCT+ turns it) */
/* (V10.37) KNOB 4 the tempo, at hand (the DJ
* FILTER stays on LIVE > KEYS's KNOB 4) */
return;
}
if (cur_page()->graph == GR_BROWSE) {
uint32_t total, cur = preset_pos(&total);
char u[8];
if (cur < total) fmt_int(val, (int32_t)cur + 1);
else str_cpy(val, total ? "--" : "NONE", 8); /* (0.6.25: an empty list said "--/0") */
str_cpy(u, "/", 8);
fmt_int(u + 1, (int32_t)total);
if (!total || (cur + 1u >= 100u && total >= 100u)) u[0] = 0; /* (0.7.0) "147/155" is too wide for the card: the
* number alone past 99 (every engine's presets counted) */
hot_unit_column(0, "No.", val, u);
hot_text_column(1, "ENG", ENGINES[TSEL->eng_req]->name);
hot_text_column(2, "FAV", preset_favorite() ? "ON" : "OFF");
hot_text_column(3, "LIST", N_LIST[list_get()]);
return;
}
if (0 /* PHRASES gone */) { /* PAT, then LOAD (a GO button) */
uint32_t n = pat_count(), k = pat_pick();
char tag[4], nm[13];
pat_label(k, tag, nm);
hot_gauge_column(0, "PAT", tag, (int32_t)k * 1000 / (int32_t)(n > 1u ? n - 1u : 1u));
draw_act_column(1, "LOAD", T_THEME, ICON_AUTO);
empty_column(2);
empty_column(3);
return;
}
if(cur_page()->graph==GR_LYRSTEP) {
char label[20];uint32_t pos=lyric_pick(label);
fmt_int(val,(int32_t)ui.cursor+1);hot_text_column(0,"STEP",val);
hot_text_column(1,"WORD",label[0]?label:"NO TEXT");
fmt_int(val,lyric_syl);hot_text_column(2,"SYLL",pos?val:"AUTO");
draw_act_column(3,"PLACE",T_THEME,ICON_AUTO);
return;
}
if(cur_page()->graph==GR_TRACKGEN) {trackgen_cards();return;}
if (SPLIT_PAGE(cur_page())) {
static const char *const labels[8] = {"SPLIT", "LOW TRK", "HIGH TRK", "KEY CUT", "LOW OCT", "HIGH OCT", "MIDI CH", "MIDI CUT"};
for (uint32_t c = 0; c < 4; c++) {
uint32_t x = (cur_page()->graph == GR_SPLIT2 ? 4u : 0u) + c, f = split_field(c);
int32_t v = split_value(f) + (f == 1u || f == 2u || f == 3u || f == 6u);
fmt_int(val, v);
hot_text_column(c, labels[x], f ? val : split_cfg[0] ? "ON" : "OFF");
}
return;
}
if (FIT_PAGE(cur_page())) { /* (codex/coherence) RHYTHM: SPAN FIT (LEN DIV: LENGTH's) */
fmt_int(val, (int32_t)fit_span(TSEL));
hot_gauge_column(0, "SPAN", val, (int32_t)(fit_span(TSEL) - 1u) * 1000 / 63);
hot_text_column(1, "FIT", TSEL->seq_fit & 128u ? "ON" : "OFF");
empty_column(2);
empty_column(3);
return;
}
if (cur_page()->graph == GR_SLOTS) { /* (0.6.12) PROJECT, PART A-D, then LOAD ERASE SAVE (as USER) */
uint32_t k = (uint32_t)song.g[G_SLOT] - 1u;
int used = graph_project_used(k);
if (save_level() == SV_PROJ) { /* (0.8.5) SAVE > PROJECT's PART SLOTS: PART, its NAME */
val[0] = (char)('A' + (k & 3u)); val[1] = 0;
hot_gauge_column(0, "PART", val, (int32_t)(k & 3u) * 1000 / 3);
draw_act_column(2, "ERASE", used ? T_THEME : T_DIM, ICON_AUTO); /* (V10.17; the name: the card) */
} else {
fmt_int(val, (int32_t)song_save_target + 1);
hot_gauge_column(0, "PROJECT", val, (int32_t)song_save_target * 1000 / (int32_t)(NSONG - 1u));
draw_act_column(2, "ERASE", T_THEME, ICON_AUTO);
}
draw_act_column(1, "LOAD", used || (save_level() == SV_LIB && (song_draft || song_save_target != song_cur)) ? T_THEME : T_DIM, ICON_AUTO);
draw_act_column(3, "SAVE", T_THEME, ICON_AUTO);
return;
}
if (cur_page()->graph == GR_USER) { /* SLOT, then three GO buttons */
int used = up_used(ui.uslot);
up_slot_label(val, ui.uslot);
hot_gauge_column(0, "SLOT", val, (int32_t)ui.uslot * 1000 / (int32_t)(UP_SLOTS - 1u));
draw_act_column(1, "LOAD", used ? T_THEME : T_DIM, ICON_AUTO);
draw_act_column(2, "ERASE", used ? T_THEME : T_DIM, ICON_AUTO);
draw_act_column(3, "SAVE", T_THEME, ICON_AUTO);
return;
}
if (cur_page()->graph == GR_SLPIT) { /* (JIANT 0.6.3) STEP, its PIT, LEN, QNT */
uint32_t id = G_SLP0 + (sl_ui_step & 15u);
fmt_int(val, (int32_t)sl_ui_step + 1);
draw_column(0, "STEP", val, "/16", sl_ui_step < (uint32_t)song.g[G_SLPLEN] ? VAL(0u) : T_DIM,
(int32_t)sl_ui_step * 1000 / 15, ICON_AUTO);
pf_column(1, "PITCH", &GP[id], song.g[id], song.g[id] ? VAL(1u) : T_DIM, ICON_AUTO);
pf_column(2, "LEN", &GP[G_SLPLEN], song.g[G_SLPLEN], VAL(2u), ICON_AUTO);
param_format(&GP[G_SLPQ], song.g[G_SLPQ], val, &unit);
hot_unit_column(3, "QUANT", val, unit);
return;
}
if (cur_page()->graph == GR_MSEQ) { /* (JIANT) STEP, its LVL, LEN, SLEW */
const track_t *t = TSEL;
uint32_t id = P_MS0 + (ms_ui_step & 15u);
fmt_int(val, (int32_t)ms_ui_step + 1);
draw_column(0, "STEP", val, "/16", ms_ui_step < (uint32_t)t->p[P_MSLEN] ? VAL(0u) : T_DIM,
(int32_t)ms_ui_step * 1000 / 15, ICON_AUTO);
pf_column(1, "LEVEL", &TP[id], t->p[id], VAL(1u), ICON_LEVEL);
pf_column(2, "LEN", &TP[P_MSLEN], t->p[P_MSLEN], VAL(2u), ICON_AUTO);
pf_column(3, "SLEW", &TP[P_MSSLW], t->p[P_MSSLW], t->p[P_MSSLW] ? VAL(3u) : T_DIM, ICON_GLIDE);
return;
}
if (fop_page(cur_page()->graph)) { /* (0.6.10) FM6: OP, then three of its bytes (ui_fm6op.c) */
for (c = 0; c < 4u; c++) {
const char *lb, *u;
int32_t r;
uint32_t ic;
int on;
if (!fop_ok()) { /* (the engine changed before ui_draw left the page) */
empty_column(c);
continue;
}
on = fop_card(c, &lb, val, &u, &r, &ic);
draw_column(c, lb, val, u, on ? VAL(c) : T_DIM, r, ic);
}
return;
}
if (cur_page()->graph == GR_MOD) { /* SLOT, then that slot's SRC DST AMT */
const track_t *t = TSEL;
uint32_t id = P_M1SRC + 3u * mod_ui_slot;
int32_t s = t->p[id], d = t->p[id + 1u], a = t->p[id + 2u];
fmt_int(val, (int32_t)mod_ui_slot + 1);
draw_column(0, "SLOT", val, "/4", VAL(0u), (int32_t)mod_ui_slot * 1000 / 3, mod_src_icon(MS_OFF)); /* (the mod icon) */
text_column(1, "SRC", N_MSRC[clamp(s, 0, MS_N - 1)], s ? VAL(1u) : T_DIM);
text_column(2, mod_dst_scope(t, d) == 'M' ? "MASTER" : mod_dst_scope(t, d) == 'V' ? "VOICE" : "TRACK", mod_dst_name(t, d), d ? VAL(2u) : T_DIM);
pf_column(3, "AMT", &TP[id + 2u], a, a ? VAL(3u) : T_DIM, mod_src_icon(MS_OFF));
return;
}
if (cur_page()->graph == GR_ROLL && lock_held()) { /* a step held: what KNOB 1..4 lock (ui_input.c lock_turn) */
uint64_t held = lock_held();
uint32_t st = 0;
while (!((held >> st) & 1u))
st++; /* (the first step held: its values) */
for (c = 0; c < 4u; c++) {
uint32_t id = lock_id(c);
const param_desc_t *d;
int16_t v;
int on;
if (id == 0xFFu) {
empty_column(c);
continue;
}
d = track_desc(TSEL, id);
on = motion_lock_get(TSEL, st, id, &v);
if (!on)
v = motion_base_value(TSEL, id); /* not locked: the sound's own, DIM */
param_format(d, v, val, &unit);
draw_column(c, d->label, val, unit, on ? VAL(c) : T_DIM, RATIO(d, enum_rank(d, v)), param_icon(d, v));
}
return;
}
if (cur_page()->scope == SC_STEP && drum_track(TSEL)) { /* the grid: STEP LANE HIT ACC */
const step_t *st = &seq_steps(TSEL)[ui.cursor];
uint32_t b = 1u << ui.lane, on = (step_lanes_of(TSEL,st) & b) != 0u, ac = (step_accents_of(TSEL,st) & b) != 0u;
char sn[8], sl[8];
fmt_int(sn, (int32_t)ui.cursor + 1);
str_cpy(sl, "/", 8);
fmt_int(sl + 1, TSEL->p[P_SLEN]);
jam_card();
hot_text_column(1, "LANE", drum_lane_name(TSEL, ui.lane));
text_column(2, "HIT", GRID_HIT[grid_hit_of(st, ui.lane)], on ? VAL(2u) : T_DIM); /* (0.8.5: its mode) */
text_column(3, "ACC", ac ? "ON" : "--", ac ? VAL(3u) : T_DIM);
return;
}
if (cur_page()->scope == SC_STEP && cur_page()->id[0] == 4u) { /* (0.6.81) SEQ > NOTE: FOCUS PITCH MOVE; (0.6.92) MICRO
* (the step off the grid, 0.6.88's TIMING; on a kit: STEP and MICRO) */
const step_t *st = &seq_steps(TSEL)[ui.cursor];
uint32_t kit = drum_track(TSEL), on = st->time == ST_NOTE && (kit ? st->hit != 0u : st->n != 0u);
uint32_t f = on && !kit && ui.pr_focus <= st->n ? ui.pr_focus : 0u;
int32_t m = ST_MICRO(st);
char fo[8], pn[8], sn[8], mo[10];
if (!f) str_cpy(fo, on && !kit && st->n > 1u ? "CHORD" : "ALL", 8);
else { str_cpy(fo, "NOTE ", 8); fmt_int(fo + 5, (int32_t)f); }
if (on && !kit) note_name(pn, st->note[f ? f - 1u : 0u]); else str_cpy(pn, "--", 8);
fmt_int(sn, (int32_t)ui.cursor + 1);
if (!m) str_cpy(mo, on ? "GRID" : "--", sizeof mo);
else { mo[0] = m < 0 ? '-' : '+'; fmt_int(mo + 1, m < 0 ? -m : m); str_cpy(mo + str_len(mo), "/64", 4); } /* (0.9.1) */
if (kit) hot_text_column(0, "STEP", sn);
else text_column(0, "FOCUS", fo, on ? VAL(0u) : T_DIM);
text_column(1, "PITCH", pn, on && !kit ? VAL(1u) : T_DIM);
unit_column(2, "MOVE", kit ? "--" : sn, kit ? "" : "<>", on && !kit ? VAL(2u) : T_DIM);
gauge_column(3, "MICRO", mo, on && m ? VAL(3u) : T_DIM, on ? (m - MICRO_MIN) * 1000 / (MICRO_MAX - MICRO_MIN) : -1);
return;
}
if (cur_page()->scope == SC_STEP) {
static const char *const TIME_N[3] = {"NOTE", "TIE", "REST"};
const step_t *st = &seq_steps(TSEL)[ui.cursor];
char u[8];
uint32_t cnt = st->n, first = st->note[0], l;
for (l = NLANE; l-- > 0;) /* (lane hits count as their notes) */
if ((st->hit >> l) & 1u) {
cnt++;
if (!st->n)
first = DRUM_LANE_NOTE[l];
}
if (cnt) {
note_name(val, first);
u[0] = 0;
if (cnt > 1) {
str_cpy(u, "+", 8);
fmt_int(u + 1, (int32_t)cnt - 1);
}
} else {
str_cpy(val, "--", 12);
u[0] = 0;
}
{
static const char *const FLAG_N[4] = {"-", "ACC", "SLD", "A+S"};
char sn[8], sl[8], tv[8];
uint32_t nl = st->time == ST_NOTE && st->n ? note_len(TSEL, ui.cursor, (uint32_t)clamp(TSEL->p[P_SLEN], 1, NSTEP)) : 1u;
fmt_int(sn, (int32_t)ui.cursor + 1);
str_cpy(sl, "/", 8);
fmt_int(sl + 1, TSEL->p[P_SLEN]);
if (nl > 1u) fmt_int(tv, (int32_t)nl); /* (0.8.4) a NOTE's length: 3 ST (NOTE: one step) */
else str_cpy(tv, TIME_N[st->time % 3u], sizeof tv);
jam_card();
unit_column(1, "NOTE", val, u, step_on(st) ? VAL(1u) : T_DIM);
hot_unit_column(2, "TIME", tv, nl > 1u ? "ST" : "");
{ /* (V10.8) VEL, past 127 the flags */
uint32_t f = (st->flags & SF_ACCENT ? 1u : 0u) | (st->flags & SF_SLIDE ? 2u : 0u);
char vv[8];
if (f) str_cpy(vv, FLAG_N[f], sizeof vv); else fmt_int(vv, st->vel ? st->vel : 96);
hot_text_column(3, "VEL", vv);
}
}
return;
}
for (c = 0; c < 4u; c++) {
static const char *const BUS_CARD[4] = {"DLY", "REV", "CHO", "SLC"}; /* (codex/coherence) FX > BUSES: each card its
* bus (DLY MIX, REV SIZE, CHO DEPTH, SLC DEPTH), as the tabs */
int16_t *vp;
const param_desc_t *d = page_desc(cur_page(), c, &vp);
if (c == 0u && BAR_PAGE(cur_page())) { /* (0.9.2) SEQ > BAR: KNOB 1 the bar ("2/4") */
uint32_t nb = ((uint32_t)clamp(TSEL->p[P_SLEN], 1, NSTEP) + 15u) / 16u;
char u[4] = "/1";
fmt_int(val, (int32_t)ui.bank + 1);
u[1] = (char)('0' + nb);
draw_column(0, "BAR", val, u, VAL(0u), nb > 1u ? (int32_t)ui.bank * 1000 / (int32_t)(nb - 1u) : 0, ICON_X_PATTERN);
continue;
}
if (!d || !d->label || d->label[0] == '-') {
empty_column(c);
continue;
}
if ((act_cols() >> c) & 1u) {
draw_act_column(c, d->label, T_THEME, ICON_AUTO);
continue;
}
if (cur_page()->id[c] == G_INFO && cur_page()->scope == SC_GLOBAL) {
fmt_int(val, (int32_t)(song.cpu_q8 * 100u / 256u));
unit = "%";
} else {
param_format(d, *vp, val, &unit);
if (sys_load && cur_page()->scope == SC_GLOBAL && /* (0.6.29) LOAD LITE / ECO swaps it while it sounds */
((cur_page()->id[c] == G_RTYPE && REV_LITE[sys_load % 3u][*vp <= 4 ? *vp : 0] != *vp) ||
((cur_page()->id[c] == G_DPIT || cur_page()->id[c] == G_DSPRY) && *vp)))
unit = N_LOAD[LOAD_ECO - sys_load % 3u];
if (sys_load == LOAD_ECO && cur_page()->scope == SC_TRACK && cur_page()->id[c] == P_CHOR && *vp)
unit = "ECO"; /* (0.6.30) no chorus: the send goes nowhere */
}
card_mot_of(vp); /* (a global: never) */
draw_column(c, cur_page()->graph == GR_BUSES ? BUS_CARD[c] : d->label, val, unit, vp == &lphase_ui && TSEL->p[P_LPHASE] < 0 ? T_DIM : VAL(c), d->fmt == F_ENUM && d->max < 2 ? -1 : RATIO(d, enum_rank(d, *vp)),
param_icon(d, *vp));
}
}
/* The power-on splash (main.c fm1_main, web/emu felucca_web.c; JIANT 0.5): the logo ("jiant fm" in the owner's pen,
* ui_signature.h, tools/gen_logo.py: a point every ~3 px, bit 7 of y a stroke's start). (V10.8.18, the owner's pick
* "Seis hilos") 0 .. SPL_IN ms: the six tracks' threads (TRK_COL) come in from the screen's edges, curving, easing out,
* onto the logo's first point; then the logo writes itself in the thermal scale (SPL_LOGO ms, the pen's tip white),
* a white flash at its start fading (300 ms); then six dots in the tracks' colours one by one under it; the version and
* "by Juan Jiant" under them from the first frame (V10.8.20). MENU > ANIM OFF: the last picture at once. The strokes are drawn smooth: each a
* line through its points, an antialiased round pen ~4 px wide stamped along it a pixel apart (spl_seg, spl_disc:
* the joins round; nothing new stored: the same points). In the saved palette (settings_init before it) */
#include "ui_signature.h"
#define SPL_IN 550u /* ms: the threads come in */
#define SPL_LOGO 800u /* .. the logo written */
#define SPL_WRITE 1750u /* .. the dots and the lines in: the animation */
#define SPL_HOLD 150u /* .. then still, before the UI (all: ~1.9 s) */
#define SPL_SY 40 /* the logo's canvas on the screen (240 x SIG_H + 12) */
#define SPL_TY 198 /* the two lines under it (the dots at 188) */
static const char *const SPLASH_LINES[] = {FELUCCA_VERSION, "by Juan Jiant"};
static uint8_t spl_anim, spl_clr; /* main.c: 1 = the splash animated (splash_write) */
/* an antialiased disc: centre (cx, cy) and radius r in Q4 (1/16 px), c over the canvas at strength a (0..256) */
static __attribute__((noinline)) void spl_disc(int32_t cx, int32_t cy, int32_t r, uint16_t c, int32_t a)
{
int32_t i, j, n = (r >> 4) + 2;
if (r < 4)
return;
for (j = -n; j <= n; j++)
for (i = -n; i <= n; i++) {
int32_t x = (cx >> 4) + i, y = (cy >> 4) + j, dx = x * 16 + 8 - cx, dy = y * 16 + 8 - cy, d = dx * dx + dy * dy, k;
k = r > 8 && d <= (r - 8) * (r - 8) ? 256 : d >= (r + 8) * (r + 8) ? 0 : ((r + 8) * (r + 8) - d) * 256 / (32 * r);
og_plot(x, y, c, k * a >> 8);
}
}
/* (V10.8.20, the owner: the version always seen) the version and "by Juan Jiant" at canvas y, from the first frame */
static __attribute__((noinline)) void spl_lines(int32_t y)
{
uint32_t k;
for (k = 0; k < 2u; k++)
cv_text_in(0, y + (int32_t)k * 16, 240, &AF_S, SPLASH_LINES[k], k ? T_DIM : T_MID, T_BG);
}
/* the round pen from (x0, y0) to (x1, y1) (Q4), a stamp a pixel (the joins round) */
static __attribute__((noinline)) void spl_seg(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t r, uint16_t c)
{
int32_t dx = x1 - x0, dy = y1 - y0, n = ((dx < 0 ? -dx : dx) > (dy < 0 ? -dy : dy) ? (dx < 0 ? -dx : dx) : (dy < 0 ? -dy : dy)) / 16 + 1, s;
for (s = 1; s <= n; s++)
spl_disc(x0 + dx * s / n, y0 + dy * s / n, r, c, 256);
}
/* the six threads' edges (px; the screen's centre + 170 px at k * 60 + 23 degrees) */
BTAPP_RO static const int16_t SPL_E[12] = {277, 186, 141, 289, -16, 222, -37, 54, 99, -49, 256, 18};
/* the threads at ms (< SPL_IN; the screen in two bands): quadratics from the edges bowed 30 px aside, eased out onto
* the logo's start (V10.8.35: in the image again, its edges still the Bluetooth segment's: without it, the screen dark that while) */
static __attribute__((noinline)) void spl_threads(uint32_t ms)
{
int32_t k, j, sx = 34 * 16, sy = (SPL_SY + 6 + 101) * 16, u = 256 - (int32_t)(ms * 256u / SPL_IN), e = 256 - u * u / 256 * u / 256;
for (j = 0; j < 2; j++) {
cv_begin(240, 120, T_BG);
cv_oy = -120 * j;
for (k = 0; k < 6; k++) {
int32_t ex = SPL_E[2 * k] * 16, ey = SPL_E[2 * k + 1] * 16, mx = ex + (sx - ex) * e / 256, my = ey + (sy - ey) * e / 256;
int32_t cx = (ex + mx) / 2 + (ey - 1920) * 3 / 17, cy = (ey + my) / 2 - (ex - 1920) * 3 / 17, t, x0 = ex, y0 = ey;
for (t = 0; t <= 16; t++) {
int32_t x = ((16 - t) * (16 - t) * ex + 2 * t * (16 - t) * cx + t * t * mx) / 256,
y = ((16 - t) * (16 - t) * ey + 2 * t * (16 - t) * cy + t * t * my) / 256;
spl_seg(x0, y0, x, y, 13, TRK_COL[k]);
x0 = x; y0 = y;
}
}
cv_oy = 0;
if (j)
spl_lines(SPL_TY - 120);
cv_blit(0, (uint32_t)(120 * j));
}
}
/* the splash at ms (>= SPL_WRITE: whole) */
static void splash_at(uint32_t ms)
{
int32_t i, k, x0 = 0, y0 = 0, sx = 34 * 16, sy = (SPL_SY + 6 + 101) * 16;
if (ms < SPL_IN) {
if (bt_hw_seg())
spl_threads(ms);
return;
}
ms -= SPL_IN;
if (!spl_clr) { /* (the threads' last picture away) */
spl_clr = 1;
lcd_fill(0, 0, 240, 240, T_BG);
}
cv_begin(240, SIG_H + 12, T_BG); /* the logo up to point n: the pen along its strokes */
cv_oy = -SPL_SY;
k = ms >= SPL_LOGO ? SIG_N : SIG_N * (int32_t)ms / (int32_t)SPL_LOGO;
for (i = 0; i < k; i++) {
int32_t x = ((240 - SIG_W) / 2 + SIG_PTS[2 * i]) * 16, y = (SPL_SY + 6 + (SIG_PTS[2 * i + 1] & 127)) * 16;
if (SIG_PTS[2 * i + 1] & 128) { x0 = x; y0 = y; } /* (a stroke's start) */
spl_seg(x0, y0, x, y, 30, heat_col(24 + i * 220 / SIG_N));
x0 = x; y0 = y;
}
if (k < SIG_N && k) /* the pen's tip */
spl_disc(x0, y0, 36, T_TEXT, 256);
if (ms < 300u) /* the flash at its start */
spl_disc(sx, sy, 128 - (int32_t)ms * 2 / 5, 0xFFFFu, 256 - (int32_t)ms * 256 / 300);
cv_oy = 0;
cv_blit(0, SPL_SY);
cv_begin(240, 52, T_BG); /* the six dots, the lines */
for (k = 0; k < 6; k++)
spl_disc((70 + 20 * k) * 16 + 8, 8 * 16 + 8, clamp((int32_t)ms - 700 - k * 60, 0, 200) * 48 / 200, TRK_COL[k], 256);
spl_lines(SPL_TY - 180);
cv_blit(0, 180);
}
static void draw_splash(void)
{
lcd_fill(0, 0, 240, 240, T_BG);
splash_at(spl_anim && !(ui_prefs & PREF_ANIM_OFF) ? 0u : SPL_WRITE);
lcd_sync();
}
/* main.c's splash loop: the splash ms after the start */
static void splash_write(uint32_t ms)
{
if (!spl_anim || (ui_prefs & PREF_ANIM_OFF))
return;
if ((int32_t)ms < 0) /* (V10.8.20: the emulator's first 30 ms came in below 0, as the
* end: its last picture, without the lines, and no more) */
ms = 0;
splash_at(ms);
lcd_sync();
}
/* UPDATE MODE countdown (main.c: OCT- + OCT+ held): over everything, the menu and the dialogs too */
static void draw_uboot(void)
{
static uint8_t shown;
char d[4] = {(char)('0' + ui.uboot % 10u), 0, 0, 0};
if (!ui.force && shown == ui.uboot)
return;
shown = ui.uboot;
lcd_fill(0, H_HEAD, 240, 240 - H_HEAD, T_BG);
ui.head_sig = ~0u;
draw_text_box(0, 76, 240, &AF_M, "UPDATE MODE IN", T_TEXT, 1);
draw_text_box(0, 102, 240, &AF_L, d, T_THEME, 1);
{ /* the two keycaps held, and what letting go does */
int32_t w = kc_w(KC_OCTDN) + 3 + kh_ink(KC_OCTUP, "LET GO TO CANCEL"), x = HALF_UP(240 - w);
cv_begin(240, KC_H + 2, T_BG);
GFX_HOOK_ALIGN(0, 0, 240, 0, AL_H | AL_N(3), "update-mode keys centred");
x = cv_keycap(x, 1, KC_OCTDN, T_KEY, T_INK, T_BG) + 3;
cv_key_hint(x, 1, KC_OCTUP, "LET GO TO CANCEL", 1, T_BG);
cv_blit(0, 149);
lcd_sync();
}
ui.force = 0;
}
/* (V10.7.22) the Bluetooth segment missing or another build's (ui.c seg_missing; GEN, the songs' saving, Bluetooth, USB
* HOST need it): what to do, over the screen. At power-on (main.c: ui.segbox, full: the header down, a key or a knob
* goes on) and on GEN instead of its cards (between its tabs and its foot) */
static void seg_screen(uint32_t full)
{
lcd_fill(0, full ? H_HEAD : 42u, 240, full ? 240u - H_HEAD : LZ_FOOT_Y - 42u, T_BG);
draw_text_box(0, 64, 240, &AF_S, SEG_MISS, T_ACCENT, 1);
draw_text_box(0, 98, 240, &AF_S, "REINSTALL WITH THE", T_TEXT, 1);
draw_text_box(0, 114, 240, &AF_S, "JIANT WEB INSTALLER:", T_TEXT, 1);
draw_text_box(0, 140, 240, &AF_S, "juanjiant-bit.github.io/JIANT", T_THEME, 1);
if (full)
draw_text_box(0, 190, 240, &AF_S, "ANY KEY: CONTINUE", T_DIM, 1);
}
/* the count-in (seq.c, MENU > COUNT-IN; 1.1, Discussion #131): over the page until the sequencer starts. Its bar's four
* beats counted down, 4 3 2 1, in four cells (the beat now filled THEME, those gone dim), with 2 BARS which bar it is;
* PLAY stops it. Drawn again on each beat (seq.c's state; the header stays live) */
#define CI_Y 88 /* the cells: 4 x 48 px, 8 px apart, 72 tall */
#define CI_H 72
static __attribute__((noinline)) void draw_countin(void)
{
static uint32_t shown;
uint32_t total = cin_total, e = total - cin_left, j, sig = total * 64u + e + 1u;
char sub[16];
int full = ui.force || shown / 64u != total; /* (0.9.0) a beat: its cells and the bar only (was the whole screen) */
if (!ui.force && shown == sig)
return;
shown = sig;
if (full) { /* (round what it draws, not under it too) */
const int16_t R[5][4] = {{0, 44, 240, AF_M.h}, {0, 66, 240, AF_S.h}, {12, CI_Y, 216, CI_H},
{0, CI_Y + CI_H + 14, 240, AF_S.h}, {0, 206, 240, KC_H + 2}};
fill_around(R, 5);
ui.head_sig = ~0u;
draw_text_box(0, 44, 240, &AF_M, "COUNT-IN", T_TEXT, 1);
}
if (total > 4u) {
str_cpy(sub, "BAR 1 OF 2", sizeof sub);
sub[4] = (char)('1' + e / 4u % 9u);
sub[9] = (char)('0' + total / 4u % 10u);
} else
str_cpy(sub, "1 BAR", sizeof sub);
draw_text_box(0, 66, 240, &AF_S, sub, T_MID, 1);
cv_begin(216, CI_H, T_BG);
for (j = 0; j < 4u; j++) {
int32_t x = (int32_t)j * 56;
char d[2] = {(char)('4' - j), 0};
int now = j == e % 4u, gone = j < e % 4u;
uint16_t fill = now ? T_THEME : T_SURF;
cv_rrect(x, 0, 48, CI_H, 8, fill, T_BG);
GFX_HOOK_ALIGN(x, 0, x + 48, CI_H, AL_HV, "count-in beat centred in its cell");
cv_text_in(x, CAP_IN(L, CI_H), 48, &AF_L, d, now ? T_INK : gone ? T_DIM : T_TEXT, fill);
}
cv_blit(12, CI_Y);
if (!full) {
ui.force = 0;
return;
}
{ /* PLAY stops it */
int32_t x = HALF_UP(240 - kh_ink(KC_PLAY, "STOP"));
cv_begin(240, KC_H + 2, T_BG);
GFX_HOOK_ALIGN(0, 0, 240, 0, AL_H | AL_N(2), "count-in key centred");
cv_key_hint(x, 1, KC_PLAY, "STOP", 1, T_BG);
cv_blit(0, 206);
lcd_sync();
}
ui.force = 0;
}
/* the OCT- / OCT+ dialog: what it does (ui.confirm, ui.confirm_trk) on two lines, on a surface */
#define DLG_X 16
#define DLG_Y 62
#define DLG_W 208
#define DLG_H 116
static void confirm_text(char *a, char *b)
{
uint32_t k = ui.confirm_trk;
b[0] = 0;
switch (ui.confirm) {
case CF_CLEAR_TRK:
str_cpy(a, "CLEAR TRACK 1?", 24);
a[12] = (char)('1' + k % NTRK);
break;
case CF_OVR_SONG:
str_cpy(a, "OVERWRITE PROJECT ", 24);
fmt_int(a + str_len(a), (int32_t)k + 1);
str_cpy(a + str_len(a), "?", 2);
break;
case CF_OVR_PROJ:
str_cpy(a, "OVERWRITE PROJECT A?", 24);
a[18] = (char)('A' + (k & 3u));
if (!project_name(k & 3u, b) || !b[0]) /* the project's name, else what SONG plays from it */
str_cpy(b, "SONG PATTERN CHANGES", 24);
break;
case CF_DEL_ROW:
str_cpy(a, "DELETE SONG ROW?", 24);
break;
case CF_CLEAR_SONG:
str_cpy(a, "CLEAR SONG ORDER?", 24);
break;
case CF_INIT_SOUND:
str_cpy(a, drum_track(TSEL) ? "INIT SOUND + KIT?" : "INITIALIZE SOUND?", 24);
break;
case CF_CLEAR_ALL:
str_cpy(a, "CLEAR ALL SEQUENCES?", 24);
break;
case CF_CPU_TEST: /* (0.6.83) SAVE > TOOLS 6 */
str_cpy(a, "CPU TEST SONG?", 24);
break;
case CF_INIT_SYS: /* (0.6.40) SAVE > TOOLS; (V10.7.22) CLEAR PROJECT, MENU > INIT */
str_cpy(a, "CLEAR PROJECT?", 24);
break;
case CF_DICE_SOUND: /* (0.6.65) EDIT + SELECT: heard already */
case CF_DICE_LFO:
case CF_DICE_FX:
str_cpy(a, drum_track(TSEL) ? "KEEP DICED KIT?" : "KEEP DICED SOUND?", 24);
break;
case CF_DICE_ALL: /* (0.6.21) HOME + SELECT */
str_cpy(a, "DICE EVERYTHING?", 24);
break;
case CF_RECALL_SOUND:
str_cpy(a, drum_track(TSEL) ? "RECALL SOUND + KIT?" : "RECALL SAVED SOUND?", 24);
break;
case CF_CLEAR_MOTION:
str_cpy(a, "CLEAR T1 AUTOMATION?", 24); a[7] = (char)('1' + k % NTRK);
break;
case CF_CLEAR_COMP: /* (V10.7.62) SEQ > STEP FX, OCT- */
str_cpy(a, "CLEAR T1 STEP FX?", 24); a[7] = (char)('1' + k % NTRK);
break;
case CF_OVR_USER:
str_cpy(a, "OVERWRITE ", 24);
up_slot_label(a + str_len(a), k);
str_cpy(a + str_len(a), "?", 2);
up_name(k, b); /* the sound stored there */
break;
case CF_ERASE_SONG:
str_cpy(a, "ERASE PROJECT ", 24); fmt_int(a + str_len(a), (int32_t)k + 1); str_cpy(a + str_len(a), "?", 2);
str_cpy(b, "ALL A-D + ARRANGEMENT", 24);
break;
case CF_ERASE_SECT: /* (V10.17) SAVE > PART SLOTS > ERASE */
str_cpy(a, "ERASE PART A?", 24);
a[11] = (char)('A' + (k & 3u));
str_cpy(b, graph_project_used(k & 3u) && graph_project_name(k & 3u)[0] ? graph_project_name(k & 3u) : "", 24);
break;
case CF_ERASE_USER:
str_cpy(a, "ERASE ", 24);
up_slot_label(a + str_len(a), k);
str_cpy(a + str_len(a), "?", 2);
up_name(k, b);
break;
default:
str_cpy(a, "CLEAR T1 SEQUENCE?", 24); /* the header (T1..T4) is hidden */
a[7] = (char)('1' + k % NTRK);
break;
}
}
static void gen_cards(void); /* (0.8.5) gen.c: GEN in HOME's lens, its cards */
/* (0.8.5) the dialogs as the approved mock-up (NOTICE . DICE . NAME): their tabs under the header, the breadcrumb at the
* foot. NOTICE (the OCT- / OCT+ questions): a RAISE card under a THEME rule, "?" in the accent, the question, the detail,
* two buttons (OCT- NO, OCT+ YES in the accent, underlined). DICE (KEEP DICED ...?): the part's cards, BEFORE and NOW
* side by side (dice_panel, ui_input.c), the question in a strip with its two buttons. No icons */
static void dice_panel(void); /* (ui_input.c: what the dice had, what it has) */
/* (0.9.0) BG under the header everywhere but in the n rectangles {x, y, w, h} the screen is about to draw (a dialog's, NAME's
* strips): a band at a time between their edges, the gaps across it (was all of it filled, then drawn over: ~1.7 screens) */
static void fill_around(const int16_t (*r)[4], uint32_t n)
{
int32_t ys[2 + 2 * 8], ny = 0, i, j, k;
ys[ny++] = H_HEAD;
ys[ny++] = 240;
for (i = 0; i < (int32_t)n && i < 8; i++) {
ys[ny++] = r[i][1];
ys[ny++] = r[i][1] + r[i][3];
}
for (i = 1; i < ny; i++) /* (sorted: a few) */
for (j = i; j > 0 && ys[j - 1] > ys[j]; j--)
k = ys[j], ys[j] = ys[j - 1], ys[j - 1] = k;
for (i = 0; i + 1 < ny; i++) {
int32_t y0 = ys[i] < H_HEAD ? H_HEAD : ys[i], y1 = ys[i + 1] > 240 ? 240 : ys[i + 1], x = 0;
if (y1 <= y0)
continue;
for (;;) { /* from x: the next rectangle covering the band, the gap before it */
int32_t nx = 240, ne = 240;
for (j = 0; j < (int32_t)n; j++)
if (r[j][1] <= y0 && r[j][1] + r[j][3] >= y1 && r[j][0] + r[j][2] > x && r[j][0] < nx)
nx = r[j][0] < x ? x : r[j][0], ne = r[j][0] + r[j][2];
if (nx > x)
lcd_fill((uint32_t)x, (uint32_t)y0, (uint32_t)(nx - x), (uint32_t)(y1 - y0), T_BG);
if (nx >= 240)
break;
x = ne;
}
}
}
#define DLG_TAB_H LT_H /* the dialogs' tabs (tabs_paint) */
static void dlg_tabs(uint32_t lv)
{
static const char *const DN[3] = {"NOTICE", "DICE", "NAME"};
tabs_paint(3, lv, DN, 0, 0, 0); /* (0.8.9: in the skin's tabs) */
}
static void dlg_crumb(const char *a, const char *b) /* "SAVE . NOTICE . CONFIRM": the section, the dialog's kind THEME,
* what it asks TEXT (0.9.2: was "LENTE") */
{
int32_t x;
cv_begin(240, LZ_FOOT_H, T_BG);
x = cv_text(6, CRUMB_Y, &AF_X, SEC_NAME[nav_sec()], T_DIM);
x = cv_text(x, CRUMB_Y, &AF_X, " \xB7 ", T_DIM);
x = cv_text(x, CRUMB_Y, &AF_X, a, T_THEME);
x = cv_text(x, CRUMB_Y, &AF_X, " \xB7 ", T_DIM);
cv_text(x, CRUMB_Y, &AF_X, b, T_TEXT);
cv_blit(0, LZ_FOOT_Y);
}
/* a dialog's card: (V10.7.23) no box, its shape a THEME line, as the knobs' cards; what lies under its words */
static uint16_t dlg_card(int32_t x, int32_t y, int32_t w, int32_t h)
{
card_line(x, y, w, h, 5, T_THEME, 1);
return T_BG;
}
static void dlg_button(int32_t x, int32_t y, int32_t w, const char *k, const char *a, int yes, uint16_t under)
{
cv_rrect(x, y, w, 34, 4, T_SURF, under);
cv_text_on(x + 6, y + 5 - AF_X_CAP_Y, &AF_X, k, T_DIM, T_SURF);
cv_text_on(x + 6, y + 16 - AF_M_CAP_Y, &AF_M, a, yes ? T_ACCENT : T_TEXT, T_SURF);
cv_rect(x + 6, y + 30, w - 12, yes ? 2 : 1, yes ? T_ACCENT : T_LINE);
}
static void draw_confirm(void)
{
char a[24], b[24];
const aafont_t *tf = &AF_M;
int dk = ui.confirm >= CF_DICE_SOUND && ui.confirm <= CF_DICE_FX;
confirm_text(a, b);
if (dk)
lcd_fill(0, H_HEAD, 240, 240 - H_HEAD, T_BG); /* (DICE: BEFORE / NOW fill the screen, its box) */
/* (0.9.5) NOTICE: its tabs, its card and the breadcrumb alone, the page live round them (ui_draw_page, dlg_holes; 0.9.0
* .. 0.9.4: BG round them, the page gone) */
ui.head_sig = ~0u;
dlg_tabs(dk ? 1u : 0u);
if (dk) { /* DICE: the part, BEFORE / NOW, the question in a strip */
static const char *const PART[4] = {"SOUND", "SEQ", "LFO", "FX"};
uint32_t pk = (uint32_t)(ui.confirm - CF_DICE_SOUND) & 3u;
dice_panel();
uint16_t cb, kb = T_SURF;
cv_begin(240, 30, T_BG);
cb = dlg_card(4, 0, 232, 30);
cv_text_on(10, 7 - AF_S_CAP_Y, &AF_S, a, T_TEXT, cb);
cv_text_on(10, 20 - AF_X_CAP_Y, &AF_X, b, T_DIM, cb);
cv_rrect(140, 3, 48, 25, 3, T_SURF, cb);
cv_rrect(192, 3, 40, 25, 3, T_SURF, cb);
cv_text_in(140, 5 - AF_X_CAP_Y, 48, &AF_X, "OCT-", T_DIM, kb); /* (the labels' face: two lines of 9 px, CANCEL 44 wide) */
cv_text_in(140, 16 - AF_X_CAP_Y, 48, &AF_X, "CANCEL", T_MID, kb);
cv_text_in(192, 5 - AF_X_CAP_Y, 40, &AF_X, "OCT+", T_DIM, kb);
cv_text_in(192, 16 - AF_X_CAP_Y, 40, &AF_X, "OK", T_ACCENT, kb);
cv_blit(0, 194);
dlg_crumb("DICE", drum_track(TSEL) && pk == 0u ? "KIT" : PART[pk]);
return;
}
cv_begin(212, 140, T_BG); /* NOTICE: the card */
{
uint16_t cb = dlg_card(0, 0, 212, 140);
cv_text_on(12, 12 - AF_M_CAP_Y, &AF_M, "?", T_ACCENT, cb);
if (text_w(tf, a) > 196)
tf = &AF_S;
GFX_HOOK_ALIGN(0, 0, 212, 0, AL_H, "dialog question centred");
cv_text_in(0, 36, 212, tf, a, T_TEXT, cb);
if (b[0]) {
char f[32];
text_fit(f, sizeof f, b, &AF_S, 196); /* a name: free text */
GFX_HOOK_ALIGN(0, 0, 212, 0, AL_H, "dialog detail centred");
cv_text_flags(ink_in(&AF_S, f, 212), 60, &AF_S, f, T_MID, cb, 8u | (f[str_len(f) - 1u] == ELLIPSIS));
}
dlg_button(12, 92, 90, "OCT -", ui.confirm == CF_DICE_ALL ? "CANCEL" : "NO", 0, cb);
dlg_button(110, 92, 90, "OCT +", "YES", 1, cb);
}
cv_blit(14, 66);
dlg_crumb("NOTICE", "CONFIRM");
}
/* (0.8.5) the end of a lens screen drawn outside the page path (GEN): the second message, the timers, the footer and the
* tabs */
static void lz_frame_end(void)
{
if (ui.msg_t && !--ui.msg_t && ui.msg2[0]) {
str_cpy(ui.msg, ui.msg2, sizeof ui.msg);
ui.msg2[0] = 0;
ui.msg_t = 60;
}
if (ui.bpm_t)
ui.bpm_t--;
if (ui.hot_t)
ui.hot_t--;
if (pf_on)
page_flash_draw();
if (!pf_on)
draw_foot();
draw_tabs();
ui.force = 0;
}
static void ui_draw_page(uint32_t counting);
static void ui_draw(void)
{
static uint8_t counting;
ui.frame++;
anim_sync(); /* (codex/anim) the animation's clock, the detail (ui.c) */
if (counting != (uint8_t)seq_counting()) { /* a count-in began or ended: the page drawn again after it */
counting = (uint8_t)seq_counting();
ui.force = 1;
}
if (!scr_frame()) /* MENU > SCREEN OFF: dark (or waking), nothing drawn */
return;
anim_st.non = 1; /* (codex/anim: the lens's entries worked out once, ui_lens.c) */
anim_st.nkey = 0;
ui_draw_page(counting);
anim_st.non = 0;
scr_shown();
}
static uint8_t dlg_behind; /* (0.9.5) the page being drawn round a NOTICE */
/* (0.9.5) a NOTICE (the OCT- / OCT+ questions) over the page: its tabs, its card, its breadcrumb the screen's holes (gfx.c
* scr_holes), the page drawn round them as ever (DICE's BEFORE / NOW are the whole screen; over the menu, NAME, UPDATE MODE:
* as before) */
static int dlg_notice(void)
{
return dlg_on() && !(ui.confirm >= CF_DICE_SOUND && ui.confirm <= CF_DICE_FX) && !ui.uboot && !ui.menu && !name_on();
}
static void ui_draw_body(uint32_t counting);
static void ui_draw_page(uint32_t counting)
{
if (dlg_notice()) {
const int16_t R[3][4] = {{0, LT_Y, 240, (int16_t)DLG_TAB_H}, {14, 66, 212, 140}, {0, LZ_FOOT_Y, 240, LZ_FOOT_H}};
uint8_t f = ui.force;
scr_holes(R, 3);
dlg_behind = 1;
ui_draw_body(counting);
dlg_behind = 0;
scr_holes(R, 0);
if (f) { /* (the page first: the box drawn over it, the lint's order too) */
draw_confirm();
ui.head_sig = ~0u;
}
return;
}
ui_draw_body(counting);
}
static void ui_draw_body(uint32_t counting)
{
if (ui.uboot) {
draw_uboot();
draw_head();
return;
}
if (ui.segbox) { /* (V10.7.22) the power-on's BLUETOOTH PART MISSING */
if (ui.force)
seg_screen(1);
ui.force = 0;
draw_head();
return;
}
if (ui.menu) {
draw_menu();
ui.force = 0;
return;
}
if (counting && !dlg_on() && !name_on()) { /* the count-in: over the page (and a layer) */
draw_countin();
draw_head();
return;
}
if (dlg_on() && !dlg_behind) { /* the OCT- / OCT+ dialog (NOTICE: over the page, ui_draw_page) */
if (ui.force) {
draw_confirm();
ui.force = 0;
}
draw_head(); /* recording remains visible over confirmations */
return;
}
if (name_on()) { /* NAME: a user preset's or a project's (ui_name.c) */
name_draw();
return;
}
if (ui.layer || mac_latch) { /* a layer's map over the page (ui_layer.c); (JIANT 0.4) the MACRO
* layer latched: its cards (no layer open) */
uint8_t hm = !ui.layer;
static uint8_t hm_was;
if (hm != hm_was)
ui.force = 1, hm_was = hm;
if (hm)
ui.layer = LAYER_MACRO;
if (ui.force)
draw_frame();
draw_head();
draw_layer();
if (hm)
ui.layer = 0;
if (ui.msg_t && !--ui.msg_t && ui.msg2[0]) {
str_cpy(ui.msg, ui.msg2, sizeof ui.msg);
ui.msg2[0] = 0;
ui.msg_t = 60;
}
if (ui.hot_t)
ui.hot_t--;
if (ui.bpm_t)
ui.bpm_t--;
ui.force = 0;
return;
}
if (ui.confirm == CF_DICE_ALL) { /* (0.8.5) GEN: HOME's lens, its last level (0.9.2: under
* a layer's map, a page as the others) */
if (ui.force)
draw_frame();
draw_head();
if (!bt_hw_seg()) { /* (V10.7.22) GEN's code is in the segment: what to do, not
* HOME's cards left under its tabs */
if (ui.force)
seg_screen(0);
} else {
gen_cards();
draw_graph();
}
lz_frame_end();
return;
}
if (!ui.home && !page_visible(ui.page)) { /* an OP page of a track that is not DIGITAL (without
* FELUCCA_FM4: any track): EDIT 1 */
uint32_t e1 = nv_page(SEC_EDIT, 0); /* (V10.7.21: EDIT 1 as shown on this track: ANALOG's own) */
ui.page = (uint8_t)(e1 < NPAGES ? e1 : page_first(FAM_EDIT));
page_entered();
}
cursor_fix();
if (ui.force)
draw_frame();
felucca_dbg.stage = 3;
draw_head();
felucca_dbg.stage = 4;
draw_columns();
felucca_dbg.stage = 5;
draw_graph();
if (ui.msg_t && !--ui.msg_t && ui.msg2[0]) { /* the second message (ui_notices) */
str_cpy(ui.msg, ui.msg2, sizeof ui.msg);
ui.msg2[0] = 0;
ui.msg_t = 60;
}
if (ui.bpm_t)
ui.bpm_t--;
if (ui.hot_t)
ui.hot_t--;
felucca_dbg.stage = 6;
if (pf_on) /* (0.6.61) the page's name for a moment; (0.6.64) over the
* footer, which says the same: the header, the cards and
* the graph stay in sight */
page_flash_draw();
if (!pf_on) /* (its end: the footer back at once) */
draw_foot();
if (lz_on()) /* (0.8.5) a lens page: the level's tabs on top */
draw_tabs();
ui.force = 0;
}