home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / ArcBoard004.arc / !GNUChessX / src / c / nondsp < prev    next >
Text File  |  1996-01-10  |  19KB  |  821 lines

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