Wednesday, August 18, 2021

Running OpenMW On Period Hardware

 My favorite video game of all time is Morrowind. OpenMW is an awesome port of the old game. I wanted to get OpenMW to run on my 2002 gaming PC build just to see if I could.

My legacy gaming PC has the following specs, which would have been very typical for a PC gamer around the time Morrowind came out.

- Athlon XP-M overclocked to 2.4 ghz
- Radeon 9550XL
- 2GB DDR400 dual channel RAM

I've found out that this is an incredibly difficult processor to target because it lacks SSE2 instructions. SSE2 happens to haphazardly be built into many binaries because it's assumed to exist on all modern hardware, and has since the Pentium 4. SSE2 instructions have notably snuck their way into firefox, which makes that browser impossible to build for my machine.

My processor is also 32 bit. OpenMW has a 32 bit (aka x86). While OpenMW has 32 bit builds for Windows, but they contain SSE2. Actually building the x86 version yourself is not really supported. Furthermore, the whole Windows toolchain is based on the latest Visual Studio, which does not allow you to forego SSE2. 

Linux x86 binaries are no longer provided by the OpenMW team. Downloading the last x86 build, version 0.45, results in a segfault - probably due to missing SSE2 instructions again.

So I had to build OpenMW myself. I found a Gentoo package for OpenMW which would compile everything I needed. I decided to give Gentoo a shot because it might also let me compile my own compatible web browsers. This ended up being a very long process, as gentoo users are familiar with. I had to build and configure the whole operating from scratch, starting with the kernel.

if you want to bake an apple pie from scratch you must ...

I started up an i686 build of Gentoo in a virtual machine on my modern PC to be copied over to the old box after all the setup was complete. Compiling everything on the Athlon would likely take weeks. 

After walking through the Gentoo installation manual I had a working terminal in 32 bits, but there were many snags on the way to a full desktop environment (xfce4).

The first snag was rustc. There are several packages which depend on rust. Rustc is a self-compiling compiler, which means it has to be bootstrapped. The rust compiler targeted for i686 contains SSE2 instructions, as described in gentoo bug 741708, which means that my Athlon could never bootstrap. I wanted to treat my VM like the physical machine so as not to run into any problems in the future, so I decided to compile rustc myself elsewhere then sideload the compatible binary.

My config.toml looks like this, which allows rustc to target either i586 or i686. In the end I ended up targeting i686 anyway (I think i586 broke librsvg) but it's good to have the i586 support. And this is compiled to match my instruction set.

changelog-seen = 2
[llvm]
cflags = "-march=\"athlon-4\" -m32"
cxxflags = "-march=\"athlon-4\" -m32"
ldflags = "-lz"
[build]
host = ["i586-unknown-linux-gnu", "i686-unknown-linux-gnu"] extended = true
configure-args = ['--build=i586-unknown-linux-gnu', '--prefix=/opt']
[install]
prefix = "/mnt/disk2/rust/install/opt"
[rust]
[target.x86_64-unknown-linux-gnu]
[dist]

I also had to avoid spidermonkey, which is not only a gargantuan thing to compile, but seemed to crash during compilation whether I used my sideloaded rustc or the one from dev-lang/rust-bin (I'm not even sure if rust caused the problem, but I had no interest in compiling spidermonkey. This reddit post helped me replace it with a more lightweight library (duktape)).

I also had to patch Qt5 to make it compatible with non-SSE2.

Eventually I was able to build xfce4 and OpenMW, and I was able to get in the OpenMW launch in my x86 VM:



This gave me hope that I could transfer the OS over to my old computer and get playing. Astonishingly, all I had to do was create a tarball of the root on my VM, and then extract that tarball to a new partition on my old PC. I just had to update the fstab and network config, run update-grub, and the operating system born in a VM was not running on a physical machine.

xfce didn't quite work though. The window manager crashes, so you lose window borders and close buttons. Luckily this didn't stop me from launching a terminal and eventually launching OpenMW.


I wasn't able to start the game from the main menu, but I could start the game from a random cell, which allowed me to start a new game from there.

 



 

Water was completely transparent.

 

It ran at about 2 FPS at 800x600. For comparison, the original Morrowind binary runs at around 30 FPS at around 1024x768. So not surprisingly, either OpenMW is just not optimized for my ancient hardware, or I could have some problem with my drivers.


No comments:

Post a Comment