Wednesday, February 17, 2021

Adventures in Old-School Gaming on Linux Mint 20.1

Linux Mint 20.1 was released shortly after my last post, and now I guess that saves me the trouble of putting a "Part 2" in the title of this addendum to that earlier post. Nothing below actually has anything to do with the upgrade to Linux Mint, though; everything done here should work on Linux Mint 20 and everything described in the earlier post should work on Linux Mint 20.1. If the title of this post misleads the hypothetical reader into thinking otherwise, then the reader must not be reading this opening paragraph and probably deserves to be confused.

Anyway, I installed some more extremely ancient video games on my Linux computer with varying degrees of ease. I'm documenting this mostly for my own sake — but if it helps anyone else, that's super neat.

Game Data Packager

I was able to install a few more games with this nice little tool whose general usage is documented a bit more in my previous post.

Some LucasArts Adventure Games

I happen to have copies of Indiana Jones and the Fate of Atlantis, Sam & Max Hit the Road, Full Throttle, and The Dig on the original CDs. Linux Mint makes mounting CDs and ISOs pretty easy, so without even really knowing how it works, I was able to mount each CD and run game-data-packager for each.

game-data-packager -d ~/deb/ -i atlantis /media/michael/ATLANTIS/  # with Indiana Jones mounted
game-data-packager -d ~/deb/ -i sam-and-max /media/michael/disk  # with Sam & Max mounted
game-data-packager -d ~/deb/ -i dig /media/michael/DIG1/  # with The Dig mounted

I tried the same with Full Throttle, but for some reason it didn't recognize the game data on my disc. Maybe the data is corrupted due to an unfortunate scratch on the disc; maybe there are different versions of the game and game-data-packager just doesn't recognize mine. In any case, I do have Full Throttle Remastered on Steam which is natively Linux-compatible so I guess it's not a big deal.

For Atlantis, Sam & Max, and The Dig — which all run in ScummVM — the use of game-data-packager saved me the trouble of manually locating and copying the necessary game data files, and also created menu shortcuts. I think it also would have installed ScummVM automatically, if I hadn't already installed it for some free games acquired via Linux Mint's package manager:

sudo apt install beneath-a-steel-sky drascula flight-of-the-amazon-queen lure-of-the-temptress

Some Apogee Games

I've had The Apogee Throwback Pack in my Steam account for a while, but had never actually installed it before this week. The pack comes with Blake Stone: Aliens of Gold, Blake Stone: Planet Strike, Rise of the Triad, and Extreme Rise of the Triad. The game-data-packager tool supports all of them.

Rise of the Triad

With the pack installed via Steam, I executed the following:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i rott

This automatically installed a Rise of the Triad source port for me. However, the correct usage of it wasn't immediately obvious. It created a single menu shortcut called "Rise of the Triad" which simply runs rott; meanwhile, the newly installed /usr/games/rott is a link to /etc/alternatives/rott which by default is a link to /usr/games/rott-shareware which runs the game's shareware episode, even though game-data-packager did find the full game in my Steam directory. A separate executable, /usr/games/rott-commercial, runs the full game. Meanwhile, /etc/alternatives/rott can be updated to point to rott-commercial instead of rott-shareware by running update-alternatives --config rott and selecting the appropriate option. Confused yet? Well, I guess it's really not that confusing, but I'm a little disappointed that game-data-packager effectively provided only a shareware menu shortcut out of the box when I was trying to install the full game.

I didn't bother with update-alternatives; I just created my own menu shortcut (in ~/.local/share/applications/ to override the existing one in /usr/share/applications) which explicitly runs rott-commercial instead of rott. (Later on, I also went back and created another shortcut which explicitly runs rott-shareware, which seems worth having because the shareware episode is actually separate from any of the episodes in the commercial release.)

Running Extreme Rise of the Triad was a bit trickier. At first, I had no idea how to do it. Documentation is sparse, even on the source port's official site. Then I opened up Synaptic Package Manager and checked the description of the rott-extreme-data package installed by game-data-packager; it indicates Extreme Rise of the Triad is played by running rott-commercial -filertl extreme.rtl. However, even this isn't quite right. That file's name is actually uppercase, and I had to provide the full path, so the correct command to run Extreme Rise of the Triad is rott-commercial -filertl /usr/share/games/rott/EXTREME.RTL. I made a menu shortcut for that too, so now I don't have to think about it anymore.

Blake Stone

Next up are the Blake Stone games. Again, with The Apogee Throwback Pack installed via Steam, I used game-data-packager to package up the game files:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i blakestone

