| title | Basic Programs |
|---|---|
| layout | home |
| nav_order | 4 |
{: .fs-8 .fw-700 .text-center }
{: .fs-6 .fw-700 }
This is a simple Hello World program for the PSP.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/hello/main.c %}CMakeLists.txt
{% include samples/hello/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and the PSP can run it.
{: .fs-6 .fw-700 }
This is a simple square drawn on the PSP. It uses the native libgu library.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/shape/main.c %}CMakeLists.txt
{% include samples/shape/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and the PSP can run it.
More libgu examples can be found here.
{: .fs-6 .fw-700 }
This is a sprite drawn on the PSP. It uses the native libgu library to draw and the stb_image library to load the image. stb_image supports a lot of image formats. For the Playstation Portable it is important that the width of images used is a power of 2. In this case 16, but 32, 64, 128 and 256 will also work. This limitation does not exist for the example with SDL below.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/sprite/main.c %}CMakeLists.txt
{% include samples/sprite/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and add the grass image file, download it from here, to be able to run it on the PSP.
More libgu examples can be found here.
{: .fs-6 .fw-700 }
This is a simple program to use the PSP's input functions.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/controls/main.c %}CMakeLists.txt
{% include samples/controls/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and the PSP can run it.
{: .fs-6 .fw-700 }
This is a simple program to use the audio of the PSP with minimal effort. It uses native audio library.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/audio/main.c %}CMakeLists.txt
{% include samples/audio/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and the PSP can run it.
More audiolib examples can be found here.
{: .fs-6 .fw-700 }
SDL is a library which handles system specific things like input, audio and window management for you. It can also be used to render shapes and images, just like the native libgu. This can be slower, but will result in code that is easier to read and can run on multiple platforms.
Despite this example adding an option to close by pressing the start button, the code is much shorter. It can even be build for Linux without any further modifications.
Click on view source below for the to see the code and how to build it.
View source
main.c
{% include samples/sdl/main.c %}CMakeLists.txt
{% include samples/sdl/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and the PSP can run it.
If you have sdl dev package and a compiler installed this code will also build on Linux for Linux by running:
mkdir build && cd build
cmake ..
makeMore documentation on SDL can be found here.
{: .fs-6 .fw-700 }
SDL support loading BMP and PNG image files out of the box. This example results in the same image as the sprite example using libgu above. Here the limitation of the image width being a power 2 does not apply.
Despite this example adding an option to close by pressing the start button, the code is much shorter. It can even be build for Linux without any further modifications.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/sdl-sprite/main.c %}CMakeLists.txt
{% include samples/sdl-sprite/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and add the grass image file, download it from here, to be able to run it on the PSP.
If you have the sdl dev package and a compiler installed this code will also build on Linux for Linux by running:
mkdir build && cd build
cmake ..
makeIf you want support for more image formats than just PNG and BMP, you can use the SDL image library ins addition to SDL. This adds the IMG_Load function, which can be used in place of SDL_LoadPNG to load any image format. This would require adding an include and linking to SDL image. Documentation for SDL image can be found here.
More documentation on SDL can be found here.
{: .fs-6 .fw-700 }
This is a simple program to use the SDL_mixer library. It handle audio playback in multimedia applications and games. It supports various audio formats(MP3/OGG).
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/sdl_mixer/main.c %}CMakeLists.txt
{% include samples/sdl_mixer/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and add the test audio file, download it from here, to be able to run it on the PSP.
Documentation for SDL_mixer can be found here.
{: .fs-6 .fw-700 }
This is a simple program to use the SDL_ttf library. It provides functionality for rendering TrueType fonts for your PSP.
Click on view source below to see the code and how to build it.
View source
main.c
{% include samples/sdl_ttf/main.c %}CMakeLists.txt
{% include samples/sdl_ttf/CMakeLists.txt %}Building can be done with:
mkdir build && cd build
psp-cmake ..
makeThis will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and you need a font file to test the program, download it from here. Put it in a directory same as EBOOT.PBP and the PSP can run it.
Documentation for SDL_ttf can be found here.
{: .fs-6 .fw-700 }
More examples on how to use specific functions offered in the PSP SDK can be found here. Additional documentation on these functions can be found here.
{: .fs-6 .fw-700 }
When making changes to the example programs listed above, you might run into errors or even crashes. To learn how to figure out what went wrong, check out the debugging page.





