From eeeacde00c589cb227746b164a39372356d1eeec Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 23 Apr 2023 19:43:33 +0200 Subject: Fix a couple of rendering corner cases --- src/drawing.c | 11 +++++++++++ src/main.c | 18 ++++++++++++------ src/sequencer.c | 25 +++++++++++-------------- 3 files changed, 34 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/drawing.c b/src/drawing.c index 89d3ef6..0f6afb0 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -1221,6 +1221,13 @@ draw_parameters_noise(void) { void draw_parameters(void) { clear_parameters(); + if (input_handler != handle_trigger_selection && + input_handler != handle_param_selection_sq1 && + input_handler != handle_param_selection_sq2 && + input_handler != handle_param_selection_wave && + input_handler != handle_param_selection_noise) { + return; + } Pattern *pat = &patterns[pattern_selection_loc]; switch (channel_selection_loc) { case 0: { @@ -1238,3 +1245,7 @@ draw_parameters(void) { } } +void +draw_cursors(void) { + +} diff --git a/src/main.c b/src/main.c index b6be6b9..aa5bd43 100644 --- a/src/main.c +++ b/src/main.c @@ -21,8 +21,6 @@ WITH REGARD TO THIS SOFTWARE. void render(void) { - // TODO: Decouple update from rendering. - // PROF(screen_fill(0), clear_cycles); PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); if (redraw_trigs) { PROF(draw_triggers(), draw_trigs_cycles); @@ -51,10 +49,17 @@ render(void) { } if (redraw_piano_note) { PROF(draw_piano(), draw_piano_cycles); - // TODO: Draw the notes currently playing with a fade off animation for - // the first 3 channels. - TriggerNote *trig = get_current_trig(); - PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles); + if (input_handler != handle_trigger_selection && + input_handler != handle_param_selection_sq1 && + input_handler != handle_param_selection_sq2 && + input_handler != handle_param_selection_wave && + input_handler != handle_param_selection_noise) { + // TODO: Show last/current played notes in all channels. + } else { + // Show currently selected trigger note. + TriggerNote *trig = get_current_trig(); + PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles); + } redraw_piano_note = false; } if (redraw_params) { @@ -97,6 +102,7 @@ main(void) { FRAME_START(); PROF(flip_buffer(), flip_cycles); PROF(handle_sequencer_input(), input_cycles); + // TODO: Update function to performa animations, etc. PROF(render(), render_cycles); FRAME_END(); } diff --git a/src/sequencer.c b/src/sequencer.c index a560bcb..34e2695 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -749,16 +749,16 @@ handle_trigger_selection(void) { // Decrease note. if (trig->active) { trig->note = MAX(trig->note - 1, NOTE_C_2); - redraw_trigs = true; - redraw_piano_note = true; } + redraw_trigs = true; + redraw_piano_note = true; } else if (key_tap(KEY_R)) { // Increase note. if (trig->active) { trig->note = MIN( trig->note + 1, NOTE_C_8 - 1); - redraw_trigs = true; - redraw_piano_note = true; } + redraw_trigs = true; + redraw_piano_note = true; } // Move trigger cursor. @@ -766,30 +766,27 @@ handle_trigger_selection(void) { if (trig_selection_loc == 0 || trig_selection_loc == 8) { // We are at the boundary, switch to channel selection. input_handler = handle_channel_selection; - redraw_params = true; } else { trig_selection_loc = MAX(trig_selection_loc - 1, 0); - redraw_piano_note = true; - redraw_params = true; } + redraw_params = true; + redraw_piano_note = true; } else if (key_tap(KEY_RIGHT)) { if (trig_selection_loc != 7 && trig_selection_loc != 15) { trig_selection_loc = MIN(trig_selection_loc + 1, 15); - redraw_piano_note = true; - redraw_params = true; } else if (trig_selection_loc == 7) { input_handler = handle_right_col_selection; right_col_selection_loc = R_COL_STOP; - redraw_params = true; } else if (trig_selection_loc == 15) { right_col_selection_loc = R_COL_BPM; input_handler = handle_right_col_selection; - redraw_params = true; } + redraw_params = true; + redraw_piano_note = true; } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { trig_selection_loc = (trig_selection_loc + 8) % 16; - redraw_piano_note = true; redraw_params = true; + redraw_piano_note = true; } else if (key_tap(KEY_A)) { // Switch to parameter selection. switch (channel_selection_loc) { @@ -806,8 +803,8 @@ handle_trigger_selection(void) { input_handler = handle_param_selection_noise; } break; } - redraw_piano_note = true; redraw_params = true; + redraw_piano_note = true; } } @@ -817,7 +814,7 @@ handle_sequencer_input(void) { // Stop the sequencer or start playing from the beginning. toggle_playing(); } else if (key_hold(KEY_SELECT)) { - if (input_handler == handle_param_selection_sq1 || + if (input_handler == handle_param_selection_sq1 || input_handler == handle_param_selection_sq2 || input_handler == handle_param_selection_wave || input_handler == handle_param_selection_noise) { -- cgit v1.2.1