summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2017-12-02 18:07:04 +0300
committerOxore <oxore@protonmail.com>2017-12-02 18:07:04 +0300
commit4e09b4c2e92806dc3230e6b9f1c2a1ff023c6080 (patch)
treee943a47779d1836c52e8591a9ab347a38016c484 /src
parent0edc5e799a5485f405756695491f1a497c21243c (diff)
Rearrange includes; replace uint8_t by char
Diffstat (limited to 'src')
-rw-r--r--src/functions.c47
-rw-r--r--src/main.c12
-rw-r--r--src/shape_maps.c15
-rw-r--r--src/text.c9
4 files changed, 52 insertions, 31 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <SFML/System/Clock.h>
+#include <SFML/Graphics/RenderWindow.h>
+#include <SFML/Graphics/Text.h>
+#include <SFML/Graphics/RectangleShape.h>
+
#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <SFML/System/Clock.h>
+#include <SFML/Window/Keyboard.h>
+#include <SFML/Graphics/RenderWindow.h>
+#include <SFML/Graphics/Font.h>
+
#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 <yaml.h>
-#include <SFML/Graphics.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
+#include <SFML/Graphics/Font.h>
+#include <SFML/Graphics/Text.h>
+#include <SFML/Graphics.h>
+#include <yaml.h>
+#include "common.h"
#include "text.h"
extern sfFont *fontScore;