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