AetiasHax / ph

Decompilation of The Legend of Zelda: Phantom Hourglass
17 stars 3 forks source link

Add `m2ctx.py` for decomp.me #3

Closed AetiasHax closed 10 months ago

AetiasHax commented 11 months ago

m2ctx.py generates a context for decomp.me, including type definitions, macros and function declarations that you may need in order to decompile a function.

All it has to do is to accept one C/C++ file and recursively preprocess all #includes. We may also want to preprocess #ifs, #ifdefs and similar directives so that the context gets smaller. But do not preprocess macros! They are meant to be used in the decompiled code, after all.

AetiasHax commented 10 months ago

m2ctx.py is now in the /tools directory. However, it uses gcc -E -P -undef -dD, which preprocesses everything, including macros. Fortunately, it still leaves the #define directives in the output, so the macros can be used in decomp.me.