Freespace 2 Open on Ubuntu Feisty

I bought both Freespace and Freespace 2 not long after they came out, and recently while looking for games to play on Linux I decided to try to run FS2 under Wine. This didn't work, but then someplace in the back of my mind I dimly remembered that Volition had long ago open-sourced Freespace 2. Back then, I didn't have a Linux system worth playing games on, and I was dual-booting Windows anyway, so it didn't matter. But today, I run only Linux (aside from virtual machines - which aside from VMware Workstation, don't support 3d graphics yet) and so the Linux port had become relevant.

I only recently even got my machine to support resolutions other than the panel's native 1680x1050, by playing around with modelines and the free 'nv' driver. So this is clearly the time to try to play games. I was formerly playing Fallout 2 in a virtual machine under the 'nv' driver, because it was the only way to change resolutions and Fallout 2 is a fixed-resolution, raster-graphic game. And it's a lot of fun, but now that I've beaten it I don't have much desire to keep going. So I needed to play something else - either something new, or something with more replay value to me (I know that sounds odd, but even though F2 is amazing and there's lots I haven't done, I'm just that way with RPGs.)

On with the process...

Anyway, enough chatter. You're probably not here for my wankery. You want instructions. I started with the instructions at hard-light.net but tweaked them somewhat, tried some things, and so on. Here's what I learned.

CVS

First, don't even try to build CVS. Just give up now. I downloaded the sources via modem (no good connection at home) and it was a big fat waste of time. The current source doesn't build and from what I understand it hasn't for some time.

Binary Installer

You want the Linux Binary Installer. This installs the fs2_open executable as well as the OpenAL and SDL libraries to keep dependencies to a minimum. You still need to come up with the data files! The original instructions give detail on that, and I am only going to explain how to get them off of the CDs. I will provide a slightly modified data extraction script.

Regardless, download the installer and then run it:

wget http://fs2source.warpcore.org/exes/linux/fs2_open-3.6.9.run
sudo bash fs2_open-3.6.9.run

The file will not be downloadable as executed, but we don't need to set it that way if we just run it with bash or sh (it's a bourne shell script.) And if you're root, you can install it anywhere.

