Leaderboard
Popular Content
Showing content with the highest reputation on 09/04/2021 in all areas
-
Open Source Decompilation of Rock Raiders
Crystalyzer reacted to trigger_segfault for a topic
Over the last few months (starting with the CFG In-depth research), I've started working through the entire `LegoRR.exe` assembly and identifying functions, global variables, symbols, and data types. Since then, things have progressed to the point where most of the game code can easily be navigated. Much of this is thanks to the recent GODS98 engine leaks, which sped things up 10 fold! (This page is going to go through numerous rewrites, to better organize most of the found information) General Info LEGO Rock Raiders is written entirely in C (with an exception of C++ with AVI and VideoPlayer classes, which have C wrappers). British spellings are being used for symbols to match DDI's naming conventions: i.e. Initialise, Finalise, Colour, etc... Naming conventions also aim to use accurate internal names, rather than commonly-known names seen during gameplay: i.e. Spade (shovel), OohScary (sonic blaster object), BirdScarer (sonic blaster boom), Immovable (solid rock), Medium (loose rock), Loose (dirt), Lake (water), Water_unused (flood water feature that was never implemented). All functions in assembly are easily identifiable and separated by address. The same goes with global variables (to an extent). DDI likes to group global variables for a module into one large structure, this is what causes most global variables to appear in an organized fashion. Even better, all game-specific modules for LegoRR appear in alphabetical order, making identification infinitely easier. Ghidra All reverse engineering work has been done through Ghidra. This is a free alternative to IDA, and offers a rough C decompilation of individual functions that works well enough, but chokes when handling heavy use of pointer arrays. Code Modification Based on the same manner of DLL-injection used by LRR:CE, it's possible to replace individual functions within LegoRR for testing (or for messing around). Cleaning up this approach and making it more user friendly will help as a base for creating an open-sourced version of LegoRR (in similar fashion to OpenRCT2). There are no immediate plans to start this, but it is already 100% possible to make useful and meaningful changes to the game through this approach. Below are some tests that have already made use of this: First-person controls in Top-down view Changing drilled walls from spawning spiders to Tool Stores Breaking everything with cycle-able wall spawns Multi-colored and level-based crystal coloring Yup, crystals support levels, and LV1 Crystals can be spawned with the CryOre map secondary values. Resource monitoring Links All work is being published to the same GitHub repository as used for the CFG research, among other things. Ghidra archive - An archive of the project where all reversing and symbol labeling is done. DDI data - Useful source leaks, including the GODS98 engine, a half-finished GODSPSX engine, and LegoRR PSX debug symbols. Source dump - Export of Ghidra's decompiled code (this is messier than hand-decompiled code, but will span the entire codebase). Modules map - Same as the section below, but with more information. LRRMonitor - Modification of LRR:CE for injecting and replacing self-written code into LegoRR. Decompile - Hand-written decompiled code, cleaned up from Ghidra's most unreadable messes. ModeSelection - Hand-written decompilation of the entire Mode Selection dialog, shown before booting LegoRR. CLGen - Hand-written decompilation of the entire CLGen tool for modifying LegoRR's standard command-line arguments. Modules map All functions in assembly are easily identifiable and separated by address. The same goes with global variables (to an extent). LegoRR modules Game code specific to LEGO Rock Raiders. All LegoRR game modules appear in alphabetical order (or at least almost every module*). Many names are based off of the PSX symbols dump, or based on commonly used names in CFG, NERPs, etc. Many enum names are a dead giveaway for a section's module, as the GODS engine also follows the pattern of prefixing enum names with the module name. GODS98 modules Data Design Interactive's GODS engine. Code not specific to LEGO Rock Raiders. All names are source-accurate, thanks to legally-obtained dumps of the GODS engine (for Windows 98). Remaining modules Misc groups of modules. Contains GODS module: Init, and GODS indirectly-related module: RNC.1 point
