Introduction

Tetris is the most well-known and best-selling GameBoy game, but has received only little attention in terms of TASing. This is probably partly due to it's deceptively simple mechanics, the short game length, and being overshadowed by the (comparatively less successful) NES and DX versions.
I started looking into Tetris merely for the sake of it and not from a TAS perspective, but I decided to create a TAS for it when I discovered a bug which can actually be used to save time compared to normal gameplay. It shows that even such a simple and short game as Tetris can contain time-saving glitches, which was reason enough for me to create a movie of it.
This bug accounts for a large part of the 416 frames which are saved compared to the currently published run (taking into account lag differences).

About the run

Goal and general strategy

The goal is to beat the "B-Type" game mode as fast as possible, getting the "best ending" (by playing at Level 9 and High 5). To beat B-Type, 25 lines need to be cleared. Each line consists of 10 blocks, which result in 250 cleared blocks total, requiring 62.5 tetriminos on an empty board. The general idea is to both minimize the number of needed tetriminos and place them as fast as possible. The number of needed tetriminos can be decreased in two ways, by using the pre-existing blocks which are generated when starting the game, and by exploiting a bug when clearing lines, which allows to duplicate blocks. The latter method turns out to be way more effective and it described in detail in the mechanics section, while the former method turns out to not be worth it, the saved time is eaten up by the additional time needed to drop the tetriminos farther down.
Also, the line clear animation costs time, so the number of individual line clears should be minimized. It is possible to beat it using only seven individual line clears (6x4 + 1). This run uses eight, but only 4 of them happen during the run, the last 4 happen after the input already ended, and thus don't count towards the total time. Manipulating the next tetriminos so that the input can end early is the second big time saver of this run.

Emulator

This run uses BizHawk and syncs on any version except 1.7 (due to frame timing differences). Note that the previous run was made in VBA-rr, which has less lag, resulting in a 30 frame difference in the initial menus (there are no lag differences during an active game).

Version

There are two versions of GB Tetris, v1.0 and v1.1, which only differ in very few aspects. The most important difference is that the initial legal screen is shown two seconds longer in v1.1. I decided to go with the v1.1 version anyway, since this is the version the previous run uses, it is the far more commonly distributed version (v1.0 was only released in Japan) and the time save is trivial. Also, only the v1.1 version contains Коробейники (Korobeiniki), the famous Tetris sound track, as the A-Type song, which significantly increases the run's entertainment value in my opinion.

Options

This run is performed on Level 9 and High 5, which not only allows for the "best ending", but also turns out to be the fastest settings. Cranking up the level and therefore the speed at which the tetriminos drop slightly decreases the time needed to place them (there is no hard drop in this game), and the High is cranked up to decrease the distance the tetriminos need to travel before being placed.

Mechanics quirks

Despite being such a simple game, this version of Tetris has quite a few quirks that can either help or be in your way.

Moving tetriminos

Each frame you have the option to issue inputs to control the tetrimino, rotating or shifting it left or right or dropping it by one block. Additionally, there is a frame timer moving the block downward (the speed of which depends on the level), which progresses each frame you are not pressing down manually. The timer is not reset when dropping the tetrimino manually, which means the fastest way to drop it is not by holding the button down, but by pressing down only every third frame (which is the cooldown of manual dropping), letting the timer tick for the other two frames.

Clearing lines

If rows become entirely filled with blocks, they get cleared and the rows above them move down. This does not apply for the two top rows, though. For some reason, the developers decided that the two top rows cannot be cleared, even if they are completely filled, the loop which checks for filled rows only begins at the third row.

Line clear bug

Due to particularly bad programming, all blocks in the topmost row get duplicated to all rows below it when multiple lines are cleared. This is no big deal in normal gameplay, since it is hard to get a block in the topmost row and continue clearing lines afterwards, so most of the time it is empty anyway. In this run, this bug is exploited extensively in order to duplicate as many blocks as possible and therefore decreasing the number of needed tetriminos.
To give an example on how this works, consider this board:
+-+
|xxxx   x x|
|xxxx xxxxx|
|xxxx xxxxx|
|xxxx xxxxx|
|xxxx xxxxx|
|xxxx xxxxx|
|   xxx    |
When an "I" tetrimino is placed to clear the lines, the topmost row moves down to the 5th row. Due to the bug, however, it is also copied into the 2nd, 3rd and 4th row:
+-+
|          |
|xxxx   x x|
|xxxx   x x|
|xxxx   x x|
|xxxx   x x|
|xxxx xxxxx|
|   xxx    |

