1 /* 2 * back.h 4.2 82/11/22 3 */ 4 5 #include <sgtty.h> 6 7 #define rnum(r) (random()%r) 8 #define D0 dice[0] 9 #define D1 dice[1] 10 #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;} 11 12 /* 13 * 14 * Some numerical conventions: 15 * 16 * Arrays have white's value in [0], red in [1]. 17 * Numeric values which are one color or the other use 18 * -1 for white, 1 for red. 19 * Hence, white will be negative values, red positive one. 20 * This makes a lot of sense since white is going in decending 21 * order around the board, and red is ascending. 22 * 23 */ 24 25 char EXEC[]; /* object for main program */ 26 char TEACH[]; /* object for tutorial program */ 27 28 int pnum; /* color of player: 29 -1 = white 30 1 = red 31 0 = both 32 2 = not yet init'ed */ 33 char args[100]; /* args passed to teachgammon and back */ 34 int acnt; /* length of args */ 35 int aflag; /* flag to ask for rules or instructions */ 36 int bflag; /* flag for automatic board printing */ 37 int cflag; /* case conversion flag */ 38 int hflag; /* flag for cleaning screen */ 39 int mflag; /* backgammon flag */ 40 int raflag; /* 'roll again' flag for recovered game */ 41 int rflag; /* recovered game flag */ 42 int tflag; /* cursor addressing flag */ 43 int rfl; /* saved value of rflag */ 44 int iroll; /* special flag for inputting rolls */ 45 int board[26]; /* board: negative values are white, 46 positive are red */ 47 int dice[2]; /* value of dice */ 48 int mvlim; /* 'move limit': max. number of moves */ 49 int mvl; /* working copy of mvlim */ 50 int p[5]; /* starting position of moves */ 51 int g[5]; /* ending position of moves (goals) */ 52 int h[4]; /* flag for each move if a man was hit */ 53 int cturn; /* whose turn it currently is: 54 -1 = white 55 1 = red 56 0 = just quitted 57 -2 = white just lost 58 2 = red just lost */ 59 int d0; /* flag if dice have been reversed from 60 original position */ 61 int table[6][6]; /* odds table for possible rolls */ 62 int rscore; /* red's score */ 63 int wscore; /* white's score */ 64 int gvalue; /* value of game (64 max.) */ 65 int dlast; /* who doubled last (0 = neither) */ 66 int bar; /* position of bar for current player */ 67 int home; /* position of home for current player */ 68 int off[2]; /* number of men off board */ 69 int *offptr; /* pointer to off for current player */ 70 int *offopp; /* pointer to off for opponent */ 71 int in[2]; /* number of men in inner table */ 72 int *inptr; /* pointer to in for current player */ 73 int *inopp; /* pointer to in for opponent */ 74 75 int ncin; /* number of characters in cin */ 76 char cin[100]; /* input line of current move 77 (used for reconstructing input after 78 a backspace) */ 79 80 char *color[]; 81 /* colors as strings */ 82 char **colorptr; /* color of current player */ 83 char **Colorptr; /* color of current player, capitalized */ 84 int colen; /* length of color of current player */ 85 86 struct sgttyb tty; /* tty information buffer */ 87 int old; /* original tty status */ 88 int noech; /* original tty status without echo */ 89 int raw; /* raw tty status, no echo */ 90 91 int curr; /* row position of cursor */ 92 int curc; /* column position of cursor */ 93 int begscr; /* 'beginning' of screen 94 (not including board) */ 95 96 int getout(); /* function to exit backgammon cleanly */ 97