logoalt Hacker News

darksim905 • today at 5:44 PM • 1 reply • view on HN

Could someone explain decompilation / these video game recompile projects? Around when AI started getting more prominent, I saw a few pages that had just a list of a few games and a percentage bar/some blocks, but no context, no link to projects, etc.


Replies

FLeXMurphy • today at 5:52 PM

You can think of these as a kind of a "static emulator" that is executed once. The opcodes are dumped from Platform A into a mixture of C and Assembly (whatever assembly that platform is using) to prepare for Platform B. It is absolute spaghetti with no real meaning to any particular block of code.

The objective of decomp is really "re-targeting". You go ahead and try to bootstrap the game code so that it will open up on another platform (like say, a Win32 Portable Executable file, your standard .exe file). You may have to substitute opcodes that the original processor had that your new processor might not have. Not as common now as it was, more platforms just use x86-64.

There is more to it than this of course, esp. if the compiler on Platform A emitted library code intended for specific peripherals and whatnot, but this is a "quick and dirty" way of getting a game to run. If you think about it, you first have to remove all the code specific to Platform A but find the logical or functional equivalent code for Platform B, and insert it into the correct places.