Browse Source

saved 44 bytes

feature/2015
Christian Kroll 14 years ago
parent
commit
ccc549db61
  1. 2
      games/tetris/input.c
  2. 16
      games/tetris/variant_bastet.c
  3. 4
      games/tetris/view.c

2
games/tetris/input.c

@ -200,7 +200,7 @@ static tetris_input_command_t tetris_input_queryJoystick(tetris_input_t *pIn)
} }
// decrement all ignore counters // decrement all ignore counters
for (int nIgnIndex = 0; nIgnIndex < TETRIS_INCMD_NONE; ++nIgnIndex) for (uint8_t nIgnIndex = 0; nIgnIndex < TETRIS_INCMD_NONE; ++nIgnIndex)
{ {
if (pIn->nIgnoreCmdCounter[nIgnIndex] != 0) if (pIn->nIgnoreCmdCounter[nIgnIndex] != 0)
{ {

16
games/tetris/variant_bastet.c

@ -39,7 +39,7 @@ static void tetris_bastet_doPreprocessing(tetris_bastet_variant_t *pBastet)
int8_t nStopRow = tetris_bucket_getFirstTaintedRow(pBastet->pBucket); int8_t nStopRow = tetris_bucket_getFirstTaintedRow(pBastet->pBucket);
// clear old precalculated scores // clear old precalculated scores
for (int i = 0; i < nWidth + 3; ++i) for (uint8_t i = 0; i < nWidth + 3; ++i)
{ {
pBastet->pColScore[i] = 0; pBastet->pColScore[i] = 0;
} }
@ -50,7 +50,7 @@ static void tetris_bastet_doPreprocessing(tetris_bastet_variant_t *pBastet)
{ {
uint16_t nDumpRow = tetris_bucket_getDumpRow(pBastet->pBucket, y); uint16_t nDumpRow = tetris_bucket_getDumpRow(pBastet->pBucket, y);
uint16_t nColMask = 0x0001; uint16_t nColMask = 0x0001;
for (int8_t x = 0; x < nWidth; ++x) for (uint8_t x = 0; x < nWidth; ++x)
{ {
if ((nDumpRow & nColMask) != 0) if ((nDumpRow & nColMask) != 0)
{ {
@ -68,7 +68,7 @@ static void tetris_bastet_doPreprocessing(tetris_bastet_variant_t *pBastet)
pBastet->pStartingRow[2] = pBastet->pStartingRow[1] > pBastet->pColScore[2]? pBastet->pStartingRow[2] = pBastet->pStartingRow[1] > pBastet->pColScore[2]?
pBastet->pStartingRow[1] : pBastet->pColScore[2]; pBastet->pStartingRow[1] : pBastet->pColScore[2];
// calculate the maxima of the 4-tuples from column 0 to width-1 // calculate the maxima of the 4-tuples from column 0 to width-1
for (int8_t i = 0; i < nWidth; ++i) for (uint8_t i = 0; i < nWidth; ++i)
{ {
int8_t t0 = pBastet->pColScore[i] > pBastet->pColScore[i + 1] ? int8_t t0 = pBastet->pColScore[i] > pBastet->pColScore[i + 1] ?
i : i + 1; i : i + 1;
@ -86,7 +86,7 @@ static void tetris_bastet_doPreprocessing(tetris_bastet_variant_t *pBastet)
} }
// calculate the score impact of every column // calculate the score impact of every column
for (int x = 0; x < nWidth; ++x) for (uint8_t x = 0; x < nWidth; ++x)
{ {
pBastet->pColScore[x] *= TETRIS_BASTET_HEIGHT_FACTOR; pBastet->pColScore[x] *= TETRIS_BASTET_HEIGHT_FACTOR;
} }
@ -116,7 +116,7 @@ static void tetris_bastet_predictColHeights(tetris_bastet_variant_t *pBastet,
while (pDump != NULL) while (pDump != NULL)
{ {
uint16_t nColMask = 0x0001 << nStartCol; uint16_t nColMask = 0x0001 << nStartCol;
for (int x = nStartCol; x <= nStopCol; ++x) for (uint8_t x = nStartCol; x <= nStopCol; ++x)
{ {
if ((*pDump & nColMask) != 0) if ((*pDump & nColMask) != 0)
{ {
@ -242,7 +242,7 @@ static int16_t tetris_bastet_evaluateMove(tetris_bastet_variant_t *pBastet,
nStartCol, nStopCol); nStartCol, nStopCol);
// modify score based on predicted column heights // modify score based on predicted column heights
for (int x = 0; x < nWidth; ++x) for (uint8_t x = 0; x < nWidth; ++x)
{ {
if ((x >= nStartCol) && (x <= nStopCol)) if ((x >= nStartCol) && (x <= nStopCol))
{ {
@ -269,12 +269,12 @@ static void tetris_bastet_evaluatePieces(tetris_bastet_variant_t *pBastet)
int8_t nWidth = tetris_bucket_getWidth(pBastet->pBucket); int8_t nWidth = tetris_bucket_getWidth(pBastet->pBucket);
tetris_piece_t *pPiece = tetris_piece_construct(TETRIS_PC_LINE, tetris_piece_t *pPiece = tetris_piece_construct(TETRIS_PC_LINE,
TETRIS_PC_ANGLE_0); TETRIS_PC_ANGLE_0);
for (int8_t nBlock = TETRIS_PC_LINE; nBlock <= TETRIS_PC_Z; ++nBlock) for (uint8_t nBlock = TETRIS_PC_LINE; nBlock <= TETRIS_PC_Z; ++nBlock)
{ {
int16_t nMaxScore = -32768; int16_t nMaxScore = -32768;
tetris_piece_setShape(pPiece, nBlock); tetris_piece_setShape(pPiece, nBlock);
int8_t nAngleCount = tetris_piece_getAngleCount(pPiece); int8_t nAngleCount = tetris_piece_getAngleCount(pPiece);
for (int8_t nAngle = TETRIS_PC_ANGLE_0; nAngle < nAngleCount; ++nAngle) for (uint8_t nAngle = TETRIS_PC_ANGLE_0; nAngle < nAngleCount; ++nAngle)
{ {
tetris_piece_setAngle(pPiece, nAngle); tetris_piece_setAngle(pPiece, nAngle);
for (int8_t nCol = -3; nCol < nWidth; ++nCol) for (int8_t nCol = -3; nCol < nWidth; ++nCol)

4
games/tetris/view.c

@ -250,7 +250,7 @@ static void tetris_view_drawDump(tetris_view_t *pV)
} }
uint16_t nElementMask = 0x0001; uint16_t nElementMask = 0x0001;
for (int8_t x = 0; x < TETRIS_VIEW_WIDTH_DUMP; ++x) for (uint8_t x = 0; x < TETRIS_VIEW_WIDTH_DUMP; ++x)
{ {
unsigned char nColor = (nRowMap & nElementMask) ? unsigned char nColor = (nRowMap & nElementMask) ?
tetris_view_getPieceColor(pV) : TETRIS_VIEW_COLORSPACE; tetris_view_getPieceColor(pV) : TETRIS_VIEW_COLORSPACE;
@ -516,7 +516,7 @@ static void tetris_view_drawLineCounter(tetris_view_t *pV)
int8_t nHundreds = (nLines / 100) % 10; int8_t nHundreds = (nLines / 100) % 10;
// draws the decimal places as 3x3 squares with 9 pixels // draws the decimal places as 3x3 squares with 9 pixels
for (int i = 0, x = 0, y = 0; i < 9; ++i) for (uint8_t i = 0, x = 0, y = 0; i < 9; ++i)
{ {
// pick drawing color for the ones // pick drawing color for the ones
uint8_t nOnesPen = nOnes > i ? uint8_t nOnesPen = nOnes > i ?

Loading…
Cancel
Save