Skip to content

Commit

Permalink
Simple hack that saves another 230 bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 30, 2013
1 parent 2688dd8 commit 0e10843
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/examples/LoLShield_Tetris/LoLShield_Tetris.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0e10843

Please sign in to comment.