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