only use ascii drawstyles in ascii mode
[netris.git] / board.c
diff --git a/board.c b/board.c
index c3a8d5cae44e69711ad4a6f7e1b698940eef6274..b240c0ae05c3d23beccac9b98aef917e953c839c 100644 (file)
--- a/board.c
+++ b/board.c
@@ -15,8 +15,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: board.c,v 1.15 1999/05/16 06:56:24 mhw Exp $
  */
 
 #include "netris.h"
@@ -94,10 +92,10 @@ int ShapeIterate(char s, int scr, int y, int x, ShapeDrawFunc func)
        int i, j, result;
        char type, rotation;
 
-       type = s/4;
-       rotation = s&3;
-       for (i = 0; i<4; i++)
-               for (j = 0; j<4; j++)
+       type = s / 4;
+       rotation = s & 3;
+       for (i = 0; i < 4; i++)
+               for (j = 0; j < 4; j++)
                        if (shapes[type][rotation][i][j])
                                if (result = func(scr, y-i, x+j, shapes[type][rotation][i][j]))
                                        return result;
@@ -112,9 +110,10 @@ char ChooseOption(float options[7])
        int i;
        float total = 0, val;
 
-       for (i = 0; i<7; i++) total += options[i];
-       val = Random(0, 32767)/32768.0*total;
-       for (i = 0; i<7; i++) if ((val -= options[i])<0) return i<<2;
+       for (i = 0; i < 7; i++) total += options[i];
+       val = Random(0, 32767) / 32768.0 * total;
+       for (i = 0; i < 7; i++) if ((val -= options[i]) < 0)
+               return i << 2;
        return 0;
 }
 
@@ -132,7 +131,7 @@ void ClearField(int scr)
                for (x = 0; x < Players[scr].boardWidth; ++x) {
                        oldBoard[scr][y][x] = board[scr][y][x] = BT_none;
                }
-} //ClearField
+}
 
 unsigned char GetBlock(int scr, int y, int x)
 { //Returns the block on field at position (x,y)
@@ -142,16 +141,16 @@ unsigned char GetBlock(int scr, int y, int x)
                return BT_none;
        else
                return board[scr][y][x];
-} //GetBlock
+}
 
 void SetBlock(int scr, int y, int x, unsigned char type)
 {
-       if (y >= 0 && y < Players[scr].boardHeight &&
-               x >= 0 && x < Players[scr].boardWidth) {
+       if (y >= 0 && y < Players[scr].boardHeight
+        && x >= 0 && x < Players[scr].boardWidth) {
                board[scr][y][x] = type;
                changed[scr][y] |= 1 << x;
        }
-} //SetBlock
+}
 
 int RefreshBoard(int scr)
 { //draw changes to screen
@@ -169,19 +168,19 @@ int RefreshBoard(int scr)
                        any = 1;
                } //changed row
        return any;
-} //RefreshBoard
+}
 
 int GlanceFunc(int scr, int y, int x, unsigned char type)
 {
        PlotBlockXY(y, x, type);
        return 0;
-} //GlanceFunc
+}
 
 int ShadowFunc(int scr, int y, int x, unsigned char type)
 { //draw shadow
        SetBlock(scr, y, x, BT_shadow);
        return 0;
-} //ShadowFunc
+}
 
 int PlotFunc(int scr, int y, int x, unsigned char type)
 {
@@ -197,7 +196,7 @@ void PlotShape(char shape, int scr, int y, int x, int shadow)
                ShapeIterate(shape, scr, shadowy + 1, x, ShadowFunc);
        } //draw shadow
        ShapeIterate(shape, scr, y, x, PlotFunc);
-} //PlotShape
+}
 
 int EraseFunc(int scr, int y, int x, unsigned char type)
 {
@@ -209,7 +208,7 @@ void EraseShape(char shape, int scr, int y, int x, int shadow)
        ShapeIterate(shape, scr, y, x, EraseFunc);
        if (shadow && scr == me) //draw shadow
                ShapeIterate(shape, scr, shadowy + 1, x, EraseFunc);
-} //EraseShape
+}
 
 int CollisionFunc(int scr, int y, int x, unsigned char type)
 {
@@ -218,7 +217,7 @@ int CollisionFunc(int scr, int y, int x, unsigned char type)
 int ShapeFits(char shape, int scr, int y, int x)
 { //check if there's nothing in the way
        return !ShapeIterate(shape, scr, y, x, CollisionFunc);
-} //ShapeFits
+}
 
 int VisibleFunc(int scr, int y, int x, unsigned char type)
 {
@@ -228,7 +227,7 @@ int VisibleFunc(int scr, int y, int x, unsigned char type)
 int ShapeVisible(char shape, int scr, int y, int x)
 {
        return ShapeIterate(shape, scr, y, x, VisibleFunc);
-} //ShapeVisible
+}
 
 int MovePiece(int scr, int deltaY, int deltaX)
 {
@@ -237,7 +236,7 @@ int MovePiece(int scr, int deltaY, int deltaX)
        EraseShape(Players[scr].curShape, scr,
                Players[scr].curY, Players[scr].curX, 1);
        result = ShapeFits(Players[scr].curShape, scr, Players[scr].curY + deltaY,
-                               Players[scr].curX + deltaX);
+                          Players[scr].curX + deltaX);
        if (result) {
                Players[scr].curY += deltaY;
                Players[scr].curX += deltaX;
@@ -245,7 +244,7 @@ int MovePiece(int scr, int deltaY, int deltaX)
        PlotShape(Players[scr].curShape, scr, Players[scr].curY, Players[scr].curX,
                scr == me);
        return result;
-} //MovePiece
+}
 
 int RotatePiece(int scr, int dir)
 {
@@ -268,9 +267,9 @@ int RotatePiece(int scr, int dir)
        } //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);
+               Players[scr].curY, Players[scr].curX, scr == me);
        return result;
-} //RotatePiece
+}
 
 int DropPiece(int scr)
 {
@@ -279,14 +278,14 @@ int DropPiece(int scr)
        EraseShape(Players[scr].curShape, scr,
                Players[scr].curY, Players[scr].curX, 1);
        while (ShapeFits(Players[scr].curShape, scr,
-                       Players[scr].curY - 1, Players[scr].curX)) {
+              Players[scr].curY - 1, Players[scr].curX)) {
                Players[scr].curY--;
                count++;
        }
        PlotShape(Players[scr].curShape, scr,
                Players[scr].curY, Players[scr].curX, 0);
        return count;
-} //DropPiece
+}
 
 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>
@@ -319,7 +318,7 @@ int CheckFall(int scr)
        unsigned char z;
 
        if (!Game.gravity) return 0;
-       for (y = Players[scr].boardHeight-1; y > 0; y--)
+       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 & 160) == 0)) {
                        //doesn't stick left/up => topleft block
@@ -362,7 +361,7 @@ int ClearFullLines(int scr)
                        from++; //skip
                        for (x = 0; x<Players[scr].boardWidth; x++) {
                                SetBlock(scr, from, x, GetBlock(scr, from, x)&239);
-                               if (from>1)
+                               if (from > 1)
                                        SetBlock(scr, from-2, x, GetBlock(scr, from-2, x)&223);
                        } //don't stick blocks to line which we'll remove
                } //full lines
@@ -398,9 +397,5 @@ void InsertJunk(int scr, int color, int count, int column)
                else break;
        PlotShape(Players[scr].curShape, scr, Players[scr].curY, Players[scr].curX,
                scr == me);
-} //InoertJunk
+}
 
-/*
- * vi: ts=4 ai
- * vim: noai si
- */