* ----------------------------------------------------------------------
* 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
*
#include "debug.h"
#include "opts.h" /* Various option-setting #defines. */
+#include <stdarg.h>
+
/*
* Display options.
*/
extern display_t display_type;
#define XSHOGI (display_type == DISPLAY_X)
-#define NOT_CURSES ((display_type == DISPLAY_X) \
- || (display_type == DISPLAY_RAW))
/* Miscellaneous globals. */
extern short hard_time_limit; /* If you exceed time limit, you lose. */
-extern short barebones; /* Don't print of stats for x interface. */
extern short nolist; /* Don't list game after exit. */
+extern short xboard; /* Use XBoard instead of xShogi protocol */
/*
#define small_ushort unsigned char
-typedef small_short BYTE;
typedef small_ushort UBYTE;
typedef short SHORT;
typedef unsigned short USHORT;
#include <sys/param.h>
#include <sys/types.h>
-#include <sys/times.h>
-#include <sys/ioctl.h>
-
+#ifdef WIN32
+# include <windows.h>
+#else
+ typedef small_short BYTE;
+# include <sys/times.h>
+# include <sys/ioctl.h>
+#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
#define SEEK_SET 0
#define SEEK_END 2
+#ifdef MINISHOGI
+#define NO_PIECES 11
+#define MAX_CAPTURED 19
+#define NO_PTYPE_PIECES 11
+#define NO_COLS 5
+#define NO_ROWS 5
+#define NO_CAMP_ROWS 1
+#else
#define NO_PIECES 15
#define MAX_CAPTURED 19
#define NO_PTYPE_PIECES 15
#define NO_COLS 9
#define NO_ROWS 9
+#define NO_CAMP_ROWS 3
+#endif
#define NO_SQUARES (NO_COLS*NO_ROWS)
-#define ROW_NAME(n) ('a' + NO_ROWS - 1 - n)
-#define COL_NAME(n) ('1' + NO_COLS - 1 - n)
+#define ROW_NAME(n) ( xboard ? '1' + n : ('a' + NO_ROWS - 1 - n) )
+#define COL_NAME(n) ( xboard ? 'a' + n : ('1' + NO_COLS - 1 - n) )
+#define ROW_NUM(c) ( xboard ? c - '1' : ('a' + NO_ROWS - 1 - c) )
+#define COL_NUM(c) ( xboard ? c - 'a' : ('1' + NO_COLS - 1 - c) )
+
#if defined HASHFILE || defined CACHE
# define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
/* board properties */
-#define InBlackCamp(sq) ((sq) < 27)
-#define InWhiteCamp(sq) ((sq) > 53)
+#define InBlackCamp(sq) ((sq) < (NO_COLS * NO_CAMP_ROWS))
+#define InWhiteCamp(sq) ((sq) >= (NO_COLS * (NO_ROWS - NO_CAMP_ROWS)))
#define InPromotionZone(side, sq) \
(((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq))
/* constants */
+/* FIXME ? */
#define OPENING_HINT 0x141d /* P7g-7f (20->29) */
/* truth values */
enum {
no_piece = 0,
pawn,
+#ifndef MINISHOGI
lance,
knight,
+#endif
+ /* start of pieces that can be dropped at any square */
silver,
gold,
bishop,
rook,
ppawn,
+#ifndef MINISHOGI
plance,
pknight,
+#endif
psilver,
pbishop,
prook,
enum {
ptype_no_piece = 0,
ptype_pawn = 0,
+#ifndef MINISHOGI
ptype_lance,
ptype_knight,
+#endif
ptype_silver,
ptype_gold,
ptype_bishop,
ptype_prook,
ptype_king,
ptype_wpawn,
+#ifndef MINISHOGI
ptype_wlance,
ptype_wknight,
+#endif
ptype_wsilver,
ptype_wgold
};
#endif
/* move symbols */
-#define pxx (CP[2])
-#define qxx (CP[1])
-#define rxx (CP[4])
-#define cxx (CP[3])
+#ifndef MINISHOGI
+#define pxx (" PLNSGBRPLNSBRK ")
+#define qxx (" plnsgbrplnsbrk ")
+#else
+#define pxx (" PSGBRPSBRK ")
+#define qxx (" psgbrpsbrk ")
+#endif
/***************** Table limits ********************************************/
#define MAXDEPTH 40 /* max depth a search can be carried */
#define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */
#define MAXMOVES 300 /* max number of half moves in a game */
-#define CPSIZE 235 /* size of lang file max */
+#define CPSIZE 241 /* size of lang file max */
#if defined SMALL_MEMORY
# if defined SAVE_SSCORE
extern char ColorStr[2][10];
extern char mvstr[4][6];
-extern unsigned short MV[MAXDEPTH];
-extern int MSCORE;
extern int mycnt1, mycnt2;
extern short ahead;
extern struct leaf rootnode;
extern small_short ChkFlag[], CptrFlag[], TesujiFlag[];
extern short Pscore[], Tscore[];
extern /*unsigned*/ short rehash; /* -1 is used as a flag --tpm */
-extern char version[], patchlevel[];
extern unsigned int ttbllimit;
extern unsigned int TTadd;
extern unsigned int ttblsize;
typedef small_short distdata_array[NO_SQUARES][NO_SQUARES];
extern const small_short inunmap[NO_SQUARES];
+#ifndef MINISHOGI
extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)];
+#else
+extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 2)];
+#endif
#if defined SAVE_NEXTPOS
extern const small_short direc[NO_PTYPE_PIECES][8];
extern hashcode_array *hashcode;
extern drop_hashcode_array *drop_hashcode;
-extern char *CP[];
#ifdef QUIETBACKGROUND
extern short background;
extern short rpthash[2][256];
extern char *DRAW;
+extern char* DRAW_REPETITION;
+extern char *DRAW_MAXMOVES;
+extern char *DRAW_JUSTDRAW;
+
#define row(a) ((a) / NO_COLS)
#define column(a) ((a) % NO_COLS)
#define locn(a, b) (((a) * NO_COLS) + b)
extern void Initialize_dist(void); /* init.c */
extern void Initialize_eval(void); /* eval.c */
extern void NewGame(void);
-extern int parse(FILE * fd, unsigned short *mv,
- short side, char *opening);
extern void GetOpenings(void);
-extern int OpeningBook(unsigned short *hint, short side);
+extern int OpeningBook(unsigned short *hint);
typedef enum
{
short score,
short depth,
short ply,
- short alpha,
short beta,
unsigned short mv);
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)(char *sx);
+ 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_ */