diff --git a/src/tetris.c b/src/tetris.c index c842eb4..aec03e4 100644 --- a/src/tetris.c +++ b/src/tetris.c @@ -63,8 +63,8 @@ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint uint *end = pos + 8; tetris_get_blocks(tetromino, pos); for (; pos < end; pos += 2) { - if (*(pos + 0) >= TET_WIDTH) break; - if (*(pos + 1) >= TET_HEIGHT) break; + if (*(pos + 0) >= TET_WIDTH) return 2; + if (*(pos + 1) >= TET_HEIGHT) return 2; if (rows[*(pos + 1)][*pos]) break; } return pos < end; diff --git a/src/tetris.h b/src/tetris.h index 28c4ae4..cfb137c 100644 --- a/src/tetris.h +++ b/src/tetris.h @@ -50,7 +50,8 @@ void tetris_init_rows(const u8 *restrict data, const u8 *restrict *restrict out) * Returns the amount of rows cleared. */ int tetris_clear_rows(u8 *restrict *restrict rows) NONNULL((1)); -/* Checks if `tetromino` intersects at (`x`, `y`) in `rows`, returns `1` if so, `0` if not. */ +/* Checks if `tetromino` intersects at (`x`, `y`) in the data within `rows` or is out-of-bounds, + * returns `1` if it overlaps within `rows`, `2` if it is out-of-bounds, `0` if no intersection is found. */ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint x, uint y) NONNULL((1)); /* Writes the blocks of `tetromino` to `rows` at position `x` and `y`. */