Coder Posts Diablo 1 Source Code Online

Sometimes, developers accidentally leave the keys to the kingdom behind. After spending more than 1200 hours and digging through debug and symbolic files found in the PC and ported versions of Blizzard's iconic dungeon brawler, a coder has attempted to reverse engineer the original source code for Diablo.

The code was uploaded to Github and took approximately four months of work, or 1200 hours according to the description. You won't be able to download the code and just start playing Diablo for free, of course - you'd need the original Diablo files, and that's not the point of this project anyway.

"The goal of Devilution itself is to recreate the original source code as accurately as possible, in order to ensure that everything is preserved," coder GalaXyHaXz wrote. "This goes as far as bugs and badly written code in the original game. However, it becomes a solid base for developers to work with; making it much easier than before to update, fix, and port the game to other platforms."

Modding is one case where having the original source code helps: it's easier to implement total conversions and wholesale changes to Diablo when you can directly tweak the code underneath. Having the source code also allows people to chronicle parts of development, tracking what features were scrapped and what ones were implemented but in a less-refined state (like multiplayer).

Having the source code makes things much easier to maintain. For years mod-makers had to rely on tedious code editing and memory injection. A few even went even further and reversed a good chunk of the game (such as Belzebub/The Hell). The problem is that they never released their sources. Usually being a one-man job, they move on with their lives inevitably due to the amount of time/work required or lack of interest.

This leaves people with a half-finished mod; one which had countless hours put into it, but left full of bugs and unfinished potential. So we're back to square one. Devilution aims to fix this, by making the source code of Diablo freely available to all.

The fun part of all this is that the clues for discovering the source code were contained within Diablo, so there's a bit more skill behind this than just finding the code on a CD-ROM.

Guy Finds StarCraft Source Code And Returns It To Blizzard, Gets Free Trip To BlizzCon

Last month, Reddit user Khemist49 made a truly unlikely find. A gold master source code disc of the original StarCraft. From 1998. At first, he didn't know what to do with it. Ultimately, he sent it to Blizzard, who was very grateful to have it back.

Read more

According to GalaXyHaXz, the two major honeypots were Sony Japan and debug tools found within the Diablo executable in the PC version. The Japanese port of Diablo for the PS1 was created by Climax Studios and a symbolic file was left inside that contained "a layout of everything in the game".

As for the original PC version of Diablo, the debug tools within Diablo.exe had "assert strings" that simplified the reverse engineering process. "Combining these aspects not only makes reversing the game much easier, but it makes it far more accurate. File names, function names, and even line numbers will be fairly close to the real deal."

GalaXyHaXz announced that a side project of Devilution would kick off soon: Devilution is intended to leave the Diablo source code untouched, so having a second venture will allow enterprising modders to try adding features like widescreen support, cross-platform play, better support for modern operating systems, and so forth.

Some users, however, have noted that the uploaded code looks more like a translation from the original Diablo files rather than new code written to replicate the behaviour of the original files. The implications of that are really only important for people looking to mess with the code itself, as one commenter noted with this snippet:

Not exactly the kind of stuff humans would produce (unless you have some kind of superhuman memory to keep track of v1 through to v159), then.

The release of the code comes as fans have been eagerly awaiting a remaster of Warcraft 3 and Diablo, following the work Blizzard did on StarCraft: Remastered. It'd be hugely unfortunate if Blizzard were set to launch a Diablo remaster this year, although given what modders have done with the DOOM source code over the years it's fascinating to imagine what a second wind will produce for the iconic action-RPG.

It'll also be interesting to see how Blizzard responds. The source code was released into Public Domain without any of the original assets - you'll need the Diablo disc or game for that - but that doesn't mean they can't push for the code to be removed from GitHub. Blizzard has been pretty open about protecting its IP in the past, as seen in the case of World of Warcraft classic servers, and not being a complete clean room reverse engineer of the code makes it more likely that it'd be violating Blizzard's copyright.

Still, it's fascinating to look under the Diablo hood nonetheless. Bloodborne fans have had a blast uncovering enemies, pathways and secrets that were lost in development, and hopefully some clever coders will be able to uncover similar nuggets from Diablo's past.


    "Some users, however, have noted that the uploaded code looks more like a translation from the original Diablo files rather than new code written to replicate the behaviour of the original files."

    Of course, its a reverse dump using symbols of the compiled code. Its not going to always be human centric, especially from code compiled in the mid 90's. The dev never inferred that it was anything but the case.

      Does make a big difference (esp. from Blizzard's perspective), so I wanted to call it out rather than just throw "reverse engineering" around, which didn't seem wholly right.

        I enjoyed this article man, thanks for posting it!
        i loved your articles back on GON from a few years ago too. keep up the good work :)

        It's definitely not what people would call clean room reverse engineering (which usually involves one party extensively documenting the original and a second party building something to match that documentation), but it is reverse engineering.

        The license they've applied to their work is a bit suss though: the work is clearly a derivative of the original, so it should be covered by Diablo's EULA, which probably prohibits redistribution like this.

    Do we need the source code for preservation though?

      You'd need to preserve the source code if you wanted to be able to make it run on different hardware. Give it say 20 years and you could have a hell of a time running the original Diablo executables. But given the source you could probably tweak it slightly to get it running again.

        Isn't that where emulation would come in?

          Emulation itself can be problematic simply because of the tremendous variety of hardware. For example, which of the dozens (if not hundreds of sound cards) do you emulate? And then there is the OS emulation. There are lots of different versions of DLLs so which one does the game need?

          Be easier if you could see the code for the game and know what it's looking for rather than trying to emulate a whole system.

            Most sound cards used common chipsets and a standard instruction set. So I don't see the issue there at all.
            Sounds like nit picking really.

              You're thinking modern sound cards, not the ones that were available when Diablo 1 came out. It was a bit of a free for all at the time. I remember having endless problems with different setups.

              It was just starting to stabilise and Soundblaster was becoming dominant around the time. But tons of people still had different sound setups and games were often written with multiple sound cards in mind.

              I'm trying to remember what card I was actually using back then, and I'm pretty sure it wasn't soundblaster.

              Sorry meant to add, no matter which way you look at it, it's easier to modify a single game than emulate an entire hardware and OS platform.

    As a former ScummVM dev involved in both *properly* reimplementing games and also obtaining original code from licensees this is horrible and wrong on so many levels.

    This is just assembly from IDA or something transliterated back to C. A developer woupd call this "lazy dirty reverse engineering". A lawyer would call it 'slam dunk copyright infringement' :P

    This is no favour for people actually working on legitimate game preservation projects :(

      ^^This! I can only assume (given the lack of upvotes for this comment) that far too many people don't realize what this "reverse engineer" actually is.

      The real source code, and this, are worlds apart, and much of the article reads as though the former has been released, rather than the latter.

    Good. My dream is that someday I'll be able to purchase Diablo 1 again legally - I decided a while back to stop pirating games, but there are almost no legal ways to get your hands on D1. I even have my original D1 disk from the 90's, but can't use it due to the fact I went without an optical drive on my PC and I think it's scratched to shit anyway.

    I checked with Blizzard customer support whether there was a way to get my hands on it, and even they told me to pirate it.

    This will disappear within a few days once Blizzard sends their lawyers his way. I'll give it 2-3 days.

    I'd recommend grabbing the code now if you have any interest + to make backups.

    Last edited 21/06/18 2:44 am

Join the discussion!

Trending Stories Right Now