4 ms·
Hey, article author here. I'm not very good at this stuff, it's just applying knowledge I've picked up over my career working in systems-level programming and v
by coldpie 6y ago
Hey, article author here. I'm not very good at this stuff, it's just applying knowledge I've picked up over my career working in systems-level programming and various little game hacking projects.
The one thing I'd say is a real pre-requisite is to learn C. And I mean really learn C: pointers, including arithmetic and aliasing; memory allocation; stack vs heap; statics and globals. C is the lingua franca of this environment, and learning C will give you a good window into what the compiler is doing to turn your code into what's actually running on the CPU.
It's also good to understand how computers actually work. I strongly recommend the book "Code" by Charles Petzold (Microsoft Press, be wary of counterfeits and don't buy from Amazon). It starts literally from scratch. Like, light bulbs with electricity and a switch. Then it builds on that to create a fundamental CPU, and then shows how to go from there into the real CPUs used today, including an introduction to assembly language and machine code. It's a fantastic book if you ever want to do anything low-level on a computer.
Once you've got C and a basic level of understanding of assembly/machine code, I think you're ready to do something real. Start simple. The NES runs on a 6502, which is 8-bit, has three registers and only a handful of opcodes, and is single-threaded. In the past I've used FCEUX-DSP's debugger features[1], but I think these days most people use Mesen. You can use the same basic techniques I did in these articles: scan memory for the values you want (the player's score or life count; the player character's velocity), then set watch points to find the code that modifies them, then go understand what that code is doing and change it to do what you want. Give yourself infinite lives or a crazy high jump in Super Mario Bros or something.
From there you can move on to more modern CPUs and such, but the complexity goes _way_ up once you move on from environments where most stuff was actually written in ASM or very simple C without fancy compilers. I was very relieved to see how readable Super Monkey Ball's disassembly actually was.
[1] My first real game RE project was dumping PNG pictures of the levels in M.C. Kids for NES, for comparison on TCRF:
https://gitlab.com/mcmapper/mcmapper/-/blob/master/main.c https://gitlab.com/mcmapper/mcmapper/-/blob/master/main.c
https://tcrf.net/Proto:M.C._Kids https://tcrf.net/Proto:M.C._Kids
- samwestdev 6y agoThe book "Code" is by Petzold Charles
- coldpie 6y agoIndeed, fixed. Thanks.
- rcfox 6y agoFrom my experience: learning C will help you learn assembly, which will help you actually learn C.
- btkramer9 6y agoHaha this is very true. This also seems very true for Algebra and Calculus. I never really remembered/internalized all of the rules of Algebra (moving around log, e, ln, a^x, etc) until doing derivatives/integrals by hand
- corysama 6y agoThanks for the article! Over in https://www.reddit.com/r/ReverseEngineering/ https://www.reddit.com/r/ReverseEngineering/ there are a bunch more people who would really appreciate it if you also posted there.
- coldpie 6y agoThanks for the suggestion, I have done that. If you know of other communities that might enjoy the article, please do feel free to pass it along anywhere you like.
- breakingcups 6y ago/r/REGames is also a good one