From: chaoskagami Date: Fri, 17 Jun 2016 08:04:48 +0000 (-0400) Subject: Improve menu display somewhat X-Git-Tag: v0.1.0~4 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=d2fc3261e2b78bbb38d70e6b210c1d7f7530e3ac;p=corbenik%2Fcorbenik.git Improve menu display somewhat --- diff --git a/Makefile b/Makefile index 54ad773..08a08ca 100644 --- 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 diff --git a/source/display.c b/source/display.c index abcce53..7a3bace 100644 --- a/source/display.c +++ b/source/display.c @@ -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: diff --git a/source/menu.c b/source/menu.c index cebc739..a2cadb6 100644 --- a/source/menu.c +++ b/source/menu.c @@ -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