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