aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-08-10 21:43:12 +0200
committerBad Diode <bd@badd10de.dev>2023-08-10 21:43:12 +0200
commitc888455af3ea5b9e8d2087a57df104c14ffac09e (patch)
tree98a38361e940f6b5b12153025b8346a5195f3ef7
parentbb4af22481a27d9324f5377b7024e3592d4227ff (diff)
downloadstepper-c888455af3ea5b9e8d2087a57df104c14ffac09e.tar.gz
stepper-c888455af3ea5b9e8d2087a57df104c14ffac09e.zip
Add two more banks and channel icons
-rw-r--r--src/assets.c22
-rw-r--r--src/drawing.c143
-rw-r--r--src/globals.c4
-rw-r--r--src/main.c2
-rw-r--r--src/save.c4
-rw-r--r--src/sequencer.c2
6 files changed, 91 insertions, 86 deletions
diff --git a/src/assets.c b/src/assets.c
index 661d012..94c9de2 100644
--- a/src/assets.c
+++ b/src/assets.c
@@ -81,28 +81,6 @@ static const u32 note_name_sprites[] = {
81 0xe0000000, 0xe0202020, 0x0e000000, 0x0e0a0e0a, 81 0xe0000000, 0xe0202020, 0x0e000000, 0x0e0a0e0a,
82}; 82};
83 83
84static const u32 ch_btn_sprite[] = {
85 // CH1
86 0x888e80ff, 0xff808e88,
87 0xa1a100ff, 0xff00a9e1,
88 0x101010f0, 0xf0101010,
89
90 // CH2
91 0x919d80ff, 0xff809d91,
92 0x424200ff, 0xff0052c2,
93 0x909010f0, 0xf0109090,
94
95 // CH3
96 0xa2ba80ff, 0xff80baa3,
97 0x858500ff, 0xff00a585,
98 0x505010f0, 0xf0105050,
99
100 // CH4
101 0xa2ba80ff, 0xff80baa3,
102 0x858500ff, 0xff00a485,
103 0x505010f0, 0xf010d050,
104};
105
106// 84//
107// Wave data. 85// Wave data.
108// 86//
diff --git a/src/drawing.c b/src/drawing.c
index c07b46d..dd77803 100644
--- a/src/drawing.c
+++ b/src/drawing.c
@@ -26,9 +26,43 @@ draw_param_stub(size_t idx, u8 color) {
26 26
27void 27void
28draw_channel_sprite(size_t x, size_t y, u8 clr, u8 idx) { 28draw_channel_sprite(size_t x, size_t y, u8 clr, u8 idx) {
29 draw_icn(x, y, &ch_btn_sprite[0 + 6 * idx], clr, 0, 0); 29 draw_rect(x, y, x + CHAN_W, y + CHAN_H - 1, clr);
30 draw_icn(x + 8, y, &ch_btn_sprite[2 + 6 * idx], clr, 0, 0); 30
31 draw_icn(x + 16, y, &ch_btn_sprite[4 + 6 * idx], clr, 0, 0); 31 switch (idx) {
32 case 0: {
33 draw_line(x + 2, y + 5, x + 6, y + 5, clr);
34 draw_line(x + 6, y + 2, x + 6, y + 5, clr);
35 draw_line(x + 7, y + 2, x + 12, y + 2, clr);
36 draw_line(x + 12, y + 2, x + 12, y + 5, clr);
37 draw_line(x + 12, y + 5, x + 16, y + 5, clr);
38 } break;
39 case 1: {
40 draw_line(x + 2, y + 5, x + 4, y + 5, clr);
41 draw_line(x + 4, y + 2, x + 4, y + 5, clr);
42 draw_line(x + 4, y + 2, x + 7, y + 2, clr);
43 draw_line(x + 7, y + 2, x + 7, y + 5, clr);
44 draw_line(x + 7, y + 5, x + 11, y + 5, clr);
45 draw_line(x + 11, y + 2, x + 11, y + 5, clr);
46 draw_line(x + 11, y + 2, x + 14, y + 2, clr);
47 draw_line(x + 14, y + 2, x + 14, y + 5, clr);
48 draw_line(x + 14, y + 5, x + 16, y + 5, clr);
49 } break;
50 case 2: {
51 draw_line(x + 2, y + 5, x + 5, y + 2, clr);
52 draw_line(x + 6, y + 2, x + 6, y + 5, clr);
53 draw_line(x + 7, y + 5, x + 10, y + 2, clr);
54 draw_line(x + 11, y + 2, x + 11, y + 5, clr);
55 draw_line(x + 12, y + 5, x + 15, y + 2, clr);
56 draw_line(x + 16, y + 2, x + 16, y + 5, clr);
57 } break;
58 case 3: {
59 u8 y_off[] = { 5, 2, 4, 2, 3, 4, 5, 2, 4, 3, 5, 3, 2, 4, 5 };
60 for (size_t i = 0; i < 15; i++) {
61 draw_pixel(x + 2 + i, y + y_off[i], clr);
62 }
63 } break;
64 default: break;
65 }
32} 66}
33 67
34void 68void
@@ -52,20 +86,21 @@ draw_channels(void) {
52} 86}
53 87
54void 88void
55draw_channel_cursor(size_t i, u8 clr) { 89draw_channel_cursor(size_t i, u8 clr, bool dither) {
56 size_t offset_x = 0; 90 size_t offset_x = 0;
57 size_t offset_y = CHAN_H + i * CHAN_OFFSET_Y + 1; 91 size_t offset_y = CHAN_H + i * CHAN_OFFSET_Y + 1;
58 size_t x0 = CHAN_START_X + offset_x; 92 size_t x0 = CHAN_START_X + offset_x;
59 size_t x1 = CHAN_START_X + offset_x + CHAN_W; 93 size_t x1 = CHAN_START_X + offset_x + CHAN_W;
60 size_t y = CHAN_START_Y + offset_y; 94 size_t y = CHAN_START_Y + offset_y;
61 switch (settings.cursor) { 95 if (dither) {
62 case CURSOR_THICK_LINE: { 96 for (size_t i = 0; i < CHAN_W - 1; i += 2) {
63 draw_line(x0, y, x1, y, clr); 97 draw_pixel(x0 + i, y, clr);
64 draw_line(x0, y + 1, x1, y + 1, clr); 98 draw_pixel(x0 + i + 1, y + 1, clr);
65 } break; 99 }
66 default: { 100 draw_pixel(x0 + CHAN_W, y, clr);
67 draw_line(x0, y, x1, y, clr); 101 } else {
68 } break; 102 draw_line(x0, y, x1, y, clr);
103 draw_line(x0, y + 1, x1, y + 1, clr);
69 } 104 }
70} 105}
71 106
@@ -77,7 +112,7 @@ void
77clear_trigger(size_t i) { 112clear_trigger(size_t i) {
78 size_t offset_x = TRIG_OFFSET_X * (i % 8); 113 size_t offset_x = TRIG_OFFSET_X * (i % 8);
79 size_t offset_y = i < 8 ? 0 : TRIG_OFFSET_Y; 114 size_t offset_y = i < 8 ? 0 : TRIG_OFFSET_Y;
80 size_t x0 = TRIG_START_X + offset_x + 1; 115 size_t x0 = TRIG_START_X + offset_x + 2;
81 size_t x1 = TRIG_START_X + offset_x + TRIG_W - 1; 116 size_t x1 = TRIG_START_X + offset_x + TRIG_W - 1;
82 size_t y0 = TRIG_START_Y + offset_y + 1; 117 size_t y0 = TRIG_START_Y + offset_y + 1;
83 size_t y1 = TRIG_START_Y + offset_y + TRIG_H - 4; 118 size_t y1 = TRIG_START_Y + offset_y + TRIG_H - 4;
@@ -107,20 +142,21 @@ draw_trigger(size_t chan, size_t i) {
107} 142}
108 143
109void 144void
110draw_trig_cursor(size_t i, u8 clr) { 145draw_trig_cursor(size_t i, u8 clr, bool dither) {
111 size_t offset_x = TRIG_OFFSET_X * (i % 8); 146 size_t offset_x = TRIG_OFFSET_X * (i % 8);
112 size_t offset_y = i < 8 ? 2 : 2 + TRIG_OFFSET_Y; 147 size_t offset_y = i < 8 ? 2 : 2 + TRIG_OFFSET_Y;
113 size_t x0 = TRIG_START_X + offset_x; 148 size_t x0 = TRIG_START_X + offset_x + 1;
114 size_t x1 = TRIG_START_X + TRIG_W + offset_x; 149 size_t x1 = TRIG_START_X + TRIG_W + offset_x;
115 size_t y = TRIG_START_Y + TRIG_H + offset_y; 150 size_t y = TRIG_START_Y + TRIG_H + offset_y;
116 switch (settings.cursor) { 151 if (dither) {
117 case CURSOR_THICK_LINE: { 152 for (size_t i = 0; i < TRIG_W - 1; i += 2) {
118 draw_line(x0, y, x1, y, clr); 153 draw_pixel(x0 + i, y, clr);
119 draw_line(x0, y + 1, x1, y + 1, clr); 154 draw_pixel(x0 + i + 1, y + 1, clr);
120 } break; 155 }
121 default: { 156 draw_pixel(x0 + TRIG_W - 1, y, clr);
122 draw_line(x0, y, x1, y, clr); 157 } else {
123 } break; 158 draw_line(x0, y, x1, y, clr);
159 draw_line(x0, y + 1, x1, y + 1, clr);
124 } 160 }
125} 161}
126 162
@@ -173,20 +209,15 @@ draw_right_col_cursor(int i, u8 clr) {
173 y = BANK_START_Y + PAT_H + 2 + 3 * PAT_OFFSET_Y; 209 y = BANK_START_Y + PAT_H + 2 + 3 * PAT_OFFSET_Y;
174 } break; 210 } break;
175 } 211 }
176 switch (settings.cursor) { 212 draw_line(x0, y, x1, y, clr);
177 case CURSOR_THICK_LINE: { 213 draw_line(x0, y + 1, x1, y + 1, clr);
178 draw_line(x0, y, x1, y, clr);
179 draw_line(x0, y + 1, x1, y + 1, clr);
180 } break;
181 default: { draw_line(x0, y, x1, y, clr); } break;
182 }
183} 214}
184 215
185void 216void
186draw_current_step(u8 step, u8 clr) { 217draw_current_step(u8 step, u8 clr) {
187 size_t offset_x = TRIG_OFFSET_X * (step % 8); 218 size_t offset_x = TRIG_OFFSET_X * (step % 8);
188 size_t offset_y = step < 8 ? 2 : 2 + TRIG_OFFSET_Y; 219 size_t offset_y = step < 8 ? 2 : 2 + TRIG_OFFSET_Y;
189 size_t x0 = TRIG_START_X + 3 + offset_x; 220 size_t x0 = TRIG_START_X + 4 + offset_x;
190 size_t x1 = TRIG_START_X - 3 + TRIG_W + offset_x; 221 size_t x1 = TRIG_START_X - 3 + TRIG_W + offset_x;
191 size_t y = TRIG_START_Y - 5 + TRIG_H + offset_y; 222 size_t y = TRIG_START_Y - 5 + TRIG_H + offset_y;
192 draw_line(x0, y, x1, y, clr); 223 draw_line(x0, y, x1, y, clr);
@@ -248,20 +279,21 @@ draw_pattern_buttons() {
248} 279}
249 280
250void 281void
251draw_pattern_cursor(size_t i, u8 clr) { 282draw_pattern_cursor(size_t i, u8 clr, bool dither) {
252 size_t offset_x = 0; 283 size_t offset_x = 0;
253 size_t offset_y = PAT_H + i * PAT_OFFSET_Y + 2; 284 size_t offset_y = PAT_H + i * PAT_OFFSET_Y + 2;
254 size_t x0 = PAT_START_X + offset_x; 285 size_t x0 = PAT_START_X + offset_x;
255 size_t x1 = PAT_START_X + offset_x + PAT_W; 286 size_t x1 = PAT_START_X + offset_x + PAT_W;
256 size_t y = PAT_START_Y + offset_y; 287 size_t y = PAT_START_Y + offset_y;
257 switch (settings.cursor) { 288 if (dither) {
258 case CURSOR_THICK_LINE: { 289 for (size_t i = 0; i < PAT_W; i += 2) {
259 draw_line(x0, y, x1, y, clr); 290 draw_pixel(x0 + i, y, clr);
260 draw_line(x0, y + 1, x1, y + 1, clr); 291 draw_pixel(x0 + i + 1, y + 1, clr);
261 } break; 292 }
262 default: { 293 draw_pixel(x0 + PAT_W, y, clr);
263 draw_line(x0, y, x1, y, clr); 294 } else {
264 } break; 295 draw_line(x0, y, x1, y, clr);
296 draw_line(x0, y + 1, x1, y + 1, clr);
265 } 297 }
266} 298}
267 299
@@ -344,7 +376,7 @@ draw_triggers(void) {
344 for (size_t i = 0; i < 16; i++) { 376 for (size_t i = 0; i < 16; i++) {
345 size_t offset_x = TRIG_OFFSET_X * (i % 8); 377 size_t offset_x = TRIG_OFFSET_X * (i % 8);
346 size_t offset_y = i < 8 ? 0 : 0 + TRIG_OFFSET_Y; 378 size_t offset_y = i < 8 ? 0 : 0 + TRIG_OFFSET_Y;
347 size_t x0 = TRIG_START_X + offset_x; 379 size_t x0 = TRIG_START_X + offset_x + 1;
348 size_t x1 = TRIG_START_X + offset_x + TRIG_W; 380 size_t x1 = TRIG_START_X + offset_x + TRIG_W;
349 size_t y0 = TRIG_START_Y + offset_y; 381 size_t y0 = TRIG_START_Y + offset_y;
350 size_t y1 = TRIG_START_Y + offset_y + TRIG_H; 382 size_t y1 = TRIG_START_Y + offset_y + TRIG_H;
@@ -1135,9 +1167,9 @@ draw_parameters(void) {
1135 1167
1136void 1168void
1137clear_cursors(void) { 1169clear_cursors(void) {
1138 draw_trig_cursor(last_trig_loc, COL_BG); 1170 draw_trig_cursor(last_trig_loc, COL_BG, false);
1139 draw_channel_cursor(last_channel_loc, COL_BG); 1171 draw_channel_cursor(last_channel_loc, COL_BG, false);
1140 draw_pattern_cursor(last_pattern_loc, COL_BG); 1172 draw_pattern_cursor(last_pattern_loc, COL_BG, false);
1141 draw_right_col_cursor(last_right_col_loc, COL_BG); 1173 draw_right_col_cursor(last_right_col_loc, COL_BG);
1142 for (size_t i = 0; i < 16; i++) { 1174 for (size_t i = 0; i < 16; i++) {
1143 draw_current_step(i, COL_OFF); 1175 draw_current_step(i, COL_OFF);
@@ -1151,15 +1183,8 @@ draw_pattern_chain_cursor(void) {
1151 size_t x0 = PAT_TRIG_START_X + offset_x; 1183 size_t x0 = PAT_TRIG_START_X + offset_x;
1152 size_t x1 = PAT_TRIG_START_X + offset_x + PAT_TRIG_W; 1184 size_t x1 = PAT_TRIG_START_X + offset_x + PAT_TRIG_W;
1153 size_t y = PAT_TRIG_START_Y + offset_y + PAT_TRIG_H + 2; 1185 size_t y = PAT_TRIG_START_Y + offset_y + PAT_TRIG_H + 2;
1154 switch (settings.cursor) { 1186 draw_line(x0, y, x1, y, COL_ACC_0);
1155 case CURSOR_THICK_LINE: { 1187 draw_line(x0, y + 1, x1, y + 1, COL_ACC_0);
1156 draw_line(x0, y, x1, y, COL_ACC_0);
1157 draw_line(x0, y + 1, x1, y + 1, COL_ACC_0);
1158 } break;
1159 default: {
1160 draw_line(x0, y, x1, y, COL_ACC_0);
1161 } break;
1162 }
1163} 1188}
1164 1189
1165void 1190void
@@ -1167,17 +1192,17 @@ draw_cursors(void) {
1167 clear_cursors(); 1192 clear_cursors();
1168 draw_current_step(step_counter, COL_ACC_1); 1193 draw_current_step(step_counter, COL_ACC_1);
1169 if (input_handler == handle_trigger_selection) { 1194 if (input_handler == handle_trigger_selection) {
1170 draw_trig_cursor(trig_selection_loc, COL_ACC_0); 1195 draw_trig_cursor(trig_selection_loc, COL_ACC_0, false);
1171 } 1196 }
1172 if (input_handler == handle_channel_selection) { 1197 if (input_handler == handle_channel_selection) {
1173 draw_channel_cursor(channel_selection_loc, COL_ACC_0); 1198 draw_channel_cursor(channel_selection_loc, COL_ACC_0, false);
1174 } else { 1199 } else {
1175 draw_channel_cursor(channel_selection_loc, COL_OFF); 1200 draw_channel_cursor(channel_selection_loc, COL_ACC_0, true);
1176 } 1201 }
1177 if (input_handler == handle_pattern_selection) { 1202 if (input_handler == handle_pattern_selection) {
1178 draw_pattern_cursor(pattern_selection_loc, COL_ACC_0); 1203 draw_pattern_cursor(pattern_selection_loc, COL_ACC_0, false);
1179 } else { 1204 } else {
1180 draw_pattern_cursor(pattern_selection_loc, COL_OFF); 1205 draw_pattern_cursor(pattern_selection_loc, COL_ACC_0, true);
1181 } 1206 }
1182 if (input_handler == handle_right_col_selection) { 1207 if (input_handler == handle_right_col_selection) {
1183 draw_right_col_cursor(right_col_selection_loc, COL_ACC_0); 1208 draw_right_col_cursor(right_col_selection_loc, COL_ACC_0);
@@ -1187,7 +1212,7 @@ draw_cursors(void) {
1187 input_handler == handle_param_selection_wave || 1212 input_handler == handle_param_selection_wave ||
1188 input_handler == handle_param_selection_noise) { 1213 input_handler == handle_param_selection_noise) {
1189 draw_params_cursor(param_selection_loc, COL_ACC_0); 1214 draw_params_cursor(param_selection_loc, COL_ACC_0);
1190 draw_trig_cursor(trig_selection_loc, COL_OFF); 1215 draw_trig_cursor(trig_selection_loc, COL_ACC_0, true);
1191 } 1216 }
1192 if (input_handler == handle_param_selection_ch1 || 1217 if (input_handler == handle_param_selection_ch1 ||
1193 input_handler == handle_param_selection_ch2 || 1218 input_handler == handle_param_selection_ch2 ||
diff --git a/src/globals.c b/src/globals.c
index 842b39f..e4d1f13 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -30,7 +30,7 @@ bool clear_screen = true;
30#define COL_ACC_2 4 30#define COL_ACC_2 4
31#define COL_OFF 5 31#define COL_OFF 5
32 32
33#define CHAN_W 19 33#define CHAN_W 18
34#define CHAN_H 8 34#define CHAN_H 8
35#define CHAN_START_X 28 35#define CHAN_START_X 28
36#define CHAN_START_Y 100 36#define CHAN_START_Y 100
@@ -97,7 +97,7 @@ bool clear_screen = true;
97 97
98#define PAT_TRIG_W 14 98#define PAT_TRIG_W 14
99#define PAT_TRIG_H 14 99#define PAT_TRIG_H 14
100#define PAT_TRIG_START_X 35 100#define PAT_TRIG_START_X 32
101#define PAT_TRIG_START_Y 30 101#define PAT_TRIG_START_Y 30
102#define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7) 102#define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7)
103#define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8) 103#define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8)
diff --git a/src/main.c b/src/main.c
index 76a54b6..6992ac2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -145,7 +145,7 @@ render(void) {
145 } break; 145 } break;
146 } 146 }
147 // DEBUG: Ensuring the saved data don't exceed SRAM size (32k). 147 // DEBUG: Ensuring the saved data don't exceed SRAM size (32k).
148 txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 6 + sizeof(chain) * 6); 148 // txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 6 + sizeof(chain) * 6);
149} 149}
150 150
151void 151void
diff --git a/src/save.c b/src/save.c
index 8c26557..0e99086 100644
--- a/src/save.c
+++ b/src/save.c
@@ -23,13 +23,13 @@ sram_write(u8 *src, u16 pos, u16 n_bytes) {
23void 23void
24save_bank(int i) { 24save_bank(int i) {
25 sram_write(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns)); 25 sram_write(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns));
26 sram_write(&chain, sizeof(Metadata) + 4 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); 26 sram_write(&chain, sizeof(Metadata) + 6 * sizeof(patterns) + i * sizeof(chain), sizeof(chain));
27} 27}
28 28
29void 29void
30load_bank(int i) { 30load_bank(int i) {
31 sram_read(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns)); 31 sram_read(&patterns, sizeof(Metadata) + i * sizeof(patterns), sizeof(patterns));
32 sram_read(&chain, sizeof(Metadata) + 4 * sizeof(patterns) + i * sizeof(chain), sizeof(chain)); 32 sram_read(&chain, sizeof(Metadata) + 6 * sizeof(patterns) + i * sizeof(chain), sizeof(chain));
33} 33}
34 34
35void 35void
diff --git a/src/sequencer.c b/src/sequencer.c
index 18c9b20..b3b27c6 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -1333,6 +1333,8 @@ sequencer_init(void) {
1333 save_bank(1); 1333 save_bank(1);
1334 save_bank(2); 1334 save_bank(2);
1335 save_bank(3); 1335 save_bank(3);
1336 save_bank(4);
1337 save_bank(5);
1336 } else { 1338 } else {
1337 current_bank = metadata.current_bank; 1339 current_bank = metadata.current_bank;
1338 current_pattern = metadata.current_pattern; 1340 current_pattern = metadata.current_pattern;