updating stuff

Dependencies:   PWMOut Pokitto_

Fork of Pokittris by Pokitto Community Team

Revision:
1:827c9852286e
Parent:
0:f759a823d3ae
Child:
3:8540039d1eed
--- a/tetris.cpp	Tue Oct 10 07:17:45 2017 +0000
+++ b/tetris.cpp	Sun Oct 15 16:51:15 2017 +0000
@@ -8,11 +8,6 @@
 
 Pokitto::Core game;
 
-#define HELD 0
-#define NEW 1
-#define RELEASE 2
-byte CompletePad, ExPad, TempPad, myPad;
-bool _A[3], _B[3], _C[3], _Up[3], _Down[3], _Left[3], _Right[3];
 bool bgNum = 1;
 char musicName[] = "pokittris.raw";
 byte palNum = 0;
@@ -25,6 +20,22 @@
 bool splodeOK=0;
 byte animSplode=0;
 
+
+/**************************************************************************/
+#define HELD 0
+#define NEW 1
+#define RELEASE 2
+byte CompletePad, ExPad, TempPad, myPad;
+bool _A[3], _B[3], _C[3], _Up[3], _Down[3], _Left[3], _Right[3];
+
+DigitalIn _aPin(P1_9);
+DigitalIn _bPin(P1_4);
+DigitalIn _cPin(P1_10);
+DigitalIn _upPin(P1_13);
+DigitalIn _downPin(P1_3);
+DigitalIn _leftPin(P1_25);
+DigitalIn _rightPin(P1_7);
+
 void UPDATEPAD(int pad, int var) {
   _C[pad] = (var >> 1)&1;
   _B[pad] = (var >> 2)&1;
@@ -45,13 +56,13 @@
 
 byte updateButtons(byte var){
    var = 0;
-   if (game.buttons.cBtn()) var |= (1<<1);
-   if (game.buttons.bBtn()) var |= (1<<2);
-   if (game.buttons.aBtn()) var |= (1<<3);
-   if (game.buttons.downBtn()) var |= (1<<4);
-   if (game.buttons.leftBtn()) var |= (1<<5);
-   if (game.buttons.rightBtn()) var |= (1<<6);
-   if (game.buttons.upBtn()) var |= (1<<7);
+   if (_cPin) var |= (1<<1);
+   if (_bPin) var |= (1<<2);
+   if (_aPin) var |= (1<<3); // P1_9 = A
+   if (_downPin) var |= (1<<4);
+   if (_leftPin) var |= (1<<5);
+   if (_rightPin) var |= (1<<6);
+   if (_upPin) var |= (1<<7);
 
    return var;
 }
@@ -257,9 +268,7 @@
         curPal[t] = (red[t]<<11)+(green[t]<<5)+blue[t];
 
     }
-
     game.display.load565Palette(curPal);
-
 }
 
 
@@ -292,8 +301,6 @@
                 game.display.drawPixel(x + i, y + j);
             }
         }
-
-    //return;
     }
 }
 
@@ -426,7 +433,7 @@
                 animSplode=1;
         }
 
-        if (_A[NEW]) {
+        if (_B[NEW]) {
           if (check(px, py, (pr - 1) & 3) == 0) {
             pr--;
           } else if (check(px - 1, py, (pr - 1) & 3) == 0) {
@@ -441,7 +448,7 @@
           pr &= 3;
         }
 
-        if (_B[NEW]) {
+        if (_A[NEW]) {
           if (check(px, py, (pr + 1) & 3) == 0) {
             pr++;
           } else if (check(px - 1, py, (pr + 1) & 3) == 0) {
@@ -546,11 +553,9 @@
    while (game.isRunning()) {
 
         // if it is time to update the screen
-        if (game.update()){
-
+        if (game.update(1)){
             frameNumber++;
             game.sound.updateStream();
-            game.buttons.update();
             myPad = updateButtons(myPad);
             UpdatePad(myPad);
 
@@ -569,7 +574,7 @@
               gameOver();
               break;
             }
-
+            game.display.updateRegion(0,0,220,176);
         }
     }
     return 0;