From ff6e784e7c5ebe223666c6c631305397ad358289 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 23 Apr 2023 15:48:59 +0200 Subject: Start decoupling of rendering from update passes --- src/globals.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/globals.c (limited to 'src/globals.c') diff --git a/src/globals.c b/src/globals.c new file mode 100644 index 0000000..bf0c5b6 --- /dev/null +++ b/src/globals.c @@ -0,0 +1,104 @@ +// +// Globals. +// + +static int step_counter = 0; +int trig_selection_loc = 0; +int param_selection_loc = 0; +int channel_selection_loc = 0; +int pattern_selection_loc = 0; +int right_col_selection_loc = 0; +int play_status = 0; +static int current_pattern = 0; +static int next_pattern = 0; +static int current_bank = 0; + +// +// Color indexes. +// + +#define COL_BG 0 +#define COL_FG 1 +#define COL_RED 2 +#define COL_BLUE 3 +#define COL_CYAN 4 +#define COL_GREY 5 + +// Theme colors. +#define COL_CURSOR COL_BLUE +#define COL_NOTE_PRESSED COL_GREY +#define COL_WAVE_A COL_RED +#define COL_WAVE_B COL_CYAN + +#define CHAN_W 19 +#define CHAN_H 8 +#define CHAN_START_X 29 +#define CHAN_START_Y 92 +#define CHAN_OFFSET_Y 12 + +#define TRIG_W 15 +#define TRIG_H 24 +#define TRIG_START_X 58 +#define TRIG_START_Y 92 +#define TRIG_OFFSET_X (TRIG_W + 3) +#define TRIG_OFFSET_Y (TRIG_H + 7) + +#define PIANO_W 170 +#define PIANO_H 20 +#define PIANO_START_X 29 +#define PIANO_START_Y 65 +#define PIANO_NOTE_W 2 + +#define PARAMS_W 170 +#define PARAMS_H 64 +#define PARAMS_START_X 29 +#define PARAMS_START_Y 1 + +#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 4) +#define L_SIDEBAR_X ((CHAN_START_X) - 26) + +#define PAT_START_X (L_SIDEBAR_X + 5) +#define PAT_START_Y 18 +#define PAT_W 14 +#define PAT_H 12 +#define PAT_OFFSET_Y 17 + +#define R_COL_W 24 +#define BPM_START_X (R_SIDEBAR_X) +#define BPM_START_Y (TRIG_START_Y + TRIG_H + 9) +#define BPM_H 22 + +#define PLAY_START_X (R_SIDEBAR_X) +#define PLAY_START_Y (TRIG_START_Y) +#define STOP_START_X (R_SIDEBAR_X) +#define STOP_START_Y (TRIG_START_Y + 14) +#define PLAY_STOP_H (10) + +#define BANK_START_X (R_SIDEBAR_X + 5) +#define BANK_START_Y (PAT_START_Y) + +#define SEQ_N_CHANNELS 4 + +enum RIGHT_COL_LOC { + R_COL_BPM = 0, + R_COL_STOP = 1, + R_COL_PLAY = 2, + R_COL_BANK_D = 3, + R_COL_BANK_C = 4, + R_COL_BANK_B = 5, + R_COL_BANK_A = 6, +}; + +// Input handling works using a FSM. The input handler is switched to whichever +// function controls each section. For example, channel selection or trigger +// selection. +void (*input_handler)(void); + +void handle_trigger_selection(void); +void handle_channel_selection(void); +void handle_pattern_selection(void); +void handle_param_selection_sq1(void); +void handle_param_selection_sq2(void); +void handle_param_selection_wave(void); +void handle_param_selection_noise(void); +void handle_right_col_selection(void); -- cgit v1.2.1