X-Git-Url: http://git.shiar.net/netris.git/blobdiff_plain/6286afa8518283f62f303e5b6ce188c9bb28e562..02d0eeb0e0a5f43971cf687eac35dcedc59a0247:/board.c diff --git a/board.c b/board.c index b240c0a..f1d159f 100644 --- a/board.c +++ b/board.c @@ -75,7 +75,7 @@ static const char shapes[7][4][4][4] = { { {0x00, 0x00, 0x00, 0x00}, {0x44, 0xC4, 0xC4, 0x84}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep { {0x00, 0x14, 0x00, 0x00}, {0x00, 0x34, 0x00, 0x00}, - {0x00, 0x34, 0x00, 0x00}, {0x00, 0x24, 0x00, 0x00} } }, //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} }, @@ -84,7 +84,7 @@ static const char shapes[7][4][4][4] = { { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00}, {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} }, //rep { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x55, 0x95, 0x00}, - {0x00, 0x65, 0xA5, 0x00}, {0x00, 0x00, 0x00, 0x00} } } //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) @@ -160,7 +160,7 @@ int RefreshBoard(int scr) for (y = Players[scr].boardVisible - 1; y >= 0; y--) 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]) { + 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]; } @@ -293,21 +293,21 @@ int BlockFree(int scr, int x, int y, unsigned char z) if (y == 0) return 0; //at bottom curblock = GetBlock(scr, y, x) & z; - if (curblock & 16 && !BlockFree(scr, x, y-1, z & 208)) return 0; - if (curblock & 32 && !BlockFree(scr, x, y+1, z & 224)) return 0; - if (curblock & 64 && !BlockFree(scr, x+1, y, z & 112)) return 0; - if (curblock & 128 && !BlockFree(scr, x-1, y, z & 176)) return 0; - if ((z = GetBlock(scr, y-1, x)) & 32) return 1; //stuck to block below + 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 } int BlockFall(int scr, int x, int y, unsigned char z) { //Drop down block (x,y) and those sticking to it mask - if (GetBlock(scr, y, x) & z & 16) BlockFall(scr, x, y-1, z & 208); - if (GetBlock(scr, y, x) & z & 32) BlockFall(scr, x, y+1, z & 224); - if (GetBlock(scr, y, x) & z & 64) BlockFall(scr, x+1, y, z & 112); - if (GetBlock(scr, y, x) & z & 128) BlockFall(scr, x-1, y, z & 174); + if (GetBlock(scr, y, x) & z & 0x10) BlockFall(scr, x, y-1, z & 0xD0); + if (GetBlock(scr, y, x) & z & 0x20) BlockFall(scr, x, y+1, z & 0xE0); + if (GetBlock(scr, y, x) & z & 0x40) BlockFall(scr, x+1, y, z & 0x70); + if (GetBlock(scr, y, x) & z & 0x80) BlockFall(scr, x-1, y, z & 0xB0); SetBlock(scr, y-1, x, GetBlock(scr, y, x)); SetBlock(scr, y, x, BT_none); } @@ -320,10 +320,10 @@ int CheckFall(int scr) if (!Game.gravity) return 0; 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)) { + if ((z = GetBlock(scr, y, x)) > BT_none && (z & 0xA0) == 0) { //doesn't stick left/up => topleft block - if (BlockFree(scr, x, y, 240)) { - BlockFall(scr, x, y, 240); + if (BlockFree(scr, x, y, 0xF0)) { + BlockFall(scr, x, y, 0xF0); fallen++; } //move blocks down } //block present @@ -360,9 +360,9 @@ int ClearFullLines(int scr) while (LineIsFull(scr, from)) { from++; //skip for (x = 0; x 1) - SetBlock(scr, from-2, x, GetBlock(scr, from-2, x)&223); + 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++); @@ -387,9 +387,9 @@ void InsertJunk(int scr, int color, int count, int column) CopyLine(scr, y, y + count); for (y = 0; y < count; ++y) for (x = 0; x < Players[scr].boardWidth; ++x) - SetBlock(scr, y, x, (x == column) ? BT_none : color + 1 - + 64 * (x != column-1 && x < Players[scr].boardWidth-1) - + 128 * (x != column+1 && x > 0)); + 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.. for (y = 0; y < count; ++y) if (ShapeFits(Players[scr].curShape, scr, Players[scr].curY - 1, Players[scr].curX))