home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / ArcBoard004.arc / !GNUChessX / src / misc / uxdsp_c < prev   
Text File  |  1995-07-02  |  19KB  |  911 lines

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