From 0e1084373bd0efd5cb6484b607f08e23d5457852 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 30 Aug 2013 22:55:29 +0000 Subject: [PATCH] Simple hack that saves another 230 bytes. --- lib/examples/LoLShield_Tetris/LoLShield_Tetris.h | 6 +++++- lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/examples/LoLShield_Tetris/LoLShield_Tetris.h b/lib/examples/LoLShield_Tetris/LoLShield_Tetris.h index 71bde90..001052a 100644 --- a/lib/examples/LoLShield_Tetris/LoLShield_Tetris.h +++ b/lib/examples/LoLShield_Tetris/LoLShield_Tetris.h @@ -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; /** diff --git a/lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde b/lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde index b6d937d..cfd3a41 100644 --- a/lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde +++ b/lib/examples/LoLShield_Tetris/LoLShield_Tetris.pde @@ -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;