Unfortunately... well, this didn't do much for me. It didn't automatically install any Blake Stone source port, or anything else with which to run the game. It just packaged up the game data files and installed them to /usr/share/games/blakestone/. So I had to install a Blake Stone source port called BStone myself. The installation was done approximately as recommended in the README on the project's GitHub page, the only differences being the install location and the fact that I had to install cmake on the spot:

mkdir -p ~/git
cd ~/git
git clone https://github.com/bibendovsky/bstone.git
cd bstone/build
sudo apt install cmake
cmake ../src -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/git/bstone/build/install
make install

I don't know why the documentation recommended installing to a subdirectory of the build folder. I shouldn't have listened. To make things a bit less horrible, though, I just had to create a link to the bstone executable in a location that appears in my $PATH:

sudo ln -s ~/git/bstone/build/install/bstone /usr/local/games/

Now I can just run bstone. But the source port doesn't know to look for data in /usr/share/games/blakestone/, where game-data-packager installed it, so I actually have to run bstone --data_dir /usr/share/games/blakestone to make it work. Meanwhile, running bstone --aog --data_dir /usr/share/games/blakestone makes it run Aliens of Gold without prompting to select a game, and bstone --ps --data_dir /usr/share/games/blakestone does the same for Planet Strike.

Aleph One

Marathon Trilogy

I wanted to play Marathon again, so I set out to install Aleph One. For the same reasons mentioned a while ago, I was hesitant to rely on the probably outdated tarball made available on the official Aleph One site. So, as I've done before, I checked out the latest source code from GitHub and compiled it. This required installing some dependencies as documented in the README on the project's GitHub page. I had neglected to document the exact process before, so now here it is:

mkdir -p git
cd git
git clone https://github.com/Aleph-One-Marathon/alephone.git
cd alephone
sudo apt install autoconf automake
sudo apt install libboost-all-dev  # Boost
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-net-dev libsdl2-ttf-dev libsdl2-mixer-dev  # SDL2-related
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev  # FFmpeg-related
sudo apt install libspeexdsp-dev libzzip-dev libpng-dev libcurl4-gnutls-dev  # Other
./autogen.sh
make
sudo make install

With that done, I downloaded the game files from the Aleph One site, and created a menu shortcut for each of the three Marathon games. Each shortcut just runs alephone <dir>, where <dir> is the location of that game's files.

After doing this, I noticed that game-data-packager does support the Marathon trilogy, but I'm not sure what it would have done for me here except perhaps installing the game files to some system-wide location instead of the ~/.local/share/games/ folder where I dumped them. It wouldn't have installed Aleph One for me, because it's not in my distro's package repository.

Saturday, January 2, 2021

Adventures in Old-School Gaming on Linux Mint 20

I had some free time recently, so I finally did a clean install of Linux Mint 20 on my PC, which seemed preferable to attempting an upgrade from Linux Mint 19.3. As usual, after getting all of the basic programs installed, I started reinstalling some essential games: Wolfenstein 3D, Doom, etc.

I did things a bit differently from last time — better, and less hacky, I hope — which required educating myself a bit. I also found a bug which doesn't seem to have been documented anywhere, and I honestly cannot be bothered to figure out where or how to submit a bug report, so I'm just going to document it here. Maybe it will help someone.

ECWolf and GZDoom

As I had done before, I started by installing some source ports: ECWolf for Wolfenstein 3D and Wolfenstein 3D: Spear of Destiny; and GZDoom for The Ultimate Doom, Doom II: Hell on Earth, Final Doom, Heretic: Shadow of the Serpent Riders, Hexen: Beyond Heretic, and Hexen: Deathkings of the Dark Citadel. Unfortunately, these source ports are not provided in Linux Mint 20's default package repository. Perhaps the easiest way to get ECWolf and GZDoom is to download .deb files from here and here respectively, but for the sake of automatic updates, I think it's best to grab them from the DRD Team repository:

wget -O- https://debian.drdteam.org/drdteam.gpg | sudo apt-key add -
sudo apt-add-repository 'deb https://debian.drdteam.org/ stable multiverse'
sudo apt-get update
sudo apt install ecwolf gzdoom

These don't actually come with the game files, though, so I downloaded the relevant games from Steam. (Although they could easily be acquired by... other means... they happen to be in my account thanks to bundles and gifts, and it's just the easiest way for me to get the data.) The Steam versions of the aforementioned games run in DOSBox by default, and the classic Doom games now come with the Unity ports as mentioned in an earlier post, but I would rather take the files provided by Steam and use them with Linux-native source ports.

Manual file management

What I did next, I now realize you probably shouldn't do. I manually copied the necessary game data into ~/.config/ecwolf/ and ~/.config/gzdoom/ as appropriate:

