From c888455af3ea5b9e8d2087a57df104c14ffac09e Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 10 Aug 2023 21:43:12 +0200 Subject: Add two more banks and channel icons --- src/assets.c | 22 --------- src/drawing.c | 143 +++++++++++++++++++++++++++++++++----------------------- src/globals.c | 4 +- src/main.c | 2 +- src/save.c | 4 +- src/sequencer.c | 2 + 6 files changed, 91 insertions(+), 86 deletions(-) diff --git a/src/assets.c b/src/assets.c index 661d012..94c9de2 100644 --- a/src/assets.c +++ b/src/assets.c @@ -81,28 +81,6 @@ static const u32 note_name_sprites[] = { 0xe0000000, 0xe0202020, 0x0e000000, 0x0e0a0e0a, }; -static const u32 ch_btn_sprite[] = { - // CH1 - 0x888e80ff, 0xff808e88, - 0xa1a100ff, 0xff00a9e1, - 0x101010f0, 0xf0101010, - - // CH2 - 0x919d80ff, 0xff809d91, - 0x424200ff, 0xff0052c2, - 0x909010f0, 0xf0109090, - - // CH3 - 0xa2ba80ff, 0xff80baa3, - 0x858500ff, 0xff00a585, - 0x505010f0, 0xf0105050, - - // CH4 - 0xa2ba80ff, 0xff80baa3, - 0x858500ff, 0xff00a485, - 0x505010f0, 0xf010d050, -}; - // // Wave data. // diff --git a/src/drawing.c b/src/drawing.c index c07b46d..dd77803 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -26,9 +26,43 @@ draw_param_stub(size_t idx, u8 color) { void draw_channel_sprite(size_t x, size_t y, u8 clr, u8 idx) { - draw_icn(x, y, &ch_btn_sprite[0 + 6 * idx], clr, 0, 0); - draw_icn(x + 8, y, &ch_btn_sprite[2 + 6 * idx], clr, 0, 0); - draw_icn(x + 16, y, &ch_btn_sprite[4 + 6 * idx], clr, 0, 0); + draw_rect(x, y, x + CHAN_W, y + CHAN_H - 1, clr); + + switch (idx) { + case 0: { + draw_line(x + 2, y + 5, x + 6, y + 5, clr); + draw_line(x + 6, y + 2, x + 6, y + 5, clr); + draw_line(x + 7, y + 2, x + 12, y + 2, clr); + draw_line(x + 12, y + 2, x + 12, y + 5, clr); + draw_line(x + 12, y + 5, x + 16, y + 5, clr); + } break; + case 1: { + draw_line(x + 2, y + 5, x + 4, y + 5, clr); + draw_line(x + 4, y + 2, x + 4, y + 5, clr); + draw_line(x + 4, y + 2, x + 7, y + 2, clr); + draw_line(x + 7, y + 2, x + 7, y + 5, clr); + draw_line(x + 7, y + 5, x + 11, y + 5, clr); + draw_line(x + 11, y + 2, x + 11, y + 5, clr); + draw_line(x + 11, y + 2, x + 14, y + 2, clr); + draw_line(x + 14, y + 2, x + 14, y + 5, clr); + draw_line(x + 14, y + 5, x + 16, y + 5, clr); + } break; + case 2: { + draw_line(x + 2, y + 5, x + 5, y + 2, clr); + draw_line(x + 6, y + 2, x + 6, y + 5, clr); + draw_line(x + 7, y + 5, x + 10, y + 2, clr); + draw_line(x + 11, y + 2, x + 11, y + 5, clr); + draw_line(x + 12, y + 5, x + 15, y + 2, clr); + draw_line(x + 16, y + 2, x + 16, y + 5, clr); + } break; + case 3: { + u8 y_off[] = { 5, 2, 4, 2, 3, 4, 5, 2, 4, 3, 5, 3, 2, 4, 5 }; + for (size_t i = 0; i < 15; i++) { + draw_pixel(x + 2 + i, y + y_off[i], clr); + } + } break; + default: break; + } } void @@ -52,20 +86,21 @@ draw_channels(void) { } void -draw_channel_cursor(size_t i, u8 clr) { +draw_channel_cursor(size_t i, u8 clr, bool dither) { size_t offset_x = 0; size_t offset_y = CHAN_H + i * CHAN_OFFSET_Y + 1; size_t x0 = CHAN_START_X + offset_x; size_t x1 = CHAN_START_X + offset_x + CHAN_W; size_t y = CHAN_START_Y + offset_y; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x0, y, x1, y, clr); - draw_line(x0, y + 1, x1, y + 1, clr); - } break; - default: { - draw_line(x0, y, x1, y, clr); - } break; + if (dither) { + for (size_t i = 0; i < CHAN_W - 1; i += 2) { + draw_pixel(x0 + i, y, clr); + draw_pixel(x0 + i + 1, y + 1, clr); + } + draw_pixel(x0 + CHAN_W, y, clr); + } else { + draw_line(x0, y, x1, y, clr); + draw_line(x0, y + 1, x1, y + 1, clr); } } @@ -77,7 +112,7 @@ void clear_trigger(size_t i) { size_t offset_x = TRIG_OFFSET_X * (i % 8); size_t offset_y = i < 8 ? 0 : TRIG_OFFSET_Y; - size_t x0 = TRIG_START_X + offset_x + 1; + size_t x0 = TRIG_START_X + offset_x + 2; size_t x1 = TRIG_START_X + offset_x + TRIG_W - 1; size_t y0 = TRIG_START_Y + offset_y + 1; size_t y1 = TRIG_START_Y + offset_y + TRIG_H - 4; @@ -107,20 +142,21 @@ draw_trigger(size_t chan, size_t i) { } void -draw_trig_cursor(size_t i, u8 clr) { +draw_trig_cursor(size_t i, u8 clr, bool dither) { size_t offset_x = TRIG_OFFSET_X * (i % 8); size_t offset_y = i < 8 ? 2 : 2 + TRIG_OFFSET_Y; - size_t x0 = TRIG_START_X + offset_x; + size_t x0 = TRIG_START_X + offset_x + 1; size_t x1 = TRIG_START_X + TRIG_W + offset_x; size_t y = TRIG_START_Y + TRIG_H + offset_y; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x0, y, x1, y, clr); - draw_line(x0, y + 1, x1, y + 1, clr); - } break; - default: { - draw_line(x0, y, x1, y, clr); - } break; + if (dither) { + for (size_t i = 0; i < TRIG_W - 1; i += 2) { + draw_pixel(x0 + i, y, clr); + draw_pixel(x0 + i + 1, y + 1, clr); + } + draw_pixel(x0 + TRIG_W - 1, y, clr); + } else { + draw_line(x0, y, x1, y, clr); + draw_line(x0, y + 1, x1, y + 1, clr); } } @@ -173,20 +209,15 @@ draw_right_col_cursor(int i, u8 clr) { y = BANK_START_Y + PAT_H + 2 + 3 * PAT_OFFSET_Y; } break; } - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x0, y, x1, y, clr); - draw_line(x0, y + 1, x1, y + 1, clr); - } break; - default: { draw_line(x0, y, x1, y, clr); } break; - } + draw_line(x0, y, x1, y, clr); + draw_line(x0, y + 1, x1, y + 1, clr); } void draw_current_step(u8 step, u8 clr) { size_t offset_x = TRIG_OFFSET_X * (step % 8); size_t offset_y = step < 8 ? 2 : 2 + TRIG_OFFSET_Y; - size_t x0 = TRIG_START_X + 3 + offset_x; + size_t x0 = TRIG_START_X + 4 + offset_x; size_t x1 = TRIG_START_X - 3 + TRIG_W + offset_x; size_t y = TRIG_START_Y - 5 + TRIG_H + offset_y; draw_line(x0, y, x1, y, clr); @@ -248,20 +279,21 @@ draw_pattern_buttons() { } void -draw_pattern_cursor(size_t i, u8 clr) { +draw_pattern_cursor(size_t i, u8 clr, bool dither) { size_t offset_x = 0; size_t offset_y = PAT_H + i * PAT_OFFSET_Y + 2; size_t x0 = PAT_START_X + offset_x; size_t x1 = PAT_START_X + offset_x + PAT_W; size_t y = PAT_START_Y + offset_y; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x0, y, x1, y, clr); - draw_line(x0, y + 1, x1, y + 1, clr); - } break; - default: { - draw_line(x0, y, x1, y, clr); - } break; + if (dither) { + for (size_t i = 0; i < PAT_W; i += 2) { + draw_pixel(x0 + i, y, clr); + draw_pixel(x0 + i + 1, y + 1, clr); + } + draw_pixel(x0 + PAT_W, y, clr); + } else { + draw_line(x0, y, x1, y, clr); + draw_line(x0, y + 1, x1, y + 1, clr); } } @@ -344,7 +376,7 @@ draw_triggers(void) { for (size_t i = 0; i < 16; i++) { size_t offset_x = TRIG_OFFSET_X * (i % 8); size_t offset_y = i < 8 ? 0 : 0 + TRIG_OFFSET_Y; - size_t x0 = TRIG_START_X + offset_x; + size_t x0 = TRIG_START_X + offset_x + 1; size_t x1 = TRIG_START_X + offset_x + TRIG_W; size_t y0 = TRIG_START_Y + offset_y; size_t y1 = TRIG_START_Y + offset_y + TRIG_H; @@ -1135,9 +1167,9 @@ draw_parameters(void) { void clear_cursors(void) { - draw_trig_cursor(last_trig_loc, COL_BG); - draw_channel_cursor(last_channel_loc, COL_BG); - draw_pattern_cursor(last_pattern_loc, COL_BG); + draw_trig_cursor(last_trig_loc, COL_BG, false); + draw_channel_cursor(last_channel_loc, COL_BG, false); + draw_pattern_cursor(last_pattern_loc, COL_BG, false); draw_right_col_cursor(last_right_col_loc, COL_BG); for (size_t i = 0; i < 16; i++) { draw_current_step(i, COL_OFF); @@ -1151,15 +1183,8 @@ draw_pattern_chain_cursor(void) { size_t x0 = PAT_TRIG_START_X + offset_x; size_t x1 = PAT_TRIG_START_X + offset_x + PAT_TRIG_W; size_t y = PAT_TRIG_START_Y + offset_y + PAT_TRIG_H + 2; - switch (settings.cursor) { - case CURSOR_THICK_LINE: { - draw_line(x0, y, x1, y, COL_ACC_0); - draw_line(x0, y + 1, x1, y + 1, COL_ACC_0); - } break; - default: { - draw_line(x0, y, x1, y, COL_ACC_0); - } break; - } + draw_line(x0, y, x1, y, COL_ACC_0); + draw_line(x0, y + 1, x1, y + 1, COL_ACC_0); } void @@ -1167,17 +1192,17 @@ draw_cursors(void) { clear_cursors(); draw_current_step(step_counter, COL_ACC_1); if (input_handler == handle_trigger_selection) { - draw_trig_cursor(trig_selection_loc, COL_ACC_0); + draw_trig_cursor(trig_selection_loc, COL_ACC_0, false); } if (input_handler == handle_channel_selection) { - draw_channel_cursor(channel_selection_loc, COL_ACC_0); + draw_channel_cursor(channel_selection_loc, COL_ACC_0, false); } else { - draw_channel_cursor(channel_selection_loc, COL_OFF); + draw_channel_cursor(channel_selection_loc, COL_ACC_0, true); } if (input_handler == handle_pattern_selection) { - draw_pattern_cursor(pattern_selection_loc, COL_ACC_0); + draw_pattern_cursor(pattern_selection_loc, COL_ACC_0, false); } else { - draw_pattern_cursor(pattern_selection_loc, COL_OFF); + draw_pattern_cursor(pattern_selection_loc, COL_ACC_0, true); } if (input_handler == handle_right_col_selection) { draw_right_col_cursor(right_col_selection_loc, COL_ACC_0); @@ -1187,7 +1212,7 @@ draw_cursors(void) { input_handler == handle_param_selection_wave || input_handler == handle_param_selection_noise) { draw_params_cursor(param_selection_loc, COL_ACC_0); - draw_trig_cursor(trig_selection_loc, COL_OFF); + draw_trig_cursor(trig_selection_loc, COL_ACC_0, true); } if (input_handler == handle_param_selection_ch1 || input_handler == handle_param_selection_ch2 || diff --git a/src/globals.c b/src/globals.c index 842b39f..e4d1f13 100644 --- a/src/globals.c +++ b/src/globals.c @@ -30,7 +30,7 @@ bool clear_screen = true; #define COL_ACC_2 4 #define COL_OFF 5 -#define CHAN_W 19 +#define CHAN_W 18 #define CHAN_H 8 #define CHAN_START_X 28 #define CHAN_START_Y 100 @@ -97,7 +97,7 @@ bool clear_screen = true; #define PAT_TRIG_W 14 #define PAT_TRIG_H 14 -#define PAT_TRIG_START_X 35 +#define PAT_TRIG_START_X 32 #define PAT_TRIG_START_Y 30 #define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7) #define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8) diff --git a/src/main.c b/src/main.c index 76a54b6..6992ac2 100644 --- a/src/main.c +++ b/src/main.c @@ -145,7 +145,7 @@ render(void) { } break; } // DEBUG: Ensuring the saved data don't exceed SRAM size (32k). - txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 6 + sizeof(chain) * 6); + // txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 6 + sizeof(chain) * 6); } void diff --git a/src/save.c b/src/save.c index 8c26557..0e99086 100644 --- a/src/save.c +++ b/src/save.c @@ -23,13 +23,13 @@ sram_write(u8 *src, u16 pos, u16 n_bytes) { void save_bank(int i) { sram_write(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns)); - sram_write(&chain, sizeof(Metadata) + 4 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); + sram_write(&chain, sizeof(Metadata) + 6 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); } void load_bank(int i) { sram_read(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns)); - sram_read(&chain, sizeof(Metadata) + 4 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); + sram_read(&chain, sizeof(Metadata) + 6 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); } void diff --git a/src/sequencer.c b/src/sequencer.c index 18c9b20..b3b27c6 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -1333,6 +1333,8 @@ sequencer_init(void) { save_bank(1); save_bank(2); save_bank(3); + save_bank(4); + save_bank(5); } else { current_bank = metadata.current_bank; current_pattern = metadata.current_pattern; -- cgit v1.2.1