Reimplementation and Decompilation

If you need help with something, this is the place to be.
Post Reply
theone_32
Posts: 1
Joined: Mon Aug 18, 2025 5:04 pm

Reimplementation and Decompilation

Post by theone_32 »

Hi everyone!
there is this old racing game, Moto Racer (1997). It's a simple, fast-paced, colorful, and quite fun arcade game.
For some unknown reason, this game means to me what Lego Island means to Matt, I guess. :lol:
Just kidding. I suppose there's some nostalgia effect, too — it reminds me of my high school years...

A few months ago, I decided I wanted to recreate this game to make it run on newer architectures, eventually porting it to my Android TV (don't ask...).
I started with Ghidra and reversed all the game file formats: geometries, textures, UI elements, scripts, fonts, sounds and so on.
Most of the data even had several different custom encryption mechanisms that took me a few days to decrypt, and only after I could finally figure out the actual file formats.
What I could not reverse through decompiling and debugging, I managed to figure out by altering game data and running the actual game to see what changed.
Once I had built a fairly extensive library of files specs and Python tools, I started a reimplementation project in C with OpenGL and SDL, recreating everything from the intro to menus to actual in-game play.
It looks quite nice in HD at 32bpp and 60fps. :D

But...

I am not satisfied with the current result, mostly because I can't replicate the exact gameplay, which is what made this game fun for me.
So.. I was considering of going back to ghidra and evaluating a decompilation instead.
Game executable is a simple MSVC 4.2 compiled exe, using DDRAW; ghidra already did a good job, apart of course the missing data structures that need a "human touch".
However, I am not familiar with the tools and techniques that could help with this task, especially in obtaining buildable code—possibly mixed ASM and C—as I progress in defining structures and renaming objects in Ghidra.

What is the state of the art? Which tools are preferred to generate buildable code, even while if it is not yet fully decompiled? And how can I progressively replace that code with the decompiled code I get from Ghidra?

Thanks, everyone! If anyone is interested in my work, I'll be happy to provide more details—just ask!
Halamix2
Posts: 17
Joined: Sat Dec 10, 2022 6:39 pm
Location: Poland
Contact:

Re: Reimplementation and Decompilation

Post by Halamix2 »

I know of some approaches to this:
  • You could create a CMake project that uses the exact MSVC 4 compiler (down to version of optimizing/non-optimizing one, and compile flags), and compile it that way; then use reccmp [1] (a tool that started as a part of Lego Island Decomp [2]) to compare original .exe functions to yours. In this scenario you might need to recreate a lot of functions to even see the game window at all, since we're not reusing any parts of the original exe nor hooking to it.
    • I'm also decompiling an old game called Stunt GP [2], and I've chose to simply start from main and reimplement functions one by one going as deep as possible; this might not be the most optimal solution, but for now I'll stick with that
  • You could create a .dll and inject functions you've recreated at the runtime. This way you can replace parts of the game as soon as possible, and still have a working game. I *think* RE3 GTA3 decomp used this technique [4].
  • anything in-between, maybe it's possible to join these two approaches
[1]: https://github.com/isledecomp/reccmp
[2]: https://github.com/isledecomp/isle
[3]: https://github.com/stuntkit/regp
[4]: https://github.com/hottabxp/re3, original repo was DMCA'd
Post Reply