diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clipboard.c | 4 | ||||
-rw-r--r-- | src/drawing.c | 54 | ||||
-rw-r--r-- | src/globals.c | 18 | ||||
-rw-r--r-- | src/main.c | 17 | ||||
-rw-r--r-- | src/sequencer.c | 29 |
5 files changed, 106 insertions, 16 deletions
diff --git a/src/clipboard.c b/src/clipboard.c index edb9b31..d82f576 100644 --- a/src/clipboard.c +++ b/src/clipboard.c | |||
@@ -21,6 +21,8 @@ typedef struct Clipboard { | |||
21 | 21 | ||
22 | static Clipboard clipboard = {CLIP_EMPTY, 0, 0, 0}; | 22 | static Clipboard clipboard = {CLIP_EMPTY, 0, 0, 0}; |
23 | 23 | ||
24 | void send_notif(char *msg); | ||
25 | |||
24 | void | 26 | void |
25 | clipboard_paste(void) { | 27 | clipboard_paste(void) { |
26 | Pattern *pat_dst = &patterns[pattern_selection_loc]; | 28 | Pattern *pat_dst = &patterns[pattern_selection_loc]; |
@@ -408,8 +410,6 @@ clipboard_paste(void) { | |||
408 | } | 410 | } |
409 | } | 411 | } |
410 | 412 | ||
411 | void send_notif(char *msg); | ||
412 | |||
413 | void | 413 | void |
414 | clipboard_copy(void) { | 414 | clipboard_copy(void) { |
415 | if (input_handler == handle_trigger_selection) { | 415 | if (input_handler == handle_trigger_selection) { |
diff --git a/src/drawing.c b/src/drawing.c index 18504bc..dff5db2 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -1251,7 +1251,7 @@ draw_notif_bar() { | |||
1251 | if (notif.time > 0) { | 1251 | if (notif.time > 0) { |
1252 | char msg[32] = {0}; | 1252 | char msg[32] = {0}; |
1253 | if (notif.time <= 32) { | 1253 | if (notif.time <= 32) { |
1254 | for (size_t i = 0; i < notif.time; i++) { | 1254 | for (s16 i = 0; i < notif.time; i++) { |
1255 | msg[i] = notif.msg[i + 32 - notif.time]; | 1255 | msg[i] = notif.msg[i + 32 - notif.time]; |
1256 | } | 1256 | } |
1257 | } else { | 1257 | } else { |
@@ -1295,10 +1295,56 @@ draw_notif_bar() { | |||
1295 | return; | 1295 | return; |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | if (play_status == 0) { | 1298 | if (chain.len != 0) { |
1299 | txt_drawf_small("STOPPED", x0 + 2, y0 + 1, color); | 1299 | char msg[64] = {0}; |
1300 | char *ptr = msg; | ||
1301 | *ptr++ = 'c'; | ||
1302 | *ptr++ = 'h'; | ||
1303 | *ptr++ = 'a'; | ||
1304 | *ptr++ = 'i'; | ||
1305 | *ptr++ = 'n'; | ||
1306 | *ptr++ = ':'; | ||
1307 | *ptr++ = ' '; | ||
1308 | for (size_t i = 0; i < chain.len; i++) { | ||
1309 | if (i != 0) { | ||
1310 | *ptr++ = '-'; | ||
1311 | } | ||
1312 | *ptr++ = 'A' + chain.chain[i]; | ||
1313 | } | ||
1314 | *ptr++ = '\0'; | ||
1315 | txt_drawf_small(msg, x0 + 2, y0 + 1, color); | ||
1300 | } else { | 1316 | } else { |
1301 | txt_drawf_small("PLAYING", x0 + 2, y0 + 1, color); | 1317 | if (play_status == 0) { |
1318 | txt_drawf_small("STOPPED", x0 + 2, y0 + 1, color); | ||
1319 | } else { | ||
1320 | txt_drawf_small("PLAYING", x0 + 2, y0 + 1, color); | ||
1321 | } | ||
1322 | } | ||
1323 | } | ||
1324 | } | ||
1325 | |||
1326 | void | ||
1327 | draw_pattern_chain() { | ||
1328 | clear_parameters(); | ||
1329 | for (size_t i = 0; i < 16; i++) { | ||
1330 | u8 color = COL_FG; | ||
1331 | size_t offset_x = PAT_TRIG_OFFSET_X * (i % 8); | ||
1332 | size_t offset_y = i < 8 ? 0 : 0 + PAT_TRIG_OFFSET_Y; | ||
1333 | size_t x0 = PAT_TRIG_START_X + offset_x; | ||
1334 | size_t x1 = PAT_TRIG_START_X + offset_x + PAT_TRIG_W; | ||
1335 | size_t y0 = PAT_TRIG_START_Y + offset_y; | ||
1336 | size_t y1 = PAT_TRIG_START_Y + offset_y + PAT_TRIG_H; | ||
1337 | draw_rect(x0, y0, x1, y1, color); | ||
1338 | if (chain.active[i]) { | ||
1339 | txt_drawc('A' + chain.chain[i], x0 + 4, y0 + 3, color); | ||
1302 | } | 1340 | } |
1303 | } | 1341 | } |
1342 | // draw_rect( | ||
1343 | // PARAMS_START_X, | ||
1344 | // PARAMS_START_Y + 6, | ||
1345 | // PARAMS_START_X + PARAMS_W, | ||
1346 | // PARAMS_START_Y + PARAMS_H - 6, COL_FG); | ||
1347 | // txt_drawf_small("Current pattern: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8, COL_FG, "A"); | ||
1348 | // txt_drawf_small("Next pattern: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8 * 2, COL_FG, "A"); | ||
1349 | // txt_drawf_small("Chain: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8 * 3, COL_FG, "A - B - B - A - B"); | ||
1304 | } | 1350 | } |
diff --git a/src/globals.c b/src/globals.c index c2e2ee2..3a70005 100644 --- a/src/globals.c +++ b/src/globals.c | |||
@@ -80,6 +80,13 @@ bool clear_screen = true; | |||
80 | #define BANK_START_X (R_SIDEBAR_X + 5) | 80 | #define BANK_START_X (R_SIDEBAR_X + 5) |
81 | #define BANK_START_Y (PAT_START_Y) | 81 | #define BANK_START_Y (PAT_START_Y) |
82 | 82 | ||
83 | #define PAT_TRIG_W 14 | ||
84 | #define PAT_TRIG_H 14 | ||
85 | #define PAT_TRIG_START_X 35 | ||
86 | #define PAT_TRIG_START_Y 29 | ||
87 | #define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7) | ||
88 | #define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8) | ||
89 | |||
83 | #define SEQ_N_CHANNELS 4 | 90 | #define SEQ_N_CHANNELS 4 |
84 | 91 | ||
85 | enum RIGHT_COL_LOC { | 92 | enum RIGHT_COL_LOC { |
@@ -131,3 +138,14 @@ typedef struct Notification { | |||
131 | static Notification notif = {0}; | 138 | static Notification notif = {0}; |
132 | 139 | ||
133 | #define NOTIF_TIME (80 + 32) | 140 | #define NOTIF_TIME (80 + 32) |
141 | |||
142 | #define MAX_CHAIN 16 | ||
143 | typedef struct Chain { | ||
144 | u8 chain[MAX_CHAIN]; | ||
145 | u8 active[MAX_CHAIN]; | ||
146 | u8 len; | ||
147 | u8 loop; | ||
148 | u8 current; | ||
149 | } Chain; | ||
150 | |||
151 | static Chain chain = {0}; | ||
@@ -92,17 +92,14 @@ render_sequencer(void) { | |||
92 | if (redraw_params) { | 92 | if (redraw_params) { |
93 | PROF(draw_parameters(), draw_param_cycles); | 93 | PROF(draw_parameters(), draw_param_cycles); |
94 | redraw_params = false; | 94 | redraw_params = false; |
95 | } else if (input_handler == handle_pattern_selection){ | ||
96 | // DEBUG: move to drawing file | ||
97 | draw_rect( | ||
98 | PARAMS_START_X, | ||
99 | PARAMS_START_Y + 6, | ||
100 | PARAMS_START_X + PARAMS_W, | ||
101 | PARAMS_START_Y + PARAMS_H - 6, COL_FG); | ||
102 | txt_drawf_small("Current pattern: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8, COL_FG, "A"); | ||
103 | txt_drawf_small("Next pattern: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8 * 2, COL_FG, "A"); | ||
104 | txt_drawf_small("Chain: %s", PARAMS_START_X + 3, PARAMS_START_Y + 8 * 3, COL_FG, "A - B - B - A - B"); | ||
105 | } | 95 | } |
96 | |||
97 | if (input_handler == handle_pattern_selection){ | ||
98 | // TODO: redraw_params in pattern_selection context? | ||
99 | draw_pattern_chain(); | ||
100 | } | ||
101 | |||
102 | // TODO: redraw_notif? | ||
106 | draw_notif_bar(); | 103 | draw_notif_bar(); |
107 | PROF(draw_cursors(), draw_cursor_cycles); | 104 | PROF(draw_cursors(), draw_cursor_cycles); |
108 | } | 105 | } |
diff --git a/src/sequencer.c b/src/sequencer.c index 5b70bb2..44ff90e 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -520,6 +520,35 @@ handle_pattern_selection(void) { | |||
520 | default: { right_col_selection_loc = R_COL_BPM; } break; | 520 | default: { right_col_selection_loc = R_COL_BPM; } break; |
521 | } | 521 | } |
522 | } | 522 | } |
523 | if (key_tap(KEY_R)) { | ||
524 | // Find next empty slot. | ||
525 | s16 slot = -1; | ||
526 | for (size_t i = 0; i < 16; i++) { | ||
527 | if (chain.active[i] == 0) { | ||
528 | slot = i; | ||
529 | break; | ||
530 | } | ||
531 | } | ||
532 | if (slot > -1) { | ||
533 | chain.chain[slot] = pattern_selection_loc; | ||
534 | chain.active[slot] = 1; | ||
535 | chain.len++; // TODO: remove | ||
536 | } | ||
537 | } | ||
538 | if (key_tap(KEY_L)) { | ||
539 | // Find last active slot. | ||
540 | s16 slot = -1; | ||
541 | for (size_t i = 0; i < 16; i++) { | ||
542 | if (chain.active[15 - i] == 1) { | ||
543 | slot = 15 - i; | ||
544 | break; | ||
545 | } | ||
546 | } | ||
547 | if (slot > -1) { | ||
548 | chain.active[slot] = 0; | ||
549 | chain.len--; // TODO: remove | ||
550 | } | ||
551 | } | ||
523 | } | 552 | } |
524 | 553 | ||
525 | bool | 554 | bool |