aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-01-04 15:36:09 +0100
committerBad Diode <bd@badd10de.dev>2024-01-04 15:36:09 +0100
commit024e372b9e271ea817353f7d07a810b99c62eb60 (patch)
tree8f545792ac2b6de4aed8467b7aed5d1f932aef9f
parent2d397003e2acbfd04019425bef00d0834191cd92 (diff)
downloadstepper-024e372b9e271ea817353f7d07a810b99c62eb60.tar.gz
stepper-024e372b9e271ea817353f7d07a810b99c62eb60.zip
Add initial Analogue MIDI sync functionality (needs options)
-rw-r--r--Makefile2
-rw-r--r--src/sequencer.c20
-rw-r--r--src/settings.c2
3 files changed, 20 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 960a8a6..3486200 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))
27INC_FLAGS += -I$(LIBGBA_SRC) 27INC_FLAGS += -I$(LIBGBA_SRC)
28 28
29# Output library names and executables. 29# Output library names and executables.
30TARGET := STEPPER-v1.8-dev-01 30TARGET := STEPPER-v1.8-dev-02
31ELF := $(BUILD_DIR)/$(TARGET).elf 31ELF := $(BUILD_DIR)/$(TARGET).elf
32BIN := $(BUILD_DIR)/$(TARGET).gba 32BIN := $(BUILD_DIR)/$(TARGET).gba
33 33
diff --git a/src/sequencer.c b/src/sequencer.c
index 11c0f5a..9dcaa89 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -346,9 +346,9 @@ play_step(void) {
346 step_counter = (step_counter + 1) % 16; 346 step_counter = (step_counter + 1) % 16;
347} 347}
348 348
349static nseq_ticks = 0;
350void 349void
351sequencer_tick(void) { 350sequencer_tick(void) {
351 static int nseq_ticks = 0;
352 if (nseq_ticks++ < 24) { 352 if (nseq_ticks++ < 24) {
353 return; 353 return;
354 } 354 }
@@ -1549,10 +1549,24 @@ handle_sequencer_input(void) {
1549 } 1549 }
1550} 1550}
1551 1551
1552static int in_ticks = 0;
1553
1554void
1555reset_serial_in(void) {
1556 in_ticks = 0;
1557}
1558
1552void 1559void
1553serial_irq() { 1560serial_irq(void) {
1554 if (play_status) { 1561 if (play_status) {
1555 play_step(); 1562 if (in_ticks++ == 0) {
1563 // TODO: Instead of play_step use the nseq_ticks instead!
1564 play_step();
1565 // MIDI: 24 / 8 = 3
1566 // set to 6 for half tempo
1567 } else if (in_ticks == 3) {
1568 in_ticks = 0;
1569 }
1556 } 1570 }
1557} 1571}
1558 1572
diff --git a/src/settings.c b/src/settings.c
index 374618c..7cebcf6 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -8,6 +8,7 @@ static Settings settings = {
8}; 8};
9static int settings_cursor_loc = 0; 9static int settings_cursor_loc = 0;
10 10
11void reset_serial_in(void);
11void serial_irq(void); 12void serial_irq(void);
12void stop_sound(void); 13void stop_sound(void);
13void toggle_playing(void); 14void toggle_playing(void);
@@ -16,6 +17,7 @@ void
16set_audio_settings(void) { 17set_audio_settings(void) {
17 stop_sound(); 18 stop_sound();
18 if (settings.sync == SYNC_IN_LINK) { 19 if (settings.sync == SYNC_IN_LINK) {
20 reset_serial_in();
19 irs_set(IRQ_SERIAL, serial_irq); 21 irs_set(IRQ_SERIAL, serial_irq);
20 irs_set(IRQ_TIMER_2, NULL); 22 irs_set(IRQ_TIMER_2, NULL);
21 SIO_MODE = SIO_MODE_GP 23 SIO_MODE = SIO_MODE_GP