Tetris

hackers-discover-how-to-reprogram-nes-tetris-from-within-the-game

Hackers discover how to reprogram NES Tetris from within the game

Building a better Tetris —

New method could help high-score chasers trying to avoid game-ending crashes.

I can see the code that controls the Tetri-verse!

Enlarge / I can see the code that controls the Tetri-verse!

Aurich Lawson

Earlier this year, we shared the story of how a classic NES Tetris player hit the game’s “kill screen” for the first time, activating a crash after an incredible 40-minute, 1,511-line performance. Now, some players are using that kill screen—and some complicated memory manipulation it enables—to code new behaviors into versions of Tetris running on unmodified hardware and cartridges.

We’ve covered similar “arbitrary code execution” glitches in games like Super Mario World, Paper Mario, and The Legend of Zelda: Ocarina of Time in the past. And the basic method for introducing outside code into NES Tetris has been publicly theorized since at least 2021 when players were investigating the game’s decompiled code (HydrantDude, who has gone deep on Tetris crashes in the past, also says the community has long had a privately known method for how to take full control of Tetris‘ RAM).

Displaced Gamers explains how to reprogram NES Tetris within the game.

But a recent video from Displaced Gamers takes the idea from private theory to public execution, going into painstaking detail on how to get NES Tetris to start reading the game’s high score tables as machine code instructions.

Fun with controller ports

Taking over a copy of NES Tetris is possible mostly due to the specific way the game crashes. Without going into too much detail, a crash in NES Tetris happens when the game’s score handler takes too long to calculate a new score between frames, which can happen after level 155. When this delay occurs, a portion of the control code gets interrupted by the new frame-writing routine, causing it to jump to an unintended portion of the game’s RAM to look for the next instruction.

Usually, this unexpected interrupt leads the code to jump to address the very beginning of RAM, where garbage data gets read as code and often leads to a quick crash. But players can manipulate this jump thanks to a little-known vagary in how Tetris handles potential inputs when running on the Japanese version of the console, the Famicom.

The Famicom expansion port that is key to making this hack work.

Enlarge / The Famicom expansion port that is key to making this hack work.

Unlike the American Nintendo Entertainment System, the Japanese Famicom featured two controllers hard-wired to the unit. Players who wanted to use third-party controllers could plug them in through an expansion port on the front of the system. The Tetris game code reads the inputs from this “extra” controller port, which can include two additional standard NES controllers through the use of an adapter (this is true even though the Famicom got a completely different version of Tetris from Bullet-Proof Software).

As it happens, the area of RAM that Tetris uses to process this extra controller input is also used for the memory location of that jump routine we discussed earlier. Thus, when that jump routine gets interrupted by a crash, that RAM will be holding data representing the buttons being pushed on those controllers. This gives players a potential way to control precisely where the game code goes after the crash is triggered.

Coding in the high-score table

For Displaced Gamers’ jump-control method, the player has to hold down “up” on the third controller and right, left, and down on the fourth controller (that latter combination requires some controller fiddling to allow for simultaneous left and right directional input). Doing so sends the jump code to an area of RAM that holds the names and scores for the game’s high score listing, giving an even larger surface of RAM that can be manipulated directly by the player.

