]> Chaos Git - corbenik/corbenik.git/commitdiff
Update menu code - fix a crash in wait()
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 14 Jun 2016 20:09:33 +0000 (16:09 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 14 Jun 2016 20:09:55 +0000 (16:09 -0400)
source/display.c
source/menu.c
source/patcher.c
source/std/abort.h

index 68fa67a4a93229e5599c777f915fe96bdb715651..1228ce534cb4de10c41939547803700b43c574cf 100644 (file)
@@ -30,7 +30,7 @@ show_menu(struct options_s *options, uint8_t *toggles)
         set_cursor(TOP_SCREEN, 0, 0);
         header("Any:Back");
         fprintf(stdout, "No entries.\n");
-        wait_key();
+        wait_key(1);
         return 0;
     }
 
@@ -101,7 +101,7 @@ show_menu(struct options_s *options, uint8_t *toggles)
 
         need_redraw = 0;
 
-        uint32_t key = wait_key();
+        uint32_t key = wait_key(1);
 
         switch (key) {
             case BUTTON_UP:
index f00c2172e18e4c0d05b22a17d457c3b23fc57ed5..4e27199435b73e403e67cf4d2044d79f02a788c3 100644 (file)
@@ -7,8 +7,6 @@ struct options_s *patches = (struct options_s *)FCRAM_MENU_LOC;
 uint8_t *enable_list = (uint8_t *)FCRAM_PATCHLIST_LOC;
 
 static struct options_s options[] = {
-    // space
-    { 0, "", "", not_option, 0, 0 },
     // Patches.
     { 0, "\x1b[32;40mGeneral Options\x1b[0m", "", not_option, 0, 0 },
 
@@ -61,10 +59,12 @@ static int need_redraw = 1;
 extern void waitcycles(uint32_t cycles);
 
 uint32_t
-wait_key()
+wait_key(int sleep)
 {
-    #define ARM9_APPROX_DELAY_MAX 134058675 / 85
-    waitcycles(ARM9_APPROX_DELAY_MAX); // Approximately what a human can input - fine tuning needed (sorry, TASers!)
+    if (sleep) {
+        #define ARM9_APPROX_DELAY_MAX 134058675 / 85
+        waitcycles(ARM9_APPROX_DELAY_MAX); // Approximately what a human can input - fine tuning needed (sorry, TASers!)
+    }
 
     uint32_t ret = 0, get = 0;
     while (ret == 0) {
@@ -94,7 +94,9 @@ wait_key()
 void
 header(char *append)
 {
-    fprintf(stdout, "\x1b[30;42m.corbenik//%s %s\x1b[0m\n", VERSION, append);
+    fprintf(stdout, "\x1b[30;42m                                                  ");
+    set_cursor(TOP_SCREEN, 0, 0);
+    fprintf(stdout, "\x1b[30;42m Corbenik//%s %s\x1b[0m\n\n", VERSION, append);
 }
 
 static int current_menu_index_patches = 0;
@@ -158,6 +160,10 @@ list_patches_build_back(char *fpath, int desc_is_path)
     return 0;
 }
 
+// This is dual purpose. When we actually list
+// patches to build the cache - desc_is_fname
+// will be set to 1.
+
 void
 list_patches_build(char *name, int desc_is_fname)
 {
@@ -165,6 +171,17 @@ list_patches_build(char *name, int desc_is_fname)
 
     memset(enable_list, 0, FCRAM_SPACING / 2);
 
+    if (!desc_is_fname) {
+        strncpy(patches[0].name, "\x1b[40;32mPatches\x1b[0m", 64);
+        strncpy(patches[0].desc, "", 255);
+        patches[0].index = 0;
+        patches[0].allowed = not_option;
+        patches[0].a = 0;
+        patches[0].b = 0;
+
+        current_menu_index_patches += 1;
+    }
+
     char fpath[256];
     strncpy(fpath, name, 256);
     list_patches_build_back(fpath, desc_is_fname);
@@ -214,7 +231,7 @@ menu_info()
                     "  Version: %s (%x)\n",
             native->version_string, native->version, agb->version_string, agb->version, twl->version_string, twl->version);
 
-    wait_key();
+    wait_key(1);
 
     need_redraw = 1;
     clear_screen(TOP_SCREEN);
@@ -246,7 +263,7 @@ menu_help()
                     " <https://github.com/chaoskagami/corbenik>\n"
                     "\n");
 
-    wait_key();
+    wait_key(1);
 
     need_redraw = 1;
     clear_screen(TOP_SCREEN);
@@ -277,7 +294,6 @@ poweroff()
 }
 
 static struct options_s main_s[] = {
-    // space
     { 0, "Options",            "", call_fun, (uint32_t)menu_options, 0 },
     { 0, "Patches",            "", call_fun, (uint32_t)menu_patches, 0 },
     { 0, "Info",               "", call_fun, (uint32_t)menu_info,    0 },
index a203a34d8191955f1d3f7167c16f007c45a89edb..3a3c277cf1b14e64e7b4570743b0d3a4e8f34969 100644 (file)
@@ -9,7 +9,7 @@
 
 // TODO - Basically all this needs to move to patcher programs.
 
-uint32_t wait_key();
+uint32_t wait_key(int sleep);
 
 extern int patch_services();
 extern int patch_modules();
@@ -23,10 +23,10 @@ void
 wait()
 {
     if (config.options[OPTION_TRACE] && !doing_autoboot) {
-        fprintf(stderr, "                                 [WAIT]");
-        wait_key();
+        fprintf(stderr, "[Waiting...]");
+        wait_key(0); // No delay on traces.
     }
-    fprintf(stderr, "\r                                       \r");
+    fprintf(stderr, "            \r");
 }
 
 void list_patches_build(char *name, int desc_is_fname);
index ff8919e5778dc376d6af4a2c354f8b233f4bfc4c..1d03ab78c92b74e879d3bb7181673541c2480ffa 100644 (file)
@@ -4,12 +4,12 @@
 #include "draw.h"
 
 void poweroff();
-uint32_t wait_key();
+uint32_t wait_key(int sleep);
 
 #define abort(x...)                                                                                                                                            \
     {                                                                                                                                                          \
         fprintf(stderr, x);                                                                                                                                    \
-        wait_key();                                                                                                                                            \
+        wait_key(1);                                                                                                                                            \
         clear_disp(stderr);                                                                                                                                    \
         set_cursor(stderr, 0, 0);                                                                                                                              \
         poweroff();                                                                                                                                            \