Games on FreeBSD

Nov. 20, 2018, 8:47 p.m.

What do all programmers like to do after work? Ok, what do most programers like to do after work? The answer is simple: play a good game! Recently at the Polish BSD User Group meetup mulander was telling us how you can play games on OpenBSD. Today let’s discuss how this looks in the FreeBSD world using the “server only” operating system.

XNA based games 

One of the ways of playing natively is to play indie games which use XNA. XNA is a framework from Microsoft which uses .NET, for creating games. Fortunately, in the BSD world we have Mono, an open source implementation of Microsoft's .NET Framework which you can use to run games. There is also FNA framework which is a reimplementation of XNA which allows you to run the games under Linux. Thomas Frohwein, from OpenBSD, prepared a script, fnaify. Fnaify translate all dependencies used by an FNA game to OpenBSD dependencies.

I decided to port the script to FreeBSD. The script is using /bin/sh which in the case of OpenBSD is a Korn Shell.

openbsd# sh
openbsd# echo $SHELL
openbsd# sha256 /bin/ksh /bin/sh
SHA256 (/bin/ksh) = 5eff26713d74e0363e7d912767f8139f79dfb51025a7ac1b6678dfb7a3d0d389
SHA256 (/bin/sh) = 5eff26713d74e0363e7d912767f8139f79dfb51025a7ac1b6678dfb7a3d0d389

