]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/main.c
1 /* $NetBSD: main.c,v 1.11 2003/08/07 09:37:52 agc Exp $ */
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
34 __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
35 The Regents of the University of California. All rights reserved.\n");
40 static char sccsid
[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
42 __RCSID("$NetBSD: main.c,v 1.11 2003/08/07 09:37:52 agc Exp $");
53 #include <sys/types.h>
57 # define PRIO 00 /* default priority */
59 uid_t Mother
= 51 + (51 << 8);
62 ** #### ##### # #### ##### #### ##### # #
63 ** # # # # # # # # # # # #
64 ** ### # ##### #### # #### ### ###
65 ** # # # # # # # # # # # #
66 ** #### # # # # # # # # ##### # #
68 ** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help
69 ** from Jeff Poskanzer and Pete Rubinstein.
71 ** I also want to thank everyone here at Berkeley who
72 ** where crazy enough to play the undebugged game. I want to
73 ** particularly thank Nick Whyte, who made considerable
74 ** suggestions regarding the content of the game. Why, I'll
75 ** never forget the time he suggested the name for the
78 ** Please send comments, questions, and suggestions about this
82 ** Electronics Research Laboratory
84 ** University of California
85 ** Berkeley, California 94720
87 ** If you make ANY changes in the game, I sure would like to
88 ** know about them. It is sort of an ongoing project for me,
89 ** and I very much want to put in any bug fixes and improvements
90 ** that you might come up with.
92 ** FORTRASH version by Kay R. Fisher (DEC) "and countless others".
93 ** That was adapted from the "original BASIC program" (ha!) by
94 ** Mike Mayfield (Centerline Engineering).
96 ** Additional inspiration taken from FORTRAN version by
97 ** David Matuszek and Paul Reynolds which runs on the CDC
98 ** 7600 at Lawrence Berkeley Lab, maintained there by
99 ** Andy Davidson. This version is also available at LLL
100 ** and at LMSC. In all fairness, this version was the
101 ** major inspiration for this version of the game (trans-
102 ** lation: I ripped off a whole lot of code).
104 ** Minor other input from the "Battelle Version 7A" by Joe Miller
105 ** (Graphics Systems Group, Battelle-Columbus Labs) and
106 ** Ross Pavlac (Systems Programmer, Battelle Memorial
107 ** Institute). That version was written in December '74
108 ** and extensively modified June '75. It was adapted
109 ** from the FTN version by Ron Williams of CDC Sunnyvale,
110 ** which was adapted from the Basic version distributed
111 ** by DEC. It also had "neat stuff swiped" from T. T.
112 ** Terry and Jim Korp (University of Texas), Hicks (Penn
113 ** U.), and Rick Maus (Georgia Tech). Unfortunately, it
114 ** was not as readable as it could have been and so the
115 ** translation effort was severely hampered. None the
116 ** less, I got the idea of inhabited starsystems from this
119 ** Permission is given for use, copying, and modification of
120 ** all or part of this program and related documentation,
121 ** provided that all reference to the authors are maintained.
124 **********************************************************************
126 ** NOTES TO THE MAINTAINER:
128 ** There is a compilation option xTRACE which must be set for any
129 ** trace information to be generated. It is probably defined in
130 ** the version that you get. It can be removed, however, if you
131 ** have trouble finding room in core.
133 ** Many things in trek are not as clear as they might be, but are
134 ** done to reduce space. I compile with the -f and -O flags. I
135 ** am constrained to running with non-separated I/D space, since
136 ** we don't have doubleing point hardware here; even if we did, I
137 ** would like trek to be available to the large number of people
138 ** who either have an 11/40 or do not have FP hardware. I also
139 ** found it desirable to make the code run reentrant, so this
140 ** added even more space constraints.
142 ** I use the portable C library to do my I/O. This is done be-
143 ** cause I wanted the game easily transportable to other C
144 ** implementations, and because I was too lazy to do the doubleing
145 ** point input myself. Little did I know. The portable C library
146 ** released by Bell Labs has more bugs than you would believe, so
147 ** I ended up rewriting the whole blessed thing. Trek excercises
148 ** many of the bugs in it, as well as bugs in some of the section
149 ** III UNIX routines. We have fixed them here. One main problem
150 ** was a bug in alloc() that caused it to always ask for a large
151 ** hunk of memory, which worked fine unless you were almost out,
152 ** which I inevitably was. If you want the code for all of this
153 ** stuff, it is also available through me.
155 ***********************************************************************
160 int main
__P((int, char **));
175 /* Revoke setgid privileges */
182 vect
= (long) curtime
;
187 if (tcgetattr(1, &argp
) == 0)
189 if (cfgetispeed(&argp
) < B1200
)
193 while (ac
> 1 && av
[0][0] == '-')
197 case 'a': /* append to log file */
201 case 'f': /* set fast mode */
205 case 's': /* set slow mode */
210 case 't': /* trace */
211 if (getuid() != Mother
)
217 case 'p': /* set priority */
218 if (getuid() != Mother
)
220 prio
= atoi(av
[0] + 2);
225 printf("Invalid option: %s\n", av
[0]);
232 errx(1, "arg count");
235 f_log = fopen(av[0], opencode);
238 printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n");
242 if ( !getynpar("Another game") )
249 } while (getynpar("Another game"));