Rewriting Doom in Rust

2 minute read

Unless you are really young (or REALLY old), you have probably played Doom.
I was 5 years old when it was released back in 1993. I remember playing it on my neighbors computer, amazed at the metal soundtrack and the 3D graphics (yes yes I know it’s not “true” 3D but 5 year old Emil didn’t know nor did he care).

In 1997 something of (nearly) equal importance happened. The original Doom source code, in all its C glory, was released.
If you are interested in programming, game development, or just video game history, I would really encourage you to take a look at the code. There’s something magical about seeing the code behind something that was such a big part of your childhood.
If you do decide to take a closer look at the source code, you might find that it’s not really in a state to be compiled and executed as-is. And no wonder, the code was written along time ago. You can probably expect compilation errors, segmentation faults, and even the occasional logic error that wont cause crashes, but unexpected behaviour. Those problems really are a pain in the ass to debug.

I have spent some time modifying the original source code. Aside from the obvious stuff like fixing various segfaults due to pointer/word size assumptions and what not, I’ve replaced the X11 rendering with some hacky OpenGL, and rewritten the audio code to use SDL2s mixer library (including a converter between Dooms MUS format and MIDI). Feel free to check it out if you are interested.

It should be fully playable. Or atleast it works on my machine(tm).

So whats next?

I like Rust, and I like Doom, and I like challenges. Thus, it makes perfect sense to rewrite Doom in Rust. Why? Because its cool thats why. Shut up.

Spiders!

Rust has a strict ownership model that doesnt really fit well with the “everything-goes” mentality of C. This will probably mean that C code cannot simply be replaced by Rust code without more or less redesigning it from the ground up. Because of this I will not try to maintain the same file structure as the original code, nor will I keep the same naming conventions for functions and variables, except where it makes sense and doesnt collide with idiomatic Rust naming conventions.

We’ll see how far I get before I give up :)

The repository for this can be found here.

Updated:

Comments