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