diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-23 19:43:33 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-23 19:43:33 +0200 |
commit | eeeacde00c589cb227746b164a39372356d1eeec (patch) | |
tree | bc95e0501f4b1cee72d1e9939ef4c1a0a033e0cd | |
parent | ec5c1ad9f16772434f0f49811c87ec58a3569e83 (diff) | |
download | stepper-eeeacde00c589cb227746b164a39372356d1eeec.tar.gz stepper-eeeacde00c589cb227746b164a39372356d1eeec.zip |
Fix a couple of rendering corner cases
-rw-r--r-- | src/drawing.c | 11 | ||||
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/sequencer.c | 25 |
3 files changed, 34 insertions, 20 deletions
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) { | |||
1221 | void | 1221 | void |
1222 | draw_parameters(void) { | 1222 | draw_parameters(void) { |
1223 | clear_parameters(); | 1223 | clear_parameters(); |
1224 | if (input_handler != handle_trigger_selection && | ||
1225 | input_handler != handle_param_selection_sq1 && | ||
1226 | input_handler != handle_param_selection_sq2 && | ||
1227 | input_handler != handle_param_selection_wave && | ||
1228 | input_handler != handle_param_selection_noise) { | ||
1229 | return; | ||
1230 | } | ||
1224 | Pattern *pat = &patterns[pattern_selection_loc]; | 1231 | Pattern *pat = &patterns[pattern_selection_loc]; |
1225 | switch (channel_selection_loc) { | 1232 | switch (channel_selection_loc) { |
1226 | case 0: { | 1233 | case 0: { |
@@ -1238,3 +1245,7 @@ draw_parameters(void) { | |||
1238 | } | 1245 | } |
1239 | } | 1246 | } |
1240 | 1247 | ||
1248 | void | ||
1249 | draw_cursors(void) { | ||
1250 | |||
1251 | } | ||
@@ -21,8 +21,6 @@ WITH REGARD TO THIS SOFTWARE. | |||
21 | 21 | ||
22 | void | 22 | void |
23 | render(void) { | 23 | render(void) { |
24 | // TODO: Decouple update from rendering. | ||
25 | // PROF(screen_fill(0), clear_cycles); | ||
26 | PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); | 24 | PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); |
27 | if (redraw_trigs) { | 25 | if (redraw_trigs) { |
28 | PROF(draw_triggers(), draw_trigs_cycles); | 26 | PROF(draw_triggers(), draw_trigs_cycles); |
@@ -51,10 +49,17 @@ render(void) { | |||
51 | } | 49 | } |
52 | if (redraw_piano_note) { | 50 | if (redraw_piano_note) { |
53 | PROF(draw_piano(), draw_piano_cycles); | 51 | PROF(draw_piano(), draw_piano_cycles); |
54 | // TODO: Draw the notes currently playing with a fade off animation for | 52 | if (input_handler != handle_trigger_selection && |
55 | // the first 3 channels. | 53 | input_handler != handle_param_selection_sq1 && |
56 | TriggerNote *trig = get_current_trig(); | 54 | input_handler != handle_param_selection_sq2 && |
57 | PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles); | 55 | input_handler != handle_param_selection_wave && |
56 | input_handler != handle_param_selection_noise) { | ||
57 | // TODO: Show last/current played notes in all channels. | ||
58 | } else { | ||
59 | // Show currently selected trigger note. | ||
60 | TriggerNote *trig = get_current_trig(); | ||
61 | PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles); | ||
62 | } | ||
58 | redraw_piano_note = false; | 63 | redraw_piano_note = false; |
59 | } | 64 | } |
60 | if (redraw_params) { | 65 | if (redraw_params) { |
@@ -97,6 +102,7 @@ main(void) { | |||
97 | FRAME_START(); | 102 | FRAME_START(); |
98 | PROF(flip_buffer(), flip_cycles); | 103 | PROF(flip_buffer(), flip_cycles); |
99 | PROF(handle_sequencer_input(), input_cycles); | 104 | PROF(handle_sequencer_input(), input_cycles); |
105 | // TODO: Update function to performa animations, etc. | ||
100 | PROF(render(), render_cycles); | 106 | PROF(render(), render_cycles); |
101 | FRAME_END(); | 107 | FRAME_END(); |
102 | } | 108 | } |
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) { | |||
749 | // Decrease note. | 749 | // Decrease note. |
750 | if (trig->active) { | 750 | if (trig->active) { |
751 | trig->note = MAX(trig->note - 1, NOTE_C_2); | 751 | trig->note = MAX(trig->note - 1, NOTE_C_2); |
752 | redraw_trigs = true; | ||
753 | redraw_piano_note = true; | ||
754 | } | 752 | } |
753 | redraw_trigs = true; | ||
754 | redraw_piano_note = true; | ||
755 | } else if (key_tap(KEY_R)) { | 755 | } else if (key_tap(KEY_R)) { |
756 | // Increase note. | 756 | // Increase note. |
757 | if (trig->active) { | 757 | if (trig->active) { |
758 | trig->note = MIN( trig->note + 1, NOTE_C_8 - 1); | 758 | trig->note = MIN( trig->note + 1, NOTE_C_8 - 1); |
759 | redraw_trigs = true; | ||
760 | redraw_piano_note = true; | ||
761 | } | 759 | } |
760 | redraw_trigs = true; | ||
761 | redraw_piano_note = true; | ||
762 | } | 762 | } |
763 | 763 | ||
764 | // Move trigger cursor. | 764 | // Move trigger cursor. |
@@ -766,30 +766,27 @@ handle_trigger_selection(void) { | |||
766 | if (trig_selection_loc == 0 || trig_selection_loc == 8) { | 766 | if (trig_selection_loc == 0 || trig_selection_loc == 8) { |
767 | // We are at the boundary, switch to channel selection. | 767 | // We are at the boundary, switch to channel selection. |
768 | input_handler = handle_channel_selection; | 768 | input_handler = handle_channel_selection; |
769 | redraw_params = true; | ||
770 | } else { | 769 | } else { |
771 | trig_selection_loc = MAX(trig_selection_loc - 1, 0); | 770 | trig_selection_loc = MAX(trig_selection_loc - 1, 0); |
772 | redraw_piano_note = true; | ||
773 | redraw_params = true; | ||
774 | } | 771 | } |
772 | redraw_params = true; | ||
773 | redraw_piano_note = true; | ||
775 | } else if (key_tap(KEY_RIGHT)) { | 774 | } else if (key_tap(KEY_RIGHT)) { |
776 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { | 775 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { |
777 | trig_selection_loc = MIN(trig_selection_loc + 1, 15); | 776 | trig_selection_loc = MIN(trig_selection_loc + 1, 15); |
778 | redraw_piano_note = true; | ||
779 | redraw_params = true; | ||
780 | } else if (trig_selection_loc == 7) { | 777 | } else if (trig_selection_loc == 7) { |
781 | input_handler = handle_right_col_selection; | 778 | input_handler = handle_right_col_selection; |
782 | right_col_selection_loc = R_COL_STOP; | 779 | right_col_selection_loc = R_COL_STOP; |
783 | redraw_params = true; | ||
784 | } else if (trig_selection_loc == 15) { | 780 | } else if (trig_selection_loc == 15) { |
785 | right_col_selection_loc = R_COL_BPM; | 781 | right_col_selection_loc = R_COL_BPM; |
786 | input_handler = handle_right_col_selection; | 782 | input_handler = handle_right_col_selection; |
787 | redraw_params = true; | ||
788 | } | 783 | } |
784 | redraw_params = true; | ||
785 | redraw_piano_note = true; | ||
789 | } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { | 786 | } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { |
790 | trig_selection_loc = (trig_selection_loc + 8) % 16; | 787 | trig_selection_loc = (trig_selection_loc + 8) % 16; |
791 | redraw_piano_note = true; | ||
792 | redraw_params = true; | 788 | redraw_params = true; |
789 | redraw_piano_note = true; | ||
793 | } else if (key_tap(KEY_A)) { | 790 | } else if (key_tap(KEY_A)) { |
794 | // Switch to parameter selection. | 791 | // Switch to parameter selection. |
795 | switch (channel_selection_loc) { | 792 | switch (channel_selection_loc) { |
@@ -806,8 +803,8 @@ handle_trigger_selection(void) { | |||
806 | input_handler = handle_param_selection_noise; | 803 | input_handler = handle_param_selection_noise; |
807 | } break; | 804 | } break; |
808 | } | 805 | } |
809 | redraw_piano_note = true; | ||
810 | redraw_params = true; | 806 | redraw_params = true; |
807 | redraw_piano_note = true; | ||
811 | } | 808 | } |
812 | } | 809 | } |
813 | 810 | ||
@@ -817,7 +814,7 @@ handle_sequencer_input(void) { | |||
817 | // Stop the sequencer or start playing from the beginning. | 814 | // Stop the sequencer or start playing from the beginning. |
818 | toggle_playing(); | 815 | toggle_playing(); |
819 | } else if (key_hold(KEY_SELECT)) { | 816 | } else if (key_hold(KEY_SELECT)) { |
820 | if (input_handler == handle_param_selection_sq1 || | 817 | if (input_handler == handle_param_selection_sq1 || |
821 | input_handler == handle_param_selection_sq2 || | 818 | input_handler == handle_param_selection_sq2 || |
822 | input_handler == handle_param_selection_wave || | 819 | input_handler == handle_param_selection_wave || |
823 | input_handler == handle_param_selection_noise) { | 820 | input_handler == handle_param_selection_noise) { |