]> Chaos Git - corbenik/corbenik.git/commitdiff
Menus now scroll with too many entries to show. Problem resolved.
authorchaoskagami <chaos.kagami@gmail.com>
Wed, 15 Jun 2016 21:33:40 +0000 (17:33 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Wed, 15 Jun 2016 21:33:40 +0000 (17:33 -0400)
Makefile
source/display.c
source/menu.c
source/std/draw.c

index 371d4a3b7b1689fa3cc0993e90d959d323f2db96..54ad7738b121b842641ddb095918275b87835a28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,7 @@ clean:
        rm -f host/{font-emit,font.h,font_prop.h,termfont.bin}
        make -C external clean
        make -C patch clean
+       make -C host/bdfe clean
        rm -rf $(dir_out) $(dir_build)
 
 .PHONY: $(dir_out)/arm9loaderhax.bin
index 1228ce534cb4de10c41939547803700b43c574cf..7ddb1b853a9499e869bd58b18e7f888ae9bcc0ad 100644 (file)
@@ -1,28 +1,22 @@
 #include "common.h"
 #include "firm/firm.h"
 #include "firm/headers.h"
-#define MENU_MAIN 1
-
-#define MENU_OPTIONS 2
-#define MENU_PATCHES 3
-#define MENU_INFO 4
-#define MENU_HELP 5
-#define MENU_RESET 6
-#define MENU_POWER 7
-#define MENU_BOOTME 8
 
 void header(char *append);
 
 extern int is_n3ds;
 
+extern unsigned int font_h;
+
 int
 show_menu(struct options_s *options, uint8_t *toggles)
 {
     int cursor_y = 0;
-    int need_redraw = 1;
     int cursor_min = -1;
     int cursor_max = -1;
     int exit = 0;
+    int window_size = (TOP_HEIGHT / font_h) - 3;
+    int window_top = 0, window_bottom = window_size;
 
     clear_screen(TOP_SCREEN);
 
@@ -57,50 +51,40 @@ show_menu(struct options_s *options, uint8_t *toggles)
 
         header("A:Enter B:Back DPAD:Nav");
 
-        int i = 0;
+        int i = window_top;
         while (options[i].index != -1) { // -1 Sentinel.
+            if (i > window_bottom)
+                break;
+
+            set_cursor(TOP_SCREEN, 0, i-window_top+2);
+
             if (options[i].allowed == boolean_val || (is_n3ds && options[i].allowed == boolean_val_n3ds)) {
                 if (cursor_y == i)
                     fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m ");
                 else
                     fprintf(TOP_SCREEN, "   ");
 
-                if (need_redraw)
-                    fprintf(TOP_SCREEN, "[%c]  %s\n", (toggles[options[i].index] ? 'X' : ' '), options[i].name);
-                else {
-                    // Yes, this is weird. printf does a large number of extra things we
-                    // don't
-                    // want computed at the moment; this is faster.
-                    putc(TOP_SCREEN, '[');
-                    putc(TOP_SCREEN, (toggles[options[i].index] ? 'X' : ' '));
-                    putc(TOP_SCREEN, ']');
-                    putc(TOP_SCREEN, '\n');
-                }
+                fprintf(TOP_SCREEN, "[%c]  %s", (toggles[options[i].index] ? '*' : ' '), options[i].name);
             } else if (options[i].allowed == call_fun || options[i].allowed == break_menu) {
                 if (cursor_y == i)
                     fprintf(TOP_SCREEN, "\x1b[32m>>\x1b[0m ");
                 else
                     fprintf(TOP_SCREEN, "   ");
 
-                if (need_redraw)
-                    fprintf(TOP_SCREEN, "%s\n", options[i].name);
-                else
-                    putc(TOP_SCREEN, '\n');
+                fprintf(TOP_SCREEN, "%s", options[i].name);
             } 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);
+                fprintf(TOP_SCREEN, "[%u]  %s  ", toggles[options[i].index], options[i].name);
             } else if (options[i].allowed == not_option) {
-                fprintf(TOP_SCREEN, "%s\n", options[i].name);
+                fprintf(TOP_SCREEN, "%s", options[i].name);
             }
             ++i;
         }
 
