Reverse engineering your favourite game: what is it, why do it and how to starton 30 August 2022 for Tech Professionals
Cover image: Nintendo
In his spare time, Exellys alumnus Olivier likes to reverse engineer games. Though it is a very niche subject, his peers at Exellys were curious to know more about it, so during his tribe’s ‘Talk of the Minds’ (which are knowledge sharing sessions among Exellysts), Olivier gave a presentation on the subject. You can watch it in full here:
- Olivier Luyckx
- 25 years old
- Lives in Kapellen
- Exellys alumnus and .NET & Java Back-End Developer
- Goes by Olifré in the online gaming community
- Big Nintendo fan & videogame preservation
How did you get started with reverse engineering?
“Seeing as how I’m such a fan of videogames and I’m also a programmer, it’s no surprise that I like game development. But even before I learned how to program, I was already comparing trailers for games with what we eventually got in the final release. Back then I was already wondering what made Nintendo decide to change so much from the trailer to the actual game.
So when I grew older and I learned how to program, I started to wonder how my favourite games were actually made. How are they coded? How are they constructed? But you don’t find any information on this online, those are company secrets. Occasionally some info will surface via leaks, and then you can get an insight into how games are made, and more specifically into what doesn’t make it into the final game.
Last year a lot of Nintendo internal documents were leaked, and that showed us for example that they designed a kind of grandpa Yoshi that was never actually used in the game. For enthusiasts like me this is very cool, this is information we otherwise would never get to see.”
So what do you do if you want to know even more about the game, and there aren’t any leaks about it?
“That’s where reverse engineering comes in. Reverse engineering is the process of trying to understand an existing application without any prior knowledge. It comes with a lot of guessing work and trial and error. That’s just how it works.
To reverse engineer a game, there are two things people start looking at. They will analyse the game ROM by looking at the assembly code and going to the resource files. In 99% of the cases you will find files lying around that aren’t actually used in the game. Just looking at them and seeing what they are, can give you an insight into how these games are made. It’s interesting to see what Nintendo was thinking and trying to do, but what ended up not being used. For anyone who is interesting in this sort of thing, I can recommend The Cutting Room Floor, which is like a Wikipedia for games. You can go to whatever game you want and find out what is hidden there, if there’s beta stuff or unused stuff, which is really cool to see. You can find the site at tcrf.net.”
Can you tell us a bit more about what tools you use for reverse engineering?
“You can use applications like IDA or Ghidra, which are closely related to each other. They are both debuggers, disassemblers and decompilers. Most people prefer Ghidra, because it’s open source and you get a free decompiler, which is a paid feature in IDA. These applications are used for really opening the game code and being able to see what it is doing.
Usually that’s where people stop, but if you want to know even more, you can start reverse engineering the whole game: really look at every single line of code and find out what it does. This is interesting for glitch hunters, speedrunners or anyone who’s interested in understanding game mechanics.”
Can you go even further?
“Yes, there is one step that can get you even deeper into the code, and that is decompilation. This is where you go from machine code back into a higher level programming language. Decompiling the assembly code into an equivalent C code (most Nintendo games are written in C or C++) makes it easier to read the code and to edit it. But before you can edit, you need to make sure your source is fully shiftable. This is important because the assembly will often reference to a function in a specific address, so if you add a line in the code, everything that comes after that won’t be in the right place anymore and this will cause the game to crash.”
Why would you want to decompile a game?
“Once you have a game fully decompiled, you can do a lot more sophisticated mods. You have the full game then, so you can basically do whatever you want: write an entire new game mode, add a new modern rendering engine, or add modern network code. But what people are most interested in, is porting to different systems.
Let’s take SuperMario 64 for example. This game was made for the Nintendo 64, but last year a group of 6 people fully decompiled this game. When it was finished, they released it to the public and about a month later somebody released a native PC port of SuperMario 64. He took the decompilation, stripped out all the Nintendo 64 specific calls and replaced them with abstractions. That way you’re left with a raw code base that isn’t relying on a specific hardware. You can just compile it, and there you go. You will have a native build of this game running on the PC. It’s so mind-blowing that something like this is possible. People are porting this game to the PlayStation now as well, I think that’s so cool.”
Exellys is a Tech Talent Incubator. We match ambitious companies with the finest tech talent. Are you ready to drive the innovations of tomorrow? Ready to make an impact and become a future-fit digital leader?
Whether you are a graduate or (young) professional, Exellys will unlock your full potential by guiding you to a challenging work environment that perfectly matches your personality, expectations and ambitions.
On top of that, you are enrolled in one of our very own training and coaching programs (based on your personal and professional ambition and experience). This means that, while working as an Exellys consultant, we are helping you to bridge your ambition to excellence.
Through intensive training and coaching, you’ll gain the essential skills, competencies and knowledge necessary to become the highly effective professional you aim to be. Become an Exellyst and get in touch with us today.