Drakonchik
Member
Hello everyone! About a year ago I went through this forum, and inside the Discord server, in hopes to see that someone had posted some sort of tutorial on how I can start making some games. Most probably others too had looked at some samples, and what they often would get, go see samples at the samples folder. Then what?
This might sound frustrating for those who are beginners in programming and want to try out it for PS2. Mainly the idea is that on PS2 it should have been easier, because the system is older... That might be the assumption, yet you are dead wrong my friend.
What awaits you in this tutorial is pain and suffering, which will result into this:
Now with that warm greeting by TnA I believe we can see what we have in store, a game with multiple states, falling asteroids and a spaceship that will shoot out a bullet. And last but not least, an actual animation.
Now before you all have all high hopes about some SSS class programming, hold your horses I wrote this game about 7 months ago? Spent a lot of time trying to figure out how to make things actually work.
Those who want to do this on Windows Machine... Well... Good Luck!
This is actually like those cooking writings, where users wait to see the needed ingredients, while the author writes about how they got the idea from the walk in the park. Nobody reads them. Like you could confess to murderer in these texts and nobody would notice it.
Anyway... where was I? Oh yeah let's start with setting up folders. Now you can do it the way you see it best for doing things. I don't judge if you'll put it all in one big pile of mess. You do you! I've found that using a structure to separate things make it all much easier.
This is a nice way to set up the folders like this
Data folder is where we will write most of the scripts. Graphics is where we will put in our sprites and images. And finally the Audio is for Audi 0 series car. Why not BMW tho...
You will need to add one more file in this parent folder. Called "audsrv.irx" I will add it to attachments. But I am sure you can find it out here too.
Let's open up the main.c file. We should start writing some code then.
I've got no clue how to write forum posts, but I do know how fonts work and how words work
------------------------CODE-----------------------
#include <stdio.h>
#include <malloc.h>
#include <gsKit.h>
#include <dmaKit.h>
#include <gsToolkit.h>
int main()
{
u64 Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00);
u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00);
GSGLOBAL *gsGlobal = gsKit_init_global();
// GS_MODE_PAL_I
// GS_MODE_VGA_640_60
// Check PAL or NTSC (Code by Daniel Santos)
gsGlobal->PSM = GS_PSM_CT24;
gsGlobal->PSMZ = GS_PSMZ_16S;
gsGlobal->Mode = gsKit_check_rom();
if(gsGlobal->Mode == GS_MODE_PAL)
{
gsGlobal->Height = 512;
}
else
{
gsGlobal->Height = 448;
}
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
// Initialize the DMAC
dmaKit_chan_init(DMA_CHANNEL_GIF);
gsKit_init_screen(gsGlobal);
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
// Sets up the mode for drawing.
// GS_ONESHOT-> every draw clears the draw queue
// GS_PERSISTENT-> gskit stores a draw queue and whenever you draw again, it just adds onto that queue
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
gsKit_clear(gsGlobal, Black);
while(1)
{
gsKit_queue_exec(gsGlobal);
gsKit_sync_flip(gsGlobal);
}
sleep(60); // sleep before boing bai bai
return 0;
}
------------------------CODE END-----------------------
Whoa... what is that. Do I see HEX?
IKR But don't worry, I myself don't fully understand what it all means either.... What I even more don't understand is what is coming next. Makefile. Which looks like this.
------------------------MAKEFILE-----------------------
EE_BIN = SpaceShooterTutorial.elf
EE_OBJS = main.o
EE_LIBS = -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib/ -Lmodules/ds34bt/ee/ -Lmodules/ds34usb/ee/ -lpatches -lfileXio -lpad -ldebug -lmath3d -ljpeg -lfreetype -lgskit_toolkit -lgskit -ldmakit -lpng -lz -lmc -laudsrv -lelf-loader -laudsrv -lc
EE_INCS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/freetype2 -I$(PS2SDK)/ports/include/zlib
#EE_CFLAGS is passed to GCC when compiling
#EE_LDFLAGS is passed to GCC/ld when linking
EE_CFLAGS = -I$(PS2DEV)/gsKit/include
EE_LDFLAGS = -L$(PS2DEV)/gsKit/lib
all: $(EE_BIN) audsrv.irx
audsrv.irx:
cp $(PS2SDK)/iop/irx/audsrv.irx $@
clean:
rm -f $(EE_BIN) $(EE_OBJS)
run: $(EE_BIN)
ps2client execee host:$(EE_BIN)
reset:
ps2client reset
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
#The GS Enviroment Variable and path had to be removed, so that the pad script would function.
------------------------MAKEFILEEND-----------------------
And after that. Let's compile and see if we have some result
To do that, you open up Terminal and....
Wow you can show this to your mom and say you hacked the National Bank! As it looks like that, but in reality, we just compiled the code.
I'll post each step in Github, so you can either try out it all for yourself understand and progress from any step you want. Or you can just download it and say that you managed to do it all by yourself!
Link: https://github.com/AndyDragon1998/SpaceShooterTutorial
Cheers! Next step coming soon! We will do State Machine!
This might sound frustrating for those who are beginners in programming and want to try out it for PS2. Mainly the idea is that on PS2 it should have been easier, because the system is older... That might be the assumption, yet you are dead wrong my friend.
What awaits you in this tutorial is pain and suffering, which will result into this:
Now with that warm greeting by TnA I believe we can see what we have in store, a game with multiple states, falling asteroids and a spaceship that will shoot out a bullet. And last but not least, an actual animation.
Now before you all have all high hopes about some SSS class programming, hold your horses I wrote this game about 7 months ago? Spent a lot of time trying to figure out how to make things actually work.
Those who want to do this on Windows Machine... Well... Good Luck!
This is actually like those cooking writings, where users wait to see the needed ingredients, while the author writes about how they got the idea from the walk in the park. Nobody reads them. Like you could confess to murderer in these texts and nobody would notice it.
Anyway... where was I? Oh yeah let's start with setting up folders. Now you can do it the way you see it best for doing things. I don't judge if you'll put it all in one big pile of mess. You do you! I've found that using a structure to separate things make it all much easier.
This is a nice way to set up the folders like this
Data folder is where we will write most of the scripts. Graphics is where we will put in our sprites and images. And finally the Audio is for Audi 0 series car. Why not BMW tho...

