|
|
1.1 ! root 1: ! 2: /* This file contains code for X-CHESS. ! 3: Copyright (C) 1986 Free Software Foundation, Inc. ! 4: ! 5: This file is part of X-CHESS. ! 6: ! 7: X-CHESS is distributed in the hope that it will be useful, ! 8: but WITHOUT ANY WARRANTY. No author or distributor ! 9: accepts responsibility to anyone for the consequences of using it ! 10: or for whether it serves any particular purpose or works at all, ! 11: unless he says so in writing. Refer to the X-CHESS General Public ! 12: License for full details. ! 13: ! 14: Everyone is granted permission to copy, modify and redistribute ! 15: X-CHESS, but only under the conditions described in the ! 16: X-CHESS General Public License. A copy of this license is ! 17: supposed to have been given to you along with X-CHESS so you ! 18: can know your rights and responsibilities. It should be in a ! 19: file named COPYING. Among other things, the copyright notice ! 20: and this notice must be preserved on all copies. */ ! 21: ! 22: ! 23: /* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:39 $ ! 24: * $Source: /users/faustus/xchess/RCS/xchess.h,v $ ! 25: * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group ! 26: * Permission is granted to do anything with this code except sell it ! 27: * or remove this message. ! 28: * ! 29: * Definitions for the X chess program. ! 30: */ ! 31: ! 32: #include "std.h" ! 33: #include <X11/Xlib.h> ! 34: #include "scrollText/scrollText.h" ! 35: ! 36: #define SIZE 8 ! 37: ! 38: typedef enum piecetype { PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING } piecetype; ! 39: typedef enum movetype { MOVE, QCASTLE, KCASTLE, CAPTURE } movetype; ! 40: typedef enum color { WHITE, BLACK, NONE } color; ! 41: ! 42: typedef struct piece { ! 43: enum piecetype type; ! 44: enum color color; ! 45: } piece; ! 46: ! 47: /* The board has y=0 and black at the top... This probably isn't the best ! 48: * place to keep track of who can castle, but it's part of the game state... ! 49: */ ! 50: ! 51: typedef struct board { ! 52: piece square[SIZE][SIZE]; ! 53: bool white_cant_castle_k; ! 54: bool white_cant_castle_q; ! 55: bool black_cant_castle_k; ! 56: bool black_cant_castle_q; ! 57: } board; ! 58: ! 59: typedef struct move { ! 60: movetype type; ! 61: piece piece; ! 62: piece taken; ! 63: int fromx, fromy; ! 64: int tox, toy; ! 65: struct move *next; ! 66: bool enpassant; ! 67: bool check; ! 68: } move; ! 69: ! 70: #define iswhite(win, i, j) (!(((i) + (j)) % 2)) ! 71: ! 72: /* Stuff for the display. */ ! 73: ! 74: typedef struct windata { ! 75: Display *display; ! 76: Window basewin; ! 77: Window boardwin; ! 78: Window recwin; ! 79: Window wclockwin; ! 80: Window bclockwin; ! 81: Window messagewin; ! 82: Window buttonwin; ! 83: Window jailwin; ! 84: Window icon; ! 85: Pixmap iconpixmap; ! 86: XColor blackpiece; ! 87: XColor whitepiece; ! 88: XColor blacksquare; ! 89: XColor whitesquare; ! 90: XColor border; ! 91: XColor textcolor; ! 92: XColor textback; ! 93: XColor errortext; ! 94: XColor playertext; ! 95: XColor cursorcolor; ! 96: XFontStruct *small; ! 97: XFontStruct *medium; ! 98: XFontStruct *large; ! 99: bool bnw; ! 100: color color; ! 101: bool flipped; ! 102: double whitehands[3]; ! 103: double blackhands[3]; ! 104: char *txtassoc; ! 105: } windata; ! 106: ! 107: #define SMALL_FONT "6x10" ! 108: #define MEDIUM_FONT "8x13" ! 109: #define LARGE_FONT "9x15" ! 110: #define JAIL_FONT "6x10" ! 111: ! 112: #define SQUARE_WIDTH 80 ! 113: #define SQUARE_HEIGHT 80 ! 114: ! 115: #define BORDER_WIDTH 3 ! 116: ! 117: #define BOARD_WIDTH 8 * SQUARE_WIDTH + 7 * BORDER_WIDTH ! 118: #define BOARD_HEIGHT 8 * SQUARE_HEIGHT + 7 * BORDER_WIDTH ! 119: #define BOARD_XPOS 0 ! 120: #define BOARD_YPOS 0 ! 121: ! 122: #define RECORD_WIDTH 265 /* 40 chars * 6 pixels / character. */ ! 123: #define RECORD_HEIGHT 433 ! 124: #define RECORD_XPOS BOARD_WIDTH + BORDER_WIDTH ! 125: #define RECORD_YPOS 0 ! 126: ! 127: #define JAIL_WIDTH RECORD_WIDTH ! 128: #define JAIL_HEIGHT 163 ! 129: #define JAIL_XPOS RECORD_XPOS ! 130: #define JAIL_YPOS RECORD_YPOS + RECORD_HEIGHT + BORDER_WIDTH ! 131: ! 132: #define CLOCK_WIDTH 131 ! 133: #define CLOCK_HEIGHT 131 + BORDER_WIDTH + 20 ! 134: #define WCLOCK_XPOS RECORD_XPOS ! 135: #define WCLOCK_YPOS RECORD_HEIGHT + JAIL_HEIGHT + BORDER_WIDTH * 2 ! 136: #define BCLOCK_XPOS WCLOCK_XPOS + CLOCK_WIDTH + BORDER_WIDTH ! 137: #define BCLOCK_YPOS WCLOCK_YPOS ! 138: ! 139: #define MESS_WIDTH 329 ! 140: #define MESS_HEIGHT 92 ! 141: #define MESS_XPOS 0 ! 142: #define MESS_YPOS BOARD_HEIGHT + BORDER_WIDTH ! 143: ! 144: #define BUTTON_WIDTH MESS_WIDTH ! 145: #define BUTTON_HEIGHT MESS_HEIGHT ! 146: #define BUTTON_XPOS MESS_WIDTH + BORDER_WIDTH ! 147: #define BUTTON_YPOS MESS_YPOS ! 148: ! 149: #define BASE_WIDTH BOARD_WIDTH + RECORD_WIDTH + BORDER_WIDTH * 3 ! 150: #define BASE_HEIGHT BOARD_HEIGHT + MESS_HEIGHT + BORDER_WIDTH * 3 ! 151: ! 152: #define BASE_XPOS 50 ! 153: #define BASE_YPOS 50 ! 154: ! 155: #define BLACK_PIECE_COLOR "#202020" ! 156: #define WHITE_PIECE_COLOR "#FFFFCC" ! 157: #define BLACK_SQUARE_COLOR "#77A26D" ! 158: #define WHITE_SQUARE_COLOR "#C8C365" ! 159: #define BORDER_COLOR "#902E39" ! 160: #define TEXT_COLOR "#006D6D" ! 161: #define TEXT_BACK "#FFFFDD" ! 162: #define ERROR_TEXT "Red" ! 163: #define PLAYER_TEXT "Blue" ! 164: #define CURSOR_COLOR "#FF606F" ! 165: ! 166: #define DEF_RECORD_FILE "xchess.game" ! 167: ! 168: #define NUM_FLASHES 5 ! 169: #define FLASH_SIZE 10 ! 170: ! 171: /* xchess.c */ ! 172: ! 173: extern void main(); ! 174: extern bool debug; ! 175: extern char *progname; ! 176: extern char *proghost; ! 177: extern char *piecenames[]; ! 178: extern char *colornames[]; ! 179: extern char *movetypenames[]; ! 180: extern char *dispname1, *dispname2; ! 181: extern bool oneboard; ! 182: extern bool bnwflag; ! 183: extern bool progflag; ! 184: extern bool blackflag; ! 185: extern bool quickflag; ! 186: extern int num_flashes; ! 187: extern int flash_size; ! 188: extern char *black_piece_color; ! 189: extern char *white_piece_color; ! 190: extern char *black_square_color; ! 191: extern char *white_square_color; ! 192: extern char *border_color; ! 193: extern char *text_color; ! 194: extern char *text_back; ! 195: extern char *error_text; ! 196: extern char *player_text; ! 197: extern char *cursor_color; ! 198: ! 199: /* board.c */ ! 200: ! 201: extern void board_setup(); ! 202: extern void board_drawall(); ! 203: extern void board_move(); ! 204: extern board *chessboard; ! 205: extern void board_init(); ! 206: ! 207: /* window.c */ ! 208: ! 209: extern bool win_setup(); ! 210: extern void win_redraw(); ! 211: extern void win_restart(); ! 212: extern void win_drawboard(); ! 213: extern void win_drawpiece(); ! 214: extern void win_erasepiece(); ! 215: extern void win_process(); ! 216: extern void win_flash(); ! 217: extern windata *win1, *win2; ! 218: extern bool win_flashmove; ! 219: ! 220: /* control.c */ ! 221: ! 222: extern void button_pressed(); ! 223: extern void button_released(); ! 224: extern void move_piece(); ! 225: extern void prog_move(); ! 226: extern move *moves; ! 227: extern move *foremoves; ! 228: extern color nexttomove; ! 229: extern void replay(); ! 230: extern void forward(); ! 231: extern void cleanup(); ! 232: extern void restart(); ! 233: extern bool noisyflag; ! 234: ! 235: /* valid.c */ ! 236: ! 237: extern bool valid_move(); ! 238: ! 239: /* record.c */ ! 240: ! 241: extern void record_move(); ! 242: extern void record_reset(); ! 243: extern void record_save(); ! 244: extern void record_back(); ! 245: extern void record_init(); ! 246: extern void record_end(); ! 247: extern bool record_english; ! 248: extern char *record_file; ! 249: extern int movenum; ! 250: extern bool saveflag; ! 251: ! 252: /* message.c */ ! 253: ! 254: extern void message_init(); ! 255: extern void message_add(); ! 256: extern void message_send(); ! 257: ! 258: /* clock.c */ ! 259: ! 260: extern void clock_init(); ! 261: extern void clock_draw(); ! 262: extern void clock_update(); ! 263: extern void clock_switch(); ! 264: extern bool clock_started; ! 265: extern int movesperunit; ! 266: extern int timeunit; ! 267: extern int whiteseconds; ! 268: extern int blackseconds; ! 269: ! 270: /* button.c */ ! 271: ! 272: extern void button_draw(); ! 273: extern void button_service(); ! 274: ! 275: /* jail.c */ ! 276: ! 277: extern void jail_init(); ! 278: extern void jail_draw(); ! 279: extern void jail_add(); ! 280: extern void jail_remove(); ! 281: ! 282: /* program.c */ ! 283: extern bool program_init(); ! 284: extern void program_end(); ! 285: extern void program_send(); ! 286: extern void program_undo(); ! 287: extern move *program_get(); ! 288: ! 289: /* parse.c */ ! 290: ! 291: extern void load_game(); ! 292: extern move *parse_file(); ! 293: extern move *parse_move(); ! 294: extern move *parse_imove(); ! 295: extern bool loading_flag; ! 296: extern bool loading_paused; ! 297: ! 298: /* popup.c */ ! 299: ! 300: extern bool pop_question(); ! 301:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.