#include <stdlib.h>
#include <wchar.h>
#include <unistd.h>
-#include <dirent.h> // for opendir
#include <sys/syslimits.h> // PATH_MAX
#include <pspdisplay.h>
pspKeyUnkn, pspKeyUnkn, pspKeyUnkn, pspKeyUnkn, pspKeyUnkn, pspKeyUnkn, pspKeyUnkn, pspKeyUnkn
};
-unsigned int __attribute__((aligned(16))) guCmdList[1024]; // TODO: adjust, mv
-
static unsigned char bg_buffer[480*272*2] __attribute__((aligned(16))); // TODO: move to vram?
#define menu_screen psp_screen
if (repeats == 2 || repeats == 4) wait /= 2;
if (repeats == 6) wait = 15;
- for (i = 0; i < 6 && inp_prev == psp_pad_read(); i++) {
+ for (i = 0; i < 6 && inp_prev == psp_pad_read(1); i++) {
if (i == 0) repeats++;
psp_msleep(wait);
}
- while ( !((ret = psp_pad_read()) & interesting) ) {
+ while ( !((ret = psp_pad_read(1)) & interesting) ) {
psp_msleep(50);
release = 1;
}
// for (i = 272; i >= 0; i--, dst += 512, src += 480)
// memcpy32((int *)dst, (int *)src, 480*2/4);
+ sceGuSync(0,0); // sync with prev
sceGuStart(GU_DIRECT, guCmdList);
sceGuCopyImage(GU_PSM_5650, 0, 0, 480, 272, 480, bg_buffer, 0, 0, 512, menu_screen);
sceGuFinish();
- sceGuSync(0, GU_SYNC_FINISH);
+ sceGuSync(0,0);
}
static void menu_draw_end(void)
{
- sceDisplayWaitVblankStart();
- psp_video_flip();
+ psp_video_flip(1);
}
char d_name[255];
};
-// rrrr rggg gggb bbbb
+// bbbb bggg gggr rrrr
static unsigned short file2color(const char *fname)
{
const char *ext = fname + strlen(fname) - 3;
if (ext < fname) ext = fname;
for (i = 0; i < sizeof(rom_exts)/sizeof(rom_exts[0]); i++)
- if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff;
+ if (strcasecmp(ext, rom_exts[i]) == 0) return 0xfdf7;
for (i = 0; i < sizeof(other_exts)/sizeof(other_exts[0]); i++)
if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5;
return 0xffff;
if (pos < 0) continue;
if (pos > 26) break;
if (namelist[i+1]->d_type & DT_DIR) {
- smalltext_out16_lim(14, pos*10, "/", 0xfff6, 1);
- smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xfff6, 53-3);
+ smalltext_out16_lim(14, pos*10, "/", 0xd7ff, 1);
+ smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 53-3);
} else {
unsigned short color = file2color(namelist[i+1]->d_name);
smalltext_out16_lim(14, pos*10, namelist[i+1]->d_name, color, 53-2);
dir_uid = sceIoDopen(dir);
if (dir_uid >= 0)
{
+ /* it is very important to clear SceIoDirent to be passed to sceIoDread(), */
+ /* or else it may crash, probably misinterpreting something in it. */
+ memset(&sce_ent, 0, sizeof(sce_ent));
ret = sceIoDread(dir_uid, &sce_ent);
if (ret < 0)
{
if (ent == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
ent->d_type = sce_ent.d_stat.st_attr;
strncpy(ent->d_name, sce_ent.d_name, sizeof(ent->d_name));
- ent->d_name[sizeof(ent->d_name)] = 0;
+ ent->d_name[sizeof(ent->d_name)-1] = 0;
if (filter == NULL || filter(ent))
namelist[name_count++] = ent;
else free(ent);
namelist = tmp;
}
+ memset(&sce_ent, 0, sizeof(sce_ent));
ret = sceIoDread(dir_uid, &sce_ent);
}
static char *romsel_loop(char *curr_path)
{
struct my_dirent **namelist;
- DIR *dir;
- int n, sel = 0;
+ int n, iret, sel = 0;
unsigned long inp = 0;
char *ret = NULL, *fname = NULL;
+ SceIoStat cpstat;
// is this a dir or a full path?
- if ((dir = opendir(curr_path))) {
- closedir(dir);
- } else {
+ memset(&cpstat, 0, sizeof(cpstat));
+ iret = sceIoGetstat(curr_path, &cpstat);
+ if (iret >= 0 && (cpstat.st_attr & FIO_SO_IFREG)) { // file
char *p;
for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--);
*p = 0;
fname = p+1;
}
+ 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);
if (n < 0) {
// try root..
- n = my_scandir("/", &namelist, scandir_filter, scandir_cmp);
+ n = my_scandir("ms0:/", &namelist, scandir_filter, scandir_cmp);
if (n < 0) {
// oops, we failed
lprintf("scandir failed, dir: "); lprintf(curr_path); lprintf("\n");
char *start = curr_path;
p = start + strlen(start) - 1;
while (*p == '/' && p > start) p--;
- while (*p != '/' && p > start) p--;
- if (p <= start) strcpy(newdir, "/");
+ while (*p != '/' && *p != ':' && p > start) p--;
+ if (p <= start || *p == ':' || p[-1] == ':') strcpy(newdir, "ms0:/");
else { strncpy(newdir, start, p-start); newdir[p-start] = 0; }
} else {
strcpy(newdir, curr_path);
{ "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, ¤tConfig.PicoOpt,0x0004, 0, 0, 1 },
{ "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, ¤tConfig.PicoOpt,0x0001, 0, 0, 1 },
{ "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,¤tConfig.PicoOpt,0x0002, 0, 0, 1 },
- { "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, ¤tConfig.EmuOpt, 0x8000, 0, 0, 1 },
- { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1 },
+// { "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, ¤tConfig.EmuOpt, 0x8000, 0, 0, 1 },
+// { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1 },
{ "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1 },
{ "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1 },
{ "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 },
if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) &&
selected_id == MA_OPT2_GAMMA) {
- while ((inp = psp_pad_read()) & (BTN_LEFT|BTN_RIGHT)) {
+ while ((inp = psp_pad_read(1)) & (BTN_LEFT|BTN_RIGHT)) {
currentConfig.gamma += (inp & BTN_LEFT) ? -1 : 1;
if (currentConfig.gamma < 1) currentConfig.gamma = 1;
if (currentConfig.gamma > 300) currentConfig.gamma = 300;
menu_entry opt_entries[] =
{
{ NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 },
- { "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, ¤tConfig.EmuOpt, 0x4000, 0, 0, 1 },
{ "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x0001, 0, 3, 1 },
{ "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x0040, 0, 0, 1 },
{ "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x0080, 0, 0, 1 },
{ "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },
{ "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },
+ { NULL, MB_NONE, MA_OPT_CPU_CLOCKS, NULL, 0, 0, 0, 1 },
{ "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },
{ "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },
}
text_out16(x, y, "Confirm savestate %s", str);
break;
+ case MA_OPT_CPU_CLOCKS:
+ text_out16(x, y, "CPU/bus clock %3i/%3iMHz", currentConfig.CPUclock, currentConfig.CPUclock/2);
+ break;
case MA_OPT_SAVECFG:
str24[0] = 0;
if (config_slot != 0) sprintf(str24, " (profile: %i)", config_slot);
} else {state_slot--; if (state_slot < 0) state_slot = 9;
}
break;
+ case MA_OPT_CPU_CLOCKS:
+ while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) {
+ currentConfig.CPUclock += (inp & BTN_LEFT) ? -1 : 1;
+ if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19;
+ if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333;
+ draw_menu_options(menu_sel); // will wait vsync
+ }
+ break;
case MA_OPT_SAVECFG:
case MA_OPT_SAVECFG_GAME:
case MA_OPT_LOADCFG:
/* make sure action buttons are not pressed on entering menu */
draw_menu_root(menu_sel);
- while (psp_pad_read() & (BTN_X|BTN_CIRCLE|BTN_SELECT)) psp_msleep(50);
+ while (psp_pad_read(1) & (BTN_X|BTN_CIRCLE|BTN_SELECT)) psp_msleep(50);
for (;;)
{
if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop();
if( inp & (BTN_SELECT|BTN_CIRCLE)) {
if (rom_data) {
- while (psp_pad_read() & (BTN_SELECT|BTN_CIRCLE)) psp_msleep(50); // wait until released
+ while (psp_pad_read(1) & (BTN_SELECT|BTN_CIRCLE)) psp_msleep(50); // wait until released
engineState = PGS_Running;
break;
}
{
case MA_MAIN_RESUME_GAME:
if (rom_data) {
- while (psp_pad_read() & BTN_X) psp_msleep(50);
+ while (psp_pad_read(1) & BTN_X) psp_msleep(50);
engineState = PGS_Running;
return;
}
/* make sure action buttons are not pressed on entering menu */
draw_menu_tray(menu_sel);
- while (psp_pad_read() & BTN_X) psp_msleep(50);
+ while (psp_pad_read(1) & BTN_X) psp_msleep(50);
for (;;)
{