Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Disassembled code from a C or C++ compiler is generally better structured than hand written assembly.

I reverse engineered major parts of Westwood’s Blade Runner for ScummVM. It was compiled with the Borland C++ compiler in 1997 and a lot of it was relatively easy to decompile. The most difficult parts were video decoding and character rendering. The video decoder was older Westwood code, clearly hand optimized, and the character renderer was also very optimized.

Currently I’m working on Cryo’s Dune which is all hand-written assembly code. The code jumps all over the place, parameters are passed in arbitrary registers and have to be traced over several calls. I’ve seen a function that, instead of using ret to return, jumped to the ret-instruction of a different function.

Code generated by an older compiler that doesn’t do too much optimization is vastly preferable.



I have been toying with doing this to simtower for awhile. The disassemblers are a bit all over the place with respect to Win16 NE code though. Bit annoying to do though as it uses a decent amount of the win16 API so those bits have to be done too sometimes to figure out what is going on. Though it is fairly decently documented so you can block off the game bits from the win16 bits and just skip past the crazy way win16 loads dlls up.


Keep in mind that there was also a MacOS version of SimTower. 68k assembly is pretty easy to follow...


hmm good point. Assuming they started with a similar code base it could be useful too.


Thanks for the insight. I've assumed hand written assembly, except for those parts where you try to squeeze out the last bit of performance, would be structured more like a human would think, but alas I might be wrong. :-) But then again the two games I tried were compiled with Watcom, which according to mmy research was pretty advanced when it comes to optimizations, for its time at least. The biggest turnoff for me was finding the right tooling though. It's not like there are many tutorials for reverse engineering, and those that exist mostly aimed at security research or cracking, targeting modern software. I found that Ghidra was unable to even load a Watcom binary, it crashed. A year later there was a patch for that, but then Ghidra didn't understand the Watcom calling convention. Found some incomplete plugin for this, but it was just blindly marking all functions as Watcom calling convention. Then I gave up. It might not be the best idea to start learning RE with a full blown game, but at the same time, if you wanna do this "for fun", it actually has to have a fun goal.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: