games - mille - remove #ifdef madness
[dragonfly.git] / games / mille / mille.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1982, 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.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)mille.h 8.1 (Berkeley) 5/31/93
34 *
35 * $FreeBSD: src/games/mille/mille.h,v 1.7 1999/12/12 06:17:24 billf Exp $
46c76430 36 * $DragonFly: src/games/mille/mille.h,v 1.6 2006/08/27 17:17:23 pavalos Exp $
984263bc
MD
37 */
38
39# include <sys/types.h>
40# include <sys/uio.h>
41# include <ctype.h>
42# include <curses.h>
43# include <string.h>
44# include <stdlib.h>
45# include <unistd.h>
46
47/*
48 * @(#)mille.h 1.1 (Berkeley) 4/1/82
49 */
50
51/*
52 * Miscellaneous constants
53 */
54
55# define unsgn unsigned
56# define CARD short
57
58# define HAND_SZ 7 /* number of cards in a hand */
59# define DECK_SZ 101 /* number of cards in decks */
60# define NUM_SAFE 4 /* number of saftey cards */
61# define NUM_MILES 5 /* number of milestones types */
62# define NUM_CARDS 20 /* number of types of cards */
63# define BOARD_Y 17 /* size of board screen */
64# define BOARD_X 40
65# define MILES_Y 7 /* size of mileage screen */
66# define MILES_X 80
67# define SCORE_Y 17 /* size of score screen */
68# define SCORE_X 40
69# define MOVE_Y 10 /* Where to print move prompt */
70# define MOVE_X 20
71# define ERR_Y 15 /* Where to print errors */
72# define ERR_X 5
73# define EXT_Y 4 /* Where to put Extension */
74# define EXT_X 9
75
76# define PLAYER 0
77# define COMP 1
78
79# define W_SMALL 0 /* Small (initial) window */
80# define W_FULL 1 /* Full (final) window */
81
82/*
83 * Move types
84 */
85
86# define M_DISCARD 0
87# define M_DRAW 1
88# define M_PLAY 2
89# define M_ORDER 3
90
91/*
92 * Scores
93 */
94
95# define SC_SAFETY 100
96# define SC_ALL_SAFE 300
97# define SC_COUP 300
98# define SC_TRIP 400
99# define SC_SAFE 300
100# define SC_DELAY 300
101# define SC_EXTENSION 200
102# define SC_SHUT_OUT 500
103
104/*
105 * safety descriptions
106 */
107
108# define S_UNKNOWN 0 /* location of safety unknown */
109# define S_IN_HAND 1 /* safety in player's hand */
110# define S_PLAYED 2 /* safety has been played */
111# define S_GAS_SAFE 0 /* Gas safety card index */
112# define S_SPARE_SAFE 1 /* Tire safety card index */
113# define S_DRIVE_SAFE 2 /* Driveing safety card index */
114# define S_RIGHT_WAY 3 /* Right-of-Way card index */
115# define S_CONV 15 /* conversion from C_ to S_ */
116
117/*
118 * card numbers
119 */
120
121# define C_INIT -1
122# define C_25 0
123# define C_50 1
124# define C_75 2
125# define C_100 3
126# define C_200 4
127# define C_EMPTY 5
128# define C_FLAT 6
129# define C_CRASH 7
130# define C_STOP 8
131# define C_LIMIT 9
132# define C_GAS 10
133# define C_SPARE 11
134# define C_REPAIRS 12
135# define C_GO 13
136# define C_END_LIMIT 14
137# define C_GAS_SAFE 15
138# define C_SPARE_SAFE 16
139# define C_DRIVE_SAFE 17
140# define C_RIGHT_WAY 18
141
142/*
143 * prompt types
144 */
145
146# define MOVEPROMPT 0
147# define REALLYPROMPT 1
148# define ANOTHERHANDPROMPT 2
149# define ANOTHERGAMEPROMPT 3
150# define SAVEGAMEPROMPT 4
151# define SAMEFILEPROMPT 5
152# define FILEPROMPT 6
153# define EXTENSIONPROMPT 7
154# define OVERWRITEFILEPROMPT 8
155
a0b4d56d
MD
156# define erasechar() _tty.c_cc[VERASE]
157# define killchar() _tty.c_cc[VKILL]
158# define _tty cur_term->Nttyb
984263bc
MD
159
160typedef struct {
161 bool coups[NUM_SAFE];
162 bool can_go;
163 bool new_battle;
164 bool new_speed;
165 short safety[NUM_SAFE];
166 short sh_safety[NUM_SAFE];
167 short nummiles[NUM_MILES];
168 short sh_nummiles[NUM_MILES];
169 CARD hand[HAND_SZ];
170 CARD sh_hand[HAND_SZ];
171 CARD battle;
172 CARD sh_battle;
173 CARD speed;
174 CARD sh_speed;
175 int mileage;
176 int sh_mileage;
177 int hand_tot;
178 int sh_hand_tot;
179 int safescore;
180 int sh_safescore;
181 int coupscore;
182 int total;
183 int sh_total;
184 int games;
185 int sh_games;
186 int was_finished;
187} PLAY;
188
189/*
190 * macros
191 */
192
193# define other(x) (1 - x)
194# define nextplay() (Play = other(Play))
195# define nextwin(x) (1 - x)
196# define opposite(x) (Opposite[x])
197# define issafety(x) (x >= C_GAS_SAFE)
198
199/*
200 * externals
201 */
202
203extern bool Debug, Finished, Next, On_exit, Order, Saved;
204
46c76430
PA
205extern char *Fromfile, Initstr[];
206extern const char *C_fmt, **C_name;
984263bc
MD
207
208extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos,
209 Numneed[], Numseen[NUM_CARDS], Play, Value[], Window;
210
211extern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], Sh_discard,
212 *Topcard;
213
214extern FILE *outf;
215
216extern PLAY Player[2];
217
218extern WINDOW *Board, *Miles, *Score;
219
220/*
221 * functions
222 */
223
851dc90d
EN
224void account (CARD);
225void calcmove (void);
226bool canplay (PLAY *, PLAY *, CARD);
227bool check_ext (bool);
228void check_more (void);
229void die (int);
230void domove (void);
46c76430 231bool error (const char *, ...);
984263bc 232#ifdef EXTRAP
851dc90d 233void extrapolate (PLAY *);
984263bc 234#endif
851dc90d
EN
235void finalscore (PLAY *);
236CARD getcard (void);
237bool getyn (int);
238void init (void);
239int isrepair (CARD);
240void newboard (void);
241void newscore (void);
242bool onecard (PLAY *);
243void prboard (void);
244void prompt (int);
245void prscore (bool);
246char readch (void);
247bool rest_f (char *);
248int roll (int, int);
249void rub (int);
250CARD safety (CARD);
251bool save (void);
252void shuffle (void);
253void sort (CARD *);
46c76430 254bool varpush (int, ssize_t (*)(int, const struct iovec *, int));
984263bc 255#ifdef EXTRAP
851dc90d 256void undoex (void);
984263bc 257#endif