cp -t ~/.config/ecwolf/ -- \
    ~/.steam/steam/steamapps/common/Wolfenstein\ 3D/base/*.WL6 \
    ~/.steam/steam/steamapps/common/Spear\ of\ Destiny/base/*.SOD \
    ~/.steam/steam/steamapps/common/Spear\ of\ Destiny/base/*.SD1 \
    ~/.steam/steam/steamapps/common/Spear\ of\ Destiny/base/*.SD2 \
    ~/.steam/steam/steamapps/common/Spear\ of\ Destiny/base/*.SD3
for sd1 in ~/.config/ecwolf/*.SD1; do mv -f $sd1 $(echo $sd1 | sed s/SD1/SOD/); done
cp -t ~/.config/gzdoom/ -- \
    ~/.steam/steam/steamapps/common/Ultimate\ Doom/base/Doom.WAD \
    ~/.steam/steam/steamapps/common/Doom\ 2/base/Doom2.WAD \
    ~/.steam/steam/steamapps/common/Final\ Doom/base/PLUTONIA.WAD \
    ~/.steam/steam/steamapps/common/Final\ Doom/base/TNT.WAD \
    ~/.steam/steam/steamapps/common/Heretic\ Shadow\ of\ the\ Serpent\ Riders/base/HERETIC.WAD \
    ~/.steam/steam/steamapps/common/Hexen/base/HEXEN.WAD \
    ~/.steam/steam/steamapps/common/Hexen\ Deathkings\ of\ the\ Dark\ Citadel/base/HEXDD.WAD

For the most part, this is pretty straightforward, but things get a bit weird when we look at the Wolfenstein 3D: Spear of Destiny files. That ugly file renaming in the for loop ensures that the *.SD1 files that come with the Steam version of Spear of Destiny have the proper *.SOD names. I think Steam has these *.SD1 files because, when running the game with DOSBox, it needs to rename the *.SD1, *.SD2, or *.SD3 files to the appropriate *.SOD names depending on which mission pack is being played. ECWolf, meanwhile, just wants the Mission 2: Return to Danger and Mission 3: Ultimate Challenge files to be named with *.SD2 and *.SD3 respectively. At least, I think that's how it works. In any case, the manual renaming above resulted in ECWolf running each mission pack correcty with no complaints. So this manual file copying and renaming is an option if you just want to run the Steam versions of all these games with ECWolf and GZDoom.

However, I ended up undoing all of this manual file management in favor of experimenting with a program called game-data-packager, which took some work to understand but seems to work quite nicely most of the time.

Game Data Packager

I became aware of game-data-packager not because I went looking for such a tool, but simply because it was installed automatically as a dependency when I installed some Linux-native engines for Hexen II and the Quake trilogy (more on that later). If you don't already have it installed automatically for similar reasons, you should be able to install it on Linux Mint 20 as follows:

sudo apt install game-data-packager

Once installed, the game-data-packager program can be used to identify the required files for various games, and install them for use with various source ports.

The basic syntax is

game-data-packager [-d OUTDIR] [-i] GAME [PATH ...]

where GAME is the name of a supported game, and PATH tells the program where to look for the game's files (if it can't find them on its own). The game's files are packaged into one or more .deb files, which are written to the current working directory by default but can be sent to some other directory OUTDIR using the optional -d argument. The optional -i flag tells game-data-packager to go ahead and install the new .deb file(s) using the system's package manager. I think it's safe to delete the .deb files after installation unless you want to keep them. At this point, however, you'll need to use sudo apt remove with the name of the locally installed package (e.g. sudo apt remove doom-wad) in order to uninstall the game data from your system.

When executed with the -i flag, game-data-packager also attempts to install dependencies, including source ports and native engines, if they're not already installed. Basically, it should give you everything you need in order to play the game, as long as you supply the copyrighted data.

Wolfenstein 3D

For Wolfenstein 3D and Spear of Destiny, my usage of game-data-packager was as follows:

mkdir -p ~/deb/
game-data-packager -d ~/deb/ -i wolf3d
game-data-packager -d ~/deb/ -i spear-of-destiny

Additional positional arguments would specify folders in which to search for each game's files, but game-data-packager is smart enough to look in Steam's directories. Since I had already downloaded the games via Steam, the above commands were enough to locate the games on my system, package the necessary data into .deb files (which I saved to a ~/deb/ folder I had created), and install the games from those .deb files. In this case, the Wolfenstein 3D and Spear of Destiny data files get installed to /usr/share/games/wolf3d/. The package manager tracks these games' data as the locally installed packages wolf3d-v14-id-data, spear-of-destiny-data, spear-of-destiny-mission1-data, spear-of-destiny-mission2-data, and spear-of-destiny-mission3-data.

However, it assumes you want to use Wolf4SDL for Wolfenstein 3D; it did not care that I already had ECWolf installed, so it installed Wolf4SDL for me. If you want to use Wolf4SDL, you're in luck. If you're like me and you want to use ECWolf instead, you can either edit the BaseDataPaths field in ~/.config/ecwolf/ecwolf.cfg to include /usr/share/games/wolf3d/, or you can make some links:

ln -s -t ~/.config/ecwolf/ -- \
    /usr/share/games/wolf3d/*.wl6 /usr/share/games/wolf3d/*.sod \
    /usr/share/games/wolf3d/*.sd2 /usr/share/games/wolf3d/*.sd3

This got ECWolf to see all of the files it needs on my system. Wolf4SDL is still installed, which is a bit redundant, but I don't mind.

Doom

Next I used game-data-packager to package up the classic Doom games — The Ultimate Doom, Doom II: Hell on Earth, Master Levels for Doom II, and Final Doom — which I had also downloaded via Steam:

mkdir -p ~/deb/
game-data-packager -d ~/deb/ -i doom
game-data-packager -d ~/deb/ -i doom2
game-data-packager -d ~/deb/ -i final-doom

This installs all of the relevant .wad files to /usr/share/games/doom/, tracked by the local packages doom-wad, doom2-wad, doom2-masterlevels-wad, plutonia-wad, and tnt-wad. As with the Wolfenstein games, game-data-packager also automatically provided me with a source port, Chocolate Doom. I probably won't it use very much, because I already have GZDoom installed, but it doesn't hurt. Meanwhile, no tweaks were required to get GZDoom to find the data files; its default configuration included /usr/share/games/doom/ in the search path.

Master Levels

In addition to Chocolate Doom, the automatically installed dependencies also included a program called doom2-masterlevels which provides a simple GUI for selecting maps from the Master Levels pack. (Note that the command ending in doom2, above, took care of packaging the Master Levels for Doom II data as well as the Doom II: Hell on Earth data.) Here's where things get weird, though: I didn't even notice this doom2-masterlevels program until I found it by accident. There should have been a shortcut created in the Linux Mint menu, but it wasn't there. This is because the desktop entry file at /usr/share/applications/doom2-masterlevels.desktop contained a mistake:

TryExec=/usr/share/games/doom2-masterlevels-tryexec

The file referenced in that TryExec field, /usr/share/games/doom2-masterlevels-tryexec, does not exist. As a result, the entry was ignored and did not show up in the menu. However, the file /usr/share/games/doom/doom2-masterlevels-tryexec does exist. This discrepancy in the .desktop file is obviously a bug. I honestly cannot be bothered to figure out how to report this bug, to whom it should be reported, or whether it has perhaps already been fixed in a newer version of game-data-packager than my package manager provides. (Linux Mint does not always have the latest version of everything.) However, it's easy enough to fix the desktop file by changing the TryExec line:

TryExec=/usr/share/games/doom/doom2-masterlevels-tryexec

If you don't want to use a text editor, this can also be done from the command line using sed:

sed s/\\/usr\\/share\\/games\\doom2-masterlevels-tryexec/\\/usr\\/share\\/games\\doom\\/doom2-masterlevels-tryexec/ -i /usr/share/applications/doom2-masterlevels.desktop

With that fixed, the "Doom 2: Master Levels" entry now shows up in the menu.

Heretic and Hexen

I ran into some more minor trouble when I tried to package the Heretic and Hexen files. As with the previous games, I had downloaded them from Steam and tried running game-data-packager with the -i, and it failed with errors about engines not being available. Specifically, for Heretic:

ERROR:game_data_packager.build:Engine "chocolate-heretic" is not (yet) available, aborting

And for Hexen:

ERROR:game_data_packager.build:Engine "chocolate-hexen" is not (yet) available, aborting

However, these errors are nonsense. When the Chocolate Doom source port was automatically installed to /usr/games/chocolate-doom upon packaging and installation of the classic Doom games, the executables /usr/games/chocolate-heretic and /usr/games/chocolate-hexen were installed as well. These actually appear to be Chocolate Doom under the hood, but I quickly confirmed that they were able to run Heretic and Hexen respectively if executed with the appropriate -iwad arguments. Perhaps game-data-packager gets confused because chocolate-heretic and chocolate-hexen are virtual packages. In any case, to get past these bogus errors, we can omit the -i flags so that game-data-packager just creates the .deb files, and then install from those .deb files using apt:

mkdir -p ~/deb/
game-data-packager -d ~/deb/ heretic
game-data-packager -d ~/deb/ hexen
sudo apt install ~/deb/heretic-wad_64_all.deb
sudo apt install ~/deb/hexen-wad_64_all.deb
sudo apt install ~/deb/hexen-deathkings-wad_64_all.deb

I've probably discovered an actual bug here as well, but again, I really don't know how and to whom it should be formally reported, and the workaround was easy enough.

Hexen II

Hexen II is playable on Linux with the Hammer of Thyrion source port, which is called uhexen2 in Linux Mint 20's package repository. Hammer of Thyrion recognizes game data placed in ~/.hexen2/data1/, so we can copy the appropriate .pak files into that directory manually after installing uhexen2. Alternatively, we can use game-data-packager to install the files to /usr/share/games/hexen2/data1/, tracked by the local package hexen2-data. Again, I had downloaded Hexen II via Steam, so I didn't need to tell game-data-packager where to look for the files:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i hexen2

I think this would have resulted in the automatic installation of uhexen2, if not for the fact that I had already installed it beforehand using apt:

sudo apt install uhexen2

So that probably could have been skipped.

Quake

Linux Mint 20 also provides native engines for Quake, Quake II, and Quake III Arena, and all of these games are supported by game-data-packager. All three games are also on Steam, but I don't have the Steam versions. I have them on a set of CDs, in a box set called The Ultimate Quake, which I had purchased before I even created a Steam account. Fortunately, my outdated PC still has an optical disc drive, and game-data-packager can read from CDs (although it apparently needs to be told explicitly where to look).

The funny thing about Quake and Quake II is that the discs contain both game data and CD audio. In other words, each CD-ROM is also a music CD. Not surprisingly, game-data-packager creates separate packages for game data and music, hence the separate game-data-packager commands below. (Maybe the game files and music packages for a game can be created with a single command, but I used separate commands anyway because I don't think combining them would make things less confusing.) Meanwhile, ripping the CD audio required some extra dependencies which were not made known to me until game-data-packager started complaining that it could not find cdparanoia or oggenc. I assume these were not automatically installed as required dependencies because they are only sometimes needed. In any case, installing cdparanoia is trivial because that's the exact package name, and oggenc is made available for Linux Mint 20 in the package vorbis-tools, so I installed both:

sudo apt install cdparanoia vorbis-tools

Now, to install Quake, I ran the following commands with the CD inserted:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i quake /media/michael/Winquake/
game-data-packager -d ~/deb/ -i quake -p quake-music /dev/cdrom
game-data-packager -d ~/deb/ -i quake -p quake-aopfm

In the command to package and install the game data, /media/michael/Winquake/ is the location to which Linux Mint automatically mounted the CD when it was inserted, so that part will vary. The game's music doesn't show up in /media/michael/Winquake/ (because, I guess, that's just not how CD audio works), so in the command to rip the music, I used /dev/cdrom (which is a reference to the optical disc drive itself, and is actually a symbolic link to /dev/sr0). The last command installs the package quake-aopfm which is a free expansion. I can't vouch for whether this expansion is any good, because I haven't played it yet — but I noticed after installing the base game that a shortcut for the expansion had already been created in my menu, and that expansion shortcut wouldn't work without the expansion's package installed, so I figured I might as well install it instead of deleting the broken shortcut.

Installing Quake II was similar. I swapped out the Quake CD for my Quake II CD and ran the following:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i quake2 /media/michael/Quake2/
game-data-packager -d ~/deb/ -i quake2 -p quake2-music /dev/cdrom

Finally, Quake III Arena had no CD audio portion on the disc, so it required only this:

mkdir -p ~/deb
game-data-packager -d ~/deb/ -i quake3 /media/michael/Quake3/

I think these commands would have triggered automatic installations of these games' native engines, but I had already installed them manually beforehand:

sudo apt install quake quake2 quake3

Other Notes

I think much of what's written above could also be applied to other versions of Linux Mint, but I've been clear about the fact that I'm using Linux Mint 20 just in case I'm wrong about that. Meanwhile, as of the time of this post, I'm using gzdoom version 4.5.0, ecwolf version 1.3.3, game-data-packager version 64, chocolate-doom version 3.0.0-5, and uhexen version 1.5.9+dfsg-1.

Also note that game-data-packager gave me some warnings about being unable to unpack certain files due to missing programs, so I installed a couple of additional packages just to make the warnings shut up:

sudo apt install innoextract lhasa

However, these don't appear to be strictly necessary, and I'm not sure if it really made a difference. At least for the Doom games, game-data-packager was already finding all of the data needed for playing the games, despite the warnings.