16773Srrh /* 2*9318Smckusick * back.h 4.2 82/11/22 36773Srrh */ 46773Srrh 56773Srrh #include <sgtty.h> 66773Srrh 7*9318Smckusick #define rnum(r) (random()%r) 86773Srrh #define D0 dice[0] 96773Srrh #define D1 dice[1] 106773Srrh #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;} 116773Srrh 126773Srrh /* 136773Srrh * 146773Srrh * Some numerical conventions: 156773Srrh * 166773Srrh * Arrays have white's value in [0], red in [1]. 176773Srrh * Numeric values which are one color or the other use 186773Srrh * -1 for white, 1 for red. 196773Srrh * Hence, white will be negative values, red positive one. 206773Srrh * This makes a lot of sense since white is going in decending 216773Srrh * order around the board, and red is ascending. 226773Srrh * 236773Srrh */ 246773Srrh 256773Srrh char EXEC[]; /* object for main program */ 266773Srrh char TEACH[]; /* object for tutorial program */ 276773Srrh 286773Srrh int pnum; /* color of player: 296773Srrh -1 = white 306773Srrh 1 = red 316773Srrh 0 = both 326773Srrh 2 = not yet init'ed */ 336773Srrh char args[100]; /* args passed to teachgammon and back */ 346773Srrh int acnt; /* length of args */ 356773Srrh int aflag; /* flag to ask for rules or instructions */ 366773Srrh int bflag; /* flag for automatic board printing */ 376773Srrh int cflag; /* case conversion flag */ 386773Srrh int hflag; /* flag for cleaning screen */ 396773Srrh int mflag; /* backgammon flag */ 406773Srrh int raflag; /* 'roll again' flag for recovered game */ 416773Srrh int rflag; /* recovered game flag */ 426773Srrh int tflag; /* cursor addressing flag */ 436773Srrh int rfl; /* saved value of rflag */ 446773Srrh int iroll; /* special flag for inputting rolls */ 456773Srrh int board[26]; /* board: negative values are white, 466773Srrh positive are red */ 476773Srrh int dice[2]; /* value of dice */ 486773Srrh int mvlim; /* 'move limit': max. number of moves */ 496773Srrh int mvl; /* working copy of mvlim */ 506773Srrh int p[5]; /* starting position of moves */ 516773Srrh int g[5]; /* ending position of moves (goals) */ 526773Srrh int h[4]; /* flag for each move if a man was hit */ 536773Srrh int cturn; /* whose turn it currently is: 546773Srrh -1 = white 556773Srrh 1 = red 566773Srrh 0 = just quitted 576773Srrh -2 = white just lost 586773Srrh 2 = red just lost */ 596773Srrh int d0; /* flag if dice have been reversed from 606773Srrh original position */ 616773Srrh int table[6][6]; /* odds table for possible rolls */ 626773Srrh int rscore; /* red's score */ 636773Srrh int wscore; /* white's score */ 646773Srrh int gvalue; /* value of game (64 max.) */ 656773Srrh int dlast; /* who doubled last (0 = neither) */ 666773Srrh int bar; /* position of bar for current player */ 676773Srrh int home; /* position of home for current player */ 686773Srrh int off[2]; /* number of men off board */ 696773Srrh int *offptr; /* pointer to off for current player */ 706773Srrh int *offopp; /* pointer to off for opponent */ 716773Srrh int in[2]; /* number of men in inner table */ 726773Srrh int *inptr; /* pointer to in for current player */ 736773Srrh int *inopp; /* pointer to in for opponent */ 746773Srrh 756773Srrh int ncin; /* number of characters in cin */ 766773Srrh char cin[100]; /* input line of current move 776773Srrh (used for reconstructing input after 786773Srrh a backspace) */ 796773Srrh 806773Srrh char *color[]; 816773Srrh /* colors as strings */ 826773Srrh char **colorptr; /* color of current player */ 836773Srrh char **Colorptr; /* color of current player, capitalized */ 846773Srrh int colen; /* length of color of current player */ 856773Srrh 866773Srrh struct sgttyb tty; /* tty information buffer */ 876773Srrh int old; /* original tty status */ 886773Srrh int noech; /* original tty status without echo */ 896773Srrh int raw; /* raw tty status, no echo */ 906773Srrh 916773Srrh int curr; /* row position of cursor */ 926773Srrh int curc; /* column position of cursor */ 936773Srrh int begscr; /* 'beginning' of screen 946773Srrh (not including board) */ 956773Srrh 966773Srrh int getout(); /* function to exit backgammon cleanly */ 97