diff --git a/src/tetris.c b/src/tetris.c index f6ab3ae..c842eb4 100644 --- a/src/tetris.c +++ b/src/tetris.c @@ -75,7 +75,7 @@ void tetris_place(u8 *restrict *restrict rows, u8 tetromino, uint x, uint y) { uint *end = pos + 8; tetris_get_blocks(tetromino, pos); tetromino &= 7; /* strip rotation data */ - tetromino |= 0x80; /* set an undefined bit, to signify there is data here. */ + tetromino |= TET_NON_EMPTY; for (; pos < end; pos += 2) rows[*(pos + 1)][*pos] = tetromino; } diff --git a/src/tetris.h b/src/tetris.h index cb299af..28c4ae4 100644 --- a/src/tetris.h +++ b/src/tetris.h @@ -6,9 +6,11 @@ #define TET_WIDTH 10 #define TET_HEIGHT 24 /* height may be 16—24 */ -/* Defines tetromino id. +/* Defines tetromino indices. * The `TET_R*` definitions specify various rotations. - * This is designed to be OR'd with the tetromino shape index. */ + * This is designed to be OR'd with the tetromino shape index. + * Shape index can be obtained via `val & 7`, and rotation index is + * obtained via `val >> 3`. */ enum tetromino { TET_I = 0x00, TET_O = 0x01, @@ -21,6 +23,11 @@ enum tetromino { TET_R90 = 0x08, TET_R180 = 0x10, TET_R270 = 0x18, + + /* Used when storing blocks to the board; + * allows to identify non-empty indices from empty ones. + * This value should not be used during general computation. */ + TET_NON_EMPTY = 0x80, }; /* Stores the co-ordinates of the four blocks in a 4x4 plane.