Compiling Aquaria on the PSP (Download included)
Disclaimer: this is a long post, somewhat technical, but please have a look at the screenshots and the video: this game is worth the read!
Those who don’t want to read the entire article can download the compiled binaries here. The game will not run if you do not get the resource files in a correct format, and for that you need to read the article, so don’t complain to me if you didn’t read this and can’t run the game.
If you have some interest in the PSP homebrew scene, and in independent games in general, you’ve probably read about the port of Aquaria to the PSP by Andrew Church. Aquaria is an independent PC game that went open source recently, and Andrew Church released his own sources of a PSP Port of this incredible game.
I didn’t know that game, although I had heard of the “humble indie pack”, but I’m not a PC player (playing on the PC doesn’t work well when I’m standing in public transports). Aquaria is not your typical homebrew, the video released by Andrew showed that this is a professional game with top quality graphics. As I read his article and saw the video, I thought to myself: “I want to run that game on my PSP, now!”.
Unfortunately the article didn’t include any downloadable version of the game, and because of this, on various news sites, people were led to believe that this was one of those “work in progress” homebrew projects that never see the day of light because they are too ambitious. But this is wrong. This is a port of an existing game, and it is already available. So I grabbed the sources, compiled them, and let me tell you it works pretty well, and this is by far the most “official” looking unofficial game I’ve ever seen on the PSP:
Note that this video is not as nice as Andrew Church’s one, but I wanted to show you the game is real and working.
OK, so before everyone gets super excited, there are a few major catches to this game in its current status for the PSP: the engine is open source, but you have to buy the game in order to get the graphics and sounds. Now, paying for the game is clearly not a problem when you have that kind of quality. The real problem is that the files are not “ready to be used” for the PSP (Andrew mentions it “should” work as is, but I tried directly with the PC graphics, and not only did it take ages to load the game, it crashed with an out of memory error). Fortunately, Andrew provides a set of tools to convert the PC graphics into a version more suitable for the PSP (smaller and optimized). Unfortunately, these tools are command-line linux-only and you have to compile them by yourself, which basically eliminates 99% of the potential audience for the port.
Let me tell you this is extremely sad because Aquaria really looks like a terrific game (haven’t played it enough yet to give a review on the game itself, but you’ll easily find reviews on google). But I have hope that solutions for these issues will be available in the short term (more on that below)
Buying the game
Ok, let’s dig into the real subject: compiling and getting the game to run. The first thing you have to do is to buy Aquaria in order to get the graphics and sounds. Compared to our beloved minis, the game is quite expensive (20$ + tax), so be sure that you would really enjoy the game before buying it (and guess what, the creators are nice enough to provide a demo, to let you decide). But honestly, the screenshots of the game should be enough to convince you (hint for Bit blot: if you guys get lots of sales with me as a referrer, don’t hesitate to give me a percentage 😛 )
Before you buy the game: the PSP Port is unofficial and has lots of instabilities. According to Andrew Church, this will get better, but currently the PSP port might not be in a state where you feel it’s worth spending 20$ (but keep in mind that for this price, you get both the PC and the PSP versions. And the PC version works very fine). Additionally, getting it to work on the PSP requires linux and strong motivation to install all the tools. Finally, the game will only work on CFW enbabled PSP 2000, or PSP3000 with the Gen Firwmare. Because the game currently requires more than 30MB of Ram, it cannot run on the PSP1000, or on HBL. Read the readme included in the sources for more info. You’ve been warned.
Compiling the game
Before I start, please understand that this is not a tutorial, you will need to try lots of stuff by yourself, and those are just a few hints if you encounter the same issues as I did. This is just a few explanations on what I did, but I don’t pretend to replace the explanations included in Andrew Church’s sources, and if some of my explanations are unclear, google usually will explain it more better than me.
You now need to get the sources from Andrew’s mercurial repository. For this unfamiliar with it, Mercurial is a version control system, slightly different from subversion. Linux users can install a mercurial client with their favorite installing system. Windows users can use TortoiseHg (note, some steps of this article require linux, I just provide windows information for the sake of completeness).
Once this is done, you can get the sources with the following command: hg clone http://achurch.org/cgi-bin/hg/aquaria/ aquaria (or in tortoise, just right click->tortoiseHg->clone, then enter http://achurch.org/cgi-bin/hg/aquaria/ )
you should end up with an aquaria folder containing the same files as in http://achurch.org/cgi-bin/hg/aquaria/file/54bf41857ae4
I once had an issue where I couldn’t see the “PSP” subfolder because I was apparently using the wrong branch of the repository. If that happens to you, type “hg update psp” to get the latest psp branch files.
Compiling the game requires to have the latest pspsdk, as well as some additional libraries for the pspsdk (see the Readme in the sources). They can all be found in the PSPSDK’s svn trunk and compiled/installed from there. I might write an article about that but for now, google for it. you just need to install the pspsdk through the psptoolchain, and additional libraries can be retrieved in the pspsdk svn.
Once you have the libraries, compiling the game is fairly easy (Go to the “aquaria/PSP” folder and type make) but there are a few bumps in the road:
Tweaking the Makefile
- First of all, be sure that the Makefile contains the correct paths to your pspsdk installation. Unless I’m mistaken, the default one used by the port is NOT what most people have, because it’s not the default of the psptoolchain. you will need to replace this line accordingly:
PSPROOT = /usr/local/pspdev/psp
- The first issue I encountered was the makefile complaining about libpng14/png.h not existing. I didn’t have libpng14 ready for the psp apparently. I assume it’s somewhat easy to install, but instead I just copy/pasted png.h from /usr/local/pspdev/psp/include to /usr/local/pspdev/psp/include/libpng14 (that I manually created). Not sure it’s the best way to go but it did the trick.
- Secondly it seems the compilation gives a few warnings with the latest pspsdk, so I had to disable warnings in the Makefile (note that this is usually not recommended):
WARNINGS_AS_ERRORS = 0
- I also had a big issue with the function “strtof” refusing to be overwritten. Fixing that required a bit of energy and I’m not sure I did it the correct way, but anyways.
I first ran the 004-newlib-1.16.0.sh from the script folders in psptoolchain. This re-installed newlib, but more importantly, gave me access to the sources.
I then edited the file scripts/newlib-1.16.0/newlib/stdlib.h and replaced the definition of strtof with the following:
extern float strtof(const char * a, char **b) __attribute__((weak));
Additionally I commented out the code of strtof in scripts/newlib-1.16.0/newlib/libc/stdlib/strtod.c
I then recompiled and reinstalled newLib for the psp:
make -j 2
I am pretty sure this is incorrect and will prevent most of your homebrews from compiling, but at least strtof wasn’t defined anymore so that worked…
- A last problem I encountered was the impossibility to add a nice Icon to the Eboot. Honestly I gave up on that part by just putting:
in the Makefile. The issue was mostly related to the tools required (pamscale and other ones…) not being available on my system (kubuntu), or at least not in a way that was easy for me. Then again, I suck at teh Linux.
With this I finally managed to compile a working EBOOT, and the good news is, you don’t have to do it yourself now that I did it, you can download my compiled Eboot here.
Compiling the tools
The next step is to get the graphics to work on the PSP. This step is necessary. I can provide the compiled EBOOT on my site so you don’t have to compile the game, but you will still have to create your resource file from the resource folders of your own copy of Aquaria. Don’t ask me for copyrighted stuff. You can already try to run the game with the PC graphics (follow the README to see which folders you need to copy from the original game), but if you have the same issues as me, the game should freeze on the loading screen (according to the logs in psplink,that’s a “not enough memory” issue).
To convert the graphics, Andrew provides a few tools that need to be compiled. You need to install the following libraries: zlib, libpng 14, libogg, libvorbis, and lame. On my kubuntu, I had to:
apt-get install zlib1g-dev libogg-dev libvorbis-dev libmp3lame-dev
Additionally, I had to download libpng1.4 from the libpng site, then compile and install it. For this, just follow the readme from libpng and it should go almost smoothly. I however had to recreate symlinks to the correct files in my /usr/lib folder, because libpng14 got installed in another folder. If you screw up with libpng14 installation, compiling the tools will complain about libpng14/png.h missing, or it might compile correctly but then the tools will complain about versions mismatch in the png library. I think it is possible to compile with libpng 1.2 by just manually creating libpng14/png.h wherever it is required.
Once all these libraries are installed, you can create the binaries for the tool, by typing “make tools” in the Aquaria/PSP folder.
You can then run the scripts to create your Aquaria “package.dat” resource file. In the tools folder (I assume ~/pspsdev/data/ is where I put my original Aquaria resource files):
(note that in the script convert-all-data.sh I had to replace all occurrences of n=$[n+1] with n=`expr $n + 1` otherwise the script would crash on me)
You should end up with a “aquaria.dat” file, that you can copy on your psp along with the eboot.
The first few times, the game crashed on me or returned to the XMB for no reason, for example after the introduction movie. It seems (I am not sure) that the game requires an “ICON0.png” file with the eboot, and I include it with my compiled binary (even if it is empty…).
Running the game, and…what next?
The game looks incredibly cool. As Andrew mentioned in his article, some levels are awfully slow but this will hopefully get better with time. There are lots of minor issues with the port, which currently makes it not as enjoyable as it could be. For example I’m currently stuck in a “temple” where I’m supposed to hold the “right-click” button to “charge my energy”, but this doesn’t seem to work at all. Putting the PSP in sleep mode crashes the game. The texts are obviously adapted to a large PC screen, but a bit difficult to read on the PSP, etc…. Nevertheless, all of these are minor flaws and will probably be fixed soon.
The fact that the game currently can’t run on the Phat or on HBL bothers me. I’m hoping that there will be a way to run the game on machine with less Ram (maybe by downsizing the textures even more, at the cost of beauty?)
But currently the main issue for now is that the resource files can not be legally obtained easily if you want to play the game on your PSP. You have to buy the game (which is normal), but then the conversion process is painful, and will be a blocking issue for 99% of the people who would like to play the game on their PSP. I’m hoping that this unofficial port becomes somewhat official, and that owners of the game can easily get a copy of the “PSP formatted” resource files in the near future. This game (and the PSP port) deserves it.
To Andrew church, if you ever read that: I happen to live in Japan and it seems you do too. If you want to grab a beer in the area of Tokyo one of these days, contact me