GCC
GCC is one of the most widely used compilers, and that holds true for game development. A large proportion of N64 games were compiled with GCC. However, there are many different versions of GCC. Due to its open source nature, some development houses made custom modifications to official releases, such as KMC GCC. The community has had to reverse-engineer these differences for some games in order to reproduce a compiler that can be used for matching decomp.
Below are the known GCC versions and some examples of games / projects that used them. (todo: add links and pages for these compilers and projects)
N64
- 2.7.2 (KMC, etc)
- 2.8.1 (Paper Mario)
- EGCS sompthin (iQue)
PSX
- PSY-Q toolchain
Decompilation patterns
Todo add https://github.com/pmret/papermario/wiki/GCC-2.8.1-Tips-and-Tricks
Todo add https://hackmd.io/eYQR3yfhQymeTGsVM-SpEg
Conditional range
Used when comparing a variable to a specific range of integers.
if (((u32)(var_a0 - 0xE)) < 9)
This can be translated into
if (var_a0 >= 0xE && var_a0 < 9 + 0xE)
And can be simplified as
if (var_a0 > 13 && var_a0 < 23)
The way it works is that if var_a0 is less than 14, when 14 is subtracted and then converted to unsigned then it will be greater than 9, effectively being equivalent to the conditional range prior to optimization.