]> Chaos Git - corbenik/corbenik.git/commitdiff
Support multiple emunands
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 6 Jun 2016 10:58:18 +0000 (06:58 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 6 Jun 2016 10:58:18 +0000 (06:58 -0400)
external/svc/emunand.s
source/config.h
source/display.c
source/menu.c
source/patcher.c
source/std/abort.h

index 0655d25921761e786bf676c119dc3a53fb44e6a8..20408e3e2adb88e4d84021a17369cdc5a7e3e9a9 100644 (file)
@@ -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
 
index 7095b4a57ea997080e47869a7b481cf2bde8e901..95371ba875207bdbfce3a31448c4857691bb0d07 100644 (file)
@@ -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
index 46ea32d91edd2c2b2ba27e66639cd4ab3b4b8984..bacd5cc12aae54bec94305f015fa08284d454b0d 100644 (file)
@@ -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;
index f9d05be5a52046a79591db26807c73233318763f..e2b6ec308bd601b61a5085566a08fb37f5dbe6f2 100644 (file)
@@ -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;
 }
 
index 1dd98d8ad0494e7df782e9a4d8f0f5d3c71addae..d2c60ddbb9c71e71133865b023e4242d68b3ee3d 100644 (file)
@@ -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();
     }
 
index 9bb233bfbf91104bcaf53cbdf30f0933064aa5a4..7cd45580ea39af48aa5dcc18f3ffc77bea2f0f87 100644 (file)
@@ -10,6 +10,7 @@ uint32_t wait_key();
     {                                                                                                                                                          \
         fprintf(stderr, x);                                                                                                                                    \
         wait_key();                                                                                                                                            \
+        clear_disp(stderr);                                                                                                                                    \
         menu_poweroff();                                                                                                                                       \
     }