Skip to content

Commit 56b677b

Browse files
committed
Add how to use page
1 parent ece3831 commit 56b677b

14 files changed

+103
-7
lines changed

basic_programs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Basic Programs
33
layout: home
4-
nav_order: 3
4+
nav_order: 4
55
---
66

77
# Basic Programs

contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Contributing
33
layout: home
4-
nav_order: 7
4+
nav_order: 8
55
---
66

77
# Contributing

debugging.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Debugging
33
layout: home
4-
nav_order: 4
4+
nav_order: 5
55
---
66

77
# Debugging

downloads.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Downloads
33
layout: home
4-
nav_order: 6
4+
nav_order: 7
55
---
66

77
# Downloads

how_to_use.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: How to Use
3+
layout: home
4+
nav_order: 3
5+
---
6+
7+
# How to use
8+
{: .fs-8 .fw-700 .text-center }
9+
10+
This page will describe how to use the PSPDEV toolchain to build a basic program for the Playstation Portable(PSP), including screenshots. The screenshots will mainly be for Windows users, but the steps will not be much different for other operating systems, so you should be able to follow along.
11+
12+
Before going through this guide, make sure to have followed the [installation instructions](installation.html) first.
13+
14+
# Install a code editor
15+
{: .fs-6 .fw-700 }
16+
17+
For developing programs for the PSP it is recommended to use [Visual Studio Code](https://code.visualstudio.com/). You can download the installer for it on the official website [here](https://code.visualstudio.com/Download). Please install it before continuing this guide.
18+
19+
While using Visual Studio Code, you may be asked to install useful plugins, which is a good idea to do.
20+
21+
# Creating a project
22+
{: .fs-6 .fw-700 }
23+
24+
When you open Visual Studio Code, you'll be greeted by the welcome screen. Simply click the `Open Folder...` link on it or select this option from the `File` menu to get started. Then create a new directory where you want your project to be, then click on it and click . See the images below:
25+
26+
![](images/vscode-welcome.png)
27+
28+
Create a new folder and give it the name of your new project. As an example, lets take `hello world`:
29+
30+
![](images/vscode-create-folder.png)
31+
32+
Then click on the folder and click on the `Select Folder` button:
33+
34+
![](images/vscode-select-folder.png)
35+
36+
Now you've successfully created a new project.
37+
38+
# Writing a simple program
39+
{: .fs-6 .fw-700 }
40+
41+
To start, clicking the `New File` button in Visual Studio Code, type the name `main.c` and press enter:
42+
43+
![](images/vscode-create-file.png)
44+
45+
Lets add some very basic code to the file:
46+
47+
```c
48+
{% include samples/hello/main.c %}
49+
```
50+
51+
This code will print "Hello World!" to the screen each frame. This may seem complex at first, but the `exit_callback`, `callback_thread` and `setup_callbacks` are just there to make the home button work and can be reused for any project. They only have to be run once. The `PSP_MODULE_INFO` is required and just contains the name of the software. `PSP_MAIN_THREAD_ATTR` will be set like this for every program. Only the content of the `main` function really matters here.
52+
53+
Now add an aditional file called `CMakLists.txt`. Make sure the case matches, `cmakelists.txt` is not valid.
54+
55+
Add the following lines to `CMakeLists.txt`:
56+
57+
```cmake
58+
{% include samples/hello/CMakeLists.txt %}
59+
```
60+
61+
The `CMakeLists.txt` file is used for CMake, which allows you to build the code. It contains which files add to the program in the `add_executable` function and which libraries to link to using the `target_link_libraries` function. In this case we just link to the libraries required to write text to the screen. The `create_pbp_file` function is used to create an `EBOOT.PBP` file, so we can run on the program on the PSP.
62+
63+
# Building the code
64+
{: .fs-6 .fw-700 }
65+
66+
For building a terminal is used with a couple of short commands. To open a terminal in Visual Studio Code, select `Terminal` in the top bar and select `New Terminal`:
67+
68+
![](images/vscode-open-terminal.png)
69+
70+
This will open a terminal at the bottom of the screen. On Windows, this will be a powershell window, but the PSPDEV toolchain is installed in WSL. To open a WSL terminal instead, click on the arrow next to the `+` sign at the right side an select `Ubuntu (WSL)`:
71+
72+
![](images/vscode-ubuntu-shell.png)
73+
74+
Now the code can be build with the following set of simple commands:
75+
76+
```shell
77+
mkdir build
78+
cd build
79+
psp-cmake ..
80+
make
81+
```
82+
83+
The first line will create the `build` folder. The `cd` command moves you into the `build` folder. The `psp-cmake` command will create `Makefile` for the `make` command to be able to build the program, which happens in the last line.
84+
85+
After running these commands, you can go to the build folder in your project to find the `EBOOT.PBP` file. This file can be copied to a new folder in the `GAME` folder of your PSP memory stick. Then you'll be able to launch it. It should look like this:
86+
87+
![](images/hello.png)
88+
89+
If you make changes and you want to build the program with the new code, you'll only have to run `make` again. Do make sure you are in the build directory, though. If you are not, you can switch to it with `cd build`.
90+
91+
# Writing your own code
92+
{: .fs-6 .fw-700 }
93+
94+
Now you know how to create code files and build them for the PSP, you will be able to create your own. For more examples of what kind of code you can write, take a look at the [Basic Programs page](basic_programs.html).

images/vscode-create-file.png

9.4 KB
Loading

images/vscode-create-folder.png

54.9 KB
Loading

images/vscode-open-terminal.png

19.9 KB
Loading

images/vscode-select-folder.png

37.8 KB
Loading

images/vscode-ubuntu-shell.png

22 KB
Loading

images/vscode-welcome.png

24.9 KB
Loading

images/windows-open-linux-shell.png

46.2 KB
Loading

installation/windows.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ When this is done, restart your computer. Afterwards Ubuntu can be selected from
2222

2323
From now on the Ubuntu shell will be used when running commands going forward.
2424

25-
Files in Ubuntu can be accessed through a network share. In `This Computer` right click on the background and select `Map network drive`. Set the folder to `\\wsl$` to make it easily accessible.
25+
**Note:** You can open an Ubuntu terminal in a specific folder by holding shift and clicking the right mouse button on the background in the file explorer and selecting `Open Linux shell here`:
2626

27-
Alternatively, you can open an Ubuntu terminal in a specific directory by holding shift and clicking the right mouse button on the background in the file browser and selecting `Open Linux shell here`.
27+
![](../images/windows-open-linux-shell.png)
28+
29+
This can be useful when building a specific project.
2830

2931
## Dependencies
3032
{: .fs-6 .fw-700 }

tips_tricks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Tips and Tricks
33
layout: home
4-
nav_order: 5
4+
nav_order: 6
55
---
66

77
# Tips and Tricks

0 commit comments

Comments
 (0)