#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);
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) {
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:
break;
case BUTTON_B:
exit = 1;
- need_redraw = 1;
clear_screen(TOP_SCREEN);
cursor_y = cursor_min;
break;
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;
}
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"
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"