![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on My app keeps freezing on exit. within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I'm trying to port some of my SDL apps to PSP but I can't get them to exit without either ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
I'm trying to port some of my SDL apps to PSP but I can't get them to exit without either freezing the PSP (or app), or turning the PSP off.
As a test app, I made an openGL+SDL app that makes a square change colour when you press the arrows. It runs fine, the problem is having a button that exits the app properly. I've concluded that exit(0) turns the whole PSP off. So, to try and focus on the exiting part, I stripped away all the code so that it is just a game loop that is exited when the start button is pressed. It locks up though. How do I get it to work properly?! Here's the code Code:
#include <SDL/SDL.h>
#include <stdlib.h>
#include <pspctrl.h>
#include <pspkernel.h>
PSP_MODULE_INFO("simpleApp", 0, 1, 1);
//using namespace std;
bool isRunning;
int buttonDown;
SceCtrlData pad;
int main(int argc, char** args)
{
isRunning = true;
while (isRunning)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons != 0 & buttonDown != 1)
{
if(pad.Buttons & PSP_CTRL_START)
{
isRunning = false;
}
}
}
SDL_Quit();
return 0;
}
Code:
TARGET = simpleApp PSPSDK = $(shell psp-config --pspsdk-path) PSPBIN = $(shell psp-config --psp-prefix)/bin SDL_CONFIG = $(PSPBIN)/sdl-config OBJS = simpleApp.o DEFAULT_CFLAGS = MORE_CFLAGS = -G0 -O2 CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions -fno-rtti LIBS = $(shell $(SDL_CONFIG) --libs) -lSDL -lglut -lGLU -lGL -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lpspvfpu -lpsplibc -lpspuser -lpspkernel -lpsprtc -lpsppower -lstdc++ -lSDLmain EXTRA_TARGETS = EBOOT.PBP include $(PSPSDK)/lib/build.mak Glenn |
|
|
|
|
|
|
#2 |
![]() |
Im not a C/C++ coder but I think you need to add this to your code to enable the Home button/Exit with it.
Code:
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
__________________
Free Prizes at [url=http://www.prizerebel.com/index.php?r=189687]Prizerebel[/url] Join us! I already got [b]11[/b] Gifts. Ask me for details or proof. |
|
|
|
|
|
#3 |
![]() ![]() Developer
|
ZeroX, SDL for the PSP does that for you. To the OP, the 'HOME' button should bring up the standard PSP quit application screen when you use SDL. However, in your code, you don't initialise SDL.
__________________
[Blog] [Portfolio] [Homebrew Illuminati - Serious Homebrew Development Forums] [I want to make Homebrew FAQ] [How I broke into the Games Industry] [Programming Book List] [Programming Article List] |
|
|
|
|
|
#4 |
![]() ![]() ...in a dream...
|
ZeroX - That hooks the Home button to that home menu screen thing. That can be placed in via initlizing SDL with an argument of the number 1 if my memory serves right...
GlennNZ - I dont use SDL, rather took a peek at porting stuff written in it. But exitting out using a PSP-specific command should owrk, unless the port of SDL to the PSP just made SDL_Quit() contain it... either way: Code:
#include <pspkernel.h> ... if(pad.Buttons & PSP_CTRL_START) sceKernelExitGame();
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#6 | |
|
Quote:
I got the HOME button/exit to work with: Code:
//This is an SDL app. How much can I remember of SDL commands? Not much unfortunately.
#include <SDL/SDL.h>
#include <stdlib.h>
#include <pspctrl.h>
#include <pspkernel.h>
PSP_MODULE_INFO("simpleApp", 0, 1, 1);
//using namespace std;
bool isRunning;
int buttonDown;
SceCtrlData pad;
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(int argc, char** args)
{
SetupCallbacks();
isRunning = true;
while (isRunning)
{
sceCtrlReadBufferPositive(&pad, 1);
}
SDL_Quit();
sceKernelExitGame();
return 0;
}
|
||
|
|
|
![]() |
| Tags |
| app , exit , freezing |
| Thread Tools | |
|
|