From 385c70e9e802d0b84a7435f992669660aa2ae255 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 21 Jul 2023 19:34:10 +0200 Subject: Add cursor drawing to square params in new UI --- src/drawing.c | 260 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 144 insertions(+), 116 deletions(-) diff --git a/src/drawing.c b/src/drawing.c index 78021c0..fcbdb95 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -464,135 +464,163 @@ draw_piano(void) { void draw_params_cursor_wave(size_t i, u8 clr) { - u8 x_positions[] = { - // 32 half bytes (Wave A). - 0, 4, 8, 12, 16, 20, 24, 28, - 34, 38, 42, 46, 50, 54, 58, 62, - 0, 4, 8, 12, 16, 20, 24, 28, - 34, 38, 42, 46, 50, 54, 58, 62, - // 32 half bytes (Wave B). - 70, 74, 78, 82, 86, 90, 94, 98, - 104, 108, 112, 116, 120, 124, 128, 132, - 70, 74, 78, 82, 86, 90, 94, 98, - 104, 108, 112, 116, 120, 124, 128, 132, - // Default wave A. - 1, 18, 35, 52, - // Default wave B. - 71, 88, 105, 122, - // Mode selection. - 141, - // Volume selection. - 141, - }; - u8 y_positions[] = { - // 32 half bytes (Wave A) - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - // 32 half bytes (Wave B) - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - // Default wave A. - 21, 21, 21, 21, - // Default wave B. - 21, 21, 21, 21, - // Mode selection. - 21, - // Volume selection. - 1, - }; - size_t cursor_length = 0; - if (i < 64) { - cursor_length = 4; - } else if (i < 72) { - cursor_length = 13; - } else { - cursor_length = 30; - } - size_t x = PARAMS_START_X + x_positions[i] - 1; - size_t y = PARAMS_START_Y + PARAMS_H - 25 + y_positions[i]; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x, y, x + cursor_length, y, clr); - draw_line(x, y + 1, x + cursor_length, y + 1, clr); - } break; - default: { - draw_line(x, y, x + cursor_length, y, clr); - } break; - } + // u8 x_positions[] = { + // // 32 half bytes (Wave A). + // 0, 4, 8, 12, 16, 20, 24, 28, + // 34, 38, 42, 46, 50, 54, 58, 62, + // 0, 4, 8, 12, 16, 20, 24, 28, + // 34, 38, 42, 46, 50, 54, 58, 62, + // // 32 half bytes (Wave B). + // 70, 74, 78, 82, 86, 90, 94, 98, + // 104, 108, 112, 116, 120, 124, 128, 132, + // 70, 74, 78, 82, 86, 90, 94, 98, + // 104, 108, 112, 116, 120, 124, 128, 132, + // // Default wave A. + // 1, 18, 35, 52, + // // Default wave B. + // 71, 88, 105, 122, + // // Mode selection. + // 141, + // // Volume selection. + // 141, + // }; + // u8 y_positions[] = { + // // 32 half bytes (Wave A) + // 0, 0, 0, 0, 0, 0, 0, 0, + // 0, 0, 0, 0, 0, 0, 0, 0, + // 9, 9, 9, 9, 9, 9, 9, 9, + // 9, 9, 9, 9, 9, 9, 9, 9, + // // 32 half bytes (Wave B) + // 0, 0, 0, 0, 0, 0, 0, 0, + // 0, 0, 0, 0, 0, 0, 0, 0, + // 9, 9, 9, 9, 9, 9, 9, 9, + // 9, 9, 9, 9, 9, 9, 9, 9, + // // Default wave A. + // 21, 21, 21, 21, + // // Default wave B. + // 21, 21, 21, 21, + // // Mode selection. + // 21, + // // Volume selection. + // 1, + // }; + // size_t cursor_length = 0; + // if (i < 64) { + // cursor_length = 4; + // } else if (i < 72) { + // cursor_length = 13; + // } else { + // cursor_length = 30; + // } + // size_t x = PARAMS_START_X + x_positions[i] - 1; + // size_t y = PARAMS_START_Y + PARAMS_H - 25 + y_positions[i]; + // switch (settings.cursor) { + // case CURSOR_THICK_LINE: { + // draw_line(x, y, x + cursor_length, y, clr); + // draw_line(x, y + 1, x + cursor_length, y + 1, clr); + // } break; + // default: { + // draw_line(x, y, x + cursor_length, y, clr); + // } break; + // } } void draw_params_cursor_noise(size_t i, u8 clr) { - u8 x_positions[] = { - 0, // Bit mode. - 31, // Env. Vol. - 59, // Env. Direction. - 87, // Env. Time. - }; - u8 y_positions[] = { - 20, // Bit mode. - 20, // Env. Vol. - 20, // Env. Direction. - 20, // Env. Time. - }; - size_t cursor_length = 24; - size_t x = PARAMS_START_X + x_positions[i] + 30; - size_t y = PARAMS_START_Y + PARAMS_H - 24 + y_positions[i]; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x, y, x + cursor_length, y, clr); - draw_line(x, y + 1, x + cursor_length, y + 1, clr); - } break; - default: { - draw_line(x, y, x + cursor_length, y, clr); - } break; - } + // u8 x_positions[] = { + // 0, // Bit mode. + // 31, // Env. Vol. + // 59, // Env. Direction. + // 87, // Env. Time. + // }; + // u8 y_positions[] = { + // 20, // Bit mode. + // 20, // Env. Vol. + // 20, // Env. Direction. + // 20, // Env. Time. + // }; + // size_t cursor_length = 24; + // size_t x = PARAMS_START_X + x_positions[i] + 30; + // size_t y = PARAMS_START_Y + PARAMS_H - 24 + y_positions[i]; + // switch (settings.cursor) { + // case CURSOR_THICK_LINE: { + // draw_line(x, y, x + cursor_length, y, clr); + // draw_line(x, y + 1, x + cursor_length, y + 1, clr); + // } break; + // default: { + // draw_line(x, y, x + cursor_length, y, clr); + // } break; + // } } void -draw_params_cursor_square(size_t i, u8 clr, bool sweep) { - size_t x_offset = sweep ? 0 : 30; - u8 x_positions[] = { - 0, // Duty. - 31, // Env. Vol. - 59, // Env. Direction. - 87, // Env. Time. - 118, // Sweep Number. - 146, // Sweep Time. - 132, // Sweep Direction. - }; - u8 y_positions[] = { - 20, // Duty. - 20, // Env. Vol. - 20, // Env. Direction. - 20, // Env. Time. - 20, // Sweep Number. - 20, // Sweep Time. - 0, // Sweep Direction. - }; - size_t cursor_length = 24; - size_t x = PARAMS_START_X + x_positions[i] + x_offset; - size_t y = PARAMS_START_Y + PARAMS_H - 24 + y_positions[i]; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x, y, x + cursor_length, y, clr); - draw_line(x, y + 1, x + cursor_length, y + 1, clr); - } break; - default: { - draw_line(x, y, x + cursor_length, y, clr); - } break; +draw_params_cursor_square(size_t i, u8 clr) { + size_t x = PARAMS_START_X + (i % 5) * PARAMS_BOX_OFFSET_X; + size_t y = PARAMS_START_Y + PARAMS_BOX_H; + if (i >= 5) { + y += PARAMS_BOX_OFFSET_Y; + } + u8 x0 = x; + u8 x1 = x + PARAMS_BOX_W; + u8 y0 = y - 6; + u8 y1 = y; + draw_filled_rect(x0 + 1, y0, x1 - 1, y1, clr); + draw_line(x0, y0 + 1, x0, y1 - 1, clr); + draw_line(x1, y0 + 1, x1, y1 - 1, clr); + { + size_t x = PARAMS_START_X; + size_t y = PARAMS_START_Y; + switch (i) { + case 0: { + x += 4 + PARAMS_BOX_OFFSET_X * 0; + y += PARAMS_BOX_H - 7; + txt_drawf_small("shape", x, y, COL_BG); + } break; + case 1: { + x += 8 + PARAMS_BOX_OFFSET_X * 1; + y += PARAMS_BOX_H - 7; + txt_drawf_small("vol", x, y, COL_BG); + } break; + case 2: { + x += 6 + PARAMS_BOX_OFFSET_X * 2; + y += PARAMS_BOX_H - 7; + txt_drawf_small("time", x, y, COL_BG); + } break; + case 3: { + x += 8 + PARAMS_BOX_OFFSET_X * 3; + y += PARAMS_BOX_H - 7; + txt_drawf_small("dir", x, y, COL_BG); + } break; + case 4: { + x += 6 + PARAMS_BOX_OFFSET_X * 4; + y += PARAMS_BOX_H - 7; + txt_drawf_small("prob", x, y, COL_BG); + } break; + case 5: { + x += 4 + PARAMS_BOX_OFFSET_X * 0; + y += PARAMS_BOX_H - 7 + PARAMS_BOX_OFFSET_Y; + txt_drawf_small("sweep", x, y, COL_BG); + } break; + case 6: { + x += 6 + PARAMS_BOX_OFFSET_X * 1; + y += PARAMS_BOX_H - 7 + PARAMS_BOX_OFFSET_Y; + txt_drawf_small("time", x, y, COL_BG); + } break; + case 7: { + x += 8 + PARAMS_BOX_OFFSET_X * 2; + y += PARAMS_BOX_H - 7 + PARAMS_BOX_OFFSET_Y; + txt_drawf_small("dir", x, y, COL_BG); + } break; + default: break; + } } } void draw_params_cursor(size_t i, u8 clr) { switch (channel_selection_loc) { - case 0: { draw_params_cursor_square(i, clr, true); } break; - case 1: { draw_params_cursor_square(i, clr, false); } break; + case 0: { draw_params_cursor_square(i, clr); } break; + case 1: { draw_params_cursor_square(i, clr); } break; case 2: { draw_params_cursor_wave(i, clr); } break; case 3: { draw_params_cursor_noise(i, clr); } break; } -- cgit v1.2.1