home *** CD-ROM | disk | FTP | other *** search
- /*
- * amidsp.c - Amiga interface for GNUCHESS, based on
- * nuxdsp.c - (new) ALPHA interface for CHESS
- *
- * Copyright (c) 1988,1989,1990 John Stanback
- * Copyright (c) 1992 Free Software Foundation
- * Copyright (c) 1992 Martin W. Scott
- *
- * This file is part of GNU CHESS.
- *
- * GNU Chess is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * GNU Chess is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Chess; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- */
- #include <ctype.h>
- #include <signal.h>
- #include <sys/types.h>
- #include <stdarg.h>
-
- #define BOARD_FOREGROUND 1
- #define TEXT_FOREGROUND 6
- #define INPUT_FOREGROUND 7
-
- #if defined(__STDC__)
- /* <stdlib.h> */
- extern void *malloc (size_t);
- extern void exit (int);
-
- /* <string.h> */
- extern char *strcat (char *, const char *);
- extern int strcmp (const char *, const char *);
- extern char *strcpy (char *, const char *);
-
- /* <time.h> */
- extern long int time (long int *);
- #endif
-
- #include "gnuchess.h"
- #include "amiterm.h"
- #include "draw.h"
-
- extern short int sscore[];
- extern short int pscore[2];
-
- #define TAB (45)
- /* coordinates within a square for the following are ([1,5],[1,3]) */
- #define SQW (5)
- #define SQH (3)
- #define VIR_C(s) ((flag.reverse) ? 7-column(s) : column(s))
- #define VIR_R(s) ((flag.reverse) ? 7-row(s) : row(s))
- #define VSQ_X(x) ((flag.reverse) ? SQW + 1 - (x) : (x))
- #define VSQ_Y(y) ((flag.reverse) ? SQH + 1 - (y) : (y))
- #define Vblack(s) (!((VIR_C(s) + VIR_R(s)) % 2))
- /* Squares swapped */
- #define Vcoord(s,x,y) \
- ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(y))
- /* Squares and internal locations swapped */
- #define VcoordI(s,x,y) \
- ((SQW)*(VIR_C(s)))+(VSQ_X(x)),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
- /* Squares and internal rows swapped */
- #define VcoordR(s,x,y) \
- ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
- char Analysis[128] = "";
- unsigned short int MV[MAXDEPTH];
- int MSCORE;
- char *DRAW;
- extern char mvstr[4][6];
- extern short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
- short PositionFlag = 0;
- void TerminateSearch (int), Die (int);
-
- #define OReverse standout
- #define ONormal standend
-
- cursoron()
- {
- leaveok(NULL, 0); /* cursor on... */
- attron(INPUT_FOREGROUND);
- printw("");
- refresh();
- }
-
- cursoroff()
- {
- attron(TEXT_FOREGROUND);
- leaveok(NULL, 1); /* ...cursor off */
- }
-
- /* max. of 3 parameters... */
- ami_scanw(char *fmt, void *a1, void *a2, void *a3)/* aesthetic curses... */
- {
- int rv;
- cursoron();
- #ifdef I_WISH
- rv = vscanw(fmt, (long *)ap);
- #else
- rv = scanw(fmt, a1, a2, a3);
- #endif
- cursoroff();
- return rv;
- }
-
- void
- Initialize (void)
- {
- signal (SIGINT, Die);
- #ifndef AMIGA
- signal (SIGQUIT, Die);
- #endif
- initscr ();
- attron(TEXT_FOREGROUND);
- leaveok(NULL, 1); /* ...cursor off */
- gotoXY(22,12);
- printw("Welcome to GNU CHESS. Initialising...");
- refresh();
- crmode ();
- }
-
- void
- ExitChess (void)
- {
- #ifdef ALWAYSLIST
- ListGame ();
- #endif
- refresh();
- nocrmode ();
- endwin ();
- exit (0);
- }
-
- void
- Die (int Sig)
- {
- char s[80];
-
- signal (SIGINT, SIG_IGN);
- #ifndef AMIGA
- signal (SIGQUIT, SIG_IGN);
- #endif
- ShowMessage (CP[31]); /*Abort?*/
- scanz ("%s", s);
- if (stricmp (s, CP[210]) == 0) /*yes*/
- ExitChess ();
- signal (SIGINT, Die);
- #ifndef AMIGA
- signal (SIGQUIT, Die);
- #endif
- }
-
- void
- TerminateSearch (int Sig)
- {
- signal (SIGINT, SIG_IGN);
- #ifndef AMIGA
- signal (SIGQUIT, SIG_IGN);
- #endif
- if (!flag.timeout)
- flag.musttimeout = true;
- flag.bothsides = false;
- signal (SIGINT, Die);
- #ifndef AMIGA
- signal (SIGQUIT, Die);
- #endif
- }
-
- void
- ShowLine (unsigned short int *bstline)
- {
- }
-
- void
- help (void)
- {
- ClrScreen ();
- /*printz ("CHESS command summary\n");*/
- #ifdef NON_GFX
- printz (CP[40]);
- printz ("----------------------------------------------------------------\n");
- #else
- attron(HILITE_PEN);
- printz (CP[40]);
- attron(TEXT_PEN);
- #endif
- /*printz ("g1f3 move from g1 to f3 quit Exit Chess\n");*/
- printz (CP[158]);
- /*printz ("Nf3 move knight to f3 beep turn %s\n", (flag.beep) ? "off" : "on");*/
- printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
- /*printz ("a7a8q promote pawn to queen\n");*/
- printz (CP[128], (flag.material) ? CP[92] : CP[93]);
- /*printz ("o-o castle king side easy turn %s\n", (flag.easy) ? "off" : "on");*/
- printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
- /*printz ("o-o-o castle queen side hash turn %s\n", (flag.hash) ? "off" : "on");*/
- printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
- /*printz ("bd redraw board reverse board display\n");*/
- printz (CP[130]);
- /*printz ("list game to chess.lst book turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount, BOOKSIZE);*/
- printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
- /*printz ("undo undo last ply remove take back a move\n");*/
- printz (CP[200]);
- /*printz ("edit edit board force enter game moves\n");*/
- printz (CP[153]);
- /*printz ("switch sides with computer both computer match\n");*/
- printz (CP[194]);
- /*printz ("white computer plays white black computer plays black\n");*/
- printz (CP[202]);
- /*printz ("depth set search depth clock set time control\n");*/
- printz (CP[149]);
- /*printz ("hint suggest a move post turn %s principle variation\n", (flag.post) ? "off" : "on");*/
- printz (CP[177], (flag.post) ? CP[92] : CP[93]);
- /*printz ("save game to file get game from file\n");*/
- printz (CP[188]);
- /*printz ("random randomize play new start new game\n");*/
- printz (CP[181]);
- /*printz ("coords show coords rv reverse video\n");*/
- printz (CP[144]);
- #ifdef NON_GFX
- printz (CP[192]);
- #define INCREMENT 0
- #else
- #define INCREMENT -1
- #endif
- gotoXY (10, 20+INCREMENT);
- printz (CP[47], ColorStr[computer]);
- gotoXY (10, 21+INCREMENT);
- printz (CP[97], ColorStr[opponent]);
- gotoXY (10, 22+INCREMENT);
- printz (CP[79], MaxResponseTime/100);
- #ifdef NON_GFX
- gotoXY (10, 23+INCREMENT);
- printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
- #endif
- gotoXY (40, 20+INCREMENT);
- printz (CP[52], MaxSearchDepth);
- gotoXY (40, 21+INCREMENT);
- printz (CP[100], (dither) ? CP[93] : CP[92]);
- gotoXY (40, 22+INCREMENT);
- printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
- #ifdef NON_GFX
- gotoXY (40, 23+INCREMENT);
- printz (CP[73]);
- gotoXY (10, 24+INCREMENT);
- printz (CP[110], (TCflag) ? CP[93] : CP[92],
- TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
- #else
- gotoXY (10, 23+INCREMENT);
- printz (CP[110], (TCflag) ? CP[93] : CP[92],
- TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
- #endif
- refresh ();
- getch ();
- ClrScreen ();
- UpdateDisplay (0, 0, 1, 0);
- }
-
- void
- EditBoard (void)
-
- /*
- * Set up a board position. Pieces are entered by typing the piece followed
- * by the location. For example, Nf3 will place a knight on square f3.
- */
-
- {
- short a, r, c, sq, i;
- char s[80];
-
- flag.regularstart = false;
- Book = false;
- ClrScreen ();
- UpdateDisplay (0, 0, 1, 0);
- gotoXY (TAB, 3);
- printz (CP[29]);
- gotoXY (TAB, 4);
- printz (CP[28]);
- gotoXY (TAB, 5);
- printz (CP[136]);
- gotoXY (TAB, 7);
- printz (CP[64]);
- a = white;
- do
- {
- gotoXY (TAB, 6);
- printz (CP[60], ColorStr[a]); /*Editing %s*/
- gotoXY (TAB + 24, 7);
- ClrEoln ();
- scanz ("%s", s);
- if (s[0] == CP[28][0]) /*#*/
- {
- attron(BOARD_FOREGROUND);
- for (sq = 0; sq < 64; sq++)
- {
- board[sq] = no_piece;
- color[sq] = neutral;
- DrawPiece (sq);
- }
- attron(TEXT_FOREGROUND);
- }
- if (s[0] == CP[136][0]) /*c*/
- a = otherside[a];
- c = s[1] - 'a';
- r = s[2] - '1';
- if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
- {
- sq = locn (r, c);
- for (i = king; i > no_piece; i--)
- if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
- break;
- board[sq] = i;
- color[sq] = ((board[sq] == no_piece) ? neutral : a);
- attron(BOARD_FOREGROUND);
- DrawPiece (sq);
- attron(TEXT_FOREGROUND);
- }
- } while (s[0] != CP[29][0]);
-
- for (sq = 0; sq < 64; sq++)
- Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
- GameCnt = 0;
- Game50 = 1;
- ZeroRPT ();
- Sdepth = 0;
- InitializeStats ();
- ClrScreen ();
- UpdateDisplay (0, 0, 1, 0);
- }
-
- void
- ShowPlayers (void)
- {
- gotoXY (TAB, ((flag.reverse) ? 21 : 2));
- printz ("%s", (computer == black) ? CP[218] : CP[74]);
- ClrEoln ();
- gotoXY (TAB, ((flag.reverse) ? 2 : 21));
- printz ("%s", (computer == white) ? CP[218] : CP[74]);
- ClrEoln ();
- }
-
- void
- ShowDepth (char ch)
- {
- gotoXY (TAB, 4);
- printz (CP[53], Sdepth, ch); /*Depth= %d%c*/
- ClrEoln ();
- }
-
- void
- ShowScore (short score)
- {
- gotoXY (TAB, 5);
- printz (CP[104], score);
- ClrEoln ();
- }
-
- void
- ShowMessage (char *s)
- {
- gotoXY (TAB, 17);
- printz ("%s", s);
- ClrEoln ();
- }
-
- void
- WarnMessage (char *s)
- {
- attron(HILITE_PEN);
- ShowMessage(s);
- attron(TEXT_FOREGROUND);
- }
-
- void
- ClearMessage (void)
- {
- gotoXY (TAB, 17);
- ClrEoln ();
- }
-
- void
- ShowCurrentMove (short int pnt, short int f, short int t)
- {
- algbr (f, t, false);
- gotoXY (TAB, 7);
- printz ("(%2d) %4s", pnt, mvstr[0]);
- }
-
- void
- ShowHeader (void)
- {
- #ifdef NON_GFX
- gotoXY (TAB, 10);
- printz (CP[68]);
- #endif
- }
-
- void
- ShowSidetoMove (void)
- {
- gotoXY (TAB, 13);
- printz ("%2d: %s", 1 + GameCnt / 2, ColorStr[player]);
- ClrEoln ();
- }
-
- void
- ShowPrompt (void)
- {
- gotoXY (TAB, 16);
- printz (CP[121]); /*Your movwe is?*/
- ClrEoln ();
- }
-
- void
- ShowNodeCnt (long int NodeCnt)
- {
- gotoXY (TAB, 18);
- printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
- ClrEoln ();
- refresh();
- }
-
- void
- ShowResults (short int score, unsigned short int *bstline, char ch)
- {
- unsigned char d, ply;
-
- if (flag.post)
- {
- ShowDepth (ch);
- ShowScore (score);
- d = 7;
- for (ply = 1; bstline[ply] > 0; ply++)
- {
- if (ply % 4 == 1)
- {
- gotoXY (TAB, ++d);
- ClrEoln ();
- }
- algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
- printz ("%5s ", mvstr[0]);
- }
- ClrEoln ();
- while (d < 12)
- {
- gotoXY (TAB, ++d);
- ClrEoln ();
- }
- }
- }
-
- void
- SearchStartStuff (short int side)
- {
- short i;
-
- signal (SIGINT, TerminateSearch);
- #ifndef AMIGA
- signal (SIGQUIT, TerminateSearch);
- #endif
- for (i = 4; i < 13; i++)
- {
- gotoXY (TAB, i);
- ClrEoln ();
- }
- }
-
- void
- OutputMove (void)
- {
- UpdateDisplay (rootnode.f, rootnode.t, 0, (short) rootnode.flags);
- gotoXY (TAB, 15);
- if(flag.illegal) {printz (CP[225]); return;}
- printz (CP[84], mvstr[0]); /*My move is %s*/
- if (flag.beep)
- beep();
- ClrEoln ();
-
- gotoXY (TAB, 22);
- if (rootnode.flags & draw)
- printz (CP[56], DRAW);
- else if (rootnode.score == -9999)
- printz (CP[95]);
- else if (rootnode.score == 9998)
- printz (CP[44]);
-
- ClrEoln ();
-
- if (flag.post)
- {
- register short h, l, t;
-
- h = TREE;
- l = 0;
- t = TREE >> 1;
- while (l != t)
- {
- if (Tree[t].f || Tree[t].t)
- l = t;
- else
- h = t;
- t = (l + h) >> 1;
- }
-
-
- ShowNodeCnt (NodeCnt);
- gotoXY (TAB, 19);
-
- printz (CP[81], t); /*Max Tree= %d*/
- ClrEoln ();
- }
- }
-
- static void
- DoClockUpdate (short who)
- {
- short m, s;
-
- m = (short) (et / 6000);
- s = (short) (et - 6000 * (long) m) / 100;
- if (TCflag)
- {
- m = (short) ((TimeControl.clock[who] - et) / 6000);
- s = (short) ((TimeControl.clock[who] - et - 6000 * (long) m) / 100);
- }
- if (m < 0)
- m = 0;
- if (s < 0)
- s = 0;
- if (who == white)
- gotoXY (60, (flag.reverse) ? 2 : 21);
- else
- gotoXY (60, (flag.reverse) ? 21 : 2);
- printz ("%d:%02d ", m, s);
- if (flag.post)
- ShowNodeCnt (NodeCnt);
- refresh ();
- }
-
- void
- UpdateClocks (void)
- {
- DoClockUpdate(player);
- }
-
- void
- gotoXY (short int x, short int y)
- {
- move (y - 1, x - 1);
- }
-
- void
- ClrScreen (void)
- {
- clear ();
- refresh ();
- }
-
- void
- ClrEoln (void)
- {
- clrtoeol ();
- refresh ();
- }
-
- #ifndef NON_GFX
- void
- FlashDrawPiece(short int sq)
- {
- #ifndef NON_GFX
- /* fancy bitmapped stuff */
- AmiFlashSquare(VIR_R(sq), VIR_C(sq));
- #endif
- DrawPiece(sq);
- }
- #endif /* NON_GFX */
-
- void
- DrawPiece (short int sq)
- {
- #ifndef NON_GFX
- /* fancy bitmapped stuff */
- UWORD pc;
- pc = (color[sq] == white ? WHITE : BLACK);
- AmiDrawSquare(VIR_R(sq), VIR_C(sq));
- if (color[sq] != neutral)
- AmiDrawPiece(board[sq]-1, pc, VIR_R(sq), VIR_C(sq));
- #else
- gotoXY (VcoordR (sq, 2, 2));
- switch (color[sq])
- {
- case black:
- if (flag.rv)
- OReverse ();
- printz ((flag.stars ? "*%c*" : " %c "), pxx[board[sq]]);
- ONormal ();
- break;
- case neutral:
- if (flag.shade)
- printz (Vblack (sq) ? "///" : " ");
- else
- {
- #ifdef AMIGA
- if (!Vblack (sq)) /* white in bottom-rh corner! */
- #else
- if (Vblack (sq))
- #endif
- OReverse ();
- printz (" ");
- ONormal ();
- }
- break;
- case white:
- printz (" %c ", pxx[board[sq]]);
- break;
- default:
- ShowMessage (CP[55]); /*Draw piece color[sq] err*/
- break;
- }
- #endif /* NON_GFX */
- }
-
- void
- DrawSquare (short int sq)
- {
- #ifndef NON_GFX
- /* fancy bitmapped stuff */
- AmiDrawSquare(VIR_R(sq), VIR_C(sq));
- #else
- if (!Vblack (sq))
- OReverse ();
- gotoXY (Vcoord (sq, 1, 1));
- printz (" ");
- gotoXY (Vcoord (sq, 1, 2));
- printz (" ");
- gotoXY (Vcoord (sq, 1, 3));
- printz (" ");
- ONormal ();
- #endif /* NON_GFX */
- }
-
- void
- DrawCoords (void)
- {
- #ifndef NON_GFX
- /* snazzy graphics! */
- AmiDrawCoords(0, flag.reverse); /* draw them */
- #else
- short z;
- for (z = 0; z <= 7; z++)
- {
- short sq;
-
- sq = z << 3;
- gotoXY (VcoordI (sq, 1, 1));
- if ((!Vblack (sq) || flag.shade) && flag.rv)
- OReverse ();
- printz ("%d", 1 + z);
- ONormal ();
- }
-
- for (z = 0; z <= 7; z++)
- {
- short sq;
-
- sq = z;
- gotoXY (VcoordI (sq, SQW, SQH));
- if ((!Vblack (sq) || flag.shade) && flag.rv)
- OReverse ();
- printz ("%c", cxx[z]);
- ONormal ();
- }
-
- for (z = 1; z <= (8 * SQH); z++)
- {
- gotoXY ((8 * SQW) + 1, z);
- printz ("|");
- }
- #endif /* NON_GFX */
- }
-
- void
- ShowPostnValue (short int sq)
-
- /*
- * must have called ExaminePosition() first
- */
-
- {
- #ifdef REALLY_DEBUG
- short score;
-
- gotoXY (VcoordR (sq, 2, 1));
- score = ScorePosition (color[sq]);
- if (!Vblack (sq) && !flag.shade)
- OReverse ();
-
- if (color[sq] != neutral)
- printz ("%3d", svalue[sq]);
- else
- printz (flag.shade && Vblack (sq) ? "///" : " ");
- ONormal ();
- #endif
- }
-
- void
- ShowPostnValues (void)
- {
- #ifdef REALLY_DEBUG
- short sq, score;
-
- ExaminePosition ();
- for (sq = 0; sq < 64; sq++)
- ShowPostnValue (sq);
- score = ScorePosition (opponent);
- gotoXY (TAB, 5);
- printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
- ClrEoln ();
- #endif
- }
-
- void
- UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
- {
- short sq;
-
- if (redraw)
- {
- attron(TEXT_FOREGROUND);
- ShowHeader ();
- ShowPlayers ();
- DoClockUpdate (white);
- DoClockUpdate (black);
- #ifndef NON_GFX
- /* fancy bitmap graphics */
- AmiDrawGrid();
- for (sq = 0; sq < 64; sq++)
- {
- DrawPiece (sq);
- }
- if (flag.coords)
- AmiDrawCoords (0, flag.reverse);
- else
- AmiDrawCoords (1, flag.reverse);
- #else
- attron(BOARD_FOREGROUND);
- for (sq = 0; sq < 64; sq++)
- {
- DrawSquare (sq);
- DrawPiece (sq);
- }
- if (flag.coords)
- DrawCoords ();
- #endif /* NON_GFX */
- }
- else
- {
- attron(BOARD_FOREGROUND);
- FlashDrawPiece (f);
- FlashDrawPiece (t);
-
- DrawPiece (f);
- DrawPiece (t);
-
- if (isspec & cstlmask)
- if (t > f)
- {
- FlashDrawPiece (f + 3);
- FlashDrawPiece (t - 1);
- }
- else
- {
- FlashDrawPiece (f - 4);
- FlashDrawPiece (t + 1);
- }
- else if (isspec & epmask)
- {
- FlashDrawPiece (t - 8);
- DrawPiece (t + 8);
- }
- }
- if (PositionFlag)
- ShowPostnValues ();
- attron(TEXT_FOREGROUND);
- refresh ();
- }
-
- extern char *InPtr;
- void
- skip ()
- {
- while (*InPtr != ' ')
- InPtr++;
- while (*InPtr == ' ')
- InPtr++;
- }
- void
- skipb ()
- {
- while (*InPtr == ' ')
- InPtr++;
- }
-
- void
- ChangeAlphaWindow (void)
- {
- ShowMessage (CP[114]);
- scanz ("%hd", &WAwindow);
- ShowMessage (CP[34]);
- scanz ("%hd", &BAwindow);
- }
-
- void
- ChangeBetaWindow (void)
- {
- ShowMessage (CP[115]);
- scanz ("%hd", &WBwindow);
- ShowMessage (CP[35]);
- scanz ("%hd", &BBwindow);
- }
-
- void
- GiveHint (void)
- {
- char s[40];
- if (hint)
- {
- algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
- strcpy (s, CP[198]); /*try*/
- strcat (s, mvstr[0]);
- ShowMessage (s);
- }
- else
- ShowMessage (CP[223]);
- }
-
- void
- ChangeHashDepth (void)
- {
- ShowMessage (CP[163]);
- scanz ("%hd", &HashDepth);
- ShowMessage (CP[82]);
- scanz ("%hd", &HashMoveLimit);
- }
-
- void
- ChangeSearchDepth (void)
- {
- ShowMessage (CP[150]);
- scanz ("%hd", &MaxSearchDepth);
- TCflag = !(MaxSearchDepth > 0);
- }
-
- void
- SetContempt (void)
- {
- ShowMessage (CP[142]);
- scanz ("%hd", &contempt);
- }
-
-
- void
- SetAnalysis (void)
- {
- ShowMessage (CP[159]);
- scanz ("%s", Analysis);
- }
-
- void
- ChangeXwindow (void)
- {
- ShowMessage (CP[208]);
- scanz ("%hd", &xwndw);
- }
-
- void
- SelectLevel (void)
- {
- int i;
- int item;
-
- ClrScreen ();
- gotoXY (37, 2);
- printz (CP[41]);
- for (i = 0; i < 10; i++)
- {
- gotoXY (25, 4+i);
- printz (CP[18+i]);
- }
-
- OperatorTime = 0;
- TCmoves = 60;
- TCminutes = 5;
- TCseconds = 0;
- gotoXY (25, 17);
- printz (CP[62]);
- refresh ();
- scanz ("%d", &item);
- switch (item)
- {
- case 1:
- TCmoves = 60;
- TCminutes = 5;
- break;
- case 2:
- TCmoves = 60;
- TCminutes = 15;
- break;
- case 3:
- TCmoves = 60;
- TCminutes = 30;
- break;
- case 4:
- TCmoves = 40;
- TCminutes = 30;
- break;
- case 5:
- TCmoves = 40;
- TCminutes = 60;
- break;
- case 6:
- TCmoves = 40;
- TCminutes = 120;
- break;
- case 7:
- TCmoves = 40;
- TCminutes = 240;
- break;
- case 8:
- TCmoves = 1;
- TCminutes = 15;
- break;
- case 9:
- TCmoves = 1;
- TCminutes = 60;
- break;
- case 10:
- TCmoves = 1;
- TCminutes = 600;
- break;
- }
- TCflag = (TCmoves > 0);
- ResetTimeControl ();
- ClrScreen ();
- UpdateDisplay (0, 0, 1, 0);
- }
-
- void
- DoDebug (void)
- {
- #ifdef REALLY_DEBUG
- short c, p, sq, tp, tc, tsq, score;
- char s[40];
-
- ExaminePosition ();
- ShowMessage (CP[65]);
- scanz ("%s", s);
- c = neutral;
- if (s[0] == CP[9][0] || s[0] == CP[9][1]) /* w W*/ c = white;
- if (s[0] == CP[9][2] || s[0] == CP[9][3]) /*b B*/ c = black;
- for (p = king; p > no_piece; p--)
- if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
- if(p > no_piece)
- for (sq = 0; sq < 64; sq++)
- {
- tp = board[sq];
- tc = color[sq];
- board[sq] = p;
- color[sq] = c;
- tsq = PieceList[c][1];
- PieceList[c][1] = sq;
- ShowPostnValue (sq);
- PieceList[c][1] = tsq;
- board[sq] = tp;
- color[sq] = tc;
- }
- score = ScorePosition (opponent);
- gotoXY (TAB, 5);
- printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
- ClrEoln ();
- #endif
- }
-
- void
- DoTable (short table[64])
- {
- #ifdef REALLY_DEBUG
- short sq;
- ExaminePosition ();
- attron(BOARD_FOREGROUND);
- for (sq=0;sq<64;sq++){
-
- gotoXY (VcoordR (sq, 2, 1));
- if (!Vblack (sq) && !flag.shade)
- OReverse ();
-
- printz ("%3d", table[sq]);
- ONormal ();
- attron(TEXT_FOREGROUND);
- }
- #endif
- }
-
-