got the board to render halfway
authorArun Persaud <arun@nubati.net>
Fri, 31 Jul 2009 05:26:07 +0000 (22:26 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 31 Jul 2009 05:26:07 +0000 (22:26 -0700)
backend.c
callback.c
gtk-interface.xml
interface.h
xboard.c

index 5df4fc6..6891eb1 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -5394,10 +5394,10 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar)
        FinishMove if the first part succeeded. Calls that do not need
        to do anything in between, can call this routine the old way. 
     */
-    ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar);
-if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar);
-    if(moveType != ImpossibleMove)
-        FinishMove(moveType, fromX, fromY, toX, toY, promoChar);
+  ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar);
+  if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar);
+  if(moveType != ImpossibleMove)
+    FinishMove(moveType, fromX, fromY, toX, toY, promoChar);
 }
 
 void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cpstats )
index c9aa4f0..2aec851 100644 (file)
@@ -266,7 +266,8 @@ void UserMoveProc(window, event, data)
     if (flipView && x >= 0) {
        x = BOARD_WIDTH - 1 - x;
     }
-
+    printf("DEBUG::UserMoveProc: x %d y %d\n",x,y);
+    
     if (fromX == -1) {
        if (event->type == ButtonPress) {
            /* First square */
@@ -274,6 +275,7 @@ void UserMoveProc(window, event, data)
                fromX = x;
                fromY = y;
                second = 0;
+    printf("DEBUG::UserMoveProc: a\n");
                DragPieceBegin(event->button.x, event->button.y);
                if (appData.highlightDragging) {
                    SetHighlights(x, y, -1, -1);
@@ -291,6 +293,7 @@ void UserMoveProc(window, event, data)
        /* Check if clicking again on the same color piece */
        fromP = boards[currentMove][fromY][fromX];
        toP = boards[currentMove][y][x];
+    printf("DEBUG::UserMoveProc: b\n");
        if ((WhitePawn <= fromP && fromP <= WhiteKing &&
             WhitePawn <= toP && toP <= WhiteKing) ||
            (BlackPawn <= fromP && fromP <= BlackKing &&
@@ -312,6 +315,7 @@ void UserMoveProc(window, event, data)
     }
 
     if (event->type == GDK_BUTTON_RELEASE &&   x == fromX && y == fromY) {
+    printf("DEBUG::UserMoveProc: c\n");
        DragPieceEnd(event->button.x, event->button.y);
        if (appData.animateDragging) {
            /* Undo animation damage if any */
@@ -335,7 +339,9 @@ void UserMoveProc(window, event, data)
     toX = x;
     toY = y;
     saveAnimate = appData.animate;
+    printf("DEBUG::UserMoveProc: d\n");
     if (event->type == GDK_BUTTON_PRESS) {
+    printf("DEBUG::UserMoveProc: e\n");
        /* Finish clickclick move */
        if (appData.animate || appData.highlightLastMove) {
            SetHighlights(fromX, fromY, toX, toY);
@@ -353,7 +359,9 @@ void UserMoveProc(window, event, data)
        /* Don't animate move and drag both */
        appData.animate = FALSE;
     }
+    printf("DEBUG::UserMoveProc: f\n");
     if (IsPromotion(fromX, fromY, toX, toY)) {
+    printf("DEBUG::UserMoveProc: f1\n");
        if (appData.alwaysPromoteToQueen) {
            UserMoveEvent(fromX, fromY, toX, toY, 'q');
            if (!appData.highlightLastMove || gotPremove) ClearHighlights();
@@ -364,12 +372,16 @@ void UserMoveProc(window, event, data)
            PromotionPopUp();
        }
     } else {
+    printf("DEBUG::UserMoveProc: f2\n");
+    
        UserMoveEvent(fromX, fromY, toX, toY, NULLCHAR);
+    printf("DEBUG::UserMoveProc: f3\n");
        if (!appData.highlightLastMove || gotPremove) ClearHighlights();
        if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY);
        fromX = fromY = -1;
     }
     appData.animate = saveAnimate;
+    printf("DEBUG::UserMoveProc: g\n");
     if (appData.animate || appData.animateDragging) {
        /* Undo animation damage if needed */
        DrawPosition(FALSE, NULL);
index dfbbda7..26171dd 100644 (file)
@@ -32,6 +32,7 @@
                             <property name="visible">True</property>
                             <property name="label" translatable="yes">Reset Game</property>
                             <property name="use_underline">True</property>
+                            <signal name="activate" handler="ResetProc"/>
                           </object>
                         </child>
                         <child>
@@ -45,6 +46,7 @@
                             <property name="visible">True</property>
                             <property name="image">image1</property>
                             <property name="use_stock">False</property>
+                            <signal name="activate" handler="LoadGameProc"/>
                           </object>
                         </child>
                         <child>
@@ -52,6 +54,7 @@
                             <property name="visible">True</property>
                             <property name="label" translatable="yes">Load Next Game</property>
                             <property name="use_underline">True</property>
+                            <signal name="activate" handler="LoadNextGameProc"/>
                           </object>
                         </child>
                         <child>
@@ -66,6 +69,7 @@
                             <property name="visible">True</property>
                             <property name="label" translatable="yes">Reload Same Game</property>
                             <property name="use_underline">True</property>
+                            <signal name="activate" handler="ReloadGameProc"/>
                           </object>
                         </child>
                         <child>
                     <property name="visible">True</property>
                     <property name="label" translatable="yes">_Action</property>
                     <property name="use_underline">True</property>
+                    <child type="submenu">
+                      <object class="GtkMenu" id="menu1">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Accept">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Accept</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Call Flag">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Call Flag</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuActioin.Decline">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Decline</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkSeparatorMenuItem" id="menuActionsep1">
+                            <property name="visible">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Rematch">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Rematch</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Draw">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Draw</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Adjourn">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Adjourn</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Resign">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Resign</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Abort">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Abort</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkSeparatorMenuItem" id="menuActionsep2">
+                            <property name="visible">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Stop Observing">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Stop Observing</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuAction.Stop Examine">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Stop Examine</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </object>
                 </child>
                 <child>
                             <property name="visible">True</property>
                             <property name="label" translatable="yes">Show Coords</property>
                             <property name="use_underline">True</property>
+                            <signal name="toggled" handler="ShowCoordsProc"/>
                           </object>
                         </child>
                         <child>
                       <object class="GtkMenu" id="menu3">
                         <property name="visible">True</property>
                         <child>
-                          <object class="GtkImageMenuItem" id="imagemenuitem10">
+                          <object class="GtkMenuItem" id="menuHelp.Hint">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Hint</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkMenuItem" id="menuHelp.Book">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Book</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkSeparatorMenuItem" id="menuHelpsep1">
+                            <property name="visible">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkImageMenuItem" id="menuHelp.about">
                             <property name="label">gtk-about</property>
                             <property name="visible">True</property>
                             <property name="use_underline">True</property>
                             <property name="use_stock">True</property>
+                            <signal name="activate" handler="AboutProc"/>
                           </object>
                         </child>
                       </object>
             <child>
               <object class="GtkDrawingArea" id="Board">
                 <property name="visible">True</property>
+                <property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
                 <signal name="button_press_event" handler="UserMoveProc"/>
                 <signal name="expose_event" handler="EventProc"/>
                 <signal name="button_release_event" handler="UserMoveProc"/>
index 9704012..78705ab 100644 (file)
@@ -12,7 +12,7 @@ gint                     boardHeight;
 GdkPixbuf               *WindowIcon=NULL;
 GdkPixbuf               *WhiteIcon=NULL;
 GdkPixbuf               *BlackIcon=NULL;
-GdkPixbuf               *SVGpieces[12];
+GdkPixbuf               *SVGpieces[100];
 GdkPixbuf               *SVGLightSquare=NULL;
 GdkPixbuf               *SVGDarkSquare=NULL;
 GdkPixbuf               *SVGNeutralSquare=NULL;
index 2fe17ed..c6786b8 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -487,7 +487,7 @@ Pixmap pieceBitmap2[2][(int)BlackPawn+4];       /* [HGM] pieces */
 Pixmap xpmPieceBitmap[4][(int)BlackPawn];      /* LL, LD, DL, DD actually used*/
 Pixmap xpmPieceBitmap2[4][(int)BlackPawn+4];   /* LL, LD, DL, DD set to select from */
 Pixmap xpmLightSquare, xpmDarkSquare, xpmJailSquare;
-int useImages, useImageSqs;
+int useImages=0, useImageSqs;
 XImage *ximPieceBitmap[4][(int)BlackPawn+4];   /* LL, LD, DL, DD */
 Pixmap ximMaskPm[(int)BlackPawn];               /* clipmasks, used for XIM pieces */
 Pixmap ximMaskPm2[(int)BlackPawn+4];            /* clipmasks, used for XIM pieces */
@@ -2153,7 +2153,7 @@ void InitDrawingSizes(BoardSize boardSize, int flags)
     XtGeometryResult gres;
     int i;
 
-    if(!formWidget) return;
+    //    if(!formWidget) return;
 
     /*
      * Enable shell resizing.
@@ -2204,6 +2204,7 @@ void InitDrawingSizes(BoardSize boardSize, int flags)
 //                 programName, gres, w, h, wr, hr);
 //     }
     }
+    if(!formWidget) return;
 
     //    XawFormDoLayout(formWidget, True);
 
@@ -2461,56 +2462,56 @@ main(argc, argv)
     gameInfo.boardHeight   = appData.NrRanks > 0 ? appData.NrRanks : 8;
     gameInfo.holdingsWidth = appData.holdingsSize > 0 ? 2 : 0;
 #endif
-
-
+    
+    
 #ifdef IDSIZE
     InitDrawingSizes(-1, 0); // [HGM] initsize: make this into a subroutine
 #else
     if (isdigit(appData.boardSize[0])) {
-        i = sscanf(appData.boardSize, "%d,%d,%d,%d,%d,%d,%d", &squareSize,
-                  &lineGap, &clockFontPxlSize, &coordFontPxlSize,
-                  &fontPxlSize, &smallLayout, &tinyLayout);
-        if (i == 0) {
-           fprintf(stderr, _("%s: bad boardSize syntax %s\n"),
-                   programName, appData.boardSize);
-           exit(2);
-       }
-       if (i < 7) {
-           /* Find some defaults; use the nearest known size */
-           SizeDefaults *szd, *nearest;
-           int distance = 99999;
-           nearest = szd = sizeDefaults;
-           while (szd->name != NULL) {
-               if (abs(szd->squareSize - squareSize) < distance) {
-                   nearest = szd;
-                   distance = abs(szd->squareSize - squareSize);
-                   if (distance == 0) break;
-               }
-               szd++;
-           }
-           if (i < 2) lineGap = nearest->lineGap;
-           if (i < 3) clockFontPxlSize = nearest->clockFontPxlSize;
-           if (i < 4) coordFontPxlSize = nearest->coordFontPxlSize;
-           if (i < 5) fontPxlSize = nearest->fontPxlSize;
-           if (i < 6) smallLayout = nearest->smallLayout;
-           if (i < 7) tinyLayout = nearest->tinyLayout;
+      i = sscanf(appData.boardSize, "%d,%d,%d,%d,%d,%d,%d", &squareSize,
+                &lineGap, &clockFontPxlSize, &coordFontPxlSize,
+                &fontPxlSize, &smallLayout, &tinyLayout);
+      if (i == 0) {
+       fprintf(stderr, _("%s: bad boardSize syntax %s\n"),
+               programName, appData.boardSize);
+       exit(2);
+      }
+      if (i < 7) {
+       /* Find some defaults; use the nearest known size */
+       SizeDefaults *szd, *nearest;
+       int distance = 99999;
+       nearest = szd = sizeDefaults;
+       while (szd->name != NULL) {
+         if (abs(szd->squareSize - squareSize) < distance) {
+           nearest = szd;
+           distance = abs(szd->squareSize - squareSize);
+                          if (distance == 0) break;
+                          }
+             szd++;
+         }
+         if (i < 2) lineGap = nearest->lineGap;
+         if (i < 3) clockFontPxlSize = nearest->clockFontPxlSize;
+         if (i < 4) coordFontPxlSize = nearest->coordFontPxlSize;
+         if (i < 5) fontPxlSize = nearest->fontPxlSize;
+         if (i < 6) smallLayout = nearest->smallLayout;
+         if (i < 7) tinyLayout = nearest->tinyLayout;
        }
-    } else {
+      } else {
         SizeDefaults *szd = sizeDefaults;
         if (*appData.boardSize == NULLCHAR) {
-           while (DisplayWidth(xDisplay, xScreen) < szd->minScreenSize ||
-                  DisplayHeight(xDisplay, xScreen) < szd->minScreenSize) {
-             szd++;
-           }
-           if (szd->name == NULL) szd--;
+         while (DisplayWidth(xDisplay, xScreen) < szd->minScreenSize ||
+                DisplayHeight(xDisplay, xScreen) < szd->minScreenSize) {
+           szd++;
+         }
+         if (szd->name == NULL) szd--;
        } else {
-           while (szd->name != NULL &&
-                  StrCaseCmp(szd->name, appData.boardSize) != 0) szd++;
-           if (szd->name == NULL) {
-               fprintf(stderr, _("%s: unrecognized boardSize name %s\n"),
-                       programName, appData.boardSize);
-               exit(2);
-           }
+         while (szd->name != NULL &&
+                StrCaseCmp(szd->name, appData.boardSize) != 0) szd++;
+         if (szd->name == NULL) {
+           fprintf(stderr, _("%s: unrecognized boardSize name %s\n"),
+                   programName, appData.boardSize);
+           exit(2);
+         }
        }
        squareSize = szd->squareSize;
        lineGap = szd->lineGap;
@@ -2521,27 +2522,9 @@ main(argc, argv)
        tinyLayout = szd->tinyLayout;
     }
 
-    /* Now, using squareSize as a hint, find a good XPM/XIM set size */
-    if (strlen(appData.pixmapDirectory) > 0) {
-       p = ExpandPathName(appData.pixmapDirectory);
-       if (!p) {
-           fprintf(stderr, _("Error expanding path name \"%s\"\n"),
-                  appData.pixmapDirectory);
-           exit(1);
-       }
-       if (appData.debugMode) {
-          fprintf(stderr, _("\
-XBoard square size (hint): %d\n\
-%s fulldir:%s:\n"), squareSize, IMAGE_EXT, p);
-       }
-       squareSize = xpm_closest_to(p, squareSize, IMAGE_EXT);
-       if (appData.debugMode) {
-           fprintf(stderr, _("Closest %s size: %d\n"), IMAGE_EXT, squareSize);
-       }
-    }
+    printf("DEBUG::main: squareSize %d\n",squareSize);
 
-    /* [HR] height treated separately (hacked) */
-    boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
+    boardWidth  = lineGap + BOARD_WIDTH * (squareSize + lineGap);
     boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
     if (appData.showJail == 1) {
        /* Jail on top and bottom */
@@ -3085,6 +3068,8 @@ XBoard square size (hint): %d\n\
     /* realize window */
     gtk_widget_show (GUI_Window);
 
+    printf("DEBUG: before created stuff squareSize %d.\n",squareSize);
+
     CreateGCs();
     CreateGrid();
     CreatePieces();
@@ -3094,7 +3079,7 @@ XBoard square size (hint): %d\n\
     if (appData.animate || appData.animateDragging)
       CreateAnimVars();
 
-    printf("DEBUG: created stuff.\n");
+    printf("DEBUG: created stuff squareSize %d.\n",squareSize);
 
 
 //    XtAugmentTranslations(formWidget,
@@ -3137,7 +3122,7 @@ XBoard square size (hint): %d\n\
     gdk_cursor_destroy(BoardCursor);
 
     /* end cursor */
-    printf("DEBUG: going into main.\n");
+    printf("DEBUG: going into gtk-main.\n");
 
     gtk_main ();
 
@@ -3704,7 +3689,7 @@ void CreateGrid()
     if (lineGap == 0) return;
 
     /* [HR] Split this into 2 loops for non-square boards. */
-
+    
     for (i = 0; i < BOARD_HEIGHT + 1; i++) {
         gridSegments[i].x1 = 0;
         gridSegments[i].x2 =
@@ -4251,6 +4236,7 @@ static void colorDrawPiece(piece, square_color, x, y, dest)
      int square_color, x, y;
      Drawable dest;
 {
+  printf("DEBUG::colorDrawPiece: piece %d square_color %d x %d y %d \n",piece,square_color,x,y);
   gdk_draw_pixbuf(GDK_WINDOW(GUI_Board->window),NULL,GDK_PIXBUF(SVGpieces[piece]),0,0,x,y,-1,-1, GDK_RGB_DITHER_NORMAL, 0, 0);
   return ;
   
@@ -4314,18 +4300,19 @@ typedef void (*DrawFunc)();
 
 DrawFunc ChooseDrawFunc()
 {
-    if (appData.monoMode) {
-       if (DefaultDepth(xDisplay, xScreen) == 1) {
-           return monoDrawPiece_1bit;
-       } else {
-           return monoDrawPiece;
-       }
+  printf("DEBUG::ChooseDrawFunc: appData.monoMode %d useImages %d\n",appData.monoMode,useImages);
+  if (appData.monoMode) {
+    if (DefaultDepth(xDisplay, xScreen) == 1) {
+      return monoDrawPiece_1bit;
     } else {
-       if (useImages)
-         return colorDrawPieceImage;
-       else
-         return colorDrawPiece;
+      return monoDrawPiece;
     }
+  } else {
+    if (useImages)
+      return colorDrawPieceImage;
+    else
+      return colorDrawPiece;
+  }
 }
 
 /* [HR] determine square color depending on chess variant. */
@@ -4364,10 +4351,13 @@ void DrawSquare(row, column, piece, do_flash)
     XCharStruct overall;
     DrawFunc drawfunc;
     int flash_delay;
-
+    
     /* Calculate delay in milliseconds (2-delays per complete flash) */
     flash_delay = 500 / appData.flashRate;
 
+    printf("DEBUG: linegap %d squareSize %d \n",lineGap,squareSize);
+
+    /* calculate x and y coordinates from row and column */
     if (flipView) {
        x = lineGap + ((BOARD_WIDTH-1)-column) *
          (squareSize + lineGap);
@@ -4380,88 +4370,90 @@ void DrawSquare(row, column, piece, do_flash)
 
     square_color = SquareColor(row, column);
 
-    if ( // [HGM] holdings: blank out area between board and holdings
-                 column == BOARD_LEFT-1 ||  column == BOARD_RGHT
-              || (column == BOARD_LEFT-2 && row < BOARD_HEIGHT-gameInfo.holdingsSize)
-                 || (column == BOARD_RGHT+1 && row >= gameInfo.holdingsSize) ) {
-                       BlankSquare(x, y, 2, EmptySquare, xBoardWindow);
-
-                       // [HGM] print piece counts next to holdings
-                       string[1] = NULLCHAR;
-                       if (column == (flipView ? BOARD_LEFT-1 : BOARD_RGHT) && piece > 1 ) {
-                           string[0] = '0' + piece;
-                           XTextExtents(countFontStruct, string, 1, &direction,
-                                &font_ascent, &font_descent, &overall);
-                           if (appData.monoMode) {
-                               XDrawImageString(xDisplay, xBoardWindow, countGC,
-                                                x + squareSize - overall.width - 2,
-                                                y + font_ascent + 1, string, 1);
-                           } else {
-                               XDrawString(xDisplay, xBoardWindow, countGC,
-                                           x + squareSize - overall.width - 2,
-                                           y + font_ascent + 1, string, 1);
-                           }
-                       }
-                       if (column == (flipView ? BOARD_RGHT : BOARD_LEFT-1) && piece > 1) {
-                           string[0] = '0' + piece;
-                           XTextExtents(countFontStruct, string, 1, &direction,
-                                        &font_ascent, &font_descent, &overall);
-                           if (appData.monoMode) {
-                               XDrawImageString(xDisplay, xBoardWindow, countGC,
-                                                x + 2, y + font_ascent + 1, string, 1);
-                           } else {
-                               XDrawString(xDisplay, xBoardWindow, countGC,
-                                           x + 2, y + font_ascent + 1, string, 1);
-                           }
-                       }
-    } else {
-           if (piece == EmptySquare || appData.blindfold) {
-                       BlankSquare(x, y, square_color, piece, xBoardWindow);
-           } else {
-                       drawfunc = ChooseDrawFunc();
-                       if (do_flash && appData.flashCount > 0) {
-                           for (i=0; i<appData.flashCount; ++i) {
-
-                                       drawfunc(piece, square_color, x, y, xBoardWindow);
-                                       XSync(xDisplay, False);
-                                       do_flash_delay(flash_delay);
-
-                                       BlankSquare(x, y, square_color, piece, xBoardWindow);
-                                       XSync(xDisplay, False);
-                                       do_flash_delay(flash_delay);
-                           }
-                       }
-                       drawfunc(piece, square_color, x, y, xBoardWindow);
-       }
-       }
+    printf("DEBUG::DrawSquare: row %d column %d piece %d do_flash %d square_color %d x %d y %d\n",row,column,piece,do_flash,square_color,x,y);
 
-    string[1] = NULLCHAR;
-    if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0)
-               && column >= BOARD_LEFT && column < BOARD_RGHT) {
-       string[0] = 'a' + column - BOARD_LEFT;
-       XTextExtents(coordFontStruct, string, 1, &direction,
+    if ( // [HGM] holdings: blank out area between board and holdings
+       column == BOARD_LEFT-1 ||  column == BOARD_RGHT
+       || (column == BOARD_LEFT-2 && row < BOARD_HEIGHT-gameInfo.holdingsSize)
+       || (column == BOARD_RGHT+1 && row >= gameInfo.holdingsSize) ) {
+      BlankSquare(x, y, 2, EmptySquare, xBoardWindow);
+      
+      // [HGM] print piece counts next to holdings
+      string[1] = NULLCHAR;
+      if (column == (flipView ? BOARD_LEFT-1 : BOARD_RGHT) && piece > 1 ) {
+       string[0] = '0' + piece;
+       XTextExtents(countFontStruct, string, 1, &direction,
                     &font_ascent, &font_descent, &overall);
        if (appData.monoMode) {
-           XDrawImageString(xDisplay, xBoardWindow, coordGC,
-                            x + squareSize - overall.width - 2,
-                            y + squareSize - font_descent - 1, string, 1);
+         XDrawImageString(xDisplay, xBoardWindow, countGC,
+                          x + squareSize - overall.width - 2,
+                          y + font_ascent + 1, string, 1);
        } else {
-           XDrawString(xDisplay, xBoardWindow, coordGC,
-                       x + squareSize - overall.width - 2,
-                       y + squareSize - font_descent - 1, string, 1);
+         XDrawString(xDisplay, xBoardWindow, countGC,
+                     x + squareSize - overall.width - 2,
+                     y + font_ascent + 1, string, 1);
        }
-    }
-    if (appData.showCoords && column == (flipView ? BOARD_RGHT-1 : BOARD_LEFT)) {
-       string[0] = ONE + row;
-       XTextExtents(coordFontStruct, string, 1, &direction,
+      }
+      if (column == (flipView ? BOARD_RGHT : BOARD_LEFT-1) && piece > 1) {
+       string[0] = '0' + piece;
+       XTextExtents(countFontStruct, string, 1, &direction,
                     &font_ascent, &font_descent, &overall);
        if (appData.monoMode) {
-           XDrawImageString(xDisplay, xBoardWindow, coordGC,
-                            x + 2, y + font_ascent + 1, string, 1);
+         XDrawImageString(xDisplay, xBoardWindow, countGC,
+                          x + 2, y + font_ascent + 1, string, 1);
        } else {
-           XDrawString(xDisplay, xBoardWindow, coordGC,
-                       x + 2, y + font_ascent + 1, string, 1);
+         XDrawString(xDisplay, xBoardWindow, countGC,
+                     x + 2, y + font_ascent + 1, string, 1);
        }
+      }
+    } else {
+      if (piece == EmptySquare || appData.blindfold) {
+       BlankSquare(x, y, square_color, piece, xBoardWindow);
+      } else {
+       drawfunc = ChooseDrawFunc();
+       if (do_flash && appData.flashCount > 0) {
+         for (i=0; i<appData.flashCount; ++i) {
+           
+           drawfunc(piece, square_color, x, y, xBoardWindow);
+           XSync(xDisplay, False);
+           do_flash_delay(flash_delay);
+           
+           BlankSquare(x, y, square_color, piece, xBoardWindow);
+           XSync(xDisplay, False);
+           do_flash_delay(flash_delay);
+         }
+       }
+       drawfunc(piece, square_color, x, y, xBoardWindow);
+      }
+    }
+    
+    string[1] = NULLCHAR;
+    if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0)
+       && column >= BOARD_LEFT && column < BOARD_RGHT) {
+      string[0] = 'a' + column - BOARD_LEFT;
+      XTextExtents(coordFontStruct, string, 1, &direction,
+                  &font_ascent, &font_descent, &overall);
+      if (appData.monoMode) {
+       XDrawImageString(xDisplay, xBoardWindow, coordGC,
+                        x + squareSize - overall.width - 2,
+                        y + squareSize - font_descent - 1, string, 1);
+      } else {
+       XDrawString(xDisplay, xBoardWindow, coordGC,
+                   x + squareSize - overall.width - 2,
+                   y + squareSize - font_descent - 1, string, 1);
+      }
+    }
+    if (appData.showCoords && column == (flipView ? BOARD_RGHT-1 : BOARD_LEFT)) {
+      string[0] = ONE + row;
+      XTextExtents(coordFontStruct, string, 1, &direction,
+                  &font_ascent, &font_descent, &overall);
+      if (appData.monoMode) {
+       XDrawImageString(xDisplay, xBoardWindow, coordGC,
+                        x + 2, y + font_ascent + 1, string, 1);
+      } else {
+       XDrawString(xDisplay, xBoardWindow, coordGC,
+                   x + 2, y + font_ascent + 1, string, 1);
+      }
     }
 }
 
@@ -4549,7 +4541,7 @@ void DrawPosition( repaint, board)
     Arg args[16];
     int rrow, rcol;
 
-    printf ("DEBUG: in draw position\n");
+    printf ("DEBUG::DrawPosition: start\n");
 
 
     if (board == NULL) {
@@ -4567,12 +4559,13 @@ void DrawPosition( repaint, board)
      * but this causes a very distracting flicker.
      */
 
-    printf ("DEBUG: in draw position 0.1\n");
+    printf ("DEBUG::DrawPosition: in draw position 0.1\n");
+    printf("DEBUG::DrawPosition: squareSize %d\n",squareSize);
 
 
     if (!repaint && lastBoardValid && lastFlipView == flipView) {
 
-    printf ("DEBUG: in draw position 0.1a\n");
+    printf ("DEBUG::DrawPosition: in draw position 0.1a\n");
        /* If too much changes (begin observing new game, etc.), don't
           do flashing */
        do_flash = too_many_diffs(board, lastBoard) ? 0 : 1;
@@ -4605,6 +4598,7 @@ void DrawPosition( repaint, board)
                DrawSquare(i, j, board[i][j], do_flash);
            }
     } else {
+      printf("DEBUG::DrawPosition: in else linegap %d squareSize %d\n",lineGap,squareSize);
        if (lineGap > 0)
           {
             /* todo move GC to setupgc */
@@ -4626,9 +4620,11 @@ void DrawPosition( repaint, board)
             gdk_draw_segments(GUI_Board->window,gtklineGC,
                               gridSegments, BOARD_HEIGHT + BOARD_WIDTH + 2 );
           }
-
+       
+       squareSize=108;
        for (i = 0; i < BOARD_HEIGHT; i++)
          for (j = 0; j < BOARD_WIDTH; j++) {
+           printf("DEBUG::DrawPosition: squareSize %d\n",squareSize);
              DrawSquare(i, j, board[i][j], 0);
              damage[i][j] = False;
          }