back.h revision 1.3 1 /* $NetBSD: back.h,v 1.3 1995/03/21 15:05:28 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)back.h 8.1 (Berkeley) 5/31/93
36 */
37
38 #include <sgtty.h>
39
40 #define rnum(r) (random()%r)
41 #define D0 dice[0]
42 #define D1 dice[1]
43 #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;}
44
45 /*
46 *
47 * Some numerical conventions:
48 *
49 * Arrays have white's value in [0], red in [1].
50 * Numeric values which are one color or the other use
51 * -1 for white, 1 for red.
52 * Hence, white will be negative values, red positive one.
53 * This makes a lot of sense since white is going in decending
54 * order around the board, and red is ascending.
55 *
56 */
57
58 char EXEC[]; /* object for main program */
59 char TEACH[]; /* object for tutorial program */
60
61 int pnum; /* color of player:
62 -1 = white
63 1 = red
64 0 = both
65 2 = not yet init'ed */
66 char args[100]; /* args passed to teachgammon and back */
67 int acnt; /* length of args */
68 int aflag; /* flag to ask for rules or instructions */
69 int bflag; /* flag for automatic board printing */
70 int cflag; /* case conversion flag */
71 int hflag; /* flag for cleaning screen */
72 int mflag; /* backgammon flag */
73 int raflag; /* 'roll again' flag for recovered game */
74 int rflag; /* recovered game flag */
75 int tflag; /* cursor addressing flag */
76 int rfl; /* saved value of rflag */
77 int iroll; /* special flag for inputting rolls */
78 int board[26]; /* board: negative values are white,
79 positive are red */
80 int dice[2]; /* value of dice */
81 int mvlim; /* 'move limit': max. number of moves */
82 int mvl; /* working copy of mvlim */
83 int p[5]; /* starting position of moves */
84 int g[5]; /* ending position of moves (goals) */
85 int h[4]; /* flag for each move if a man was hit */
86 int cturn; /* whose turn it currently is:
87 -1 = white
88 1 = red
89 0 = just quitted
90 -2 = white just lost
91 2 = red just lost */
92 int d0; /* flag if dice have been reversed from
93 original position */
94 int table[6][6]; /* odds table for possible rolls */
95 int rscore; /* red's score */
96 int wscore; /* white's score */
97 int gvalue; /* value of game (64 max.) */
98 int dlast; /* who doubled last (0 = neither) */
99 int bar; /* position of bar for current player */
100 int home; /* position of home for current player */
101 int off[2]; /* number of men off board */
102 int *offptr; /* pointer to off for current player */
103 int *offopp; /* pointer to off for opponent */
104 int in[2]; /* number of men in inner table */
105 int *inptr; /* pointer to in for current player */
106 int *inopp; /* pointer to in for opponent */
107
108 int ncin; /* number of characters in cin */
109 char cin[100]; /* input line of current move
110 (used for reconstructing input after
111 a backspace) */
112
113 char *color[];
114 /* colors as strings */
115 char **colorptr; /* color of current player */
116 char **Colorptr; /* color of current player, capitalized */
117 int colen; /* length of color of current player */
118
119 struct sgttyb tty; /* tty information buffer */
120 int old; /* original tty status */
121 int noech; /* original tty status without echo */
122 int raw; /* raw tty status, no echo */
123
124 int curr; /* row position of cursor */
125 int curc; /* column position of cursor */
126 int begscr; /* 'beginning' of screen
127 (not including board) */
128
129 int getout(); /* function to exit backgammon cleanly */
130