I keep having problems with my app hanging on exit, I get the "Please wait..." screen and it just never quits. I am running 3.03OE-C and FileAssistant++ to launch my elf binary. When I press the start button to quit everything works fine, though I get a screen with some white vertical bars on the left hand side before I get dropped back to FileAssistant++. However when I try to quit the application through the home button exit callback my PSP freezes in the "Please wait..." screen.
I have tried adding the sceKernelDisplayWaitVblankStart() and sceKernelDelayThread(0) before and after sceKernelExitGame() but that didn't change anything. I've tried putting sceKernelExitGame in the exit callback function, but that didn't help. Now I've been trying to gracefully clean up the callback function and threads, but that doesn't seem to relieve the problem either. I've included the code I currently have below, I have run out of ideas and after much searching around on the forums and on google I've concluded I've come to a dead end.
Could anybody say what I'm doing wrong, or what I could do to resolve the issue? Is it a problem of running the program from FileAssistant, or with the 3.03OE-C firmware or am I just missing something completely here?
Code: Select all
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
PSP_MODULE_INFO("Test v1.0", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
int done = false;
int exit_callback(int arg1, int arg2, void* common) {
done = true;
return 0;
}
int callback_thread(SceSize args, void* argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, 0);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return cbid;
}
int setup_callbacks() {
int thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
if (0 <= thid)
sceKernelStartThread(thid, 0, 0);
return thid;
}
void deinit_callbacks(int thid) {
sceKernelWakeupThread(thid);
sceKernelWaitThreadEnd(thid, 0);
int cbid = sceKernelGetThreadExitStatus(thid);
//sceKernelUnregisterExitCallback();
sceKernelDeleteCallback(cbid);
sceKernelDeleteThread(thid);
}
int main(int argc, char** argv) {
SceCtrlData pad;
int cb_thread = setup_callbacks();
while (!done) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_START)
done = true;
}
deinit_callbacks(cb_thread);
sceDisplayWaitVblankStart();
sceKernelExitGame();
sceKernelDelayThread(0);
sceKernelExitThread(0);
return 0;
}
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o -lstdc++ -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf