#ifndef LOADER
+/// Bear in mind the following functions are only defined insofar
+/// as that they exist. Do not make assumptions as to what is
+/// backing these functions on disk.
+
/* Loads the config file off SD from the configured location.
*/
void load_config();
*/
void save_config();
+/* Changes an option according to internal rules.
+ */
+void change_opt(void* val);
+
+/* Gets an option as a readable string.
+ */
+char* get_opt(void* val);
+
+/* Gets an option in raw form.
+ */
+uint32_t get_opt_raw(uint32_t val);
+
+/* Sets an option in raw form
+ */
+void set_opt_raw(uint32_t key, uint32_t val);
+
#endif
#endif
inc_dir = $(top_srcdir)/include
-corbenik_SOURCES = patch/reboot.c patch/svc.c patch/module.c patch/emunand.c main.c std/fs.c std/draw.c std/memory.c std/abort.c std/allocator.c menu.c firm/version.c firm/firm.c firm/decryptor.c interpreter.c input.c patcher.c chainloader.c config-file.c menu-backend.c start.s interrupt.c arm11.c
+corbenik_SOURCES = patch/reboot.c patch/svc.c patch/module.c patch/emunand.c main.c std/fs.c std/draw.c std/memory.c std/abort.c std/allocator.c menu.c firm/version.c firm/firm.c firm/decryptor.c interpreter.c input.c patcher.c chainloader.c config-backend-file.c menu-backend.c start.s interrupt.c arm11.c
void screen_mode(uint32_t mode) {
static uint32_t stride, init_top, init_bottom, bright;
- bright = brightness[config->options[OPTION_BRIGHTNESS]];
+ bright = brightness[get_opt_raw(OPTION_BRIGHTNESS)];
stride = 240 * 3;
if (mode == RGBA8)
fclose(conf_handle);
}
+
+void change_opt(void* val) {
+ uint32_t opt = (uint32_t)val;
+ uint8_t* set = & (config->options[opt]);
+ switch(opt) {
+ case OPTION_EMUNAND_INDEX:
+ // 0-9
+ set[0]++;
+ if (set[0] > 9)
+ set[0] = 0;
+ break;
+ case OPTION_BRIGHTNESS:
+ // 0-3
+ set[0]++;
+ if (set[0] > 3)
+ set[0] = 0;
+ break;
+ case OPTION_ACCENT_COLOR:
+ // 1-7
+ set[0]++;
+ if (set[0] > 7 || set[0] < 1)
+ set[0] = 1;
+ break;
+ default:
+ set[0] = !(set[0]);
+ break;
+ }
+}
+
+char* get_opt(void* val) {
+ uint32_t opt = (uint32_t)val;
+ char raw = config->options[opt];
+ static char str[2] = "0";
+ str[0] = '0';
+ switch(opt) {
+ case OPTION_EMUNAND_INDEX:
+ case OPTION_BRIGHTNESS:
+ case OPTION_ACCENT_COLOR:
+ str[0] += raw;
+ break;
+ default:
+ if (raw)
+ str[0] = '*';
+ else
+ str[0] = ' ';
+ break;
+ }
+ return str;
+}
+
+uint32_t get_opt_raw(uint32_t val) {
+ uint32_t opt = config->options[(uint32_t)val];
+ return opt;
+}
+
+void set_opt_raw(uint32_t key, uint32_t val) {
+ config->options[(uint32_t)key] = (uint8_t)val;
+}
void
wait()
{
- if (config->options[OPTION_TRACE] && !doing_autoboot) {
+ if (get_opt_raw(OPTION_TRACE) && !doing_autoboot) {
fprintf(stderr, "[Waiting...]");
wait_key(0); // No delay on traces.
}
#ifdef LOADER
if (config.options[OPTION_OVERLY_VERBOSE]) {
#else
- if (config->options[OPTION_OVERLY_VERBOSE]) {
+ if (get_opt_raw(OPTION_OVERLY_VERBOSE)) {
#endif
debug = 1;
}
installArm11Stub();
if (CFG_BOOTENV == 7)
- config->options[OPTION_EMUNAND] = 0; // Disable EmuNAND on AGB reboot.
+ set_opt_raw(OPTION_EMUNAND, 0); // Disable EmuNAND on AGB reboot.
set_font(PATH_TERMFONT); // Read the font before all else.
clear_disp(TOP_SCREEN);
clear_disp(BOTTOM_SCREEN);
- if (config->options[OPTION_AUTOBOOT] && !r_held) {
+ if (get_opt_raw(OPTION_AUTOBOOT) && !r_held) {
doing_autoboot = 1;
- if (config->options[OPTION_SILENCE])
+ if (get_opt_raw(OPTION_SILENCE))
shut_up(); // This does exactly what it sounds like.
} else {
menu_handler();
header(const char *append)
{
set_cursor(TOP_SCREEN, 0, 0);
- fill_line(stdout, 0, config->options[OPTION_ACCENT_COLOR]);
+ fill_line(stdout, 0, get_opt_raw(OPTION_ACCENT_COLOR));
accent_color(TOP_SCREEN, 0);
fprintf(stdout, "\x1b[30m ." FW_NAME " // %s\x1b[0m\n\n", append);
}
void accent_color(void* screen, int fg) {
char color[] = "\x1b[30m";
if (!fg) color[2] = '4';
- color[3] = ("01234567")[config->options[OPTION_ACCENT_COLOR]];
+ color[3] = ("01234567")[get_opt_raw(OPTION_ACCENT_COLOR)];
fprintf(screen, "%s", color);
}
struct options_s *patches = NULL;
uint8_t *enable_list;
-void change_opt(void* val) {
- uint32_t opt = (uint32_t)val;
- uint8_t* set = & (config->options[opt]);
- switch(opt) {
- case OPTION_EMUNAND_INDEX:
- // 0-9
- set[0]++;
- if (set[0] > 9)
- set[0] = 0;
- break;
- case OPTION_BRIGHTNESS:
- // 0-3
- set[0]++;
- if (set[0] > 3)
- set[0] = 0;
- break;
- case OPTION_ACCENT_COLOR:
- // 1-7
- set[0]++;
- if (set[0] > 7 || set[0] < 1)
- set[0] = 1;
- break;
- default:
- set[0] = !(set[0]);
- break;
- }
-}
-
-char* get_opt(void* val) {
- uint32_t opt = (uint32_t)val;
- char raw = config->options[opt];
- static char str[2] = "0";
- str[0] = '0';
- switch(opt) {
- case OPTION_EMUNAND_INDEX:
- case OPTION_BRIGHTNESS:
- case OPTION_ACCENT_COLOR:
- str[0] += raw;
- break;
- default:
- if (raw)
- str[0] = '*';
- else
- str[0] = ' ';
- break;
- }
- return str;
-}
-
static struct options_s options[] = {
// Patches.
{ "General Options", "", unselectable, 0, NULL, NULL, 0, 1 },
fprintf(stderr, "VM exited without issue\n");
// Hook firmlaunch?
- if (config->options[OPTION_REBOOT]) {
+ if (get_opt_raw(OPTION_REBOOT)) {
patch_reboot();
wait();
}
// Use EmuNAND?
- if (config->options[OPTION_EMUNAND]) {
+ if (get_opt_raw(OPTION_EMUNAND)) {
// Yes.
- patch_emunand(config->options[OPTION_EMUNAND_INDEX]);
+ patch_emunand(get_opt_raw(OPTION_EMUNAND_INDEX));
wait();
}
// Inject services?
- if (config->options[OPTION_SVCS]) {
+ if (get_opt_raw(OPTION_SVCS)) {
if (patch_services()) {
abort("Fatal. Svc inject has failed.");
}
}
// Replace loader?
- if (config->options[OPTION_LOADER]) {
+ if (get_opt_raw(OPTION_LOADER)) {
if (patch_modules()) {
abort("Fatal. Loader inject has failed.");
}
wait();
}
- // Use ARM9 hook thread?
- if (config->options[OPTION_ARM9THREAD]) {
- // Yes.
-
- // FIXME - NYI
- wait();
- }
-
return 0;
}