aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-24 12:16:55 +0200
committerBad Diode <bd@badd10de.dev>2023-04-24 12:16:55 +0200
commitc7c789096ec6aa31ed98396fd066f1b39dfa8e01 (patch)
tree9e10889f253959f0ad5abcb69832d9fe4fbf1948
parent0fa40db0a578cc2dc3952fe108a332a1e3182452 (diff)
downloadstepper-c7c789096ec6aa31ed98396fd066f1b39dfa8e01.tar.gz
stepper-c7c789096ec6aa31ed98396fd066f1b39dfa8e01.zip
Fix copy-paste behaviour when copying channels
-rw-r--r--src/clipboard.c9
-rw-r--r--src/main.c2
-rw-r--r--src/sequencer.c117
3 files changed, 83 insertions, 45 deletions
diff --git a/src/clipboard.c b/src/clipboard.c
index 7491d4b..d802645 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -175,11 +175,13 @@ clipboard_paste(void) {
175 case 0: { 175 case 0: {
176 for (size_t i = 0; i < 16; i++) { 176 for (size_t i = 0; i < 16; i++) {
177 pat_dst->ch1.notes[i] = pat_src->ch1.notes[i]; 177 pat_dst->ch1.notes[i] = pat_src->ch1.notes[i];
178 pat_dst->ch1.params[i] = pat_src->ch1.params[i];
178 } 179 }
179 } break; 180 } break;
180 case 1: { 181 case 1: {
181 for (size_t i = 0; i < 16; i++) { 182 for (size_t i = 0; i < 16; i++) {
182 pat_dst->ch2.notes[i] = pat_src->ch1.notes[i]; 183 pat_dst->ch2.notes[i] = pat_src->ch1.notes[i];
184 pat_dst->ch2.params[i] = pat_src->ch1.params[i];
183 } 185 }
184 } break; 186 } break;
185 case 2: { 187 case 2: {
@@ -199,11 +201,16 @@ clipboard_paste(void) {
199 case 0: { 201 case 0: {
200 for (size_t i = 0; i < 16; i++) { 202 for (size_t i = 0; i < 16; i++) {
201 pat_dst->ch1.notes[i] = pat_src->ch2.notes[i]; 203 pat_dst->ch1.notes[i] = pat_src->ch2.notes[i];
204 pat_dst->ch1.params[i].env_volume = pat_src->ch2.params[i].env_volume;
205 pat_dst->ch1.params[i].env_time = pat_src->ch2.params[i].env_time;
206 pat_dst->ch1.params[i].env_direction = pat_src->ch2.params[i].env_direction;
207 pat_dst->ch1.params[i].duty_cycle = pat_src->ch2.params[i].duty_cycle;
202 } 208 }
203 } break; 209 } break;
204 case 1: { 210 case 1: {
205 for (size_t i = 0; i < 16; i++) { 211 for (size_t i = 0; i < 16; i++) {
206 pat_dst->ch2.notes[i] = pat_src->ch2.notes[i]; 212 pat_dst->ch2.notes[i] = pat_src->ch2.notes[i];
213 pat_dst->ch2.params[i] = pat_src->ch2.params[i];
207 } 214 }
208 } break; 215 } break;
209 case 2: { 216 case 2: {
@@ -233,6 +240,7 @@ clipboard_paste(void) {
233 case 2: { 240 case 2: {
234 for (size_t i = 0; i < 16; i++) { 241 for (size_t i = 0; i < 16; i++) {
235 pat_dst->ch3.notes[i] = pat_src->ch3.notes[i]; 242 pat_dst->ch3.notes[i] = pat_src->ch3.notes[i];
243 pat_dst->ch3.params[i] = pat_src->ch3.params[i];
236 } 244 }
237 } break; 245 } break;
238 case 3: { 246 case 3: {
@@ -262,6 +270,7 @@ clipboard_paste(void) {
262 case 3: { 270 case 3: {
263 for (size_t i = 0; i < 16; i++) { 271 for (size_t i = 0; i < 16; i++) {
264 pat_dst->ch4.notes[i] = pat_src->ch4.notes[i]; 272 pat_dst->ch4.notes[i] = pat_src->ch4.notes[i];
273 pat_dst->ch4.params[i] = pat_src->ch4.params[i];
265 } 274 }
266 } break; 275 } break;
267 } 276 }
diff --git a/src/main.c b/src/main.c
index 3cc5345..54f14b4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,8 @@ WITH REGARD TO THIS SOFTWARE.
32// Advanced 32// Advanced
33// - Sync via MIDI via arduinoboy or something similar. 33// - Sync via MIDI via arduinoboy or something similar.
34// - Sync via CV by using the link cable. 34// - Sync via CV by using the link cable.
35//
36// FIXME: Update readme and project pages with control changes.
35 37
36#include "gba/gba.h" 38#include "gba/gba.h"
37 39
diff --git a/src/sequencer.c b/src/sequencer.c
index 2940b25..4528e0f 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -186,21 +186,31 @@ get_current_trig(void) {
186void 186void
187handle_channel_selection(void) { 187handle_channel_selection(void) {
188 if (key_tap(KEY_B)) { 188 if (key_tap(KEY_B)) {
189 switch (channel_selection_loc) { 189 if (key_hold(KEY_SELECT)) {
190 case 0: { 190 clipboard_copy();
191 patterns[pattern_selection_loc].ch1.active ^= 1; 191 } else {
192 } break; 192 switch (channel_selection_loc) {
193 case 1: { 193 case 0: {
194 patterns[pattern_selection_loc].ch2.active ^= 1; 194 patterns[pattern_selection_loc].ch1.active ^= 1;
195 } break; 195 } break;
196 case 2: { 196 case 1: {
197 patterns[pattern_selection_loc].ch3.active ^= 1; 197 patterns[pattern_selection_loc].ch2.active ^= 1;
198 } break; 198 } break;
199 case 3: { 199 case 2: {
200 patterns[pattern_selection_loc].ch4.active ^= 1; 200 patterns[pattern_selection_loc].ch3.active ^= 1;
201 } break; 201 } break;
202 case 3: {
203 patterns[pattern_selection_loc].ch4.active ^= 1;
204 } break;
205 }
206 redraw_channels = true;
207 }
208 } else {
209 if (key_tap(KEY_A)) {
210 if (key_hold(KEY_SELECT)) {
211 clipboard_paste();
212 }
202 } 213 }
203 redraw_channels = true;
204 } 214 }
205 if (key_tap(KEY_RIGHT)) { 215 if (key_tap(KEY_RIGHT)) {
206 trig_selection_loc = 0; 216 trig_selection_loc = 0;
@@ -384,8 +394,17 @@ handle_right_col_selection(void) {
384void 394void
385handle_pattern_selection(void) { 395handle_pattern_selection(void) {
386 if (key_tap(KEY_B)) { 396 if (key_tap(KEY_B)) {
387 next_pattern = pattern_selection_loc; 397 if (key_hold(KEY_SELECT)) {
388 redraw_pattern_buttons = true; 398 clipboard_copy();
399 } else {
400 next_pattern = pattern_selection_loc;
401 redraw_pattern_buttons = true;
402 }
403 }
404 if (key_tap(KEY_A)) {
405 if (key_hold(KEY_SELECT)) {
406 clipboard_paste();
407 }
389 } 408 }
390 if (key_tap(KEY_RIGHT)) { 409 if (key_tap(KEY_RIGHT)) {
391 input_handler = handle_channel_selection; 410 input_handler = handle_channel_selection;
@@ -773,9 +792,13 @@ handle_trigger_selection(void) {
773 TriggerNote *trig = get_current_trig(); 792 TriggerNote *trig = get_current_trig();
774 793
775 if (key_tap(KEY_B)) { 794 if (key_tap(KEY_B)) {
776 // Toggle trigger. 795 if (key_hold(KEY_SELECT)) {
777 trig->active ^= 1; 796 clipboard_copy();
778 redraw_trigs = true; 797 } else {
798 // Toggle trigger.
799 trig->active ^= 1;
800 redraw_trigs = true;
801 }
779 } else if (key_tap(KEY_L)) { 802 } else if (key_tap(KEY_L)) {
780 // Decrease note. 803 // Decrease note.
781 if (trig->active) { 804 if (trig->active) {
@@ -819,23 +842,27 @@ handle_trigger_selection(void) {
819 redraw_params = true; 842 redraw_params = true;
820 redraw_piano_note = true; 843 redraw_piano_note = true;
821 } else if (key_tap(KEY_A)) { 844 } else if (key_tap(KEY_A)) {
822 // Switch to parameter selection. 845 if (key_hold(KEY_SELECT)) {
823 switch (channel_selection_loc) { 846 clipboard_paste();
824 case 0: { 847 } else {
825 input_handler = handle_param_selection_sq1; 848 // Switch to parameter selection.
826 } break; 849 switch (channel_selection_loc) {
827 case 1: { 850 case 0: {
828 input_handler = handle_param_selection_sq2; 851 input_handler = handle_param_selection_sq1;
829 } break; 852 } break;
830 case 2: { 853 case 1: {
831 input_handler = handle_param_selection_wave; 854 input_handler = handle_param_selection_sq2;
832 } break; 855 } break;
833 case 3: { 856 case 2: {
834 input_handler = handle_param_selection_noise; 857 input_handler = handle_param_selection_wave;
835 } break; 858 } break;
859 case 3: {
860 input_handler = handle_param_selection_noise;
861 } break;
862 }
863 redraw_params = true;
864 redraw_piano_note = true;
836 } 865 }
837 redraw_params = true;
838 redraw_piano_note = true;
839 } 866 }
840} 867}
841 868
@@ -850,17 +877,17 @@ handle_sequencer_input(void) {
850 input_handler == handle_param_selection_wave || 877 input_handler == handle_param_selection_wave ||
851 input_handler == handle_param_selection_noise) { 878 input_handler == handle_param_selection_noise) {
852 clipboard_copy(); 879 clipboard_copy();
853 input_handler();
854 }
855 if (input_handler == handle_right_col_selection) {
856 input_handler();
857 }
858 // Clipboard combo.
859 else if (key_tap(KEY_A)) {
860 clipboard_paste();
861 } else if (key_tap(KEY_B)){
862 clipboard_copy();
863 } 880 }
881 input_handler();
882 // // if (input_handler == handle_right_col_selection) {
883 // // input_handler();
884 // // }
885 // // // Clipboard combo.
886 // // else if (key_tap(KEY_A)) {
887 // // clipboard_paste();
888 // // } else if (key_tap(KEY_B)){
889 // // clipboard_copy();
890 // // }
864 } else { 891 } else {
865 input_handler(); 892 input_handler();
866 } 893 }