Sunday, October 07, 2007

Here's how to almost workingly build wolfgl, on Ubuntu Feisty Fawn.

I had been playing wolf3d under dosbox, but the performance of it was a little bit annoying, pausing every now and then, and music stuttering, which fiddling with the cpu cycles didn't really help with, I decided to find a native port.

I found wolfgl, however it hasn't been compiled for years, and there was no source available. I grabbed the binaries I could find, and tried running it, but could only get LIBC errors.

"version GLIBC_2.0 not defined in file libc.so.6 with link time reference"

I found this page, where it says you can run it like "LD_ASSUME_KERNEL=2.4 ./wolfgl". That didn't work for me either.

A bit later, I found this page, a gentoo build page.. hmm, how can there be a gentoo build page if there's no source to this? also, it was last updated only a few months ago, that's more promising than the sourceforge page, which hasn't been updated in a few years, and the homepage, not touched since 1999.

I found the port page here, and downloaded the ebuild file.

While trying to work out how ebuilds work, ie where I could get the source from, that gentoo would, I found a forum thread, saying there were working debian binaries here.

I tried downloading and installing from there, however I needed libx or something installed, and there's no such package anymore. I installed the replacement packages, but it wasn't happy with that.

I suppose I could have tried just extracting the binaries from the debs, but I figured I'd just end up with library issues anyway, and dealing with the fact they were compiled in 2003.

I went back to the ebuild file, read the doco here, and worked out where it was getting the source from, checking it out of cvs.

I installed cvs, and then set my cvsroot: "export CVSROOT=:pserver:wolfgl.cvs.sourceforge.net:/cvsroot/wolfgl", followed by "cvs -z5 co wolfgl". That was a good start, I had a source tree.

I tried compiling it, however received errors about "invalid lvalue in increment", and "invalid lvalue in unary ‘&’".

Googling turned up this page, where it seemed that the code was a bit sloppy, not being written as syntactically correct as gcc4 requires.

I thought about hacking the source, to fix what was defined on the above page, but then I remembered reading the changelog for the wolfgl port to gentoo, and that it had a couple of patches, which were also defined in the ebuild page.

I went about finding the patches, they were attached to bug reports, here, and here.

I downloaded the patches 1, 2, 3, 4, and applied them.

This caused more issues, first, patch 1, for gcc4 compiling, has to be applied with patch -p1, whereas the others are -p0, and one of them wouldn't apply because the chunk failed on a bunch of files in the common directory.

I had a quick look with vi, to find out what it was trying to change, and realised the files were in dos format, so I tried running dos2unix across all the files in the common directory, and running the patch again, which worked.

I was getting pretty close now I thought. Compilation failed with an "ld: cannot find "-lXext"" error or some such.

I found I needed the "libxext-dev" package installed. After installing that, the compilation completed.

I copied it into the directory with the dos version of the game I had been playing under dosbox, and tried to run it, immediately resulting in a segfault, nice.

Running strace across the binary told me it was trying to open "vswap.wl6", but I had "VSWAP.WL6", ah, case sensitivity.

I copied that across to a lowercase version of the filename, and it got a step further, complaining it couldn't find another wl6 file. I then copied all the uppercase versions of the files to lowercase versions.

The game started, woo, but then the video was all scrambled, hmm. I noticed during patching that a few hunks were offset by a few lines, maybe that's the issue.

The game kept going though, and it got to the menu, however there was some funkiness with the sprites. Instead of the spinning logo or whatever it is, next to the selected item on the menu, it was using a sprite of BJ Blazkowitz, and it changed into a gun side on, there was alos a gold key at the top of the screen for some reason.

Trying to start a game anyway, (after getting through the select episode/difficulty menus, with same sprite funkiness), resulted in the game segfaulting.

Hmm, it must work on gentoo, why can't I compile it? Maybe it needs to be compiled without the sprite patch being applied.