By putting “(G” in the targeted portion of the B-Type high score table, we can force the game to jump to another area of the high score table, where it will start reading the names and scores sequentially as what Displaced Gamers calls “bare metal” code, with the letters and numbers representing opcodes for the NES CPU.

This very specific name and score combination is actually read as code in Displaced Gamers' proof of concept.

Enlarge / This very specific name and score combination is actually read as code in Displaced Gamers’ proof of concept.

Unfortunately, there are only 43 possible symbols that can be used in the name entry area and 10 different digits that can be part of a high score. That means only a small portion of the NES’s available opcode instructions can be “coded” into the high score table using the available attack surface.

Despite these restrictions, Displaced Gamers was able to code a short proof-of-concept code snippet that can be translated into high-score table data (A name of '))"-P)', and a second-place score of 8,575 in the A-Type game factors prominently, in case you’re wondering). This simple routine puts two zeroes in the top digits of the game’s score, lowering the score processing time that would otherwise cause a crash (though the score will eventually reach the “danger zone” for a crash again, with continued play).

Of course, the lack of a battery-backed save system means hackers need to achieve these high scores manually (and enter these complicated names) every time they power up Tetris on a stock NES. The limited space in the high score table also doesn’t leave much room for direct coding of complex programs on top of Tetris‘ actual code. But there are ways around this limitation; HydrantDude writes of a specific set of high-score names and numbers that “build[s] another bootstrapper which builds another bootstrapper that grants full control over all of RAM.”

With that kind of full control, a top-level player could theoretically recode NES Tetris to patch out the crash bugs altogether. That could be extremely helpful for players who are struggling to make it past level 255, where the game actually loops back to the tranquility of Level 0. In the meantime, I guess you could always just follow the lead of Super Mario World speedrunners and transform Tetris into Flappy Bird.

Hackers discover how to reprogram NES Tetris from within the game Read More »

34-years-later,-a-13-year-old-hits-the-nes-tetris-“kill-screen”

34 years later, a 13-year-old hits the NES Tetris “kill screen”

A moment in <em>Tetris</em> history.” src=”https://cdn.arstechnica.net/wp-content/uploads/2024/01/tetrisrecord-800×394.png”></img><figcaption>
<p><a data-height=Enlarge / A moment in Tetris history.

For decades after its 1989 release, each of the hundreds of millions of standard NES Tetris games ended the same way: A block reaches the top of the screen and triggers a “game over” message. That 34-year streak was finally broken on December 21, 2023, when 13-year-old phenom BlueScuti became the first human to reach the game’s “kill screen” after a 40-minute, 1,511-line performance, crashing the game by reaching its functional limits.

The game-crashing, record-setting performance. Jump to 38: 56 for BlueScuti’s disbelieving reaction to his achievement and a short interview.

What makes BlueScuti’s achievement even more incredible (as noted in some excellent YouTube summaries of the scene) is that, until just a few years ago, the Tetris community at large assumed it was functionally impossible for a human to get much past 290 lines. The road to the first NES Tetris kill screen highlights the surprisingly robust competitive scene that still surrounds the classic game and just how much that competitive community has been able to collectively improve in a relatively short time.

From hypertaps to rolling

If and when a player reaches Level 29 on NES Tetris (after clearing between 230 to 290 lines, depending on the starting level), the game reaches its highest possible speed. At this point, simply holding down left or right on the NES D-pad can’t usually get a piece all the way to the side of the well unless the board is extremely “low” (i.e., pieces only on the first one or two rows, maximum). Thus, for years, players that reached Level 29 found their games usually “topped out” just a few pieces later.

A demonstration of hypertapping technique.

The first known way past the brick wall of Level 29 was a technique that became known as hypertapping. By using a special grip that lets you vibrate a finger over the D-pad directions at least 10 times a second, you can effectively skip the “delayed autoshift” (DAS) that limits how fast pieces can move laterally when the D-pad is held down.

With hypertapping, players can effectively move pieces at Level 29 speed even when the board is stacked four or five levels high. While that gives a little breathing room, a run of bad pieces or execution can still put a hypertapper in an untenable position where the pieces start to stack up high, and completing new lines becomes essentially impossible.

The first Level 30 NES Tetris performance on record, from back in 2011.

Noted Tetris pro Thor Aackerlund was able to eke out a Level 30 hypertapping performance in 2011. But it wouldn’t be until 2018 that Joseph Saelee used his mastery of the technique to dominate the 2018 and 2019 editions of the Classic Tetris World Championship, a live tournament that takes place at the Portland Retro Gaming Expo every year. By 2020, Saelee had hypertapped his way to a Level 35 performance, while fellow player EricICX had achieved the first Level 38 performance.

A deep dive into the advanced Tetris control technique known as rolling.

Then, in 2021, a new, even faster button-mashing technique appeared on the competitive Tetris scene. This “rolling” technique was inspired by arcade player Hector “Fly” Rodriguez, who used a similar multi-finger roll to set button-mashing records on the Track & Field arcade game. Tetris players adapted this technique by combining it with a grip that lets you tap the back of the NES controller with a “roll” of three to five successive fingers. This roll of the fingers then nudges the D-pad into a finger on the other hand to register an extremely quick series of directional button presses.

Rolling is fast enough to get pieces to the sides on Level 29-speed boards stacked up to eight rows high, giving Tetris masters quite a bit of leeway in their quest for longer games. Cheez, one of the first players to master the rolling technique, hit Level 40 in 2021, but that was just the start of how far things could go.

A Level 146 performance from 2022 that shows NES Tetris can be effectively played indefinitely at Level 29 speed.

By the time EricICX managed to roll his way to Level 146 in August 2022, it was clear that players were getting good enough to effectively play indefinitely on the same “Level 29” speed that had been considered an effective kill screen just a few years earlier. Players were getting so good at stretching their NES Tetris games that the community started debating how to stop tournament matches from going on too long (they eventually settled on a modded game with an even faster Level 39 “super killscreen” for competitive play).

34 years later, a 13-year-old hits the NES Tetris “kill screen” Read More »