X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=psp%2Fmenu.c;h=6fe06ae6357946e4b8cf5dd0680564cbe7f567c3;hb=f11bad75edc8966e9f84b040163cc86e830c46c6;hp=20c34601f85feabbb12166949ef0ff54b163a6b9;hpb=6589c840ca686751d15ebb127367af1378dd7de2;p=libpicofe.git diff --git a/psp/menu.c b/psp/menu.c index 20c3460..6fe06ae 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -27,8 +27,8 @@ #include "../common/lprintf.h" #include "version.h" -#include -#include +#include +#include #include @@ -174,13 +174,9 @@ void menu_romload_end(void) // -------------- ROM selector -------------- -// SceIoDirent -#define DT_DIR FIO_SO_IFDIR -#define DT_REG FIO_SO_IFREG - struct my_dirent { - unsigned char d_type; + unsigned int d_type; char d_name[255]; }; @@ -221,7 +217,7 @@ static void draw_dirlist(char *curdir, struct my_dirent **namelist, int n, int s pos = start + i; if (pos < 0) continue; if (pos > 26) break; - if (namelist[i+1]->d_type & DT_DIR) { + if (namelist[i+1]->d_type & FIO_S_IFDIR) { smalltext_out16_lim(14, pos*10, "/", 0xd7ff, 1); smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 80-3); } else { @@ -236,9 +232,10 @@ static void draw_dirlist(char *curdir, struct my_dirent **namelist, int n, int s static int scandir_cmp(const void *p1, const void *p2) { struct my_dirent **d1 = (struct my_dirent **)p1, **d2 = (struct my_dirent **)p2; - if ((*d1)->d_type == (*d2)->d_type) return strcasecmp((*d1)->d_name, (*d2)->d_name); - if ((*d1)->d_type & DT_DIR) return -1; // put before - if ((*d2)->d_type & DT_DIR) return 1; + if ((*d1)->d_type & (*d2)->d_type & FIO_S_IFDIR) + return strcasecmp((*d1)->d_name, (*d2)->d_name); + if ((*d1)->d_type & FIO_S_IFDIR) return -1; // put before + if ((*d2)->d_type & FIO_S_IFDIR) return 1; return strcasecmp((*d1)->d_name, (*d2)->d_name); } @@ -297,7 +294,7 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out, { ent = malloc(sizeof(*ent)); if (ent == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; } - ent->d_type = sce_ent.d_stat.st_attr; + ent->d_type = sce_ent.d_stat.st_mode; strncpy(ent->d_name, sce_ent.d_name, sizeof(ent->d_name)); ent->d_name[sizeof(ent->d_name)-1] = 0; if (filter == NULL || filter(ent)) @@ -350,7 +347,8 @@ static char *romsel_loop(char *curr_path) // is this a dir or a full path? memset(&cpstat, 0, sizeof(cpstat)); iret = sceIoGetstat(curr_path, &cpstat); - if (iret >= 0 && (cpstat.st_attr & FIO_SO_IFREG)) { // file + if (iret >= 0 && (cpstat.st_mode & FIO_S_IFDIR)); // dir + else if (iret >= 0 && (cpstat.st_mode & FIO_S_IFREG)) { // file char *p; for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--); if (p > curr_path) { @@ -359,7 +357,6 @@ static char *romsel_loop(char *curr_path) } else strcpy(curr_path, "ms0:/"); } - else if (iret >= 0 && (cpstat.st_attr & FIO_SO_IFDIR)); // dir else strcpy(curr_path, "ms0:/"); // something else n = my_scandir(curr_path, &namelist, scandir_filter, scandir_cmp); @@ -394,14 +391,10 @@ static char *romsel_loop(char *curr_path) if(inp & BTN_L) { sel-=24; if (sel < 0) sel = 0; } if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } if(inp & BTN_R) { sel+=24; if (sel > n-2) sel = n-2; } - if(inp & BTN_CIRCLE) { // enter dir/select - if (namelist[sel+1]->d_type & DT_REG) { - strcpy(romFileName, curr_path); - strcat(romFileName, "/"); - strcat(romFileName, namelist[sel+1]->d_name); - ret = romFileName; - break; - } else if (namelist[sel+1]->d_type & DT_DIR) { + if(inp & BTN_CIRCLE) // enter dir/select + { + if (namelist[sel+1]->d_type & FIO_S_IFDIR) + { int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; char *p, *newdir = malloc(newlen); if (strcmp(namelist[sel+1]->d_name, "..") == 0) { @@ -422,6 +415,14 @@ static char *romsel_loop(char *curr_path) free(newdir); break; } + else if (namelist[sel+1]->d_type & FIO_S_IFREG) + { + strcpy(romFileName, curr_path); + strcat(romFileName, "/"); + strcat(romFileName, namelist[sel+1]->d_name); + ret = romFileName; + break; + } } if(inp & BTN_X) break; // cancel } @@ -692,14 +693,14 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ text_out16(x, y, "Done"); if (sel < opt_cnt) { - text_out16(80+30, 225, "Press a button to bind/unbind"); - text_out16(80+30, 235, "Use SELECT to clear"); - text_out16(80+30, 245, "To bind UP/DOWN, hold SELECT"); - text_out16(80+30, 255, "Select \"Done\" to exit"); + text_out16(80+30, 220, "Press a button to bind/unbind"); + text_out16(80+30, 230, "Use SELECT to clear"); + text_out16(80+30, 240, "To bind UP/DOWN, hold SELECT"); + text_out16(80+30, 250, "Select \"Done\" to exit"); } else { - text_out16(80+30, 235, "Use Options -> Save cfg"); - text_out16(80+30, 245, "to save controls"); - text_out16(80+30, 255, "Press X or O to exit"); + text_out16(80+30, 230, "Use Options -> Save cfg"); + text_out16(80+30, 240, "to save controls"); + text_out16(80+30, 250, "Press X or O to exit"); } menu_draw_end(); } @@ -787,7 +788,7 @@ me_bind_action emuctrl_actions[] = static void kc_sel_loop(void) { - int menu_sel = 3, menu_sel_max = 3; + int menu_sel = 5, menu_sel_max = 5; unsigned long inp = 0; menu_id selected_id; @@ -824,7 +825,7 @@ menu_entry cdopt_entries[] = { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, - { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, + { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, @@ -1160,6 +1161,7 @@ menu_entry opt2_entries[] = { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x00008, 0, 0, 1, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x00020, 0, 0, 1, 1 }, { "Status line in main menu", MB_ONOFF, MA_OPT2_STATUS_LINE, ¤tConfig.EmuOpt, 0x20000, 0, 0, 1, 1 }, + { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 }, { "Disable frame limiter", MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, ¤tConfig.EmuOpt, 0x40000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1630,10 +1632,10 @@ static void menu_loop_root(void) { char curr_path[PATH_MAX], *selfname; FILE *tstf; - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else getcwd(curr_path, PATH_MAX); @@ -1775,10 +1777,10 @@ int menu_loop_tray(void) menu_gfx_prepare(); - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else { @@ -1802,7 +1804,7 @@ int menu_loop_tray(void) if (selfname) { int ret = -1; cd_img_type cd_type; - cd_type = emu_cdCheck(NULL); + cd_type = emu_cdCheck(NULL, romFileName); if (cd_type != CIT_NOT_CD) ret = Insert_CD(romFileName, cd_type); if (ret != 0) {