void *g_menubg_src_ptr;\r
void *g_menubg_ptr;\r
\r
-#if !MSCREEN_SIZE_FIXED\r
int g_menuscreen_w;\r
int g_menuscreen_h;\r
-#endif\r
+\r
+int g_autostateld_opt;\r
\r
static unsigned char *menu_font_data = NULL;\r
static int menu_text_color = 0xfffe; // default to white\r
\r
snprintf(buff, sizeof(buff), "%s - select, %s - back",\r
in_get_key_name(-1, -PBTN_MOK), in_get_key_name(-1, -PBTN_MBACK));\r
- smalltext_out16(x, g_menuscreen_h - me_sfont_h * 2 - 2, buff, 0xe78c);\r
+ smalltext_out16(x, g_menuscreen_h - me_sfont_h * 3 - 2, buff, 0xe78c);\r
+\r
snprintf(buff, sizeof(buff), g_menu_filter_off ?\r
"%s - hide unknown files" : "%s - show all files",\r
in_get_key_name(-1, -PBTN_MA3));\r
+ smalltext_out16(x, g_menuscreen_h - me_sfont_h * 2 - 2, buff, 0xe78c);\r
+\r
+ snprintf(buff, sizeof(buff), g_autostateld_opt ?\r
+ "%s - autoload save is ON" : "%s - autoload save is OFF",\r
+ in_get_key_name(-1, -PBTN_MA2));\r
smalltext_out16(x, g_menuscreen_h - me_sfont_h * 1 - 2, buff, 0xe78c);\r
}\r
\r
return alphasort(d1, d2);\r
}\r
\r
+static const char **filter_exts_internal;\r
+\r
static int scandir_filter(const struct dirent *ent)\r
{\r
+ const char **filter = filter_exts_internal;\r
const char *ext;\r
int i;\r
\r
return 0;\r
\r
ext++;\r
- for (i = 0; i < array_size(filter_exts); i++)\r
- if (strcasecmp(ext, filter_exts[i]) == 0)\r
+ for (i = 0; filter[i] != NULL; i++)\r
+ if (strcasecmp(ext, filter[i]) == 0)\r
return 1;\r
\r
return 0;\r
int i;\r
\r
sel++;\r
- for (i = sel + 1; i != sel; i++) {\r
+ for (i = sel + 1; ; i++) {\r
if (i >= len)\r
i = 1;\r
+ if (i == sel)\r
+ break;\r
\r
if (tolower_simple(namelist[i]->d_name[0]) == c)\r
break;\r
return i - 1;\r
}\r
\r
-static char *menu_loop_romsel(char *curr_path, int len,\r
+static const char *menu_loop_romsel(char *curr_path, int len,\r
+ const char **filter_exts,\r
int (*extra_filter)(struct dirent **namelist, int count,\r
const char *basedir))\r
{\r
struct dirent **namelist = NULL;\r
int n = 0, inp = 0, sel = 0, show_help = 0;\r
char *curr_path_restore = NULL;\r
- char *ret = NULL;\r
+ const char *ret = NULL;\r
char cinp;\r
\r
+ filter_exts_internal = filter_exts;\r
sel_fname[0] = 0;\r
\r
// is this a dir or a full path?\r
if (!plat_is_dir(curr_path)) {\r
- char *p = curr_path + strlen(curr_path) - 1;\r
- for (; p > curr_path && *p != '/'; p--)\r
- ;\r
- *p = 0;\r
- curr_path_restore = p;\r
- snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1);\r
+ char *p = strrchr(curr_path, '/');\r
+ if (p != NULL) {\r
+ *p = 0;\r
+ curr_path_restore = p;\r
+ snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1);\r
+ }\r
\r
- show_help = 2;\r
+ if (rom_fname_reload[0] == 0)\r
+ show_help = 2;\r
}\r
\r
rescan:\r
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT\r
| PBTN_L|PBTN_R|PBTN_MA2|PBTN_MA3|PBTN_MOK|PBTN_MBACK\r
| PBTN_MENU|PBTN_CHAR, &cinp, 33);\r
- if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
- if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
- if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
- if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }\r
- if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
- if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
- if (inp & PBTN_CHAR) sel = dirent_seek_char(namelist, n, sel, cinp);\r
if (inp & PBTN_MA3) {\r
g_menu_filter_off = !g_menu_filter_off;\r
snprintf(sel_fname, sizeof(sel_fname), "%s",\r
namelist[sel+1]->d_name);\r
goto rescan;\r
}\r
+ if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
+ if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
+ if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
+ if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }\r
+ if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
+ if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
+\r
if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_MA2)) == (PBTN_MENU|PBTN_MA2))\r
{\r
again:\r
strcat(newdir, "/");\r
strcat(newdir, namelist[sel+1]->d_name);\r
}\r
- ret = menu_loop_romsel(newdir, newlen, extra_filter);\r
+ ret = menu_loop_romsel(newdir, newlen, filter_exts, extra_filter);\r
free(newdir);\r
break;\r
}\r
}\r
}\r
}\r
+ else if (inp & PBTN_MA2) {\r
+ g_autostateld_opt = !g_autostateld_opt;\r
+ show_help = 3;\r
+ }\r
+ else if (inp & PBTN_CHAR) {\r
+ // must be last\r
+ sel = dirent_seek_char(namelist, n, sel, cinp);\r
+ }\r
+\r
if (inp & PBTN_MBACK)\r
break;\r
\r