aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c114
1 files changed, 4 insertions, 110 deletions
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.
55#include "gba/gba.h" 55#include "gba/gba.h"
56 56
57#include "renderer_m0.c" 57#include "renderer_m0.c"
58#include "globals.c"
59#include "settings.c"
58#include "sequencer.c" 60#include "sequencer.c"
59 61
60#define PROF_ENABLE 0 62#define PROF_ENABLE 0
@@ -99,65 +101,6 @@ render_sequencer(void) {
99 PROF(draw_cursors(), draw_cursor_cycles); 101 PROF(draw_cursors(), draw_cursor_cycles);
100} 102}
101 103
102bool clear_screen = false;
103
104typedef enum Scene {
105 SCENE_SEQUENCER = 0,
106 SCENE_SETTINGS,
107} Scene;
108
109static scene = SCENE_SETTINGS;
110static next_scene = SCENE_SETTINGS;
111
112typedef enum SyncSetting {
113 SYNC_NONE = 0,
114 SYNC_OUT_LINK_16,
115 SYNC_OUT_LINK_8,
116 SYNC_OUT_LINK_4,
117 SYNC_NUM,
118} SyncSetting;
119
120char * sync_setting_str[] = {
121 "NONE",
122 "LINK OUT (16)",
123 "LINK OUT (8)",
124 "LINK OUT (4)",
125};
126
127typedef enum ThemeSetting {
128 THEME_DEFAULT = 0,
129} ThemeSetting;
130
131char * theme_setting_str[] = {
132 "DEFAULT",
133};
134
135typedef enum CursorSetting {
136 CURSOR_DEFAULT = 0,
137} CursorSetting;
138
139char * cursor_setting_str[] = {
140 "LINE",
141};
142
143typedef struct Settings {
144 SyncSetting sync;
145 ThemeSetting theme;
146 CursorSetting cursor;
147} Settings;
148
149static Settings settings = {0};
150static settings_cursor_loc = 0;
151
152void
153draw_settings_cursor(void) {
154 int x = 6;
155 int y = 17 + settings_cursor_loc * 12;
156 draw_line(x + 1, y + 3, x + 1, y + 7, COL_CYAN);
157 draw_line(x + 2, y + 4, x + 2, y + 6, COL_CYAN);
158 draw_line(x + 3, y + 5, x + 3, y + 5, COL_CYAN);
159}
160
161void 104void
162render_settings(void) { 105render_settings(void) {
163 PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); 106 PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles);
@@ -168,62 +111,13 @@ render_settings(void) {
168 txt_printf(" CURSOR: %s\n\n", cursor_setting_str[settings.cursor]); 111 txt_printf(" CURSOR: %s\n\n", cursor_setting_str[settings.cursor]);
169 txt_render(); 112 txt_render();
170 txt_clear(); 113 txt_clear();
171 draw_settings_cursor(); 114 PROF(draw_settings_cursor(), draw_cursor_cycles);
172}
173
174#define N_SETTINGS 3
175
176void
177handle_settings_input(void) {
178 if (key_tap(KEY_DOWN)) {
179 if (settings_cursor_loc == (N_SETTINGS - 1)) {
180 settings_cursor_loc = 0;
181 } else {
182 settings_cursor_loc++;
183 }
184 clear_screen = true;
185 }
186 if (key_tap(KEY_UP)) {
187 if (settings_cursor_loc == 0) {
188 settings_cursor_loc = N_SETTINGS - 1;
189 } else {
190 settings_cursor_loc--;
191 }
192 clear_screen = true;
193 }
194 if (key_tap(KEY_R)) {
195 switch (settings_cursor_loc) {
196 case 0: {
197 if ((settings.sync + 1) >= SYNC_NUM) {
198 settings.sync = 0;
199 } else {
200 settings.sync++;
201 }
202 } break;
203 }
204 clear_screen = true;
205 }
206 if (key_tap(KEY_L)) {
207 switch (settings_cursor_loc) {
208 case 0: {
209 if (settings.sync == 0) {
210 settings.sync = SYNC_NUM - 1;
211 } else {
212 settings.sync--;
213 }
214 } break;
215 }
216 clear_screen = true;
217 }
218 if (key_tap(KEY_B)) {
219 next_scene = SCENE_SEQUENCER;
220 }
221} 115}
222 116
223void 117void
224render(void) { 118render(void) {
225 if (clear_screen) { 119 if (clear_screen) {
226 screen_fill(COL_BG); 120 PROF(screen_fill(COL_BG), clear_cycles);
227 clear_screen = false; 121 clear_screen = false;
228 } 122 }
229 switch (scene) { 123 switch (scene) {