Simple hack that saves another 230 bytes.

This commit is contained in:
root
2013-08-30 22:55:29 +00:00
parent 2688dd8738
commit 0e1084373b
2 changed files with 8 additions and 4 deletions
@@ -31,11 +31,15 @@ typedef struct coord {
int8_t y;
} coord_t;
typedef struct coordPacked {
unsigned x:2, y:2;
} coordPacked_t;
/**
* One piece view. Each Tetris piece may have one to four views.
*/
typedef struct pieceView {
coord_t elements[4];
coordPacked_t elements[4];
} pieceView_t;
/**
@@ -122,7 +122,7 @@ pos_t position;
*/
void switchPiece(const piece_t* piece, const pos_t& position, uint8_t c=1) {
for(uint8_t i=0;i<4;i++) {
coord_t element = piece->views[position.view].elements[i];
coordPacked_t element = piece->views[position.view].elements[i];
uint8_t eltXPos = element.x+position.coord.x;
uint8_t eltYPos = element.y+position.coord.y;
LedSign::Set(13-eltYPos, eltXPos, c);
@@ -180,7 +180,7 @@ void startGame() {
*/
boolean checkPieceMove(const piece_t* piece, const pos_t& position) {
for (uint8_t i=0; i<4; i++) {
coord_t element = piece->views[position.view].elements[i];
coordPacked_t element = piece->views[position.view].elements[i];
int8_t eltXPos = element.x+position.coord.x;
int8_t eltYPos = element.y+position.coord.y;
// Check x boundaries.
@@ -278,7 +278,7 @@ void timerPieceDown(uint32_t& count) {
} else {
// Drop the piece on the grid.
for (uint8_t i=0; i<4; i++) {
coord_t element = currentPiece->views[position.view].elements[i];
coordPacked_t element = currentPiece->views[position.view].elements[i];
uint8_t eltXPos = element.x+position.coord.x;
uint8_t eltYPos = element.y+position.coord.y;
playGrid[eltYPos][eltXPos] = true;