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