uncommited code for 151 release (PSP suspend, file browser, etc)

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@554 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-07-18 13:04:38 +00:00
parent 6589c840ca
commit dfa8d77a42
8 changed files with 78 additions and 57 deletions

View file

@ -421,7 +421,8 @@ void debug_menu_loop(void)
case 2: clear_screen(); case 2: clear_screen();
emu_forcedFrame(0); emu_forcedFrame(0);
darken_screen(); darken_screen();
PDebugShowSpriteStats(SCREEN_BUFFER, SCREEN_WIDTH); break; PDebugShowSpriteStats((unsigned short *)SCREEN_BUFFER + (SCREEN_HEIGHT/2 - 240/2)*SCREEN_WIDTH +
SCREEN_WIDTH/2 - 320/2, SCREEN_WIDTH); break;
case 3: clear_screen(); case 3: clear_screen();
PDebugShowPalette(SCREEN_BUFFER, SCREEN_WIDTH); PDebugShowPalette(SCREEN_BUFFER, SCREEN_WIDTH);
PDebugShowSprite((unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH*120+SCREEN_WIDTH/2+16, PDebugShowSprite((unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH*120+SCREEN_WIDTH/2+16,

View file

@ -237,12 +237,12 @@ int gp2x_touchpad_read(int *x, int *y)
if (touchdev < 0) return -1; if (touchdev < 0) return -1;
retval = read(touchdev, &event, sizeof(event)); retval = read(touchdev, &event, sizeof(event));
if (retval < 0) { if (retval <= 0) {
printf("touch read failed %i %i\n", retval, errno); printf("touch read failed %i %i\n", retval, errno);
return -1; return -1;
} }
// this is to ignore the messed-up 4.1.x driver // this is to ignore the messed-up 4.1.x driver
if (retval == 0) zero_seen = 1; if (event.pressure == 0) zero_seen = 1;
if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16; if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16;
if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16; if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16;

View file

@ -22,6 +22,7 @@
#include "../common/config.h" #include "../common/config.h"
#include "../common/lprintf.h" #include "../common/lprintf.h"
#include "../../Pico/PicoInt.h" #include "../../Pico/PicoInt.h"
#include "../../Pico/cd/cue.h"
#define OSD_FPS_X 432 #define OSD_FPS_X 432
@ -34,7 +35,7 @@ int sceAudioOutput2GetRestSample();
char romFileName[PATH_MAX]; char romFileName[PATH_MAX];
unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. 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; static unsigned int noticeMsgTime = 0;
int reset_timing = 0; // do we need this? int reset_timing = 0; // do we need this?
@ -1118,15 +1119,31 @@ void emu_HandleResume(void)
{ {
if (!(PicoAHW & PAHW_MCD)) return; if (!(PicoAHW & PAHW_MCD)) return;
// reopen files.. // reopen first CD track
if (Pico_mcd->TOC.Tracks[0].F != NULL) 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); 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"); lprintf("reopen %s\n", Pico_mcd->TOC.Tracks[0].F != NULL ? "ok" : "failed");
if (cue_data != NULL) cue_destroy(cue_data);
} }
mp3_reopen_file(); mp3_reopen_file();
if (!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
cdda_start_play();
} }

View file

@ -15,11 +15,11 @@ enum TPicoGameState {
PGS_Menu, PGS_Menu,
PGS_RestartRun, PGS_RestartRun,
PGS_Suspending, PGS_Suspending,
PGS_SuspendAck, PGS_SuspendWake,
}; };
extern char romFileName[]; extern char romFileName[];
extern int engineState; extern int engineState, engineStateSuspend;
void emu_Init(void); void emu_Init(void);

View file

@ -69,11 +69,15 @@ int pico_main(void)
break; break;
case PGS_Suspending: case PGS_Suspending:
while (engineState == PGS_Suspending || engineState == PGS_SuspendAck) { while (engineState == PGS_Suspending)
if (engineState == PGS_Suspending)
engineState = PGS_SuspendAck;
psp_wait_suspend(); psp_wait_suspend();
} break;
case PGS_SuspendWake:
psp_unhandled_suspend = 0;
psp_resume_suspend();
emu_HandleResume();
engineState = engineStateSuspend;
break; break;
case PGS_RestartRun: case PGS_RestartRun:
@ -81,8 +85,10 @@ int pico_main(void)
case PGS_Running: case PGS_Running:
if (psp_unhandled_suspend) { if (psp_unhandled_suspend) {
psp_unhandled_suspend = 0;
psp_resume_suspend(); psp_resume_suspend();
emu_HandleResume(); emu_HandleResume();
break;
} }
emu_Loop(); emu_Loop();
#ifdef GPROF #ifdef GPROF

View file

@ -174,13 +174,9 @@ void menu_romload_end(void)
// -------------- ROM selector -------------- // -------------- ROM selector --------------
// SceIoDirent
#define DT_DIR FIO_SO_IFDIR
#define DT_REG FIO_SO_IFREG
struct my_dirent struct my_dirent
{ {
unsigned char d_type; unsigned int d_type;
char d_name[255]; 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; pos = start + i;
if (pos < 0) continue; if (pos < 0) continue;
if (pos > 26) break; 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, pos*10, "/", 0xd7ff, 1);
smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 80-3); smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 80-3);
} else { } 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) static int scandir_cmp(const void *p1, const void *p2)
{ {
struct my_dirent **d1 = (struct my_dirent **)p1, **d2 = (struct my_dirent **)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 & (*d2)->d_type & FIO_S_IFDIR)
if ((*d1)->d_type & DT_DIR) return -1; // put before return strcasecmp((*d1)->d_name, (*d2)->d_name);
if ((*d2)->d_type & DT_DIR) return 1; 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); 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)); ent = malloc(sizeof(*ent));
if (ent == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; } 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)); strncpy(ent->d_name, sce_ent.d_name, sizeof(ent->d_name));
ent->d_name[sizeof(ent->d_name)-1] = 0; ent->d_name[sizeof(ent->d_name)-1] = 0;
if (filter == NULL || filter(ent)) if (filter == NULL || filter(ent))
@ -350,7 +347,8 @@ static char *romsel_loop(char *curr_path)
// is this a dir or a full path? // is this a dir or a full path?
memset(&cpstat, 0, sizeof(cpstat)); memset(&cpstat, 0, sizeof(cpstat));
iret = sceIoGetstat(curr_path, &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; char *p;
for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--); for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--);
if (p > curr_path) { if (p > curr_path) {
@ -359,7 +357,6 @@ static char *romsel_loop(char *curr_path)
} }
else strcpy(curr_path, "ms0:/"); else strcpy(curr_path, "ms0:/");
} }
else if (iret >= 0 && (cpstat.st_attr & FIO_SO_IFDIR)); // dir
else strcpy(curr_path, "ms0:/"); // something else else strcpy(curr_path, "ms0:/"); // something else
n = my_scandir(curr_path, &namelist, scandir_filter, scandir_cmp); 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_L) { sel-=24; if (sel < 0) sel = 0; }
if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } 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_R) { sel+=24; if (sel > n-2) sel = n-2; }
if(inp & BTN_CIRCLE) { // enter dir/select if(inp & BTN_CIRCLE) // enter dir/select
if (namelist[sel+1]->d_type & DT_REG) { {
strcpy(romFileName, curr_path); if (namelist[sel+1]->d_type & FIO_S_IFDIR)
strcat(romFileName, "/"); {
strcat(romFileName, namelist[sel+1]->d_name);
ret = romFileName;
break;
} else if (namelist[sel+1]->d_type & DT_DIR) {
int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;
char *p, *newdir = malloc(newlen); char *p, *newdir = malloc(newlen);
if (strcmp(namelist[sel+1]->d_name, "..") == 0) { if (strcmp(namelist[sel+1]->d_name, "..") == 0) {
@ -422,6 +415,14 @@ static char *romsel_loop(char *curr_path)
free(newdir); free(newdir);
break; 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 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"); text_out16(x, y, "Done");
if (sel < opt_cnt) { if (sel < opt_cnt) {
text_out16(80+30, 225, "Press a button to bind/unbind"); text_out16(80+30, 220, "Press a button to bind/unbind");
text_out16(80+30, 235, "Use SELECT to clear"); text_out16(80+30, 230, "Use SELECT to clear");
text_out16(80+30, 245, "To bind UP/DOWN, hold SELECT"); text_out16(80+30, 240, "To bind UP/DOWN, hold SELECT");
text_out16(80+30, 255, "Select \"Done\" to exit"); text_out16(80+30, 250, "Select \"Done\" to exit");
} else { } else {
text_out16(80+30, 235, "Use Options -> Save cfg"); text_out16(80+30, 230, "Use Options -> Save cfg");
text_out16(80+30, 245, "to save controls"); text_out16(80+30, 240, "to save controls");
text_out16(80+30, 255, "Press X or O to exit"); text_out16(80+30, 250, "Press X or O to exit");
} }
menu_draw_end(); menu_draw_end();
} }
@ -787,7 +788,7 @@ me_bind_action emuctrl_actions[] =
static void kc_sel_loop(void) 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; unsigned long inp = 0;
menu_id selected_id; menu_id selected_id;

View file

@ -373,6 +373,9 @@ void mp3_start_play(FILE *f, int pos)
mp3_fname = fname; mp3_fname = fname;
} }
// clear decoder state
sceAudiocodecInit(mp3_codec_struct, 0x1002);
// seek.. // seek..
mp3_src_pos = (int) (((float)pos / 1023.0f) * (float)mp3_src_size); mp3_src_pos = (int) (((float)pos / 1023.0f) * (float)mp3_src_size);
sceIoLseek32(mp3_handle, mp3_src_pos, PSP_SEEK_SET); sceIoLseek32(mp3_handle, mp3_src_pos, PSP_SEEK_SET);

View file

@ -26,14 +26,14 @@ extern int pico_main(void);
#ifndef FW15 #ifndef FW15
PSP_MODULE_INFO("PicoDrive", 0, 1, 50); PSP_MODULE_INFO("PicoDrive", 0, 1, 51);
PSP_HEAP_SIZE_MAX(); PSP_HEAP_SIZE_MAX();
int main() { return pico_main(); } /* just a wrapper */ int main() { return pico_main(); } /* just a wrapper */
#else #else
PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 50); PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 51);
PSP_MAIN_THREAD_ATTR(0); PSP_MAIN_THREAD_ATTR(0);
int main() int main()
@ -58,10 +58,11 @@ int main()
#endif #endif
int psp_unhandled_suspend = 0;
unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE]; unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE];
void *psp_screen = VRAM_FB0; void *psp_screen = VRAM_FB0;
int psp_unhandled_suspend = 0;
static int current_screen = 0; /* front bufer */ static int current_screen = 0; /* front bufer */
@ -79,26 +80,19 @@ static int exit_callback(int arg1, int arg2, void *common)
/* Power Callback */ /* Power Callback */
static int power_callback(int unknown, int pwrflags, void *common) 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); lprintf("power_callback: flags: 0x%08X\n", pwrflags);
/* check for power switch and suspending as one is manual and the other automatic */ /* 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 (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING || pwrflags & PSP_POWER_CB_STANDBY)
{ {
if (engineState != PGS_Suspending && engineState != PGS_SuspendAck) { psp_unhandled_suspend = 1;
old_state = engineState; if (engineState != PGS_Suspending)
engineState = PGS_Suspending; engineStateSuspend = engineState;
} sceKernelDelayThread(100000); // ??
for (i = 0; i < 10 && engineState != PGS_SuspendAck; i++)
sceKernelDelayThread(100*1024);
} }
else if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE) else if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE)
{ {
engineState = old_state; engineState = PGS_SuspendWake;
psp_unhandled_suspend = 1;
} }
//sceDisplayWaitVblankStart(); //sceDisplayWaitVblankStart();
@ -288,7 +282,6 @@ void psp_resume_suspend(void)
} }
if (fd >= 0) sceIoClose(fd); if (fd >= 0) sceIoClose(fd);
sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart();
psp_unhandled_suspend = 0;
if (i < 30) if (i < 30)
lprintf("io resumed after %i tries\n", i); lprintf("io resumed after %i tries\n", i);
else { else {