diff --git a/src/cursor.cpp b/src/cursor.cpp index 3b56d99..f2f00c0 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -45,6 +45,7 @@ namespace cursor { float dy = static_cast(data.analog_coordinate_axis[3] - 0x80) * 0.015; state[port_ix].x += dx; state[port_ix].y += dy; + state[port_ix].a = ft0::data_transfer::digital_button::a(data.digital_button) == 0; state[port_ix].b = ft0::data_transfer::digital_button::b(data.digital_button) == 0; diff --git a/src/graphics.cpp b/src/graphics.cpp index bfc35fb..9f90720 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -126,14 +126,18 @@ void graphics_cursor(ta_multiwriter& multi) para_control::list_type::opaque, tsp_instruction_word::dst_alpha_instr::zero); - const cursor::cursor& c = cursor::state[0]; + for (int i = 0; i < 4; i++) { + const cursor::cursor& c = cursor::state[i]; + if (!c.active) + continue; - quad_type_0(multi.op, - {c.x - 1, c.y - 1, 10}, - {c.x + 1, c.y - 1, 10}, - {c.x + 1, c.y + 1, 10}, - {c.x - 1, c.y + 1, 10}, - 0xffffff); + quad_type_0(multi.op, + {c.x - 1, c.y - 1, 10}, + {c.x + 1, c.y - 1, 10}, + {c.x + 1, c.y + 1, 10}, + {c.x - 1, c.y + 1, 10}, + 0xffffff); + } } void graphics_event(ta_multiwriter& multi) diff --git a/src/interpreter.cpp b/src/interpreter.cpp index a7c4022..defcc86 100644 --- a/src/interpreter.cpp +++ b/src/interpreter.cpp @@ -208,6 +208,9 @@ void execute_line(int line_index) void interrupt() { + if (state.paused) + return; + state.interrupt_clock += 1; // execute keyons for (int ch = 0; ch < 64; ch++) { @@ -298,4 +301,20 @@ void init(float clock_multiplier) printf("tick_rate %d\n", state.tick_rate); } +void pause() +{ + state.tmp_paused = state.paused; + state.paused = true; +} + +void unpause() +{ + state.paused = false; +} + +void resume() +{ + state.paused = state.tmp_paused; +} + } diff --git a/src/interpreter.hpp b/src/interpreter.hpp index d716c0d..0465282 100644 --- a/src/interpreter.hpp +++ b/src/interpreter.hpp @@ -21,6 +21,8 @@ struct interpreter_state { int pattern_index; int line_index; int next_line_index; // within the current pattern + bool paused; + bool tmp_paused; struct xm_state xm; @@ -30,5 +32,7 @@ struct interpreter_state { extern struct interpreter_state state; void interrupt(); void init(float clock_multiplier); +void pause(); +void unpause(); } diff --git a/src/main.cpp b/src/main.cpp index ab01360..a0cb425 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,9 +9,6 @@ #include "cursor.hpp" #include "input.hpp" -#include "xm/milkypack01.xm.h" -#include "xm.h" - void vbr100() { serial::string("vbr100\n"); @@ -59,24 +56,6 @@ void vbr600() asm volatile ("ldc %0,sr" : : "r" (sr)); } -void load_xm(float clock_multiplier) -{ - using namespace interpreter; - - int buf = (int)&_binary_xm_milkypack01_xm_start; - - static uint8_t __attribute__((aligned(32))) sample_data[1024 * 1024 * 2]; - const int sample_data_length = (sizeof (sample_data)); - - int sample_data_ix = xm_init(&state.xm, - buf, - sample_data, - sample_data_length); - interpreter::init(clock_multiplier); - sound::transfer(sample_data, sample_data_ix); - printf("tick_rate %d\n", state.tick_rate); -} - #include "memorymap.hpp" #include "holly/texture_memory_alloc9.hpp" #include "holly/holly.hpp" @@ -119,9 +98,6 @@ void main() input::state_init(); cursor::init(); - const float aica_clock_multiplier = 44.1; - load_xm(aica_clock_multiplier); - //test_pattern(); interrupt_init(); diff --git a/src/playlist.cpp b/src/playlist.cpp new file mode 100644 index 0000000..e078123 --- /dev/null +++ b/src/playlist.cpp @@ -0,0 +1,34 @@ +#include "xm.h" +#include "xm/milkypack01.xm.h" + +const float aica_clock_multiplier = 44.1; + +namespace playlist { + + static playlist_item playlist[] = { + { + "milkypack01" + } + }; + + + void load_xm(float clock_multiplier, int buf) + { + using namespace interpreter; + + static uint8_t __attribute__((aligned(32))) sample_data[1024 * 1024 * 2]; + const int sample_data_length = (sizeof (sample_data)); + + interpreter::pause(); + + int sample_data_ix = xm_init(&state.xm, + buf, + sample_data, + sample_data_length); + interpreter::init(clock_multiplier); + sound::transfer(sample_data, sample_data_ix); + //printf("tick_rate %d\n", state.tick_rate); + + interpreter::resume(); + } +} diff --git a/src/playlist.hpp b/src/playlist.hpp new file mode 100644 index 0000000..6c304aa --- /dev/null +++ b/src/playlist.hpp @@ -0,0 +1,6 @@ +namespace playlist { + struct playlist_item { + const char * const name; + const int start; + }; +}