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