Compiling the Cave Story source code leak

Compiling the Cave Story source code leak

For Cave Story's 20th anniversary someone leaked the source code to a 2004 build of the game online, so I decided to try and compile it myself and get it up and running.

No downloads will be provided for this post for legalities sake, but here's what you'll need if you want to try it yourself:

REQUIRED:

  • DirectX 5 SDK

RECOMMENDED:

  • Visual Studio .NET 2003
  • Windows XP (for running VS .NET 2003 in an ideal configuration)
  • Windows japanese language pack (so text isn't messed up)

Visual Studio

Like I said in the requirements, I will be installing VS .NET 2003 under Windows XP, mostly because I refuse to curse my main system with a piece of development software old enough to drink. It's probably possible but it would be way too much hassle, Windows 10 already had a large hissy fit when I got Visual Studio 2005 installed on my main machine.

After 3 separate re-installations later because I kept getting the initial configuration wrong, I finally got it installed how I wanted.

Hours of watching paint dry not included

trying to compile it as-is, I get errors complaining about DirectDraw, DirectInput, etc. not existing. Apparently I need to get the header and library files for those from the DirectX 5 SDK and add them into the project myself, as they aren't provided. I placed these files in a folder called "DirectX5" in the root directory of the project as defined in the .vcproj file, like this:

Contents of the DirectX5 folder
Contents of the DirectX5 folder

I needed to rename all the files because they aren't formatted like this (e.x. ddraw.h -> DxDRAW.H). I have no idea why this is the case, but I decided not to question it as I'm sure there is a reasonable explanation, here's your homework DirectX nerds.

There is also another file not provided just called "version.txt" as described in the project directory, nothing crazy but strange nonetheless.

After doing all of that, it compiled and I was left with a playable debug build of Cave Story under the "exe_d" folder, which is used instead of Visual Studio's default "Debug" folder for whatever reason.

Compiled output from source code
Compiled output from source code

Attempting to use the Release configuration compiled an executable with a different icon, but none of the data files were present, those will need to be reinserted from exe_d where they are already pre-added, likely compiled separately.

Once actually playing my built copies, I inevitably came across the nightmare of all Windows developers, non-Unicode text. I thought it was Visual Studio's fault for it and after hours of debugging and downloading the entire MSDN documentation to try and figure it out, I realized it was in fact a Windows issue in itself. You need to force Windows to use Japanese as the system language itself which of course requires the language pack, which should be a part of the Windows XP disc. This will force all ASCII translation to be under the Japanese character set instead of English. It is definitely possible to change the code to replace every Win32 API call with its Unicode equivalent (e.x. CreateWindow(A) -> CreateWindowW), but that is a task I'll let someone else tackle, as it will likely require intense rewriting on how text is both read and written to.

Hope this post is helpful to those looking into this leak, I'm looking forward to seeing any potential unused material that is commented out of this. Have fun!