diff options
author | inmarket <andrewh@inmarket.com.au> | 2018-06-23 13:02:07 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2018-06-23 13:02:07 +1000 |
commit | 41271d632b74f5cf47c30d3b699eb6b2786f2136 (patch) | |
tree | 78bcb729c6d6177ca598f28908fefd186c50e9b6 /demos/games/tetris | |
parent | 3b97fb798e96514057bcf17263c1e5dbdcd7da26 (diff) | |
download | uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.tar.gz uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.tar.bz2 uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.zip |
Added new type definitions - moving towards V3.0
Diffstat (limited to 'demos/games/tetris')
9 files changed, 57 insertions, 57 deletions
diff --git a/demos/games/tetris/Example_Makefiles/stm32f4/board_SSD1289.h b/demos/games/tetris/Example_Makefiles/stm32f4/board_SSD1289.h index 833ebdb4..dc3580e6 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4/board_SSD1289.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4/board_SSD1289.h @@ -111,7 +111,7 @@ static GFXINLINE void post_init_board(GDisplay *g) { (void) g; } -static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { +static GFXINLINE void setpin_reset(GDisplay *g, gBool state) { (void) g; (void) state; } diff --git a/demos/games/tetris/Example_Makefiles/stm32f4/ginput_lld_mouse_board.h b/demos/games/tetris/Example_Makefiles/stm32f4/ginput_lld_mouse_board.h index 39538747..0568d4e5 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4/ginput_lld_mouse_board.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4/ginput_lld_mouse_board.h @@ -26,7 +26,7 @@ static GFXINLINE void init_board(void) spiStart(&SPID1, &spicfg); } -static GFXINLINE bool_t getpin_pressed(void) +static GFXINLINE gBool getpin_pressed(void) { return (!palReadPad(GPIOC, 4)); } diff --git a/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h b/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h index dc8e979e..1af92bb2 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h @@ -45,12 +45,12 @@ static const SPIConfig spicfg = { // How much extra data to allocate at the end of the GMouse structure for the board's use #define GMOUSE_ADS7843_BOARD_DATA_SIZE 0 -static bool_t init_board(GMouse* m, unsigned driverinstance) { +static gBool init_board(GMouse* m, unsigned driverinstance) { (void)m; // Only one touch interface on this board if (driverinstance) - return FALSE; + return gFalse; // Set the GPIO modes palSetPadMode(GPIOC, 6, PAL_MODE_OUTPUT_PUSHPULL); @@ -62,10 +62,10 @@ static bool_t init_board(GMouse* m, unsigned driverinstance) { // Start the SPI peripheral spiStart(&SPID1, &spicfg); - return TRUE; + return gTrue; } -static GFXINLINE bool_t getpin_pressed(GMouse* m) { +static GFXINLINE gBool getpin_pressed(GMouse* m) { (void) m; return (!palReadPad(GPIOC, 4)); diff --git a/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h.old b/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h.old index 77d82bf8..70a22ee3 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h.old +++ b/demos/games/tetris/Example_Makefiles/stm32f4/gmouse_lld_ADS7843_board.h.old @@ -22,13 +22,13 @@ static const SPIConfig spicfg = { /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, }; -static bool_t init_board(GMouse* m, unsigned driverinstance) +static gBool init_board(GMouse* m, unsigned driverinstance) { (void)m; // Only one touch interface on this board if (driverinstance) - return FALSE; + return gFalse; // Set the GPIO modes palSetPadMode(GPIOC, 6, PAL_MODE_OUTPUT_PUSHPULL); @@ -40,10 +40,10 @@ static bool_t init_board(GMouse* m, unsigned driverinstance) // Start the SPI peripheral spiStart(&SPID1, &spicfg); - return TRUE; + return gTrue; } -GFXINLINE bool_t getpin_pressed(void) { +GFXINLINE gBool getpin_pressed(void) { return (!palReadPad(GPIOC, 4)); } diff --git a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/board_SSD1289.h b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/board_SSD1289.h index a74507e5..7e2bb05d 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/board_SSD1289.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/board_SSD1289.h @@ -109,7 +109,7 @@ static GFXINLINE void post_init_board(GDisplay *g) { (void) g; } -static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { +static GFXINLINE void setpin_reset(GDisplay *g, gBool state) { (void) g; (void) state; } diff --git a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/ginput_lld_mouse_board.h b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/ginput_lld_mouse_board.h index 39538747..0568d4e5 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/ginput_lld_mouse_board.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/ginput_lld_mouse_board.h @@ -26,7 +26,7 @@ static GFXINLINE void init_board(void) spiStart(&SPID1, &spicfg); } -static GFXINLINE bool_t getpin_pressed(void) +static GFXINLINE gBool getpin_pressed(void) { return (!palReadPad(GPIOC, 4)); } diff --git a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/gmouse_lld_ADS7843_board.h b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/gmouse_lld_ADS7843_board.h index 77d82bf8..70a22ee3 100644 --- a/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/gmouse_lld_ADS7843_board.h +++ b/demos/games/tetris/Example_Makefiles/stm32f4_chibios_3.x/gmouse_lld_ADS7843_board.h @@ -22,13 +22,13 @@ static const SPIConfig spicfg = { /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, }; -static bool_t init_board(GMouse* m, unsigned driverinstance) +static gBool init_board(GMouse* m, unsigned driverinstance) { (void)m; // Only one touch interface on this board if (driverinstance) - return FALSE; + return gFalse; // Set the GPIO modes palSetPadMode(GPIOC, 6, PAL_MODE_OUTPUT_PUSHPULL); @@ -40,10 +40,10 @@ static bool_t init_board(GMouse* m, unsigned driverinstance) // Start the SPI peripheral spiStart(&SPID1, &spicfg); - return TRUE; + return gTrue; } -GFXINLINE bool_t getpin_pressed(void) { +GFXINLINE gBool getpin_pressed(void) { return (!palReadPad(GPIOC, 4)); } diff --git a/demos/games/tetris/main.c b/demos/games/tetris/main.c index ffbccf6c..705813ab 100644 --- a/demos/games/tetris/main.c +++ b/demos/games/tetris/main.c @@ -43,7 +43,7 @@ int main(void) tetrisInit(); - while (TRUE) { + while (1) { // Start a new game // Will return when game is over tetrisStart(); diff --git a/demos/games/tetris/tetris.c b/demos/games/tetris/tetris.c index ed924781..cf73c978 100644 --- a/demos/games/tetris/tetris.c +++ b/demos/games/tetris/tetris.c @@ -86,9 +86,9 @@ int tetrisOldShape[4][2]; int tetrisNextShapeNum, tetrisOldShapeNum; unsigned long tetrisLines = 0; unsigned long tetrisScore = 0; -bool_t tetrisKeysPressed[5] = {FALSE, FALSE, FALSE, FALSE, FALSE}; // left/down/right/up/pause -bool_t tetrisPaused = FALSE; -bool_t tetrisGameOver = FALSE; +gBool tetrisKeysPressed[5] = {gFalse, gFalse, gFalse, gFalse, gFalse}; // left/down/right/up/pause +gBool tetrisPaused = gFalse; +gBool tetrisGameOver = gFalse; font_t font16; font_t font12; @@ -274,34 +274,34 @@ static void printTouchAreas(void) { gdispDrawLine(gdispGetWidth()-(gdispGetWidth()/4), gdispGetHeight()-gdispGetHeight()/4, gdispGetWidth()-(gdispGetWidth()/4), gdispGetHeight()-1, GFX_GRAY); } -static bool_t stay(bool_t down) { +static gBool stay(gBool down) { int sk, k; - bool_t stay; - if (down == TRUE) sk = 1; else sk = 0; - stay = FALSE; + gBool stay; + if (down) sk = 1; else sk = 0; + stay = gFalse; for (k = 0; k <= 3; k++) { if (tetrisCurrentShape[k][1] == 0) { - return TRUE; + return gTrue; } } for (k = 0; k <= 3; k++) { - if ((tetrisCurrentShape[k][0] < 0) || (tetrisCurrentShape[k][0] > 9)) return TRUE; + if ((tetrisCurrentShape[k][0] < 0) || (tetrisCurrentShape[k][0] > 9)) return gTrue; if (tetrisCurrentShape[k][1] <= 16) - if (tetrisField[tetrisCurrentShape[k][1]-sk][tetrisCurrentShape[k][0]] != 0) return TRUE; + if (tetrisField[tetrisCurrentShape[k][1]-sk][tetrisCurrentShape[k][0]] != 0) return gTrue; } return stay; } static void clearCompleteLines(void) { - bool_t t; + gBool t; uint8_t reiz = 0; int l,k,j; l = 0; while (l <= 16) { - t = TRUE; + t = gTrue; for (j = 0; j <= 9; j++) - if (tetrisField[l][j] == 0) t = FALSE; - if (t == TRUE) { + if (tetrisField[l][j] == 0) t = gFalse; + if (t) { for (j = 4; j >= 0; j--) { // cheap & dirty line removal animation :D drawCell(j,l, 0); drawCell(9-j,l, 0); @@ -331,7 +331,7 @@ static void clearCompleteLines(void) { static void goDown(void) { int i; - if (stay(TRUE) == FALSE) { + if (!stay(gTrue)) { drawShape(0); for (i = 0; i <= 3; i++) { tetrisCurrentShape[i][1]--; @@ -340,7 +340,7 @@ static void goDown(void) { } else { for (i = 0; i <= 3; i++) { if (tetrisCurrentShape[i][1] >=17) { - tetrisGameOver = TRUE; + tetrisGameOver = gTrue; return; } else { tetrisField[tetrisCurrentShape[i][1]][tetrisCurrentShape[i][0]] = tetrisOldShapeNum+1; @@ -348,8 +348,8 @@ static void goDown(void) { } clearCompleteLines(); createShape(); - if (stay(FALSE) == TRUE) { - tetrisGameOver = TRUE; + if (stay(gFalse)) { + tetrisGameOver = gTrue; return; } drawShape(tetrisOldShapeNum+1); @@ -383,7 +383,7 @@ static void rotateShape(void) { tetrisCurrentShape[i][0] = ox+(round((tx-ox)*cos(90*(3.14/180))-(ty-oy)*sin(90*(3.14/180)))); tetrisCurrentShape[i][1] = oy+(round((tx-ox)*sin(90*(3.14/180))+(ty-oy)*cos(90*(3.14/180)))); } - if (stay(FALSE) == FALSE) { + if (!stay(gFalse)) { memcpy(tetrisNextShape, tetrisCurrentShape, sizeof(tetrisNextShape)); // tetrisNextShape = tetrisCurrentShape; memcpy(tetrisCurrentShape, tetrisOldShape, sizeof(tetrisCurrentShape)); // tetrisCurrentShape = tetrisOldShape; drawShape(0); @@ -394,20 +394,20 @@ static void rotateShape(void) { } } -static bool_t checkSides(bool_t left) { +static gBool checkSides(gBool left) { int sk,k; - if (left == TRUE) sk = 1; else sk = -1; + if (left) sk = 1; else sk = -1; for (k = 0; k <= 3; k++) { - if ((tetrisCurrentShape[k][0]+sk < 0) || (tetrisCurrentShape[k][0]+sk > 9)) return TRUE; + if ((tetrisCurrentShape[k][0]+sk < 0) || (tetrisCurrentShape[k][0]+sk > 9)) return gTrue; if (tetrisCurrentShape[k][1] <= 16) - if (tetrisField[tetrisCurrentShape[k][1]][tetrisCurrentShape[k][0]+sk] != 0) return TRUE; + if (tetrisField[tetrisCurrentShape[k][1]][tetrisCurrentShape[k][0]+sk] != 0) return gTrue; } - return FALSE; + return gFalse; } static void goRight(void) { int i; - if (checkSides(TRUE) == FALSE) { + if (!checkSides(gTrue)) { drawShape(0); for (i = 0; i <= 3; i++) { tetrisCurrentShape[i][0]++; @@ -418,7 +418,7 @@ static void goRight(void) { static void goLeft(void) { int i; - if (checkSides(FALSE) == FALSE) { + if (!checkSides(gFalse)) { drawShape(0); for (i = 0; i <= 3; i++) { tetrisCurrentShape[i][0]--; @@ -434,8 +434,8 @@ static DECLARE_THREAD_FUNCTION(thdTetris, arg) { // key handling if (gfxSystemTicks() - tetrisPreviousKeyTime >= gfxMillisecondsToTicks(tetrisKeySpeed) || gfxSystemTicks() <= gfxMillisecondsToTicks(tetrisKeySpeed)) { for (i = 0; i < sizeof(tetrisKeysPressed); i++) { - if (tetrisKeysPressed[i] == TRUE) { - tetrisKeysPressed[i] = FALSE; + if (tetrisKeysPressed[i]) { + tetrisKeysPressed[i] = gFalse; } } tetrisPreviousKeyTime = gfxSystemTicks(); @@ -447,28 +447,28 @@ static DECLARE_THREAD_FUNCTION(thdTetris, arg) { tetrisPreviousGameTime = gfxSystemTicks(); } if (!(ev.buttons & GINPUT_MOUSE_BTN_LEFT)) continue; - if (ev.x <= gdispGetWidth()/4 && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && tetrisKeysPressed[0] == FALSE && !tetrisPaused) { + if (ev.x <= gdispGetWidth()/4 && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && !tetrisKeysPressed[0] && !tetrisPaused) { goLeft(); - tetrisKeysPressed[0] = TRUE; + tetrisKeysPressed[0] = gTrue; tetrisPreviousKeyTime = gfxSystemTicks(); } - if (ev.x > gdispGetWidth()-(gdispGetWidth()/4) && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && tetrisKeysPressed[2] == FALSE && !tetrisPaused) { + if (ev.x > gdispGetWidth()-(gdispGetWidth()/4) && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && !tetrisKeysPressed[2] && !tetrisPaused) { goRight(); - tetrisKeysPressed[2] = TRUE; + tetrisKeysPressed[2] = gTrue; tetrisPreviousKeyTime = gfxSystemTicks(); } - if (ev.y > gdispGetHeight()/4 && ev.y < gdispGetHeight()-(gdispGetHeight()/4) && tetrisKeysPressed[3] == FALSE && !tetrisPaused) { + if (ev.y > gdispGetHeight()/4 && ev.y < gdispGetHeight()-(gdispGetHeight()/4) && !tetrisKeysPressed[3] && !tetrisPaused) { rotateShape(); - tetrisKeysPressed[3] = TRUE; + tetrisKeysPressed[3] = gTrue; tetrisPreviousKeyTime = gfxSystemTicks(); } - if (ev.x > gdispGetWidth()/4 && ev.x <= gdispGetWidth()-(gdispGetWidth()/4) && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && tetrisKeysPressed[1] == FALSE && !tetrisPaused) { + if (ev.x > gdispGetWidth()/4 && ev.x <= gdispGetWidth()-(gdispGetWidth()/4) && ev.y >= gdispGetHeight()-(gdispGetHeight()/4) && !tetrisKeysPressed[1] && !tetrisPaused) { goDown(); - tetrisKeysPressed[1] = TRUE; + tetrisKeysPressed[1] = gTrue; tetrisPreviousKeyTime = gfxSystemTicks(); } - if (ev.y <= gdispGetHeight()/4 && tetrisKeysPressed[4] == FALSE) { - tetrisKeysPressed[4] = TRUE; + if (ev.y <= gdispGetHeight()/4 && !tetrisKeysPressed[4]) { + tetrisKeysPressed[4] = gTrue; tetrisPaused = !tetrisPaused; printPaused(); tetrisPreviousKeyTime = gfxSystemTicks(); @@ -495,8 +495,8 @@ void tetrisStart(void) { // Away we go initField(); - tetrisGameOver = FALSE; - printGameOver(); // removes "Game Over!" if tetrisGameOver == FALSE + tetrisGameOver = gFalse; + printGameOver(); // removes "Game Over!" if tetrisGameOver == gFalse tetrisPreviousGameTime = gfxSystemTicks(); gfxThreadCreate(0, 1024, NORMAL_PRIORITY, thdTetris, 0); while (!tetrisGameOver) { |