Skip to main content

Making a game for the PlayStation 2

Actually, not really for the PS2 - not natively at least. Rather making a game for YaBasic which can be played on the PS2.

I started my geek life when I was 11 years old and got my first computer (486). A few years later I found some games written in QBasic on a gaming magazine's CD. That was the first time I came in contact with programming. I didn't understand much back then, because I wasn't taught before and I didn't speak any English (it's my 3rd language...) so I was just trying to figure out how the games worked by modifying stuff. These games were simple text adventures, where you had to make choices and the game would progress that way. There were no commands like "go left" or "pick up". The game presented you all the options and you had to input the number of the option you chose. And instead of "if-else" there were GOTOs everywhere. This was how I made my first game, a multiple-choice quiz with 10 questions. Since I didn't know anything about programming it was extremely simple, the questions and answers always following the same order.

After that I began dabbling in HTML, went on to study IT (Turbo Pascal being the first language having taught) and 20-something years later... Boom, here we are. Back at the beginning, making a game in Basic.

People nowadays don't even realize it how easy we have it with modern languages and development environments. Take Unity for example: a free engine everybody can download and with just a few clicks and some lines of code you can have a prototype game up and running in a matter of hours. We have pre-made engines, we have high-level languages with functions and objects, dictionaries (associative arrays / multi-dimensional arrays) and tons of help and tutorials on the Internet. That's not the case with YaBasic.

YaBasic was a small attempt by Sony to market the PS2 as an educational device, but the YaBasic program itself made it only to a few Demo Discs. The language is of course based on Basic with functions to make simple 2D graphics (circles, rectangles, etc.). A talented programmer can even make 3D-looking graphics like this F1 demo or the bouncing Amiga ball, which is included with YaBasic. I'm not a talented programmer - hell, I'm not even a programmer, just a sysadmin - so my game is a lot simpler.

It's a cheap Snake knock-off, but instead of the player getting longer (like in Snake) the game just gets faster and faster. You can watch a short video of it running on my PS2 phat and the PBPX-95506 Demo Disc here:


The controls are very simple: just use the d-pad to move around. The "food" is placed at random intervals (3-6 seconds), after that it moves to a different place and the players speed is increased every 50 points (10 points per food eaten) by 50%. If the player hits a wall, it's game over and he can start a new game by pressing Start. Highscore is kept between deaths, but since there is no option to use the memory card in-game, it's lost as soon as you exit. Actually there is no way to store anything persistently. No access to the memory card to read or to write, so there's also no way to load textures or the like. Another limitation is, that there's no sound, which is really a pity. With QBasic you could make the PC speaker beep at different frequencies and lengths, so you could make something like chiptune music.

Programming in YaBasic is very hard, because you only have two "frames". The current frame being displayed and the next frame which is being drawn. You have to alternate between these two frames (called display buffers) and do everything else by hand. Keeping track of the players speed and position and moving him accordingly for example. There's no collision detection built in (like rectangle A intersects with circle B), so you have to calculate everything pixel by pixel. You have to time everything basically by counting the frames, which is a PITA. All these limitations (and more), but people still manage to make good looking games (not me, though).

If you'd like to check out my source code, just head on to my Github repository: yabasic-tools

The game is in the "Source" folder called BESCES-50008NOOBS. You might want to open the file with the .vb extension. The file without extension has the checksum already added (see my previous entry for details).

I showed it to some of my friends who really liked it and gave me some ideas how to further improve it. For example: there could be a 2-player (dare I say it: BATTLE ROYALE) mode, where the players can "fight" for the food (whoever gets it first). This could bring a little bit of strategic depth to the game, because the more food you eat, the faster you become and it'll be harder to stay alive - last player wins.

Last but definitely not least I'd like to mention this awesome site: The Ultimate Site on programming in Yabasic on your PS 2 (Playstation Basic)

It helped my a LOT in making the game and not having to look up the functions in the YaBasic built-in help (which would take considerably more time flipping through the pages). Thank you, a.vanarum8!

Until next time!

Comments

  1. Hi there, I wrote the F1 game you linked to. There was a bit of a community with a forum dedicated to PS2 yabasic where a few of us were trying to outdo each other.
    There's an online yabasic emulator along with a lot of demos and games we all made.
    https://www.mrdictionary.net/yabasic/

    ReplyDelete

Post a Comment

Popular posts from this blog

Building my own arcade cabinet - a photo diary

This has been in the making for 1.5 years and I'm thrilled to share it with you. But instead of writing a long post with boring details, I'll just add short comments to the pictures. Enjoy! The beginning: RasPi3 and RetroPie started for the first time. Buttons & joystick from AliExpress for $20. Neat! Testing the buttons. The first box. Version 2 of the box, much cleaner. Should be something like this, when it's finished Temporary solution: ATX power supply from an old PC. The amplifier arrived, too! Learning to solder: if your tip looks like this, you're doing something wrong. Visual concept number two: controller and speaker box. The messy insides of the controller box. A friend helped me out cutting the wood for the final controller box. That's not the final box, just another test run. This is more like it. Made from an old office desk. Button layout on paper...

RE: "Hacking" the PS2 - Game development

Happy 2019 everbody! This is a follow-up to my previous post:  "Hacking" the PS2 This whole thing started basically when I discovered that there is a possibility to write your own programs for the PS2. I didn't have a PS2 back in the day (I started collecting consoles around 2011) so I just found out recently. Finding out how YaBasic worked and "reverse engineering" the checksum in the source code proved to be so entertaining that I basically lost interest in making a game after that. During the holidays I had a lot of time and to make something productive I decided to take it up again and this time actually make a game. I also wanted to "streamline" the development process by not having to use 3 different programs and 2 OS's to test every change in the code I make. My old process was: write the code in Vim run the Bash script (from the previous post) to add the checksum use PS2 Save Builder to make a save file use mymc to a