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