reformat code comments
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 03:48:56 +0000 (04:48 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 03:48:56 +0000 (04:48 +0100)
board.c

diff --git a/board.c b/board.c
index 538a0dfe406f1d4aec0ceee05596dd18705d08de..87073b9a7b5348e14ebe9ed20b94ba96d70fdd87 100644 (file)
--- a/board.c
+++ b/board.c
@@ -30,67 +30,67 @@ static const char shapes[7][4][4][4] = {
         */
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x47, 0xC7, 0x97, 0x00},
-           {0x00, 0x00, 0x27, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //sharp horizontal
+           {0x00, 0x00, 0x27, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // sharp horizontal
          { {0x00, 0x17, 0x00, 0x00}, {0x00, 0x37, 0x00, 0x00},
-           {0x47, 0xA7, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //blunt vertical J
+           {0x47, 0xA7, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // blunt vertical
          { {0x17, 0x00, 0x00, 0x00}, {0x67, 0xC7, 0x87, 0x00},
-           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //blunt horizontal
+           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // blunt horizontal
          { {0x00, 0x57, 0x87, 0x00}, {0x00, 0x37, 0x00, 0x00},
-           {0x00, 0x27, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, //J (yellow)
+           {0x00, 0x27, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, // J (yellow)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x53, 0xC3, 0x83, 0x00},
-           {0x23, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //sharp horizontal
+           {0x23, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // sharp horizontal
          { {0x43, 0x93, 0x00, 0x00}, {0x00, 0x33, 0x00, 0x00},
-           {0x00, 0x23, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //sharp vertical
+           {0x00, 0x23, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // sharp vertical
          { {0x00, 0x00, 0x13, 0x00}, {0x43, 0xC3, 0xA3, 0x00},
-           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //blunt horizontal
+           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // blunt horizontal
          { {0x00, 0x13, 0x00, 0x00}, {0x00, 0x33, 0x00, 0x00},
-           {0x00, 0x63, 0x83, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, //L (cyan)
+           {0x00, 0x63, 0x83, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, // L (cyan)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x48, 0xD8, 0x88, 0x00},
-           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //pointing down
+           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // pointing down
          { {0x00, 0x18, 0x00, 0x00}, {0x48, 0xB8, 0x00, 0x00},
-           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //pointing left
+           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // pointing left
          { {0x00, 0x18, 0x00, 0x00}, {0x48, 0xE8, 0x88, 0x00},
-           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //pointing up
+           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // pointing up
          { {0x00, 0x18, 0x00, 0x00}, {0x00, 0x78, 0x88, 0x00},
-           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, //T (white)
+           {0x00, 0x28, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, // T (white)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x52, 0x82, 0x00},
-           {0x42, 0xA2, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //lieing
+           {0x42, 0xA2, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // lieing
          { {0x12, 0x00, 0x00, 0x00}, {0x62, 0x92, 0x00, 0x00},
-           {0x00, 0x22, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //standing
+           {0x00, 0x22, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // standing
          { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x52, 0x82, 0x00},
-           {0x42, 0xA2, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep
+           {0x42, 0xA2, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // repeats
          { {0x12, 0x00, 0x00, 0x00}, {0x62, 0x92, 0x00, 0x00},
-           {0x00, 0x22, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, //S (green)
+           {0x00, 0x22, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, // S (green)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x46, 0x96, 0x00, 0x00},
-           {0x00, 0x66, 0x86, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //lieing
+           {0x00, 0x66, 0x86, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // lieing
          { {0x00, 0x16, 0x00, 0x00}, {0x56, 0xA6, 0x00, 0x00},
-           {0x26, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //standing
+           {0x26, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // standing
          { {0x00, 0x00, 0x00, 0x00}, {0x46, 0x96, 0x00, 0x00},
-           {0x00, 0x66, 0x86, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep
+           {0x00, 0x66, 0x86, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // repeats
          { {0x00, 0x16, 0x00, 0x00}, {0x56, 0xA6, 0x00, 0x00},
-           {0x26, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, //Z (red)
+           {0x26, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} } }, // Z (red)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x44, 0xC4, 0xC4, 0x84},
-           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //lieing
+           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // lieing
          { {0x00, 0x14, 0x00, 0x00}, {0x00, 0x34, 0x00, 0x00},
-           {0x00, 0x34, 0x00, 0x00}, {0x00, 0x24, 0x00, 0x00} }, //standing
+           {0x00, 0x34, 0x00, 0x00}, {0x00, 0x24, 0x00, 0x00} }, // standing
          { {0x00, 0x00, 0x00, 0x00}, {0x44, 0xC4, 0xC4, 0x84},
-           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep
+           {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // repeats
          { {0x00, 0x14, 0x00, 0x00}, {0x00, 0x34, 0x00, 0x00},
-           {0x00, 0x34, 0x00, 0x00}, {0x00, 0x24, 0x00, 0x00} } }, //I, stick (blue)
+           {0x00, 0x34, 0x00, 0x00}, {0x00, 0x24, 0x00, 0x00} } }, // I, stick (blue)
 
        { { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00},
            {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} },
          { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00},
-           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep
+           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} }, // repeats
          { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00},
-           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep
+           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} },
          { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00},
-           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} } } //O, square (purple)
+           {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} } } // O, square (purple)
 };
 
 int ShapeIterate(char s, int scr, int y, int x, ShapeDrawFunc func)
@@ -164,13 +164,13 @@ int RefreshBoard(int scr)
        unsigned int c;
 
        for (y = Players[scr].boardVisible - 1; y >= 0; y--)
-               if ((c = changed[scr][y])) { //line changed
+               if ((c = changed[scr][y])) { // line changed
                        for (x = 0; c; (c >>= 1), x++)
                                if (c & 1 && board[scr][y][x] != oldBoard[scr][y][x]) {
                                        PlotBlock(scr, y, x, board[scr][y][x]);
                                        oldBoard[scr][y][x] = board[scr][y][x];
                                }
-                       changed[scr][y] = 0; //reset
+                       changed[scr][y] = 0; // reset
                        any = 1;
                } //changed row
        return any;
@@ -212,7 +212,7 @@ int EraseFunc(int scr, int y, int x, unsigned char type)
 void EraseShape(char shape, int scr, int y, int x, int shadow)
 { //remove block from field
        ShapeIterate(shape, scr, y, x, EraseFunc);
-       if (shadow && scr == me) //draw shadow
+       if (shadow && scr == me) // draw shadow
                ShapeIterate(shape, scr, shadowy + 1, x, EraseFunc);
 }
 
@@ -263,14 +263,16 @@ int RotatePiece(int scr, int dir)
        newshape = (Players[scr].curShape & 252) + (((Players[scr].curShape & 3) + dir) & 3);
        result = ShapeFits(newshape, scr, Players[scr].curY, Players[scr].curX);
        if (!result) {
+               // move if it doesn't fit anymore
                short int slideX;
                for (slideX = 0; slideX < 2; slideX = -slideX) {
-                       if (slideX >= 0) slideX++; //slide more
+                       // slide left and right
+                       if (slideX >= 0) slideX++; // slide more
                        if (result = ShapeFits(newshape, scr, Players[scr].curY,
                                Players[scr].curX+slideX)) break;
-               } //slide left and right
+               }
                if (result) Players[scr].curX += slideX;
-       } //try to fit if it doesn't
+       }
        if (result) Players[scr].curShape = newshape;
        PlotShape(Players[scr].curShape, scr,
                Players[scr].curY, Players[scr].curX, scr == me);
@@ -297,15 +299,15 @@ int BlockFree(int scr, int x, int y, unsigned char z)
 { //Check if blocks are empty below block (x,y) and sticking to (x,y) mask <z>
        unsigned char curblock;
 
-       if (y == 0) return 0; //at bottom
+       if (y == 0) return 0; // at bottom
        curblock = GetBlock(scr, y, x) & z;
        if (curblock & 0x10 && !BlockFree(scr, x, y-1, z & 0xD0)) return 0;
        if (curblock & 0x20 && !BlockFree(scr, x, y+1, z & 0xE0)) return 0;
        if (curblock & 0x40 && !BlockFree(scr, x+1, y, z & 0x70)) return 0;
        if (curblock & 0x80 && !BlockFree(scr, x-1, y, z & 0xB0)) return 0;
-       if ((z = GetBlock(scr, y-1, x)) & 0x20) return 1; //stuck to block below
-       if (z > BT_none) return 0; //some other piece below
-       return 1; //nothing below
+       if ((z = GetBlock(scr, y-1, x)) & 0x20) return 1; // stuck to block below
+       if (z > BT_none) return 0; // some other piece below
+       return 1; // nothing below
 }
 
 int BlockFall(int scr, int x, int y, unsigned char z)
@@ -327,13 +329,13 @@ int CheckFall(int scr)
        for (y = Players[scr].boardHeight - 1; y > 0; y--)
                for (x = 0; x < Players[scr].boardWidth; x++) {
                        if ((z = GetBlock(scr, y, x)) > BT_none && (z & 0xA0) == 0) {
-                       //doesn't stick left/up => topleft block
+                               // block present which doesn't stick left/up => topleft block
                                if (BlockFree(scr, x, y, 0xF0)) {
-                                       BlockFall(scr, x, y, 0xF0);
+                                       BlockFall(scr, x, y, 0xF0); // move blocks down
                                        fallen++;
-                               } //move blocks down
+                               }
                        } //block present
-               } //handle line
+               }
        return fallen;
 }
 
@@ -364,13 +366,14 @@ int ClearFullLines(int scr)
        from = to = 0;
        while (to < Players[scr].boardHeight) {
                while (LineIsFull(scr, from)) {
-                       from++; //skip
+                       from++; // skip
                        for (x = 0; x<Players[scr].boardWidth; x++) {
+                               // don't stick blocks to line which we'll remove
                                SetBlock(scr, from, x, GetBlock(scr, from, x) & 0xEF);
                                if (from > 1)
                                        SetBlock(scr, from-2, x, GetBlock(scr, from-2, x) & 0xDF);
-                       } //don't stick blocks to line which we'll remove
-               } //full lines
+                       }
+               }
                CopyLine(scr, from++, to++);
        }
        linescleared += from - to;
@@ -396,10 +399,10 @@ void InsertJunk(int scr, int color, int count, int column)
                        SetBlock(scr, y, x, x == column ? BT_none : color + 1
                                + 0x40 * (x != column-1 && x < Players[scr].boardWidth-1)
                                + 0x80 * (x != column+1 && x > 0));
-       Players[scr].curY += count; //move piece up..
+       Players[scr].curY += count; // move piece up..
        for (y = 0; y < count; ++y)
                if (ShapeFits(Players[scr].curShape, scr, Players[scr].curY - 1, Players[scr].curX))
-                       Players[scr].curY--; //..and down again as far as possible
+                       Players[scr].curY--; // ...and down again as far as possible
                else break;
        PlotShape(Players[scr].curShape, scr, Players[scr].curY, Players[scr].curX,
                scr == me);