|
@ -107,8 +107,8 @@ static void tetris_bucket_hoverStatus(tetris_bucket_t *pBucket) |
|
|
tetris_bucket_t *tetris_bucket_construct(int8_t nWidth, |
|
|
tetris_bucket_t *tetris_bucket_construct(int8_t nWidth, |
|
|
int8_t nHeight) |
|
|
int8_t nHeight) |
|
|
{ |
|
|
{ |
|
|
assert((nWidth >= 4) && (nWidth <= 16)); |
|
|
assert((nWidth >= 4) && (nWidth <= TETRIS_BUCKET_MAX_COLUMNS)); |
|
|
assert((nHeight >= 4) && (nHeight <= 124)); |
|
|
assert((nHeight >= 4) && (nHeight <= TETRIS_BUCKET_MAX_ROWS)); |
|
|
|
|
|
|
|
|
// allocating memory
|
|
|
// allocating memory
|
|
|
tetris_bucket_t *pBucket = |
|
|
tetris_bucket_t *pBucket = |
|
@ -355,8 +355,8 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket, |
|
|
{ |
|
|
{ |
|
|
assert(pBucket != NULL); |
|
|
assert(pBucket != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(nStartRow >= -1 && nStartRow < pBucket->nHeight); |
|
|
assert(nStartRow > TETRIS_BUCKET_INVALID && nStartRow < pBucket->nHeight); |
|
|
assert(nColumn >= -3 && nColumn < pBucket->nWidth); |
|
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); |
|
|
|
|
|
|
|
|
// exchange current piece of the bucket (to use its collision detection)
|
|
|
// exchange current piece of the bucket (to use its collision detection)
|
|
|
tetris_piece_t *pActualPiece = pBucket->pPiece; |
|
|
tetris_piece_t *pActualPiece = pBucket->pPiece; |
|
@ -376,7 +376,7 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket, |
|
|
// bucket overflow?
|
|
|
// bucket overflow?
|
|
|
if (nStartRow < 0 && ((0xFFFF >> (((4 + nStartRow) * 4))) & nMap)) |
|
|
if (nStartRow < 0 && ((0xFFFF >> (((4 + nStartRow) * 4))) & nMap)) |
|
|
{ |
|
|
{ |
|
|
nStartRow = TETRIS_BUCKET_INVALIDROW; |
|
|
nStartRow = TETRIS_BUCKET_INVALID; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -394,8 +394,8 @@ int8_t tetris_bucket_predictCompleteLines(tetris_bucket_t *pBucket, |
|
|
{ |
|
|
{ |
|
|
assert(pBucket != NULL); |
|
|
assert(pBucket != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(nRow > -4 && nRow < pBucket->nHeight); |
|
|
assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight); |
|
|
assert(nColumn > -4 && nColumn < pBucket->nWidth); |
|
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); |
|
|
|
|
|
|
|
|
// initialization
|
|
|
// initialization
|
|
|
int8_t nCompleteRows = 0; |
|
|
int8_t nCompleteRows = 0; |
|
@ -433,8 +433,8 @@ uint16_t* tetris_bucket_predictBottomRow(tetris_bucket_iterator_t *pIt, |
|
|
assert(pIt != NULL); |
|
|
assert(pIt != NULL); |
|
|
assert(pBucket != NULL); |
|
|
assert(pBucket != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(pPiece != NULL); |
|
|
assert(nRow > -4 && nRow < pBucket->nHeight); |
|
|
assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight); |
|
|
assert(nColumn > -4 && nColumn < pBucket->nWidth); |
|
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); |
|
|
|
|
|
|
|
|
pIt->pBucket = pBucket; |
|
|
pIt->pBucket = pBucket; |
|
|
pIt->nCurrentRow = pBucket->nHeight - 1; |
|
|
pIt->nCurrentRow = pBucket->nHeight - 1; |
|
|