1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1980 Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 06/01/90"; 16 #endif /* not lint */ 17 18 # include "trek.h" 19 # include <stdio.h> 20 # include <sgtty.h> 21 # define PRIO 00 /* default priority */ 22 23 int Mother = 51 + (51 << 8); 24 25 /* 26 ** #### ##### # #### ##### #### ##### # # 27 ** # # # # # # # # # # # # 28 ** ### # ##### #### # #### ### ### 29 ** # # # # # # # # # # # # 30 ** #### # # # # # # # # ##### # # 31 ** 32 ** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help 33 ** from Jeff Poskanzer and Pete Rubinstein. 34 ** 35 ** I also want to thank everyone here at Berkeley who 36 ** where crazy enough to play the undebugged game. I want to 37 ** particularly thank Nick Whyte, who made considerable 38 ** suggestions regarding the content of the game. Why, I'll 39 ** never forget the time he suggested the name for the 40 ** "capture" command. 41 ** 42 ** Please send comments, questions, and suggestions about this 43 ** game to: 44 ** Eric P. Allman 45 ** Project INGRES 46 ** Electronics Research Laboratory 47 ** Cory Hall 48 ** University of California 49 ** Berkeley, California 94720 50 ** 51 ** If you make ANY changes in the game, I sure would like to 52 ** know about them. It is sort of an ongoing project for me, 53 ** and I very much want to put in any bug fixes and improvements 54 ** that you might come up with. 55 ** 56 ** FORTRASH version by Kay R. Fisher (DEC) "and countless others". 57 ** That was adapted from the "original BASIC program" (ha!) by 58 ** Mike Mayfield (Centerline Engineering). 59 ** 60 ** Additional inspiration taken from FORTRAN version by 61 ** David Matuszek and Paul Reynolds which runs on the CDC 62 ** 7600 at Lawrence Berkeley Lab, maintained there by 63 ** Andy Davidson. This version is also available at LLL 64 ** and at LMSC. In all fairness, this version was the 65 ** major inspiration for this version of the game (trans- 66 ** lation: I ripped off a whole lot of code). 67 ** 68 ** Minor other input from the "Battelle Version 7A" by Joe Miller 69 ** (Graphics Systems Group, Battelle-Columbus Labs) and 70 ** Ross Pavlac (Systems Programmer, Battelle Memorial 71 ** Institute). That version was written in December '74 72 ** and extensively modified June '75. It was adapted 73 ** from the FTN version by Ron Williams of CDC Sunnyvale, 74 ** which was adapted from the Basic version distributed 75 ** by DEC. It also had "neat stuff swiped" from T. T. 76 ** Terry and Jim Korp (University of Texas), Hicks (Penn 77 ** U.), and Rick Maus (Georgia Tech). Unfortunately, it 78 ** was not as readable as it could have been and so the 79 ** translation effort was severely hampered. None the 80 ** less, I got the idea of inhabited starsystems from this 81 ** version. 82 ** 83 ** Permission is given for use, copying, and modification of 84 ** all or part of this program and related documentation, 85 ** provided that all reference to the authors are maintained. 86 ** 87 ** 88 ********************************************************************** 89 ** 90 ** NOTES TO THE MAINTAINER: 91 ** 92 ** There is a compilation option xTRACE which must be set for any 93 ** trace information to be generated. It is probably defined in 94 ** the version that you get. It can be removed, however, if you 95 ** have trouble finding room in core. 96 ** 97 ** Many things in trek are not as clear as they might be, but are 98 ** done to reduce space. I compile with the -f and -O flags. I 99 ** am constrained to running with non-seperated I/D space, since 100 ** we don't have doubleing point hardware here; even if we did, I 101 ** would like trek to be available to the large number of people 102 ** who either have an 11/40 or do not have FP hardware. I also 103 ** found it desirable to make the code run reentrant, so this 104 ** added even more space constraints. 105 ** 106 ** I use the portable C library to do my I/O. This is done be- 107 ** cause I wanted the game easily transportable to other C 108 ** implementations, and because I was too lazy to do the doubleing 109 ** point input myself. Little did I know. The portable C library 110 ** released by Bell Labs has more bugs than you would believe, so 111 ** I ended up rewriting the whole blessed thing. Trek excercises 112 ** many of the bugs in it, as well as bugs in some of the section 113 ** III UNIX routines. We have fixed them here. One main problem 114 ** was a bug in alloc() that caused it to always ask for a large 115 ** hunk of memory, which worked fine unless you were almost out, 116 ** which I inevitably was. If you want the code for all of this 117 ** stuff, it is also available through me. 118 ** 119 *********************************************************************** 120 */ 121 122 main(argc, argv) 123 int argc; 124 char **argv; 125 { 126 long vect; 127 /* extern FILE *f_log; */ 128 register char opencode; 129 int prio; 130 register int ac; 131 register char **av; 132 struct sgttyb argp; 133 int been_here = 0; 134 135 av = argv; 136 ac = argc; 137 av++; 138 time(&vect); 139 srand(vect); 140 opencode = 'w'; 141 prio = PRIO; 142 if (gtty(1, &argp) == 0) 143 { 144 if ((argp.sg_ispeed ) < B1200) 145 Etc.fast++; 146 } 147 while (ac > 1 && av[0][0] == '-') 148 { 149 switch (av[0][1]) 150 { 151 case 'a': /* append to log file */ 152 opencode = 'a'; 153 break; 154 155 case 'f': /* set fast mode */ 156 Etc.fast++; 157 break; 158 159 case 's': /* set slow mode */ 160 Etc.fast = 0; 161 break; 162 163 # ifdef xTRACE 164 case 't': /* trace */ 165 if (getuid() != Mother) 166 goto badflag; 167 Trace++; 168 break; 169 # endif 170 171 case 'p': /* set priority */ 172 if (getuid() != Mother) 173 goto badflag; 174 if (scanf(-1, &av[0][2], "%d", &prio) > 0) 175 break; 176 177 default: 178 badflag: 179 printf("Invalid option: %s\n", av[0]); 180 181 } 182 ac--; 183 av++; 184 } 185 if (ac > 2) 186 syserr(0, "arg count"); 187 /* 188 if (ac > 1) 189 f_log = fopen(av[0], opencode); 190 */ 191 192 printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n"); 193 194 setexit(); 195 if ( been_here == 1 ) 196 { 197 if ( !getynpar("Another game") ) 198 exit(0); 199 } 200 been_here = 1; 201 do 202 { 203 setup(); 204 play(); 205 } while (getynpar("Another game")); 206 207 fflush(stdout); 208 } 209