From: chaoskagami Date: Mon, 6 Jun 2016 10:58:18 +0000 (-0400) Subject: Support multiple emunands X-Git-Tag: v0.0.5~3 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=7c3b1cd136801fee202d03cf9586ee2b4d1173fc;p=corbenik%2Fcorbenik.git Support multiple emunands --- diff --git a/external/svc/emunand.s b/external/svc/emunand.s index 0655d25..20408e3 100644 --- a/external/svc/emunand.s +++ b/external/svc/emunand.s @@ -10,7 +10,7 @@ _start: main: // If we're already trying to access the SD, return. ldr r2, [r0, #4] - ldr r1, sdmmc // In armips this instruction uses pc-releative loading + ldr r1, sdmmc // In armips this instruction uses pc-releative loading. Specifying it like this causes gcc to emit the same code. cmp r2, r1 beq nand_sd_ret diff --git a/source/config.h b/source/config.h index 7095b4a..95371ba 100644 --- a/source/config.h +++ b/source/config.h @@ -99,6 +99,9 @@ struct options_s // Whether to use an EmuNAND #define OPTION_EMUNAND 16 +// Which EmuNAND to use (currently only allows 10 total, but eh, I can change that if anyone truly needs it) +#define OPTION_EMUNAND_INDEX 17 + // Save log files during boot and from loader. // This will slow things down a bit. #define OPTION_SAVE_LOGS 253 diff --git a/source/display.c b/source/display.c index 46ea32d..bacd5cc 100644 --- a/source/display.c +++ b/source/display.c @@ -72,7 +72,14 @@ show_menu(struct options_s *options, uint8_t *toggles) putc(TOP_SCREEN, ']'); putc(TOP_SCREEN, '\n'); } - } else if (options[i].allowed == not_option) { + } else if (options[i].allowed == ranged_val) { + if (cursor_y == i) + fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m "); + else + fprintf(TOP_SCREEN, " "); + + fprintf(TOP_SCREEN, "[%u] %s \n", toggles[options[i].index], options[i].name); + } else if (options[i].allowed == not_option) { fprintf(TOP_SCREEN, "%s\n", options[i].name); } ++i; @@ -104,9 +111,22 @@ show_menu(struct options_s *options, uint8_t *toggles) cursor_y++; break; case BUTTON_A: - // FIXME - This needs to be part of the patch menu. - // toggles[OPTION_RECONFIGURED] = 1; - toggles[options[cursor_y].index] = !toggles[options[cursor_y].index]; + if (options[cursor_y].allowed == boolean_val) { + toggles[options[cursor_y].index] = !toggles[options[cursor_y].index]; + } else if (options[cursor_y].allowed == ranged_val) { + if (toggles[options[cursor_y].index] == options[cursor_y].b) + toggles[options[cursor_y].index] = options[cursor_y].a; + else + toggles[options[cursor_y].index]++; + } + break; + case BUTTON_X: + if (options[cursor_y].allowed == ranged_val) { + if (toggles[options[cursor_y].index] == options[cursor_y].a) + toggles[options[cursor_y].index] = options[cursor_y].b; + else + toggles[options[cursor_y].index]--; + } break; case BUTTON_B: exit = 1; diff --git a/source/menu.c b/source/menu.c index f9d05be..e2b6ec3 100644 --- a/source/menu.c +++ b/source/menu.c @@ -32,7 +32,8 @@ static struct options_s options[] = { { 0, "", "", not_option, 0, 0 }, - { OPTION_EMUNAND, "EmuNAND", "Redirects NAND write/read to EmuNAND #0. Right now, only one is supported (but the work is done)", boolean_val, 0, 0 }, + { OPTION_EMUNAND, "Use EmuNAND", "Redirects NAND write/read to the SD.", boolean_val, 0, 0 }, + { OPTION_EMUNAND_INDEX, " Index", "Which EmuNAND to use. Currently, 10 maximum (but this is arbitrary)", ranged_val, 0, 0x9 }, { 0, "", "", not_option, 0, 0 }, @@ -86,6 +87,8 @@ wait_key() get = BUTTON_A; else if (HID_PAD & BUTTON_B) get = BUTTON_B; + else if (HID_PAD & BUTTON_X) + get = BUTTON_X; } while (HID_PAD & get) ; @@ -202,6 +205,9 @@ menu_options() { show_menu(options, config.options); + // TODO - Determine whether it actually changed. + config.options[OPTION_RECONFIGURED] = 1; + return MENU_MAIN; } diff --git a/source/patcher.c b/source/patcher.c index 1dd98d8..d2c60dd 100644 --- a/source/patcher.c +++ b/source/patcher.c @@ -85,13 +85,11 @@ patch_firm_all() wait(); } - // Use loopback EmuNAND? + // Use EmuNAND? if (config.options[OPTION_EMUNAND]) { // Yes. - patch_emunand(0); -// patch_loop_emunand("/nand.bin"); + patch_emunand(config.options[OPTION_EMUNAND_INDEX]); - // FIXME - NYI wait(); } diff --git a/source/std/abort.h b/source/std/abort.h index 9bb233b..7cd4558 100644 --- a/source/std/abort.h +++ b/source/std/abort.h @@ -10,6 +10,7 @@ uint32_t wait_key(); { \ fprintf(stderr, x); \ wait_key(); \ + clear_disp(stderr); \ menu_poweroff(); \ }