generic tetromino game

Replay format

A replay file starts the same as a configuration file, listing options used for the replay. Note that not all options are included in the replay, for instance, music and input options aren't included. After the options, there's a single blank line, followed by a series of decimal ASCII numbers, each separated by one space. The numbers respectively represent the starting level, the seed, the starting frame (affects line clear delays), and miscellaneous data for the RNG algorithm. If the seed was set on the level select screen, an asterisk (*) immediately follows the seed number (this is necessary since whether or not the seed was pre-set affects piece generation). After these numbers, there's a newline, followed by the replay data.

Replay data is encoded as a series of bytes describing the inputs that should be interpreted. Each byte is as follows (right-most bit is least significant):

PSAB UDRL
|||| ||||
|||| |||left
|||| ||right
|||| |down
|||| up
|||flip ccw
||flip cw
|start
repeat

The least significant 7 bits are self explanatory: if they are set the button is held down, otherwise the button is released. Note that a side effect of this is that it's impossible to have a replay that taps faster than 30Hz. If you really want to tap faster than 30Hz, use pause buffering and/or simultaneously press left and right.

The most significant bit is the repeat bit. If this bit is set, then the next byte is read and interpreted as an unsigned integer. The rest of the inputs are then repeated for that number + 3 frames. So, for instance:

10000001 00000100

This will hold "left" for 7 frames, since the second byte is the number 4, and 4+3=7. The rationale for this decision is that you're not saving any bytes by using the repeat bit to repeat any less than three times, so we can allow three extra frames of delay by having 3 be the starting point.