Korn shell has two main features which are used by the script and which are not supported in the Bourne shell, but used by fnaify:

  • Arrays:
    • iterating array_name[index]
    • size array_name[]
    • ${array_name[*]} - accessing all elements
    • ${#ignoredarray[*]} - the size of the array
    • set -a for setting the multiple value in the array
  • The new test command (The ‘[[‘ construction)

I could just use another shell, like bash, to accomplish this task but I decided to rewrite the whole script in Bourne shell which should make it simpler to port across other operating systems as well. Another problem was the difference between sed’s in OpenBSD and FreeBSD. I simplified the commands so it should work on both platforms. I also reduced the code size of the script by about 20%.

The official version support FreeBSD and you can find it here. I tested it with Stardew Valley. You can see a demo of it here.

I didn't test it with many games, but I don’t see any reason why it shouldn’t work with all the games tested by the OpenBSD guys. For example, with:

  • Cryptark
  • Rouge Legacy
  • Apotheon
  • Escape Goat
  • Bastion
  • CrossCode
  • Atom Zombie Smasher

Open-Source games

In FreeBSD and OpenBSD we also will find popular games which were open sourced. For example, I spend a lot of time playing in Quake 3 Arena on my FreeBSD machine. You can very simply install it using pkg:

# pkg install ioquake3

Then move the files for the skins and maps to the .ioquake3 directory from your copy of Quake. In the past I also played UrbanTerror which is a fully open source shooter based on the Quake 3 Arena engine. It’s is also very easy to install it from ports:

# pkg install iourbanterror

In the ports tree in the games directory you can find over 1000 directories, many of them with fully implemented games. I didn’t test many games in this category, but you can find some interesting titles like:

  • openxcom (Open-source re-implementation of the original X-Com)
  • openjazz (Free re-implementation of the Jazz Jackrabbit(tm) game engine)
  • corsixth (Open source re-implementation of Theme Hospital)
  • quake2
  • openra (Red Alert)
  • openrct2 (Open source re-implementation of RollerCoaster Tycoon 2)
  • openmw (Open source engine reimplementation of the game Morrowind)

All those titles are simply installed through the packages. In that case I don’t think FreeBSD has any difference from OpenBSD.



One of the big advantages of FreeBSD over OpenBSD is that FreeBSD supports wine. Wine allows you to run Windows applications under other operating systems (including mac). If you are a FreeBSD 11 user, you can simply fetch wine from packages:

# pkg install i386-wine

To run Windows games, you need to have a 32-bit wine because most of the games on Windows are built on 32-bits (maybe this has changed – I don’t play so much these days). In my case, because I run FreeBSD-CURRENT I needed to build wine from ports. It wasn’t nice, but it also wasn’t unpleasant. The whole step-by-step building process of a wine from ports can be found here. What I loved about FreeBSD is that you can easily configure additional interpreters for PE32 executables:

# binmiscctl add wine32 --interpreter /usr/local/bin32/wine \
    --magic "\x4d\x5a\x90\x00\x03\x00\x00\x00\x04\x00\x00\x00\xff\xff\x00\x00\xb8\x00\x00\x00" \
    --mask "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
    --size 20 --set-enabled

In this hex magic value, you can see MZ letters which is a signature for Windows executables.

In theory, wine allows you to play many, many games – you can see the wine database for a whole list. Unfortunately, running games under wine can be challenging and different games can have different issues. If you are thinking about buying a game and running it under FreeBSD I would recommend first checking the game in the wine database. If there is no known error running it under Linux, then feel free to try it under FreeBSD.

I didn’t test many games on FreeBSD. The game I tested was Septerra Core: Legacy of the Creator, an old cRPG from 1999. When I was a kid I spent many hours playing it, and it turns out that I bought it on some time ago. GOG released the ‘Linux version of game’ which means that there are some scripts which allow to run it under Linux using wine. The first problem is that all scripts have a shebang set to `/bin/bash`. It’s not a big problem to change this but still people should understand that not everybody has a bash installed in `/bin/`.

The scripts from are using some Linux libraries which were attached to the game.

$ file g17_wine
g17_wine: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 2.6.24, BuildID[sha1]=34ddab73835550d9f80f07ed85a9de25c430f9ce, with debug_info, not stripped

On FreeBSD you can try to run Linux binaries because you have a compatibility layer called Linuxulator. I spent a couple of minutes playing with those scripts and they started to run under my machine. So, I tried to run the game:

DEBUG: ********************STARTING Septerra Core ********************
DEBUG: curernt variables are:
DEBUG: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/oshogbo/bin:/usr/local/bin:/home/oshogbo/bin
DEBUG: pwd: /home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game
DEBUG: startDir: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game
DEBUG: gameDir: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Game/
DEBUG: wineBinDir: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Wine/bin
DEBUG: wineConfig: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Wine/prefix/.config
DEBUG: wine binary shoult be at: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Wine/bin/g17_wine
DEBUG: done!
DEBUG: *********************************************************
Starting the game now...
DEBUG: adding wineBinDir to PATH, PATH is now: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Wine/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/oshogbo/bin:/usr/local/bin:/home/oshogbo/bin
DEBUG: adding wineLibDir to LD_LIBRARY_PATH, LD_LIBRARY_PATH is now: /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Wine/lib::/usr/local/lib/
DEBUG: entering game directory using cd /usr/home/oshogbo/GOG Games/Septerra Core Legacy of the Creator/game/Game/
DEBUG: calling wine septerra.exe ...
wine: failed to initialize: /home/Projects/wine-1.8.1/wineBuild/lib/wine/ cannot open shared object file: No such file or directory

As you can see, wine is trying to look for ntdll.dll in the `/home/Projects/wine-1.8.1/wineBuild/` which I obviously don’t have. I looked inside the binaries and I discovered that there are multiple libraries hardcoded there. This doesn't really mean anything because there is maybe one magic environment which allows me to run the game, but I couldn’t find it, so I gave up on this path.

GOG allows you to download a Windows games in two ways. One of them is using their fancy installer, which does not work if you are trying to run it on a too old Windows. The second way is through the ‘offline backup’ which allows you to download a normal game installer. When I downloaded the ‘Windows’ version of the game and tried to run under wine, everything looked pretty good. The intro played. The sound was working. And when I clicked the ‘new game button’, my game crashed.

The error mentioned using uninitialized memory. I was devastated for a couple of minutes. After disconnecting additional monitors and leaving only the primary (I use 4 monitors) from my PC and not clicking the ‘new game’ button on the main screen but on the options menu the game seems to work fine…


As you can see there are many titles available for *BSDs. Thanks to the FNA and fnaify, OpenBSD and FreeBSD can work with indie games which use the XNA framework. There are many interesting games implemented using this framework. Open source is not only for big server machines, and there are many re-implementations of popular games like Theme Hospital or RollerCoaster Tycoon 2. The biggest market is still enabled through wine, although its creates a lot of problems to run the games. Also, if you are an OpenBSD user only this option is not available for you. Please also note that we didn’t discuss any other emulators besides wine. In OpenBSD and FreeBSD there are many of them for GameBoy, SNES, NeoGeo and other games consoles. 

That said OpenBSD has a big gaming community in multiple places, so if you want more information don’t hesitate to visit:

  • reddit,
  • irc (#openBSD-gaming @ FreeNODE).

But the most important place is, the service (which is still under construction) which has a list of popular games available for BSD operating systems. 

I would like to thank mulander for showing me how big the gaming market is on BSDs

If any of you tested any of these open source games, or you spent a couple of hours fighting with wine, or you tested the FreeBSD version of fnaify please share your experience in the comments section!

UPDATE 1: All my changes to the fnaify was upstreamed to the official repo by Thomas Frohwein.