Losing

While it seems obvious in normal gameplay, the losing condition is actually not clearly defined for Tetris. In this version, you lose if a tetrimino gets locked in its starting position (regardless of rotation changes) two times. This can become an issue for these kinds of runs which are trying to complete lines as far up as possible, but it hasn't been in this one. Note that when moving tetriminos only the destination position is checked for collisions, not the current position, which means that even if a tetrimino spawns inside other blocks, it can still be moved.

Heart mode

There is a hidden harder game mode which can be accessed by pressing Down + Start at the title screen. It is indicated by a heart symbol next to the level display and increases the effective level by 10, but has no further implications on scores or endings you get. While it seems logical to use it in this run to save time dropping the pieces, I found it to be slower overall: At level "9 Heart", it is not possible to fill the rightmost block in the topmost row by any means due to how fast the tetriminos are dropped, which prevents exploiting the line clear bug to its fullest. Technically, it would be possible at "8 Heart" and lower, but it wouldn't result in the "best ending".

RNG

The game's random number generator is primitive, but effective. It uses the raw value of the DIV counter (a 1-byte hardware clock) for all random events. This means the RNG has exactly 16384 possible states at any given point during the game's execution (256 values with 64 intermediate states each). This comparatively low number has some implications, for example for the initial blocks placed when starting the game at High > 0. Since the process of starting a game is entirely deterministic, there are at most 16384 possible different starting configurations for any given High value (in reality there are even less, since some result in the same board being generated). These starting configurations determine both where blocks are placed and which the initial 3 tetriminos are. This means that where the blocks are placed and which tetriminos you get at the start of the game can only be manipulated very roughly, using one of the few possible board configurations.
Also, most of the time the only way to manipulate luck effectively is by delaying frames, which is why in this run some of the tetriminos are dropped way slower than they could.

Tetrimino selection

At any point in the game the three next tetriminos are determined: the one currently on the board, the one in the preview window and a hidden third one. Whenever a tetrimino is placed, the other two move up a spot and a new tetrimino is randomly chosen to go into the hidden spot.
Due to particularly bad design decisions combined with poor programming, the "random" selection of the new tetrimino is biased depending on the other two tetriminos, though. The developers apparently thought that getting the same tetrimino three times in a row is not perceived as "random", so they made an effort to prevent this, or at least make it more unlikely. If the same tetrimino as the other two is chosen, it is re-rolled, at most 2 times. If it's still the same the third time around, they keep it anyway. Unfortunately, they failed to implement this test properly (they use bitwise or to combine the three tetrimino data values), which triggers the re-roll even in cases where it shouldn't. This skews the probability for each tetrimino type depending on its internal data value:
Tetrimino Data Value Probability (perfect RNG) Probability (Game RNG)
L 0x00 10.3229% 10.5102%
J 0x04 13.6637% 13.7503%
I 0x08 13.6637% 13.8487%
O 0x0c 16.2286% 16.4093%
Z 0x10 13.6637% 13.6401%
S 0x14 16.2286% 15.7913%
T 0x18 16.2286% 16.0501%
(Note that these probabilities assume individual selections to be independent; raw data for Game RNG taken from here)

Strategy

The line clears are made from the 3rd to 6th row, which are the topmost rows that can actually be cleared. Before clearing lines, as many tetriminos as possible are placed in the topmost rows (ideally so that all but one column is entirely filled), both because they need less time to reach their destination that way and to exploit the line clear bug. The empty column can only be the 5th one, since it is the only one that can be reached when the board is filled. This leaves a 4-wide column at the left and a 5-wide column at the right to be filled. On the right side, it may happen that the required number of blocks is not divisible by 4, so it can't be filled perfectly by tetriminos. In this case the "I" tetrimino can be used vertically so that the topmost block is outside the board (it is the only tetrimino which allows that), effectively only placing 3 blocks on the board.
adelikat: Setting to delayed, pending a fix to BizHawk. Also claiming for judging while I'm at it.

adelikat: Replacing the movie file with the 1190 frame version that will sync in a post-bugfix version of BizHawk, setting the emulator version appropriately, and remove the delayed status.

adelikat: Accepting for publication as an improvement to the published movie. Due to viewer feedback, this movie, like its predecessor should be published to the Alternative tier
Guga: Processing...