The source code to a video game is one of the smaller elements of the game, on a byte-by-byte comparison. The bulk of a game is its assets – the graphics, models, and sound effects that define a world. I’m not particularly interested in digging into Quake’s wad files. I may look at those in the future, but for now, I’m much more interested in rebuilding the project itself.
To that end, what we’re going to do here is set up a new Visual Studio 2008 project, set up the same options as the Fitzquake project, and then bring in some of the files that were included in the original Fitzquake project.
Download and Run Fitzquake
The first thing you may want to do is make sure you can run Fitzquake itself. The program itself is almost wholly self-contained, you only need to find a copy of a wad file to supply the level, graphics, and sound. An easy, free way to do this is to download the Quake demo from id’s website.
We’ll get there though. Let’s get Fitzquake first. Go to the official Fitzquake site and download both the executable and the source. The executable file is a zip file that contains just two items, the executable itself and a README document. If you try to run it as is, though, you get an error.
This is because it can’t find a wad file. These are the files that define the game you are playing. It’s the game versus the engine that runs it. We’re looking at the engine here, so let’s find a wad to get the engine up and running.
Go to id Software’s website to download the demo of the original Quake. It gives you the old DOS installer, which runs with no problem in Windows XP, hopefully it runs in Windows 7 too. Tell it which directory to install it into, and then go to that directory when it’s done. You will see a few different files, but you’re interested in the folder called ID1.
Copy this entire folder into your Fitzquake folder, so you now have three items together – the Fitzquake executable, the readme, and the ID1 folder.
Now try running Fitzquake, and you should have Quake up and running. The reason I suggest doing this is because the Visual Studio project is going to create this Fitzquake executable, so you can just drop the program you create into this folder and compare it to how it runs with the way Fitzquake runs. It’s not 100% necessary to do this, but it helps later when you’re comparing work.
Fitzquake Source Code
The source code for Fitzquake is quite easy to work with, at least in my experience. Download it from the official website, and you’ll see it’s all kept in a single folder. A quick run of CLOC shows that there are 125 files total, but we don’t need to recreate all of them. In fact, you’ll see shortly that we’re going to be able to save ourselves several thousands lines of code right away.
I have copied over the resource files in this folder. They consist of the following:
- The dxsdk folder. This folder is full of DirectX headers used when building in Windows. There’s no reason for us to copy over Microsoft’s header files, and if you run CLOC on this folder, you’ll see that it’s over 4000 lines of code long. That’s roughly 10% of the original code that we do not need to worry about!
- The Visual Studio project files. These are Visual Studio 6 files, so Visual Studio 2008 needs to update them, but no big deal – it should do so without any problems. There are four files (and one invisible one that it creates automatically but don’t worry about that one) that we will copy over.
- The Fitzquake.ico, progdefs.q1, and winquake.rc files. These we will add to the resources folder in Visual Studio.
- The winquake.h and resource.h files. These are created by Visual Studio and are easier to just move over than worry about remaking.
That should be it! Now open the project in Visual Studio, it will update it, and then you can recreate the folder structure in your new project (or just download the file I have below).
There are a few other things I’m doing here. I’m going through the Project Properties and matching up the new project with the Fitzquake project, to make sure it compiles using the same rule set. I’m also creating the first of the files we need, sys_win.c, in order to put the WinMain function in. This is so we can get SOME C code into the project, which allows us to set the C/C++ project property settings.
The end result we have is in the following .rar file:
Great start! Now we can actually focus on the code in this monster.