From: chaoskagami Date: Tue, 24 May 2016 02:30:58 +0000 (-0400) Subject: Clean up the menu code somewhat X-Git-Tag: stable-1~42 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=9a1213bab4a3eedaf0a0e5ee4db41e2034adb071;p=corbenik%2Fcorbenik.git Clean up the menu code somewhat --- diff --git a/Makefile b/Makefile index cd09351..d563546 100644 --- 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 diff --git a/source/menu.c b/source/menu.c index a48f735..5ecaaad 100644 --- a/source/menu.c +++ b/source/menu.c @@ -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; }