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