X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=psp%2Fpsp.c;h=cdf26ae2436a3c1858ede9289ce66e7dcf8af996;hb=426ecc582f3f6f3d04f7b7ae25b548be7178c4fd;hp=99b9084c5fa585bbbfdeea3a82751a695ff8c5d6;hpb=63b796cabb7d484d648755810f79bebc8f0fd689;p=libpicofe.git diff --git a/psp/psp.c b/psp/psp.c index 99b9084..cdf26ae 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -14,14 +14,43 @@ #include #include #include +#include #include "psp.h" #include "emu.h" #include "../common/lprintf.h" -PSP_MODULE_INFO("PicoDrive", 0, 1, 34); +extern int pico_main(void); + +#ifndef FW15 + +PSP_MODULE_INFO("PicoDrive", 0, 1, 35); PSP_HEAP_SIZE_MAX(); +int main() { return pico_main(); } /* just a wrapper */ + +#else + +PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 35); +PSP_MAIN_THREAD_ATTR(0); + +int main() +{ + SceUID thid; + + /* this is the thing we need the kernel mode for */ + pspSdkInstallNoDeviceCheckPatch(); + + thid = sceKernelCreateThread("pico_main", (SceKernelThreadEntry) pico_main, 32, 0x2000, PSP_THREAD_ATTR_USER, NULL); + if (thid >= 0) + sceKernelStartThread(thid, 0, 0); + sceKernelExitDeleteThread(0); + + return 0; +} + +#endif + unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE]; void *psp_screen = VRAM_FB0; @@ -41,13 +70,22 @@ static int exit_callback(int arg1, int arg2, void *common) /* Power Callback */ static int power_callback(int unknown, int pwrflags, void *common) { + static int old_state = PGS_Menu; + + 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) + if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING || pwrflags & PSP_POWER_CB_STANDBY) { - lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags); - engineState = PGS_Menu; + if (engineState != PGS_Suspending) { + old_state = engineState; + engineState = PGS_Suspending; + } } - sceDisplayWaitVblankStart(); + else if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE) + engineState = old_state; + + //sceDisplayWaitVblankStart(); return 0; } @@ -79,7 +117,7 @@ void psp_init(void) lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id, sceKernelGetThreadCurrentPriority()); - thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, 0); + thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL); if (thid >= 0) { sceKernelStartThread(thid, 0, 0); @@ -127,6 +165,7 @@ void psp_init(void) void psp_finish(void) { + lprintf("psp_finish..\n"); sceGuTerm(); //sceKernelSleepThread(); @@ -208,9 +247,16 @@ char *psp_get_status_line(void) return buff; } +void psp_wait_suspend(void) +{ + // probably should do something smarter here? + sceDisplayWaitVblankStart(); +} + /* alt logging */ #define LOG_FILE "log.txt" +#ifndef LPRINTF_STDIO typedef struct _log_entry { char buff[256]; @@ -218,8 +264,9 @@ typedef struct _log_entry } log_entry; static log_entry *le_root = NULL; +#endif -void lprintf_f(const char *fmt, ...) +void lprintf(const char *fmt, ...) { va_list vl;