Add __attribute__((__noreturn__)) to various function prototypes in games/.
[dragonfly.git] / games / backgammon / common_source / back.h
CommitLineData
6693db17 1/*-
984263bc
MD
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
6693db17 13 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)back.h 8.1 (Berkeley) 5/31/93
30 */
31
a579280a 32#include <termios.h>
120e5d0e
PA
33#include <stdlib.h>
34#include <unistd.h>
984263bc
MD
35
36#define rnum(r) (random()%r)
37#define D0 dice[0]
38#define D1 dice[1]
39#define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;}
40
41/*
42 *
43 * Some numerical conventions:
44 *
45 * Arrays have white's value in [0], red in [1].
46 * Numeric values which are one color or the other use
47 * -1 for white, 1 for red.
48 * Hence, white will be negative values, red positive one.
6693db17 49 * This makes a lot of sense since white is going in descending
984263bc
MD
50 * order around the board, and red is ascending.
51 *
52 */
53
54extern const char EXEC[]; /* object for main program */
55extern const char TEACH[];/* object for tutorial program */
56
57extern int pnum; /* color of player:
58 -1 = white
59 1 = red
60 0 = both
61 2 = not yet init'ed */
62extern char *args[16]; /* args passed to teachgammon and back */
63extern int acnt; /* number of args */
64extern int aflag; /* flag to ask for rules or instructions */
65extern int bflag; /* flag for automatic board printing */
66extern int cflag; /* case conversion flag */
67extern int hflag; /* flag for cleaning screen */
68extern int mflag; /* backgammon flag */
69extern int raflag; /* 'roll again' flag for recovered game */
70extern int rflag; /* recovered game flag */
71extern int tflag; /* cursor addressing flag */
72extern int rfl; /* saved value of rflag */
73extern int iroll; /* special flag for inputting rolls */
74extern int board[26]; /* board: negative values are white,
75 positive are red */
76extern int dice[2]; /* value of dice */
77extern int mvlim; /* 'move limit': max. number of moves */
78extern int mvl; /* working copy of mvlim */
79extern int p[5]; /* starting position of moves */
80extern int g[5]; /* ending position of moves (goals) */
81extern int h[4]; /* flag for each move if a man was hit */
82extern int cturn; /* whose turn it currently is:
83 -1 = white
84 1 = red
85 0 = just quitted
86 -2 = white just lost
87 2 = red just lost */
88extern int d0; /* flag if dice have been reversed from
89 original position */
90extern int table[6][6]; /* odds table for possible rolls */
91extern int rscore; /* red's score */
92extern int wscore; /* white's score */
93extern int gvalue; /* value of game (64 max.) */
94extern int dlast; /* who doubled last (0 = neither) */
95extern int bar; /* position of bar for current player */
96extern int home; /* position of home for current player */
97extern int off[2]; /* number of men off board */
98extern int *offptr; /* pointer to off for current player */
99extern int *offopp; /* pointer to off for opponent */
100extern int in[2]; /* number of men in inner table */
101extern int *inptr; /* pointer to in for current player */
102extern int *inopp; /* pointer to in for opponent */
103
104extern int ncin; /* number of characters in cin */
105extern char cin[100]; /* input line of current move
106 (used for reconstructing input after
107 a backspace) */
108
109extern const char *const color[];
110 /* colors as strings */
111extern const char *const *colorptr; /* color of current player */
112extern const char *const *Colorptr; /* color of current player, capitalized */
113extern int colen; /* length of color of current player */
114
a579280a 115extern struct termios tty; /* tty information buffer */
984263bc
MD
116extern int old; /* original tty status */
117extern int noech; /* original tty status without echo */
06e4c4ec 118extern int bgraw; /* raw tty status, no echo */
984263bc
MD
119
120extern int curr; /* row position of cursor */
121extern int curc; /* column position of cursor */
122extern int begscr; /* 'beginning' of screen
123 (not including board) */
124
6693db17
SW
125int addbuf(int);
126void backone(int);
127void buflush(void);
128int canhit(int, int);
129int checkmove(int);
120e5d0e 130void clear(void);
120e5d0e
PA
131void clend(void);
132void cline(void);
120e5d0e 133int count(void);
6693db17
SW
134void curmove(int, int);
135void dble(void);
136int dblgood(void);
09ac707a 137void errexit(const char *) __dead2;
6693db17
SW
138void fancyc(char);
139void fboard(void);
140void fixtty(int);
141int freemen(int);
142void getarg(int, char **);
143int getcaps(const char *);
144void getmove(void);
09ac707a 145void getout(int) __dead2; /* function to exit backgammon cleanly */
6693db17
SW
146void gwrite(void);
147void init(void);
120e5d0e 148int makmove(int);
6693db17 149int movallow(void);
120e5d0e 150void movback(int);
6693db17
SW
151void move(int);
152void moverr(int);
153int movokay(int);
154void newpos(void);
155void nexturn(void);
156void odds(int, int, int);
120e5d0e 157void proll(void);
120e5d0e 158int quit(void);
6693db17
SW
159char readc(void);
160void recover(const char *);
161void refresh(void);
120e5d0e 162void roll(void);
6693db17 163void save(int);
120e5d0e
PA
164#ifdef TEACHGAMMON_TEXT
165int text(const char *const *);
166#else
167void text(const char *const *);
168#endif
6693db17
SW
169int trapped(int, int);
170void wrboard(void);
171void wrhit(int);
172void wrint(int);
173void writec(char);
174void writel(const char *);
175void wrscore(void);
176int yorn(char);