aboutsummaryrefslogtreecommitdiffstats
path: root/src/sequencer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sequencer.c')
-rw-r--r--src/sequencer.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index b295730..d8c5f3f 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -26,9 +26,9 @@ gate_off(void) {
26 | SIO_SI_OUT(0) 26 | SIO_SI_OUT(0)
27 | SIO_SO_OUT(1) 27 | SIO_SO_OUT(1)
28 | SIO_SC(0) 28 | SIO_SC(0)
29 | SIO_SD(1) 29 | SIO_SD(0)
30 | SIO_SO(0); 30 | SIO_SO(0);
31 TIMER_CTRL_1 = 0; 31 TIMER_CTRL_3 = 0;
32} 32}
33 33
34void 34void
@@ -39,12 +39,13 @@ gate_on(void) {
39 | SIO_SI_OUT(0) 39 | SIO_SI_OUT(0)
40 | SIO_SO_OUT(1) 40 | SIO_SO_OUT(1)
41 | SIO_SC(1) 41 | SIO_SC(1)
42 | SIO_SD(1) 42 | SIO_SD(0)
43 | SIO_SO(0); 43 | SIO_SO(1);
44 int n_ticks = -244181 / 600; 44 int n_ticks = -244181 / 600;
45 irs_set(IRQ_TIMER_1, gate_off); 45 irs_set(IRQ_TIMER_3, gate_off);
46 TIMER_DATA_1 = n_ticks; 46 TIMER_DATA_3 = n_ticks;
47 TIMER_CTRL_1 = TIMER_CTRL_IRQ | TIMER_CTRL_ENABLE | TIMER_CTRL_FREQ_3; 47 TIMER_CTRL_3 = TIMER_CTRL_IRQ | TIMER_CTRL_ENABLE | TIMER_CTRL_FREQ_3;
48 audio_sync_click = true;
48} 49}
49 50
50void 51void
@@ -183,9 +184,9 @@ set_time(int bpm) {
183 // We have to operate on integer values, so the numbers have been 184 // We have to operate on integer values, so the numbers have been
184 // precalculated to `n_ticks = 244181 / bmp` 185 // precalculated to `n_ticks = 244181 / bmp`
185 int n_ticks = -244181 / bpm; 186 int n_ticks = -244181 / bpm;
186 irs_set(IRQ_TIMER_0, play_step); 187 irs_set(IRQ_TIMER_2, play_step);
187 TIMER_DATA_0 = n_ticks; 188 TIMER_DATA_2 = n_ticks;
188 TIMER_CTRL_0 = TIMER_CTRL_IRQ | TIMER_CTRL_ENABLE | TIMER_CTRL_FREQ_3; 189 TIMER_CTRL_2 = TIMER_CTRL_IRQ | TIMER_CTRL_ENABLE | TIMER_CTRL_FREQ_3;
189} 190}
190 191
191TriggerNote * 192TriggerNote *
@@ -296,7 +297,7 @@ void
296stop_playing(void) { 297stop_playing(void) {
297 play_status = 0; 298 play_status = 0;
298 step_counter = 0; 299 step_counter = 0;
299 TIMER_CTRL_0 = 0; 300 TIMER_CTRL_2 = 0;
300 SOUND_SQUARE1_CTRL = 0; 301 SOUND_SQUARE1_CTRL = 0;
301 SOUND_SQUARE2_CTRL = 0; 302 SOUND_SQUARE2_CTRL = 0;
302 SOUND_WAVE_CTRL = 0; 303 SOUND_WAVE_CTRL = 0;
@@ -308,7 +309,7 @@ void
308toggle_playing(void) { 309toggle_playing(void) {
309 play_status ^= 1; 310 play_status ^= 1;
310 step_counter = 0; 311 step_counter = 0;
311 if ((TIMER_CTRL_0 & TIMER_CTRL_ENABLE) == 0) { 312 if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) {
312 if (current_pattern != next_pattern) { 313 if (current_pattern != next_pattern) {
313 current_pattern = next_pattern; 314 current_pattern = next_pattern;
314 redraw_pattern_buttons = true; 315 redraw_pattern_buttons = true;
@@ -316,7 +317,7 @@ toggle_playing(void) {
316 set_time(patterns[current_pattern].bpm); 317 set_time(patterns[current_pattern].bpm);
317 play_step(); 318 play_step();
318 } else { 319 } else {
319 TIMER_CTRL_0 ^= TIMER_CTRL_ENABLE; 320 TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE;
320 SOUND_SQUARE1_CTRL = 0; 321 SOUND_SQUARE1_CTRL = 0;
321 SOUND_SQUARE2_CTRL = 0; 322 SOUND_SQUARE2_CTRL = 0;
322 SOUND_WAVE_CTRL = 0; 323 SOUND_WAVE_CTRL = 0;
@@ -328,7 +329,7 @@ toggle_playing(void) {
328void 329void
329pause_playing(void) { 330pause_playing(void) {
330 play_status ^= 1; 331 play_status ^= 1;
331 if ((TIMER_CTRL_0 & TIMER_CTRL_ENABLE) == 0) { 332 if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) {
332 if (current_pattern != next_pattern && step_counter == 0) { 333 if (current_pattern != next_pattern && step_counter == 0) {
333 current_pattern = next_pattern; 334 current_pattern = next_pattern;
334 redraw_pattern_buttons = true; 335 redraw_pattern_buttons = true;
@@ -336,7 +337,7 @@ pause_playing(void) {
336 set_time(patterns[current_pattern].bpm); 337 set_time(patterns[current_pattern].bpm);
337 play_step(); 338 play_step();
338 } else { 339 } else {
339 TIMER_CTRL_0 ^= TIMER_CTRL_ENABLE; 340 TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE;
340 SOUND_SQUARE1_CTRL = 0; 341 SOUND_SQUARE1_CTRL = 0;
341 SOUND_SQUARE2_CTRL = 0; 342 SOUND_SQUARE2_CTRL = 0;
342 SOUND_WAVE_CTRL = 0; 343 SOUND_WAVE_CTRL = 0;
@@ -414,7 +415,7 @@ handle_right_col_selection(void) {
414 patterns[pattern_selection_loc].bpm + bpm_inc, 415 patterns[pattern_selection_loc].bpm + bpm_inc,
415 10, 416 10,
416 300); 417 300);
417 if ((TIMER_CTRL_0 & TIMER_CTRL_ENABLE) != 0 418 if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0
418 && current_pattern == pattern_selection_loc) { 419 && current_pattern == pattern_selection_loc) {
419 set_time(patterns[current_pattern].bpm); 420 set_time(patterns[current_pattern].bpm);
420 } 421 }
@@ -432,7 +433,7 @@ handle_right_col_selection(void) {
432 patterns[pattern_selection_loc].bpm + bpm_inc, 433 patterns[pattern_selection_loc].bpm + bpm_inc,
433 10, 434 10,
434 300); 435 300);
435 if ((TIMER_CTRL_0 & TIMER_CTRL_ENABLE) != 0 436 if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) != 0
436 && current_pattern == pattern_selection_loc) { 437 && current_pattern == pattern_selection_loc) {
437 set_time(patterns[current_pattern].bpm); 438 set_time(patterns[current_pattern].bpm);
438 } 439 }
@@ -1036,5 +1037,5 @@ sequencer_init(void) {
1036 | SOUND_SQUARE2 1037 | SOUND_SQUARE2
1037 | SOUND_WAVE 1038 | SOUND_WAVE
1038 | SOUND_NOISE, 3); 1039 | SOUND_NOISE, 3);
1039 SOUND_DSOUND_MASTER = SOUND_DMG100; 1040 init_dsound();
1040} 1041}