aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/psp/psp_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/psp/psp_main.cpp')
-rw-r--r--backends/platform/psp/psp_main.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp
index 0af7ebf269..74363e4ac9 100644
--- a/backends/platform/psp/psp_main.cpp
+++ b/backends/platform/psp/psp_main.cpp
@@ -31,12 +31,16 @@
#include <pspdebug.h>
#endif
+#include <psppower.h>
+
#include <common/system.h>
#include <engines/engine.h>
#include <base/main.h>
#include <base/plugins.h>
+#include "backends/platform/psp/powerman.h"
+
-#include "osys_psp_gu.h"
+#include "osys_psp.h"
#include "./trace.h"
@@ -58,9 +62,8 @@ PSP_MODULE_INFO("SCUMMVM-PSP", 0, 1, 1);
* code (crt0.c) starts this program in to be in usermode
* even though the module was started in kernelmode
*/
-#ifndef USERSPACE_ONLY
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
-#endif
+PSP_HEAP_SIZE_KB(-128); //Leave 128kb for thread stacks, etc.
#ifndef USERSPACE_ONLY
@@ -91,17 +94,36 @@ void loaderInit() {
#endif
/* Exit callback */
-SceKernelCallbackFunction exit_callback(int /*arg1*/, int /*arg2*/, void * /*common*/) {
+int exit_callback(void) {
sceKernelExitGame();
return 0;
}
+/* Function for handling suspend/resume */
+void power_callback(int , int powerinfo) {
+ if (powerinfo & PSP_POWER_CB_POWER_SWITCH || powerinfo & PSP_POWER_CB_SUSPENDING) {
+ PowerMan.suspend();
+ } else if (powerinfo & PSP_POWER_CB_RESUME_COMPLETE) {
+ PowerMan.resume();
+ }
+}
+
/* Callback thread */
int CallbackThread(SceSize /*size*/, void *arg) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", (SceKernelCallbackFunction)exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
+ /* Set up callbacks for PSPIoStream */
+
+ cbid = sceKernelCreateCallback("Power Callback", (SceKernelCallbackFunction)power_callback, 0);
+ if (cbid >= 0) {
+ if(scePowerRegisterCallback(-1, cbid) < 0) {
+ PSPDebugTrace("SetupCallbacks(): Couldn't register callback for power_callback\n");
+ }
+ } else {
+ PSPDebugTrace("SetupCallbacks(): Couldn't create a callback for power_callback\n");
+ }
sceKernelSleepThreadCB();
return 0;
@@ -119,18 +141,25 @@ int SetupCallbacks(void) {
#undef main
int main(void) {
+ //change clock rate to 333mhz
+ scePowerSetClockFrequency(333, 333, 166);
+
+ PowerManager::instance(); // Setup power manager
+
SetupCallbacks();
static const char *argv[] = { "scummvm", NULL };
static int argc = sizeof(argv)/sizeof(char *)-1;
- g_system = new OSystem_PSP_GU();
+ g_system = new OSystem_PSP();
assert(g_system);
int res = scummvm_main(argc, argv);
g_system->quit(); // TODO: Consider removing / replacing this!
+ PowerManager::destroy(); // get rid of PowerManager
+
sceKernelSleepThread();
return res;