aboutsummaryrefslogtreecommitdiffstats
path: root/src/globals.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-23 15:48:59 +0200
committerBad Diode <bd@badd10de.dev>2023-04-23 15:48:59 +0200
commitff6e784e7c5ebe223666c6c631305397ad358289 (patch)
tree0f87823d48366a6beb8d36d7eea5dc33663d7abd /src/globals.c
parentdeb9c48fbd3dc5854de4ae3a04dc999029c10ae0 (diff)
downloadstepper-ff6e784e7c5ebe223666c6c631305397ad358289.tar.gz
stepper-ff6e784e7c5ebe223666c6c631305397ad358289.zip
Start decoupling of rendering from update passes
Diffstat (limited to 'src/globals.c')
-rw-r--r--src/globals.c104
1 files changed, 104 insertions, 0 deletions
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 @@
1//
2// Globals.
3//
4
5static int step_counter = 0;
6int trig_selection_loc = 0;
7int param_selection_loc = 0;
8int channel_selection_loc = 0;
9int pattern_selection_loc = 0;
10int right_col_selection_loc = 0;
11int play_status = 0;
12static int current_pattern = 0;
13static int next_pattern = 0;
14static int current_bank = 0;
15
16//
17// Color indexes.
18//
19
20#define COL_BG 0
21#define COL_FG 1
22#define COL_RED 2
23#define COL_BLUE 3
24#define COL_CYAN 4
25#define COL_GREY 5
26
27// Theme colors.
28#define COL_CURSOR COL_BLUE
29#define COL_NOTE_PRESSED COL_GREY
30#define COL_WAVE_A COL_RED
31#define COL_WAVE_B COL_CYAN
32
33#define CHAN_W 19
34#define CHAN_H 8
35#define CHAN_START_X 29
36#define CHAN_START_Y 92
37#define CHAN_OFFSET_Y 12
38
39#define TRIG_W 15
40#define TRIG_H 24
41#define TRIG_START_X 58
42#define TRIG_START_Y 92
43#define TRIG_OFFSET_X (TRIG_W + 3)
44#define TRIG_OFFSET_Y (TRIG_H + 7)
45
46#define PIANO_W 170
47#define PIANO_H 20
48#define PIANO_START_X 29
49#define PIANO_START_Y 65
50#define PIANO_NOTE_W 2
51
52#define PARAMS_W 170
53#define PARAMS_H 64
54#define PARAMS_START_X 29
55#define PARAMS_START_Y 1
56
57#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 4)
58#define L_SIDEBAR_X ((CHAN_START_X) - 26)
59
60#define PAT_START_X (L_SIDEBAR_X + 5)
61#define PAT_START_Y 18
62#define PAT_W 14
63#define PAT_H 12
64#define PAT_OFFSET_Y 17
65
66#define R_COL_W 24
67#define BPM_START_X (R_SIDEBAR_X)
68#define BPM_START_Y (TRIG_START_Y + TRIG_H + 9)
69#define BPM_H 22
70
71#define PLAY_START_X (R_SIDEBAR_X)
72#define PLAY_START_Y (TRIG_START_Y)
73#define STOP_START_X (R_SIDEBAR_X)
74#define STOP_START_Y (TRIG_START_Y + 14)
75#define PLAY_STOP_H (10)
76
77#define BANK_START_X (R_SIDEBAR_X + 5)
78#define BANK_START_Y (PAT_START_Y)
79
80#define SEQ_N_CHANNELS 4
81
82enum RIGHT_COL_LOC {
83 R_COL_BPM = 0,
84 R_COL_STOP = 1,
85 R_COL_PLAY = 2,
86 R_COL_BANK_D = 3,
87 R_COL_BANK_C = 4,
88 R_COL_BANK_B = 5,
89 R_COL_BANK_A = 6,
90};
91
92// Input handling works using a FSM. The input handler is switched to whichever
93// function controls each section. For example, channel selection or trigger
94// selection.
95void (*input_handler)(void);
96
97void handle_trigger_selection(void);
98void handle_channel_selection(void);
99void handle_pattern_selection(void);
100void handle_param_selection_sq1(void);
101void handle_param_selection_sq2(void);
102void handle_param_selection_wave(void);
103void handle_param_selection_noise(void);
104void handle_right_col_selection(void);