32x: drc: finish MAC, gen drc entry/exit (for statically alloced regs)
[libpicofe.git] / common / menu.c
index 4393ed5..8e3b9dd 100644 (file)
@@ -23,7 +23,7 @@
 #include <pico/patch.h>\r
 \r
 static char static_buff[64];\r
-static char menu_error_msg[64] = { 0, };\r
+char menu_error_msg[64] = { 0, };\r
 static int  menu_error_time = 0;\r
 \r
 #ifndef UIQ3\r
@@ -276,7 +276,8 @@ void menu_init(void)
                lprintf("found skin.txt\n");\r
                while (!feof(f))\r
                {\r
-                       fgets(buff, sizeof(buff), f);\r
+                       if (fgets(buff, sizeof(buff), f) == NULL)\r
+                               break;\r
                        if (buff[0] == '#'  || buff[0] == '/')  continue; // comment\r
                        if (buff[0] == '\r' || buff[0] == '\n') continue; // empty line\r
                        if (strncmp(buff, "text_color=", 11) == 0)\r
@@ -744,10 +745,15 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
 \r
 static int scandir_cmp(const void *p1, const void *p2)\r
 {\r
-       struct dirent **d1 = (struct dirent **)p1, **d2 = (struct dirent **)p2;\r
-       if ((*d1)->d_type == (*d2)->d_type) return alphasort(d1, d2);\r
-       if ((*d1)->d_type == DT_DIR) return -1; // put before\r
-       if ((*d2)->d_type == DT_DIR) return  1;\r
+       const struct dirent **d1 = (const struct dirent **)p1;\r
+       const struct dirent **d2 = (const struct dirent **)p2;\r
+       if ((*d1)->d_type == (*d2)->d_type)\r
+               return alphasort(d1, d2);\r
+       if ((*d1)->d_type == DT_DIR)\r
+               return -1; // put before\r
+       if ((*d2)->d_type == DT_DIR)\r
+               return  1;\r
+\r
        return alphasort(d1, d2);\r
 }\r
 \r
@@ -789,13 +795,13 @@ rescan:
                fname = p+1;\r
        }\r
 \r
-       n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+       n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
        if (n < 0) {\r
                lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
 \r
                // try root\r
-               getcwd(curr_path, len);\r
-               n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+               plat_get_root_dir(curr_path, len);\r
+               n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
                if (n < 0) {\r
                        // oops, we failed\r
                        lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
@@ -1424,6 +1430,21 @@ static int menu_loop_cd_options(menu_id id, int keys)
        return 0;\r
 }\r
 \r
+// ------------ 32X options menu ------------\r
+\r
+static menu_entry e_menu_32x_options[] =\r
+{\r
+       mee_onoff("32X enabled",          MA_32XOPT_ENABLE_32X,   PicoOpt, POPT_EN_32X),\r
+       mee_onoff("PWM sound",            MA_32XOPT_PWM,          PicoOpt, POPT_EN_PWM),\r
+};\r
+\r
+static int menu_loop_32x_options(menu_id id, int keys)\r
+{\r
+       static int sel = 0;\r
+       me_loop(e_menu_32x_options, &sel, NULL);\r
+       return 0;\r
+}\r
+\r
 // ------------ adv options menu ------------\r
 \r
 static menu_entry e_menu_adv_options[] =\r
@@ -1672,6 +1693,7 @@ static menu_entry e_menu_options[] =
        mee_range     (cpu_clk_name,               MA_OPT_CPU_CLOCKS,    currentConfig.CPUclock, 20, 900),\r
        mee_handler   ("[Display options]",        menu_loop_gfx_options),\r
        mee_handler   ("[Sega/Mega CD options]",   menu_loop_cd_options),\r
+       mee_handler   ("[32X options]",            menu_loop_32x_options),\r
        mee_handler   ("[Advanced options]",       menu_loop_adv_options),\r
        mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg),\r
        mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg),\r
@@ -2079,6 +2101,7 @@ static menu_entry *e_menu_table[] =
        e_menu_gfx_options,\r
        e_menu_adv_options,\r
        e_menu_cd_options,\r
+       e_menu_32x_options,\r
        e_menu_keyconfig,\r
        e_menu_hidden,\r
 };\r