minor acceleration of the predictNextRow function

This commit is contained in:
Christian Kroll 2010-12-15 21:51:59 +00:00
parent 8e2261eddd
commit b16b908003
1 changed files with 10 additions and 12 deletions

View File

@ -465,22 +465,20 @@ uint16_t* tetris_bucket_predictBottomRow(tetris_bucket_iterator_t *pIt,
pIt->nCurrentRow = pBucket->nHeight - 1;
pIt->nRowBuffer = 0;
// determine sane start and stop values for the piece's row indices
pIt->nPieceHighestRow = nRow;
pIt->nPieceLowestRow = ((pIt->nPieceHighestRow + 3) < pBucket->nHeight) ?
(pIt->nPieceHighestRow + 3) : pBucket->nHeight - 1;
// prepare piece bitmap for faster detection of complete lines
pIt->nPieceMap = tetris_piece_getBitmap(pPiece);
if ((nRow + 3) >= pBucket->nHeight)
{
pIt->nPieceMap <<= (nRow + 4 - pBucket->nHeight) * 4;
}
// determine sane start and stop values for the piece's row indices
pIt->nPieceHighestRow = nRow + tetris_piece_getTopRow(pIt->nPieceMap);
int8_t nBottomOffset = tetris_piece_getBottomOffset(pIt->nPieceMap);
pIt->nPieceLowestRow = (nRow + nBottomOffset) < pBucket->nHeight ?
nRow + nBottomOffset : pBucket->nHeight - 1;
// accelerate detection of full rows
pIt->nPieceMap <<= (nRow + 3 - pIt->nPieceLowestRow) * 4;
pIt->nShift = nColumn - 12;
// don't return any trailing rows which are empty, so we look for a stop row
pIt->nStopRow = pBucket->nFirstTaintedRow < nRow ?
pBucket->nFirstTaintedRow : nRow;
pIt->nStopRow = pBucket->nFirstTaintedRow < pIt->nPieceHighestRow ?
pBucket->nFirstTaintedRow : pIt->nPieceHighestRow;
pIt->nStopRow = pIt->nStopRow < 0 ? 0 : pIt->nStopRow;
return tetris_bucket_predictNextRow(pIt);