4 * Wrapper functions which call analogous functions in rawdsp.c
5 * or cursesdsp.c depending on the interface.
7 * ----------------------------------------------------------------------
8 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
9 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
11 * GNU SHOGI is based on GNU CHESS
13 * Copyright (c) 1988, 1989, 1990 John Stanback
14 * Copyright (c) 1992 Free Software Foundation
16 * This file is part of GNU SHOGI.
18 * GNU Shogi is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 3 of the License,
21 * or (at your option) any later version.
23 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
24 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 * You should have received a copy of the GNU General Public License along
29 * with GNU Shogi; see the file COPYING. If not, see
30 * <http://www.gnu.org/licenses/>.
31 * ----------------------------------------------------------------------
35 /* request *snprintf prototypes*/
36 #define _POSIX_C_SOURCE 200112L
39 #include "dspwrappers.h"
41 #include "cursesdsp.h"
45 #define CASE_DSP_RAW(func,args) \
52 #define CASE_DSP_CURSES(func,args) \
53 case DISPLAY_CURSES: \
57 #define CASE_DSP_CURSES(func,args)
60 #define DISPLAY_FUNC(func,argsdecl,args) \
63 switch (display_type) { \
64 CASE_DSP_RAW(Raw_ ## func, args); \
65 CASE_DSP_CURSES(Curses_ ## func, args); \
68 #define DISPLAY_VOIDFUNC(func) \
69 DISPLAY_FUNC(func,(void),())
71 #define DISPLAY_STDARGFUNC(func,argsdecl,last,args) \
76 switch (display_type) { \
77 CASE_DSP_RAW(Raw_ ## func, args); \
78 CASE_DSP_CURSES(Curses_ ## func, args); \
83 DISPLAY_VOIDFUNC(ChangeAlphaWindow)
84 DISPLAY_VOIDFUNC(ChangeBetaWindow)
85 DISPLAY_VOIDFUNC(ChangeHashDepth)
86 DISPLAY_VOIDFUNC(ChangeSearchDepth)
87 DISPLAY_VOIDFUNC(ChangeXwindow)
88 DISPLAY_VOIDFUNC(ClearScreen)
89 DISPLAY_VOIDFUNC(DoDebug)
90 DISPLAY_FUNC(DoTable, (short table[NO_SQUARES]), (table))
91 DISPLAY_VOIDFUNC(EditBoard)
92 DISPLAY_VOIDFUNC(ExitShogi)
93 DISPLAY_VOIDFUNC(GiveHint)
94 DISPLAY_VOIDFUNC(Initialize)
95 DISPLAY_FUNC(ShowNodeCnt, (long NodeCnt), (NodeCnt))
96 DISPLAY_VOIDFUNC(OutputMove)
97 DISPLAY_VOIDFUNC(PollForInput)
98 DISPLAY_VOIDFUNC(SetContempt)
99 DISPLAY_FUNC(SearchStartStuff, (short side), (side))
100 DISPLAY_FUNC(SelectLevel, (char *sx), (sx))
101 DISPLAY_VOIDFUNC(SetupBoard)
102 DISPLAY_FUNC(ShowCurrentMove, (short pnt, short f, short t), (pnt, f, t))
103 DISPLAY_FUNC(ShowDepth, (char ch), (ch))
104 DISPLAY_VOIDFUNC(ShowGameType)
105 DISPLAY_FUNC(ShowLine, (unsigned short *bstline), (bstline))
106 DISPLAY_FUNC(ShowMessage, (char *s), (s))
107 DISPLAY_STDARGFUNC(AlwaysShowMessage, (const char *format, ...), format, (format, ap))
108 DISPLAY_STDARGFUNC(Printf, (const char *format, ...), format, (format, ap))
109 DISPLAY_FUNC(ShowPatternCount, (short side, short n), (side, n))
110 DISPLAY_FUNC(ShowPostnValue, (short sq), (sq))
111 DISPLAY_VOIDFUNC(ShowPostnValues)
112 DISPLAY_VOIDFUNC(ShowPrompt)
113 DISPLAY_VOIDFUNC(ShowResponseTime)
114 DISPLAY_FUNC(ShowResults, (short score, unsigned short *bstline, char ch), (score, bstline, ch))
115 DISPLAY_VOIDFUNC(ShowSidetoMove)
116 DISPLAY_VOIDFUNC(ShowStage)
117 DISPLAY_FUNC(TerminateSearch, (int sig), (sig))
118 DISPLAY_VOIDFUNC(UpdateClocks)
119 DISPLAY_FUNC(UpdateDisplay, (short f, short t, short redraw, short isspec), (f, t, redraw, isspec))
120 DISPLAY_VOIDFUNC(help)
122 DISPLAY_FUNC(doRequestInputString, (const char* fmt, char* buffer), (fmt, buffer))
123 void RequestInputString(char* buffer, unsigned bufsize)
126 int ret = snprintf(fmt, sizeof(fmt), "%%%us", bufsize);
127 if (ret >= sizeof(fmt)) {
129 "Insufficient format-buffer size in %s for bufsize=%u\n",
130 __FUNCTION__, bufsize);
133 doRequestInputString(fmt, buffer);
138 #define CASE_DSPFUNC_RAW(func,args) \
141 return (func args); \
144 #ifdef HAVE_LIBCURSES
145 #define CASE_DSPFUNC_CURSES(func,args) \
146 case DISPLAY_CURSES: \
147 return (func args); \
150 #define CASE_DSPFUNC_CURSES(func,args)
153 #define DISPLAY_INTFUNC(func,argsdecl,args) \
156 switch (display_type) { \
157 CASE_DSPFUNC_RAW(Raw_ ## func, args); \
158 CASE_DSPFUNC_CURSES(Curses_ ## func, args); \
163 DISPLAY_INTFUNC(GetString, (char* sx), (sx))