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.
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.
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.