From 52bdd0d79c77df0a7752fd15ebcc730f9e9796b1 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 28 May 2023 19:17:48 +0200 Subject: Refactor settings into own files --- src/main.c | 114 +++---------------------------------------------------------- 1 file changed, 4 insertions(+), 110 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b2d7a23..4a4f265 100644 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,8 @@ WITH REGARD TO THIS SOFTWARE. #include "gba/gba.h" #include "renderer_m0.c" +#include "globals.c" +#include "settings.c" #include "sequencer.c" #define PROF_ENABLE 0 @@ -99,65 +101,6 @@ render_sequencer(void) { PROF(draw_cursors(), draw_cursor_cycles); } -bool clear_screen = false; - -typedef enum Scene { - SCENE_SEQUENCER = 0, - SCENE_SETTINGS, -} Scene; - -static scene = SCENE_SETTINGS; -static next_scene = SCENE_SETTINGS; - -typedef enum SyncSetting { - SYNC_NONE = 0, - SYNC_OUT_LINK_16, - SYNC_OUT_LINK_8, - SYNC_OUT_LINK_4, - SYNC_NUM, -} SyncSetting; - -char * sync_setting_str[] = { - "NONE", - "LINK OUT (16)", - "LINK OUT (8)", - "LINK OUT (4)", -}; - -typedef enum ThemeSetting { - THEME_DEFAULT = 0, -} ThemeSetting; - -char * theme_setting_str[] = { - "DEFAULT", -}; - -typedef enum CursorSetting { - CURSOR_DEFAULT = 0, -} CursorSetting; - -char * cursor_setting_str[] = { - "LINE", -}; - -typedef struct Settings { - SyncSetting sync; - ThemeSetting theme; - CursorSetting cursor; -} Settings; - -static Settings settings = {0}; -static settings_cursor_loc = 0; - -void -draw_settings_cursor(void) { - int x = 6; - int y = 17 + settings_cursor_loc * 12; - draw_line(x + 1, y + 3, x + 1, y + 7, COL_CYAN); - draw_line(x + 2, y + 4, x + 2, y + 6, COL_CYAN); - draw_line(x + 3, y + 5, x + 3, y + 5, COL_CYAN); -} - void render_settings(void) { PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); @@ -168,62 +111,13 @@ render_settings(void) { txt_printf(" CURSOR: %s\n\n", cursor_setting_str[settings.cursor]); txt_render(); txt_clear(); - draw_settings_cursor(); -} - -#define N_SETTINGS 3 - -void -handle_settings_input(void) { - if (key_tap(KEY_DOWN)) { - if (settings_cursor_loc == (N_SETTINGS - 1)) { - settings_cursor_loc = 0; - } else { - settings_cursor_loc++; - } - clear_screen = true; - } - if (key_tap(KEY_UP)) { - if (settings_cursor_loc == 0) { - settings_cursor_loc = N_SETTINGS - 1; - } else { - settings_cursor_loc--; - } - clear_screen = true; - } - if (key_tap(KEY_R)) { - switch (settings_cursor_loc) { - case 0: { - if ((settings.sync + 1) >= SYNC_NUM) { - settings.sync = 0; - } else { - settings.sync++; - } - } break; - } - clear_screen = true; - } - if (key_tap(KEY_L)) { - switch (settings_cursor_loc) { - case 0: { - if (settings.sync == 0) { - settings.sync = SYNC_NUM - 1; - } else { - settings.sync--; - } - } break; - } - clear_screen = true; - } - if (key_tap(KEY_B)) { - next_scene = SCENE_SEQUENCER; - } + PROF(draw_settings_cursor(), draw_cursor_cycles); } void render(void) { if (clear_screen) { - screen_fill(COL_BG); + PROF(screen_fill(COL_BG), clear_cycles); clear_screen = false; } switch (scene) { -- cgit v1.2.1