Dr. Mario

Dr. Mario is a non-tetromino puzzle game franchise developed by Nintendo and released on its systems.

The bottle is 8 blocks wide by 11 to 16 blocks high (depending on version) and starts out partially full of "viruses", or fixed blocks of the color red, yellow, or blue.

Pieces in Dr. Mario are vitamin pills with two halves (making them dominoes), with each half colored red, yellow, or blue. The player can move or rotate them as they fall into the bottom. Once a pill locks, if four or more blocks of a color are aligned horizontally or vertically, they are removed, and the pill segments above them (but not viruses) fall in a cascade. In 2-player, cascades cause garbage pill segments to drop into the opponent's playfield. Anything that falls falls slowly, at a rate of 4 rows per second, due to the design of the playfield refresh logic. Modern versions allow players to speed up the fall rate of these cascades in single-player, but not in multiplayer, where the time lost waiting for garbage segments to fall is often more damaging than the segments themselves.

Players who like Dr. Mario may also like Columns, Klax, and Puyo Pop. The game Tetris 2 can be thought of as Dr. Mario with tetrominoes.

Rotation system
Ordinarily, the pills rotate within a 2x2 box whose bottom left corner is always filled. Clockwise rotation looks like this:

Wall kicks on Dr. Mario (NES), WarioWare Inc.: Mega Microgame$ (GBA), and Dr. Mario & Puzzle League (GBA) are as follows:

Horizontal to vertical:

Vertical to horizontal:

Tetris & Dr. Mario has some additional wall kicks from horizontal to vertical:

NES Version
A sequence of length 128 is generated before a game starts, with each element of the sequence an integer uniformly distributed in range [0,8], with the integer being used to select from all nine possible color pairs for a capsule. The 128-long sequence loops, so once the 129th capsule is generated, it's the same as the first, and 130th the same as the second, and so on.

NES Version
For virus levels 20 and up, use virus level 19's maximum row value.

The algorithm described here takes as inputs the current bottle virus contents, selected virus level, and the number of remaining viruses to generate. It's called repeatedly until the remaining viruses to generate returned is zero:
 * 1) Generate a random number in range [1,16].
 * 2) If the random number in step 1 is greater than the maximum allowed row (seed the "Virus Level"/"Maximum Row" table above), go back to step 1.
 * 3) Generate a random number in range [1,8] and use for the candidate virus X coordinate, with 1 on the left and 8 on the right.
 * 4) Use the number generated in step 1 as the candidate virus Y coordinate, with 1 on the bottom and 16 the top.
 * 5) Using the number of remaining viruses as the numerator, take the remainder of division by 4.
 * 6) Using the remainder calculated in step 5, with 0 = Yellow, 1 = Red, and 2 = Blue, if the remainder was 3, do the following, else use the integer to select the currently selected virus color as specified earlier this sentence:
 * 7) Randomly generate an integer in range [0,15].
 * 8) Select from the "PRNG Output" table above the virus color matching the integer generated in step 6.1.
 * 9) Do repeatedly the following while the current candidate virus position is filled:
 * 10) Increment the candidate virus X position.
 * 11) If the candidate virus X position is now 9:
 * 12) Set the candidate virus X position to 1 and increment the candidate virus Y position
 * 13) If the candidate virus Y position is now 17:
 * 14) Return the number of remaining viruses to generate.
 * 15) Check in all four cardinal directions 2 cells away from the candidate virus position the virus contents of the bottle.
 * 16) If all three colors are present in the four checked cells, go back to step 7.1 (don't do step 7).
 * 17) If the four checked cells in step 8 lacks the currently selected virus color, go to step 13.
 * 18) If the currently selected virus type is yellow, change the currently selected virus color to blue; if the currently selected virus type is red, change the currently selected virus color to yellow; if the currently selected virus color is blue, change the currently selected virus color to red.
 * 19) Go to step 8.
 * 20) Set the candidate virus position in the bottle to the currently selected virus color.
 * 21) Return the number of remaining viruses less one.

Gravity
There is a "speed counter" that increments every 10 capsules; there is a subtle sound effect that plays when it increments. The speed counter's maximum value is 49. There is also a speed base value table, indexed by the currently selected speed: The current speed counter is added to the speed base value and that is used to index the gravity table. The gravity table is as follows:

Indexes 0-25: (35 - index) * 2 - 1

Indexes 26-34: 44 - index

Indexes 35 and up to 79 use the following table, with values in the right column being in frames per row: