From 4e09b4c2e92806dc3230e6b9f1c2a1ff023c6080 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sat, 2 Dec 2017 18:07:04 +0300 Subject: Rearrange includes; replace uint8_t by char --- include/common.h | 23 ++++++----------------- include/functions.h | 6 ------ include/text.h | 3 --- src/functions.c | 47 ++++++++++++++++++++++++++++------------------- src/main.c | 12 +++++++++++- src/shape_maps.c | 15 +++++++-------- src/text.c | 9 ++++++--- 7 files changed, 58 insertions(+), 57 deletions(-) diff --git a/include/common.h b/include/common.h index 136edaa..4452bf0 100644 --- a/include/common.h +++ b/include/common.h @@ -1,19 +1,10 @@ -#ifndef TCOMMON_H -#define TCOMMON_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tet_conf.h" +/* + * Types + * + * */ typedef struct Cell { - uint8_t a; // active/empty state of cell + char a; // active/empty state of cell sfColor fColor; // fill color } Cell; @@ -34,7 +25,7 @@ typedef struct Shape { int y; // y coord of shape's bottom int t; // shape type sfColor fColor; // shape color - uint8_t c[4][4]; // array of logic shape cells + char c[4][4]; // array of logic shape cells sfRectangleShape *p[4][4]; // array of physical shape cells sfVector2f cSize; // shape rectangles size variable x/y } Shape; @@ -87,5 +78,3 @@ typedef struct Text { char *text; void *sfText; } Text; - -#endif diff --git a/include/functions.h b/include/functions.h index 8658aa5..73979e5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1,7 +1,3 @@ -#ifndef TFUNCTIONS_H -#define TFUNCTIONS_H - -/* Prototypes of functions*/ void tKeyCtrl(); void initFld(); void tTick(); @@ -26,5 +22,3 @@ void genNextShape(); void copyShape(Shape *localSh); void drawNextShape(); void freeFld(); - -#endif diff --git a/include/text.h b/include/text.h index 7948c51..1171a51 100644 --- a/include/text.h +++ b/include/text.h @@ -1,6 +1,3 @@ -#include -#include "common.h" - FILE *openFile(char *filename); void checkArgs(int argc, char **argv); KeyMap *KeyMap_getLast(KeyMap **keyMap); diff --git a/src/functions.c b/src/functions.c index 7637289..a573266 100644 --- a/src/functions.c +++ b/src/functions.c @@ -1,4 +1,13 @@ +#include +#include +#include +#include +#include +#include +#include + #include "common.h" +#include "tet_conf.h" #include "functions.h" /* Externs from main.c */ @@ -8,7 +17,7 @@ extern Field fld; extern sfFont *fontScore; -extern uint8_t arrKeys; // Arrow keys states byte container +extern char arrKeys; // Arrow keys states byte container /* arrKeys = ...n|7|6|5|4|3|2|1|0| (just a bit of so called "bit fucking") * 0 - Right arrow pushed and held * 1 - Down arrow pushed and held @@ -28,13 +37,13 @@ extern sfClock *repKeyLeft; // Clock for repeat latency when Left arrow long pus extern sfClock *repKeyRight; // Clock for repeat latency when Left arrow long push /* Shapes maps */ -extern uint8_t arrShapeL[4][4]; -extern uint8_t arrShapeRL[4][4]; -extern uint8_t arrShapeZ[4][4]; -extern uint8_t arrShapeS[4][4]; -extern uint8_t arrShapeB[4][4]; -extern uint8_t arrShapeI[4][4]; -extern uint8_t arrShapeT[4][4]; +extern char arrShapeL[4][4]; +extern char arrShapeRL[4][4]; +extern char arrShapeZ[4][4]; +extern char arrShapeS[4][4]; +extern char arrShapeB[4][4]; +extern char arrShapeI[4][4]; +extern char arrShapeT[4][4]; /* Field init routine */ @@ -209,8 +218,8 @@ void tTick() */ void rotateLeft() { - uint8_t arr[4][4]; - memcpy(&arr[0][0], &active.c[0][0], sizeof(uint8_t)*4*4); + char arr[4][4]; + memcpy(&arr[0][0], &active.c[0][0], sizeof(char)*4*4); if (active.t == 5) return; if (active.t == 6) { @@ -231,8 +240,8 @@ void rotateLeft() */ void rotateRight() { - uint8_t arr[4][4]; - memcpy(&arr[0][0], &active.c[0][0], sizeof(uint8_t)*4*4); + char arr[4][4]; + memcpy(&arr[0][0], &active.c[0][0], sizeof(char)*4*4); if (active.t == 5) return; if (active.t == 6) { @@ -553,31 +562,31 @@ void copyShape(Shape *localSh) { switch (localSh->t) { // Copy cell active/inactive state case 1 : - memcpy(&localSh->c[0][0], &arrShapeL[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeL[0][0], sizeof(char)*4*4); localSh->fColor = tOrange; break; case 2 : - memcpy(&localSh->c[0][0], &arrShapeRL[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeRL[0][0], sizeof(char)*4*4); localSh->fColor = tBlue; break; case 3 : - memcpy(&localSh->c[0][0], &arrShapeZ[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeZ[0][0], sizeof(char)*4*4); localSh->fColor = tRed; break; case 4 : - memcpy(&localSh->c[0][0], &arrShapeS[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeS[0][0], sizeof(char)*4*4); localSh->fColor = tGreen; break; case 5 : - memcpy(&localSh->c[0][0], &arrShapeB[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeB[0][0], sizeof(char)*4*4); localSh->fColor = tYellow; break; case 6 : - memcpy(&localSh->c[0][0], &arrShapeI[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeI[0][0], sizeof(char)*4*4); localSh->fColor = tCyan; break; case 7 : - memcpy(&localSh->c[0][0], &arrShapeT[0][0], sizeof(uint8_t)*4*4); + memcpy(&localSh->c[0][0], &arrShapeT[0][0], sizeof(char)*4*4); localSh->fColor = tMagneta; break; } diff --git a/src/main.c b/src/main.c index c429ca9..0677e11 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,16 @@ +#include +#include +#include +#include +#include +#include +#include +#include + #include "common.h" #include "functions.h" #include "text.h" +#include "tet_conf.h" /* --- Variables --- */ Window w = {.mode = {450, 520, 32}}; @@ -10,7 +20,7 @@ sfFont *fontScore; Shape active, next; Field fld; -uint8_t arrKeys = 0b00000000; // Arrow keys states byte container +char arrKeys = 0b00000000; // Arrow keys states byte container /* --- Variables End --- */ sfClock *gameTick; diff --git a/src/shape_maps.c b/src/shape_maps.c index 9de04d2..50061e3 100644 --- a/src/shape_maps.c +++ b/src/shape_maps.c @@ -1,4 +1,3 @@ -#include "common.h" /* * Shapes maps * @@ -13,7 +12,7 @@ * .... .##. #... .#.. * .... .... .... .... */ -uint8_t arrShapeL[4][4] = { +char arrShapeL[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, @@ -27,7 +26,7 @@ uint8_t arrShapeL[4][4] = { * .... .... .... .... */ -uint8_t arrShapeRL[4][4] = { +char arrShapeRL[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, @@ -40,7 +39,7 @@ uint8_t arrShapeRL[4][4] = { * .... .#.. .##. #... * .... .... .... .... */ -uint8_t arrShapeZ[4][4] = { +char arrShapeZ[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 1, 1, 0}, @@ -53,7 +52,7 @@ uint8_t arrShapeZ[4][4] = { * .... ..#. ##.. .#.. * .... .... .... .... */ -uint8_t arrShapeS[4][4] = { +char arrShapeS[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 0, 0}, @@ -67,7 +66,7 @@ uint8_t arrShapeS[4][4] = { * .... .... .... .... * .... .... .... .... */ -uint8_t arrShapeB[4][4] = { +char arrShapeB[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 1, 1, 0}, @@ -81,7 +80,7 @@ uint8_t arrShapeB[4][4] = { * .#.. .... .#.. .... * .#.. .... .#.. .... */ -uint8_t arrShapeI[4][4] = { +char arrShapeI[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, @@ -95,7 +94,7 @@ uint8_t arrShapeI[4][4] = { * .... .#.. .#.. .#.. * .... .... .... .... */ -uint8_t arrShapeT[4][4] = { +char arrShapeT[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, diff --git a/src/text.c b/src/text.c index 8932496..20b9797 100644 --- a/src/text.c +++ b/src/text.c @@ -1,9 +1,12 @@ -#include -#include +#include #include #include -#include +#include +#include +#include +#include +#include "common.h" #include "text.h" extern sfFont *fontScore; -- cgit v1.2.3