From: Yann Dirson Date: Wed, 6 Nov 2013 21:33:03 +0000 (+0100) Subject: Switch display-selection framework from dspwrappers to "struct display". X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=9da823015c78c8e9131cf76f14598a1071d29192;p=gnushogi.git Switch display-selection framework from dspwrappers to "struct display". Much easier to write, will allow to correctly separate raw from xshogi, to add proper xboard support, etc. --- diff --git a/gnushogi/Makefile.in b/gnushogi/Makefile.in index b4c3932..1da5643 100644 --- a/gnushogi/Makefile.in +++ b/gnushogi/Makefile.in @@ -115,7 +115,6 @@ NOTCOMMONFILES = \ book.o \ commondsp.o \ @CURSESDSP@ \ - dspwrappers.o \ eval.o \ genmove.o \ init.o \ @@ -165,9 +164,6 @@ commondsp.o: commondsp.c cursesdsp.o: cursesdsp.c $(CC) $(CFLAGS) -c $< -dspwrappers.o: dspwrappers.c - $(CC) $(CFLAGS) -c $< - genmove.o: genmove.c $(CC) $(CFLAGS) -c $< @@ -274,11 +270,11 @@ attacks.o: attacks.c gnushogi.h book.o: book.c gnushogi.h commondsp.o: commondsp.c gnushogi.h cursesdsp.o: cursesdsp.c gnushogi.h -dspwrappers.o: dspwrappers.c gnushogi.h genmove.o: genmove.c gnushogi.h globals.o: globals.c gnushogi.h eval.o: eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h init.o: init.c gnushogi.h $(SRCDIR)/pattern.h +init-common.o: init-common.c gnushogi.h main.o: main.c gnushogi.h makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc diff --git a/gnushogi/book.c b/gnushogi/book.c index ae3956f..727ae55 100644 --- a/gnushogi/book.c +++ b/gnushogi/book.c @@ -876,7 +876,7 @@ GetOpenings(void) } sprintf(msg, "Book used %d(%d).", B.bookcount, B.booksize); - ShowMessage(msg); + dsp->ShowMessage(msg); } /* Set everything back to start the game. */ @@ -886,7 +886,7 @@ GetOpenings(void) /* Now get ready to play .*/ if (!B.bookcount) { - ShowMessage("Can't find book."); + dsp->ShowMessage("Can't find book."); Book = 0; } } diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 8750fcd..a5a3b42 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -47,6 +47,7 @@ char mvstr[4][6]; char *InPtr; int InBackground = false; +struct display *dsp = &raw_display; #if defined(BOOKTEST) @@ -164,7 +165,7 @@ algbr(short f, short t, short flag) if ((f == t) && ((f != 0) || (t != 0))) { if (!barebones) { - Printf("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); + dsp->Printf("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); } mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = '\0'; @@ -297,7 +298,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) if (SqAttacked(PieceList[opponent][0], computer, &blocked)) { UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); - AlwaysShowMessage("Illegal move (in check) %s", s); + dsp->AlwaysShowMessage("Illegal move (in check) %s", s); return false; } else @@ -305,7 +306,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) if (iop == VERIFY_AND_TRY_MODE) return true; - UpdateDisplay(xnode.f, xnode.t, 0, (short) xnode.flags); + dsp->UpdateDisplay(xnode.f, xnode.t, 0, (short) xnode.flags); GameList[GameCnt].depth = GameList[GameCnt].score = 0; GameList[GameCnt].nodes = 0; ElapsedTime(COMPUTE_AND_INIT_MODE); @@ -330,7 +331,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) char buf[20]; sprintf(buf, "%s mates!\n", ColorStr[opponent]); - ShowMessage(buf); + dsp->ShowMessage(buf); flag.mate = true; } } @@ -339,12 +340,12 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) } } - AlwaysShowMessage("Illegal move (no match) %s", s); + dsp->AlwaysShowMessage("Illegal move (no match) %s", s); if (!barebones && (cnt > 1)) { sprintf(buffer, "Ambiguous Move %s!", s); - ShowMessage(buffer); + dsp->ShowMessage(buffer); } return false; @@ -410,6 +411,23 @@ skipb() } +void RequestInputString(char* buffer, unsigned bufsize) +{ + static char fmt[10]; + int ret = snprintf(fmt, sizeof(fmt), "%%%us", bufsize); + if (ret < 0 ) { + perror("RequestInputString snprintf"); + exit(1); + } + if (ret >= sizeof(fmt)) { + fprintf(stderr, + "Insufficient format-buffer size in %s for bufsize=%u\n", + __FUNCTION__, bufsize); + exit(1); + } + dsp->doRequestInputString(fmt, buffer); +} + void GetGame(void) @@ -423,7 +441,7 @@ GetGame(void) if (savefile[0]) { strcpy(fname, savefile); } else { - ShowMessage("Enter file name: "); + dsp->ShowMessage("Enter file name: "); RequestInputString(fname, sizeof(fname)-1); } @@ -628,7 +646,7 @@ GetGame(void) ZeroRPT(); InitializeStats(); - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); Sdepth = 0; hint = 0; } @@ -648,7 +666,7 @@ SaveGame(void) if (savefile[0]) { strcpy(fname, savefile); } else { - ShowMessage("Enter file name: "); + dsp->ShowMessage("Enter file name: "); RequestInputString(fname, sizeof(fname)-1); } @@ -773,11 +791,11 @@ SaveGame(void) fclose(fd); - ShowMessage("Game saved"); + dsp->ShowMessage("Game saved"); } else { - ShowMessage("Could not open file"); + dsp->ShowMessage("Could not open file"); } } @@ -797,7 +815,7 @@ GetXGame(void) short sq; short side, isp; - ShowMessage("Enter file name: "); + dsp->ShowMessage("Enter file name: "); RequestInputString(fname, sizeof(fname)-1); if (fname[0] == '\0') @@ -911,7 +929,7 @@ GetXGame(void) Game50 = 1; ZeroRPT(); InitializeStats(); - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); Sdepth = 0; hint = 0; } @@ -926,7 +944,7 @@ SaveXGame(void) short sq, piece; short side, isp; - ShowMessage("Enter file name: "); + dsp->ShowMessage("Enter file name: "); RequestInputString(fname, sizeof(fname)-1); if (fname[0] == '\0') @@ -1008,7 +1026,7 @@ BookSave(void) strcpy(fname, savefile); } else { /* Enter file name */ - ShowMessage("Enter file name: "); + dsp->ShowMessage("Enter file name: "); RequestInputString(fname, sizeof(fname)-1); } @@ -1080,11 +1098,11 @@ BookSave(void) fclose(fd); - ShowMessage("Game saved"); + dsp->ShowMessage("Game saved"); } else { - ShowMessage("Could not open file"); + dsp->ShowMessage("Could not open file"); } } @@ -1295,8 +1313,8 @@ Undo(void) flag.mate = false; Sdepth = 0; player = player ^ 1; - ShowSidetoMove(); - UpdateDisplay(0, 0, 1, 0); + dsp->ShowSidetoMove(); + dsp->UpdateDisplay(0, 0, 1, 0); if (flag.regularstart) Book = false; @@ -1407,7 +1425,7 @@ TestSpeed(void(*f)(short side, short ply, else et = 1; - ShowNodeCnt(cnt); + dsp->ShowNodeCnt(cnt); } @@ -1445,7 +1463,7 @@ TestPSpeed(short(*f) (short side), unsigned j) else et = 1; - ShowNodeCnt(cnt); + dsp->ShowNodeCnt(cnt); } @@ -1565,7 +1583,7 @@ InputCommand(char *command) #if !defined NOPOST if (flag.post) - GiveHint(); + dsp->GiveHint(); #endif /* do the hint move */ @@ -1574,7 +1592,7 @@ InputCommand(char *command) Sdepth = 0; #ifdef QUIETBACKGROUND - ShowPrompt(); + dsp->ShowPrompt(); have_shown_prompt = true; #endif /* QUIETBACKGROUND */ @@ -1621,7 +1639,7 @@ InputCommand(char *command) { #endif /* QUIETBACKGROUND */ - ShowPrompt(); + dsp->ShowPrompt(); #ifdef QUIETBACKGROUND } @@ -1633,7 +1651,7 @@ InputCommand(char *command) if (NOT_CURSES) s[0] = '\0'; - eof = GetString(sx); + eof = dsp->GetString(sx); } else { strcpy(sx, command); done = true; @@ -1642,7 +1660,7 @@ InputCommand(char *command) sscanf(sx, "%s", s); if (eof) - ExitShogi(); + dsp->ExitShogi(); if (s[0] == '\0') continue; @@ -1655,8 +1673,8 @@ InputCommand(char *command) if (old_xshogi) display_type = DISPLAY_RAW; - ClearScreen(); - UpdateDisplay(0, 0, 1, 0); + dsp->ClearScreen(); + dsp->UpdateDisplay(0, 0, 1, 0); if (old_xshogi) display_type = DISPLAY_X; @@ -1683,11 +1701,11 @@ InputCommand(char *command) else if ((strcmp(s, "set") == 0) || (strcmp(s, "edit") == 0)) { - EditBoard(); + dsp->EditBoard(); } else if ((strcmp(s, "setup") == 0)) { - SetupBoard(); + dsp->SetupBoard(); } else if (strcmp(s, "first") == 0) { @@ -1711,7 +1729,7 @@ InputCommand(char *command) } else if (strcmp(s, "help") == 0) { - help(); + dsp->help(); } else if (strcmp(s, "material") == 0) { @@ -1737,7 +1755,7 @@ InputCommand(char *command) else if (strcmp(s, "new") == 0) { NewGame(); - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); } else if (strcmp(s, "list") == 0) { @@ -1746,7 +1764,7 @@ InputCommand(char *command) else if ((strcmp(s, "level") == 0) || (strcmp(s, "clock") == 0)) { - SelectLevel(sx); + dsp->SelectLevel(sx); } else if (strcmp(s, "hash") == 0) { @@ -1770,11 +1788,11 @@ InputCommand(char *command) } else if (strcmp(s, "Awindow") == 0) { - ChangeAlphaWindow(); + dsp->ChangeAlphaWindow(); } else if (strcmp(s, "Bwindow") == 0) { - ChangeBetaWindow(); + dsp->ChangeBetaWindow(); } else if (strcmp(s, "rcptr") == 0) { @@ -1782,7 +1800,7 @@ InputCommand(char *command) } else if (strcmp(s, "hint") == 0) { - GiveHint(); + dsp->GiveHint(); } else if (strcmp(s, "both") == 0) { @@ -1796,8 +1814,8 @@ InputCommand(char *command) else if (strcmp(s, "reverse") == 0) { flag.reverse = !flag.reverse; - ClearScreen(); - UpdateDisplay(0, 0, 1, 0); + dsp->ClearScreen(); + dsp->UpdateDisplay(0, 0, 1, 0); } else if (strcmp(s, "switch") == 0) { @@ -1875,11 +1893,11 @@ InputCommand(char *command) } else if (strcmp(s, "depth") == 0) { - ChangeSearchDepth(); + dsp->ChangeSearchDepth(); } else if (strcmp(s, "hashdepth") == 0) { - ChangeHashDepth(); + dsp->ChangeHashDepth(); } else if (strcmp(s, "random") == 0) { @@ -1899,26 +1917,26 @@ InputCommand(char *command) } else if (strcmp(s, "contempt") == 0) { - SetContempt(); + dsp->SetContempt(); } else if (strcmp(s, "xwndw") == 0) { - ChangeXwindow(); + dsp->ChangeXwindow(); } else if (strcmp(s, "rv") == 0) { flag.rv = !flag.rv; - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); } else if (strcmp(s, "coords") == 0) { flag.coords = !flag.coords; - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); } else if (strcmp(s, "stars") == 0) { flag.stars = !flag.stars; - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); } else if (!XSHOGI && strcmp(s, "moves") == 0) { @@ -1936,44 +1954,44 @@ InputCommand(char *command) #endif SwagHt = 0; - ShowMessage("Testing MoveList Speed"); + dsp->ShowMessage("Testing MoveList Speed"); temp = generate_move_flags; generate_move_flags = true; TestSpeed(MoveList, 1); generate_move_flags = temp; - ShowMessage("Testing CaptureList Speed"); + dsp->ShowMessage("Testing CaptureList Speed"); TestSpeed(CaptureList, 1); - ShowMessage("Testing Eval Speed"); + dsp->ShowMessage("Testing Eval Speed"); ExaminePosition(opponent); TestPSpeed(ScorePosition, 1); } else if (!XSHOGI && strcmp(s, "test") == 0) { #ifdef SLOW_CPU - ShowMessage("Testing MoveList Speed"); + dsp->ShowMessage("Testing MoveList Speed"); TestSpeed(MoveList, 2000); - ShowMessage("Testing CaptureList Speed"); + dsp->ShowMessage("Testing CaptureList Speed"); TestSpeed(CaptureList, 3000); - ShowMessage("Testing Eval Speed"); + dsp->ShowMessage("Testing Eval Speed"); ExaminePosition(opponent); TestPSpeed(ScorePosition, 1500); #else - ShowMessage("Testing MoveList Speed"); + dsp->ShowMessage("Testing MoveList Speed"); TestSpeed(MoveList, 20000); - ShowMessage("Testing CaptureList Speed"); + dsp->ShowMessage("Testing CaptureList Speed"); TestSpeed(CaptureList, 30000); - ShowMessage("Testing Eval Speed"); + dsp->ShowMessage("Testing Eval Speed"); ExaminePosition(opponent); TestPSpeed(ScorePosition, 15000); #endif } else if (!XSHOGI && strcmp(s, "p") == 0) { - ShowPostnValues(); + dsp->ShowPostnValues(); } else if (!XSHOGI && strcmp(s, "debug") == 0) { - DoDebug(); + dsp->DoDebug(); } else { @@ -1989,7 +2007,7 @@ InputCommand(char *command) if (rpt >= 3) { DRAW = DRAW_REPETITION; - ShowMessage(DRAW); + dsp->ShowMessage(DRAW); GameList[GameCnt].flags |= draw; flag.mate = true; @@ -2064,4 +2082,3 @@ SetTimeControl(void) et = 0; ElapsedTime(COMPUTE_AND_INIT_MODE); } - diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 906e44d..a42bb26 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -41,7 +41,6 @@ #include #include "gnushogi.h" -#include "cursesdsp.h" #if HAVE_UNISTD_H #include @@ -70,12 +69,16 @@ unsigned short MV[MAXDEPTH]; int MSCORE; char *DRAW; -/* Forward declarations. */ -/* FIXME: change this name, puh-leeze! */ +/**************************************** + * 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); /**************************************** * Trivial output functions. @@ -165,20 +168,26 @@ Curses_ShowMessage(char *s) void -Curses_AlwaysShowMessage(const char *format, va_list ap) +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, va_list ap) +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); } @@ -672,7 +681,7 @@ Curses_OutputMove(void) t = (l + h) >> 1; } - ShowNodeCnt(NodeCnt); + Curses_ShowNodeCnt(NodeCnt); gotoXY(TAB, 23); printw("Max Tree = %5d", t); ClearEoln(); @@ -714,7 +723,7 @@ Curses_UpdateClocks(void) printw("%d:%02d ", m, s); if (flag.post) - ShowNodeCnt(NodeCnt); + Curses_ShowNodeCnt(NodeCnt); refresh(); } @@ -1200,3 +1209,48 @@ 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, +}; diff --git a/gnushogi/cursesdsp.h b/gnushogi/cursesdsp.h deleted file mode 100644 index 6f2b07e..0000000 --- a/gnushogi/cursesdsp.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * FILE: cursesdsp.h - * - * Curses interface for GNU Shogi. - * - * ---------------------------------------------------------------------- - * Copyright (c) 1993, 1994, 1995 Matthias Mutz - * Copyright (c) 1999 Michael Vanier and the Free Software Foundation - * - * GNU SHOGI is based on GNU CHESS - * - * Copyright (c) 1988, 1989, 1990 John Stanback - * Copyright (c) 1992 Free Software Foundation - * - * 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 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. - * - * You should have received a copy of the GNU General Public License along - * with GNU Shogi; see the file COPYING. If not, see - * . - * ---------------------------------------------------------------------- - * - */ - -#ifndef _CURSESDSP_H_ -#define _CURSESDSP_H_ - -#include "gnushogi.h" - -/* The following are common to rawdsp.h and cursesdsp.h */ - -void Curses_ChangeAlphaWindow(void); -void Curses_ChangeBetaWindow(void); -void Curses_ChangeHashDepth(void); -void Curses_ChangeSearchDepth(void); -void Curses_ChangeXwindow(void); -void Curses_ClearScreen(void); -void Curses_Die(int sig); -void Curses_DoDebug(void); -void Curses_DoTable(short table[NO_SQUARES]); -void Curses_EditBoard(void); -void Curses_ExitShogi(void); -void Curses_GiveHint(void); -void Curses_Initialize(void); -void Curses_ShowNodeCnt(long NodeCnt); -void Curses_OutputMove(void); -void Curses_PollForInput(void); -void Curses_SearchStartStuff(short side); -void Curses_SelectLevel(char *sx); -void Curses_SetContempt(void); -void Curses_ShowCurrentMove(short pnt, short f, short t); -void Curses_ShowDepth(char ch); -void Curses_ShowGameType(void); -void Curses_ShowLine(unsigned short *bstline); -void Curses_ShowMessage(char *s); -void Curses_AlwaysShowMessage(const char *format, va_list ap); -void Curses_Printf(const char *format, va_list ap); -void Curses_doRequestInputString(const char* fmt, char* buffer); -int Curses_GetString(char* sx); -void Curses_SetupBoard(void); -void Curses_ShowPatternCount(short side, short n); -void Curses_ShowPostnValue(short sq); -void Curses_ShowPostnValues(void); -void Curses_ShowPrompt(void); -void Curses_ShowResponseTime(void); -void Curses_ShowResults(short score, unsigned short *bstline, char ch); -void Curses_ShowSidetoMove(void); -void Curses_ShowStage(void); -void Curses_TerminateSearch(int sig); -void Curses_UpdateClocks(void); -void Curses_UpdateDisplay(short f, short t, short redraw, short isspec); -void Curses_help(void); - -#endif /* _CURSESDSP_H_ */ diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c deleted file mode 100644 index 3cdfbce..0000000 --- a/gnushogi/dspwrappers.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * FILE: dspwrappers.c - * - * Wrapper functions which call analogous functions in rawdsp.c - * or cursesdsp.c depending on the interface. - * - * ---------------------------------------------------------------------- - * Copyright (c) 1993, 1994, 1995 Matthias Mutz - * Copyright (c) 1999 Michael Vanier and the Free Software Foundation - * - * GNU SHOGI is based on GNU CHESS - * - * Copyright (c) 1988, 1989, 1990 John Stanback - * Copyright (c) 1992 Free Software Foundation - * - * 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 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. - * - * You should have received a copy of the GNU General Public License along - * with GNU Shogi; see the file COPYING. If not, see - * . - * ---------------------------------------------------------------------- - * - */ - -#include "gnushogi.h" -#include "dspwrappers.h" -#include "rawdsp.h" -#include "cursesdsp.h" - -#include - -#define CASE_DSP_RAW(func,args) \ - case DISPLAY_RAW: \ - case DISPLAY_X: \ - func args; \ - break - -#ifdef HAVE_LIBCURSES -#define CASE_DSP_CURSES(func,args) \ - case DISPLAY_CURSES: \ - func args; \ - break; -#else -#define CASE_DSP_CURSES(func,args) -#endif - -#define DISPLAY_FUNC(func,argsdecl,args) \ - void func argsdecl \ - { \ - switch (display_type) { \ - CASE_DSP_RAW(Raw_ ## func, args); \ - CASE_DSP_CURSES(Curses_ ## func, args); \ - } \ - } -#define DISPLAY_VOIDFUNC(func) \ - DISPLAY_FUNC(func,(void),()) - -#define DISPLAY_STDARGFUNC(func,argsdecl,last,args) \ - void func argsdecl \ - { \ - va_list ap; \ - va_start(ap, last); \ - switch (display_type) { \ - CASE_DSP_RAW(Raw_ ## func, args); \ - CASE_DSP_CURSES(Curses_ ## func, args); \ - } \ - va_end(ap); \ - } - -DISPLAY_VOIDFUNC(ChangeAlphaWindow) -DISPLAY_VOIDFUNC(ChangeBetaWindow) -DISPLAY_VOIDFUNC(ChangeHashDepth) -DISPLAY_VOIDFUNC(ChangeSearchDepth) -DISPLAY_VOIDFUNC(ChangeXwindow) -DISPLAY_VOIDFUNC(ClearScreen) -DISPLAY_VOIDFUNC(DoDebug) -DISPLAY_FUNC(DoTable, (short table[NO_SQUARES]), (table)) -DISPLAY_VOIDFUNC(EditBoard) -DISPLAY_VOIDFUNC(ExitShogi) -DISPLAY_VOIDFUNC(GiveHint) -DISPLAY_VOIDFUNC(Initialize) -DISPLAY_FUNC(ShowNodeCnt, (long NodeCnt), (NodeCnt)) -DISPLAY_VOIDFUNC(OutputMove) -DISPLAY_VOIDFUNC(PollForInput) -DISPLAY_VOIDFUNC(SetContempt) -DISPLAY_FUNC(SearchStartStuff, (short side), (side)) -DISPLAY_FUNC(SelectLevel, (char *sx), (sx)) -DISPLAY_VOIDFUNC(SetupBoard) -DISPLAY_FUNC(ShowCurrentMove, (short pnt, short f, short t), (pnt, f, t)) -DISPLAY_FUNC(ShowDepth, (char ch), (ch)) -DISPLAY_VOIDFUNC(ShowGameType) -DISPLAY_FUNC(ShowLine, (unsigned short *bstline), (bstline)) -DISPLAY_FUNC(ShowMessage, (char *s), (s)) -DISPLAY_STDARGFUNC(AlwaysShowMessage, (const char *format, ...), format, (format, ap)) -DISPLAY_STDARGFUNC(Printf, (const char *format, ...), format, (format, ap)) -DISPLAY_FUNC(ShowPatternCount, (short side, short n), (side, n)) -DISPLAY_FUNC(ShowPostnValue, (short sq), (sq)) -DISPLAY_VOIDFUNC(ShowPostnValues) -DISPLAY_VOIDFUNC(ShowPrompt) -DISPLAY_VOIDFUNC(ShowResponseTime) -DISPLAY_FUNC(ShowResults, (short score, unsigned short *bstline, char ch), (score, bstline, ch)) -DISPLAY_VOIDFUNC(ShowSidetoMove) -DISPLAY_VOIDFUNC(ShowStage) -DISPLAY_FUNC(TerminateSearch, (int sig), (sig)) -DISPLAY_VOIDFUNC(UpdateClocks) -DISPLAY_FUNC(UpdateDisplay, (short f, short t, short redraw, short isspec), (f, t, redraw, isspec)) -DISPLAY_VOIDFUNC(help) - -DISPLAY_FUNC(doRequestInputString, (const char* fmt, char* buffer), (fmt, buffer)) -void RequestInputString(char* buffer, unsigned bufsize) -{ - static char fmt[10]; - int ret = snprintf(fmt, sizeof(fmt), "%%%us", bufsize); - if (ret >= sizeof(fmt)) { - fprintf(stderr, - "Insufficient format-buffer size in %s for bufsize=%u\n", - __FUNCTION__, bufsize); - exit(1); - } - doRequestInputString(fmt, buffer); -} - -/*********/ - -#define CASE_DSPFUNC_RAW(func,args) \ - case DISPLAY_RAW: \ - case DISPLAY_X: \ - return (func args); \ - break - -#ifdef HAVE_LIBCURSES -#define CASE_DSPFUNC_CURSES(func,args) \ - case DISPLAY_CURSES: \ - return (func args); \ - break; -#else -#define CASE_DSPFUNC_CURSES(func,args) -#endif - -#define DISPLAY_INTFUNC(func,argsdecl,args) \ - int func argsdecl \ - { \ - switch (display_type) { \ - CASE_DSPFUNC_RAW(Raw_ ## func, args); \ - CASE_DSPFUNC_CURSES(Curses_ ## func, args); \ - } \ - assert(0); \ - } - -DISPLAY_INTFUNC(GetString, (char* sx), (sx)) diff --git a/gnushogi/dspwrappers.h b/gnushogi/dspwrappers.h deleted file mode 100644 index 0bfe79f..0000000 --- a/gnushogi/dspwrappers.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * FILE: dspwrappers.h - * - * Wrapper functions which call analogous functions in rawdsp.c - * or cursesdsp.c depending on the interface. - * - * ---------------------------------------------------------------------- - * Copyright (c) 1993, 1994, 1995 Matthias Mutz - * Copyright (c) 1999 Michael Vanier and the Free Software Foundation - * - * GNU SHOGI is based on GNU CHESS - * - * Copyright (c) 1988, 1989, 1990 John Stanback - * Copyright (c) 1992 Free Software Foundation - * - * 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 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. - * - * You should have received a copy of the GNU General Public License along - * with GNU Shogi; see the file COPYING. If not, see - * . - * ---------------------------------------------------------------------- - * - */ - -#ifndef _DSPWRAPPERS_H_ -#define _DSPWRAPPERS_H_ - -#include - -extern void ChangeAlphaWindow(void); -extern void ChangeBetaWindow(void); -extern void ChangeHashDepth(void); -extern void ChangeSearchDepth(void); -extern void ChangeXwindow(void); -extern void ClearScreen(void); -extern void DoDebug(void); -extern void DoTable(short table[NO_SQUARES]); -extern void EditBoard(void); -extern void ExitShogi(void); -extern void GiveHint(void); -extern void Initialize(void); -extern void ShowNodeCnt(long NodeCnt); -extern void OutputMove(void); -extern void PollForInput(void); -extern void SetContempt(void); -extern void SearchStartStuff(short side); -extern void SelectLevel(char *sx); -extern void ShowCurrentMove(short pnt, short f, short t); -extern void ShowDepth(char ch); -extern void ShowGameType(void); -extern void ShowLine(unsigned short *bstline); -extern void ShowMessage(char *s); -extern void AlwaysShowMessage(const char *format, ...); -extern void Printf(const char *format, ...); -extern void RequestInputString(char* buffer, unsigned bufsize); -extern int GetString(char* sx); -extern void SetupBoard(void); -extern void ShowPatternCount(short side, short n); -extern void ShowPostnValue(short sq); -extern void ShowPostnValues(void); -extern void ShowPrompt(void); -extern void ShowResponseTime(void); -extern void ShowResults(short score, unsigned short *bstline, char ch); -extern void ShowSidetoMove(void); -extern void ShowStage(void); -extern void TerminateSearch(int sig); -extern void UpdateClocks(void); -extern void UpdateDisplay(short f, short t, short redraw, short isspec); -extern void help(void); - -#endif /* _DSPWRAPPERS_H_ */ diff --git a/gnushogi/eval.c b/gnushogi/eval.c index 569b997..ac3404a 100644 --- a/gnushogi/eval.c +++ b/gnushogi/eval.c @@ -32,9 +32,6 @@ #include "gnushogi.h" #include "pattern.h" -extern void -ShowStage(void); - /* Hash table for preventing multiple scoring of the same position */ int EADD = 0; /* number of writes to the cache table */ @@ -2138,7 +2135,7 @@ UpdatePatterns(short side, short GameCnt) } if (flag.post) - ShowPatternCount(side, n); + dsp->ShowPatternCount(side, n); if (os != END_OF_SEQUENCES) update_advance_bonus(side, os); @@ -2530,8 +2527,8 @@ DetermineGameType(short side_to_move) } else { - ShowPatternCount(black, -1); - ShowPatternCount(white, -1); + dsp->ShowPatternCount(black, -1); + dsp->ShowPatternCount(white, -1); } } @@ -2708,7 +2705,7 @@ DetermineStage(short side) stage = 0; if (flag.post) - ShowStage(); + dsp->ShowStage(); /* Determine stage dependant weights */ diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c index 9034b65..988d0fa 100644 --- a/gnushogi/genmove.c +++ b/gnushogi/genmove.c @@ -250,7 +250,7 @@ Link(short side, short piece, { if (*TrP == TREE) { - ShowMessage("TREE overflow\n"); + dsp->ShowMessage("TREE overflow\n"); } else { diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h index 677d22c..e1a5471 100644 --- a/gnushogi/gnushogi.h +++ b/gnushogi/gnushogi.h @@ -43,6 +43,8 @@ #include "debug.h" #include "opts.h" /* Various option-setting #defines. */ +#include + /* * Display options. */ @@ -1124,6 +1126,55 @@ typedef enum extern int VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv); extern unsigned short TTage; -#include "dspwrappers.h" /* Display functions. */ +/* display driver framework */ + +struct display +{ + void (*ChangeAlphaWindow)(void); + void (*ChangeBetaWindow)(void); + void (*ChangeHashDepth)(void); + void (*ChangeSearchDepth)(void); + void (*ChangeXwindow)(void); + void (*ClearScreen)(void); + void (*DoDebug)(void); + void (*DoTable)(short table[NO_SQUARES]); + void (*EditBoard)(void); + void (*ExitShogi)(void); + void (*GiveHint)(void); + void (*Initialize)(void); + void (*ShowNodeCnt)(long NodeCnt); + void (*OutputMove)(void); + void (*PollForInput)(void); + void (*SetContempt)(void); + void (*SearchStartStuff)(short side); + void (*SelectLevel)(char *sx); + void (*ShowCurrentMove)(short pnt, short f, short t); + void (*ShowDepth)(char ch); + void (*ShowGameType)(void); + void (*ShowLine)(unsigned short *bstline); + void (*ShowMessage)(char *s); + void (*AlwaysShowMessage)(const char *format, ...); + void (*Printf)(const char *format, ...); + void (*doRequestInputString)(const char* fmt, char* buffer); + int (*GetString)(char* sx); + void (*SetupBoard)(void); + void (*ShowPatternCount)(short side, short n); + void (*ShowPostnValue)(short sq); + void (*ShowPostnValues)(void); + void (*ShowPrompt)(void); + void (*ShowResponseTime)(void); + void (*ShowResults)(short score, unsigned short *bstline, char ch); + void (*ShowSidetoMove)(void); + void (*ShowStage)(void); + void (*TerminateSearch)(int sig); + void (*UpdateClocks)(void); + void (*UpdateDisplay)(short f, short t, short redraw, short isspec); + void (*help)(void); +}; + +extern struct display *dsp; + +extern struct display raw_display; +extern struct display curses_display; #endif /* _GNUSHOGI_H_ */ diff --git a/gnushogi/init-common.c b/gnushogi/init-common.c index bd571ce..945f9e0 100644 --- a/gnushogi/init-common.c +++ b/gnushogi/init-common.c @@ -119,7 +119,7 @@ Initialize_data(void) if (x >= 0) { - ShowMessage("datatype 'small_short' is unsigned; " + dsp->ShowMessage("datatype 'small_short' is unsigned; " "check gnushogi.h\n"); return 1; } @@ -132,7 +132,7 @@ Initialize_data(void) { sprintf(buffer, "Cannot allocate %ld bytes for search tree", (long)n); - ShowMessage(buffer); + dsp->ShowMessage(buffer); return 1; } @@ -142,7 +142,7 @@ Initialize_data(void) if (!hashcode) { sprintf(buffer, "Cannot allocate %ld bytes for hashcode", (long)n); - ShowMessage(buffer); + dsp->ShowMessage(buffer); return 1; } @@ -154,7 +154,7 @@ Initialize_data(void) sprintf(buffer, "Cannot allocate %ld bytes for drop_hashcode", (long)n); - ShowMessage(buffer); + dsp->ShowMessage(buffer); return 1; } @@ -166,7 +166,7 @@ Initialize_data(void) sprintf(buffer, "Cannot allocate %ld bytes for game record", (long)n); - ShowMessage(buffer); + dsp->ShowMessage(buffer); return 1; } @@ -183,7 +183,7 @@ Initialize_data(void) { sprintf(buffer, "cannot allocate %ld space for nextdir %d", (long)(n), i); - ShowMessage(buffer); + dsp->ShowMessage(buffer); } nextdir[i] = NULL; @@ -198,7 +198,7 @@ Initialize_data(void) { sprintf(buffer, "cannot allocate %ld space for nextpos %d", (long)(n), i); - ShowMessage(buffer); + dsp->ShowMessage(buffer); } use_nextpos = false; @@ -216,7 +216,7 @@ Initialize_data(void) if (!value) { - ShowMessage("cannot allocate value space"); + dsp->ShowMessage("cannot allocate value space"); return 1; } @@ -225,7 +225,7 @@ Initialize_data(void) if (!fscore) { - ShowMessage("cannot allocate fscore space"); + dsp->ShowMessage("cannot allocate fscore space"); return 1; } @@ -237,7 +237,7 @@ Initialize_data(void) { sprintf(buffer, "Cannot allocate %ld bytes for history table", (long)sizeof_history); - ShowMessage(buffer); + dsp->ShowMessage(buffer); use_history = false; } #endif @@ -253,7 +253,7 @@ Initialize_data(void) { sprintf(buffer, "Cannot allocate %ld bytes for cache table %ld", (long)n, (long)i); - ShowMessage(buffer); + dsp->ShowMessage(buffer); use_etable = false; } } @@ -303,7 +303,7 @@ Initialize_data(void) { sprintf(buffer, "Cannot allocate %ld bytes for transposition table", (long)(2 * n)); - ShowMessage(buffer); + dsp->ShowMessage(buffer); ttable[0] = ttable[1] = NULL; } #endif /* ttblsz */ @@ -314,7 +314,7 @@ Initialize_data(void) if (!distdata) { - ShowMessage("cannot allocate distdata space..."); + dsp->ShowMessage("cannot allocate distdata space..."); use_distdata = false; } #endif diff --git a/gnushogi/init.c b/gnushogi/init.c index e6b495f..d86abc4 100644 --- a/gnushogi/init.c +++ b/gnushogi/init.c @@ -591,7 +591,7 @@ NewGame(void) } ClearCaptured(); - ClearScreen(); + dsp->ClearScreen(); InitializeStats(); #ifdef HAVE_GETTIMEOFDAY @@ -614,9 +614,9 @@ NewGame(void) if (TCflag) SetTimeControl(); else if (MaxResponseTime == 0) - SelectLevel(sx); + dsp->SelectLevel(sx); - UpdateDisplay(0, 0, 1, 0); + dsp->UpdateDisplay(0, 0, 1, 0); GetOpenings(); GetOpeningPatterns(&max_opening_sequence); @@ -675,7 +675,7 @@ InitMain(void) barebones = 0; } - Initialize(); + dsp->Initialize(); Initialize_dist(); Initialize_eval(); #if !defined SAVE_NEXTPOS @@ -725,6 +725,6 @@ ExitMain(void) #endif /* HASHFILE */ #endif /* ttblsz */ - ExitShogi(); + dsp->ExitShogi(); } diff --git a/gnushogi/main.c b/gnushogi/main.c index 2dd78b8..b14016b 100644 --- a/gnushogi/main.c +++ b/gnushogi/main.c @@ -98,7 +98,7 @@ main (int argc, char **argv) case 'C': /* Curses interface. */ display_type = DISPLAY_CURSES; - + dsp = &curses_display; break; #endif @@ -150,7 +150,7 @@ main (int argc, char **argv) case 'R': /* Raw text interface. */ display_type = DISPLAY_RAW; - + dsp = &raw_display; break; @@ -293,7 +293,7 @@ main (int argc, char **argv) case 'X': /* X interface. */ display_type = DISPLAY_X; - + dsp = &raw_display; break; diff --git a/gnushogi/makepattern.c b/gnushogi/makepattern.c index 34053d8..774d11f 100644 --- a/gnushogi/makepattern.c +++ b/gnushogi/makepattern.c @@ -40,11 +40,15 @@ char *patternfile = PATTERNFILE; small_short pattern_data[MAX_PATTERN_DATA]; /* minimal ShowMessage to avoid dependency on extraneous display code */ -void -ShowMessage(char *s) +static void +Dummy_ShowMessage(char *s) { printf("%s\n", s); } +static struct display dummydsp = { + .ShowMessage = Dummy_ShowMessage, +}; +struct display *dsp = &dummydsp; #define is_digit(c) (((c) >= '0') && ((c) <= '9')) #define is_alpha(c) ((((c) >= 'a') && ((c) <= 'z')) \ @@ -221,7 +225,7 @@ ReadOpeningSequences (short *pindex) { if (ScanPattern(s, pindex)) { - ShowMessage("error in pattern sequence..."); + dsp->ShowMessage("error in pattern sequence..."); exit(1); } else @@ -237,12 +241,12 @@ ReadOpeningSequences (short *pindex) sprintf(s, "Pattern: %d bytes for %d sequences with %d patterns.\n", *pindex, max_opening_sequence, max_pattern); - ShowMessage(s); + dsp->ShowMessage(s); fclose(fd); } else { sprintf(s, "no pattern file '%s'", patternfile); - ShowMessage(s); + dsp->ShowMessage(s); } } diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index d868179..99a9ba0 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -41,7 +41,6 @@ #endif #include "gnushogi.h" -#include "rawdsp.h" unsigned short MV[MAXDEPTH]; int MSCORE; @@ -51,6 +50,11 @@ char *DRAW; extern char *InPtr; extern short pscore[]; +/**************************************** + * forward declarations + ****************************************/ + +void Raw_UpdateDisplay(short f, short t, short redraw, short isspec); /**************************************** * Trivial output functions. @@ -126,17 +130,23 @@ Raw_ShowMessage(char *s) void -Raw_AlwaysShowMessage(const char *format, va_list ap) +Raw_AlwaysShowMessage(const char *format, ...) { + va_list ap; + va_start(ap, format); vprintf(format, ap); printf("\n"); + va_end(ap); } void -Raw_Printf(const char *format, va_list ap) +Raw_Printf(const char *format, ...) { + va_list ap; + va_start(ap, format); vprintf(format, ap); + va_end(ap); } @@ -961,7 +971,7 @@ Raw_PollForInput(void) int cnt = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 0); if (cnt < 0) { perror("polling standard input"); - ExitShogi(); + Raw_ExitShogi(); } #endif if (cnt) { /* if anything to read, or error occured */ @@ -970,3 +980,47 @@ Raw_PollForInput(void) flag.bothsides = false; } } + +struct display raw_display = +{ + .ChangeAlphaWindow = Raw_ChangeAlphaWindow, + .ChangeBetaWindow = Raw_ChangeBetaWindow, + .ChangeHashDepth = Raw_ChangeHashDepth, + .ChangeSearchDepth = Raw_ChangeSearchDepth, + .ChangeXwindow = Raw_ChangeXwindow, + .ClearScreen = Raw_ClearScreen, + .DoDebug = Raw_DoDebug, + .DoTable = Raw_DoTable, + .EditBoard = Raw_EditBoard, + .ExitShogi = Raw_ExitShogi, + .GiveHint = Raw_GiveHint, + .Initialize = Raw_Initialize, + .ShowNodeCnt = Raw_ShowNodeCnt, + .OutputMove = Raw_OutputMove, + .PollForInput = Raw_PollForInput, + .SetContempt = Raw_SetContempt, + .SearchStartStuff = Raw_SearchStartStuff, + .SelectLevel = Raw_SelectLevel, + .ShowCurrentMove = Raw_ShowCurrentMove, + .ShowDepth = Raw_ShowDepth, + .ShowGameType = Raw_ShowGameType, + .ShowLine = Raw_ShowLine, + .ShowMessage = Raw_ShowMessage, + .AlwaysShowMessage = Raw_AlwaysShowMessage, + .Printf = Raw_Printf, + .doRequestInputString = Raw_doRequestInputString, + .GetString = Raw_GetString, + .SetupBoard = Raw_SetupBoard, + .ShowPatternCount = Raw_ShowPatternCount, + .ShowPostnValue = Raw_ShowPostnValue, + .ShowPostnValues = Raw_ShowPostnValues, + .ShowPrompt = Raw_ShowPrompt, + .ShowResponseTime = Raw_ShowResponseTime, + .ShowResults = Raw_ShowResults, + .ShowSidetoMove = Raw_ShowSidetoMove, + .ShowStage = Raw_ShowStage, + .TerminateSearch = Raw_TerminateSearch, + .UpdateClocks = Raw_UpdateClocks, + .UpdateDisplay = Raw_UpdateDisplay, + .help = Raw_help, +}; diff --git a/gnushogi/rawdsp.h b/gnushogi/rawdsp.h deleted file mode 100644 index 699528e..0000000 --- a/gnushogi/rawdsp.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * FILE: rawdsp.h - * - * Raw text interface for GNU Shogi. - * - * ---------------------------------------------------------------------- - * Copyright (c) 1993, 1994, 1995 Matthias Mutz - * Copyright (c) 1999 Michael Vanier and the Free Software Foundation - * - * GNU SHOGI is based on GNU CHESS - * - * Copyright (c) 1988, 1989, 1990 John Stanback - * Copyright (c) 1992 Free Software Foundation - * - * 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 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. - * - * You should have received a copy of the GNU General Public License along - * with GNU Shogi; see the file COPYING. If not, see - * . - * ---------------------------------------------------------------------- - * - */ - -#ifndef _RAWDSP_H_ -#define _RAWDSP_H_ - -#include "gnushogi.h" - -/* The following are common to rawdsp.h and cursesdsp.h */ - -void Raw_ChangeAlphaWindow(void); -void Raw_ChangeBetaWindow(void); -void Raw_ChangeHashDepth(void); -void Raw_ChangeSearchDepth(void); -void Raw_ChangeXwindow(void); -void Raw_ClearScreen(void); -void Raw_Die(int sig); -void Raw_DoDebug(void); -void Raw_DoTable(short table[NO_SQUARES]); -void Raw_EditBoard(void); -void Raw_ExitShogi(void); -void Raw_GiveHint(void); -void Raw_Initialize(void); -void Raw_ShowNodeCnt(long NodeCnt); -void Raw_OutputMove(void); -void Raw_PollForInput(void); -void Raw_SearchStartStuff(short side); -void Raw_SelectLevel(char *sx); -void Raw_SetContempt(void); -void Raw_ShowCurrentMove(short pnt, short f, short t); -void Raw_ShowDepth(char ch); -void Raw_ShowGameType(void); -void Raw_ShowLine(unsigned short *bstline); -void Raw_ShowMessage(char *s); -void Raw_AlwaysShowMessage(const char *format, va_list ap); -void Raw_Printf(const char *format, va_list ap); -void Raw_doRequestInputString(const char* fmt, char* buffer); -int Raw_GetString(char* sx); -void Raw_SetupBoard(void); -void Raw_ShowPatternCount(short side, short n); -void Raw_ShowPostnValue(short sq); -void Raw_ShowPostnValues(void); -void Raw_ShowPrompt(void); -void Raw_ShowResponseTime(void); -void Raw_ShowResults(short score, unsigned short *bstline, char ch); -void Raw_ShowSidetoMove(void); -void Raw_ShowStage(void); -void Raw_TerminateSearch(int sig); -void Raw_UpdateClocks(void); -void Raw_UpdateDisplay(short f, short t, short redraw, short isspec); -void Raw_help(void); - -#endif /* _RAWDSP_H_ */ - diff --git a/gnushogi/search.c b/gnushogi/search.c index 060d958..b8fa819 100644 --- a/gnushogi/search.c +++ b/gnushogi/search.c @@ -180,7 +180,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowResponseTime(); + dsp->ShowResponseTime(); ExtraTime = 0; @@ -189,12 +189,12 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowSidetoMove(); + dsp->ShowSidetoMove(); #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - SearchStartStuff(side); + dsp->SearchStartStuff(side); #ifdef HISTORY array_zero(history, sizeof_history); @@ -304,7 +304,7 @@ SelectMove(short side, SelectMove_mode iop) # ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth(' '); + dsp->ShowDepth(' '); /* search at this level returns score of PV */ score = search(side, 1, Sdepth, alpha, beta, PrVar, &rpt); @@ -320,7 +320,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth('-'); + dsp->ShowDepth('-'); if (TCflag && TCcount < MAXTCCOUNTR) { @@ -342,7 +342,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowDepth('+'); + dsp->ShowDepth('+'); score = search(side, 1, Sdepth, -(SCORE_LIMIT + 999), (SCORE_LIMIT + 999), PrVar, &rpt); @@ -395,7 +395,7 @@ SelectMove(short side, SelectMove_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowResults(score, PrVar, '.'); + dsp->ShowResults(score, PrVar, '.'); } /********************** end of main loop ***************************/ @@ -452,7 +452,7 @@ SelectMove(short side, SelectMove_mode iop) ElapsedTime(COMPUTE_AND_INIT_MODE); /* update time control info */ - OutputMove(); + dsp->OutputMove(); /* if mate set flag */ if ((score == -(SCORE_LIMIT + 999) || score == (SCORE_LIMIT + 998))) @@ -580,7 +580,7 @@ search(short side, #ifdef QUIETBACKGROUND if (!background) #endif - ShowResponseTime(); + dsp->ShowResponseTime(); } else if (!TCflag && flag.musttimeout && Sdepth > MINDEPTH) { @@ -870,7 +870,7 @@ search(short side, #ifdef QUIETBACKGROUND if (!background) #endif /* QUIETBACKGROUND */ - ShowCurrentMove(pnt, node->f, node->t); + dsp->ShowCurrentMove(pnt, node->f, node->t); } } #endif @@ -984,15 +984,15 @@ search(short side, { if (best > beta) { - ShowResults(best, bstline, '+'); + dsp->ShowResults(best, bstline, '+'); } else if (best < alpha) { - ShowResults(best, bstline, '-'); + dsp->ShowResults(best, bstline, '-'); } else { - ShowResults (best, bstline, '&'); + dsp->ShowResults(best, bstline, '&'); } } #ifdef QUIETBACKGROUND diff --git a/gnushogi/tcontrl.c b/gnushogi/tcontrl.c index fd5f4a5..f8f15dc 100644 --- a/gnushogi/tcontrl.c +++ b/gnushogi/tcontrl.c @@ -345,7 +345,7 @@ CheckForTimeout(int score, int globalscore, int Jscore, int zwndw) #endif if (flag.timeout) - ShowMessage("timeout"); + dsp->ShowMessage("timeout"); } @@ -365,7 +365,7 @@ ElapsedTime(ElapsedTime_mode iop) struct timeval tv; #endif - PollForInput(); + dsp->PollForInput(); #ifdef HAVE_GETTIMEOFDAY gettimeofday(&tv, NULL); @@ -410,6 +410,6 @@ ElapsedTime(ElapsedTime_mode iop) #ifdef QUIETBACKGROUND if (!background) #endif - UpdateClocks(); + dsp->UpdateClocks(); } }