home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuch40.zip / gnuchess-4.0.pl79 / src / uxdsp.c < prev    next >
C/C++ Source or Header  |  1999-01-16  |  21KB  |  920 lines

  1. /*
  2.  * uxdsp.c - ALPHA 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 <ctype.h>
  27. #include <signal.h>
  28. #ifdef MSDOS
  29. #include <dos.h>
  30. /*#include <conio.h>*/
  31. #include <stdlib.h>
  32. #include <string.h>
  33.  
  34. #define ESC 0x1B
  35. #define refresh() fflush(stdout)
  36. static void param (SHORT n);
  37.  
  38. #else
  39. #include <sys/param.h>
  40. #include <sys/types.h>
  41. #include <sys/file.h>
  42. #ifdef DOSLIKE_ANSI_DISPLAY
  43. #define ESC 0x1B
  44. #define refresh() fflush(stdout)
  45. static void param (SHORT n);
  46. #else
  47. #include <curses.h>
  48. #endif
  49.  
  50. #endif /* MSDOS */
  51.  
  52. int mycnt1, mycnt2;
  53.  
  54. extern SHORT pscore[2];
  55.  
  56. #define TAB (46)
  57. #define VIR_C(s)  ((flag.reverse) ? 7-column(s) : column(s))
  58. #define VIR_R(s)  ((flag.reverse) ? 7-row(s) : row(s))
  59.  
  60. UTSHORT MV[MAXDEPTH+1];
  61. int MSCORE;
  62. CHAR *DRAW;
  63.  
  64. void TerminateSearch (int), Die (int);
  65.  
  66. void
  67. Initialize (void)
  68. {
  69.   signal (SIGINT, Die);
  70. #if !defined (MSDOS) && !defined (DOSLIKE_ANSI_DISPLAY)
  71.   signal (SIGQUIT, Die);
  72.   initscr ();
  73.   crmode ();
  74.   echo ();
  75. #else
  76.   mycnt1 = mycnt2 = 0;
  77. #endif /* MSDOS */
  78. }
  79.  
  80. void
  81. ExitChess (void)
  82. {
  83.   ListGame ();
  84.   gotoXY (1, 24);
  85. #if !defined (MSDOS) && !defined (DOSLIKE_ANSI_DISPLAY)
  86.   refresh();
  87.   nocrmode ();
  88.   endwin ();
  89. #endif /* MSDOS */
  90.   exit (0);
  91. }
  92.  
  93. void
  94. Die (int Sig)
  95. {
  96.   CHAR s[80];
  97.  
  98.   signal (SIGINT, SIG_IGN);
  99. #ifdef MSDOS
  100.   Sig++;            /* shut up the compiler */
  101. #else
  102.   signal (SIGQUIT, SIG_IGN);
  103. #endif /* MSDOS */
  104.   ShowMessage (CP[31]);        /*Abort?*/
  105.   scanz ("%s", s);
  106.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  107.     ExitChess ();
  108.   signal (SIGINT, Die);
  109. #ifndef MSDOS
  110.   signal (SIGQUIT, Die);
  111. #endif /* MSDOS */
  112. }
  113.  
  114. void
  115. TerminateSearch (int Sig)
  116. {
  117.   signal (SIGINT, SIG_IGN);
  118. #ifdef MSDOS
  119.   Sig++;            /* shut up the compiler */
  120. #else
  121.   signal (SIGQUIT, SIG_IGN);
  122. #endif /* MSDOS */
  123.   if (!flag.timeout)
  124.     flag.musttimeout = true;
  125.   flag.bothsides = false;
  126.   signal (SIGINT, Die);
  127. #ifndef MSDOS
  128.   signal (SIGQUIT, Die);
  129. #endif /* MSDOS */
  130. }
  131. void
  132. ShowLine (UTSHORT *bstline)
  133. {
  134. }
  135.  
  136. void
  137. help (void)
  138. {
  139.   ClrScreen ();
  140.   /*printz ("CHESS command summary\n");*/
  141.   printz (CP[40]);
  142.   printz ("----------------------------------------------------------------\n");
  143.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  144.   printz (CP[158]);
  145. #ifdef DEBUG
  146.   /*printz ("Nf3       move knight to f3       cache      turn %s\n", (flag.cache) ? "off" : "on");*/
  147.   printz (CP[86], (!flag.nocache) ? CP[92] : CP[93]);
  148. #endif
  149.   /*printz ("a7a8q     promote pawn to queen\n");*/
  150.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  151.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  152.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  153.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  154.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  155.   /*printz ("bd        redraw board            reverse   board display\n");*/
  156.   printz (CP[130]);
  157.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", book
  158. count, booksize);*/
  159.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  160.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  161.   printz (CP[200]);
  162.   /*printz ("edit      edit board              force     enter game moves\n");*/
  163.   printz (CP[153]);
  164.   /*printz ("switch    sides with computer     both      computer match\n");*/
  165.   printz (CP[194]);
  166.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  167.   printz (CP[202]);
  168.   /*printz ("depth     set search depth        clock     set time control\n");*/
  169.   printz (CP[149]);
  170.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" :
  171. "on");*/
  172.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  173.   /*printz ("save      game to file            get       game from file\n");*/
  174.   printz (CP[188]);
  175.   /*printz ("random    randomize play          new       start new game\n");*/
  176.   printz (CP[181]);
  177.   gotoXY (10, 20);
  178.   printz (CP[47], ColorStr[computer]);
  179.   gotoXY (10, 21);
  180.   printz (CP[97], ColorStr[opponent]);
  181.   gotoXY (10, 22);
  182.   printz (CP[79], MaxResponseTime/100);
  183.   gotoXY (10, 23);
  184.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  185.   gotoXY (40, 20);
  186.   printz (CP[52], MaxSearchDepth);
  187.   gotoXY (40, 21);
  188.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  189.   gotoXY (40, 22);
  190.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  191.   gotoXY (40, 23);
  192.   printz (CP[73]);
  193.   gotoXY (10, 24);
  194. if(flag.gamein)
  195.   printz (CP[230], (TCflag) ? CP[93] : CP[92],
  196.            TimeControl.clock[white] / 100, TCadd/100, MaxSearchDepth);
  197. else
  198.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  199.           TimeControl.moves[white], TimeControl.clock[white] / 100, TCadd/100, MaxSearchDepth);
  200.   refresh ();
  201. #ifdef BOGUS
  202.   fflush (stdin); /*what is this supposed to do??*/
  203. #endif /*BOGUS*/
  204.   getchar ();
  205.   ClrScreen ();
  206.   UpdateDisplay (0, 0, 1, 0);
  207. }
  208.  
  209.  
  210. void
  211. EditBoard (void)
  212.  
  213. /*
  214.  * Set up a board position. Pieces are entered by typing the piece followed
  215.  * by the location. For example, Nf3 will place a knight on square f3.
  216.  */
  217.  
  218. {
  219.   SHORT a, r, c, sq, i;
  220.   CHAR s[80];
  221.  
  222.   flag.regularstart = true;
  223.   Book = BOOKFAIL;
  224.   ClrScreen ();
  225.   UpdateDisplay (0, 0, 1, 0);
  226.   gotoXY (TAB, 3);
  227.   printz (CP[29]);
  228.   gotoXY (TAB, 4);
  229.   printz (CP[28]);
  230.   gotoXY (TAB, 5);
  231.   printz (CP[136]);
  232.   gotoXY (TAB, 7);
  233.   printz (CP[64]);
  234.   a = white;
  235.   do
  236.     {
  237.       gotoXY (TAB, 6);
  238.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  239.       gotoXY (TAB + 24, 7);
  240.       ClrEoln ();
  241.       scanz ("%s", s);
  242.       if (s[0] == CP[28][0])    /*#*/
  243.     {
  244.       for (sq = 0; sq < 64; sq++)
  245.         {
  246.           board[sq] = no_piece;
  247.           color[sq] = neutral;
  248.           DrawPiece (sq);
  249.         }
  250.     }
  251.       if (s[0] == CP[136][0])    /*c*/
  252.     a = otherside[a];
  253.       c = s[1] - 'a';
  254.       r = s[2] - '1';
  255.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  256.     {
  257.       sq = locn (r, c);
  258.       for (i = king; i > no_piece; i--)
  259.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  260.           break;
  261.       board[sq] = i;
  262.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  263.       DrawPiece (sq);
  264.     }
  265.   } while (s[0] != CP[29][0]);    /*.*/
  266.  
  267.   for (sq = 0; sq < 64; sq++)
  268.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  269.   GameCnt = 0;
  270.   Game50 = 1;
  271.   ZeroRPT ();
  272.   Sdepth = 0;
  273.   InitializeStats ();
  274.   ClrScreen ();
  275.   UpdateDisplay (0, 0, 1, 0);
  276. }
  277.  
  278. void
  279. ShowPlayers (void)
  280. {
  281.   gotoXY (5, ((flag.reverse) ? 23 : 2));
  282.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  283.   gotoXY (5, ((flag.reverse) ? 2 : 23));
  284.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  285. }
  286.  
  287. void
  288. ShowDepth (CHAR ch)
  289. {
  290.   gotoXY (TAB, 4);
  291.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  292.   ClrEoln ();
  293. }
  294.  
  295. void
  296. ShowScore (SHORT score)
  297. {
  298.   gotoXY (TAB, 5);
  299.   printz (CP[104], score);
  300.   ClrEoln ();
  301. }
  302.  
  303. void
  304. ShowMessage (CHAR *s)
  305. {
  306.   gotoXY (TAB, 6);
  307.   printz ("%s", s);
  308.   ClrEoln ();
  309. }
  310.  
  311. void
  312. ClearMessage (void)
  313. {
  314.   gotoXY (TAB, 6);
  315.   ClrEoln ();
  316. }
  317.  
  318. void
  319. ShowCurrentMove (SHORT pnt, SHORT f, SHORT t)
  320. {
  321.   algbr (f, t, false);
  322.   gotoXY (TAB, 7);
  323.   printz ("(%2d) %4s", pnt, mvstr[0]);
  324. }
  325.  
  326. void
  327. ShowHeader (void)
  328. {
  329.   gotoXY (TAB, 2);
  330.   printz (CP[69]);
  331. }
  332.  
  333. void
  334. ShowSidetoMove (void)
  335. {
  336.   gotoXY (TAB, 14);
  337.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  338.   ClrEoln ();
  339. }
  340.  
  341. void
  342. ShowPrompt (void)
  343. {
  344.   gotoXY (TAB, 19);
  345.   printz (CP[121]);        /*Your movwe is?*/
  346.   ClrEoln ();
  347. }
  348.  
  349. void
  350. ShowNodeCnt (long int NodeCnt)
  351. {
  352.   gotoXY (TAB, 21);
  353.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  354.   ClrEoln ();
  355. }
  356.  
  357. void
  358. ShowResults (SHORT score, UTSHORT *bstline, CHAR ch)
  359. {
  360.   UCHAR d, ply;
  361.  
  362.   if (flag.post)
  363.     {
  364.       ShowDepth (ch);
  365.       ShowScore (score);
  366.       d = 7;
  367.       for (ply = 1; bstline[ply] > 0; ply++)
  368.     {
  369.       if (ply % 4 == 1)
  370.         {
  371.           gotoXY (TAB, ++d);
  372.           ClrEoln ();
  373.         }
  374.       algbr ((SHORT) bstline[ply] >> 8, (SHORT) bstline[ply] & 0xFF, false);
  375.       printz ("%5s ", mvstr[0]);
  376.     }
  377.       ClrEoln ();
  378.       while (d < 13)
  379.     {
  380.       gotoXY (TAB, ++d);
  381.       ClrEoln ();
  382.     }
  383.     }
  384. }
  385.  
  386. void
  387. SearchStartStuff (SHORT side)
  388. {
  389.   SHORT i;
  390.  
  391.   signal (SIGINT, TerminateSearch);
  392. #ifdef MSDOS
  393.   side++;            /* shut up the compiler */
  394. #else
  395.   signal (SIGQUIT, TerminateSearch);
  396. #endif /* MSDOS */
  397.   for (i = 4; i < 14; i++)
  398.     {
  399.       gotoXY (TAB, i);
  400.       ClrEoln ();
  401.     }
  402. }
  403.  
  404. void
  405. OutputMove (SHORT score)
  406. {
  407.  
  408.   UpdateDisplay (root->f, root->t, 0, (SHORT) root->flags);
  409.   gotoXY (TAB, 17);
  410.   if(flag.illegal){printz(CP[225]);return;}
  411.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  412.   if (flag.beep)
  413.     putchar (7);
  414.   ClrEoln ();
  415.  
  416.   gotoXY (TAB, 24);
  417.   if (root->flags & draw)
  418.     printz (CP[58]);
  419.   else if (root->score == -9999)
  420.     printz (CP[95]);
  421.   else if (root->score == 9998)
  422.     printz (CP[44]);
  423. #ifdef VERYBUGGY
  424.   else if (root->score < -9000)
  425.     printz (CP[96]);
  426.   else if (root->score > 9000)
  427.     printz (CP[45]);
  428. #endif /*VERYBUGGY*/
  429.   ClrEoln ();
  430.   if (flag.post)
  431.     {
  432.       register SHORT h, l, t;
  433.  
  434.       h = TREE;
  435.       l = 0;
  436.       t = TREE >> 1;
  437.       while (l != t)
  438.     {
  439.       if (Tree[t].f || Tree[t].t)
  440.         l = t;
  441.       else
  442.         h = t;
  443.       t = (l + h) >> 1;
  444.     }
  445.  
  446.       ShowNodeCnt (NodeCnt);
  447.       gotoXY (TAB, 22);
  448.       printz (CP[81], t);    /*Max Tree=*/
  449.       ClrEoln ();
  450.     }
  451.   ShowSidetoMove ();
  452. }
  453.  
  454. void
  455. UpdateClocks (void)
  456. {
  457.   SHORT m, s;
  458.  
  459.   m = (SHORT) (et / 6000);
  460.   s = (SHORT) (et - 6000 * (long) m) / 100;
  461.   if (TCflag)
  462.     {
  463.       m = (SHORT) ((TimeControl.clock[player] - et) / 6000);
  464.       s = (SHORT) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  465.     }
  466.   if (m < 0)
  467.     m = 0;
  468.   if (s < 0)
  469.     s = 0;
  470.   if (player == white)
  471.     gotoXY (20, (flag.reverse) ? 2 : 23);
  472.   else
  473.     gotoXY (20, (flag.reverse) ? 23 : 2);
  474.   printz ("%d:%02d   ", m, s);
  475.   if (flag.post)
  476.     ShowNodeCnt (NodeCnt);
  477.   refresh ();
  478. }
  479.  
  480. void
  481. gotoXY (SHORT x, SHORT y)
  482. {
  483. #if defined (MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)
  484.   putchar (ESC);
  485.   putchar ('[');
  486.   param (y);
  487.   putchar (';');
  488.   param (x);
  489.   putchar ('H');
  490. #else
  491.   move (y - 1, x - 1);
  492. #endif /* MSDOS */
  493. }
  494.  
  495. void
  496. ClrScreen (void)
  497. {
  498. #if defined (MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)
  499.   putchar (ESC);
  500.   putchar ('[');
  501.   putchar ('2');
  502.   putchar ('J');
  503. #else
  504.   clear ();
  505. #endif /* MSDOS */
  506.   refresh ();
  507. }
  508.  
  509. void
  510. ClrEoln (void)
  511. {
  512. #if defined (MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)
  513.   putchar (ESC);
  514.   putchar ('[');
  515.   putchar ('K');
  516. #else
  517.   clrtoeol ();
  518. #endif /* MSDOS */
  519.   refresh ();
  520. }
  521.  
  522. #if defined (MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)
  523. void
  524. param (SHORT n)
  525. {
  526.   if (n >= 10)
  527.     {
  528.       register SHORT d, q;
  529.  
  530.       q = n / 10;
  531.       d = n % 10;
  532.       putchar (q + '0');
  533.       putchar (d + '0');
  534.     }
  535.   else
  536.     putchar (n + '0');
  537. }
  538.  
  539. #endif /* MSDOS */
  540.  
  541. void
  542. DrawPiece (SHORT sq)
  543. {
  544.   register CHAR x;
  545.  
  546.   if (color[sq] == black)
  547. #if (defined(MSDOS) || defined(DOSLIKE_ANSI_DISPLAY)) && !defined(SEVENBIT)
  548.     x = '7';            /* print WHITE boldface, */
  549.   else
  550.     x = '1';            /* print BLACK inverted     */
  551.   gotoXY (6 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  552.   printz ("\033[%cm%c\033[0m", x, pxx[board[sq]]);
  553. #else
  554.     x = '*';
  555.   else
  556.     x = ' ';
  557.   gotoXY (5 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  558.   printz ("%c%c ", x, pxx[board[sq]]);
  559. #endif /* MSDOS && !SEVENBIT */
  560. }
  561.  
  562. void
  563. ShowPostnValue (SHORT sq)
  564.  
  565. /*
  566.  * must have called ExaminePosition() first
  567.  */
  568.  
  569. {
  570.   SHORT score;
  571.  
  572.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  573.   score = ScorePosition (color[sq]);
  574.   if (color[sq] != neutral)
  575.     printz ("%3d ", svalue[sq]);
  576.   else
  577.     printz ("   ");
  578. }
  579.  
  580. void
  581. ShowPostnValues (void)
  582. {
  583.   SHORT sq, score;
  584.  
  585.   ExaminePosition ();
  586.   for (sq = 0; sq < 64; sq++)
  587.     ShowPostnValue (sq);
  588.   score = ScorePosition (opponent);
  589.   gotoXY (TAB, 5);
  590.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  591.  
  592.   ClrEoln ();
  593. }
  594.  
  595. void
  596. UpdateDisplay (SHORT f, SHORT t, SHORT redraw, SHORT isspec)
  597. {
  598.   SHORT i, sq, z;
  599.  
  600.   if (redraw)
  601.     {
  602.       ShowHeader ();
  603.       ShowPlayers ();
  604.  
  605.       i = 3;
  606.       gotoXY (3, ++i);
  607. #if (defined(MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)) && !defined(SEVENBIT)
  608.       printz ("\332\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  609.         "\302\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  610.           "\302\304\304\304\304\302\304\304\304\304\277");
  611. #else
  612.       printz ("+----+----+----+----+----+----+----+----+");
  613. #endif /* MSDOS && !SEVENBIT */
  614.       while (i < 19)
  615.     {
  616.       gotoXY (1, ++i);
  617.       if (flag.reverse)
  618.         z = (i / 2) - 1;
  619.       else
  620.         z = 10 - (i / 2);
  621. #if (defined(MSDOS) || defined(DOSLIKE_ANSI_DISPLAY)) && !defined(SEVENBIT)
  622.       printz ("%d \263    \263    \263    \263    \263    \263    " \
  623.           "\263    \263    \263", z);
  624. #else
  625.       printz ("%d |    |    |    |    |    |    |    |    |", z);
  626. #endif /* MSDOS && !SEVENBIT */
  627.       gotoXY (3, ++i);
  628.       if (i < 19)
  629. #if (defined(MSDOS) || defined(DOSLIKE_ANSI_DISPLAY)) && !defined(SEVENBIT)
  630.         printz ("\303\304\304\304\304\305\304\304\304\304\305\304\304" \
  631.             "\304\304\305\304\304\304\304\305\304\304\304\304\305" \
  632.             "\304\304\304\304\305\304\304\304\304\305\304\304\304" \
  633.             "\304\264");
  634. #else
  635.         printz ("+----+----+----+----+----+----+----+----+");
  636. #endif /* MSDOS && !SEVENBIT */
  637.     }
  638. #if (defined(MSDOS) || defined(DOSLIKE_ANSI_DISPLAY)) && !defined(SEVENBIT)
  639.       printz ("\300\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  640.         "\301\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  641.           "\301\304\304\304\304\301\304\304\304\304\331");
  642. #else
  643.       printz ("+----+----+----+----+----+----+----+----+");
  644. #endif /* MSDOS && !SEVENBIT */
  645.       gotoXY (3, 21);
  646.       if (flag.reverse)
  647.     printz (CP[16]);
  648.       else
  649.     printz (CP[15]);
  650.       for (sq = 0; sq < 64; sq++)
  651.     DrawPiece (sq);
  652.     }
  653.   else
  654.     {
  655.       DrawPiece (f);
  656.       DrawPiece (t);
  657.       if (isspec & cstlmask)
  658.     if (t > f)
  659.       {
  660.         DrawPiece (f + 3);
  661.         DrawPiece (t - 1);
  662.       }
  663.     else
  664.       {
  665.         DrawPiece (f - 4);
  666.         DrawPiece (t + 1);
  667.       }
  668.       else if (isspec & epmask)
  669.     {
  670.       DrawPiece (t - 8);
  671.       DrawPiece (t + 8);
  672.     }
  673.     }
  674.   refresh ();
  675. }
  676.  
  677. extern CHAR *InPtr;
  678. void
  679. skip ()
  680. {
  681.   while (*InPtr != ' ')
  682.     InPtr++;
  683.   while (*InPtr == ' ')
  684.     InPtr++;
  685. }
  686. void
  687. skipb ()
  688. {
  689.   while (*InPtr == ' ')
  690.     InPtr++;
  691. }
  692.  
  693. void
  694. ChangeAlphaWindow (void)
  695. {
  696.   ShowMessage (CP[114]);
  697.   scanz ("%hd", &WAwindow);
  698.   ShowMessage (CP[34]);
  699.   scanz ("%hd", &BAwindow);
  700. }
  701.  
  702. void
  703. ChangeBetaWindow (void)
  704. {
  705.   ShowMessage (CP[115]);
  706.   scanz ("%hd", &WBwindow);
  707.   ShowMessage (CP[35]);
  708.   scanz ("%hd", &BBwindow);
  709. }
  710.  
  711. void
  712. GiveHint (void)
  713. {
  714.   CHAR s[40];
  715.   if (hint)
  716.     {
  717.       algbr ((SHORT) (hint >> 8), (SHORT) (hint & 0xFF), false);
  718.       strcpy (s, CP[198]);    /*try*/
  719.       strcat (s, mvstr[0]);
  720.       ShowMessage (s);
  721.     }
  722.   else
  723.     ShowMessage (CP[223]);
  724. }
  725.  
  726. void
  727. ChangeHashDepth (void)
  728. {
  729.   ShowMessage (CP[163]);
  730.   scanz ("%hd", &HashDepth);
  731.   ShowMessage (CP[82]);
  732.   scanz ("%hd", &HashMoveLimit);
  733. }
  734.  
  735. void
  736. ChangeSearchDepth (void)
  737. {
  738.   ShowMessage (CP[150]);
  739.   scanz ("%hd", &MaxSearchDepth);
  740.   TCflag = !(MaxSearchDepth > 0);
  741. }
  742.  
  743. void
  744. SetContempt (void)
  745. {
  746.   ShowMessage (CP[142]);
  747.   scanz ("%hd", &contempt);
  748. }
  749.  
  750. void
  751. ChangeXwindow (void)
  752. {
  753.   ShowMessage (CP[208]);
  754.   scanz ("%hd", &xwndw);
  755. }
  756.  
  757. void
  758. SelectLevel (CHAR *sx)
  759. {
  760.  
  761.   CHAR T[64], *p, *q;
  762.  
  763.   ClrScreen ();
  764.   XC = XCmore =0;
  765.  
  766.   if ((p = strstr (sx, CP[169])) != NULL) p += strlen (CP[169]);
  767.   else if ((p = strstr (sx, CP[217])) != NULL) p += strlen (CP[217]);
  768.   strcat (sx, "XX");
  769.   q = T;
  770.   *q = '\0';
  771.   for (; *p != 'X'; *q++ = *p++);
  772.   *q = '\0';
  773.   /* line empty ask for input */
  774.   while(true){
  775.   if (!T[0])
  776.     {
  777.    gotoXY(5,2);
  778.    printz(CP[61]);
  779.    refresh ();
  780. #if defined (MSDOS) || defined (DOSLIKE_ANSI_DISPLAY)
  781.    T[0] = '\0';
  782.    gets (T);
  783. #else
  784.    getstr (T);
  785. #endif
  786.     }
  787.   strcat (T, "XX");
  788.   /* skip whitespace */
  789.   for (p = T; *p == ' '; p++);
  790.   /*
  791.   Input forms are:
  792.              M    m[:s]        - M moves in m:s time
  793.           m[:s]   t    - game in m:s time increment t
  794.           m:[s]        - game in m:s time
  795.              M    m[:s]      t    - for M moves m:s time increment t then reset
  796.   */
  797.   /* could be moves or a incremental clock */
  798.       TCminutes = TCmoves = TCseconds =  TCadd = 0;
  799.       TCmoves = (SHORT) strtol (p, &q, 10);
  800.       if (*q == ':')
  801.     { /* its gamein form: m:s  or m:s t */
  802.       TCminutes = TCmoves;
  803.       TCmoves = 0;
  804.       if(*(q+1) != ' ') TCseconds = (SHORT) strtol (q + 1, &q, 10); else {q++; }
  805.       if(*q != 'X' && *q != '+'){
  806.         TCadd = (SHORT) strtol (q, &q, 10) * 100;
  807.         }
  808.     }
  809.       else
  810.     { /* m or m t or M m t*/
  811.       while (*q == ' ') q++;
  812.       if (*q == 'X' || *q == '+')
  813.         { /*  m only 1 number must be gamein */
  814.           TCminutes = TCmoves;
  815.           TCmoves = 0;
  816.         }
  817.       else
  818.         { /* M m or M m[:s] t */
  819.           TCminutes = (SHORT) strtol (q, &q, 10);
  820.           if (*q == ':')
  821.         { /* M m[:s] t */
  822.               if(*(q+1) != ' ') TCseconds = (SHORT) strtol (q + 1, &q, 10); else {q++; }
  823.           TCadd = (SHORT) strtol (q, &q, 10);
  824.         }else{/* M m or M m t */
  825.           if(*q != 'X' && *q != '+')/* its M m t*/ TCadd = (SHORT) strtol (q, &q, 10)*100;
  826.                  }
  827.          }
  828.     }
  829.     while(*q == ' ')q++;
  830.     XCmoves[XC] = TCmoves;
  831.     XCminutes[XC] = TCminutes;
  832.     XCseconds[XC] = TCseconds;
  833.     XCadd[XC] = TCadd;
  834.     XC++;
  835.  
  836.         if(*q != '+' || XC == XCLIMIT) break;
  837.         T[0]='\0';
  838.  
  839.     }
  840.   TimeControl.clock[white] = TimeControl.clock[black] = 0;
  841.   SetTimeControl ();
  842.   ClrScreen ();
  843.   UpdateDisplay (0, 0, 1, 0);
  844. }
  845.  
  846.  
  847.  
  848. void
  849. DoDebug (void)
  850. {
  851.   SHORT c, p, sq, tp, tc, tsq, score;
  852.   CHAR s[40];
  853.  
  854.   ExaminePosition ();
  855.   ShowMessage (CP[65]);
  856.   scanz ("%s", s);
  857.   c = neutral;
  858.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /* w W*/
  859.     c = white;
  860.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*b B*/
  861.     c = black;
  862.   for (p = king; p > no_piece; p--)
  863.     if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
  864.       break;
  865.   for (sq = 0; sq < 64; sq++)
  866.     {
  867.       tp = board[sq];
  868.       tc = color[sq];
  869.       board[sq] = p;
  870.       color[sq] = c;
  871.       tsq = PieceList[c][1];
  872.       PieceList[c][1] = sq;
  873.       ShowPostnValue (sq);
  874.       PieceList[c][1] = tsq;
  875.       board[sq] = tp;
  876.       color[sq] = tc;
  877.     }
  878.   score = ScorePosition (opponent);
  879.   gotoXY (TAB, 5);
  880.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  881.  
  882.   ClrEoln ();
  883. }
  884. void
  885. DoTable (SHORT table[64])
  886. {
  887.   SHORT  sq;
  888.   ExaminePosition ();
  889.   for (sq=0;sq<64;sq++){
  890.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  891.   printz ("%3d ", table[sq]);
  892.  
  893. }
  894. }
  895. SHORT LdisplayLine;
  896. void Ldisplay1(){LdisplayLine=4; ClrScreen();UpdateDisplay (0, 0, 1, 0); }
  897.  
  898. void Ldisplay2(){
  899.   refresh ();
  900.   getchar ();
  901.   ClrScreen ();
  902.   UpdateDisplay (0, 0, 1, 0);
  903. }
  904.  
  905. void Ldisplay(char *m, char *h, SHORT count)
  906. {
  907.     gotoXY(50,LdisplayLine);
  908.     LdisplayLine++;
  909.     printz("%s\t%s\t%d\n",m,h,count);
  910. }
  911. Ldisplay3()
  912. {ClrScreen();refresh();LdisplayLine=4;}
  913. void Ldisplay4(char *line)
  914. {
  915.         gotoXY(10,LdisplayLine);
  916.         LdisplayLine++;
  917.         printz("%s",line);
  918.     refresh();
  919. }
  920.