PSP Programming/General/Hello World

Hello World!
Now that we've got a common folder for files which we're going to use often, and created our callbacks file we can begin creating a simple "Hello World!" program.

main.c
We'll start by including “pspkernel.h” which will allow us to exit the application, "pspdebug.h" so that we can get a simple debug screen started, "pspdisplay.h" for "sceDisplayWaitVblankStart" function, and "callback.h" of course so that the user can quit at any time by pressing 'home' and then 'exit'.

Next, we will tell the PSP a little about our program. In "PSP_MODULE_INFO" we will tell it the name of our program, any attributes, and its major and minor version. You can ignore most of these attributes for now. Then to make things easier for ourselves (so that we don't have to type as much), we will replace "pspDebugScreenPrintf" with "printf" which will allow us to type text on the screen.

So, first we will initialize the debug screen, and setup our callbacks. Then inside a loop we place the position to write to at (0,0) (so that printing doesn't go to the next line) and print out our message, then to prevent “ripping” effects we call “sceDisplayWaitVblankStart”. Once the user quits and the loop is broken (remember we are using the "isRunning" method), we do a last call to "sceKernelExitGame" which will exit our application and return zero thus closing off the program.

Now if you are using an IDE that can also compile your PSP programs, you can hit compile and put the "EBOOT.PBP" in a folder on your PSP, and then run it. If on the other hand you choose to do things manually, then we will have to create the Makefile before compiling.

Makefile
So... create a "Makefile" file (no extension) in your project's directory and open it up in your favorite text editing application.

Compile the program by using the word “make” and... sign it! :)

Signing your program (Linux)
Yes, with the release of Geohot's root signing keys, any PSP can run only signed applications. So, you must have a program which you will force sign your application. :)

I use PSCrypter. Download "PSCrypter Signed 2.0", extract it somewhere and make.

If you got error sort of "unknown command psp-config" then export pspdev path:

Next, copy entire PSCrypter folder (which you extracted) to /PSP/GAME/ and move your EBOOT.PBP to "sign" folder there. Go to "Memory Stick" on your PSP and run PSCRYPTER. Wait...

When PSP will reboot rename EBOOT_Signed.PBP in "sign" folder to EBOOT.PBP. Create any folder in /PSP/GAME/ (e.g. "hello_world") and move EBOOT.PBP there.

Now you can run own first PSP program! ;)

Once you're done with this you can proceed to the next tutorial.