The directory you install to is the "Freespace 2 Directory", and is usually called fs2_open. You can put it wherever you like; I installed to /opt/fs2_open (it's a common convention, and I already had a number of pieces of software there.) From here on out we're going to call it $FS2DIR (You'll see why in a bit.)

Data Files

Data Files can either be copied from the CDs or downloaded from the internet. You might try downloading Freespace 2 on HOTU, which does have some issues but in general is the most reliable way to get FS2 data files, and with the smallest possible upload. Check the forums on Hard Light Productions for more information on this. I however have the original commercial CDs, so I will extract from them. Once upon a time I played on Windows and downloaded pack "1.5c" from Shivansps, which included the 1.2 version VPs, Version 3.0.3 of FS1Port, MediaVP 3.6.8 Beta, and some other goodies. You might consider looking for something like that. Someone occasionally puts together a .torrent file (for bittorrent)

Now for the data extraction script. Note that the data does not have to be installed where the executable is installed! You just need a properly-formed data directory which can be symbolically linked into the directory. This is how my system is set up at the moment. This is what the directory structure of my /opt/fs2_open looks like:

fs2_open/
fs2_open/fs2_open
fs2_open/fs2_open.bin
fs2_open/lib
fs2_open/lib/libSDL-1.2.so.0
fs2_open/lib/libopenal.so.0
fs2_open/fs2_open.png
fs2_open/.manifest
fs2_open/.manifest/scripts
fs2_open/.manifest/scripts/update-menus-0.sh
fs2_open/.manifest/fs2_open.xml
fs2_open/uninstall
fs2_open/data

fs2_open/data is a symbolic link to a "data" directory inside my home dir, which looks like this:

data
data/players
data/players/hud_1.hcf
data/players/hud_2.hcf
data/players/hud_3.hcf
data/root_fs2.vp
data/sparky_fs2.vp
data/stu_fs2.vp
data/sparky_hi_fs2.vp
data/smarty_fs2.vp
data/warble_fs2.vp
data/tango1_fs2.vp
data/tango2_fs2.vp
data/tangoa_fs2.vp
data/tango3_fs2.vp
data/tangob_fs2.vp

If you want, you can just accomplish this yourself. The files can be copied from a Freespace 2 installation on Windows; Wine will successfully install the game so you can copy the files to your system in this way. You need to change a filename or two to be all-lowercase so that it will work, and all of the files MUST be in this directory structure. You can also use the following script (tweaked a bit from the existing one) to extract the files from the original CDs:

#!/bin/bash
FS2DIR="/tmp/fs2_open/data" # where data dir will be made
TMPDIR="/tmp/fs2_open/tmp" # where files are temporarily stored
CDROM="/dev/cdrom" # the DEVICE of the cdrom
mkdir -p $FS2DIR $TMPDIR

echo =========================
echo [ Freespace 2 Retail CD Installer ]
echo =========================
echo Please insert the first disk
read
mkdir -p $FS2DIR/players
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 /media/FREESPACE2_1/data1.cab;
done;
mv -v $TMPDIR/*/*.vp $FS2DIR/
mv -v $TMPDIR/*/*.hcf $FS2DIR/players/
eject $CDROM

echo Please insert the second disk
read
cp -v /media/FREESPACE2_2/tango{1,A}_fs2.vp $FS2DIR
mv $FS2DIR/tango{A,a}_fs2.vp
eject $CDROM

echo Please insert the third disk
read
cp -v /media/FREESPACE2_3/tango{2,3,B}_fs2.vp $FS2DIR
mv $FS2DIR/tango{B,b}_fs2.vp
eject $CDROM

rm -vrf $TMPDIR
chmod -x $FS2DIR/tango*.vp

Remember, this is for Ubuntu. When you insert a disc it's mounted to /media/volume name.

You may want to change some values. For example the FS2DIR could be set to the actual location where the data files are going. And the TMPDIR could be anywhere. But there is one limitation. There can be no uppercase letters anywhere in the path to TMPDIR. The 'unshield' program (sudo aptitude install unshield) either never handles uppercase characters in the path, or some option being used in this script is doing this, but at a very stupid time (converting the whole path, not just the filename) so that you cannot unshield to a path with a capital letter in it.

These are all the vp files (and related) that you will need to play the game. You can download and install the MediaVP files, which enhance the game graphically; I only have some of them so far, as I live in the sticks, and it's a big download over a modem. Regardless, either move the data dir to the fs2_open directory (regardless of where you placed it) or make a symbolic link from the actual location:

cd fs2_open
ln -s /home/username/files/data

This will let fs2_open find the files. The files' location is determined based on the location of the fs2_open executable, so this is very important.

Hardware

The original Freespace 2 let you change all settings from inside the game. fs2_open isn't quite there yet, so we have to do some configuration outside of the game. While controller mapping is done inside fs2_open, controller selection is done through an environment variable. Video detail settings are changed inside the game, but resolution is chosen manually, through the ini file.

Joystick Support

Whether this is by accident or design, joystick support didn't work for me without setting the SDL_JOYSTICK_DEVICE environment variable. Connect your joystick (if it's USB or joystick port) or connect it and reboot (if it's serial) and then list the contents of /dev/input to find out what the joystick device is. Here's my listing:

$ ls /dev/input
by-id    event0  event2  event4  event6  event8  js1   mouse0  mouse2  ts0  ts2
by-path  event1  event3  event5  event7  event9  mice  mouse1  mouse3  ts1  ts3

There's only one file beginning with "js" (it's /dev/input/js1) and this is what I use for SDL_JOYSTICK_DEVICE in this case. It would normally be /dev/input/js0 but I had removed and reinserted it. Sometimes this will result in a new device being detected, and the old one being dropped; sometimes it's the same device. Regardless, in this case you would type either:

export SDL_JOYSTICK_DEVICE=/dev/input/js1
/opt/fs2_open/fs2_open

or

SDL_JOYSTICK_DEVICE=/dev/input/js1 /opt/fs2_open/fs2_open

to start the game with the proper joystick device - in my case. The following will select the first joystick device:

export SDL_JOYSTICK_DEVICE=/dev/input/js?
/opt/fs2_open/fs2_open

or

SDL_JOYSTICK_DEVICE= /dev/input/js? /opt/fs2_open/fs2_open

The file /opt/fs2_open/fs2_open (remember, I installed to /opt/fs2_open) is actually a shell script. So you could add the "export SDL..." line to that file before that file runs fs2_open.bin) to get this set for you every time you run it. Or you could add the export... line to your .profile, .bashrc, or a number of other locations to make it happen every time you log in. The best place for it, though, is in the fs2_open file. Globbing doesn't work precisely the same in the bourne shell as it does in the bourne-again shell, so we have to make a slight change from the way we accomplished this on the command line. The top of the file would look like this:

#!/bin/sh
#
# FS2_Open startup script
#

