#include "../common/config.h"
#include "../common/lprintf.h"
#include "../../Pico/PicoInt.h"
+#include "../../Pico/cd/cue.h"
#define OSD_FPS_X 432
char romFileName[PATH_MAX];
unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword..
-int engineState = PGS_Menu;
+int engineState = PGS_Menu, engineStateSuspend;
static unsigned int noticeMsgTime = 0;
int reset_timing = 0; // do we need this?
{
if (!(PicoAHW & PAHW_MCD)) return;
- // reopen files..
+ // reopen first CD track
if (Pico_mcd->TOC.Tracks[0].F != NULL)
{
- lprintf("emu_HandleResume: reopen %s\n", romFileName);
+ char *fname = romFileName;
+ int len = strlen(romFileName);
+ cue_data_t *cue_data = NULL;
+
+ if (len > 4 && strcasecmp(fname + len - 4, ".cue") == 0)
+ {
+ cue_data = cue_parse(romFileName);
+ if (cue_data != NULL)
+ fname = cue_data->tracks[1].fname;
+ }
+
+ lprintf("emu_HandleResume: reopen %s\n", fname);
pm_close(Pico_mcd->TOC.Tracks[0].F);
- Pico_mcd->TOC.Tracks[0].F = pm_open(romFileName);
+ Pico_mcd->TOC.Tracks[0].F = pm_open(fname);
lprintf("reopen %s\n", Pico_mcd->TOC.Tracks[0].F != NULL ? "ok" : "failed");
+
+ if (cue_data != NULL) cue_destroy(cue_data);
}
mp3_reopen_file();
+
+ if (!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
+ cdda_start_play();
}
// -------------- 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];
};
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 {
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);
}
{
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))
// 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) {
}
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);
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) {
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
}
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();
}
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;
#ifndef FW15
-PSP_MODULE_INFO("PicoDrive", 0, 1, 50);
+PSP_MODULE_INFO("PicoDrive", 0, 1, 51);
PSP_HEAP_SIZE_MAX();
int main() { return pico_main(); } /* just a wrapper */
#else
-PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 50);
+PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 51);
PSP_MAIN_THREAD_ATTR(0);
int main()
#endif
+int psp_unhandled_suspend = 0;
+
unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE];
void *psp_screen = VRAM_FB0;
-int psp_unhandled_suspend = 0;
static int current_screen = 0; /* front bufer */
/* Power Callback */
static int power_callback(int unknown, int pwrflags, void *common)
{
- static int old_state = PGS_Menu;
- int i;
-
lprintf("power_callback: flags: 0x%08X\n", pwrflags);
/* check for power switch and suspending as one is manual and the other automatic */
if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING || pwrflags & PSP_POWER_CB_STANDBY)
{
- if (engineState != PGS_Suspending && engineState != PGS_SuspendAck) {
- old_state = engineState;
- engineState = PGS_Suspending;
- }
- for (i = 0; i < 10 && engineState != PGS_SuspendAck; i++)
- sceKernelDelayThread(100*1024);
-
+ psp_unhandled_suspend = 1;
+ if (engineState != PGS_Suspending)
+ engineStateSuspend = engineState;
+ sceKernelDelayThread(100000); // ??
}
else if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE)
{
- engineState = old_state;
- psp_unhandled_suspend = 1;
+ engineState = PGS_SuspendWake;
}
//sceDisplayWaitVblankStart();
}
if (fd >= 0) sceIoClose(fd);
sceDisplayWaitVblankStart();
- psp_unhandled_suspend = 0;
if (i < 30)
lprintf("io resumed after %i tries\n", i);
else {