1a0e65812859b36dbea8f97c28d113bfdfa0ebb6
[xboard.git] / winboard-dm-beta4 / common.h
1 /*
2  * common.h -- Common definitions for X and Windows NT versions of XBoard
3  * $Id$
4  *
5  * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
6  * Enhancements Copyright 1992-95 Free Software Foundation, Inc.
7  *
8  * The following terms apply to Digital Equipment Corporation's copyright
9  * interest in XBoard:
10  * ------------------------------------------------------------------------
11  * All Rights Reserved
12  *
13  * Permission to use, copy, modify, and distribute this software and its
14  * documentation for any purpose and without fee is hereby granted,
15  * provided that the above copyright notice appear in all copies and that
16  * both that copyright notice and this permission notice appear in
17  * supporting documentation, and that the name of Digital not be
18  * used in advertising or publicity pertaining to distribution of the
19  * software without specific, written prior permission.
20  *
21  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
22  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
23  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27  * SOFTWARE.
28  * ------------------------------------------------------------------------
29  *
30  * The following terms apply to the enhanced version of XBoard distributed
31  * by the Free Software Foundation:
32  * ------------------------------------------------------------------------
33  * This program is free software; you can redistribute it and/or modify
34  * it under the terms of the GNU General Public License as published by
35  * the Free Software Foundation; either version 2 of the License, or
36  * (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41  * GNU General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License
44  * along with this program; if not, write to the Free Software
45  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
46  * ------------------------------------------------------------------------
47  */
48
49 #ifndef _COMMON
50 #define _COMMON
51
52 /* Begin compatibility grunge  */
53
54 #if defined(__STDC__) || defined(WIN32) || defined(_amigados)
55 #define P(args) args
56 typedef void *VOIDSTAR;
57 #else
58 #define P(args)         ()
59 typedef char *VOIDSTAR;
60 #endif
61
62 #ifdef WIN32
63 typedef char Boolean;
64 typedef char *String;
65 #define popen _popen
66 #define pclose _pclose
67
68 #else
69 #ifdef _amigados        /*  It is important, that these types have  */
70 typedef int Boolean;    /*  a length of 4 bytes each, as we are     */
71 typedef char *String;   /*  using ReadArgs() for argument parsing.  */
72 #ifdef _DCC
73 FILE *popen(const char *, const char *);
74 int pclose(FILE *);
75 #endif
76
77 #else
78 #include <X11/Intrinsic.h>
79 #endif
80 #endif
81
82
83 #ifndef TRUE
84 #define TRUE 1
85 #define FALSE 0
86 #endif
87
88 #if !HAVE_RANDOM
89 # if HAVE_RAND48
90 #  define srandom srand48
91 #  define random lrand48
92 # else /* not HAVE_RAND48 */
93 #  define srandom srand
94 #  define random rand
95 # endif /* not HAVE_RAND48 */
96 #endif /* !HAVE_RANDOM */
97
98 /* End compatibility grunge */
99
100 #define PROTOVER                2       /* engine protocol version */
101
102 #define BOARD_SIZE              8
103 #define DROP_RANK               -3
104 #define MAX_MOVES               1000
105 #define MSG_SIZ                 2048
106 #define DIALOG_SIZE             256
107 #define STAR_MATCH_N            16
108 #define MOVE_LEN                32
109 #define TIME_CONTROL            "5"     /* in minutes */
110 #define TIME_DELAY_QUOTE        "1.0"   /* seconds between moves */
111 #define TIME_DELAY              ((float) 1.0)
112 #define MOVES_PER_SESSION       40      /* moves per TIME_CONTROL */
113 #define TIME_INCREMENT          -1      /* if >= 0, MOVES_PER_SESSION unused */
114 #define WhiteOnMove(move)       (((move) % 2) == 0)
115 #define ICS_HOST                "chessclub.com"
116 #define ICS_PORT                "5000"
117 #define ICS_COMM_PORT           ""
118 #define FIRST_HOST              "localhost"
119 #define SECOND_HOST             "localhost"
120 #define TELNET_PROGRAM          "telnet"
121 #define MATCH_MODE              "False"
122 #define INIT_STRING             "new\nrandom\n"
123 #define WHITE_STRING            "white\ngo\n"
124 #define BLACK_STRING            "black\ngo\n"
125 #define COMPUTER_STRING         "computer\n"
126 #define REUSE_CHESS_PROGRAMS    1
127 #define WHITE_PIECE_COLOR       "#FFFFCC"
128 #define BLACK_PIECE_COLOR       "#202020"
129 #define LIGHT_SQUARE_COLOR      "#C8C365"
130 #define DARK_SQUARE_COLOR       "#77A26D"
131 #define JAIL_SQUARE_COLOR       "#808080"
132 #define HIGHLIGHT_SQUARE_COLOR  "#FFFF00"
133 #define PREMOVE_HIGHLIGHT_COLOR "#FF0000"
134 #define BELLCHAR                '\007'
135 #define NULLCHAR                '\000'
136 #define FEATURE_TIMEOUT         10000 /*ms*/
137
138 /* Zippy defaults */
139 #define ZIPPY_TALK FALSE
140 #define ZIPPY_PLAY FALSE
141 #define ZIPPY_LINES "yow.lines"
142 #define ZIPPY_PINHEAD ""
143 #define ZIPPY_PASSWORD ""
144 #define ZIPPY_PASSWORD2 ""
145 #define ZIPPY_PASSWORD3 ""
146 #define ZIPPY_WRONG_PASSWORD ""
147 #define ZIPPY_ACCEPT_ONLY ""
148 #define ZIPPY_USE_I TRUE
149 #define ZIPPY_BUGHOUSE 0
150 #define ZIPPY_NOPLAY_CRAFTY FALSE
151 #define ZIPPY_GAME_END "gameend\n"
152 #define ZIPPY_GAME_START ""
153 #define ZIPPY_ADJOURN FALSE
154 #define ZIPPY_ABORT FALSE
155 #define ZIPPY_VARIANTS "normal"
156 #define ZIPPY_MAX_GAMES 0
157 #define ZIPPY_REPLAY_TIMEOUT 120
158
159 typedef enum {
160     BeginningOfGame, MachinePlaysWhite, MachinePlaysBlack,
161     AnalyzeMode, AnalyzeFile, TwoMachinesPlay,
162     EditGame, PlayFromGameFile, EndOfGame, EditPosition, Training,
163     IcsIdle, IcsPlayingWhite, IcsPlayingBlack, IcsObserving,
164     IcsExamining
165   } GameMode;
166
167 GameMode gameMode;
168
169 typedef enum {
170     WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, WhiteKing,
171     BlackPawn, BlackKnight, BlackBishop, BlackRook, BlackQueen, BlackKing,
172     EmptySquare, 
173     ClearBoard, WhitePlay, BlackPlay /*for use on EditPosition menus*/
174   } ChessSquare;
175
176 typedef ChessSquare Board[BOARD_SIZE][BOARD_SIZE];
177
178 typedef enum {
179     WhiteKingSideCastle = 1, WhiteQueenSideCastle,
180     WhiteKingSideCastleWild, WhiteQueenSideCastleWild,
181     WhiteHSideCastleFR, WhiteASideCastleFR, 
182     BlackKingSideCastle, BlackQueenSideCastle,
183     BlackKingSideCastleWild, BlackQueenSideCastleWild,
184     BlackHSideCastleFR, BlackASideCastleFR, 
185     WhitePromotionKnight, WhitePromotionBishop,
186     WhitePromotionRook, WhitePromotionQueen, WhitePromotionKing,
187     BlackPromotionKnight, BlackPromotionBishop,
188     BlackPromotionRook, BlackPromotionQueen, BlackPromotionKing,
189     WhiteCapturesEnPassant, BlackCapturesEnPassant,
190     WhiteDrop, BlackDrop, 
191     NormalMove, AmbiguousMove, IllegalMove, ImpossibleMove,
192     WhiteWins, BlackWins, GameIsDrawn, GameUnfinished,
193     GNUChessGame, XBoardGame, MoveNumberOne, 
194     Comment, PositionDiagram, ElapsedTime, PGNTag, NAG
195   } ChessMove;
196
197 typedef enum {
198     ColorShout, ColorSShout, ColorChannel1, ColorChannel, ColorKibitz,
199     ColorTell, ColorChallenge, ColorRequest, ColorSeek, ColorNormal,
200     ColorNone, NColorClasses
201 } ColorClass;
202
203 typedef enum {
204     SoundMove, SoundBell, SoundAlarm, SoundIcsWin, SoundIcsLoss,
205     SoundIcsDraw, SoundIcsUnfinished, NSoundClasses
206 } SoundClass;
207
208 /* Names for chess variants, not necessarily supported */
209 typedef enum {
210     VariantNormal,       /* Normal chess */
211     VariantLoadable,     /* "loadgame" command allowed (not really a variant)*/
212     VariantWildCastle,   /* Shuffle chess where king can castle from d file */
213     VariantNoCastle,     /* Shuffle chess with no castling at all */
214     VariantFischeRandom, /* FischeRandom */
215     VariantBughouse,     /* Bughouse, ICC/FICS rules */
216     VariantCrazyhouse,   /* Crazyhouse, ICC/FICS rules */
217     VariantLosers,       /* Try to lose all pieces or get mated (ICC wild 17)*/
218     VariantSuicide,      /* Try to lose all pieces incl. king (FICS) */
219     VariantGiveaway,     /* Try to have no legal moves left (ICC wild 26) */
220     VariantTwoKings,     /* Weird ICC wild 9 */
221     VariantKriegspiel,   /* Kriegspiel; pawns can capture invisible pieces */
222     VariantAtomic,       /* Capturing piece explodes (ICC wild 27) */
223     Variant3Check,       /* Win by giving check 3 times (ICC wild 25) */
224     VariantShatranj,     /* Unsupported (ICC wild 28) */
225     Variant29,           /* Temporary name for possible future ICC wild 29 */
226     Variant30,           /* Temporary name for possible future ICC wild 30 */
227     Variant31,           /* Temporary name for possible future ICC wild 31 */
228     Variant32,           /* Temporary name for possible future ICC wild 32 */
229     Variant33,           /* Temporary name for possible future ICC wild 33 */
230     Variant34,           /* Temporary name for possible future ICC wild 34 */
231     Variant35,           /* Temporary name for possible future ICC wild 35 */
232     Variant36,           /* Temporary name for possible future ICC wild 36 */
233     VariantUnknown       /* Catchall for other unknown variants */
234 } VariantClass;
235
236 #define VARIANT_NAMES { \
237   "normal", \
238   "normal", \
239   "wildcastle", \
240   "nocastle", \
241   "fischerandom", \
242   "bughouse", \
243   "crazyhouse", \
244   "losers", \
245   "suicide", \
246   "giveaway", \
247   "twokings", \
248   "kriegspiel", \
249   "atomic", \
250   "3check", \
251   "shatranj", \
252   "wild29", \
253   "wild30", \
254   "wild31", \
255   "wild32", \
256   "wild33", \
257   "wild34", \
258   "wild35", \
259   "wild36", \
260   "unknown" \
261 }
262
263 typedef struct {
264 #if !defined(_amigados)
265     char *whitePieceColor;
266     char *blackPieceColor;
267     char *lightSquareColor;
268     char *darkSquareColor;
269     char *jailSquareColor;
270     char *highlightSquareColor;
271     char *premoveHighlightColor;
272 #else
273     int whitePieceColor;
274     int blackPieceColor;
275     int lightSquareColor;
276     int darkSquareColor;
277     int jailSquareColor;
278     int highlightSquareColor;
279     int premoveHighlightColor;
280 #endif
281     int movesPerSession;
282     int timeIncrement;
283     char *initString;
284     char *secondInitString;
285     char *firstComputerString;
286     char *secondComputerString;
287     char *firstChessProgram;
288     char *secondChessProgram;
289     char *firstDirectory;
290     char *secondDirectory;
291     Boolean firstPlaysBlack;
292     Boolean noChessProgram;
293     char *firstHost;
294     char *secondHost;
295     char *bitmapDirectory;
296     char *remoteShell;
297     char *remoteUser;
298     float timeDelay;
299     char *timeControl;
300     Boolean icsActive;
301     char *icsHost;
302     char *icsPort;
303     char *icsCommPort;  /* if set, use serial port instead of tcp host/port */
304     char *icsLogon;     /* Hack to permit variable logon scripts. */
305     char *icsHelper;
306     Boolean icsInputBox;
307     Boolean useTelnet;
308     char *telnetProgram;
309     char *gateway;
310     char *loadGameFile;
311     int loadGameIndex;      /* game # within file */
312     char *saveGameFile;
313     Boolean autoSaveGames;
314     char *loadPositionFile;
315     int loadPositionIndex;  /* position # within file */
316     char *savePositionFile;
317     Boolean matchMode;
318     int matchGames;
319     Boolean monoMode;
320     Boolean debugMode;
321     Boolean clockMode;
322         /* daniel */
323         Boolean userVersion;    /* programmer version */
324         Boolean icsAnalyze;
325         Boolean icsEngineKillPV;
326         Boolean icsEngineWhisper;
327         Boolean icsEngineKibitz;
328         Boolean icsEngineTell;
329         Boolean icsEngineNone;
330         Boolean icsAnalyzeWindow;
331         Boolean smartQueue;             /* Live broadcast quere */
332         Boolean ICC_feature;            /* Enable special ICC fetures */ 
333         Boolean windowMove;             /* Drop fail high/low moves at icsAnalyzeOutPut */
334         int icsAnalyzeOutPut; /* 1=whisper 2=kibitz 3=tell 4=none */
335         int icsKillPVs;
336         char icsTells[MSG_SIZ]; /* handle/channel do we tell somthing */
337         Boolean icsWBprotoNorm;
338         Boolean icsWBprotoAgr;
339         int icsWBproto; /* dummy */
340         int icsSmartQueue;              /* 0 = standard game 1 = Blitzgame */
341         /* Split smartQueue with int because i want more for the future */
342         Boolean icsSmartQueueStd; 
343         Boolean icsSmartQueueBlitz;
344         Boolean icsShowBook;    /* True = show book False = disable */
345         Boolean AnalysisWindow; /* Engine Room */
346         Boolean engineStart; /* EngineRoom  Button */
347         Boolean engineTourneyMode; /* EngineRoom checkbox tourneyMode */
348         Boolean engineStatLine;  /* EngineRoom Statline disable */
349         Boolean zippyDraw; /* active zippy draw Handling ? */
350         int SendOutPutToICS; /* Analysis window: Send thinking lines to ICS */
351                                                  /* 0 none 1 whisper 2 kibitz */
352         Boolean ButtonSendOutPutToICS; /* Checkbox analysis window */
353     char *boardSize;
354     Boolean Iconic;
355     char *searchTime;
356     int searchDepth;
357     Boolean showCoords;
358     char *clockFont;
359     char *messageFont; /* WinBoard only */
360     char *coordFont;
361     char *font; /* xboard only: all other fonts */
362     char *tagsFont; /* WinBoard only */
363     char *commentFont; /* WinBoard only */
364     char *icsFont; /* WinBoard only */
365     Boolean ringBellAfterMoves;
366     Boolean autoCallFlag;
367     Boolean flipView;
368     Boolean autoFlipView;
369     char *cmailGameName; /* xboard only */
370     Boolean alwaysPromoteToQueen;
371     Boolean oldSaveStyle;
372     Boolean quietPlay;
373     Boolean showThinking;
374     Boolean ponderNextMove;
375     Boolean periodicUpdates;
376     Boolean autoObserve;
377     Boolean autoComment;
378     Boolean getMoveList;
379     Boolean testLegality;
380     int borderXoffset; /* xboard only */
381     int borderYoffset; /* xboard only */
382     Boolean titleInWindow; /* xboard only */
383     Boolean localLineEditing; /* WinBoard only */
384     Boolean zippyTalk;
385     Boolean zippyPlay;
386     int flashCount; /* Number of times to flash (xboard only) */
387     int flashRate; /* Flashes per second (xboard only)  */
388     char *pixmapDirectory; /* Path to XPM/XIM files to use (xboard only) */
389     int msLoginDelay;  /* Delay per character (in msec) while sending
390                           ICS logon script (xboard only) */
391     Boolean colorize;   /* If True, use the following colors to color text */
392     /* Strings for colors, as "fg, bg, bold" (strings used in xboard only) */
393     char *colorShout;
394     char *colorSShout;
395     char *colorChannel1;
396     char *colorChannel;
397     char *colorKibitz;
398     char *colorTell;
399     char *colorChallenge;
400     char *colorRequest;
401     char *colorSeek;
402     char *colorNormal;
403     char *soundProgram; /* sound-playing program */
404     char *soundShout;
405     char *soundSShout;
406     char *soundChannel1;
407     char *soundChannel;
408     char *soundKibitz;
409     char *soundTell;
410     char *soundChallenge;
411     char *soundRequest;
412     char *soundSeek;
413     char *soundMove;
414     char *soundIcsWin;
415     char *soundIcsLoss;
416     char *soundIcsDraw;
417     char *soundIcsUnfinished;
418     char *soundIcsAlarm;
419     Boolean reuseFirst;
420     Boolean reuseSecond;
421     Boolean animateDragging; /* If True, animate mouse dragging of pieces */
422     Boolean animate;    /* If True, animate non-mouse moves */
423     int animSpeed;      /* Delay in milliseconds between animation frames */
424     Boolean popupMoveErrors;
425     Boolean popupExitMessage;
426     int showJail;
427     Boolean highlightLastMove;
428     Boolean highlightDragging;
429     Boolean blindfold;          /* if true, no pieces are drawn */
430     Boolean premove;            /* true if premove feature enabled */ 
431     Boolean premoveWhite;       /* true if premoving White first move  */ 
432     char *premoveWhiteText;     /* text of White premove 1 */ 
433     Boolean premoveBlack;       /* true if premoving Black first move */ 
434     char *premoveBlackText;     /* text of Black premove 1 */ 
435     Boolean icsAlarm;           /* true if sounding alarm at a certain time */  
436     int icsAlarmTime;           /* time to sound alarm, in milliseconds */
437     Boolean autoRaiseBoard;
438     int fontSizeTolerance; /* xboard only */
439     char *initialMode;
440     char *variant;
441     int firstProtocolVersion;
442     int secondProtocolVersion;
443     Boolean showButtonBar;
444 #if ZIPPY
445     char *zippyLines;
446     char *zippyPinhead;
447     char *zippyPassword;
448     char *zippyPassword2;
449         char *zippyPassword3;
450     char *zippyWrongPassword;
451     char *zippyAcceptOnly;
452     int zippyUseI;
453     int zippyBughouse;
454     int zippyNoplayCrafty;
455     char *zippyGameEnd;
456     char *zippyGameStart;
457     int zippyAdjourn;
458     int zippyAbort;
459     char *zippyVariants;
460     int zippyMaxGames;
461     int zippyReplayTimeout; /*seconds*/
462 #endif
463 } AppData, *AppDataPtr;
464
465 extern AppData appData;
466
467 typedef struct {
468     /* PGN 7-tag info */
469     char *event;
470     char *site;
471     char *date;
472     char *round;
473     char *white;
474     char *black;
475     ChessMove result;
476     /* Additional info */
477     char *fen;          /* NULL or FEN for starting position; input only */
478     char *resultDetails;
479     char *timeControl;
480     char *extraTags;    /* NULL or "[Tag \"Value\"]\n", etc. */
481     int whiteRating;    /* -1 if unknown */
482     int blackRating;    /* -1 if unknown */
483     VariantClass variant;
484 } GameInfo;
485
486
487
488 #endif