summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sequencer.c175
1 files changed, 92 insertions, 83 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 5aaeab3..856d579 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -629,7 +629,8 @@ draw_params_cursor_wave(size_t i, u8 clr) {
629} 629}
630 630
631void 631void
632draw_params_cursor_sq1(size_t i, u8 clr) { 632draw_params_cursor_square(size_t i, u8 clr, bool sweep) {
633 size_t x_offset = sweep ? 0 : 30;
633 u8 x_positions[] = { 634 u8 x_positions[] = {
634 0, // Duty. 635 0, // Duty.
635 31, // Env. Vol. 636 31, // Env. Vol.
@@ -649,7 +650,7 @@ draw_params_cursor_sq1(size_t i, u8 clr) {
649 0, // Sweep Direction. 650 0, // Sweep Direction.
650 }; 651 };
651 size_t cursor_length = 24; 652 size_t cursor_length = 24;
652 size_t x = PARAMS_START_X + x_positions[i]; 653 size_t x = PARAMS_START_X + x_positions[i] + x_offset;
653 size_t y = PARAMS_START_Y + PARAMS_H - 23 + y_positions[i]; 654 size_t y = PARAMS_START_Y + PARAMS_H - 23 + y_positions[i];
654 draw_line(x, y, x + cursor_length, y, clr); 655 draw_line(x, y, x + cursor_length, y, clr);
655} 656}
@@ -658,10 +659,10 @@ void
658draw_params_cursor(size_t i, u8 clr) { 659draw_params_cursor(size_t i, u8 clr) {
659 switch (channel_selection_loc) { 660 switch (channel_selection_loc) {
660 case 0: { 661 case 0: {
661 draw_params_cursor_sq1(i, clr); 662 draw_params_cursor_square(i, clr, true);
662 } break; 663 } break;
663 case 1: { 664 case 1: {
664 // draw_params_cursor_sq2(i, clr); 665 draw_params_cursor_square(i, clr, false);
665 } break; 666 } break;
666 case 2: { 667 case 2: {
667 draw_params_cursor_wave(i, clr); 668 draw_params_cursor_wave(i, clr);
@@ -806,11 +807,13 @@ draw_parameters_wave(void) {
806 807
807void 808void
808draw_parameters_square(ChannelSquareParams *params, bool sweep) { 809draw_parameters_square(ChannelSquareParams *params, bool sweep) {
810 size_t x_offset = sweep ? 0 : 30;
811
809 // Duty cycle. 812 // Duty cycle.
810 { 813 {
811 // Shape drawing. 814 // Shape drawing.
812 { 815 {
813 size_t x = PARAMS_START_X; 816 size_t x = PARAMS_START_X + x_offset;
814 size_t y = PARAMS_START_Y + PARAMS_H - 43; 817 size_t y = PARAMS_START_Y + PARAMS_H - 43;
815 818
816 size_t x0 = x + 2; 819 size_t x0 = x + 2;
@@ -868,7 +871,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
868 871
869 // Param box. 872 // Param box.
870 { 873 {
871 size_t x = PARAMS_START_X; 874 size_t x = PARAMS_START_X + x_offset;
872 size_t y = PARAMS_START_Y + PARAMS_H - 25; 875 size_t y = PARAMS_START_Y + PARAMS_H - 25;
873 draw_line(x, y + 7, x + 2, y + 7, COL_FG); 876 draw_line(x, y + 7, x + 2, y + 7, COL_FG);
874 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG); 877 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG);
@@ -879,7 +882,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
879 882
880 switch (params->duty_cycle) { 883 switch (params->duty_cycle) {
881 case 0: { 884 case 0: {
882 txt_drawf("0", x + 9, y + 10, 6, COL_FG); 885 txt_drawf("12", x + 6, y + 10, 6, COL_FG);
883 } break; 886 } break;
884 case 1: { 887 case 1: {
885 txt_drawf("25", x + 6, y + 10, 6, COL_FG); 888 txt_drawf("25", x + 6, y + 10, 6, COL_FG);
@@ -900,14 +903,14 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
900 { 903 {
901 // Bounding box. 904 // Bounding box.
902 { 905 {
903 size_t x0 = PARAMS_START_X + 31; 906 size_t x0 = PARAMS_START_X + 31 + x_offset;
904 size_t y0 = PARAMS_START_Y + PARAMS_H - 46; 907 size_t y0 = PARAMS_START_Y + PARAMS_H - 46;
905 size_t x1 = x0 + 79; 908 size_t x1 = x0 + 79;
906 size_t y1 = y0 + 21; 909 size_t y1 = y0 + 21;
907 draw_rect(x0, y0, x1, y1, COL_CYAN); 910 draw_rect(x0, y0, x1, y1, COL_CYAN);
908 } 911 }
909 912
910 size_t x = PARAMS_START_X + 42; 913 size_t x = PARAMS_START_X + 42 + x_offset;
911 size_t y = PARAMS_START_Y + PARAMS_H - 43; 914 size_t y = PARAMS_START_Y + PARAMS_H - 43;
912 size_t x0 = x; 915 size_t x0 = x;
913 size_t y0 = y + 15 - params->env_volume; 916 size_t y0 = y + 15 - params->env_volume;
@@ -927,7 +930,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
927 930
928 // Env. volume. 931 // Env. volume.
929 { 932 {
930 size_t x = PARAMS_START_X + 31; 933 size_t x = PARAMS_START_X + 31 + x_offset;
931 size_t y = PARAMS_START_Y + PARAMS_H - 25; 934 size_t y = PARAMS_START_Y + PARAMS_H - 25;
932 draw_line(x, y + 7, x + 4, y + 7, COL_FG); 935 draw_line(x, y + 7, x + 4, y + 7, COL_FG);
933 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG); 936 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG);
@@ -990,7 +993,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
990 993
991 // Env. direction 994 // Env. direction
992 { 995 {
993 size_t x = PARAMS_START_X + 59; 996 size_t x = PARAMS_START_X + 59 + x_offset;
994 size_t y = PARAMS_START_Y + PARAMS_H - 25; 997 size_t y = PARAMS_START_Y + PARAMS_H - 25;
995 draw_line(x, y + 7, x + 4, y + 7, COL_FG); 998 draw_line(x, y + 7, x + 4, y + 7, COL_FG);
996 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG); 999 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG);
@@ -1013,7 +1016,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
1013 1016
1014 // Env. time. 1017 // Env. time.
1015 { 1018 {
1016 size_t x = PARAMS_START_X + 87; 1019 size_t x = PARAMS_START_X + 87 + x_offset;
1017 size_t y = PARAMS_START_Y + PARAMS_H - 25; 1020 size_t y = PARAMS_START_Y + PARAMS_H - 25;
1018 draw_line(x, y + 7, x + 2, y + 7, COL_FG); 1021 draw_line(x, y + 7, x + 2, y + 7, COL_FG);
1019 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG); 1022 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG);
@@ -1075,6 +1078,18 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
1075 case 3: { 1078 case 3: {
1076 txt_drawf("3", x + 9, y + 10, 6, COL_FG); 1079 txt_drawf("3", x + 9, y + 10, 6, COL_FG);
1077 } break; 1080 } break;
1081 case 4: {
1082 txt_drawf("4", x + 9, y + 10, 6, COL_FG);
1083 } break;
1084 case 5: {
1085 txt_drawf("5", x + 9, y + 10, 6, COL_FG);
1086 } break;
1087 case 6: {
1088 txt_drawf("6", x + 9, y + 10, 6, COL_FG);
1089 } break;
1090 case 7: {
1091 txt_drawf("7", x + 9, y + 10, 6, COL_FG);
1092 } break;
1078 } 1093 }
1079 } 1094 }
1080 1095
@@ -1102,6 +1117,18 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
1102 case 3: { 1117 case 3: {
1103 txt_drawf("3", x + 9, y + 10, 6, COL_FG); 1118 txt_drawf("3", x + 9, y + 10, 6, COL_FG);
1104 } break; 1119 } break;
1120 case 4: {
1121 txt_drawf("4", x + 9, y + 10, 6, COL_FG);
1122 } break;
1123 case 5: {
1124 txt_drawf("5", x + 9, y + 10, 6, COL_FG);
1125 } break;
1126 case 6: {
1127 txt_drawf("6", x + 9, y + 10, 6, COL_FG);
1128 } break;
1129 case 7: {
1130 txt_drawf("7", x + 9, y + 10, 6, COL_FG);
1131 } break;
1105 } 1132 }
1106 } 1133 }
1107 1134
@@ -1130,7 +1157,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) {
1130 1157
1131 // Labels. 1158 // Labels.
1132 { 1159 {
1133 size_t x = PARAMS_START_X; 1160 size_t x = PARAMS_START_X + x_offset;
1134 size_t y = PARAMS_START_Y + PARAMS_H - 43; 1161 size_t y = PARAMS_START_Y + PARAMS_H - 43;
1135 txt_drawf_small("shape", x + 1, y - 12, 4, COL_FG); 1162 txt_drawf_small("shape", x + 1, y - 12, 4, COL_FG);
1136 txt_drawf_small("envelope", x + 54, y - 12, 4, COL_FG); 1163 txt_drawf_small("envelope", x + 54, y - 12, 4, COL_FG);
@@ -1363,9 +1390,9 @@ handle_param_selection_sq1(void) {
1363 inc = -2; 1390 inc = -2;
1364 } 1391 }
1365 } 1392 }
1366 draw_params_cursor_sq1(param_selection_loc, COL_BG); 1393 draw_params_cursor(param_selection_loc, COL_BG);
1367 param_selection_loc = CLAMP(loc + inc, 0, 6); 1394 param_selection_loc = CLAMP(loc + inc, 0, 6);
1368 draw_params_cursor_sq1(param_selection_loc, COL_CURSOR); 1395 draw_params_cursor(param_selection_loc, COL_CURSOR);
1369 } 1396 }
1370 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { 1397 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) {
1371 int inc = 0; 1398 int inc = 0;
@@ -1387,9 +1414,9 @@ handle_param_selection_sq1(void) {
1387 inc = -1; 1414 inc = -1;
1388 } 1415 }
1389 } 1416 }
1390 draw_params_cursor_sq1(param_selection_loc, COL_BG); 1417 draw_params_cursor(param_selection_loc, COL_BG);
1391 param_selection_loc = CLAMP(loc + inc, 0, 6); 1418 param_selection_loc = CLAMP(loc + inc, 0, 6);
1392 draw_params_cursor_sq1(param_selection_loc, COL_CURSOR); 1419 draw_params_cursor(param_selection_loc, COL_CURSOR);
1393 } 1420 }
1394 1421
1395 // Adjust parameter. 1422 // Adjust parameter.
@@ -1415,10 +1442,10 @@ handle_param_selection_sq1(void) {
1415 params->env_time = CLAMP(params->env_time + inc, 0, 7); 1442 params->env_time = CLAMP(params->env_time + inc, 0, 7);
1416 } break; 1443 } break;
1417 case 4: { 1444 case 4: {
1418 params->sweep_number = CLAMP(params->sweep_number + inc, 0, 3); 1445 params->sweep_number = CLAMP(params->sweep_number + inc, 0, 7);
1419 } break; 1446 } break;
1420 case 5: { 1447 case 5: {
1421 params->sweep_time = CLAMP(params->sweep_time + inc, 0, 3); 1448 params->sweep_time = CLAMP(params->sweep_time + inc, 0, 7);
1422 } break; 1449 } break;
1423 case 6: { 1450 case 6: {
1424 params->sweep_direction ^= 1; 1451 params->sweep_direction ^= 1;
@@ -1431,71 +1458,53 @@ handle_param_selection_sq1(void) {
1431 1458
1432void 1459void
1433handle_param_selection_sq2(void) { 1460handle_param_selection_sq2(void) {
1461 // Go back to trigger selection.
1434 if (key_tap(KEY_A)) { 1462 if (key_tap(KEY_A)) {
1435 draw_params_cursor(param_selection_loc, COL_BG); 1463 draw_params_cursor(param_selection_loc, COL_BG);
1436 input_handler = handle_trigger_selection; 1464 input_handler = handle_trigger_selection;
1437 draw_trig_cursor(trig_selection_loc, COL_CURSOR); 1465 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1438 } 1466 }
1439 // // Move through the selected synth parameters. 1467
1440 // if (key_tap(KEY_LEFT)) { 1468 // Cursor movement.
1441 // int max_param = 6; 1469 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) {
1442 // if (channel_selection_loc == 1) { 1470 int inc = 0;
1443 // max_param = 3; 1471 int loc = param_selection_loc;
1444 // } 1472 if (key_tap(KEY_RIGHT)) {
1445 // if (param_selection_loc == 0) { 1473 inc = 1;
1446 // param_selection_loc = max_param; 1474 } else {
1447 // } else { 1475 inc = -1;
1448 // param_selection_loc = MAX(param_selection_loc - 1, 0); 1476 }
1449 // } 1477 draw_params_cursor(param_selection_loc, COL_BG);
1450 // } 1478 param_selection_loc = CLAMP(loc + inc, 0, 3);
1451 // if (key_tap(KEY_RIGHT)) { 1479 draw_params_cursor(param_selection_loc, COL_CURSOR);
1452 // int max_param = 6; 1480 }
1453 // if (channel_selection_loc == 1) { 1481
1454 // max_param = 3; 1482 // Adjust parameter.
1455 // } 1483 if (key_tap(KEY_R) || key_tap(KEY_L)) {
1456 // if (param_selection_loc == max_param) { 1484 int inc;
1457 // param_selection_loc = 0; 1485 if (key_tap(KEY_L)) {
1458 // } else { 1486 inc = -1;
1459 // param_selection_loc = MIN(param_selection_loc + 1, max_param); 1487 } else {
1460 // } 1488 inc = 1;
1461 // } 1489 }
1462 1490 ChannelSquareParams *params = &ch2.params[trig_selection_loc];
1463 // // Adjust the parameters up or down. 1491 switch (param_selection_loc) {
1464 // if (key_tap(KEY_L) || key_tap(KEY_R)) { 1492 case 0: {
1465 // int inc; 1493 params->duty_cycle = CLAMP(params->duty_cycle + inc, 0, 3);
1466 // if (key_tap(KEY_L)) { 1494 } break;
1467 // inc = -1; 1495 case 1: {
1468 // } else { 1496 params->env_volume = CLAMP(params->env_volume + inc, 0, 15);
1469 // inc = 1; 1497 } break;
1470 // } 1498 case 2: {
1471 // switch (param_selection_loc) { 1499 params->env_direction ^= 1;
1472 // case 0: { 1500 } break;
1473 // trig->env_volume = CLAMP(trig->env_volume + inc, 0, 15); 1501 case 3: {
1474 // } break; 1502 params->env_time = CLAMP(params->env_time + inc, 0, 7);
1475 // case 1: { 1503 } break;
1476 // trig->env_time = CLAMP(trig->env_time + inc, 0, 7); 1504 }
1477 // } break; 1505 draw_parameters();
1478 // case 2: { 1506 draw_params_cursor(param_selection_loc, COL_CURSOR);
1479 // trig->env_direction ^= 1; 1507 }
1480 // } break;
1481 // case 3: {
1482 // trig->duty_cycle = CLAMP(trig->duty_cycle + inc, 0, 3);
1483 // } break;
1484 // case 4: {
1485 // trig->sweep_number = CLAMP(trig->sweep_number + inc, 0, 7);
1486 // } break;
1487 // case 5: {
1488 // trig->sweep_time = CLAMP(trig->sweep_time + inc, 0, 7);
1489 // } break;
1490 // case 6: {
1491 // if (trig->sweep_direction == 0) {
1492 // trig->sweep_direction = 1;
1493 // } else {
1494 // trig->sweep_direction = 0;
1495 // }
1496 // } break;
1497 // }
1498 // }
1499} 1508}
1500 1509
1501void 1510void
@@ -1530,9 +1539,9 @@ handle_param_selection_wave(void) {
1530 inc = -1; 1539 inc = -1;
1531 } 1540 }
1532 } 1541 }
1533 draw_params_cursor_wave(param_selection_loc, COL_BG); 1542 draw_params_cursor(param_selection_loc, COL_BG);
1534 param_selection_loc = CLAMP(loc + inc, 0, 73); 1543 param_selection_loc = CLAMP(loc + inc, 0, 73);
1535 draw_params_cursor_wave(param_selection_loc, COL_CURSOR); 1544 draw_params_cursor(param_selection_loc, COL_CURSOR);
1536 } 1545 }
1537 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { 1546 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) {
1538 int inc = 0; 1547 int inc = 0;
@@ -1586,9 +1595,9 @@ handle_param_selection_wave(void) {
1586 inc = -1; 1595 inc = -1;
1587 } 1596 }
1588 } 1597 }
1589 draw_params_cursor_wave(param_selection_loc, COL_BG); 1598 draw_params_cursor(param_selection_loc, COL_BG);
1590 param_selection_loc = CLAMP(loc + inc, 0, 73); 1599 param_selection_loc = CLAMP(loc + inc, 0, 73);
1591 draw_params_cursor_wave(param_selection_loc, COL_CURSOR); 1600 draw_params_cursor(param_selection_loc, COL_CURSOR);
1592 } 1601 }
1593 1602
1594 // Adjust parameter. 1603 // Adjust parameter.