public int clearLines() {
    int numClearedLines = 0;
    for (int curOldLine = board.length-1 ; curOldLine >= 0; curOldLine--) {
      if (curOldLine >= 2 && board[curOldLine] == 0x3ff)
        numClearedLines++;
      else
        board[curOldLine + numClearedLines] = board[curOldLine];
    }
    for (int i = numClearedLines-1; i >= 0; i--) {
      if (i > 0)
        board[i] = board[0]; // Simulate GB Tetris line clear bug.
      else
        board[0] = 0;
    }
    return numClearedLines;
  }