]> Chaos Git - corbenik/corbenik.git/commitdiff
Improve menu display somewhat
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 17 Jun 2016 08:04:48 +0000 (04:04 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 17 Jun 2016 08:04:48 +0000 (04:04 -0400)
Makefile
source/display.c
source/menu.c

index 54ad7738b121b842641ddb095918275b87835a28..08a08ca28c9fe8a33e021481d70ffef690879109 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,10 +22,11 @@ dir_data   := data
 dir_build  := build
 dir_out    := out
 
-REVISION := r$(shell git rev-list --count HEAD):$(shell git rev-parse HEAD | head -c8)
+REVISION := $(shell git rev-parse HEAD | head -c10)+$(shell git rev-list --count HEAD)
+REL ?= master
 
 CROSS_ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
-CROSS_CFLAGS  := -MMD -MP -Wall -Wextra -Werror -fomit-frame-pointer -Os $(ASFLAGS) -fshort-wchar -fno-builtin -std=gnu11 -DVERSION=\"$(REVISION)\"
+CROSS_CFLAGS  := -MMD -MP -Wall -Wextra -Werror -fomit-frame-pointer -Os $(ASFLAGS) -fshort-wchar -fno-builtin -std=gnu11 -DVERSION=\"$(REVISION)\" -DREL=\"$(REL)\"
 CROSS_FLAGS   := dir_out=$(abspath $(dir_out)) --no-print-directory
 CROSS_LDFLAGS := -nostdlib -Wl,-z,defs -lgcc -Wl,-Map,$(dir_build)/link.map
 
index abcce536130300ebf6a6c17b7ea488b550560927..7a3bace410b9ccf24e07771fb11ce5f8fd997c62 100644 (file)
@@ -45,11 +45,11 @@ show_menu(struct options_s *options, uint8_t *toggles)
             while (options[cursor_max].index != -1)
                 ++cursor_max;
 
-            while (options[cursor_max].allowed == not_option)
+            while (options[cursor_max].allowed == not_option && cursor_max > 0)
                 --cursor_max;
         }
 
-        // Figure out the max if unset.
+        // Figure out the min if unset.
         if (cursor_min == -1) {
             cursor_min = 0;
             while (options[cursor_min].allowed == not_option)
@@ -57,7 +57,13 @@ show_menu(struct options_s *options, uint8_t *toggles)
             cursor_y = cursor_min;
         }
 
-        header("A:Enter B:Back DPAD:Nav Select:Info");
+        if (cursor_max == cursor_y && cursor_max == 0)
+            header("B:Back");
+        else if (cursor_max == cursor_y)
+            header("A:Enter B:Back");
+        else
+            header("A:Enter B:Back DPAD:Nav Select:Info");
+
 
         int i = window_top;
         while (options[i].index != -1) { // -1 Sentinel.
@@ -97,21 +103,29 @@ show_menu(struct options_s *options, uint8_t *toggles)
 
         switch (key) {
             case BUTTON_UP:
+                if (cursor_min == cursor_max)
+                    break;
                 cursor_y -= 1;
                 while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min)
                     cursor_y--;
                 break;
             case BUTTON_DOWN:
+                if (cursor_min == cursor_max)
+                    break;
                 cursor_y += 1;
                 while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max)
                     cursor_y++;
                 break;
             case BUTTON_LEFT:
+                if (cursor_min == cursor_max)
+                    break;
                 cursor_y -= 5;
                 while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min)
                     cursor_y--;
                 break;
             case BUTTON_RIGHT:
+                if (cursor_min == cursor_max)
+                    break;
                 cursor_y += 5;
                 while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max)
                     cursor_y++;
@@ -128,6 +142,8 @@ show_menu(struct options_s *options, uint8_t *toggles)
                     ((func_call_t)(options[cursor_y].a))(); // Call 'a' as a function.
                 } else if (options[cursor_y].allowed == break_menu) {
                     exit = 1;
+                    clear_screen(TOP_SCREEN);
+                    cursor_y = cursor_min;
                 }
                 break;
             case BUTTON_X:
index cebc739217737193eaf06f2ec4cd06f7c55e1991..a2cadb655b7d8250229ed602e5d0871de774b0c7 100644 (file)
@@ -103,7 +103,7 @@ header(char *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);
+    fprintf(stdout, "\x1b[30;42m .Corbenik // %s\x1b[0m\n\n", append);
 }
 
 static int current_menu_index_patches = 0;
@@ -215,33 +215,40 @@ menu_options()
     show_menu(options, config.options);
 }
 
+#ifndef REL
+#define REL "master"
+#endif
+
+static struct options_s info_d[] = {
+       { 0, "  Native FIRM: ", "The version of NATIVE_FIRM in use.", not_option, 0, 0},
+       { 0, "  AGB FIRM:    ", "The version of AGB_FIRM in use. This is used to run GBA games.", not_option, 0, 0},
+       { 0, "  TWL FIRM:    ", "The version of TWL_FIRM in use. This is used to run DS games and DSiware.", not_option, 0, 0},
+       { 0, "  Corbenik:    " VERSION " (" REL ")", "Corbenik's version.", not_option, 0, 0},
+       { 0, "", "", not_option, 0, 0},
+       { 0, "[OK]", "", break_menu, 0, 0 }, // Temporary
+       { -1, "", "", not_option, 0, 0 }
+};
+static int is_setup_info = 0;
+
 void
 menu_info()
 {
-    // This menu requres firm to be loaded. Unfortunately.
-    load_firms(); // Lazy load!
+    if (!is_setup_info) {
+           // This menu requres firm to be loaded. Unfortunately.
+       load_firms(); // Lazy load!
 
-    clear_screen(TOP_SCREEN);
+           struct firm_signature *native = get_firm_info(firm_loc);
+       struct firm_signature *agb = get_firm_info(agb_firm_loc);
+       struct firm_signature *twl = get_firm_info(twl_firm_loc);
 
-    set_cursor(TOP_SCREEN, 0, 0);
+           memcpy(&info_d[0].name[strlen(info_d[0].name)], native->version_string, strlen(native->version_string));
+       memcpy(&info_d[1].name[strlen(info_d[1].name)], agb->version_string, strlen(agb->version_string));
+       memcpy(&info_d[2].name[strlen(info_d[2].name)], twl->version_string, strlen(twl->version_string));
 
-    header("Any:Back");
-    struct firm_signature *native = get_firm_info(firm_loc);
-    struct firm_signature *agb = get_firm_info(agb_firm_loc);
-    struct firm_signature *twl = get_firm_info(twl_firm_loc);
-
-    fprintf(stdout, "NATIVE_FIRM / Firmware:\n"
-                    "  Version: %s (%x)\n"
-                    "AGB_FIRM / GBA Firmware:\n"
-                    "  Version: %s (%x)\n"
-                    "TWL_FIRM / DSi Firmware:\n"
-                    "  Version: %s (%x)\n",
-            native->version_string, native->version, agb->version_string, agb->version, twl->version_string, twl->version);
+               is_setup_info = 1;
+       }
 
-    wait_key(1);
-
-    need_redraw = 1;
-    clear_screen(TOP_SCREEN);
+    show_menu(info_d, NULL);
 }
 
 void