X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcursesdsp.c;h=5d33790ad9901abcdcdfa70c278335519f2d89a6;hb=b1b9616a3147b835beaabfaaa8f2de0db6d12ee9;hp=d8d73914b904bd5425e0a7d604ee51b4563c1826;hpb=8ae7e7d1b257ef36d8a9fd1cd88807954ef10764;p=gnushogi.git
diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c
index d8d7391..5d33790 100644
--- a/gnushogi/cursesdsp.c
+++ b/gnushogi/cursesdsp.c
@@ -6,6 +6,7 @@
* ----------------------------------------------------------------------
* Copyright (c) 1993, 1994, 1995 Matthias Mutz
* Copyright (c) 1999 Michael Vanier and the Free Software Foundation
+ * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
*
* GNU SHOGI is based on GNU CHESS
*
@@ -14,24 +15,29 @@
*
* This file is part of GNU SHOGI.
*
- * GNU Shogi 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 1, or (at your option)
- * any later version.
+ * GNU Shogi 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 3 of the License,
+ * or (at your option) any later version.
*
- * GNU Shogi 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.
+ * GNU Shogi 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 Shogi; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with GNU Shogi; see the file COPYING. If not, see
+ * .
+ * ----------------------------------------------------------------------
*/
+/* request *snprintf prototypes*/
+#define _POSIX_C_SOURCE 200112L
#include
#include
+#include
+#include
#include
#include
@@ -39,32 +45,45 @@
#include
#include "gnushogi.h"
-#include "cursesdsp.h"
-#define FLUSH_SCANW fflush(stdout), scanw
+#if HAVE_UNISTD_H
+#include
+#endif
-int mycnt1, mycnt2;
+#if HAVE_SYS_FILIO_H
+/* Definition of FIONREAD */
+#include
+#endif
-#define TAB (58)
+#if HAVE_ERRNO_H
+/* Definition of errno(). */
+#include
+#endif
-#define VIR_C(s) ((flag.reverse) ? (8 - column(s)) : column(s))
-#define VIR_R(s) ((flag.reverse) ? (8 - row(s)) : row(s))
+#define FLUSH_SCANW fflush(stdout), scanw
-unsigned short MV[MAXDEPTH];
-int MSCORE;
-char *DRAW;
+#define TAB (58)
-/* Forward declarations. */
-/* FIXME: change this name, puh-leeze! */
+#define VIR_C(s) ((flag.reverse) ? (NO_COLS - 1 - column(s)) : column(s))
+#define VIR_R(s) ((flag.reverse) ? (NO_ROWS - 1 - row(s)) : row(s))
-static void UpdateCatched();
+/****************************************
+ * forward declarations
+ ****************************************/
+/* FIXME: change this name, puh-leeze! */
+static void UpdateCatched(void);
+static void DrawPiece(short sq);
+static void ShowScore(short score);
+void Curses_UpdateDisplay(short f, short t, short redraw, short isspec);
+void Curses_Die(int sig);
+void Curses_ShowSidetoMove(void);
/****************************************
* Trivial output functions.
****************************************/
-void
+static void
ClearEoln(void)
{
clrtoeol();
@@ -80,16 +99,7 @@ Curses_ClearScreen(void)
}
-void
-ClearMessage(void)
-{
- gotoXY(TAB, 6);
- ClearEoln();
-}
-
-
-
-void
+static void
gotoXY(short x, short y)
{
move(y - 1, x - 1);
@@ -109,7 +119,7 @@ void
Curses_ShowDepth(char ch)
{
gotoXY(TAB, 4);
- printw(CP[53], Sdepth, ch); /* Depth = %d%c */
+ printw("Depth= %d%c ", Sdepth, ch);
ClearEoln();
}
@@ -129,7 +139,7 @@ void
ShowHeader(void)
{
gotoXY(TAB, 2);
- printw(CP[69], version, patchlevel);
+ printw("GNU Shogi %s", PACKAGE_VERSION);
}
@@ -149,10 +159,49 @@ Curses_ShowMessage(char *s)
void
-ShowNodeCnt(long NodeCnt)
+Curses_AlwaysShowMessage(const char *format, ...)
+{
+ static char buffer[60];
+ va_list ap;
+ va_start(ap, format);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
+ Curses_ShowMessage(buffer);
+ va_end(ap);
+}
+
+
+void
+Curses_Printf(const char *format, ...)
+{
+ static char buffer[60];
+ va_list ap;
+ va_start(ap, format);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
+ printw("%s", buffer);
+ va_end(ap);
+}
+
+
+void
+Curses_doRequestInputString(const char* fmt, char* buffer)
+{
+ FLUSH_SCANW(fmt, buffer);
+}
+
+
+int
+Curses_GetString(char* sx)
+{
+ fflush(stdout);
+ return (getstr(sx) == ERR);
+}
+
+
+void
+Curses_ShowNodeCnt(long NodeCnt)
{
gotoXY(TAB, 22);
- /* printw(CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0); */
+ /* printw("Nodes = %8ld, Nodes/Sec = %5ld", NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0); */
printw("n = %ld n/s = %ld",
NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
ClearEoln();
@@ -164,7 +213,7 @@ Curses_ShowPatternCount(short side, short n)
{
if (flag.post)
{
- gotoXY(TAB + 10 + 3 * side, 20);
+ gotoXY(TAB + 10 + 3 * side, 20); /* CHECKME */
if (n >= 0)
printw("%3d", n);
@@ -174,21 +223,22 @@ Curses_ShowPatternCount(short side, short n)
}
-void
+static void
ShowPlayers(void)
{
- gotoXY(5, ((flag.reverse) ? 23 : 2));
- printw("%s", (computer == white) ? CP[218] : CP[74]);
- gotoXY(5, ((flag.reverse) ? 2 : 23));
- printw("%s", (computer == black) ? CP[218] : CP[74]);
+ gotoXY(5, ((flag.reverse) ? (5 + 2*NO_ROWS) : 2));
+ printw("%s", (computer == white) ? "Computer" : "Human ");
+ gotoXY(5, ((flag.reverse) ? 2 : (5 + 2*NO_ROWS)));
+ printw("%s", (computer == black) ? "Computer" : "Human ");
}
void
-ShowPrompt(void)
+Curses_ShowPrompt(void)
{
+ Curses_ShowSidetoMove();
gotoXY(TAB, 17);
- printw(CP[121]); /* Your move is? */
+ printw("Your move is? ");
ClearEoln();
}
@@ -200,8 +250,6 @@ Curses_ShowResponseTime(void)
{
short TCC = TCcount;
gotoXY(TAB, 21);
- /* printw("RT = %ld TCC = %d TCL = %ld EX = %ld ET = %ld TO = %d",
- ResponseTime, TCC, TCleft, ExtraTime, et, flag.timeout); */
printw("%ld, %d, %ld, %ld, %ld, %d",
ResponseTime, TCC, TCleft, ExtraTime, et, flag.timeout);
ClearEoln();
@@ -244,11 +292,11 @@ Curses_ShowResults(short score, unsigned short *bstline, char ch)
}
-void
+static void
ShowScore(short score)
{
gotoXY(TAB, 5);
- printw(CP[104], score);
+ printw("Score= %d", score);
ClearEoln();
}
@@ -271,12 +319,10 @@ Curses_ShowStage(void)
ClearEoln();
}
-
/****************************************
* End of trivial output routines.
****************************************/
-
void
Curses_Initialize(void)
{
@@ -303,7 +349,6 @@ Curses_ExitShogi(void)
}
-
void
Curses_Die(int sig)
{
@@ -312,10 +357,10 @@ Curses_Die(int sig)
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- Curses_ShowMessage(CP[31]); /* Abort? */
+ Curses_ShowMessage("Abort? ");
FLUSH_SCANW("%s", s);
- if (strcmp(s, CP[210]) == 0) /* yes */
+ if (strcmp(s, "yes") == 0)
Curses_ExitShogi();
signal(SIGINT, Curses_Die);
@@ -323,7 +368,6 @@ Curses_Die(int sig)
}
-
void
Curses_TerminateSearch(int sig)
{
@@ -340,81 +384,48 @@ Curses_TerminateSearch(int sig)
}
-
void
Curses_help(void)
{
Curses_ClearScreen();
- /* printw("GNU Shogi ??p? command summary\n"); */
- printw(CP[40], version, patchlevel);
+ printw("GNU Shogi %s command summary\n", PACKAGE_VERSION);
printw("-------------------------------"
"---------------------------------\n");
- /* printw("7g7f move from 7g to 7f quit
- * Exit Shogi\n"); */
- printw(CP[158]);
- /* printw("S6h move silver to 6h beep
- * turn %s\n", (flag.beep) ? "off" : "on"); */
- printw(CP[86], (flag.beep) ? CP[92] : CP[93]);
- /* printw("2d2c+ move to 2c and promote\n"); */
- printw(CP[128], (flag.material) ? CP[92] : CP[93]);
- /* printw("P*5e drop a pawn to 5e easy
- * turn %s\n", (flag.easy) ? "off" : "on"); */
- printw(CP[173], (flag.easy) ? CP[92] : CP[93]);
- /* printw(" hash
- * turn %s\n", (flag.hash) ? "off" : "on"); */
- printw(CP[174], (flag.hash) ? CP[92] : CP[93]);
- /* printw("bd redraw board reverse
- * board display\n"); */
- printw(CP[130]);
- /* printw("list game to shogi.lst book
- * turn %s used %d of %d\n", (Book) ? "off" : "on", book
- count, booksize); */
- printw(CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
- /* printw("undo undo last ply remove
- * take back a move\n"); */
- printw(CP[200]);
- /* printw("edit edit board force
- * enter game moves\n"); */
- printw(CP[153]);
- /* printw("switch sides with computer both
- * computer match\n"); */
- printw(CP[194]);
- /* printw("black computer plays black white
- * computer plays white\n"); */
- printw(CP[202]);
- /* printw("depth set search depth clock
- * set time control\n"); */
- printw(CP[149]);
- /* printw("hint suggest a move post
- * turn %s principle variation\n", (flag.post) ? "off" :
- * "on"); */
- printw(CP[177], (flag.post) ? CP[92] : CP[93]);
- /* printw("save game to file get
- * game from file\n"); */
- printw(CP[188]);
- /* printw("random randomize play new
- * start new game\n"); */
- printw(CP[181]);
+ printw("7g7f move from 7g to 7f quit Exit Shogi\n");
+ printw("S6h move silver to 6h beep turn %s\n", (flag.beep) ? "OFF" : "ON");
+ printw("2d2c+ move to 2c and promote material turn %s\n", (flag.material) ? "OFF" : "ON");
+ printw("P*5e drop pawn to 5e easy turn %s\n", (flag.easy) ? "OFF" : "ON");
+ printw("tsume toggle tsume mode hash turn %s\n", (flag.hash) ? "OFF" : "ON");
+ printw("bd redraw board reverse board display\n");
+ printw("list game to shogi.lst book turn %s used %d of %d\n", (Book) ? "OFF" : "ON", bookcount, BOOKSIZE);
+ printw("undo undo last ply remove take back a move\n");
+ printw("edit edit board force toggle manual move mode\n");
+ printw("switch sides with computer both computer match\n");
+ printw("black computer plays black white computer plays white\n");
+ printw("depth set search depth clock set time control\n");
+ printw("post principle variation hint suggest a move\n", (flag.post) ? "OFF" : "ON");
+ printw("save game to file get game from file\n");
+ printw("random randomize play new start new game\n");
gotoXY(10, 20);
- printw(CP[47], ColorStr[computer]);
+ printw("Computer: %s", ColorStr[computer]);
gotoXY(10, 21);
- printw(CP[97], ColorStr[opponent]);
+ printw("Opponent: %s", ColorStr[opponent]);
gotoXY(10, 22);
- printw(CP[79], MaxResponseTime/100);
+ printw("Level: %ld", MaxResponseTime/100);
gotoXY(10, 23);
- printw(CP[59], (flag.easy) ? CP[93] : CP[92]);
+ printw("Easy mode: %s", (flag.easy) ? "ON" : "OFF");
gotoXY(25, 23);
- printw(CP[231], (flag.tsume) ? CP[93] : CP[92]);
+ printw("Tsume: %s", (flag.tsume) ? "ON" : "OFF");
gotoXY(40, 20);
- printw(CP[52], MaxSearchDepth);
+ printw("Depth: %d", MaxSearchDepth);
gotoXY(40, 21);
- printw(CP[100], (dither) ? CP[93] : CP[92]);
+ printw("Random: %s", (dither) ? "ON" : "OFF");
gotoXY(40, 22);
- printw(CP[112], (flag.hash) ? CP[93] : CP[92]);
+ printw("Transposition table: %s", (flag.hash) ? "ON" : "OFF");
gotoXY(40, 23);
- printw(CP[73]);
+ printw("Hit to return: ");
gotoXY(10, 24);
- printw(CP[110], (TCflag) ? CP[93] : CP[92],
+ printw("Time Control %s %d moves %d sec %d add %d depth\n", (TCflag) ? "ON" : "OFF",
TimeControl.moves[black],
TimeControl.clock[black] / 100,
OperatorTime, MaxSearchDepth);
@@ -453,24 +464,24 @@ Curses_EditBoard(void)
Curses_ClearScreen();
Curses_UpdateDisplay(0, 0, 1, 0);
gotoXY(TAB, 3);
- printw(CP[29]);
+ printw(". Exit to main\n");
gotoXY(TAB, 4);
- printw(CP[28]);
+ printw("# Clear board\n");
gotoXY(TAB, 5);
- printw(CP[136]);
+ printw("c Change sides\n");
gotoXY(TAB, 7);
- printw(CP[64]);
+ printw("Enter piece & location: ");
a = black;
do
{
gotoXY(TAB, 6);
- printw(CP[60], ColorStr[a]); /* Editing %s */
+ printw("Editing: %s", ColorStr[a]);
gotoXY(TAB + 24, 7);
ClearEoln();
FLUSH_SCANW("%s", s);
- if (s[0] == CP[28][0]) /* # */
+ if (s[0] == '#')
{
for (sq = 0; sq < NO_SQUARES; sq++)
{
@@ -483,7 +494,7 @@ Curses_EditBoard(void)
UpdateCatched();
}
- if (s[0] == CP[136][0]) /* c */
+ if (s[0] == 'c')
a = otherside[a];
if (s[1] == '*')
@@ -500,8 +511,8 @@ Curses_EditBoard(void)
}
else
{
- c = '9' - s[1];
- r = 'i' - s[2];
+ c = COL_NAME(s[1]);
+ r = ROW_NAME(s[2]);
}
if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
@@ -524,7 +535,7 @@ Curses_EditBoard(void)
DrawPiece(sq);
}
}
- while (s[0] != CP[29][0]); /* . */
+ while (s[0] != '.');
for (sq = 0; sq < NO_SQUARES; sq++)
Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
@@ -539,7 +550,6 @@ Curses_EditBoard(void)
}
-
static void
UpdateCatched()
{
@@ -591,7 +601,6 @@ UpdateCatched()
}
-
void
Curses_SearchStartStuff(short side)
{
@@ -600,7 +609,7 @@ Curses_SearchStartStuff(short side)
signal(SIGINT, Curses_TerminateSearch);
signal(SIGQUIT, Curses_TerminateSearch);
- for (i = 4; i < 14; i++)
+ for (i = 4; i < 14; i++) /* CHECKME */
{
gotoXY(TAB, i);
ClearEoln();
@@ -608,7 +617,6 @@ Curses_SearchStartStuff(short side)
}
-
void
Curses_OutputMove(void)
{
@@ -618,11 +626,11 @@ Curses_OutputMove(void)
if (flag.illegal)
{
- printw(CP[225]);
+ printw("Illegal position.");
return;
}
- printw(CP[84], mvstr[0]); /* My move is %s */
+ printw("My move is: %5s", mvstr[0]);
if (flag.beep)
putchar(7);
@@ -632,16 +640,16 @@ Curses_OutputMove(void)
gotoXY(TAB, 18);
if (root->flags & draw)
- printw(CP[58]);
+ printw("Drawn game!");
else if (root->score == -(SCORE_LIMIT + 999))
- printw(CP[95]);
+ printw("Opponent mates!");
else if (root->score == SCORE_LIMIT + 998)
- printw(CP[44]);
+ printw("Computer mates!");
#ifdef VERYBUGGY
else if (root->score < -SCORE_LIMIT)
- printw(CP[96], SCORE_LIMIT + 999 + root->score - 1);
+ printw("Opp: mate in %d!", SCORE_LIMIT + 999 + root->score - 1);
else if (root->score > SCORE_LIMIT)
- printw(CP[45], SCORE_LIMIT + 998 - root->score - 1);
+ printw("Comp: mate in %d!", SCORE_LIMIT + 998 - root->score - 1);
#endif /* VERYBUGGY */
ClearEoln();
@@ -664,9 +672,9 @@ Curses_OutputMove(void)
t = (l + h) >> 1;
}
- ShowNodeCnt(NodeCnt);
+ Curses_ShowNodeCnt(NodeCnt);
gotoXY(TAB, 23);
- printw(CP[81], t); /* Max Tree= */
+ printw("Max Tree = %5d", t);
ClearEoln();
}
@@ -674,9 +682,8 @@ Curses_OutputMove(void)
}
-
void
-UpdateClocks(void)
+Curses_UpdateClocks(void)
{
short m, s;
long dt;
@@ -707,14 +714,13 @@ UpdateClocks(void)
printw("%d:%02d ", m, s);
if (flag.post)
- ShowNodeCnt(NodeCnt);
+ Curses_ShowNodeCnt(NodeCnt);
refresh();
}
-
-void
+static void
DrawPiece(short sq)
{
char y;
@@ -747,24 +753,19 @@ DrawPiece(short sq)
y = pxx[(int)piece];
}
- gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * (8 - VIR_R(sq)));
+ gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * ((NO_ROWS - 1) - VIR_R(sq)));
printw("%c%c%c%c", l, p, y, r);
}
-
-
/*
* Curses_ShowPostnValue(): must have called ExaminePosition() first
*/
-
void
Curses_ShowPostnValue(short sq)
{
- short score;
-
- gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq)));
- score = ScorePosition(color[sq]);
+ gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); /* CHECKME */
+ (void) ScorePosition(color[sq]);
if (color[sq] != neutral)
#if defined SAVE_SVALUE
@@ -783,7 +784,6 @@ Curses_ShowPostnValue(short sq)
}
-
void
Curses_ShowPostnValues(void)
{
@@ -796,7 +796,7 @@ Curses_ShowPostnValues(void)
score = ScorePosition(opponent);
gotoXY(TAB, 5);
- printw(CP[103], score,
+ printw("S%d m%d ps%d gt%c m%d ps%d gt%c", score,
mtl[computer], pscore[computer], GameType[computer],
mtl[opponent], pscore[opponent], GameType[opponent]);
@@ -804,11 +804,11 @@ Curses_ShowPostnValues(void)
}
-
void
Curses_UpdateDisplay(short f, short t, short redraw, short isspec)
{
short i, sq, z;
+ int j;
if (redraw)
{
@@ -818,37 +818,51 @@ Curses_UpdateDisplay(short f, short t, short redraw, short isspec)
i = 2;
gotoXY(3, ++i);
- printw(" +----+----+----+----+----+----+----+----+----+");
+ printw(" +");
+ for (j=0; j> 8), (short) (hint & 0xFF), false);
- strcpy(s, CP[198]); /* try */
+ strcpy(s, "try ");
strcat(s, mvstr[0]);
Curses_ShowMessage(s);
}
else
{
- Curses_ShowMessage(CP[223]);
+ Curses_ShowMessage("I have no idea.\n");
}
}
-
void
-Curses_ChangeSearchDepth(void)
+Curses_ChangeSearchDepth(char* sx)
{
- Curses_ShowMessage(CP[150]);
+ Curses_ShowMessage("depth = ");
FLUSH_SCANW("%hd", &MaxSearchDepth);
TCflag = !(MaxSearchDepth > 0);
}
@@ -965,9 +973,9 @@ Curses_ChangeSearchDepth(void)
void
Curses_ChangeHashDepth(void)
{
- Curses_ShowMessage(CP[163]);
+ Curses_ShowMessage("hashdepth = ");
FLUSH_SCANW("%hd", &HashDepth);
- Curses_ShowMessage(CP[82]);
+ Curses_ShowMessage("MoveLimit = ");
FLUSH_SCANW("%hd", &HashMoveLimit);
}
@@ -975,21 +983,19 @@ Curses_ChangeHashDepth(void)
void
Curses_SetContempt(void)
{
- Curses_ShowMessage(CP[142]);
+ Curses_ShowMessage("contempt = ");
FLUSH_SCANW("%hd", &contempt);
}
-
void
Curses_ChangeXwindow(void)
{
- Curses_ShowMessage(CP[208]);
+ Curses_ShowMessage("xwndw= ");
FLUSH_SCANW("%hd", &xwndw);
}
-
void
Curses_SelectLevel(char *sx)
{
@@ -997,27 +1003,27 @@ Curses_SelectLevel(char *sx)
Curses_ClearScreen();
gotoXY(32, 2);
- printw(CP[41], version, patchlevel);
+ printw("GNU Shogi %s", PACKAGE_VERSION);
gotoXY(20, 4);
- printw(CP[18]);
+ printw(" 1. 40 moves in 5 minutes");
gotoXY(20, 5);
- printw(CP[19]);
+ printw(" 2. 40 moves in 15 minutes");
gotoXY(20, 6);
- printw(CP[20]);
+ printw(" 3. 40 moves in 30 minutes");
gotoXY(20, 7);
- printw(CP[21]);
+ printw(" 4. all moves in 15 minutes");
gotoXY(20, 8);
- printw(CP[22]);
+ printw(" 5. all moves in 30 minutes");
gotoXY(20, 9);
- printw(CP[23]);
+ printw(" 6. all moves in 15 minutes, 30 seconds fischer clock");
gotoXY(20, 10);
- printw(CP[24]);
+ printw(" 7. all moves in 30 minutes, 30 seconds fischer clock");
gotoXY(20, 11);
- printw(CP[25]);
+ printw(" 8. 1 move in 1 minute");
gotoXY(20, 12);
- printw(CP[26]);
+ printw(" 9. 1 move in 15 minutes");
gotoXY(20, 13);
- printw(CP[27]);
+ printw("10. 1 move in 30 minutes");
OperatorTime = 0;
TCmoves = 40;
@@ -1025,7 +1031,7 @@ Curses_SelectLevel(char *sx)
TCseconds = 0;
gotoXY(20, 17);
- printw(CP[62]);
+ printw("Enter Level: ");
refresh();
FLUSH_SCANW("%d", &item);
@@ -1100,7 +1106,6 @@ Curses_SelectLevel(char *sx)
}
-
void
Curses_DoDebug(void)
{
@@ -1108,14 +1113,14 @@ Curses_DoDebug(void)
char s[40];
ExaminePosition(opponent);
- Curses_ShowMessage(CP[65]);
+ Curses_ShowMessage("Enter piece: ");
FLUSH_SCANW("%s", s);
c = neutral;
- if ((s[0] == CP[9][0]) || (s[0] == CP[9][1])) /* b B */
+ if ((s[0] == 'b') || (s[0] == 'B'))
c = black;
- if ((s[0] == CP[9][2]) || (s[0] == CP[9][3])) /* w W */
+ if ((s[0] == 'w') || (s[0] == 'W'))
c = white;
for (p = king; p > no_piece; p--)
@@ -1140,7 +1145,7 @@ Curses_DoDebug(void)
score = ScorePosition(opponent);
gotoXY(TAB, 5);
- printw(CP[103], score,
+ printw("S%d m%d ps%d gt%c m%d ps%d gt%c", score,
mtl[computer], pscore[computer], GameType[computer],
mtl[opponent], pscore[opponent], GameType[opponent]);
@@ -1148,7 +1153,6 @@ Curses_DoDebug(void)
}
-
void
Curses_DoTable(short table[NO_SQUARES])
{
@@ -1163,4 +1167,79 @@ Curses_DoTable(short table[NO_SQUARES])
}
+void
+Curses_PollForInput(void)
+{
+ int i;
+ int nchar;
+
+ if ((i = ioctl((int) 0, FIONREAD, &nchar)))
+ {
+ perror("FIONREAD");
+ fprintf(stderr,
+ "You probably have a non-ANSI ; "
+ "see README. %d %d %x\n",
+ i, errno, FIONREAD);
+ exit(1);
+ }
+
+ if (nchar)
+ {
+ if (!flag.timeout)
+ flag.back = true;
+
+ flag.bothsides = false;
+ }
+}
+
+void
+Curses_SetupBoard(void)
+{
+ Curses_ShowMessage("'setup' command is not supported in Cursesmode");
+}
+
+
+struct display curses_display =
+{
+ .ChangeAlphaWindow = Curses_ChangeAlphaWindow,
+ .ChangeBetaWindow = Curses_ChangeBetaWindow,
+ .ChangeHashDepth = Curses_ChangeHashDepth,
+ .ChangeSearchDepth = Curses_ChangeSearchDepth,
+ .ChangeXwindow = Curses_ChangeXwindow,
+ .ClearScreen = Curses_ClearScreen,
+ .DoDebug = Curses_DoDebug,
+ .DoTable = Curses_DoTable,
+ .EditBoard = Curses_EditBoard,
+ .ExitShogi = Curses_ExitShogi,
+ .GiveHint = Curses_GiveHint,
+ .Initialize = Curses_Initialize,
+ .ShowNodeCnt = Curses_ShowNodeCnt,
+ .OutputMove = Curses_OutputMove,
+ .PollForInput = Curses_PollForInput,
+ .SetContempt = Curses_SetContempt,
+ .SearchStartStuff = Curses_SearchStartStuff,
+ .SelectLevel = Curses_SelectLevel,
+ .ShowCurrentMove = Curses_ShowCurrentMove,
+ .ShowDepth = Curses_ShowDepth,
+ .ShowGameType = Curses_ShowGameType,
+ .ShowLine = Curses_ShowLine,
+ .ShowMessage = Curses_ShowMessage,
+ .AlwaysShowMessage = Curses_AlwaysShowMessage,
+ .Printf = Curses_Printf,
+ .doRequestInputString = Curses_doRequestInputString,
+ .GetString = Curses_GetString,
+ .SetupBoard = Curses_SetupBoard,
+ .ShowPatternCount = Curses_ShowPatternCount,
+ .ShowPostnValue = Curses_ShowPostnValue,
+ .ShowPostnValues = Curses_ShowPostnValues,
+ .ShowPrompt = Curses_ShowPrompt,
+ .ShowResponseTime = Curses_ShowResponseTime,
+ .ShowResults = Curses_ShowResults,
+ .ShowSidetoMove = Curses_ShowSidetoMove,
+ .ShowStage = Curses_ShowStage,
+ .TerminateSearch = Curses_TerminateSearch,
+ .UpdateClocks = Curses_UpdateClocks,
+ .UpdateDisplay = Curses_UpdateDisplay,
+ .help = Curses_help,
+};