home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuch40.zip / gnuchess-4.0.pl79 / src / nondsp.c < prev    next >
C/C++ Source or Header  |  1998-09-28  |  19KB  |  820 lines

  1. /*
  2.  * nondsp.c - UNIX & MSDOS NON-DISPLAY, AND CHESSTOOL interface for Chess
  3.  *
  4.  * Copyright (c) 1985-1996 Stuart Cracraft, John Stanback,
  5.  *                         Daryl Baker, Conor McCarthy,
  6.  *                         Mike McGann, Chua Kong Sian
  7.  * Copyright (c) 1985-1996 Free Software Foundation
  8.  *
  9.  * This file is part of GNU CHESS.
  10.  *
  11.  * GNU Chess is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2, or (at your option)
  14.  * any later version.
  15.  *
  16.  * GNU Chess is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with GNU Chess; see the file COPYING.  If not, write to
  23.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25. #include "gnuchess.h"
  26. #include "ttable.h"  /* calls ShowHashStats() to display stats; move to main.c? */
  27. #include <signal.h>
  28.  
  29. #ifdef MSDOS
  30. #include <dos.h>
  31. #elif !defined(Think_C) && !defined(WIN32)
  32. #include <sys/file.h>
  33. #ifndef AMIGADOS
  34. #include <sys/ioctl.h>
  35. #endif
  36.  
  37. void TerminateSearch (int), Die (int);
  38.  
  39. #endif /* MSDOS */
  40.  
  41.  
  42. #ifdef DEBUG
  43. SHORT debuglevel = 0;
  44.  
  45. #endif /* DEBUG */
  46. UTSHORT MV[MAXDEPTH+1];
  47. int MSCORE;
  48.  
  49. #if defined CHESSTOOL || defined XBOARD
  50. SHORT chesstool = 1;
  51.  
  52. #else
  53. SHORT chesstool = 0;
  54.  
  55. #endif /* CHESSTOOL */
  56. int mycnt1, mycnt2;
  57. CHAR *DRAW;
  58. extern CHAR *InPtr;
  59. extern SHORT pscore[];
  60.  
  61. void
  62. Initialize (void)
  63. {
  64.   mycnt1 = mycnt2 = 0;
  65. #if defined CHESSTOOL || defined XBOARD
  66. #if defined(HAVE_SETVBUF)  ||  defined(AMIGADOS)
  67.   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  68. #elif defined(HAVE_SETLINEBUF)
  69.   setlinebuf (stdout);
  70. #else
  71.   setbuf(stdout, NULL);
  72. #endif
  73.   printf (CP[43]);        /*Chess*/
  74.   if (!TCflag && (MaxResponseTime == 0))
  75.     MaxResponseTime = 15L*100L;
  76. #endif /* CHESSTOOL */
  77. }
  78.  
  79. void
  80. ExitChess (void)
  81. {
  82.   signal (SIGTERM, SIG_IGN);
  83.   if(flag.autolist)ListGame ();
  84.   exit (0);
  85. }
  86.  
  87. #ifndef MSDOS            /* never called!!! */
  88. void
  89. Die (int sig)
  90. {
  91.   CHAR s[80];
  92.  
  93.   ShowMessage (CP[31]);        /*Abort?*/
  94.   scanz ("%s", s);
  95.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  96.     ExitChess ();
  97. }
  98.  
  99. #endif /* MSDOS */
  100.  
  101. void
  102. TerminateSearch (int sig)
  103. {
  104. #ifdef MSDOS
  105.   sig++;            /* shut up the compiler */
  106. #endif /* MSDOS */
  107.   if (!flag.timeout)
  108.     flag.back = true;
  109.   flag.bothsides = false;
  110. }
  111.  
  112.  
  113. void
  114. help (void)
  115. {
  116.   ClrScreen ();
  117.   /*printz ("CHESS command summary\n");*/
  118.   printz (CP[40]);
  119.   printz ("----------------------------------------------------------------\n");
  120.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  121.   printz (CP[158]);
  122. #ifdef DEBUG
  123.   /*printz ("Nf3       move knight to f3       cache      turn %s\n", (!flag.nocache) ? "off" : "on");*/
  124.   printz (CP[86], (!flag.nocache) ? CP[92] : CP[93]);
  125. #endif
  126.   /*printz ("a7a8q     promote pawn to queen\n");*/
  127.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  128.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  129.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  130.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  131.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  132.   /*printz ("bd        redraw board            reverse   board display\n");*/
  133.   printz (CP[130]);
  134.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount);*/
  135.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount,booksize);
  136.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  137.   printz (CP[200]);
  138.   /*printz ("edit      edit board              force     enter game moves\n");*/
  139.   printz (CP[153]);
  140.   /*printz ("switch    sides with computer     both      computer match\n");*/
  141.   printz (CP[194]);
  142.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  143.   printz (CP[202]);
  144.   /*printz ("depth     set search depth        clock     set time control\n");*/
  145.   printz (CP[149]);
  146.   /*printz ("post      principle variation     hint      suggest a move\n");*/
  147.   printz (CP[177],(flag.post) ? CP[93] : CP[92]);
  148.   /*printz ("save      game to file            get       game from file\n");*/
  149.   printz (CP[188]);
  150.   /*printz ("random    randomize play          new       start new game\n");*/
  151.   printz (CP[181]);
  152.   printz ("----------------------------------------------------------------\n");
  153.   /*printz ("Computer: %-12s Opponent:            %s\n",*/
  154.   printz (CP[46],
  155.       ColorStr[computer], ColorStr[opponent]);
  156.   /*printz ("Depth:    %-12d Response time:       %d sec\n",*/
  157.   printz (CP[51],
  158.       MaxSearchDepth, MaxResponseTime/100);
  159.   /*printz ("Random:   %-12s Easy mode:           %s\n",*/
  160.   printz (CP[99],
  161.       (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
  162.   /*printz ("Beep:     %-12s Transposition file: %s\n",*/
  163.   printz (CP[36],
  164.       (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
  165.   /*printz ("Time Control %s %d moves %d seconds %d opr %d depth\n", (TCflag) ? "ON" : "OFF",*/
  166. if(flag.gamein)
  167.   printz (CP[230], (TCflag) ? CP[93] : CP[92],
  168.        TimeControl.clock[white] / 100, TCadd/100, MaxSearchDepth);
  169. else
  170.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  171.       TimeControl.moves[white], TimeControl.clock[white] / 100, TCadd/100, MaxSearchDepth);
  172. #if !defined CHESSTOOL
  173.   signal (SIGINT, TerminateSearch);
  174. #endif
  175. #if !defined(MSDOS) && !defined(WIN32)
  176.   signal (SIGQUIT, TerminateSearch);
  177. #endif /* MSDOS */
  178. }
  179.  
  180. void
  181. EditBoard (void)
  182.  
  183. /*
  184.  * Set up a board position. Pieces are entered by typing the piece followed
  185.  * by the location. For example, Nf3 will place a knight on square f3.
  186.  */
  187.  
  188. {
  189.   SHORT a, r, c, sq, i, found;
  190.   CHAR s[80];
  191.  
  192.   flag.regularstart = true;
  193.   Book = BOOKFAIL;
  194.   ClrScreen ();
  195.   UpdateDisplay (0, 0, 1, 0);
  196.   /*printz (".   exit to main\n");*/
  197.   printz (CP[29]);
  198.   /*printz ("#   clear board\n");*/
  199.   printz (CP[28]);
  200.   /*printz ("c   change sides\n");*/
  201.   printz (CP[136]);
  202.   /*printz ("enter piece & location: \n");*/
  203.   printz (CP[155]);
  204.  
  205.   a = white;
  206.   do
  207.     {
  208.       scanz ("%s", s);
  209.       found=0;
  210.       if (s[0] == CP[28][0])    /*#*/
  211.     for (sq = 0; sq < 64; sq++)
  212.       {
  213.         board[sq] = no_piece;
  214.         color[sq] = neutral;
  215.             Mvboard[sq]=0;
  216.       }
  217.       else if (s[0] == CP[136][0])    /*c*/
  218.     a = otherside[a];
  219.       else if (s[0] == CP[5][0])    /*o-o*/
  220.     Mvboard[(a==white)?7:63] = !Mvboard[(a==white)?7:63]; 
  221.       else if (s[0] == CP[6][0])    /*o-o-o*/
  222.     Mvboard[(a==white)?0:56] = !Mvboard[(a==white)?0:56];
  223.       else {
  224.       c = s[1] - 'a';
  225.       r = s[2] - '1';
  226.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  227.     {
  228.       sq = locn (r, c);
  229.       color[sq] = a;
  230.       board[sq] = no_piece;
  231.       for (i = no_piece; i <= king; i++)
  232.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  233.           {
  234.         board[sq] = i;
  235.         found=1;
  236.         break;
  237.           }
  238.       if (found==0) color[sq] = neutral;    
  239.     }
  240.     }
  241.   } while (s[0] != CP[29][0]);
  242.   GameCnt = 0;
  243.   Game50 = 1;
  244.   ZeroRPT ();
  245.   Sdepth = 0;
  246.   InitializeStats ();
  247.   ClrScreen ();
  248.   UpdateDisplay (0, 0, 1, 0);
  249. }
  250.  
  251. void
  252. SetupBoard (void)
  253.  
  254. /*
  255.  * Compatibility with Unix chess and the nchesstool. Set up a board position.
  256.  * Eight lines of eight characters are used to setup the board. a8-h8 is the
  257.  * first line. Black pieces are  represented  by  uppercase characters.
  258.  */
  259.  
  260. {
  261.   SHORT r, c, sq, i;
  262.   CHAR ch;
  263.   CHAR s[80];
  264.  
  265.   NewGame ();
  266.  
  267.   gets (s);            /* skip "setup" command */
  268.   for (r = 7; r >= 0; r--)
  269.     {
  270.       gets (s);
  271.       for (c = 0; c <= 7; c++)
  272.     {
  273.       ch = s[c];
  274.       sq = locn (r, c);
  275.       color[sq] = neutral;
  276.       board[sq] = no_piece;
  277.       for (i = no_piece; i <= king; i++)
  278.         if (ch == pxx[i])
  279.           {
  280.         color[sq] = black;
  281.         board[sq] = i;
  282.         break;
  283.           }
  284.         else if (ch == qxx[i])
  285.           {
  286.         color[sq] = white;
  287.         board[sq] = i;
  288.         break;
  289.           }
  290.     }
  291.     }
  292.   for (sq = 0; sq < 64; sq++)
  293.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  294.   InitializeStats ();
  295.   ClrScreen ();
  296.   UpdateDisplay (0, 0, 1, 0);
  297.   /*printz ("Setup successful\n");*/
  298.   printz (CP[106]);
  299. }
  300.  
  301. void
  302. ShowDepth (CHAR ch)
  303. {
  304. #ifdef MSDOS
  305.   ch++;                /* shut up the compiler */
  306. #endif /* MSDOS */
  307. }
  308.  
  309.  
  310. void
  311. ShowLine (UTSHORT *bstline)
  312. {
  313.   register int i;
  314.  
  315.   for (i = 1; bstline[i] > 0; i++)
  316.     {
  317.       if ((i > 1) && (i % 8 == 1))
  318.     printf ("\n                          ");
  319.       algbr ((SHORT) (bstline[i] >> 8), (SHORT) (bstline[i] & 0xFF), false);
  320.       printf ("%5s ", mvstr[0]);
  321.     }
  322.   printf ("\n");
  323. }
  324.  
  325. void
  326. ShowResults (SHORT score, UTSHORT *bstline, CHAR ch)
  327. {
  328. #if !defined CHESSTOOL
  329.   if (flag.post)
  330.     {
  331.       ElapsedTime (2);
  332.       printf ("%2d%c %6d %4ld %8ld  ", Sdepth, ch, score, et / 100, NodeCnt);
  333.       ShowLine (bstline);
  334.     }
  335. #else
  336.   register int i;
  337.  
  338.   MSCORE = score;
  339.   MV[30] = ch;
  340.   for (i = 1; bstline[i] > 0; i++)
  341.     {
  342.       MV[i] = bstline[i];
  343.     } MV[i] = 0;
  344. #endif /* CHESSTOOL */
  345. }
  346.  
  347. void
  348. SearchStartStuff (SHORT side)
  349. {
  350.   signal (SIGINT, TerminateSearch);
  351. #if !defined(MSDOS) && !defined(WIN32)
  352.   signal (SIGQUIT, TerminateSearch);
  353. #endif /* MSDOS */
  354. #if !defined CHESSTOOL
  355.   if (flag.post)
  356.     {
  357.       printf (CP[123],
  358.            GameCnt/2+1,
  359.            ResponseTime, TimeControl.clock[side]);
  360.     }
  361. #endif /* CHESSTOOL */
  362. }
  363. void
  364. OutputMove (SHORT score)
  365. {
  366. #ifdef DEBUG11
  367.   extern UTSHORT PrVar[];
  368.   if (1)
  369.     {
  370.       FILE *D;
  371.       CHAR d[80];
  372.       int r, c, l, i;
  373.       D = fopen ("DEBUGA", "a+");
  374.       fprintf (D, "inout move is %s\n", mvstr[0]);
  375.       strcpy (d, mvstr[0]);
  376.       for (i = 1; PrVar[i] > 0; i++)
  377.     {
  378.       algbr ((SHORT) (PrVar[i] >> 8), (SHORT) (PrVar[i] & 0xFF), false);
  379.       fprintf (D, "%5s ", mvstr[0]);
  380.     }
  381.       fprintf (D, "\n");
  382.  
  383.       fprintf (D, "\n current board is\n");
  384.       for (r = 7; r >= 0; r--)
  385.     {
  386.       for (c = 0; c <= 7; c++)
  387.         {
  388.           l = locn (r, c);
  389.           if (color[l] == neutral)
  390.         fprintf (D, " -");
  391.           else if (color[l] == white)
  392.         fprintf (D, " %c", qxx[board[l]]);
  393.           else
  394.         fprintf (D, " %c", pxx[board[l]]);
  395.         }
  396.       fprintf (D, "\n");
  397.     }
  398.       fprintf (D, "\n");
  399.       fclose (D);
  400.       strcpy (mvstr[0], d);
  401.     }
  402. #endif
  403. if(flag.illegal){printf("%s\n",CP[225]);return;}
  404. if (mvstr[0][0] == '\0') goto nomove;
  405. #ifdef CLIENT
  406. if(mvstr[0][4] != '\0' && mvstr[0][4] != 'o'){mvstr[0][5]=toupper(mvstr[0][4]);mvstr[0][4]='=';mvstr[0][6]='\0';}
  407. #endif
  408. #if defined CHESSTOOL
  409.   if (computer == black)
  410.     printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  411.   else
  412.     printz ("%d. %s\n", ++mycnt1, mvstr[0]);
  413. #else
  414. #ifdef SHOWLINE
  415.   printz ("%d. ... %s %d ", ++mycnt1, mvstr[0],score);
  416.   ShowLine(PrVar);
  417.   printz ("\n");
  418. #else
  419.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  420. #endif
  421. #endif /* CHESSTOOL */
  422. nomove:
  423.   if ((root->flags & (draw)) || flag.mate) goto summary;
  424. #ifndef BAREBONES
  425.   if (flag.post)
  426.     {
  427.       SHORT h, l, t;
  428.  
  429.       h = TREE;
  430.       l = 0;
  431.       t = TREE >> 1;
  432.       while (l != t)
  433.     {
  434.       if (Tree[t].f || Tree[t].t)
  435.         l = t;
  436.       else
  437.         h = t;
  438.       t = (l + h) >> 1;
  439.     }
  440. #if defined MORESTATS
  441.        ShowHashStats();
  442. #endif
  443. #if !defined HASHSTATS
  444.       /*printf ("Nodes %ld Tree %d Eval %ld Rate %ld RS high %ld low %ld\n",*/
  445.       printf (CP[89],GenCnt,NodeCnt,t,EvalNodes,(et>100)?(NodeCnt/(et/100)):0,0,0,reminus,replus);
  446. #else
  447.       printf (CP[89],GenCnt,NodeCnt,t,EvalNodes,(et>100)?(NodeCnt/(et/100)):0,EADD,EGET,reminus,replus);
  448.       /*printf ("Hin/Hout/Coll/Fin/Fout = %ld/%ld/%ld/%ld/%ld\n",*/
  449.       printf (CP[71],
  450.            HashAdd, HashCnt, THashCol, HashCol,FHashCnt, FHashAdd);
  451. #endif
  452.     }
  453.   UpdateDisplay (root->f, root->t, 0, root->flags);
  454.   /*printf ("My move is: %s\n", mvstr[0]);*/
  455. #if !defined CHESSTOOL
  456.   printf (CP[83], mvstr[0]);
  457. #endif
  458. /*  if (flag.beep) printz ("%c", 7); */
  459. #endif /* BAREBONES */
  460.  summary:
  461.   if (root->flags & draw)
  462.     /*    printf ("Drawn game!\n");*/
  463.     printf (CP[57]);
  464.   else if(flag.mate){
  465.     if (root->score == -9999)
  466.             printf("%s mates!\n",ColorStr[opponent]);
  467.       else if (root->score == 9998)
  468.             printf("%s mates!\n",ColorStr[computer]);
  469.     }
  470. #if !defined CHESSTOOL && !defined XBOARD
  471. #ifdef VERYBUGGY
  472.   else if (root->score < -9000)
  473.     printf("%s has a forced mate!\n",ColorStr[opponent]);
  474.   else if (root->score > 9000)
  475.     printf("%s has a forced mate!\n",ColorStr[computer]);
  476. #endif /*VERYBUGGY*/
  477. #endif /* CHESSTOOL */
  478. }
  479.  
  480. void
  481. ClrScreen (void)
  482. {
  483. #if !defined CHESSTOOL && !defined XBOARD
  484.   printz ("\n");
  485. #endif
  486. }
  487.  
  488. void
  489. UpdateDisplay (SHORT f, SHORT t, SHORT redraw, SHORT isspec)
  490. {
  491.  
  492.   SHORT r, c, l, m;
  493.  
  494.   if (redraw && !chesstool)
  495.     {
  496.       printz ("\n");
  497.       r = (SHORT)(TimeControl.clock[white] / 6000);
  498.       c = (SHORT)((TimeControl.clock[white] % 6000) / 100);
  499.       l = (SHORT)(TimeControl.clock[black] / 6000);
  500.       m = (SHORT)((TimeControl.clock[black] % 6000) / 100);
  501.       /*printz ("White %d:%02d  Black %d:%02d\n", r, c, l, m);*/
  502.       printz (CP[116], r, c, l, m);
  503.       printz ("\n");
  504.       for (r = 7; r >= 0; r--)
  505.     {
  506.       for (c = 0; c <= 7; c++)
  507.         {
  508.           l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  509.           if (color[l] == neutral)
  510.         printz (" -");
  511.           else if (color[l] == white)
  512.         printz (" %c", qxx[board[l]]);
  513.           else
  514.         printz (" %c", pxx[board[l]]);
  515.         }
  516.       printz ("\n");
  517.     }
  518.       printz ("\n");
  519.     }
  520. }
  521.  
  522. void
  523. skip ()
  524. {
  525.   while (*InPtr != ' ')
  526.     InPtr++;
  527.   while (*InPtr == ' ')
  528.     InPtr++;
  529. }
  530. void
  531. skipb ()
  532. {
  533.   while (*InPtr == ' ')
  534.     InPtr++;
  535. }
  536.  
  537. void
  538. ShowMessage (CHAR *s)
  539. {
  540.   printf("%s\n", s);
  541. }
  542.  
  543. void
  544. ShowSidetoMove (void)
  545. {
  546. }
  547.  
  548. void
  549. PromptForMove (void)
  550. {
  551. #if !defined CHESSTOOL && !defined XBOARD
  552.   /*printz ("\nYour move is? ");*/
  553.   printz (CP[124]);
  554. #endif /* CHESSTOOL */
  555. }
  556.  
  557.  
  558. void
  559. ShowCurrentMove (SHORT pnt, SHORT f, SHORT t)
  560. {
  561.   f++;
  562. #ifdef MSDOS
  563.   f++;
  564.   t++;
  565.   pnt++;            /* shut up the compiler */
  566. #endif /* MSDOS */
  567. }
  568.  
  569. void
  570. ChangeAlphaWindow (void)
  571. {
  572.   printz ("WAwindow: ");
  573.   scanz ("%hd", &WAwindow);
  574.   printz ("BAwindow: ");
  575.   scanz ("%hd", &BAwindow);
  576. }
  577.  
  578. void
  579. ChangeBetaWindow (void)
  580. {
  581.   printz ("WBwindow: ");
  582.   scanz ("%hd", &WBwindow);
  583.   printz ("BBwindow: ");
  584.   scanz ("%hd", &BBwindow);
  585. }
  586.  
  587. void
  588. GiveHint (void)
  589. {
  590.   if (hint)
  591.     {
  592.       algbr ((SHORT) (hint >> 8), (SHORT) (hint & 0xFF), false);
  593.       printf(CP[72], mvstr[0]);    /*hint*/
  594.     }
  595.   else
  596.     printz (CP[223]);
  597. }
  598.  
  599.  
  600. void
  601. SelectLevel (CHAR *sx)
  602. {
  603.  
  604.   CHAR T[64], *p, *q;
  605.  
  606.   XC = XCmore =0;
  607.  
  608.   if ((p = strstr (sx, CP[169])) != NULL) p += strlen (CP[169]);
  609.   else if ((p = strstr (sx, CP[217])) != NULL) p += strlen (CP[217]);
  610.   strcat (sx, "XX");
  611.   q = T;
  612.   *q = '\0';
  613.   for (; *p != 'X'; *q++ = *p++);
  614.   *q = '\0';
  615.   /* line empty ask for input */
  616.   while(true){
  617.   if (!T[0])
  618.     {
  619.       printz (CP[61]);
  620.       gets (T);
  621.     }
  622.   strcat (T, "XX");
  623.   /* skip whitespace */
  624.   for (p = T; *p == ' '; p++);
  625.   /*
  626.   Input forms are:
  627.              M    m[:s]        - M moves in m:s time
  628.           m[:s]   t    - game in m:s time increment t
  629.           m:[s]        - game in m:s time
  630.              M    m[:s]      t    - for M moves m:s time increment t then reset
  631.   */
  632.   /* could be moves or a incremental clock */
  633.       TCminutes = TCmoves = TCseconds =  TCadd = 0;
  634.       TCmoves = (SHORT) strtol (p, &q, 10);
  635.       if (*q == ':')
  636.     { /* its gamein form: m:s  or m:s t */
  637.       TCminutes = TCmoves;
  638.       TCmoves = 0;
  639.       if(*(q+1) != ' ') TCseconds = (SHORT) strtol (q + 1, &q, 10); else {q++; }
  640.       if(*q != 'X' && *q != '+'){
  641.         TCadd = (SHORT) strtol (q, &q, 10) * 100;
  642.         }
  643.     }
  644.       else
  645.     { /* m or m t or M m t*/
  646.       while (*q == ' ') q++;
  647.       if (*q == 'X' || *q == '+')
  648.         { /*  m only 1 number must be gamein */
  649.           TCminutes = TCmoves;
  650.           TCmoves = 0;
  651.         }
  652.       else
  653.         { /* M m or M m[:s] t */
  654.           TCminutes = (SHORT) strtol (q, &q, 10);
  655.           if (*q == ':')
  656.         { /* M m[:s] t */
  657.               if(*(q+1) != ' ') TCseconds = (SHORT) strtol (q + 1, &q, 10); else {q++; }
  658.           TCadd = (SHORT) strtol (q, &q, 10);
  659.         }else{/* M m or M m t */
  660.           if(*q != 'X' && *q != '+')/* its M m t*/ TCadd = (SHORT) strtol (q, &q, 10)*100;
  661.                  }
  662.          }
  663.     }
  664.     while(*q == ' ')q++;
  665.     XCmoves[XC] = TCmoves;
  666.     XCminutes[XC] = TCminutes;
  667.     XCseconds[XC] = TCseconds;
  668.     XCadd[XC] = TCadd;
  669.     XC++;
  670.     if(*q != '+' || XC == 3) break;
  671.     T[0]='\0';
  672.     }
  673.   TimeControl.clock[white] = TimeControl.clock[black] = 0;
  674.   SetTimeControl ();
  675.   if (TCmoves == 1)
  676.     {
  677.       TCflag = false;
  678.       MaxResponseTime = 6000L * TCminutes + 100 * TCseconds;
  679.     }
  680. }
  681.  
  682. #ifdef DEBUG
  683. void
  684. ChangeDbLev (void)
  685. {
  686.   printz (CP[146]);
  687. #ifdef USEINT
  688.   scanz ("%d", &debuglevel);
  689. #else
  690.   scanz ("%hd", &debuglevel);
  691. #endif
  692. printf("%d\n",debuglevel);
  693. }
  694.  
  695. #endif /* DEBUG */
  696.  
  697. void
  698. ChangeSearchDepth (void)
  699. {
  700.   printz ("depth= ");
  701. #ifdef USEINT
  702.   scanz ("%d", &MaxSearchDepth);
  703. #else
  704.   scanz ("%hd", &MaxSearchDepth);
  705. #endif
  706.   TCflag = !(MaxSearchDepth > 0);
  707. }
  708.  
  709. void
  710. ChangeHashDepth (void)
  711. {
  712.   printz ("hashdepth= ");
  713.   scanz ("%hd", &HashDepth);
  714.   printz ("MoveLimit= ");
  715.   scanz ("%hd", &HashMoveLimit);
  716. }
  717.  
  718. void
  719. SetContempt (void)
  720. {
  721.   printz ("contempt= ");
  722.   scanz ("%hd", &contempt);
  723. }
  724.  
  725. void
  726. ChangeXwindow (void)
  727. {
  728.   printz ("xwndw= ");
  729.   scanz ("%hd", &xwndw);
  730. }
  731.  
  732. void
  733. ShowPostnValue (SHORT sq)
  734.  
  735. /*
  736.  * must have called ExaminePosition() first
  737.  */
  738.  
  739. {
  740. /*  SHORT score; */
  741.   if (color[sq] != neutral){
  742.   /*  score = ScorePosition (color[sq]);*/
  743.     printz ("%3d%c ", svalue[sq],(color[sq] == black)?'b':'w');}
  744.   else
  745.     printz(" *   ");
  746. }
  747.  
  748. void
  749. DoDebug (void)
  750. {
  751.   SHORT c, p, sq, tp, tc, tsq, score,j,k;
  752.   CHAR s[40];
  753.  
  754.   ExaminePosition ();
  755.   ShowMessage (CP[65]);
  756.   scanz ("%s", s);
  757.   c = neutral;
  758.   if (s[0] == CP[9][0] || s[0] == CP[9][1])     /* w W*/ c = white;
  759.   if (s[0] == CP[9][2] || s[0] == CP[9][3])     /*b B*/ c = black;
  760.   for (p = king; p > no_piece; p--)
  761.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  762.   if(p > no_piece)
  763.   for(j=7;j>=0;j--){
  764.   for(k=0;k<8;k++){
  765.       sq=j*8+k;
  766.       tp = board[sq];
  767.       tc = color[sq];
  768.       board[sq] = p;
  769.       color[sq] = c;
  770.       tsq = PieceList[c][1];
  771.       PieceList[c][1] = sq;
  772.       ShowPostnValue (sq);
  773.       PieceList[c][1] = tsq;
  774.       board[sq] = tp;
  775.       color[sq] = tc;
  776.     }
  777.       printz("\n");
  778.     }
  779.   score = ScorePosition (opponent);
  780.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  781. }
  782.  
  783. void
  784. DoTable (SHORT table[64])
  785. {
  786.   SHORT  sq,j,k;
  787.   ExaminePosition ();
  788.   for(j=7;j>=0;j--){
  789.   for(k=0;k<8;k++){
  790.     sq=j*8+k;
  791.     printz ("%3d ", table[sq]);
  792.   }
  793. printz("\n");
  794. }
  795. }
  796.  
  797. void
  798. ShowPostnValues (void)
  799. {
  800.   SHORT sq, score,j,k;
  801.   ExaminePosition ();
  802.   score = ScorePosition (white);
  803.   for(j=7;j>=0;j--){
  804.   for(k=0;k<8;k++){
  805.   sq=j*8+k;
  806.     ShowPostnValue (sq);
  807.   }
  808.     printz("\n");
  809.   }
  810. /*  score = ScorePosition (opponent); */
  811.  printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  812.  printz("\nhung white %d hung black %d\n",hung[white],hung[black]);
  813. }
  814. void Ldisplay1(){printf("\n"); }
  815. void Ldisplay2(){printf("\n"); }
  816. void Ldisplay3(){printf("\n"); }
  817.  
  818. void Ldisplay(char *m, char *h,SHORT count) { printf("\t%s\t%s\t%d\n",m,h,count); }
  819. void Ldisplay4(char *line) { printf("%s",line); }
  820.