QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

My app keeps freezing on exit.

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 ...

Reply
 
LinkBack Thread Tools
Old 01-12-2007, 07:48 PM   #1
 
Join Date: Oct 2006
Posts: 25
Trader Feedback: 0
Default My app keeps freezing on exit.

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;
}
Just to be thorough, here's the makefile
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
Cheers for any help. Turning the PSP on and off all the time is not ideal.

Glenn
GlennNZ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-12-2007, 07:53 PM   #2
 
ZereoX's Avatar
 
Join Date: Jan 2006
Posts: 871
Trader Feedback: 0
Default

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.
ZereoX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-12-2007, 08:03 PM   #3

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

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.
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-12-2007, 08:04 PM   #4

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

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();
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-12-2007, 08:56 PM   #5
 
FreePlay's Avatar
 
Join Date: Dec 2005
Location: h0000000rj
Posts: 12,858
Trader Feedback: 0
Default

At the very least, in your main function, add
Code:
sceKernelExitGame();
before the return.
__________________
[qj now fails.]
FreePlay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-12-2007, 11:44 PM   #6
 
Join Date: Oct 2006
Posts: 25
Trader Feedback: 0
Default

Quote:
Originally Posted by yaustar
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.
Could you perhaps elaborate on that, Yaustar? I'm getting the impression that there is a simpler way than the way I just got working.

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;
}
I needed the sceCtrlReadBufferPositive (&pad, 1) line or else the exit process locks up on the 'Please wait...' screen after you choose 'yes' to exiting.
GlennNZ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
app , exit , freezing

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 08:21 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us