# set the joystick to the first device
export SDL_JOYSTICK_DEVICE=`ls /dev/input/js?`

# Function to find the real directory a program resides in.
# Feb. 17, 2000 - Sam Lantinga, Loki Entertainment Software
FindPath()

...and so on.

Screen Resolution

The original document also describes the process for increasing video resolution past 640x480. I originally used 1400x1050, which is the highest 4:3 aspect ratio resolution that will fit on my laptop's panel. This was because various sources said that the game would not work properly in widescreen aspect ratio; the original game supported only 640x480, 800x600, and 1024x768, and the HUD and Radar were supposed to malfunction, et cetera. But now I am using 1680x1050, which at least seems to be working. This legacy is rumored to continue today, at least to some extent, and using resolutions other than these three has the potential to cause problems (up to and including crashes.) Here's my $HOME/.fs2_open/fs2_open.ini file's relevant contents:

[Default]
VideocardFs2open=OGL -(1680x1050)x32 bit
LastPlayer=drinkS
GammaD3D=1.05

If you run fs2_open (with or without arguments) it will create the .fs2_open directory, and the fs2_open.ini file. It will start up at 640x480@(whatever your current bit depth is). 16 bit works just fine, but 32 bit provides higher visual quality. It also doesn't run as fast, so if you have an older system (in 2007, any modern video card in any modern system is balls-out fast compared to the systems we ran Freespace 2 on originally) then you might want to consider using 16 bit.

Starting Up