-        need_redraw = 0;
-
         uint32_t key = wait_key(1);
 
         switch (key) {
@@ -134,10 +118,8 @@ show_menu(struct options_s *options, uint8_t *toggles)
                         toggles[options[cursor_y].index]++;
                 } else if (options[cursor_y].allowed == call_fun) {
                     ((func_call_t)(options[cursor_y].a))(); // Call 'a' as a function.
-                    need_redraw = 1;
                 } else if (options[cursor_y].allowed == break_menu) {
                     exit = 1;
-                    need_redraw = 1;
                 }
                 break;
             case BUTTON_X:
@@ -150,7 +132,6 @@ show_menu(struct options_s *options, uint8_t *toggles)
                 break;
             case BUTTON_B:
                 exit = 1;
-                need_redraw = 1;
                 clear_screen(TOP_SCREEN);
                 cursor_y = cursor_min;
                 break;
@@ -160,9 +141,18 @@ show_menu(struct options_s *options, uint8_t *toggles)
             cursor_y = cursor_max - 1;
         else if (cursor_y > cursor_max - 1)
             cursor_y = cursor_min;
-    }
 
-    clear_screen(TOP_SCREEN);
+        if (cursor_y < window_top + cursor_min) {
+            window_top = cursor_y - cursor_min;
+            window_bottom = window_top + window_size;
+            clear_screen(TOP_SCREEN);
+
+        } else if (cursor_y > window_bottom - cursor_min) {
+            window_bottom = cursor_y + cursor_min;
+            window_top = window_bottom - window_size;
+            clear_screen(TOP_SCREEN);
+        }
+    }
 
     return 0;
 }
index 8dd2344a76ebaeeb56eadd8aa41241b6c22a6d36..28b52ad9f25523faf90dd069deb9ccc727c9c930 100644 (file)
@@ -223,7 +223,7 @@ menu_info()
     struct firm_signature *agb = get_firm_info(agb_firm_loc);
     struct firm_signature *twl = get_firm_info(twl_firm_loc);
 
-    fprintf(stdout, "\nNATIVE_FIRM / Firmware:\n"
+    fprintf(stdout, "NATIVE_FIRM / Firmware:\n"
                     "  Version: %s (%x)\n"
                     "AGB_FIRM / GBA Firmware:\n"
                     "  Version: %s (%x)\n"
@@ -246,7 +246,7 @@ menu_help()
 
     header("Any:Back");
 
-    fprintf(stdout, "\nCorbenik is another 3DS CFW for power users.\n"
+    fprintf(stdout, "Corbenik is another 3DS CFW for power users.\n"
                     "  It seeks to address some faults in other\n"
                     "  CFWs and is generally just another choice\n"
                     "  for users - but primarily is intended for\n"
index 425d6f319c573bdeb7f35839dfd5041bafe27e38..51f1d8fe11bfad7f8169c1f4d5d73cf2187ad623 100644 (file)
@@ -17,8 +17,8 @@ static unsigned int bottom_cursor_x = 0, bottom_cursor_y = 0;
 static size_t  log_size = 0;
 static char    log_buffer[4096]; // Log buffer.
 
-static unsigned int font_w = 8;
-static unsigned int font_h = 8;
+unsigned int font_w = 8;
+unsigned int font_h = 8;
 static unsigned int font_kern = 0;
 
 static unsigned int text_top_width = 20;
@@ -231,7 +231,7 @@ putc(void *buf, const int c)
             cursor_y[0]++;
         }
 
-        while (cursor_y[0] >= height - 1) {
+        while (cursor_y[0] >= height) {
             clear_disp(buf);
             cursor_x[0] = 0;
             cursor_y[0] = 0;