You will need to add one more file in this parent folder. Called "audsrv.irx" I will add it to attachments. But I am sure you can find it out here too.
Let's open up the main.c file. We should start writing some code then.
I've got no clue how to write forum posts, but I do know how fonts work and how words work
------------------------CODE-----------------------
#include <stdio.h>
#include <malloc.h>
#include <gsKit.h>
#include <dmaKit.h>
#include <gsToolkit.h>
int main()
{
u64 Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00);
u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00);
GSGLOBAL *gsGlobal = gsKit_init_global();
// GS_MODE_PAL_I
// GS_MODE_VGA_640_60
// Check PAL or NTSC (Code by Daniel Santos)
gsGlobal->PSM = GS_PSM_CT24;
gsGlobal->PSMZ = GS_PSMZ_16S;
gsGlobal->Mode = gsKit_check_rom();
if(gsGlobal->Mode == GS_MODE_PAL)
{
gsGlobal->Height = 512;
}
else
{
gsGlobal->Height = 448;
}
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
// Initialize the DMAC
dmaKit_chan_init(DMA_CHANNEL_GIF);
gsKit_init_screen(gsGlobal);
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
// Sets up the mode for drawing.
// GS_ONESHOT-> every draw clears the draw queue
// GS_PERSISTENT-> gskit stores a draw queue and whenever you draw again, it just adds onto that queue
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
gsKit_clear(gsGlobal, Black);
while(1)
{
gsKit_queue_exec(gsGlobal);
gsKit_sync_flip(gsGlobal);
}
sleep(60); // sleep before boing bai bai
return 0;
}
------------------------CODE END-----------------------
Whoa... what is that. Do I see HEX?
IKR But don't worry, I myself don't fully understand what it all means either.... What I even more don't understand is what is coming next. Makefile. Which looks like this.
------------------------MAKEFILE-----------------------
EE_BIN = SpaceShooterTutorial.elf
EE_OBJS = main.o
EE_LIBS = -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib/ -Lmodules/ds34bt/ee/ -Lmodules/ds34usb/ee/ -lpatches -lfileXio -lpad -ldebug -lmath3d -ljpeg -lfreetype -lgskit_toolkit -lgskit -ldmakit -lpng -lz -lmc -laudsrv -lelf-loader -laudsrv -lc
EE_INCS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/freetype2 -I$(PS2SDK)/ports/include/zlib
#EE_CFLAGS is passed to GCC when compiling
#EE_LDFLAGS is passed to GCC/ld when linking
EE_CFLAGS = -I$(PS2DEV)/gsKit/include
EE_LDFLAGS = -L$(PS2DEV)/gsKit/lib
all: $(EE_BIN) audsrv.irx
audsrv.irx:
cp $(PS2SDK)/iop/irx/audsrv.irx $@
clean:
rm -f $(EE_BIN) $(EE_OBJS)
run: $(EE_BIN)
ps2client execee host:$(EE_BIN)
reset:
ps2client reset
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
#The GS Enviroment Variable and path had to be removed, so that the pad script would function.
------------------------MAKEFILEEND-----------------------
And after that. Let's compile and see if we have some result
To do that, you open up Terminal and....
Wow you can show this to your mom and say you hacked the National Bank! As it looks like that, but in reality, we just compiled the code.
I'll post each step in Github, so you can either try out it all for yourself understand and progress from any step you want. Or you can just download it and say that you managed to do it all by yourself!
Link: https://github.com/AndyDragon1998/SpaceShooterTutorial
Cheers! Next step coming soon! We will do State Machine!

