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.

Basics

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:

in scripts/newlib-1.16.0/build-psp

make -j 2

make install

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:

ICON0_SOURCE_PNG =

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):

./convert-all-data.sh /~/pspdev/data

and then

./create-aquaria-dat.sh

(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.

Additional stuff

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 🙂

Share

wololo

We are constantly looking for guest bloggers at wololo.net. If you like to write, and have a strong interest in the console hacking scene, contact me either with a comment here, or in a PM on /talk!

This is the best looking homebrew iv ever seen, its just like official psp game But this game is kinda stupid and i wouldn’t even take the time to download it even if it was just one step to install on psp

@Pregnant and 13: you don’t tell me what I work on. If you don’t like independent games and homebrews you shouldn’t be reading my blog.

You pay 20$ for the freedom of playing the game on as many platforms as you like, including the PSP, but the game is a PC game. You’ll never get such an opportunity with “standard” commercial games.

If you can’t understand that, then you don’t understand what HBL really is about.

I agree that if you pay for the game only to play it on your psp, currently it is not worth it. But if you play it on a pc, it’s 3 times less expensive than any other modern game, for the same quality.

i didnt use to pay for games or software, until I started working on Wagic, Wagic has actually taught me what other’s hard work and dedication is worth, paying for a services someone provides is perfectly normal, one can not expect to get a free meal from a restaurant the same way why should one get a game for free?

@Triompf this won’t ever be released for the PSP 1000, because as wololo said this game requires 30mb of ram which the PSP 1000 doesn’t have…

@Wololo, this game looks great, to bad I can’t do this until I’m over my summer vacation, my mom didn’t let me bring my laptop to Canada. I have Mac OS X, Windows XP, Windows Vista, and Linux Ubuntu, Linux and XP are running on virtual machines on my mac, while i use bootcamp for windows vista 😀

I might compile everything myself or wait until some guy does this later in the future, and lets people download this and only have to put it in to there game folder for it have to run 😀

@ogre: 20$ for the result of years of work is not “being greedy”. You have to learn the reality of life. When you’ll become a grown up and have to find a job, I think you won’t be happy when your boss tells you “what, you want a salary? Stop being greedy”.

i have baught the game…..and have all the graphics…just dont know how to compile the stuff on windows 7…..can you please send me the aquaria.dat if i send you all the graphics and sounds? just tell me what to load onto a .zip file and send and i will……

@darren : I’m sorry… please try to contact the developers of the game, and tell them they should include the PSP files in a download for buyers… As soon as a better solution is available, I’ll post it.

– I’ve put together a GTK+ based PSP build tool to replace the simple shell scripts. The tool has an embedded copy of the EBOOT, so you only need the data from the commercial PC version to build the PSP game directory. (Linux binary at http://achurch.org/AquariaPSPBuilder-1.0.300.tar.gz, though that will change with future releases; my home page (http://achurch.org/) will have a link to the current version. I don’t have a working Windows build environment, but the source should compile on any platform supported by GTK+. However, be aware that gtkitemfactory.h has a deliberately non-prototyped function declaration, so you’ll need to either disable WARNINGS_AS_ERRORS or change the declaration.)

– PSP-1000 support is unfortunately just not possible with the current engine, which in fairness was designed for systems with far more memory. I’ve already trimmed texture data down to around 8MB, and the early Home Waters area still uses over 30MB total. (Side note: If you press Square+L, a debug display pops up showing current memory usage.) Between this and frame rate issues, I think the only solution for a “real” PSP port would be a new engine. Perhaps if I’m feeling particularly bored some day…

– I did find a memory leak in PNG handling (thanks for the bug report!), but even with that fixed, the PSP doesn’t have enough memory to go beyond the title screen. I’ve updated the README accordingly.

– For strtof(), it’s sufficient to add __attribute__((weak)) to the function declaration, and doing so won’t break any other programs — you don’t need to delete the function definition itself. Disabling WARNINGS_AS_ERRORS is also generally safe if you haven’t changed any of the code yourself; my own installed copy of PSPSDK has several fixes for system call prototypes in the SDK headers, and GCC may spout warnings with a vanilla copy of PSPSDK. (I should probably just disable it in the public repository to save people the trouble.)

– A missing ICON0.PNG shouldn’t cause any problems, and doesn’t for me with the current code. (It’s only loaded in order to provide an icon for the settings save file.) There might have been a bug in older code, or there could be a bug in the OS / custom firmware you used.

– I’ll check out the “charging” issue in the Energy Temple. I haven’t yet played that far on the PSP myself, but in theory you should be able to charge by holding down Circle for a few seconds.

Hey. For the “right-click” shot-charging thing, make sure you’re in the form with the black suit. You actually have to transform to use different power sets in the game. Usually, it’s shortcutted to the 1-8 numerical keys, or each can be toggled on by “singing” an appropriate song.

I forget how to change back once you do that (apart from pressing “1,” I mean. The shortcut keys spoiled me a bit!). Hope that helps you, and enjoy! Aquaria is a fantastic adventure, just wait until you hit the “Kelp Forest” area…

Archives

Disclaimer: Wololo.net is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com