View Single Post
Old 17-09-17, 21:58   #1
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default Tomb Raider 5 Decompilation Project

Tomb Raider 5 Decompilation Project

TL;DR AT THE END

The goal of this project is to decompile entirely Tomb Raider 5 to C/C++ code. There are many reasons for that; first, having the source code (or a functionally equivalent code) of the game allows modding it much more extensively than what the existing patches (TREP, TRNG, etc.) can do, because where those patches will inject code, and patch parts of the memory using hacks and workarounds, here, we can simply modify the code and recompile. Second, it is almost certain that Square Enix / Crystal Dynamics are not in possession of the code. We know that the source code of TR1 and TR2 (used to make the mobile versions) have been given to SE by former Core Design employees, but we are almost sure that the source code of the other games have been lost. This project allows us to preserve a part of history that would be lost otherwise.

How?

A lot of information required to decompile the game comes from the symbol files contained in the leaked TR4-5 PSX SDK. A symbol file is a file contains a list of memory address, and the name of "what is at that address". When you load the executable binary file of the game, you only get the raw binary code, without any function or variable name. A symbol file allows us to put back the original function and variable names, hence making the reverse engineering process much easier.
The symbol files contained in the leaked SDK are of a special format that contains much more information than simply the names, and thanks to Steffen Ohrendorf (OpenTomb & EdisonEngine developer) we have been able to get even more than names: function definitions, variable types and even the original file names.
Thus, our current source tree is very similar (for the PSX version, it's identical) to the original one.

Source tree

The repository is divided in multiple folders (exactly like the original source code):
  • GAME = main game code, that is common between platforms
  • SPEC_* = platform-specific code
    • SPEC_PC = PC version
    • SPEC_PSX = PSX version (requires the Psy-Q SDK and toolchain)
    • SPEC_PSXPC = PSX version that runs on PC (used for debugging purposes)
    • (maybe one day) SPEC_CE = Dreamcast

Current state of the project

As of today (2017-09-17), all three trees compile without errors. The PSX and PSXPC run up to the main game loop, where they just loop and do nothing.
The PSX version can currently go up to the first loading screen (with the spinning CD icon), but a lot of work still needs to be done since on PSX, all the loading code is located in a separate file that is dynamically injected at runtime.
The PC version can currently go up to the main game thread and the level loading part (title level) but the level loading code is not finished yet, so the game crashes a little bit, unless you comment out the main thread code, then the game just loops indefinitely like its PSX counterpart.

Who?
  • Gh0stBlade: main developer, now works mainly on PSX version
  • zdimension: main developer of PC version

Legal stuff

All code here comes from decompilation of publicly available (this includes the leaked SDK) binaries and ressources of Tomb Raider 5. Additional informations about the game's internal mechanisms come from the TRosettaStone 3 project. Square Enix plz don't sue us. We're basically retrieveing the game's source for free whereas your developers would want money.

TL;DR

We're decompiling TR5 so that you can mod it more easily (and that we, developers, can understand it better and make better tools).
It is not finished at all.
There is still a lot of work to do.
It may take months, it may take years.

Want to help?

Currently we're searching for people that know C and C++, and that can use IDA Pro or similar reverse engineering tools. Knowledge of x86 and/or MIPS assembly is a plus.

Shut up and take my money!

GitHub:
Binaries:
None

Screenshots:
click here

Last edited by zdimension; 20-02-19 at 16:28.
zdimension is offline   Reply With Quote