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