]> Chaos Git - corbenik/corbenik.git/commitdiff
Clean up the menu code somewhat
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 24 May 2016 02:30:58 +0000 (22:30 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 24 May 2016 02:30:58 +0000 (22:30 -0400)
Makefile
source/menu.c

index cd093519fcccc410a0aee4a25e0b9583f5c4831b..d56354624588184168a853f0a83714bffd56fb60 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,8 @@ LD := arm-none-eabi-ld
 OC := arm-none-eabi-objcopy
 
 name := Corbenik
-cons ?= n3ds
+
+# If unset, the primary folder is /corbenik.
 fw_folder ?= corbenik
 
 dir_source := source
@@ -28,7 +29,7 @@ objects_cfw = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
                          $(call rwildcard, $(dir_source), *.s *.c)))
 
 .PHONY: all
-all: a9lh modules external host/langemu.conf
+all: host/langemu.conf a9lh modules external
 
 .PHONY: modules
 modules:
@@ -53,9 +54,9 @@ host/langemu.conf:
 
 .PHONY: clean
 clean:
+       rm -f host/langemu.conf
        make -C modules clean
        make -C external clean
-       rm -f host/langemu.conf
        rm -rf $(dir_out) $(dir_build)
 
 .PHONY: $(dir_out)/arm9loaderhax.bin
index a48f735c2c6effeab3a7afdf53385b6ef22def69..5ecaaad5a5fde9072c91d8556b46fd2b8a6b89bf 100644 (file)
@@ -40,6 +40,7 @@ static struct options_s options[] = {
 };
 
 static int cursor_y = 0;
+static int cursor_max = 0;
 static int which_menu = 1;
 static int need_redraw = 1;
 
@@ -83,6 +84,13 @@ menu_options()
 {
     set_cursor(TOP_SCREEN, 0, 0);
 
+    // Figure out the max if unset.
+    if (cursor_max == 0) {
+        cursor_max=0;
+        while(options[cursor_max].index != -1)
+            ++cursor_max;
+    }
+
     header("A:Enter B:Back DPAD:Nav");
 
     int i = 0;
@@ -115,13 +123,15 @@ menu_options()
     switch (key) {
         case BUTTON_UP:
             cursor_y -= 1;
-            if (cursor_y < 0)
-                cursor_y = 0;
             break;
         case BUTTON_DOWN:
             cursor_y += 1;
-            if (options[cursor_y].index == -1)
-                cursor_y -= 1;
+            break;
+        case BUTTON_LEFT:
+            cursor_y -= 5;
+            break;
+        case BUTTON_RIGHT:
+            cursor_y += 5;
             break;
         case BUTTON_A:
             // TODO - Value options
@@ -136,6 +146,13 @@ menu_options()
             break;
     }
 
+    if (cursor_y < 0) {
+        cursor_y = cursor_max - 1;
+    }
+    else if (cursor_y > cursor_max - 1) {
+        cursor_y = 0;
+    }
+
     return 0;
 }