home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / game / think / uchess / source / uchessrc.lha / nondsp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-04  |  21.1 KB  |  987 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. #include <ctype.h>
  25. #include <signal.h>
  26.  
  27. #ifdef AMIGA
  28. #define __USE_SYSBASE
  29. #include <exec/types.h>
  30. #include <exec/exec.h>
  31. #include <proto/exec.h>
  32. #include <proto/dos.h>
  33. #include <proto/graphics.h>
  34. #include <proto/intuition.h>
  35. #endif
  36.  
  37. char HintString[80];
  38.  
  39. #define SIGQUIT SIGINT
  40.  
  41. #ifdef MSDOS
  42. #include <dos.h>
  43. #include <conio.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46. #include <time.h>
  47. #else
  48. #include <stdio.h>
  49. #include <dos.h>
  50. #include <stdlib.h>
  51. #include <string.h>
  52. #include <time.h>
  53. /*
  54. #include <sys/param.h>
  55. #include <sys/types.h>
  56. #include <sys/file.h>
  57. #include <sys/ioctl.h>
  58. */
  59. #endif
  60.  
  61. #include "gnuchess.h"
  62.  
  63. extern short int ISZERO;
  64. char IllegalString[40];
  65. extern int AmigaStarted;
  66. int IllegalMove=0;
  67. int Mate=0;
  68. int DrawnGame=0;
  69. char MateString[40]={0};
  70.  
  71. #ifdef DEBUG
  72. INTSIZE int debuglevel = 0;
  73.  
  74. #endif /* DEBUG */
  75. unsigned INTSIZE int MV[MAXDEPTH];
  76. int MSCORE;
  77.  
  78. #if defined CHESSTOOL || defined XBOARD
  79. INTSIZE int chesstool = 1;
  80.  
  81. #else
  82. INTSIZE int chesstool = 0;
  83.  
  84. #endif /* CHESSTOOL */
  85. extern char mvstr[4][6];
  86. int mycnt1, mycnt2;
  87. char *DRAW;
  88. extern char *InPtr;
  89. extern INTSIZE int pscore[];
  90.  
  91. void
  92. Initialize (void)
  93. {
  94.   mycnt1 = mycnt2 = 0;
  95. #if defined CHESSTOOL || defined XBOARD
  96. #ifndef SYSV
  97.   setlinebuf (stdout);
  98. #else
  99.   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  100. #endif
  101.   printf (CP[43]);        /*Chess*/
  102.   if (!TCflag && (MaxResponseTime == 0))
  103.     MaxResponseTime = 15L*100L;
  104. #endif /* CHESSTOOL */
  105. }
  106.  
  107.  
  108. void DoAMove(void);
  109.  
  110. void DoAMove()
  111. {
  112.  char astr[40];
  113.  int r,c,l;
  114.  char piece;
  115.  
  116.       r = mvstr[0][3] - '1';
  117.       c = mvstr[0][2] - 'a';
  118.       l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  119.       if (color[l] == neutral)
  120.        {
  121.     DisplayBeep(0L);
  122.         Delay(25L);
  123.     DisplayBeep(0L);
  124.         Delay(25L);
  125.     DisplayBeep(0L);
  126.         Delay(25L);
  127.         piece = ' ';
  128.        }
  129.       else if (color[l] == white)
  130.         piece = qxx[board[l]]; /* white are lower case pieces */
  131.       else
  132.         piece = pxx[board[l]]; /* black are upper case pieces */
  133.   if (computer == black)
  134.    sprintf(astr,"%d: %s",GameCnt>>1,mvstr[0]);
  135.   else
  136.    sprintf(astr,"%d: %s",(GameCnt+1)>>1,mvstr[0]);   
  137.   DisplayComputerMove(astr);
  138.   AnimateAmigaMove(mvstr[0],piece);
  139. }
  140. void
  141. ExitChess (void)
  142. {
  143.   signal (SIGTERM, SIG_IGN);
  144.   ListGame (0L);
  145. #ifdef AMIGA
  146.   if (AmigaStarted)
  147.    AmigaShutDown();
  148. #endif
  149.   exit (0);
  150. }
  151.  
  152. #ifndef MSDOS            /* never called!!! */
  153. #ifndef AMIGA
  154. void
  155. Die (int sig)
  156. {
  157.   char s[80];
  158.  
  159.   ShowMessage (CP[31]);        /*Abort?*/
  160.   scanz ("%s", s);
  161.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  162.     ExitChess ();
  163. }
  164. #endif
  165. #endif /* MSDOS */
  166.  
  167. void
  168. TerminateSearch (int sig)
  169. {
  170. #ifdef MSDOS
  171.   sig++;            /* shut up the compiler */
  172. #endif /* MSDOS */
  173.   if (!flag.timeout)
  174.     flag.musttimeout = true;
  175.   flag.bothsides = false;
  176. }
  177.  
  178.  
  179. void
  180. help (void)
  181. {
  182. #ifndef AMIGA
  183.   ClrScreen ();
  184.   /*printz ("CHESS command summary\n");*/
  185.   printz (CP[40]);
  186.   printz ("----------------------------------------------------------------\n");
  187.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  188.   printz (CP[158]);
  189.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  190.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  191.   /*printz ("a7a8q     promote pawn to queen\n");*/
  192.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  193.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  194.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  195.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  196.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  197.   /*printz ("bd        redraw board            reverse   board display\n");*/
  198.   printz (CP[130]);
  199.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount, BOOKSIZE);*/
  200.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  201.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  202.   printz (CP[200]);
  203.   /*printz ("edit      edit board              force     enter game moves\n");*/
  204.   printz (CP[153]);
  205.   /*printz ("switch    sides with computer     both      computer match\n");*/
  206.   printz (CP[194]);
  207.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  208.   printz (CP[202]);
  209.   /*printz ("depth     set search depth        clock     set time control\n");*/
  210.   printz (CP[149]);
  211.   /*printz ("post      principle variation     hint      suggest a move\n");*/
  212.   printz (CP[177]);
  213.   /*printz ("save      game to file            get       game from file\n");*/
  214.   printz (CP[188]);
  215.   /*printz ("random    randomize play          new       start new game\n");*/
  216.   printz (CP[181]);
  217.   printz ("----------------------------------------------------------------\n");
  218.   /*printz ("Computer: %-12s Opponent:            %s\n",*/
  219.   printz (CP[46],
  220.       ColorStr[computer], ColorStr[opponent]);
  221.   /*printz ("Depth:    %-12d Response time:       %d sec\n",*/
  222.   printz (CP[51],
  223.       MaxSearchDepth, MaxResponseTime/100);
  224.   /*printz ("Random:   %-12s Easy mode:           %s\n",*/
  225.   printz (CP[99],
  226.       (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
  227.   /*printz ("Beep:     %-12s Transposition file: %s\n",*/
  228.   printz (CP[36],
  229.       (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
  230.   /*printz ("Time Control %s %d moves %d seconds %d opr %d depth\n", (TCflag) ? "ON" : "OFF",*/
  231.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  232.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  233.   signal (SIGINT, TerminateSearch);
  234. #ifndef MSDOS
  235.   signal (SIGQUIT, TerminateSearch);
  236. #endif /* MSDOS */
  237. #endif
  238. }
  239.  
  240. void
  241. EditBoard (void)
  242.  
  243. /*
  244.  * Set up a board position. Pieces are entered by typing the piece followed
  245.  * by the location. For example, Nf3 will place a knight on square f3.
  246.  */
  247.  
  248. {
  249.   INTSIZE a, r, c, sq, i, found;
  250.   int tmpcolor;
  251.   char s[80];
  252.  
  253.   flag.regularstart = false;
  254.   Book = 0;
  255. #ifndef AMIGA
  256.   /*printz (".   exit to main\n");*/
  257.   printz (CP[29]);
  258.   /*printz ("#   clear board\n");*/
  259.   printz (CP[28]);
  260.   /*printz ("c   change sides\n");*/
  261.   printz (CP[136]);
  262.   /*printz ("enter piece & location: \n");*/
  263.   printz (CP[155]);
  264. #else
  265.   if (!OpenAmigaEditWindow())
  266.    { /* open the window which will give us back text string */
  267.     DisplayBeep(0L);
  268.     Delay(25L);
  269.     DisplayBeep(0L);
  270.     return;
  271.    }
  272. #endif
  273.  
  274.   a = tmpcolor = white;
  275.   do
  276.     {
  277.       GetEditText(s,&tmpcolor); /* amiga routine to get the command from user */
  278.       found=0;
  279.       if (s[0] == CP[28][0])    /*#*/
  280.     for (sq = 0; sq < 64; sq++)
  281.       {
  282.         board[sq] = no_piece;
  283.         color[sq] = neutral;
  284.       }
  285.       if (a != tmpcolor)    /*c*/
  286.     a = otherside[a];
  287.       c = s[1] - 'a';
  288.       r = s[2] - '1';
  289.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  290.     {
  291.       sq = locn (r, c);
  292.       color[sq] = a;
  293.       board[sq] = no_piece;
  294.       for (i = no_piece; i <= king; i++)
  295.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  296.           {
  297.         board[sq] = i;
  298.         found=1;
  299.         break;
  300.           }
  301.       if ((found==0)||(board[sq] == no_piece)) color[sq] = neutral;    
  302.     }
  303.   } while (s[0] != CP[29][0]);
  304.   for (sq = 0; sq < 64; sq++)
  305.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  306.   CloseAmigaEditWindow(); /* Closes the edit window */
  307.   GameCnt = 0;
  308.   Game50 = 1;
  309.   ISZERO = 1;
  310.   ZeroRPT ();
  311.   Sdepth = 0;
  312.   InitializeStats ();
  313.   DrawAmigaBoard();
  314. }
  315.  
  316. void
  317. SetupBoard (void)
  318.  
  319. /*
  320.  * Compatibility with Unix chess and the nchesstool. Set up a board position.
  321.  * Eight lines of eight characters are used to setup the board. a8-h8 is the
  322.  * first line. Black pieces are  represented  by  uppercase characters.
  323.  */
  324.  
  325. {
  326. #ifdef AMIGA
  327. return;
  328. #else
  329.   INTSIZE r, c, sq, i;
  330.   char ch;
  331.   char s[80];
  332.  
  333.   NewGame ();
  334.  
  335.   gets (s);            /* skip "setup" command */
  336.   for (r = 7; r >= 0; r--)
  337.     {
  338.       gets (s);
  339.       for (c = 0; c <= 7; c++)
  340.     {
  341.       ch = s[c];
  342.       sq = locn (r, c);
  343.       color[sq] = neutral;
  344.       board[sq] = no_piece;
  345.       for (i = no_piece; i <= king; i++)
  346.         if (ch == pxx[i])
  347.           {
  348.         color[sq] = black;
  349.         board[sq] = i;
  350.         break;
  351.           }
  352.         else if (ch == qxx[i])
  353.           {
  354.         color[sq] = white;
  355.         board[sq] = i;
  356.         break;
  357.           }
  358.     }
  359.     }
  360.   for (sq = 0; sq < 64; sq++)
  361.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  362.   InitializeStats ();
  363.   ClrScreen ();
  364.   UpdateDisplay (0, 0, 1, 0);
  365.   /*printz ("Setup successful\n");*/
  366.   printz (CP[106]);
  367. #endif
  368. }
  369.  
  370.  
  371. void
  372. ShowDepth (char ch)
  373. {
  374. #ifdef MSDOS
  375.   ch++;                /* shut up the compiler */
  376. #endif /* MSDOS */
  377. }
  378.  
  379.  
  380. void
  381. ShowLine (INTSIZE unsigned int *bstline,char *astr)
  382. {
  383.  
  384.       algbr ((INTSIZE) (bstline[1] >> 8), (INTSIZE) (bstline[1] & 0xFF), false);
  385.       sprintf (astr,"%s", mvstr[0]);
  386. }
  387.  
  388. void
  389. ShowResults (INTSIZE int score, INTSIZE unsigned int *bstline, char ch)
  390. {
  391.  char astr[64];
  392.  char nstr[16];
  393.  
  394. #if !defined CHESSTOOL
  395. /*printf("GameCnt = %d PrevDepth = %d\n",GameCnt,GameList[GameCnt-1].depth);*/
  396.   if ((!flag.easy)&&(ThinkAheadDepth)&&(TCflag)&&(GameCnt > 1)&&(Sdepth > 2))
  397.    { /* check for lookahead abort */
  398.     if ((Sdepth >= ThinkAheadDepth)&&(Sdepth >= GameList[GameCnt-1].depth)&&(Sdepth > GlobalTgtDepth))
  399.      { /* a chance I may want to abort search here */
  400.         if (!flag.musttimeout)
  401.          { /* not already aborted */
  402.           if ((ThinkInARow < 4)||(Sdepth > ThinkAheadDepth))
  403.            { /* max 4 times in a row */
  404.             flag.musttimeout = true;
  405.             if (Sdepth == ThinkAheadDepth)
  406.              ThinkInARow++;
  407.             else /* you thought past thinkaheaddepth */
  408.              ThinkInARow = 0;
  409.            }
  410.          }
  411.      }
  412.    }
  413.   if (flag.post)
  414.     {
  415.       ElapsedTime (2);
  416.       sprintf (astr,"D%d S%d ", Sdepth, score);
  417.       ShowLine (bstline,nstr);
  418.       strcat(astr,nstr);
  419.       ShowMessage(astr);
  420.     }
  421. #else
  422.   REG int i;
  423.  
  424.   MSCORE = score;
  425.   MV[30] = ch;
  426.   for (i = 1; bstline[i] > 0; i++)
  427.     {
  428.       MV[i] = bstline[i];
  429.     } MV[i] = 0;
  430. #endif /* CHESSTOOL */
  431. }
  432.  
  433. void
  434. SearchStartStuff (INTSIZE int side)
  435. {
  436.  char astr[64];
  437.   signal (SIGINT, TerminateSearch);
  438. #ifndef MSDOS
  439.   signal (SIGQUIT, TerminateSearch);
  440. #endif /* MSDOS */
  441. #if !defined CHESSTOOL
  442. /*#ifndef AMIGA*/
  443.   if (flag.post)
  444.     {
  445.       sprintf (astr,"Tgt:%d  ", ResponseTime);
  446.       ShowMessage(astr);
  447.     }
  448. /*#endif*/
  449. #endif /* CHESSTOOL */
  450. }
  451. void
  452. OutputMove (cstring)
  453. char *cstring;
  454. {
  455.  int r,c,l;
  456.  char astr[40];
  457.  char piece;
  458.  
  459. #ifdef DEBUG11
  460.   if (1)
  461.     {
  462.       FILE *D;
  463.       extern unsigned INTSIZE int PrVar[];
  464.       char d[80];
  465.       int r, c, l, i;
  466.       D = fopen ("/tmp/DEBUGA", "a+");
  467.       fprintf (D, "inout move is %s\n", mvstr[0]);
  468.       strcpy (d, mvstr[0]);
  469.       for (i = 1; PrVar[i] > 0; i++)
  470.     {
  471.       algbr ((INTSIZE) (PrVar[i] >> 8), (INTSIZE) (PrVar[i] & 0xFF), false);
  472.       fprintf (D, "%5s ", mvstr[0]);
  473.     }
  474.       fprintf (D, "\n");
  475.  
  476.       fprintf (D, "\n current board is\n");
  477.       for (r = 7; r >= 0; r--)
  478.     {
  479.       for (c = 0; c <= 7; c++)
  480.         {
  481.           l = locn (r, c);
  482.           if (color[l] == neutral)
  483.         fprintf (D, " -");
  484.           else if (color[l] == white)
  485.         fprintf (D, " %c", qxx[board[l]]);
  486.           else
  487.         fprintf (D, " %c", pxx[board[l]]);
  488.         }
  489.       fprintf (D, "\n");
  490.     }
  491.       fprintf (D, "\n");
  492.       fclose (D);
  493.       strcpy (mvstr[0], d);
  494.     }
  495. #endif
  496. if(flag.illegal){
  497.  IllegalMove = 1;
  498.  sprintf(IllegalString,"%s\n",CP[225]);
  499.  return;
  500. }
  501. if (mvstr[0][0] == '\0') goto nomove;
  502. #ifndef AMIGA
  503. #if defined CHESSTOOL
  504.   if (computer == black)
  505.     printz ("%d. ... %s\n", GameCnt, mvstr[0]);
  506.   else
  507.     printz ("%d. %s\n", ++mycnt1, mvstr[0]);
  508. #else
  509. #ifdef XBOARD
  510.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  511. #else
  512.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  513. #endif
  514. #endif /* CHESSTOOL */
  515. #endif /* amiga */
  516. #ifdef notdef
  517.   if (flag.post)
  518.     {
  519.       REG int i;
  520.  
  521.       printz (" %6d%c ", MSCORE, MV[30]);
  522.       for (i = 1; MV[i] > 0; i++)
  523.     {
  524.       algbr ((INTSIZE) (MV[i] >> 8), (INTSIZE) (MV[i] & 0xFF), false);
  525.       printz ("%5s ", mvstr[0]);
  526.     }
  527.     }
  528.   printz ("\n");
  529. #endif
  530. nomove:
  531.   if ((root->flags & draw)||(root->score == -9999)||
  532.       (root->score == 9998)) goto summary;
  533. #if !defined CHESSTOOL
  534.   if (flag.post)
  535.     {
  536.       INTSIZE h, l, t;
  537.  
  538.       h = TREE;
  539.       l = 0;
  540.       t = TREE >> 1;
  541.       while (l != t)
  542.     {
  543.       if (Tree[t].f || Tree[t].t)
  544.         l = t;
  545.       else
  546.         h = t;
  547.       t = (l + h) >> 1;
  548.     }
  549. #ifndef AMIGA
  550.       /*printf ("Nodes %ld Tree %d Eval %ld Rate %ld RS high %ld low %ld\n",*/
  551.       printf (CP[89],
  552.            NodeCnt, t, EvalNodes, (et) ? (NodeCnt / (et / 100)) : 0, reminus, replus);
  553.       /*printf ("Hin/Hout/Coll/Fin/Fout = %ld/%ld/%ld/%ld/%ld\n",*/
  554.       printf (CP[71],
  555.            HashAdd, HashCnt, THashCol, HashCol, FHashAdd, FHashCnt);
  556. #else /* print out thinking on amiga */
  557. #endif
  558.     }
  559.   UpdateDisplay (root->f, root->t, 0, root->flags);
  560. #ifndef AMIGA
  561.   /*printf ("My move is: %s\n", mvstr[0]);*/
  562.  
  563.   printz (CP[83], mvstr[0]);
  564. #else
  565.       r = mvstr[0][3] - '1';
  566.       c = mvstr[0][2] - 'a';
  567.       l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  568.       if (color[l] == neutral)
  569.        {
  570.     DisplayBeep(0L);
  571.         Delay(25L);
  572.     DisplayBeep(0L);
  573.         Delay(25L);
  574.     DisplayBeep(0L);
  575.         Delay(25L);
  576.         piece = ' ';
  577.        }
  578.       else if (color[l] == white)
  579.         piece = qxx[board[l]]; /* white are lower case pieces */
  580.       else
  581.         piece = pxx[board[l]]; /* black are upper case pieces */
  582.   if (computer == black)
  583.    sprintf(astr,"%d: %s",GameCnt>>1,mvstr[0]);
  584.   else
  585.    sprintf(astr,"%d: %s",(GameCnt+1)>>1,mvstr[0]);   
  586.   DisplayComputerMove(astr);
  587.   AnimateAmigaMove(mvstr[0],piece);
  588. #endif
  589.   if ((flag.beep)&&(!flag.bothsides))
  590.    {
  591.     DisplayBeep(0L);
  592.    }
  593. #endif /* CHESSTOOL */
  594.  summary:
  595.   if (root->flags & draw)
  596.     /*    printf ("Drawn game!\n");*/
  597.    {
  598.     /*printz (CP[57]);*/
  599.     DrawnGame = 1;
  600.    }
  601.   else if (root->score == -9999)
  602.    {
  603.     Mate = 1;
  604. #ifdef OLDWAYPL58
  605.     if (flag.bothsides)
  606.      sprintf(MateString,"%s mates!",ColorStr[opponent^1]);
  607.     else
  608.      sprintf(MateString,"%s mates!",ColorStr[opponent]);
  609. #else
  610.     sprintf(MateString,"%s mates!",ColorStr[opponent]);
  611. #endif
  612. /*    printz("%s mates!\n",ColorStr[opponent]);*/
  613.    }
  614.   else if (root->score == 9998)
  615.    {
  616.     Mate = 1;
  617.     DoAMove();
  618.     if (flag.bothsides)
  619.      sprintf(MateString,"%s mates!",ColorStr[computer^1]);
  620.     else
  621.      sprintf(MateString,"%s mates!",ColorStr[computer]);
  622. /*    printz("%s mates!\n",ColorStr[computer]);*/
  623.    }
  624. #if !defined CHESSTOOL && !defined XBOARD
  625. #ifdef VERYBUGGY
  626.   else if (root->score < -9000)
  627.     printf("%s has a forced mate!\n",ColorStr[opponent]);
  628.   else if (root->score > 9000)
  629.     printf("%s has a forced mate!\n",ColorStr[computer]);
  630. #endif /*VERYBUGGY*/
  631. #endif /* CHESSTOOL */
  632. }
  633.  
  634. void
  635. ClrScreen (void)
  636. {
  637. #if !defined CHESSTOOL && !defined XBOARD && !defined AMIGA
  638.   printz ("\n");
  639. #endif
  640. #ifdef AMIGA
  641. #endif
  642. }
  643.  
  644. void
  645. UpdateDisplay (INTSIZE int f, INTSIZE int t, INTSIZE int redraw, INTSIZE int isspec)
  646. {
  647.  
  648. #ifndef AMIGA
  649.   INTSIZE r, c, l, m;
  650. #endif
  651.  
  652.   if (redraw && !chesstool)
  653.     {
  654. #ifndef AMIGA /* text clock and etc display */
  655.       printz ("\n");
  656.       r = TimeControl.clock[white] / 6000;
  657.       c = (TimeControl.clock[white] % 6000) / 100;
  658.       l = TimeControl.clock[black] / 6000;
  659.       m = (TimeControl.clock[black] % 6000) / 100;
  660.       /*printz ("White %d:%02d  Black %d:%02d\n", r, c, l, m);*/
  661.       printz (CP[116], r, c, l, m);
  662.       printz ("\n");
  663.       for (r = 7; r >= 0; r--)
  664.     {
  665.       for (c = 0; c <= 7; c++)
  666.         {
  667.           l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  668.           if (color[l] == neutral)
  669.         printz (" -");
  670.           else if (color[l] == white)
  671.         printz (" %c", qxx[board[l]]);
  672.           else
  673.         printz (" %c", pxx[board[l]]);
  674.         }
  675.       printz ("\n");
  676.     }
  677.       printz ("\n");
  678. #else /* Update intution board on the Amiga */
  679. #endif
  680.     }
  681. }
  682.  
  683. void
  684. skip ()
  685. {
  686.   while (*InPtr != ' ')
  687.     InPtr++;
  688.   while (*InPtr == ' ')
  689.     InPtr++;
  690. }
  691. void
  692. skipb ()
  693. {
  694.   while (*InPtr == ' ')
  695.     InPtr++;
  696. }
  697.  
  698. #ifndef AMIGA
  699. void
  700. ShowMessage (char *s)
  701. {
  702. #ifndef AMIGA
  703.   printf("%s\n", s);
  704. #else /* write this msg on the intuition msg screen */
  705.   DisplayComputerMove(s);
  706. #endif
  707. }
  708.  
  709. #endif
  710.  
  711. void
  712. ShowSidetoMove (void)
  713. {
  714. }
  715.  
  716. void
  717. PromptForMove (void)
  718. {
  719. #if !defined CHESSTOOL && !defined XBOARD && !defined AMIGA
  720.   /*printz ("\nYour move is? ");*/
  721.   printz (CP[124]);
  722. #endif /* CHESSTOOL */
  723. }
  724.  
  725.  
  726. void
  727. ShowCurrentMove (INTSIZE int pnt, INTSIZE int f, INTSIZE int t)
  728. {
  729. #ifdef MSDOS
  730.   f++;
  731.   t++;
  732.   pnt++;            /* shut up the compiler */
  733. #endif /* MSDOS */
  734. }
  735.  
  736. void
  737. ChangeAlphaWindow (void)
  738. {
  739. #ifndef AMIGA
  740.   printz ("WAwindow: ");
  741.   scanz ("%hd", &WAwindow);
  742.   printz ("BAwindow: ");
  743.   scanz ("%hd", &BAwindow);
  744. #endif
  745. }
  746.  
  747.  
  748. void
  749. ChangeBetaWindow (void)
  750. {
  751. #ifndef AMIGA
  752.   printz ("WBwindow: ");
  753.   scanz ("%hd", &WBwindow);
  754.   printz ("BBwindow: ");
  755.   scanz ("%hd", &BBwindow);
  756. #endif
  757. }
  758.  
  759. void
  760. GiveHint (void)
  761. {
  762.   if (hint)
  763.     {
  764.       algbr ((INTSIZE) (hint >> 8), (INTSIZE) (hint & 0xFF), false);
  765.       sprintf(HintString,CP[72], mvstr[0]);    /*hint*/
  766.     }
  767.   else
  768.     sprintf (HintString,CP[223]);
  769. #ifndef AMIGA
  770. printf(HintString);
  771. #else
  772. DisplayComputerMove(HintString);
  773. #endif
  774. }
  775.  
  776. void
  777. SelectLevel (timestring)
  778. char *timestring;
  779. {
  780.   int tmp;
  781.   char T[64], *p, *q;
  782.  
  783. #ifndef AMIGA
  784.   printz (CP[61]);
  785.   scanz ("%hd %s", &TCmoves, T);
  786. #else
  787. #ifndef LONGINTS2
  788.   sscanf(timestring,"%hd %s",&TCmoves,T);
  789. #else
  790.   sscanf(timestring,"%d %s",&TCmoves,T);
  791. #endif
  792. #endif
  793.   for (p = T; *p == ' '; p++) ;
  794.   TCminutes = strtol (p, &q, 10);
  795.   TCadd = 0;
  796.   if (TCminutes < 1)
  797.    TCminutes = 1;
  798.   if (TCmoves < 1)
  799.    TCmoves = 1;
  800.   if ((TCminutes/TCmoves) > 0)
  801.    {
  802.     EnableMoveNow();
  803.    }
  804.   else
  805.    {
  806.     DisableMoveNow();
  807.    }
  808.   if (*q == ':')
  809.     TCseconds = strtol (q + 1, (char **) NULL, 10);
  810.   else
  811.     TCseconds = 0;
  812. #ifdef OPERATORTIME
  813.   printz (CP[94]);
  814.   scanz ("%hd", &OperatorTime);
  815. #endif
  816.   if (TCmoves == 0) {
  817.     TCflag = false;
  818.     MaxResponseTime = TCminutes*60L*100L + TCseconds*100L;
  819.     TCminutes = TCseconds = 0;
  820.   } else {
  821.     TCflag = true;
  822.     MaxResponseTime = 0;
  823.     MaxSearchDepth = MAXDEPTH - 1;
  824.   }
  825.   SetTimeControl ();
  826. #ifdef AMIGA
  827.   tmp = player;
  828.   player = white;
  829.   UpdateClocks();
  830.   player = black;
  831.   UpdateClocks();
  832.   player = tmp;
  833. #endif
  834. }
  835.  
  836. #ifdef DEBUG
  837. void
  838. ChangeDbLev (void)
  839. {
  840.   printz (CP[146]);
  841.   scanz ("%hd", &debuglevel);
  842. }
  843.  
  844. #endif /* DEBUG */
  845.  
  846. void
  847. ChangeSearchDepth (void)
  848. {
  849.  int Old;
  850.  
  851.  Old = MaxSearchDepth;
  852. #ifndef AMIGA
  853.   printz ("depth= ");
  854.   scanz ("%hd", &MaxSearchDepth);
  855. #else
  856.   MaxSearchDepth = SetAmigaDepth();
  857. #endif
  858.   if (MaxSearchDepth)
  859.    {
  860.     TCflag = !(MaxSearchDepth > 0);
  861.     if (MaxSearchDepth > 2)
  862.      EnableMoveNow();
  863.    }
  864.   else
  865.    MaxSearchDepth = Old;
  866. }
  867.  
  868. void ChangeHashDepth (void)
  869. {
  870. #ifndef AMIGA
  871.   printz ("hashdepth= ");
  872.   scanz ("%hd", &HashDepth);
  873.   printz ("MoveLimit= ");
  874.   scanz ("%hd", &HashMoveLimit);
  875. #endif
  876. }
  877.  
  878. void
  879. SetContempt (void)
  880. {
  881. #ifndef AMIGA
  882.   printz ("contempt= ");
  883.   scanz ("%hd", &contempt);
  884. #endif
  885. }
  886.  
  887. void
  888. ChangeXwindow (void)
  889. {
  890. #ifndef AMIGA
  891.   printz ("xwndw= ");
  892.   scanz ("%hd", &xwndw);
  893. #endif
  894. }
  895.  
  896. void
  897. ShowPostnValue (INTSIZE int sq)
  898.  
  899. /*
  900.  * must have called ExaminePosition() first
  901.  */
  902.  
  903. {
  904.   char astr[80];
  905.   INTSIZE score;
  906.  
  907.   score = ScorePosition (color[sq]);
  908.   if (color[sq] != neutral){
  909.     sprintf (astr,"%3d%c ", svalue[sq],(color[sq] == black)?'b':'w');}
  910.   else
  911.     sprintf(astr," *   ");
  912.   ShowMessage(astr);
  913. }
  914.  
  915. void
  916. DoDebug (void)
  917. {
  918. #ifndef AMIGA
  919.   INTSIZE c, p, sq, tp, tc, tsq, score,j,k;
  920.   char s[40];
  921.  
  922.   ExaminePosition ();
  923.   ShowMessage (CP[65]);
  924.   scanz ("%s", s);
  925.   c = neutral;
  926.   if (s[0] == CP[9][0] || s[0] == CP[9][1])     /* w W*/ c = white;
  927.   if (s[0] == CP[9][2] || s[0] == CP[9][3])     /*b B*/ c = black;
  928.   for (p = king; p > no_piece; p--)
  929.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  930.   if(p > no_piece)
  931.   for(j=7;j>=0;j--){
  932.   for(k=0;k<8;k++){
  933.       sq=j*8+k;
  934.       tp = board[sq];
  935.       tc = color[sq];
  936.       board[sq] = p;
  937.       color[sq] = c;
  938.       tsq = PieceList[c][1];
  939.       PieceList[c][1] = sq;
  940.       ShowPostnValue (sq);
  941.       PieceList[c][1] = tsq;
  942.       board[sq] = tp;
  943.       color[sq] = tc;
  944.     }
  945.       printz("\n");
  946.     }
  947.   score = ScorePosition (opponent);
  948.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  949. #endif
  950. }
  951.  
  952. void
  953. DoTable (INTSIZE table[64])
  954. {
  955.   char astr[16];
  956.   INTSIZE  sq,j,k;
  957.   ExaminePosition ();
  958.   for(j=7;j>=0;j--){
  959.   for(k=0;k<8;k++){
  960.     sq=j*8+k;
  961.     sprintf (astr,"%3d ", table[sq]);
  962.     ShowMessage(astr);
  963.   }
  964. }
  965. }
  966.  
  967. void
  968. ShowPostnValues (void)
  969. {
  970.   INTSIZE sq, score,j,k;
  971.   char astr[64];
  972.  
  973.   ExaminePosition ();
  974.   for(j=7;j>=0;j--){
  975.   for(k=0;k<8;k++){
  976.   sq=j*8+k;
  977.     ShowPostnValue (sq);
  978.   }
  979.   }
  980.   score = ScorePosition (opponent);
  981.  sprintf (astr,CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  982.  ShowMessage(astr);
  983.  sprintf(astr,"hung white %d hung black %d\n",hung[white],hung[black]);
  984.  ShowMessage(astr);
  985. }
  986.  
  987.