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