diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/drawing.c | 17 | ||||
-rw-r--r-- | src/globals.c | 12 | ||||
-rw-r--r-- | src/main.c | 14 | ||||
-rw-r--r-- | src/sequencer.c | 57 | ||||
-rw-r--r-- | src/settings.c | 55 | ||||
-rw-r--r-- | src/settings.h | 27 |
6 files changed, 137 insertions, 45 deletions
diff --git a/src/drawing.c b/src/drawing.c index fbc741c..27e265b 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -418,7 +418,12 @@ draw_bpm() { | |||
418 | txt_drawf("SYNC", x + 2, y + 2, COL_FG); | 418 | txt_drawf("SYNC", x + 2, y + 2, COL_FG); |
419 | } else { | 419 | } else { |
420 | // Make sure its horizontally centered if only 2 digits | 420 | // Make sure its horizontally centered if only 2 digits |
421 | int bpm = patterns[pattern_selection_loc].bpm; | 421 | int bpm; |
422 | if (settings.global_bpm) { | ||
423 | bpm = settings.bpm; | ||
424 | } else { | ||
425 | bpm = patterns[pattern_selection_loc].bpm; | ||
426 | } | ||
422 | if (bpm >= 100) { | 427 | if (bpm >= 100) { |
423 | txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); | 428 | txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); |
424 | } else { | 429 | } else { |
@@ -1672,7 +1677,7 @@ draw_notif_bar() { | |||
1672 | return; | 1677 | return; |
1673 | } | 1678 | } |
1674 | 1679 | ||
1675 | if (settings.help == HELP_ON) { | 1680 | if (settings.help == TOGGLE_ON) { |
1676 | if (input_handler == handle_trigger_selection || | 1681 | if (input_handler == handle_trigger_selection || |
1677 | input_handler == handle_channel_selection) { | 1682 | input_handler == handle_channel_selection) { |
1678 | txt_drawf_small("L/R:NOTE A:PARAMS B:TOGGLE", x0 + 2, y0 + 1, color); | 1683 | txt_drawf_small("L/R:NOTE A:PARAMS B:TOGGLE", x0 + 2, y0 + 1, color); |
@@ -1735,7 +1740,13 @@ draw_notif_bar() { | |||
1735 | roots[current_scale_root], scale_long[current_scale]); | 1740 | roots[current_scale_root], scale_long[current_scale]); |
1736 | } break; | 1741 | } break; |
1737 | case R_COL_BPM: { | 1742 | case R_COL_BPM: { |
1738 | txt_drawf_small("TEMPO: %d bpm", x0 + 2, y0 + 1, color, patterns[pattern_selection_loc].bpm); | 1743 | int bpm; |
1744 | if (settings.global_bpm) { | ||
1745 | bpm = settings.bpm; | ||
1746 | } else { | ||
1747 | bpm = patterns[pattern_selection_loc].bpm; | ||
1748 | } | ||
1749 | txt_drawf_small("TEMPO: %d bpm", x0 + 2, y0 + 1, color, bpm); | ||
1739 | } break; | 1750 | } break; |
1740 | } | 1751 | } |
1741 | return; | 1752 | return; |
diff --git a/src/globals.c b/src/globals.c index b94cb11..7361129 100644 --- a/src/globals.c +++ b/src/globals.c | |||
@@ -190,3 +190,15 @@ typedef enum Prob { | |||
190 | PROB_20, | 190 | PROB_20, |
191 | PROB_NUM, | 191 | PROB_NUM, |
192 | } Prob; | 192 | } Prob; |
193 | |||
194 | bool redraw_pattern_buttons = true; | ||
195 | bool redraw_play_pause = true; | ||
196 | bool redraw_trigs = true; | ||
197 | bool redraw_channels = true; | ||
198 | bool redraw_bank_buttons = true; | ||
199 | bool redraw_params = true; | ||
200 | bool redraw_bpm = true; | ||
201 | bool redraw_scale = true; | ||
202 | bool update_bpm = false; | ||
203 | u8 bar_counter = 0; | ||
204 | |||
@@ -146,11 +146,11 @@ render_settings(void) { | |||
146 | y0 += 17; | 146 | y0 += 17; |
147 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); | 147 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); |
148 | txt_drawf("MUTE", x0 + 2, y0 + 1, COL_FG); | 148 | txt_drawf("MUTE", x0 + 2, y0 + 1, COL_FG); |
149 | txt_drawf("OFF", x1 + 8, y0 + 1, COL_FG); | 149 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.global_mute]); |
150 | y0 += 17; | 150 | y0 += 17; |
151 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); | 151 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); |
152 | txt_drawf("BPM", x0 + 2, y0 + 1, COL_FG); | 152 | txt_drawf("BPM", x0 + 2, y0 + 1, COL_FG); |
153 | txt_drawf("OFF", x1 + 8, y0 + 1, COL_FG); | 153 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.global_bpm]); |
154 | y0 += 17; | 154 | y0 += 17; |
155 | 155 | ||
156 | txt_drawf("GENERAL", x0, y0, COL_FG); | 156 | txt_drawf("GENERAL", x0, y0, COL_FG); |
@@ -158,7 +158,7 @@ render_settings(void) { | |||
158 | y0 += 17; | 158 | y0 += 17; |
159 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); | 159 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); |
160 | txt_drawf("AUTO-SAVE", x0 + 2, y0 + 1, COL_FG); | 160 | txt_drawf("AUTO-SAVE", x0 + 2, y0 + 1, COL_FG); |
161 | txt_drawf("OFF", x1 + 8, y0 + 1, COL_FG); | 161 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.auto_save]); |
162 | y0 += 17; | 162 | y0 += 17; |
163 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); | 163 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); |
164 | txt_drawf("SYNC", x0 + 2, y0 + 1, COL_FG); | 164 | txt_drawf("SYNC", x0 + 2, y0 + 1, COL_FG); |
@@ -170,7 +170,7 @@ render_settings(void) { | |||
170 | y0 += 17; | 170 | y0 += 17; |
171 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); | 171 | draw_rect(x0, y0, x1, y0 + 10, COL_FG); |
172 | txt_drawf("HELP", x0 + 2, y0 + 1, COL_FG); | 172 | txt_drawf("HELP", x0 + 2, y0 + 1, COL_FG); |
173 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, help_setting_str[settings.help]); | 173 | txt_drawf("%s", x1 + 8, y0 + 1, COL_FG, toggle_settings_str[settings.help]); |
174 | 174 | ||
175 | PROF(draw_settings_cursor(), draw_cursor_cycles); | 175 | PROF(draw_settings_cursor(), draw_cursor_cycles); |
176 | } | 176 | } |
@@ -224,7 +224,11 @@ update(void) { | |||
224 | last_pattern_loc = pattern_selection_loc; | 224 | last_pattern_loc = pattern_selection_loc; |
225 | last_right_col_loc = right_col_selection_loc; | 225 | last_right_col_loc = right_col_selection_loc; |
226 | if (update_bpm) { | 226 | if (update_bpm) { |
227 | set_time(patterns[current_pattern].bpm); | 227 | if (settings.global_bpm) { |
228 | set_time(settings.bpm); | ||
229 | } else { | ||
230 | set_time(patterns[current_pattern].bpm); | ||
231 | } | ||
228 | update_bpm = false; | 232 | update_bpm = false; |
229 | } | 233 | } |
230 | if (audio_sync_click) { | 234 | if (audio_sync_click) { |
diff --git a/src/sequencer.c b/src/sequencer.c index f3dff04..07f3012 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -8,17 +8,6 @@ | |||
8 | 8 | ||
9 | void set_time(int bpm); | 9 | void set_time(int bpm); |
10 | 10 | ||
11 | bool redraw_pattern_buttons = true; | ||
12 | bool redraw_play_pause = true; | ||
13 | bool redraw_trigs = true; | ||
14 | bool redraw_channels = true; | ||
15 | bool redraw_bank_buttons = true; | ||
16 | bool redraw_params = true; | ||
17 | bool redraw_bpm = true; | ||
18 | bool redraw_scale = true; | ||
19 | bool update_bpm = false; | ||
20 | u8 bar_counter = 0; | ||
21 | |||
22 | void | 11 | void |
23 | clear_pattern(size_t idx) { | 12 | clear_pattern(size_t idx) { |
24 | Pattern *pat = &patterns[idx]; | 13 | Pattern *pat = &patterns[idx]; |
@@ -121,7 +110,9 @@ select_bank(int i) { | |||
121 | next_pattern = 0; | 110 | next_pattern = 0; |
122 | next_bank = i; | 111 | next_bank = i; |
123 | clipboard.type = CLIP_EMPTY; | 112 | clipboard.type = CLIP_EMPTY; |
124 | save_bank(current_bank); | 113 | if (settings.auto_save) { |
114 | save_bank(current_bank); | ||
115 | } | ||
125 | metadata.current_pattern = current_pattern; | 116 | metadata.current_pattern = current_pattern; |
126 | metadata.current_bank = i; | 117 | metadata.current_bank = i; |
127 | save_metadata(); | 118 | save_metadata(); |
@@ -552,7 +543,11 @@ toggle_playing(void) { | |||
552 | if (current_bank != next_bank) { | 543 | if (current_bank != next_bank) { |
553 | select_bank(next_bank); | 544 | select_bank(next_bank); |
554 | } | 545 | } |
555 | set_time(patterns[current_pattern].bpm); | 546 | if (settings.global_bpm) { |
547 | set_time(settings.bpm); | ||
548 | } else { | ||
549 | set_time(patterns[current_pattern].bpm); | ||
550 | } | ||
556 | play_step(); | 551 | play_step(); |
557 | } else { | 552 | } else { |
558 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; | 553 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; |
@@ -590,7 +585,11 @@ pause_playing(void) { | |||
590 | current_pattern = next_pattern; | 585 | current_pattern = next_pattern; |
591 | redraw_pattern_buttons = true; | 586 | redraw_pattern_buttons = true; |
592 | } | 587 | } |
593 | set_time(patterns[current_pattern].bpm); | 588 | if (settings.global_bpm) { |
589 | set_time(settings.bpm); | ||
590 | } else { | ||
591 | set_time(patterns[current_pattern].bpm); | ||
592 | } | ||
594 | play_step(); | 593 | play_step(); |
595 | } else { | 594 | } else { |
596 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; | 595 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; |
@@ -666,13 +665,18 @@ handle_right_col_selection(void) { | |||
666 | if (key_pressed(KEY_SELECT)) { | 665 | if (key_pressed(KEY_SELECT)) { |
667 | bpm_inc = -10; | 666 | bpm_inc = -10; |
668 | } | 667 | } |
669 | patterns[pattern_selection_loc].bpm = CLAMP( | 668 | if (settings.global_bpm) { |
670 | patterns[pattern_selection_loc].bpm + bpm_inc, | 669 | settings.bpm = CLAMP(settings.bpm + bpm_inc, 10, 300); |
671 | 10, | 670 | } else { |
672 | 300); | 671 | patterns[pattern_selection_loc].bpm = CLAMP(patterns[pattern_selection_loc].bpm + bpm_inc, 10, 300); |
672 | } | ||
673 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0 | 673 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0 |
674 | && current_pattern == pattern_selection_loc) { | 674 | && current_pattern == pattern_selection_loc) { |
675 | set_time(patterns[current_pattern].bpm); | 675 | if (settings.global_bpm) { |
676 | set_time(settings.bpm); | ||
677 | } else { | ||
678 | set_time(patterns[current_pattern].bpm); | ||
679 | } | ||
676 | } | 680 | } |
677 | redraw_bpm = true; | 681 | redraw_bpm = true; |
678 | if (patterns[pattern_selection_loc].empty) { | 682 | if (patterns[pattern_selection_loc].empty) { |
@@ -701,13 +705,18 @@ handle_right_col_selection(void) { | |||
701 | if (key_pressed(KEY_SELECT)) { | 705 | if (key_pressed(KEY_SELECT)) { |
702 | bpm_inc = 10; | 706 | bpm_inc = 10; |
703 | } | 707 | } |
704 | patterns[pattern_selection_loc].bpm = CLAMP( | 708 | if (settings.global_bpm) { |
705 | patterns[pattern_selection_loc].bpm + bpm_inc, | 709 | settings.bpm = CLAMP(settings.bpm + bpm_inc, 10, 300); |
706 | 10, | 710 | } else { |
707 | 300); | 711 | patterns[pattern_selection_loc].bpm = CLAMP(patterns[pattern_selection_loc].bpm + bpm_inc, 10, 300); |
712 | } | ||
708 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0 | 713 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0 |
709 | && current_pattern == pattern_selection_loc) { | 714 | && current_pattern == pattern_selection_loc) { |
710 | set_time(patterns[current_pattern].bpm); | 715 | if (settings.global_bpm) { |
716 | set_time(settings.bpm); | ||
717 | } else { | ||
718 | set_time(patterns[current_pattern].bpm); | ||
719 | } | ||
711 | } | 720 | } |
712 | redraw_bpm = true; | 721 | redraw_bpm = true; |
713 | if (patterns[pattern_selection_loc].empty) { | 722 | if (patterns[pattern_selection_loc].empty) { |
diff --git a/src/settings.c b/src/settings.c index eb1393b..5a10c90 100644 --- a/src/settings.c +++ b/src/settings.c | |||
@@ -1,7 +1,10 @@ | |||
1 | #include "settings.h" | 1 | #include "settings.h" |
2 | #include "save.h" | 2 | #include "save.h" |
3 | 3 | ||
4 | static Settings settings = {0}; | 4 | static Settings settings = { |
5 | .bpm = 90, | ||
6 | .auto_save = TOGGLE_ON, | ||
7 | }; | ||
5 | static int settings_cursor_loc = 0; | 8 | static int settings_cursor_loc = 0; |
6 | 9 | ||
7 | void serial_irq(void); | 10 | void serial_irq(void); |
@@ -86,8 +89,31 @@ handle_settings_input(void) { | |||
86 | } | 89 | } |
87 | swap_palette(settings.theme); | 90 | swap_palette(settings.theme); |
88 | } break; | 91 | } break; |
92 | case SETTINGS_GLOBAL_MUTE: { | ||
93 | if ((settings.global_mute + 1) >= TOGGLE_NUM) { | ||
94 | settings.global_mute = 0; | ||
95 | } else { | ||
96 | settings.global_mute++; | ||
97 | } | ||
98 | } break; | ||
99 | case SETTINGS_GLOBAL_BPM: { | ||
100 | if ((settings.global_bpm + 1) >= TOGGLE_NUM) { | ||
101 | settings.global_bpm = 0; | ||
102 | } else { | ||
103 | settings.global_bpm++; | ||
104 | } | ||
105 | redraw_bpm = true; | ||
106 | update_bpm = true; | ||
107 | } break; | ||
108 | case SETTINGS_AUTO_SAVE: { | ||
109 | if ((settings.auto_save + 1) >= TOGGLE_NUM) { | ||
110 | settings.auto_save = 0; | ||
111 | } else { | ||
112 | settings.auto_save++; | ||
113 | } | ||
114 | } break; | ||
89 | case SETTINGS_HELP: { | 115 | case SETTINGS_HELP: { |
90 | if ((settings.help + 1) >= HELP_NUM) { | 116 | if ((settings.help + 1) >= TOGGLE_NUM) { |
91 | settings.help = 0; | 117 | settings.help = 0; |
92 | } else { | 118 | } else { |
93 | settings.help++; | 119 | settings.help++; |
@@ -115,9 +141,32 @@ handle_settings_input(void) { | |||
115 | } | 141 | } |
116 | swap_palette(settings.theme); | 142 | swap_palette(settings.theme); |
117 | } break; | 143 | } break; |
144 | case SETTINGS_GLOBAL_MUTE: { | ||
145 | if (settings.global_mute == 0) { | ||
146 | settings.global_mute = TOGGLE_NUM - 1; | ||
147 | } else { | ||
148 | settings.global_mute--; | ||
149 | } | ||
150 | } break; | ||
151 | case SETTINGS_GLOBAL_BPM: { | ||
152 | if (settings.global_bpm == 0) { | ||
153 | settings.global_bpm = TOGGLE_NUM - 1; | ||
154 | } else { | ||
155 | settings.global_bpm--; | ||
156 | } | ||
157 | redraw_bpm = true; | ||
158 | update_bpm = true; | ||
159 | } break; | ||
160 | case SETTINGS_AUTO_SAVE: { | ||
161 | if (settings.auto_save == 0) { | ||
162 | settings.auto_save = TOGGLE_NUM - 1; | ||
163 | } else { | ||
164 | settings.auto_save--; | ||
165 | } | ||
166 | } break; | ||
118 | case SETTINGS_HELP: { | 167 | case SETTINGS_HELP: { |
119 | if (settings.help == 0) { | 168 | if (settings.help == 0) { |
120 | settings.help = HELP_NUM - 1; | 169 | settings.help = TOGGLE_NUM - 1; |
121 | } else { | 170 | } else { |
122 | settings.help--; | 171 | settings.help--; |
123 | } | 172 | } |
diff --git a/src/settings.h b/src/settings.h index f917534..a348517 100644 --- a/src/settings.h +++ b/src/settings.h | |||
@@ -2,8 +2,8 @@ | |||
2 | #define SETTINGS_H | 2 | #define SETTINGS_H |
3 | 3 | ||
4 | typedef enum SettingsList { | 4 | typedef enum SettingsList { |
5 | SETTINGS_GLOB_MUTE, | 5 | SETTINGS_GLOBAL_MUTE, |
6 | SETTINGS_GLOB_BPM, | 6 | SETTINGS_GLOBAL_BPM, |
7 | SETTINGS_AUTO_SAVE, | 7 | SETTINGS_AUTO_SAVE, |
8 | SETTINGS_SYNC, | 8 | SETTINGS_SYNC, |
9 | SETTINGS_THEME, | 9 | SETTINGS_THEME, |
@@ -59,22 +59,29 @@ char * theme_setting_str[] = { | |||
59 | "MERVEILLES", | 59 | "MERVEILLES", |
60 | }; | 60 | }; |
61 | 61 | ||
62 | typedef enum HelpSetting { | 62 | typedef enum ToggleSettings { |
63 | HELP_OFF = 0, | 63 | TOGGLE_OFF = 0, |
64 | HELP_ON, | 64 | TOGGLE_ON, |
65 | HELP_NUM, | 65 | TOGGLE_NUM, |
66 | } HelpSetting; | 66 | } ToggleSettings; |
67 | 67 | ||
68 | char * help_setting_str[] = { | 68 | char * toggle_settings_str[] = { |
69 | "OFF", | 69 | "OFF", |
70 | "ON", | 70 | "ON", |
71 | }; | 71 | }; |
72 | 72 | ||
73 | typedef struct Settings { | 73 | typedef struct Settings { |
74 | ToggleSettings global_mute; | ||
75 | bool mutes[4]; | ||
76 | ToggleSettings global_bpm; | ||
77 | int bpm; | ||
78 | ToggleSettings auto_save; | ||
74 | SyncSetting sync; | 79 | SyncSetting sync; |
75 | ThemeSetting theme; | 80 | ThemeSetting theme; |
76 | HelpSetting help; | 81 | ToggleSettings help; |
77 | u8 reserved[63]; | 82 | u8 reserved[52]; |
78 | } Settings; | 83 | } Settings; |
79 | 84 | ||
85 | // TODO: Save globals on a separate struct, within the metadata struct? | ||
86 | |||
80 | #endif // SETTINGS_H | 87 | #endif // SETTINGS_H |