home *** CD-ROM | disk | FTP | other *** search
-
- /* @(#)othello.h 1.6 90/04/10
- *
- * Definitions used by the othello program.
- *
- * Original SunView version by Ed Falk - Sun Microsystems Inc.
- *
- * Rewritten for independent use by
- * Rich Burridge, Sun Microsystems, Australia
- *
- * Copyright (c) Ed Falk & Rich Burridge - Sun Microsystems.
- * All rights reserved.
- *
- * Permission is given to distribute these sources, as long as the
- * introductory messages are not removed, and no monies are exchanged.
- *
- * No responsibility is taken for any errors on inaccuracies inherent
- * either to the comments or the code of this program, but if reported
- * to me, then an attempt will be made to fix them.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <sys/ioctl.h>
- #include <sys/types.h>
- #include <sys/time.h>
- #include <signal.h>
-
- #define FCLOSE (void) fclose /* To make lint happy. */
- #define FFLUSH (void) fflush
- #define FSEEK (void) fseek
- #define FPRINTF (void) fprintf
- #define GETTIMEOFDAY (void) gettimeofday
- #define IOCTL (void) ioctl
- #define PUTC (void) putc
- #define READ (void) read
- #define SELECT (void) select
- #define SIGNAL (void) signal
- #define SPRINTF (void) sprintf
- #define STRCAT (void) strcat
- #define STRCPY (void) strcpy
- #define WRITE (void) write
-
- #define BBORDER 15 /* Width of the othello border. */
- #define BOARD_SIZE 8 /* 8x8 playing board */
- #define BGAP 10 /* Width of the gap between buttons. */
- #define BHEIGHT 32 /* Height of an othello button item. */
- #define BWIDTH 64 /* Width of an othello button item. */
- #define CELL_SIZE (int) ((TOTAL_WIDTH-(2*BBORDER)) / BOARD_SIZE)
- #define CHEIGHT 20 /* Height of an othello cycle item. */
- #define CWIDTH 32 /* Width of an othello cycle item. */
- #define CY ((NOROWS*BHEIGHT) + ((NOROWS-1)*BGAP) + (2*BBORDER))
- #define NOBUTS 6 /* Number of othello buttons. */
- #define NOROWS 6 /* Number of rows of othello items. */
- #define PIECE_MARGIN 8
- #define PIECE_RAD (CELL_SIZE / 2 - PIECE_MARGIN)
- #define TOTAL_HEIGHT CY + (8 * CELL_SIZE) + (2 * BBORDER)
- #define TOTAL_WIDTH ((NOBUTS*BWIDTH) + ((NOBUTS-1)*BGAP) + (2*BBORDER))
-
- #define BLACK 1 /* Piece definitions. */
- #define FREE 0
- #define WHITE -1
-
- #define FALSE 0 /* Boolean definitions. */
- #define TRUE 1
-
- #define ESCAPE 27 /* ASCII escape character. */
- #define EQUAL(a, b) !strncmp(a, b, strlen(b))
- #define FOR_BOARD(i) for (i = 0; i < 64; i++)
- #define ICONHEIGHT 64 /* Height in pixels for Othello icon. */
- #define ICONWIDTH 64 /* Width in pixels of Othello icon. */
- #define INC argc-- ; argv++ ;
- #define INFINITY 10000
- #define INIT_ASPIRE 3
- #define INIT_DEPTH 2
- #define ISMOVE(pos, player) \
- (nextmove(pos, NOMOVE, (BOARD *) NULL, player) != NOMOVE)
- #define MAXASPIRE 6
- #define MAXCHOICES 7 /* Limit on number of choices for cyclic. */
- #define MAXCURSORS 3 /* Maximum number of cursor types. */
- #define MAXDEPTH 6
- #define MAXFONTS 2 /* Maximum number of font types. */
- #define MAXIMAGES 9 /* Maximum number of image types. */
- #define MAXITEMS 13 /* Number of buttons, cyclics and messages. */
-
- #ifndef MAXLINE
- #define MAXLINE 80 /* Length of character strings. */
- #endif /*MAXLINE*/
-
- #define MAXMENUS 4 /* Maximum number of popup menus. */
- #define NOMOVE -1
- #define OPPONENT(p) p * -1
- #define PAUSE usleep(500000)
- #define PSIZE 40 /* Diameter of playing piece. */
-
- #ifndef REMNAME
- #define REMNAME "othello.remarks"
- #endif /*REMNAME*/
-
- #ifndef NO_4_3SIGNAL
- #define SIGRET void
- #else
- #define SIGRET int
- #endif /*NO_4_3SIGNAL*/
-
- #define VINVUL 50
-
- #define MAX_REMARKS 50
- #define FIRST_REMARK (INFINITY+1)
-
- /* Various pseudo events used by the othello program. */
- #define FRAME_REPAINT 100 /* Othello window needs repainting. */
- #define ENTER_WINDOW 101 /* Mouse has entered the Othello window. */
- #define EXIT_WINDOW 102 /* Mouse has exited Othello window. */
- #define LEFT_DOWN 103 /* Left mouse button was depressed. */
- #define LEFT_UP 104 /* Left mouse button was debounced. */
- #define MIDDLE_DOWN 105 /* Middle mouse button was depressed. */
- #define MIDDLE_UP 106 /* Middle mouse button was debounced. */
- #define RIGHT_DOWN 107 /* Right mouse button was depressed. */
- #define RIGHT_UP 108 /* Right mouse button was debounced. */
- #define KEYBOARD 109 /* Keyboard character has been pressed. */
- #define MOUSE_MOVING 110 /* Mouse is moving. */
- #define IGNORE_EVENT 111 /* No interest in this event. */
-
- /* Batch or locking direction (ON or OFF). */
- enum bltype { IS_OFF, IS_ON } ;
-
- /* Othello move status. */
- enum cantype { WHITE_START, WHITE_MOVING,
- BLACK_START, BLACK_MOVING, GAME_OVER } ;
-
- /* Current cursor type. */
- enum curtype { CANVASCUR, HOURGLASS, NOCURSOR } ;
-
- enum font_type { NFONT, BFONT } ; /* Text font definitions. */
-
- /* Different types of graphic images. */
- enum image_type { BUT_NORMAL, BUT_INVERT, BUT_STENCIL,
- CY_NORMAL, CY_LINVERT, CY_RINVERT, CY_STENCIL,
- P_WHITE, P_BLACK } ;
-
- /* Different types of panel items. */
- enum item_type { P_BUTTON, P_CYCLE, P_MESSAGE } ;
-
- /* Different panel items. */
- enum panel_type { DONE_BUT, LAST_BUT, NEW_GAME_BUT, SUGGEST_BUT, UNDO_BUT,
- QUIT_BUT, COMPUTER_PLAYS, REMARK, ASPIRATION, DIFFICULTY,
- PANEL_MES, REMARK_MES, SCORE_MES } ;
-
- enum set_type { INCREMENT, DECREMENT, NONE } ; /* Cycle directions. */
-
- enum optype { RCLR, RINV, RSRC } ; /* Rasterop codes. */
-
- enum playtype { PLAY_BLACK, PLAY_WHITE } ; /* What the computer is playing. */
-
- char *getenv(), *sprintf() ;
-
- typedef struct {
- int square[64] ;
- int moves_left ;
- } BOARD ;
-
- struct iteminfo /* Item information record. */
- {
- enum item_type type ; /* Item type. */
- int x ; /* X position of this panel item. */
- int y ; /* Y position of this panel item. */
- int width ; /* Width of this panel item. */
- int height ; /* Height of this panel item. */
- char text[60] ; /* Text string associated with this item. */
- int value ; /* Current value of item. */
- int (*func)() ; /* Function to obey for this panel item. */
- } ;
-