Beginner PSP Programming Questions

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
darkweb
Posts: 6
Joined: Mon Aug 22, 2005 2:12 am

Beginner PSP Programming Questions

Post by darkweb »

Hi everyone,
I've just started programming on the PSP and I have a few questions that I can't seem to find the answers to on the forums.

1) I've noticed when using sceKernelExitGame() it's always in the exit_callback function but I've used it in the main function. Is there a reason for it being in the exit_callback and also is it bad coding for me to have it in the main function?

2) Reading about the exit_callback for the home button they used a startup.s file. What exactly is the startup.s file and what is it used for? I read it was like a boot loader or something but I couldn't find anything else on it.

Thanks for any help you guys can give! Also I'd like to thank everyone in this community for allowing this all to happen. Hopefully I can give back for everything that I have learned!

Thanks again,
Darkweb
Sirwhizz
Posts: 16
Joined: Wed Jun 08, 2005 4:12 am
Location: Melbourne, FL

Post by Sirwhizz »

1) I've noticed when using sceKernelExitGame() it's always in the exit_callback function but I've used it in the main function. Is there a reason for it being in the exit_callback and also is it bad coding for me to have it in the main function?
Someone else will half to tell you the reason why there is a callback because I don't fully understand it myself, but it is there running in the background so when you press the HOME button that code executes when you select yes. It isn't bad coding to have it in your main function. If you look at the different samples in the SDK, they will show you where to put sceKernelExitGame(). Also, In different Samples they don't use sceKernelExitGame() in the main menu but another function, I am not sure why, but I would like to know about it. Also, If you have mutliply functions besides the main function, I found out that you have to put scekernelExitGame() at the end of those functions too for it to work correctly. I am still new to programming for the PSP, but I learned a lot from these forums and thanks to everyone for their hard work in making the PSPSDK.

2) Reading about the exit_callback for the home button they used a startup.s file. What exactly is the startup.s file and what is it used for? I read it was like a boot loader or something but I couldn't find anything else on it.
Well since you have the SDK you don't need to worry about startup.s, because they already have included it in the SDK. If you want to do Wifi, you have to include an addition to the .s file, but if you search the forum you should find PSPpet Wifi Example that has the extra functions. The startup.s file loads up the sce functions so your code will work for the PSP. Someone else will probably do a better job at explaining it then me, because I know little about it, but do know a lot about programing in c/c++. I hope that helps you out.

Best advice to get started is to read these forums and try compiling the samples in the SDK.
darkweb
Posts: 6
Joined: Mon Aug 22, 2005 2:12 am

Post by darkweb »

Thanks for the reply, the info was very helpful! Hopefully someone else can further explain the whole callback and why they use sceKernelExitGame() in different functions.
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

Post by liquid8d »

Callbacks exist so it can wait for a request to be processed, since you don't know when they will be called.. possibly by the system itself?. I am assuming if the system requests for the game to be closed (via Home or otherwise?) it calls the exit callback. You should always leave it in there, and do any exit code there as well.. you may not have a problem doing it differently, but ya never know.

As mentioned, you won't need to mess with the startup.s file, unless you are doing some funky stuff that isn't implement in the SDK yet... also mentioned, even if you want to do WiFi, look at the WiFi sample and FTPd source, and you can use the source to automate the process.

Maybe someone can clear some of this up, but mainly just for informational purposes.. if you follow the samples, you'll be fine.

I see the Controller code does it differently.. it should work fine that way as well, since the while loop goes until 'done' has been set, which is set in the exit callback, but I would think it would be better to do in the exit callback itself?

LiQuiD8d
darkweb
Posts: 6
Joined: Mon Aug 22, 2005 2:12 am

Post by darkweb »

so basically the exit callback is only used for the home button or a crash? Or can we call that function if we wanted a different way to exit the program like in a menu of some sort.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Basically the exit callback is there because it allows you to exit from the program at any time without having to deal with it explicitly in the main program loop (for info use of the exit callback is mandatory in getting Sony to permit the publishing of a commercial game, something we don't have to worry about).

You can of course call sceKernelExitGame anywhere you like and it should work, the only place it wont is in the startup code of your app which you shouldn't need to touch anyway.
darkweb
Posts: 6
Joined: Mon Aug 22, 2005 2:12 am

Post by darkweb »

Alright! Thanks for clearing that up Tyranid, it makes a bit more sense now. Also thanks again to liquid8d and sirwhizz for their help!
Post Reply