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
Beginner PSP Programming Questions
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.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?
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.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.
Best advice to get started is to read these forums and try compiling the samples in the SDK.
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
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
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.
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.