Book Review: How to Implement Design Patterns in PHP
Enforce Coding Standards with PHP_CodeSniffer and Eclipse IDE on Ubuntu Linux
Using PHP pspell Spell Check Functions with a Custom Dictionary
Using Multi-Byte Character Sets in PHP (Unicode, UTF-8, etc)
Native Linux Space Warfare: Freespace 2
Changing Mailman Python Scripts for Virtual Host Support

Native Linux Space Warfare: Freespace 2

Saturday, 31 March 12, 2:19 am
Freespace 2 is an ace game, atmospheric, moody, with lots of huge spaceships squaring off against each other in epic battles teeming with smaller craft, explosions and mega-death blastrays. The sound effects are good, the story compelling, and even the voice acting is well done.

Or at least it was, when I first played it over 10 years ago. It's since been open sourced, and the community open source project is still lively today. The code will run natively on Linux and even Apple, as well of course as Windows, and has significant enhancements contributed by the community since the original release. Even though the game's executable code is fully open source and can be compiled from the public subversion repo mentioned here, you still need to own the game in order to get the data files needed to play. If you don't already own it, the best solution is to get it as a download for $6.

The instructions here are tailored for Arch Linux, as that's my current distro of choice. There are pre-compiled binaries around, but if you want to compile the latest code from the public repository, you'll first need subversion installed:
sudo pacman -S subversion
You'll also need Arch's development tools, gcc make et al, plus the following additional libraries:
sudo pacman -S pkg-config automake autoconf openal libvorbis sdl libtheora lua readline libpng jansson
Yes - Freespace 2 will compile and run in 64-bit mode. Now navigate to where you want the source code directory to be placed, and checkout trunk from SVN:
svn checkout svn://svn.icculus.org/fs2open/trunk/fs2_open
The source code will be downloaded into a new directory called fs2_open. Enter this directory, and run the following script:
./autogen.sh
This configures the compiler for your system, and only needs to be run once. You can try setting CFLAGS to tell gcc to optimise the code to the max:
./autogen.sh CFLAGS="-O3 -pipe -fomit-frame-pointer -fno-ident" CXXFLAGS="$CFLAGS"
Note that that is a letter O in -O3, for optimisation level. 3 is the max level, you could also try -O2 or -O1. Apparently, optimisations do not always work, and may sometimes actually slow down code or even break compilation. Apparently. So if, further down the line, something doesn't work or doesn't work well, it might be worth coming back to this point and running autogen.sh without any CFLAGS or perhaps with a different set.

If all goes well, autogen.sh will exit with a message reading, 'Now type `make' to compile fs2_open.'. So do just that:
make
This is where all the source code is compiled to make the binary executable. Expect it to take several minutes depending on your system speed – go make a coffee while the PC gets on with it. There'll be loads of compiler warnings, e.g. deprecated conversion from string constant to ‘char*’, which you can ignore, and hopefully no errors. All the compiled code will be in the code subdirectory. If you look in here, you'll see loads of *.o files, which are the object code created in the first step of the compilation. There should be just one binary file, fs2_open_r. The _r suffix indicates that we have a release build – debug builds end in _d.

Now we have our executable, we just need the game data files. You can either install Freespace 2 under Wine and grab the installed files that way, or extract them directly from the CDs. If you want to extract them directly, you'll need the unshield program which can decompress InstallShield's *.cab files. It's available in the Arch repos:
sudo pacman -S unshield
Now insert the first CD and mount it at /media/cdrom0 (or change the CDROM variable in the script below). Run the following script, which is a slightly modified version from the FS2 Open Wiki, to extract the needed files:
#!/bin/bash FS2DIR="$HOME/fs2/data" TMPDIR="/tmp/fs2" CDROM="/media/cdrom0" echo =================================== echo [ Freespace 2 Retail CD Installer ] echo =================================== read mkdir -p $FS2DIR/players $FS2DIR/movies $TMPDIR   # Set files to writable in case of re-running the script chmod +w $FS2DIR/*.vp   for group in "Basic Install Files" "Intel Anims" "Music Compressed" \ "High Res Files" "Hud Config Files"; do unshield -d $TMPDIR -g "$group" -L -j x $CDROM/data1.cab; done; mv -v $TMPDIR/*/*.vp $FS2DIR/ mv -v $TMPDIR/*/*.hcf $FS2DIR/players/ sudo umount $CDROM   echo Please mount the second disk onto $CDROM read cp -v $CDROM/*.MVE $FS2DIR/movies cp -v $CDROM/tango{1,A}_fs2.vp $FS2DIR mv $FS2DIR/tango{A,a}_fs2.vp sudo umount $CDROM   echo Please mount the third disk onto $CDROM read cp -v $CDROM/tango{2,3,B}_fs2.vp $FS2DIR mv $FS2DIR/tango{B,b}_fs2.vp sudo umount $CDROM
So now we're almost there! Now all the game files are installed in the fs2 directory off your home folder, move the executable from the code subdirectory of the source folder there too:
mv code/fs2_open_r ~/fs2/
Now create a subfolder for mods produced by the Open Source FreeSpace project. Call it mediavps_3612. Go to this forum post and download the mods that you like the look of (be sure to get all the ones labelled 'Required'), and unzip them to the mediavps_3612 folder. You can now start the game with:
cd ~/fs2/ ./fs2_open_r -spec -env -glow -cell -mipmap -missile_lighting -dualscanlines -orbradar -ship_choice_3d -targetinfo -3dwarp -warp_flash -snd_preload -safeloading -mod mediavps_3612
The first time it runs, it will create a config file at ~/.fs2_open/fs2_open.ini. Edit this file to set the resolution you want to use in-game. You can apparently set any value for the resolution, as long as it's supported by your monitor. (If you're not sure what resolutions your monitor supports, run xrandr to list them all – the current resolution is marked with an asterisk.)

Please enter your comment in the box below. Comments will be moderated before going live. Thanks for your feedback!

Cancel Post

/xkcd/ Europa Clipper