Comments (1)
Hello @idubrov , thanks for your kind words, I really appreciate it
I intend to continue that document, but currently I spend most of my time coding. I learnt a lot of Watcom C++ specific code patterns that I still want to document in that article. I actually set up an MS-DOS development environment with the original compiler to try out various C++ constructs and study how their disassembly looks like. One particular pattern I would highlight is the RTTI data layout and virtual tables in general. I am sure it would be useful for anyone who wants to work with MS-DOS games that were written in Watcom C++.
A couple months ago when I messed around with M.A.X. 2 I accidentally found out that its MS Visual C/C++ compiler emitted RTTI data including class names. Amazingly M.A.X. 2 reused more than 112 classes from M.A.X. 1. The entire AI, building management and most GUI related stuff are copy and paste from the first game which gave a big boost to my work. Another good source of information was Fallout 2's official Mapper tool which was released with full debug information included (by accident?). Yet another useful source was Fallout 1 & 2 themselves as their Macintosh releases embedded full symbol tables for every function
M.A.X. 1 & 2 and Fallout 1 & 2 use the same game engine, called GNW. So basically the work I did here is fully reusable for those other games as well. Interestingly Fallout 1 & 2 did not use any C++.
One interesting observation I made is that, at least for Watcomβs old compiler, reversing C++ is easier on assembly level than on pseudo code. The reason I say this is that C++ does a lot of magic in the background which is part of the language and should not be reproduced in the rewritten C++ code itself.
For a basic example the C++ standard says that it is fine to call the delete operator on a Null object without a Null pointer check. How does this work in practice? The Watcom compiler simply wraps all delete operator calls with an implicit Null pointer check. So what happens if the code author adds an explicit check as well out of paranoia or ignorance? There will be two Null checks and both will be reproduced in the pseudo code as well. Constructor and destructor calls, returning classes by value and similar constructs are just super confusing on pseudo code level while on assembly level the patterns can be identified with high clarity.
If you go for another MS-DOS game, then I recommend using a similar approach to what I did for M.A.X. The ability to always have a "functional" version of the game, to be able to rewrite stuff incrementally and integrate the changes right away is incredibly useful. It's rather difficult when the game uses C++ though as we cannot control the space allocated for C++ objects and this could break the ABI quite fast... so another recommendation I could give is to select a game that was not written in C++.
Actually when I started this project I did not know that most of the game was written in C++
I wish you good luck with your project too and thanks!
from max.
Related Issues (10)
- [Bug] Keyboard modifiers stick HOT 1
- Demo support? HOT 4
- [Bug] HOT 7
- Use the SR framework for binary recompilation and SDL support HOT 1
- Mechanized Assault & eXploration Reloaded HOT 1
- Link dead HOT 4
- [Bug] Moving mouse pointer to close to border leaves the game HOT 5
- [Suggestion] Allow coop network games vs AI HOT 4
- MAX Community HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from max.