summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-11 18:22:58 +0200
committerBad Diode <bd@badd10de.dev>2021-06-11 18:22:58 +0200
commit8047b0c5b14ddfdef83d8a9b5d978947614ea80b (patch)
treea3697479c0c43e39d0c09dae429b2a88c69c8390
parentdab077db84599aedc2a48a6114ba7b1730702a3e (diff)
downloadgba-sequencer-8047b0c5b14ddfdef83d8a9b5d978947614ea80b.tar.gz
gba-sequencer-8047b0c5b14ddfdef83d8a9b5d978947614ea80b.zip
Add volume selection to ch3
-rw-r--r--src/sequencer.c75
1 files changed, 61 insertions, 14 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 0f3cff7..d3e6858 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -135,7 +135,7 @@ static const u32 square_wave[16] = {
135static int bpm = 115; 135static int bpm = 115;
136static int step_counter = 0; 136static int step_counter = 0;
137int trig_selection_loc = 0; 137int trig_selection_loc = 0;
138int param_selection_loc = 70; 138int param_selection_loc = 0;
139int channel_selection_loc = 0; 139int channel_selection_loc = 0;
140 140
141typedef struct TriggerNote { 141typedef struct TriggerNote {
@@ -579,6 +579,8 @@ draw_params_cursor_ch3(size_t i, u8 clr) {
579 71, 88, 105, 122, 579 71, 88, 105, 122,
580 // Mode selection. 580 // Mode selection.
581 141, 581 141,
582 // Volume selection.
583 141,
582 }; 584 };
583 u8 y_positions[] = { 585 u8 y_positions[] = {
584 // 32 half bytes (Wave A) 586 // 32 half bytes (Wave A)
@@ -597,6 +599,8 @@ draw_params_cursor_ch3(size_t i, u8 clr) {
597 20, 20, 20, 20, 599 20, 20, 20, 20,
598 // Mode seleciton. 600 // Mode seleciton.
599 20, 601 20,
602 // Volume seleciton.
603 0,
600 }; 604 };
601 size_t cursor_length = 0; 605 size_t cursor_length = 0;
602 if (i < 64) { 606 if (i < 64) {
@@ -712,26 +716,56 @@ draw_parameters_ch3(void) {
712 // Mode selection. 716 // Mode selection.
713 { 717 {
714 size_t x = PARAMS_START_X + 140; 718 size_t x = PARAMS_START_X + 140;
715 size_t y = PARAMS_START_Y + PARAMS_H - 20; 719 size_t y = PARAMS_START_Y + PARAMS_H - 17;
716 draw_line(x, y + 4, x + 5, y + 4, COL_FG); 720 draw_line(x, y + 4, x + 5, y + 4, COL_FG);
717 draw_line(x + 25, y + 4, x + 30, y + 4, COL_FG); 721 draw_line(x + 25, y + 4, x + 30, y + 4, COL_FG);
718 draw_line(x, y + 5, x, y + 19, COL_FG); 722 draw_line(x, y + 5, x, y + 16, COL_FG);
719 draw_line(x + 30, y + 5, x + 30, y + 19, COL_FG); 723 draw_line(x + 30, y + 5, x + 30, y + 17, COL_FG);
720 draw_line(x, y + 20, x + 30, y + 20, COL_FG); 724 draw_line(x, y + 17, x + 30, y + 17, COL_FG);
721 txt_drawf_small("mode", x + 6, y, 4, COL_FG); 725 txt_drawf_small("mode", x + 6, y, 4, COL_FG);
722 726
723 switch (ch3.params[trig_selection_loc].wave_mode) { 727 switch (ch3.params[trig_selection_loc].wave_mode) {
724 case 0: { 728 case 0: {
725 txt_drawf("A", x + 12, y + 9, 6, COL_FG); 729 txt_drawf("A", x + 12, y + 8, 6, COL_FG);
726 } break; 730 } break;
727 case 1: { 731 case 1: {
728 txt_drawf("B", x + 12, y + 9, 6, COL_FG); 732 txt_drawf("B", x + 12, y + 8, 6, COL_FG);
729 } break; 733 } break;
730 case 2: { 734 case 2: {
731 txt_drawf("A+B", x + 6, y + 9, 6, COL_FG); 735 txt_drawf("A+B", x + 6, y + 8, 6, COL_FG);
732 } break; 736 } break;
733 case 3: { 737 case 3: {
734 txt_drawf("B+A", x + 6, y + 9, 6, COL_FG); 738 txt_drawf("B+A", x + 6, y + 8, 6, COL_FG);
739 } break;
740 }
741 }
742
743 // Wave volume.
744 {
745 size_t x = PARAMS_START_X + 140;
746 size_t y = PARAMS_START_Y + PARAMS_H - 40;
747 draw_line(x, y + 7, x + 7, y + 7, COL_FG);
748 draw_line(x + 23, y + 7, x + 30, y + 7, COL_FG);
749 draw_line(x, y + 8, x, y + 19, COL_FG);
750 draw_line(x + 30, y + 8, x + 30, y + 19, COL_FG);
751 draw_line(x, y + 20, x + 30, y + 20, COL_FG);
752 txt_drawf_small("vol", x + 8, y + 3, 4, COL_FG);
753
754 switch (ch3.params[trig_selection_loc].wave_volume) {
755 case 0: {
756 txt_drawf("0", x + 12, y + 10, 6, COL_FG);
757 } break;
758 case 1: {
759 txt_drawf("25", x + 9, y + 10, 6, COL_FG);
760 } break;
761 case 2: {
762 txt_drawf("50", x + 9, y + 10, 6, COL_FG);
763 } break;
764 case 3: {
765 txt_drawf("75", x + 9, y + 10, 6, COL_FG);
766 } break;
767 case 4: {
768 txt_drawf("100", x + 6, y + 10, 6, COL_FG);
735 } break; 769 } break;
736 } 770 }
737 } 771 }
@@ -1092,21 +1126,23 @@ handle_param_selection_ch3(void) {
1092 if (loc == 15 || loc == 31) { 1126 if (loc == 15 || loc == 31) {
1093 inc = 17; 1127 inc = 17;
1094 } else if (loc == 47) { 1128 } else if (loc == 47) {
1095 inc = 25; 1129 inc = 26;
1096 } else if (loc == 63) { 1130 } else if (loc == 63) {
1097 inc = 9; 1131 inc = 9;
1098 } else if (loc != 47 && loc != 63) { 1132 } else if (loc != 47 && loc != 63 && loc < 72) {
1099 inc = 1; 1133 inc = 1;
1100 } 1134 }
1101 } else { 1135 } else {
1102 if (loc == 32 || loc == 48) { 1136 if (loc == 32 || loc == 48) {
1103 inc = -17; 1137 inc = -17;
1138 } else if (loc == 73) {
1139 inc = -26;
1104 } else if (loc != 16 && loc != 64) { 1140 } else if (loc != 16 && loc != 64) {
1105 inc = -1; 1141 inc = -1;
1106 } 1142 }
1107 } 1143 }
1108 draw_params_cursor_ch3(param_selection_loc, COL_BG); 1144 draw_params_cursor_ch3(param_selection_loc, COL_BG);
1109 param_selection_loc = CLAMP(loc + inc, 0, 72); 1145 param_selection_loc = CLAMP(loc + inc, 0, 73);
1110 draw_params_cursor_ch3(param_selection_loc, COL_BLUE); 1146 draw_params_cursor_ch3(param_selection_loc, COL_BLUE);
1111 } 1147 }
1112 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { 1148 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) {
@@ -1131,6 +1167,10 @@ handle_param_selection_ch3(void) {
1131 inc = -14; 1167 inc = -14;
1132 } else if (loc == 71) { 1168 } else if (loc == 71) {
1133 inc = -11; 1169 inc = -11;
1170 } else if (loc == 72) {
1171 inc = 1;
1172 } else if (loc == 73) {
1173 inc = -1;
1134 } 1174 }
1135 } else { 1175 } else {
1136 if (loc < 16 || (loc >= 32 && loc < 48)) { 1176 if (loc < 16 || (loc >= 32 && loc < 48)) {
@@ -1151,10 +1191,14 @@ handle_param_selection_ch3(void) {
1151 inc = 14 - (loc - 56); 1191 inc = 14 - (loc - 56);
1152 } else if (loc >= 60 && loc <= 63) { 1192 } else if (loc >= 60 && loc <= 63) {
1153 inc = 11 - (loc - 60); 1193 inc = 11 - (loc - 60);
1194 } else if (loc == 72) {
1195 inc = 1;
1196 } else if (loc == 73) {
1197 inc = -1;
1154 } 1198 }
1155 } 1199 }
1156 draw_params_cursor_ch3(param_selection_loc, COL_BG); 1200 draw_params_cursor_ch3(param_selection_loc, COL_BG);
1157 param_selection_loc = CLAMP(loc + inc, 0, 71); 1201 param_selection_loc = CLAMP(loc + inc, 0, 73);
1158 draw_params_cursor_ch3(param_selection_loc, COL_BLUE); 1202 draw_params_cursor_ch3(param_selection_loc, COL_BLUE);
1159 } 1203 }
1160 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1204 if (key_tap(KEY_R) || key_tap(KEY_L)) {
@@ -1226,9 +1270,12 @@ handle_param_selection_ch3(void) {
1226 memcpy32(wave_b, rand_wave, 16); 1270 memcpy32(wave_b, rand_wave, 16);
1227 } break; 1271 } break;
1228 } 1272 }
1229 } else { 1273 } else if (param_selection_loc == 72) {
1230 u8 *wave_mode = &ch3.params[trig_selection_loc].wave_mode; 1274 u8 *wave_mode = &ch3.params[trig_selection_loc].wave_mode;
1231 *wave_mode = CLAMP(*wave_mode + inc, 0, 3); 1275 *wave_mode = CLAMP(*wave_mode + inc, 0, 3);
1276 } else if (param_selection_loc == 73) {
1277 u8 *wave_volume = &ch3.params[trig_selection_loc].wave_volume;
1278 *wave_volume = CLAMP(*wave_volume + inc, 0, 4);
1232 } 1279 }
1233 draw_parameters(); 1280 draw_parameters();
1234 draw_params_cursor(param_selection_loc, COL_BLUE); 1281 draw_params_cursor(param_selection_loc, COL_BLUE);