Académique Documents
Professionnel Documents
Culture Documents
Note from Wololo: This tutorial on How to program homebrews for your PS Vita was initially published by /Talk member
thevitamaster, as part of our monthly tutorial contest. Thevitamaster won the August tutorial contest for the PS Vita (a $10
Amazon gift code) with this entry. You can find the original post here.
Hi guys,
welcome to part one of my new tutorial series on programming for the Vita, where we will be laying the groundwork for you to
develop your own homebrew / port games to the vita! Today we will be doing a graphical hello world with the unofficial VitaSDK
and vita2dlib.
Requirements:
Vita with Henkaku
********************************************************************************************************************
Unofficial VitaSDK and vita2dlib installed on a linux system (see my last tutorial)
********************************************************************************************************************
Local Area Network connectivity between Vita and linux system
********************************************************************************************************************
So, dont be scared but here comes a dump of code. Scroll a little bit down for the explanation.
Main.c
#include <psp2/display.h>
#include <psp2/moduleinfo.h>
#include <psp2/kernel/processmgr.h>
#include
PSP2_MODULE_INFO(0, 0, "HelloWorld");
int main() {
vita2d_pgf *pgf;
vita2d_init();
vita2d_set_clear_color(RGBA8(0, 0, 0, 255));
pgf = vita2d_load_default_pgf();
while(1){
vita2d_start_drawing();
vita2d_clear_screen();
vita2d_end_drawing();
vita2d_swap_buffers();
vita2d_fini();
vita2d_free_pgf(pgf);
sceKernelExitProcess(0);
return 0;
#include
printf("%d", decimal);
return 0;
}
int main(){
// Function call
printdec(123);
return 0;
So, now we can see that function creation and function call always follow a pattern. The pattern for function creation is:
[routine]
Note the semicolon at the end of every function call, variable assignment, defintion, as this tells the C compiler that the
instruction ends there.
********************************************************************************************************************
Now we can look at the first skeletal function call in Vita program, namely
PSP2_MODULE_INFO(0, 0, "HelloWorld");
This function is defined in psp2/moduleinfo.h and, as you can see, it gives the Vita system some basic information on our
program, namely
int main(){
In the C language, as opposed to say Python 2.7, every function call that should be executed has to be in the routine of the main()
function. So, basically, every function call we want to make, we put within the { curly braces following int main().
********************************************************************************************************************
Following, we have:
vita2d_pgf *pgf;
This variabble defintion basically creates a new pointer variable of type vita2d_pgf which we can assign to the start of a pgf file
with the appropriate function call.
********************************************************************************************************************
vita2d_init();
With that function call, we initialize the vita2d graphics engine.
********************************************************************************************************************
vita2d_set_clear_color(RGBA8(0, 0, 0, 255));
pgf = vita2d_load_default_pgf();
This is a variable assignment. Here, we assign the return value of vita2d_load_default_pgf() to the pointer pgf of type vita2d_pgf.
********************************************************************************************************************
while(1){
Here, we have an infinite while loop. We do this to draw the values all the time and not draw them once and then exit.
********************************************************************************************************************
vita2d_start_drawing();
Here, we tell the vita to start the rendering process in memory not allocated to the display.
[!Important]But, we wont see anything on the vita screen until we call vita2d_swap_buffers();[/!Important]
Because then, our instructions will be swapped to the vita memory allocated to the display and the display controller will then
execute the instructions.
********************************************************************************************************************
vita2d_clear_screen();
So, this function call lets us draw text on the screen of the vita!
The arguments to the function are in following order:
To 3. and 4.: Both of these values must be of type int (e.g. no decimal points).
********************************************************************************************************************
vita2d_end_drawing();
End the creation of the graphical elements in memory; the memory can now be swapped.
********************************************************************************************************************
vita2d_swap_buffers();
vita2d_fini();
vita2d_free_pgf(pgf);
sceKernelExitProcess(0);
return 0;
Makefile:
TITLE_ID = VITA2DTST
TARGET = vita2dsample
OBJS = main.o
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
ASFLAGS = $(CFLAGS)
all: $(TARGET).vpk
%.vpk: eboot.bin
vita-make-fself $< $@
%.velf: %.elf
vita-elf-create $< $@
$(TARGET).elf: $(OBJS)
%.o: %.png
$(PREFIX)-ld -r -b binary -o $@ $^
clean:
eboot.bin param.sfo
make
Installation:
1. Open molecularshell on your vita and press select
2. Open a terminal and type:
cd ~
wget https://github.com/xyzz/Vita_Doom/releases/download/1.0/vitadoom.vpk
ftp [ip displayed on your vita] [port displayed on your vita] (without the brackets)
3. Press circle on your vita and navigate to ux0:, then press cross when the vitadoom.vpk file is highlighted
4. Press select again
5. Open a terminal and type:
ftp [ip displayed on your vita] [port displayed on your vita] (without the brackets)