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