aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-07-21 13:13:10 +0200
committerBad Diode <bd@badd10de.dev>2023-07-21 13:13:10 +0200
commit53729509f4f39690f025902df07bc38fc898ec65 (patch)
tree2d1093795b809d57c65d522bfb1e4c8e4a358824
parent1f7b89b12e39a57ab7ac16cc4eeb61740d0c14a9 (diff)
downloadstepper-53729509f4f39690f025902df07bc38fc898ec65.tar.gz
stepper-53729509f4f39690f025902df07bc38fc898ec65.zip
Prepare for parameter UI rework
-rw-r--r--Makefile2
-rw-r--r--src/drawing.c161
-rw-r--r--src/globals.c26
3 files changed, 101 insertions, 88 deletions
diff --git a/Makefile b/Makefile
index c131c5c..dd719cb 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.5 30TARGET := STEPPER-v1.6-dev
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/drawing.c b/src/drawing.c
index b7d5421..c596995 100644
--- a/src/drawing.c
+++ b/src/drawing.c
@@ -316,6 +316,9 @@ draw_note(u8 note, u8 clr) {
316 size_t octave = note / 12; 316 size_t octave = note / 12;
317 size_t value = note % 12; 317 size_t value = note % 12;
318 318
319 size_t base_x = PIANO_START_X + 2;
320 size_t base_y0 = PIANO_START_Y + 2;
321 size_t base_y1 = PIANO_START_Y - 2;
319 size_t x0 = 0; 322 size_t x0 = 0;
320 size_t y0 = 0; 323 size_t y0 = 0;
321 size_t x1 = 0; 324 size_t x1 = 0;
@@ -323,99 +326,101 @@ draw_note(u8 note, u8 clr) {
323 switch (value) { 326 switch (value) {
324 // White notes. 327 // White notes.
325 case 0:{ 328 case 0:{
326 x0 = PIANO_START_X + 2 + octave * 28; 329 x0 = base_x + octave * 28;
327 x1 = x0 + 1; 330 x1 = x0 + 1;
328 y0 = PIANO_START_Y + 2; 331 y0 = base_y0;
329 y1 = PIANO_START_Y - 2 + PIANO_H; 332 y1 = base_y1 + PIANO_H;
330 draw_filled_rect(x0, y0, x1, y1, clr); 333 draw_filled_rect(x0, y0, x1, y1, clr);
331 x0 = PIANO_START_X + 2 + octave * 28 + 2; 334 x0 = base_x + octave * 28 + 2;
332 x1 = x0; 335 x1 = x0;
333 y0 = y0 + 9; 336 y0 = base_y1 + PIANO_BLACK_H;
337 y1 = y0 + PIANO_H - PIANO_BLACK_H;
334 draw_filled_rect(x0, y0, x1, y1, clr); 338 draw_filled_rect(x0, y0, x1, y1, clr);
335 } break; 339 } break;
336 case 2:{ 340 case 2:{
337 x0 = PIANO_START_X + 2 + octave * 28 + 5; 341 x0 = base_x + octave * 28 + 5;
338 x1 = x0; 342 x1 = x0;
339 y0 = PIANO_START_Y + 2; 343 y0 = base_y0;
340 y1 = PIANO_START_Y - 2 + 12; 344 y1 = base_y1 + PIANO_BLACK_H;
341 draw_filled_rect(x0, y0, x1, y1, clr); 345 draw_filled_rect(x0, y0, x1, y1, clr);
342 x0 = PIANO_START_X + 2 + octave * 28 + 4; 346 x0 = base_x + octave * 28 + 4;
343 x1 = x0 + 2; 347 x1 = x0 + 2;
344 y0 = PIANO_START_Y - 2 + 13; 348 y0 = base_y1 + PIANO_BLACK_H;
345 y1 = y0 + 2; 349 y1 = y0 + PIANO_H - PIANO_BLACK_H;
346 draw_filled_rect(x0, y0, x1, y1, clr); 350 draw_filled_rect(x0, y0, x1, y1, clr);
347 } break; 351 } break;
348 case 4:{ 352 case 4:{
349 x0 = PIANO_START_X + 2 + octave * 28 + 9; 353 x0 = base_x + octave * 28 + 9;
350 x1 = x0 + 1; 354 x1 = x0 + 1;
351 y0 = PIANO_START_Y + 2; 355 y0 = base_y0;
352 y1 = PIANO_START_Y - 2 + 12; 356 y1 = base_y1 + PIANO_H;
353 draw_filled_rect(x0, y0, x1, y1, clr); 357 draw_filled_rect(x0, y0, x1, y1, clr);
354 x0 = PIANO_START_X + 2 + octave * 28 + 8; 358 x0 = base_x + octave * 28 + 8;
355 x1 = x0 + 2; 359 x1 = x0 + 2;
356 y0 = PIANO_START_Y - 2 + 13; 360 y0 = base_y1 + PIANO_BLACK_H;
357 y1 = y0 + 2; 361 y1 = y0 + PIANO_H - PIANO_BLACK_H;
358 draw_filled_rect(x0, y0, x1, y1, clr); 362 draw_filled_rect(x0, y0, x1, y1, clr);
359 } break; 363 } break;
360 case 5:{ 364 case 5:{
361 x0 = PIANO_START_X + 2 + octave * 28 + 12; 365 x0 = base_x + octave * 28 + 12;
362 x1 = x0 + 1; 366 x1 = x0 + 1;
363 y0 = PIANO_START_Y + 2; 367 y0 = base_y0;
364 y1 = PIANO_START_Y - 2 + PIANO_H; 368 y1 = base_y1 + PIANO_H;
365 draw_filled_rect(x0, y0, x1, y1, clr); 369 draw_filled_rect(x0, y0, x1, y1, clr);
366 x0 = PIANO_START_X + 2 + octave * 28 + 14; 370 x0 = base_x + octave * 28 + 14;
367 x1 = x0; 371 x1 = x0;
368 y0 = y0 + 9; 372 y0 = base_y1 + PIANO_BLACK_H;
373 y1 = y0 + PIANO_H - PIANO_BLACK_H;
369 draw_filled_rect(x0, y0, x1, y1, clr); 374 draw_filled_rect(x0, y0, x1, y1, clr);
370 } break; 375 } break;
371 case 7:{ 376 case 7:{
372 x0 = PIANO_START_X + 2 + octave * 28 + 17; 377 x0 = base_x + octave * 28 + 17;
373 x1 = x0; 378 x1 = x0;
374 y0 = PIANO_START_Y + 2; 379 y0 = base_y0;
375 y1 = PIANO_START_Y - 2 + 12; 380 y1 = base_y1 + PIANO_H;
376 draw_filled_rect(x0, y0, x1, y1, clr); 381 draw_filled_rect(x0, y0, x1, y1, clr);
377 x0 = PIANO_START_X + 2 + octave * 28 + 16; 382 x0 = base_x + octave * 28 + 16;
378 x1 = x0 + 2; 383 x1 = x0 + 2;
379 y0 = PIANO_START_Y - 2 + 13; 384 y0 = base_y1 + PIANO_BLACK_H;
380 y1 = y0 + 2; 385 y1 = y0 + PIANO_H - PIANO_BLACK_H;
381 draw_filled_rect(x0, y0, x1, y1, clr); 386 draw_filled_rect(x0, y0, x1, y1, clr);
382 } break; 387 } break;
383 case 9:{ 388 case 9:{
384 x0 = PIANO_START_X + 2 + octave * 28 + 21; 389 x0 = base_x + octave * 28 + 21;
385 x1 = x0; 390 x1 = x0;
386 y0 = PIANO_START_Y + 2; 391 y0 = base_y0;
387 y1 = PIANO_START_Y - 2 + 12; 392 y1 = base_y1 + PIANO_H;
388 draw_filled_rect(x0, y0, x1, y1, clr); 393 draw_filled_rect(x0, y0, x1, y1, clr);
389 x0 = PIANO_START_X + 2 + octave * 28 + 20; 394 x0 = base_x + octave * 28 + 20;
390 x1 = x0 + 2; 395 x1 = x0 + 2;
391 y0 = PIANO_START_Y - 2 + 13; 396 y0 = base_y1 + PIANO_BLACK_H;
392 y1 = y0 + 2; 397 y1 = y0 + PIANO_H - PIANO_BLACK_H;
393 draw_filled_rect(x0, y0, x1, y1, clr); 398 draw_filled_rect(x0, y0, x1, y1, clr);
394 } break; 399 } break;
395 case 11: { 400 case 11: {
396 x0 = PIANO_START_X + 2 + octave * 28 + 25; 401 x0 = base_x + octave * 28 + 25;
397 x1 = x0 + 1; 402 x1 = x0 + 1;
398 y0 = PIANO_START_Y + 2; 403 y0 = base_y0;
399 y1 = PIANO_START_Y - 2 + 12; 404 y1 = base_y1 + PIANO_H;
400 draw_filled_rect(x0, y0, x1, y1, clr); 405 draw_filled_rect(x0, y0, x1, y1, clr);
401 x0 = PIANO_START_X + 2 + octave * 28 + 24; 406 x0 = base_x + octave * 28 + 24;
402 x1 = x0 + 2; 407 x1 = x0 + 2;
403 y0 = PIANO_START_Y - 2 + 13; 408 y0 = base_y1 + PIANO_BLACK_H;
404 y1 = y0 + 2; 409 y1 = y0 + PIANO_H - PIANO_BLACK_H;
405 draw_filled_rect(x0, y0, x1, y1, clr); 410 draw_filled_rect(x0, y0, x1, y1, clr);
406 } break; 411 } break;
407 default: { 412 default: {
408 if (clr == COL_FG) { 413 if (clr == COL_FG) {
409 clr = COL_BG; 414 clr = COL_BG;
410 } 415 }
411 y0 = PIANO_START_Y + 2; 416 y0 = base_y0;
412 y1 = PIANO_START_Y - 2 + 11; 417 y1 = base_y1 + PIANO_BLACK_H - 2;
413 switch (value) { 418 switch (value) {
414 case 1: { x0 = PIANO_START_X + 2 + octave * 28 + 3; } break; 419 case 1: { x0 = base_x + octave * 28 + 3; } break;
415 case 3: { x0 = PIANO_START_X + 2 + octave * 28 + 7; } break; 420 case 3: { x0 = base_x + octave * 28 + 7; } break;
416 case 6: { x0 = PIANO_START_X + 2 + octave * 28 + 15; } break; 421 case 6: { x0 = base_x + octave * 28 + 15; } break;
417 case 8: { x0 = PIANO_START_X + 2 + octave * 28 + 19; } break; 422 case 8: { x0 = base_x + octave * 28 + 19; } break;
418 case 10: { x0 = PIANO_START_X + 2 + octave * 28 + 23; } break; 423 case 10: { x0 = base_x + octave * 28 + 23; } break;
419 } 424 }
420 x1 = x0; 425 x1 = x0;
421 draw_line(x0, y0, x1, y1, clr); 426 draw_line(x0, y0, x1, y1, clr);
@@ -1112,32 +1117,34 @@ void
1112draw_parameters(void) { 1117draw_parameters(void) {
1113 clear_parameters(); 1118 clear_parameters();
1114 Pattern *pat = &patterns[pattern_selection_loc]; 1119 Pattern *pat = &patterns[pattern_selection_loc];
1115 if (input_handler == handle_trigger_selection || 1120 draw_rect(PARAMS_START_X, PARAMS_START_Y, PARAMS_START_X + PARAMS_W, PARAMS_START_Y + PARAMS_H, COL_OFF);
1116 input_handler == handle_param_selection_sq1 || 1121 // DEBUG: Drawing the reference grid
1117 input_handler == handle_param_selection_sq2 || 1122 // if (input_handler == handle_trigger_selection ||
1118 input_handler == handle_param_selection_wave || 1123 // input_handler == handle_param_selection_sq1 ||
1119 input_handler == handle_param_selection_noise) { 1124 // input_handler == handle_param_selection_sq2 ||
1120 switch (channel_selection_loc) { 1125 // input_handler == handle_param_selection_wave ||
1121 case 0: { draw_parameters_square(&pat->ch1.params[trig_selection_loc], true, false); } break; 1126 // input_handler == handle_param_selection_noise) {
1122 case 1: { draw_parameters_square(&pat->ch2.params[trig_selection_loc], false, false); } break; 1127 // switch (channel_selection_loc) {
1123 case 2: { draw_parameters_wave(&pat->ch3.params[trig_selection_loc], false); } break; 1128 // case 0: { draw_parameters_square(&pat->ch1.params[trig_selection_loc], true, false); } break;
1124 case 3: { draw_parameters_noise(&pat->ch4.params[trig_selection_loc], false); } break; 1129 // case 1: { draw_parameters_square(&pat->ch2.params[trig_selection_loc], false, false); } break;
1125 } 1130 // case 2: { draw_parameters_wave(&pat->ch3.params[trig_selection_loc], false); } break;
1126 return; 1131 // case 3: { draw_parameters_noise(&pat->ch4.params[trig_selection_loc], false); } break;
1127 } 1132 // }
1128 if (input_handler == handle_channel_selection || 1133 // return;
1129 input_handler == handle_param_selection_ch1 || 1134 // }
1130 input_handler == handle_param_selection_ch2 || 1135 // if (input_handler == handle_channel_selection ||
1131 input_handler == handle_param_selection_ch3 || 1136 // input_handler == handle_param_selection_ch1 ||
1132 input_handler == handle_param_selection_ch4) { 1137 // input_handler == handle_param_selection_ch2 ||
1133 switch (channel_selection_loc) { 1138 // input_handler == handle_param_selection_ch3 ||
1134 case 0: { draw_parameters_square(&ch1_params, true, true); } break; 1139 // input_handler == handle_param_selection_ch4) {
1135 case 1: { draw_parameters_square(&ch2_params, false, true); } break; 1140 // switch (channel_selection_loc) {
1136 case 2: { draw_parameters_wave(&ch3_params, true); } break; 1141 // case 0: { draw_parameters_square(&ch1_params, true, true); } break;
1137 case 3: { draw_parameters_noise(&ch4_params, true); } break; 1142 // case 1: { draw_parameters_square(&ch2_params, false, true); } break;
1138 } 1143 // case 2: { draw_parameters_wave(&ch3_params, true); } break;
1139 return; 1144 // case 3: { draw_parameters_noise(&ch4_params, true); } break;
1140 } 1145 // }
1146 // return;
1147 // }
1141} 1148}
1142 1149
1143void 1150void
@@ -1262,10 +1269,10 @@ draw_piano_notes(void) {
1262 1269
1263void 1270void
1264draw_notif_bar() { 1271draw_notif_bar() {
1265 u8 x0 = PARAMS_START_X; 1272 u8 x0 = NOTIF_START_X;
1266 u8 y0 = PARAMS_START_Y - 7; 1273 u8 y0 = NOTIF_START_Y - 7;
1267 u8 x1 = PARAMS_START_X + PARAMS_W; 1274 u8 x1 = NOTIF_START_X + NOTIF_W;
1268 u8 y1 = y0 + 10; 1275 u8 y1 = y0 + NOTIF_H;
1269 u8 color = COL_FG; 1276 u8 color = COL_FG;
1270 draw_filled_rect(x0, y0, x1, y1, COL_BG); 1277 draw_filled_rect(x0, y0, x1, y1, COL_BG);
1271 draw_rect(x0, y0, x1, y1, color); 1278 draw_rect(x0, y0, x1, y1, color);
diff --git a/src/globals.c b/src/globals.c
index 7a55f02..724ff10 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -33,32 +33,38 @@ bool clear_screen = true;
33#define CHAN_W 19 33#define CHAN_W 19
34#define CHAN_H 8 34#define CHAN_H 8
35#define CHAN_START_X 30 35#define CHAN_START_X 30
36#define CHAN_START_Y 97 36#define CHAN_START_Y 98
37#define CHAN_OFFSET_Y 15 37#define CHAN_OFFSET_Y 15
38 38
39#define TRIG_W 15 39#define TRIG_W 15
40#define TRIG_H 22 40#define TRIG_H 22
41#define TRIG_START_X 59 41#define TRIG_START_X 59
42#define TRIG_START_Y 97 42#define TRIG_START_Y 98
43#define TRIG_OFFSET_X (TRIG_W + 3) 43#define TRIG_OFFSET_X (TRIG_W + 3)
44#define TRIG_OFFSET_Y (TRIG_H + 8) 44#define TRIG_OFFSET_Y (TRIG_H + 8)
45 45
46#define PIANO_W 170 46#define PIANO_W 170
47#define PIANO_H 15 47#define PIANO_H 12
48#define PIANO_BLACK_H 10
48#define PIANO_START_X 30 49#define PIANO_START_X 30
49#define PIANO_START_Y 76 50#define PIANO_START_Y 80
50#define PIANO_NOTE_W 2 51#define PIANO_NOTE_W 2
51 52
52#define PARAMS_W 170 53#define NOTIF_W 170
53#define PARAMS_H 60 54#define NOTIF_H 10
54#define PARAMS_START_X 30 55#define NOTIF_START_X 30
55#define PARAMS_START_Y 16 56#define NOTIF_START_Y 13
57
58#define PARAMS_W 166
59#define PARAMS_H 52
60#define PARAMS_START_X 32
61#define PARAMS_START_Y 22
56 62
57#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 4) 63#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 4)
58#define L_SIDEBAR_X ((CHAN_START_X) - 26) 64#define L_SIDEBAR_X ((CHAN_START_X) - 26)
59 65
60#define PAT_START_X (L_SIDEBAR_X + 4) 66#define PAT_START_X (L_SIDEBAR_X + 4)
61#define PAT_START_Y 20 67#define PAT_START_Y 21
62#define PAT_W 14 68#define PAT_W 14
63#define PAT_H 10 69#define PAT_H 10
64#define PAT_OFFSET_Y 17 70#define PAT_OFFSET_Y 17
@@ -83,7 +89,7 @@ bool clear_screen = true;
83#define PAT_TRIG_W 14 89#define PAT_TRIG_W 14
84#define PAT_TRIG_H 14 90#define PAT_TRIG_H 14
85#define PAT_TRIG_START_X 35 91#define PAT_TRIG_START_X 35
86#define PAT_TRIG_START_Y 29 92#define PAT_TRIG_START_Y 30
87#define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7) 93#define PAT_TRIG_OFFSET_X (PAT_TRIG_W + 7)
88#define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8) 94#define PAT_TRIG_OFFSET_Y (PAT_TRIG_H + 8)
89 95