If you want fs2_open to look its best then you will need to pass it some additional options. The more options you use (and the more visual detail you turn up inside the game, and the more Media VPs you load) the more powerful a machine you will need to get good performance. I have about half the Media VPs and my frame rate isn't dropping below my vsync (good thing, since I have vertical sync matching active) and I'm using 4X Antialiasing, texture sharpening, 1680x1050 resolution, all of that. But I have a Compaq nw9440 (Core Duo T2600, NVIDIA Quadro FX1500 graphics, 2GB RAM) which is a fairly powerful system. If you have less machine, you might not be able to use all of these options. If you have more machine (if you have a desktop system, it's not that hard to do) then you should have no problem at basically any resolution. These are the commands with which I start up:

fs2_open -spec -env -glow -jpgtga -mipmap -missile_lighting -cache_bitmaps -targetinfo -orbradar -ballistic_gauge -rearm_timer -ship_choice_3d -3dwarp -warp_flash -snd_preload -fps -mod mediavps -mod ...
  • -spec: Enables specular mapping.
  • -env: Enables environment mapping.
  • -glow: Enables glow mapping.
  • -jpgtga: Enables the use of TGA and JPG file formats for image files. This is default in either 3.6.9 or 3.6.10 (at the time of this article's creation, as yet unreleased) so I don't take chances.
  • -mipmap: Enables mip-mapping. As far as I can tell this is default in 3.6.9 (or even earlier) and it doesn't just enable mip-mapping, but actually activates automatic mip-mapping for files for which this was not done ahead of time.
  • -missile_lighting: Light effects apply to missiles.
  • -cache_bitmaps: Caches bitmaps between missions. Improves load time after the first mission.
  • -targetinfo: Puts some info about a target next to it.
  • -orbradar: 3D radar system. Takes a little getting used to, but makes more sense once you do.
  • -ballistic_gauge: Adds an ammo gauge to the HUD when armed with a ballistic weapon.
  • -rearm_timer: Gives a more or less accurate countdown to the time when you're done with rearming (about as accurate as the time it will take the support ship to dock with you.)
  • -ship_choice_3d: Instead of canned animations, the actual ship models are shown in the ship selection screen. Best with MediaVPs (esp. models VP.)
  • -3dwarp: Gives a more complicated object for the subspace warp effect to be mapped to. Looks a little slicker.
  • -warp_flash: A flash of light at warp.
  • -snd_preload: Preload mission sounds to avoid stuttering the first time the play (at which time they are cached.)
  • -fps: Displays current frame rate. Nice to see if you've turned on too many visual goodies and doesn't take up much space regardless.
  • -mod mediavps: Loads mod (.vp) files from the mediavps directory. In my case this is the Media VP files, but it will load all VP files from the specified location in alphanumeric order. The specified location is relative.

A lot of the visual quality comes from installing as much of the Media VP set as you can manage. Let's talk, therefore, about modules.

cmdline_fso.cfg

If you create this file someplace FS2Open will read things from, then the contents will be prepended to the command line. This is handy for activating options you always want to use. So here's the contents of my /opt/fs2_open/data/cmdline_fso.cfg file:

-spec -env -glow -jpgtga -mipmap -missile_lighting -cache_bitmaps -targetinfo -orbradar -ballistic_gauge -rearm_timer -ship_choice_3d -3dwarp -warp_flash -snd_preload -fps -mod mediavps

This all goes on one line (regardless of what it looks like here.) Because the installer puts a symbolic link on your system to run fs2_open (it's installed in /usr/local/bin by default; your mileage may vary) you can run the game just by running fs2_open. If you want to load a mod then you can just run fs2_open -mod modname, and it will be as if you ran fs2_open -spec -env -glow -jpgtga -mipmap -missile_lighting -cache_bitmaps -targetinfo -orbradar -ballistic_gauge -rearm_timer -ship_choice_3d -3dwarp -warp_flash -snd_preload -fps -mod mediavps -mod modname. This file should work from your $HOME/.fs2_open/data directory as well; I just went ahead and put it into the global directory - but my screen resolution settings are done just for me.

Launching the program

I use Ubuntu (with GNOME) and the following .desktop file (for instance, "Freespace 2 Open.desktop" will launch FS2Open:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name[en]=Freespace 2 Open
Exec=fs2_open
Icon[en]=/opt/fs2_open/fs2_open.png
Comment[en]=Made by the Freespace 2 SCP
Name=Freespace 2 Open
Comment=Made by the Freespace 2 SCP
Icon=/opt/fs2_open/fs2_open.png

Any additional flags can be added to the Exec line. So the following lines might be changed thusly for loading the Freespace 1 Port (if you, like me, install it to $FS2DIR/mod_fs1port:)

Name[en]=Freespace 2 Open - Freespace 1 Port
Exec=fs2_open -mod mod_fs1port

This icon can be placed on the desktop, into a menu or panel, et cetera.

Modules

Modules are collections of files which change the way the game behaves. They are typically packaged as "VP" files (which end with the extension ".vp" but they can also be a loose collection of files in a directory, with the proper structure. Normally, everything you see or hear in the game comes from a VP file (except for HUD graphics, which come from some related files.) More interestingly, you can load new and unusual VP files into the game, and the files you load will supersede the ones which come with the game. They can be used to improve graphics, change behaviors, alter music, and so on. Installing and using them is simple if you just keep a few simple points in mind.

Installing Modules

Modules are typically installed to a subdirectory of the $FS2DIR (see Binary Installer, above) and all you need to do is to make a directory there and unpack the .vp files into it. It will go something like this:

FS2DIR=/opt/fs2_open
cd $FS2DIR
sudo mkdir mod_whatever
sudo unzip ~/Downloads/mod_whatever.zip

Remember, $FS2DIR is wherever you installed.

Loading Modules

Freespace 2 Open has a very nice mod management system. You can use it to start mods in various combinations (if you want) or one at a time to provide functionality. In order to use a mod, you would put it in a directory inside of the fs2_open directory (where the binaries are installed) and then add the -mod directory option to the command, like so:

fs2_open -mod mod_ep

This will load all the .vp files in the "mod_ep" directory. It doesn't take much imagination to figure out that you can combine mods that way. Just create a new directory, and then make links from the mods' .vp files into that directory. I had limited success with symbolic links, but they seemed to work - usually. If the files are on the same partition you can make hard links (use ln without the -s flag) and those will definitely work.1 Some mods will play well with others, and some won't.

Loading modules concurrently

In theory, mods providing campaigns should be loadable together, but I experienced some crash errors when loading multiple campaign modules at once. Now, I load only the mediavps that I'm using and the module for the campaign that I'm playing.

Module loading order

It's important to note that modules loaded first win. If you load a module which replaces a file, and you load it after another module which also replaces the same file, then the first module you loaded takes precedence. Thus, if you want the content from the mediavps to be used before module content, you have to load them first. But also, loose files in the "data" directory - which can be not only in the root, but also in a subdirectory specified with the -mod flag - load before anything else.

Cleaning up cache directories

In theory Freespace 2 is supposed to detect when you have updated modules, and update its own caches, but this does not always happen. On Linux you need clean only your .fs2_open directory. Just delete anything inside a directory called "cache" anywhere inside of there. The next time you start up will be slow, but files will be properly updated.

Here is a short shell script I call "fs2_clean" which will intelligently clean all cache directories on Linux. It does not remove subdirectories in them or anything like that so if you put something wacky there, it will stay. This behavior is intentional. I put it in my fs2_dir and made a symlink into /usr/local/bin.

#!/bin/sh
#
# script to clean caches from homedir/.fs2_open

FS2OPEN_DIRNAME=.fs2_open
RMFLAGS="-vf"
FINDEXPRESSION="-type f"

if [ ! x"$HOME"x != xx ]; then
  echo "Home directory variable \$HOME not set! Exiting..."
  exit 1
fi

FS2OPEN_DIR="${HOME}/${FS2OPEN_DIRNAME}"

if [ ! -d "${FS2OPEN_DIR}" ]; then
  echo "FS2 Open directory ${FS2OPEN_DIR} does not exist! Exiting..."
  exit 1
fi

for i in `find ${FS2OPEN_DIR} ${FINDEXPRESSION} | grep 'cache/*'`; do
  rm ${RMFLAGS} -- "${i}"
done

You should use this script (or something like it) every time you switch modules. Apparently, on Windows you clear the contents of all subdirectories of $FS2DIR\data except the "players" and "freddoc" directories, but I cannot confirm this (I have no windows testing system with 3D capabilities at this time.)

MediaVPs - New art and effects

One example of a mod intended to work with other modules is the MediaVP package, which is a series of modules which contain enhanced game content. When they are used, they override original game content with higher-quality material, enhancing gameplay. You install and load them like any other mod - which brings up an additional point. You can specify multiple module directories (with additional -mod flags) when starting fs2_open. Thus, in order to load the .vp files in the mod_ep directory along with the MediaVPs, we would do the following (if we had the MediaVP files installed to fs2_open/mediavps, the most common location):

fs2_open -spec -glow -mipmap -jpgtga -orbradar -mod mediavps -mod mod_ep

You need to specify at least the -jpgtga flag when loading the Media VPs, and you probably want to add at least the options I have listed above (possibly not counting any -mod flags, depending on which campaign you're playing with) no matter what other options you're using. They give the bare minimum graphical improvements, and the -jpgtga flag is necessary for many modules.

More on MediaVPs

There are multiple packages of MediaVPs. You need to install the core VP, but then you can more or less install whichever VPs you like. I believe (but am not sure) that you need to install effects before adv_effects (advanced, naturally) but I am not sure about that.

The MediaVPs not only improve the appearance and functionality of the game, but they also fix some bugs which were really errors in VP files included with the original Freespace 2, so they are well worth your while. Check the official site's forums for more information.

Campaigns

A campaign is a series of missions that tell a story. You can think of it as a storyline, because they are only as non-linear as their authors have made them (unlike e.g. a MMOG, where you have fairly broad control over your actions.)

If a mod provides a campaign, then you will need to use the campaign selection screen (accessible from the main menu) to activate it, and play in that campaign. If you have a player in a campaign and you forget to load its module, you will be forced to select another campaign before you can even quit, which is annoying (though you can always select the default campaign.)

Conversions

Conversions actually change the game into a different game. The most popular to date is the Freespace 1 Port, which is as close as you can come to playing the original Descent: Freespace on Linux (without emulation.) The current version of the port uses imported versions of the tables from the actual original game, which makes it as close as can be achieved.

Cutscenes

A common complaint is the lack of the game's cutscenes. For example, without them, beating the final mission simply results in a return to the menu screen. This is because the cutscenes are stored in the special magical "MVE" format, and the code for playing them had to be removed from the source code release for licensing reasons. You have two options for getting cutscenes in the FS2SCP: you can convert them yourself, or you can download them.

There is no cutscene support in Linux. This would be relatively easy to address, but there has not yet been interest on the part of the developers.

Conclusions

Playing Freespace 2 in the fs2_open engine on Linux is a complicated process, but not impossible. I was able to find all of this information through a combination of googling (by which I found the original instructions, and the ONLY pointer to the binary installer that I've yet seen) and combing the forums. fs2_open is substantially superior to the original in many ways, not least that it runs on Linux, but the sound performance is poor (lots of distortion while playing voice samples) and you have to perform an inordinate number of configuration tasks from the command line. While it is possible to simply download the data files these days (they're legal, even) pretty much every place that distributes them is agonizingly slow, so it's a great thing to have the original CDs.

Incidentally, the game also runs on Mac OS X and Windows. Either way you will definitely want to install from a binary. On Windows, if you have the CDs, you should definitely install (and upgrade) the game, then just lay down the fs2_open binaries inside of the original install folder. This will get you up and running in the minimum amount of time, and with the least fuss.

  • 1. Hard links are additional directory entries that point to the same blocks on the disk, while symbolic links are just a sort of pointer to a path. Additional discussion is outside the scope of this document.

Add new comment