From 52841e735953c642588a33830f0bb4245d08d28e Mon Sep 17 00:00:00 2001 From: Oxore Date: Tue, 20 Jun 2017 21:48:38 +0700 Subject: Refactoring 3 --- src/functions.c | 56 +++++++++++++--------------------------------------- src/include/common.h | 1 - src/shape_maps.c | 14 ++++++------- 3 files changed, 21 insertions(+), 50 deletions(-) diff --git a/src/functions.c b/src/functions.c index 68cb377..b4d08ea 100644 --- a/src/functions.c +++ b/src/functions.c @@ -37,40 +37,13 @@ extern int lvlLatency; extern int scoreCurrent; extern char *scoreDisp; /* Shapes maps */ -extern uint8_t arrShapeL_a1[4][4]; -extern uint8_t arrShapeL_a2[4][4]; -extern uint8_t arrShapeL_a3[4][4]; -extern uint8_t arrShapeL_a4[4][4]; - -extern uint8_t arrShapeRL_a1[4][4]; -extern uint8_t arrShapeRL_a2[4][4]; -extern uint8_t arrShapeRL_a3[4][4]; -extern uint8_t arrShapeRL_a4[4][4]; - -extern uint8_t arrShapeZ_a1[4][4]; -extern uint8_t arrShapeZ_a2[4][4]; -extern uint8_t arrShapeZ_a3[4][4]; -extern uint8_t arrShapeZ_a4[4][4]; - -extern uint8_t arrShapeS_a1[4][4]; -extern uint8_t arrShapeS_a2[4][4]; -extern uint8_t arrShapeS_a3[4][4]; -extern uint8_t arrShapeS_a4[4][4]; - -extern uint8_t arrShapeB_a1[4][4]; -extern uint8_t arrShapeB_a2[4][4]; -extern uint8_t arrShapeB_a3[4][4]; -extern uint8_t arrShapeB_a4[4][4]; - -extern uint8_t arrShapeI_a1[4][4]; -extern uint8_t arrShapeI_a2[4][4]; -extern uint8_t arrShapeI_a3[4][4]; -extern uint8_t arrShapeI_a4[4][4]; - -extern uint8_t arrShapeT_a1[4][4]; -extern uint8_t arrShapeT_a2[4][4]; -extern uint8_t arrShapeT_a3[4][4]; -extern uint8_t arrShapeT_a4[4][4]; +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]; /* @@ -212,48 +185,47 @@ void resetActiveShape() { actiSh.x = 3; actiSh.y = 16; - actiSh.r = 1; actiSh.t = (rand()%7)+1; // Insert new random shape of 7 variants switch (actiSh.t) { // Copy cell active/inactive state case 1 : memcpy(&actiSh.c[0][0], - &arrShapeL_a1[0][0], + &arrShapeL[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tOrange; break; case 2 : memcpy(&actiSh.c[0][0], - &arrShapeRL_a1[0][0], + &arrShapeRL[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tBlue; break; case 3 : memcpy(&actiSh.c[0][0], - &arrShapeZ_a1[0][0], + &arrShapeZ[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tRed; break; case 4 : memcpy(&actiSh.c[0][0], - &arrShapeS_a1[0][0], + &arrShapeS[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tGreen; break; case 5 : memcpy(&actiSh.c[0][0], - &arrShapeB_a1[0][0], + &arrShapeB[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tYellow; break; case 6 : memcpy(&actiSh.c[0][0], - &arrShapeI_a1[0][0], + &arrShapeI[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tCyan; break; case 7 : memcpy(&actiSh.c[0][0], - &arrShapeT_a1[0][0], + &arrShapeT[0][0], sizeof(uint8_t)*4*4); actiSh.fColor = tMagneta; break; diff --git a/src/include/common.h b/src/include/common.h index c606560..4db5941 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -34,7 +34,6 @@ struct tCell fldCAtt[20][10];// fld cells attributes struct activeShape { int x; // x coord of shape's left side int y; // y coord of shape's bottom - int r; // rotate state, one of four int t; // shape type sfColor fColor; // shape color uint8_t c[4][4]; // array of shape cells diff --git a/src/shape_maps.c b/src/shape_maps.c index c89420d..eaa4635 100644 --- a/src/shape_maps.c +++ b/src/shape_maps.c @@ -13,7 +13,7 @@ * .... .##. #... .#.. * .... .... .... .... */ -uint8_t arrShapeL_a1[4][4] = { +uint8_t arrShapeL[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, @@ -27,7 +27,7 @@ uint8_t arrShapeL_a1[4][4] = { * .... .... .... .... */ -uint8_t arrShapeRL_a1[4][4] = { +uint8_t arrShapeRL[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, @@ -40,7 +40,7 @@ uint8_t arrShapeRL_a1[4][4] = { * .... .#.. .##. #... * .... .... .... .... */ -uint8_t arrShapeZ_a1[4][4] = { +uint8_t arrShapeZ[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 1, 1, 0}, @@ -53,7 +53,7 @@ uint8_t arrShapeZ_a1[4][4] = { * .... ..#. ##.. .#.. * .... .... .... .... */ -uint8_t arrShapeS_a1[4][4] = { +uint8_t arrShapeS[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 0, 0}, @@ -67,7 +67,7 @@ uint8_t arrShapeS_a1[4][4] = { * .... .... .... .... * .... .... .... .... */ -uint8_t arrShapeB_a1[4][4] = { +uint8_t arrShapeB[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 1, 1, 0}, @@ -81,7 +81,7 @@ uint8_t arrShapeB_a1[4][4] = { * .#.. .... .#.. .... * .#.. .... .#.. .... */ -uint8_t arrShapeI_a1[4][4] = { +uint8_t arrShapeI[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, @@ -95,7 +95,7 @@ uint8_t arrShapeI_a1[4][4] = { * .... .#.. .#.. .#.. * .... .... .... .... */ -uint8_t arrShapeT_a1[4][4] = { +uint8_t arrShapeT[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 0}, -- cgit v1.2.3