]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - mille/mille.h
Allow this to be cross-compiled (in a manner consistent with boggle's
[bsdgames-darwin.git] / mille / mille.h
1 /* $NetBSD: mille.h,v 1.5 1995/03/24 05:01:51 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1982, 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 * @(#)mille.h 8.1 (Berkeley) 5/31/93
36 */
37
38 # include <sys/types.h>
39 # include <ctype.h>
40 # include <curses.h>
41 # include <termios.h>
42 # include <string.h>
43
44 /*
45 * @(#)mille.h 1.1 (Berkeley) 4/1/82
46 */
47
48 /*
49 * Miscellaneous constants
50 */
51
52 # define unsgn unsigned
53 # define CARD short
54
55 # define HAND_SZ 7 /* number of cards in a hand */
56 # define DECK_SZ 101 /* number of cards in decks */
57 # define NUM_SAFE 4 /* number of saftey cards */
58 # define NUM_MILES 5 /* number of milestones types */
59 # define NUM_CARDS 20 /* number of types of cards */
60 # define BOARD_Y 17 /* size of board screen */
61 # define BOARD_X 40
62 # define MILES_Y 7 /* size of mileage screen */
63 # define MILES_X 80
64 # define SCORE_Y 17 /* size of score screen */
65 # define SCORE_X 40
66 # define MOVE_Y 10 /* Where to print move prompt */
67 # define MOVE_X 20
68 # define ERR_Y 15 /* Where to print errors */
69 # define ERR_X 5
70 # define EXT_Y 4 /* Where to put Extension */
71 # define EXT_X 9
72
73 # define PLAYER 0
74 # define COMP 1
75
76 # define W_SMALL 0 /* Small (initial) window */
77 # define W_FULL 1 /* Full (final) window */
78
79 /*
80 * Move types
81 */
82
83 # define M_DISCARD 0
84 # define M_DRAW 1
85 # define M_PLAY 2
86 # define M_ORDER 3
87
88 /*
89 * Scores
90 */
91
92 # define SC_SAFETY 100
93 # define SC_ALL_SAFE 300
94 # define SC_COUP 300
95 # define SC_TRIP 400
96 # define SC_SAFE 300
97 # define SC_DELAY 300
98 # define SC_EXTENSION 200
99 # define SC_SHUT_OUT 500
100
101 /*
102 * safety descriptions
103 */
104
105 # define S_UNKNOWN 0 /* location of safety unknown */
106 # define S_IN_HAND 1 /* safety in player's hand */
107 # define S_PLAYED 2 /* safety has been played */
108 # define S_GAS_SAFE 0 /* Gas safety card index */
109 # define S_SPARE_SAFE 1 /* Tire safety card index */
110 # define S_DRIVE_SAFE 2 /* Driveing safety card index */
111 # define S_RIGHT_WAY 3 /* Right-of-Way card index */
112 # define S_CONV 15 /* conversion from C_ to S_ */
113
114 /*
115 * card numbers
116 */
117
118 # define C_INIT -1
119 # define C_25 0
120 # define C_50 1
121 # define C_75 2
122 # define C_100 3
123 # define C_200 4
124 # define C_EMPTY 5
125 # define C_FLAT 6
126 # define C_CRASH 7
127 # define C_STOP 8
128 # define C_LIMIT 9
129 # define C_GAS 10
130 # define C_SPARE 11
131 # define C_REPAIRS 12
132 # define C_GO 13
133 # define C_END_LIMIT 14
134 # define C_GAS_SAFE 15
135 # define C_SPARE_SAFE 16
136 # define C_DRIVE_SAFE 17
137 # define C_RIGHT_WAY 18
138
139 /*
140 * prompt types
141 */
142
143 # define MOVEPROMPT 0
144 # define REALLYPROMPT 1
145 # define ANOTHERHANDPROMPT 2
146 # define ANOTHERGAMEPROMPT 3
147 # define SAVEGAMEPROMPT 4
148 # define SAMEFILEPROMPT 5
149 # define FILEPROMPT 6
150 # define EXTENSIONPROMPT 7
151 # define OVERWRITEFILEPROMPT 8
152
153 # ifdef SYSV
154 # define srandom(x) srand(x)
155 # define random() rand()
156
157 # ifndef attron
158 # define erasechar() _tty.c_cc[VERASE]
159 # define killchar() _tty.c_cc[VKILL]
160 # endif
161 # else
162 # ifndef erasechar
163 # define erasechar() _tty.sg_erase
164 # define killchar() _tty.sg_kill
165 # endif
166 # endif SYSV
167
168 typedef struct {
169 bool coups[NUM_SAFE];
170 bool can_go;
171 bool new_battle;
172 bool new_speed;
173 short safety[NUM_SAFE];
174 short sh_safety[NUM_SAFE];
175 short nummiles[NUM_MILES];
176 short sh_nummiles[NUM_MILES];
177 CARD hand[HAND_SZ];
178 CARD sh_hand[HAND_SZ];
179 CARD battle;
180 CARD sh_battle;
181 CARD speed;
182 CARD sh_speed;
183 int mileage;
184 int sh_mileage;
185 int hand_tot;
186 int sh_hand_tot;
187 int safescore;
188 int sh_safescore;
189 int coupscore;
190 int total;
191 int sh_total;
192 int games;
193 int sh_games;
194 int was_finished;
195 } PLAY;
196
197 /*
198 * macros
199 */
200
201 # define other(x) (1 - x)
202 # define nextplay() (Play = other(Play))
203 # define nextwin(x) (1 - x)
204 # define opposite(x) (Opposite[x])
205 # define issafety(x) (x >= C_GAS_SAFE)
206
207 /*
208 * externals
209 */
210
211 extern bool Debug, Finished, Next, On_exit, Order, Saved;
212
213 extern char *C_fmt, **C_name, *Fromfile, Initstr[];
214
215 extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos,
216 Numneed[], Numseen[NUM_CARDS], Play, Value[], Window;
217
218 extern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], Sh_discard,
219 *Topcard;
220
221 extern FILE *outf;
222
223 extern PLAY Player[2];
224
225 extern WINDOW *Board, *Miles, *Score;
226
227 /*
228 * functions
229 */
230
231 CARD getcard();