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