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