You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basic_programs.md
+93Lines changed: 93 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,45 @@ More libgu examples can be found <a href="https://github.com/pspdev/pspsdk/tree/
84
84
85
85
</details>
86
86
87
+
## Drawing Sprites
88
+
{: .fs-6 .fw-700 }
89
+
90
+

91
+
92
+
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 SDL2 below.
93
+
94
+
Click on view source below to see the code and how to build it.
95
+
96
+
<detailsmarkdown="1">
97
+
98
+
<summary>View source</summary>
99
+
100
+
**main.c**
101
+
102
+
```c
103
+
{% include samples/sprite/main.c %}
104
+
```
105
+
106
+
**CMakeLists.txt**
107
+
108
+
```cmake
109
+
{% include samples/sprite/CMakeLists.txt %}
110
+
```
111
+
112
+
Building can be done with:
113
+
114
+
```shell
115
+
mkdir build &&cd build
116
+
psp-cmake ..
117
+
make
118
+
```
119
+
120
+
This 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 <ahref="/resources/grass.png">here</a>, to be able to run it on the PSP.
121
+
122
+
More libgu examples can be found <ahref="https://github.com/pspdev/pspsdk/tree/master/src/samples/gu">here</a>.
123
+
124
+
</details>
125
+
87
126
## Controller
88
127
{: .fs-6 .fw-700 }
89
128
@@ -209,6 +248,56 @@ More documentation on SDL can be found <a href="http://wiki.libsdl.org/FrontPage
209
248
210
249
</details>
211
250
251
+
## Using SDL2 Image
252
+
{: .fs-6 .fw-700 }
253
+
254
+

255
+
256
+
SDL2 image is a library which adds support for multiple image formats to SDL2. 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.
257
+
258
+
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.
259
+
260
+
Click on view source below to see the code and how to build it.
261
+
262
+
<detailsmarkdown="1">
263
+
264
+
<summary>View source</summary>
265
+
266
+
**main.c**
267
+
268
+
```c
269
+
{% include samples/sdl2_image/main.c %}
270
+
```
271
+
272
+
**CMakeLists.txt**
273
+
274
+
```cmake
275
+
{% include samples/sdl2_image/CMakeLists.txt %}
276
+
```
277
+
278
+
Building can be done with:
279
+
280
+
```shell
281
+
mkdir build &&cd build
282
+
psp-cmake ..
283
+
make
284
+
```
285
+
286
+
This 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 <ahref="/resources/grass.png">here</a>, to be able to run it on the PSP.
287
+
288
+
If you have sdl2 sdl2-image dev packages and a compiler installed this code will also build on Linux for Linux by running:
289
+
290
+
```shell
291
+
mkdir build &&cd build
292
+
cmake ..
293
+
make
294
+
```
295
+
296
+
Documentation for SDL2_image can be found <ahref="https://wiki.libsdl.org/SDL2_image/FrontPage">here</a>.
297
+
298
+
</details>
299
+
300
+
212
301
## Using SDL2 mixer
213
302
{: .fs-6 .fw-700 }
214
303
@@ -244,6 +333,8 @@ make
244
333
245
334
This will result in an EBOOT.PBP file in the build directory. Put it in a directory in ms0:/PSP/GAME/ and you need an audio file to test the program, download it from <ahref="/resources/test.ogg">here</a>. Put it in a directory in ms0:/MUSIC/ and then rename the audio file same as name on your *MUSIC_PATH* macro in your C code and the PSP can run it.
246
335
336
+
Documentation for SDL2_mixer can be found <ahref="https://wiki.libsdl.org/SDL2_mixer/FrontPage">here</a>.
337
+
247
338
</details>
248
339
249
340
## Using SDL2 ttf
@@ -281,6 +372,8 @@ make
281
372
282
373
This 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 <ahref="/resources/Pacifico.ttf">here</a>. Put it in a directory same as EBOOT.PBP and the PSP can run it.
283
374
375
+
Documentation for SDL2_ttf can be found <ahref="https://wiki.libsdl.org/SDL2_ttf/FrontPage">here</a>.
0 commit comments