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