In a previous episode of Behind the Code, we talked about how the scoring logic of Tetris can crash the game at high levels.
Now what is even more interesting is that you can hook up extra controllers to the expansion port on a Famicom and use them to redirect code execution to the A-Type and B-Type High Score Tables in the game!
Why would you want to do that? Well… assembly code is basically just numbers that are interpreted as instructions by the CPU. When you enter your name in the High Score Tables, those characters are stored in RAM as values. A is 1, B is 2, and so forth.
If we enter a name with the intention that the characters’ values will be interpreted as code… we can use the High Score Tables to reprogram the game.
Intercepting Tetris code execution, how controller ports work, how to redirect code execution to RAM, what on earth we are going to program, and seeing it in action on real hardware… It is all here.
Hope you enjoy it!