153d071fbSrrh /* 2*954a9e43Sbostic * Copyright (c) 1980, 1993 3*954a9e43Sbostic * The Regents of the University of California. All rights reserved. 4b2780829Sdist * 5785daf11Sbostic * %sccs.include.redist.c% 666562148Sbostic * 7*954a9e43Sbostic * @(#)back.h 8.1 (Berkeley) 05/31/93 853d071fbSrrh */ 953d071fbSrrh 1053d071fbSrrh #include <sgtty.h> 1153d071fbSrrh 126a5a0a43Smckusick #define rnum(r) (random()%r) 1353d071fbSrrh #define D0 dice[0] 1453d071fbSrrh #define D1 dice[1] 1553d071fbSrrh #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;} 1653d071fbSrrh 1753d071fbSrrh /* 1853d071fbSrrh * 1953d071fbSrrh * Some numerical conventions: 2053d071fbSrrh * 2153d071fbSrrh * Arrays have white's value in [0], red in [1]. 2253d071fbSrrh * Numeric values which are one color or the other use 2353d071fbSrrh * -1 for white, 1 for red. 2453d071fbSrrh * Hence, white will be negative values, red positive one. 2553d071fbSrrh * This makes a lot of sense since white is going in decending 2653d071fbSrrh * order around the board, and red is ascending. 2753d071fbSrrh * 2853d071fbSrrh */ 2953d071fbSrrh 3053d071fbSrrh char EXEC[]; /* object for main program */ 3153d071fbSrrh char TEACH[]; /* object for tutorial program */ 3253d071fbSrrh 3353d071fbSrrh int pnum; /* color of player: 3453d071fbSrrh -1 = white 3553d071fbSrrh 1 = red 3653d071fbSrrh 0 = both 3753d071fbSrrh 2 = not yet init'ed */ 3853d071fbSrrh char args[100]; /* args passed to teachgammon and back */ 3953d071fbSrrh int acnt; /* length of args */ 4053d071fbSrrh int aflag; /* flag to ask for rules or instructions */ 4153d071fbSrrh int bflag; /* flag for automatic board printing */ 4253d071fbSrrh int cflag; /* case conversion flag */ 4353d071fbSrrh int hflag; /* flag for cleaning screen */ 4453d071fbSrrh int mflag; /* backgammon flag */ 4553d071fbSrrh int raflag; /* 'roll again' flag for recovered game */ 4653d071fbSrrh int rflag; /* recovered game flag */ 4753d071fbSrrh int tflag; /* cursor addressing flag */ 4853d071fbSrrh int rfl; /* saved value of rflag */ 4953d071fbSrrh int iroll; /* special flag for inputting rolls */ 5053d071fbSrrh int board[26]; /* board: negative values are white, 5153d071fbSrrh positive are red */ 5253d071fbSrrh int dice[2]; /* value of dice */ 5353d071fbSrrh int mvlim; /* 'move limit': max. number of moves */ 5453d071fbSrrh int mvl; /* working copy of mvlim */ 5553d071fbSrrh int p[5]; /* starting position of moves */ 5653d071fbSrrh int g[5]; /* ending position of moves (goals) */ 5753d071fbSrrh int h[4]; /* flag for each move if a man was hit */ 5853d071fbSrrh int cturn; /* whose turn it currently is: 5953d071fbSrrh -1 = white 6053d071fbSrrh 1 = red 6153d071fbSrrh 0 = just quitted 6253d071fbSrrh -2 = white just lost 6353d071fbSrrh 2 = red just lost */ 6453d071fbSrrh int d0; /* flag if dice have been reversed from 6553d071fbSrrh original position */ 6653d071fbSrrh int table[6][6]; /* odds table for possible rolls */ 6753d071fbSrrh int rscore; /* red's score */ 6853d071fbSrrh int wscore; /* white's score */ 6953d071fbSrrh int gvalue; /* value of game (64 max.) */ 7053d071fbSrrh int dlast; /* who doubled last (0 = neither) */ 7153d071fbSrrh int bar; /* position of bar for current player */ 7253d071fbSrrh int home; /* position of home for current player */ 7353d071fbSrrh int off[2]; /* number of men off board */ 7453d071fbSrrh int *offptr; /* pointer to off for current player */ 7553d071fbSrrh int *offopp; /* pointer to off for opponent */ 7653d071fbSrrh int in[2]; /* number of men in inner table */ 7753d071fbSrrh int *inptr; /* pointer to in for current player */ 7853d071fbSrrh int *inopp; /* pointer to in for opponent */ 7953d071fbSrrh 8053d071fbSrrh int ncin; /* number of characters in cin */ 8153d071fbSrrh char cin[100]; /* input line of current move 8253d071fbSrrh (used for reconstructing input after 8353d071fbSrrh a backspace) */ 8453d071fbSrrh 8553d071fbSrrh char *color[]; 8653d071fbSrrh /* colors as strings */ 8753d071fbSrrh char **colorptr; /* color of current player */ 8853d071fbSrrh char **Colorptr; /* color of current player, capitalized */ 8953d071fbSrrh int colen; /* length of color of current player */ 9053d071fbSrrh 9153d071fbSrrh struct sgttyb tty; /* tty information buffer */ 9253d071fbSrrh int old; /* original tty status */ 9353d071fbSrrh int noech; /* original tty status without echo */ 9453d071fbSrrh int raw; /* raw tty status, no echo */ 9553d071fbSrrh 9653d071fbSrrh int curr; /* row position of cursor */ 9753d071fbSrrh int curc; /* column position of cursor */ 9853d071fbSrrh int begscr; /* 'beginning' of screen 9953d071fbSrrh (not including board) */ 10053d071fbSrrh 10153d071fbSrrh int getout(); /* function to exit backgammon cleanly */ 102