Merge branch 'maint'
[gnushogi.git] / xshogi / xshogifn.h
blob627cdf205851ec47160daf8ff9a9dbe12303a835
1 /*
2 * FILE: xshogifn.h
4 * Function declarations for xshogi.
6 * ------------------------------------------------------------------------
7 * xshogi is based on XBoard -- an Xt/Athena user interface for GNU Chess.
9 * Original authors: Dan Sears, Chris Sears
10 * Enhancements (Version 2.0 and following): Tim Mann
11 * Modifications to XShogi (Version 1.0): Matthias Mutz
12 * Enhancements to XShogi (Version 1.1): Matthias Mutz
13 * Modified implementation of ISS mode for XShogi: Matthias Mutz
14 * Current maintainer: Michael C. Vanier
16 * XShogi borrows some of its piece bitmaps from CRANES Shogi.
18 * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
19 * Enhancements Copyright 1992 Free Software Foundation, Inc.
20 * Enhancements for XShogi Copyright 1993, 1994, 1995 Matthias Mutz
21 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
23 * The following terms apply to Digital Equipment Corporation's copyright
24 * interest in XBoard:
25 * ------------------------------------------------------------------------
26 * All Rights Reserved
28 * Permission to use, copy, modify, and distribute this software and its
29 * documentation for any purpose and without fee is hereby granted,
30 * provided that the above copyright notice appear in all copies and that
31 * both that copyright notice and this permission notice appear in
32 * supporting documentation, and that the name of Digital not be
33 * used in advertising or publicity pertaining to distribution of the
34 * software without specific, written prior permission.
36 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
37 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
38 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
40 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
41 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
42 * SOFTWARE.
43 * ------------------------------------------------------------------------
45 * This file is part of GNU shogi.
47 * GNU shogi is free software; you can redistribute it and/or modify
48 * it under the terms of the GNU General Public License as published by
49 * the Free Software Foundation.
51 * GNU shogi is distributed in the hope that it will be useful,
52 * but WITHOUT ANY WARRANTY; without even the implied warranty of
53 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 * GNU General Public License for more details.
56 * You should have received a copy of the GNU General Public License
57 * along with GNU shogi; see the file COPYING. If not, write to
58 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
60 * ------------------------------------------------------------------------
64 #ifndef _XSHOGIFN_H_
65 #define _XSHOGIFN_H_
68 int main(int argc, char **argv);
69 void CreateGCs(void);
70 void CreatePieces(void);
71 void CreatePieceMenus(void);
72 char *FindFont(char *pattern, int targetPxlSize);
73 void PieceMenuPopup(Widget w, XEvent *event, String *params,
74 Cardinal *num_params);
75 static void PieceMenuSelect(Widget w, ShogiSquare piece, char *junk);
76 static void SetBlackToPlay(void);
77 static void SetWhiteToPlay(void);
78 void ReadBitmap(String name, Pixmap *pm, Pixmap *qm,
79 unsigned char small_bits[], unsigned char medium_bits[],
80 unsigned char large_bits[]);
81 void CreateGrid(void);
82 int EventToSquare(int x);
83 int EventToXSquare(int x);
84 ShogiSquare CharToPiece(int c, int p);
85 void DrawSquare(int row, int column, ShogiSquare piece);
86 void BlinkSquare(int row, int column, ShogiSquare piece);
87 void EventProc(Widget widget, XtPointer client_data, XEvent *event);
88 void DrawPosition(Widget w, XEvent *event, String *prms, Cardinal *nprms);
89 void InitPosition(int redraw);
90 void CopyBoard(Board to, Board from);
91 void CopyCatches(Catched to, Catched from);
92 void ClearCatches(Catched to);
93 void UpdateCatched(int c, int f, int d, int a, int cm);
94 void SendCurrentBoard(FILE *fp);
95 void SendBoard(FILE *fp, Board board, Catched catches);
96 void HandleUserMove(Widget w, XEvent *event);
97 void FinishUserMove(ShogiMove move_type, int to_x, int to_y);
98 void HandleMachineMove(char *message, FILE *fp);
99 void ReadGameFile(void);
100 int ReadGameFileProc(void);
101 void ApplyMove(ShogiMove *move_type, int from_x, int from_y,
102 int to_x, int to_y, int currentMove);
103 void MakeMove(ShogiMove *move_type, int from_x, int from_y,
104 int to_x, int to_y);
105 void InitShogiProgram(char *host_name, char *program_name, int *pid,
106 FILE **to, FILE **from, XtIntervalId *xid,
107 int *sendTime);
108 void ShutdownShogiPrograms(char *message);
109 void CommentPopUp(char *label);
110 void FileNamePopUp(char *label, Boolean (*proc)(char *name));
111 void FileNameCallback(Widget w, XtPointer client_data,
112 XtPointer call_data);
113 void FileNameAction(Widget w, XEvent *event, String *prms, Cardinal *nprms);
114 void PromotionPopUp(ShogiSquare piece, int to_x, int to_y, int frp);
115 void PromotionCallback(Widget w, XtPointer client_data,
116 XtPointer call_data);
117 void FileModePopUp(char *name);
118 void FileModeCallback(Widget w, XtPointer client_data,
119 XtPointer call_data);
120 void SelectCommand(Widget w, XtPointer client_data, XtPointer call_data);
121 void ModeHighlight(void);
122 void QuitProc(Widget w, XEvent *event, String *prms, Cardinal *nprms);
123 void QuitRemotePlayerProc(void);
125 Boolean LoadGame(char *name);
126 void LoadGameProc(Widget w, XEvent *event, String *prms, Cardinal *nprms);
127 Boolean LoadPosition(char *name);
128 void LoadPositionProc(Widget w, XEvent *event,
129 String *prms, Cardinal *nprms);
130 void MachineBlackProc(Widget w, XEvent *event,
131 String *prms, Cardinal *nprms);
132 void MachineWhiteProc(Widget w, XEvent *event,
133 String *prms, Cardinal *nprms);
134 void ForwardProc(Widget w, XEvent *event,
135 String *prms, Cardinal *nprms);
136 void MoveNowProc(Widget w, XEvent *event,
137 String *prms, Cardinal *nprms);
138 void ResetFileProc(void);
139 void ResetChallenge(void);
140 void ResetProc(Widget w, XEvent *event,
141 String *prms, Cardinal *nprms);
142 void Reset(int /* Boolean */ redraw);
143 Boolean Challenge(char *name);
144 void ChallengeProc(Widget w, XEvent *event,
145 String *prms, Cardinal *nprms);
146 Boolean SelectLevel(char *command);
147 void SelectLevelProc(Widget w, XEvent *event,
148 String *prms, Cardinal *nprms);
149 void BackwardProc(Widget w, XEvent *event,
150 String *prms, Cardinal *nprms);
151 void FlipViewProc(Widget w, XEvent *event,
152 String *prms, Cardinal *nprms);
153 void ForceProc(Widget w, XEvent *event,
154 String *prms, Cardinal *nprms);
155 void SaveGameProc(Widget w, XEvent *event,
156 String *prms, Cardinal *nprms);
157 Boolean SaveGame(char *name);
158 void SavePositionProc(Widget w, XEvent *event,
159 String *prms, Cardinal *nprms);
160 Boolean SavePosition(char *name);
161 void SwitchProc(Widget w, XEvent *event,
162 String *prms, Cardinal *nprms);
163 void HintProc(Widget w, XEvent *event,
164 String *prms, Cardinal *nprms);
165 void EditPositionProc(Widget w, XEvent *event,
166 String *prms, Cardinal *nprms);
167 void EditPositionDone(void);
169 void TwoMachinesProc(Widget w, XEvent *event, String *prms,
170 Cardinal *nprms);
171 void PauseProc(Widget w, XEvent *event, String *prms, Cardinal *nprms);
172 void Iconify(Widget w, XEvent *event, String *prms, Cardinal *nprms);
173 void PrintOpponents(FILE *fp);
174 void PrintPosition(FILE *fp, int move);
175 void SendToProgram(char *message, FILE *fp);
176 void ReceiveFromProgram(FILE *fp, int *source, XtInputId *id);
177 void SendSearchDepth(FILE *fp);
178 void SendTimeRemaining(FILE *fp);
179 void DisplayMessage(char *message, int toRemotePlayer);
180 void DisplayName(char *name);
181 void DisplayMove(int moveNumber);
182 void DisplayTitle(char *title);
183 void Attention(int pid);
184 void DisplayClocks(int clock_mode);
185 void DisplayTimerLabel(Widget w, char *color, long timer);
186 char *TimeString(long tm);
187 void Usage(void);
188 extern void parseGameFile(void);
189 Boolean ParseBoard(char *string);
190 void ParseMachineMove(char *machine_move, ShogiMove *move_type,
191 int *from_x, int *from_y, int *to_x, int *to_y);
192 void CatchPipeSignal(int dummy);
194 #endif /* _XSHOGIFN_H_ */