4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / games / adventure / init.c
CommitLineData
da1ddb48 1/*-
1dfd973d 2 * Copyright (c) 1993 The Regents of the University of California.
da1ddb48
KB
3 * All rights reserved.
4 *
49016dbd
KB
5 * The game adventure was originally written in Fortran by Will Crowther
6 * and Don Woods. It was later translated to C and enhanced by Jim
7 * Gillogly. This code is derived from software contributed to Berkeley
8 * by Jim Gillogly at The Rand Corporation.
da1ddb48
KB
9 *
10 * %sccs.include.redist.c%
11 */
12
1dfd973d 13#ifndef lint
01140ede 14static char sccsid[] = "@(#)init.c 8.1 (Berkeley) %G%";
1dfd973d
KB
15#endif /* not lint */
16
da1ddb48 17/* Re-coding of advent in C: data initialization */
c96ddd80 18
699b2c2e
KB
19#include <sys/types.h>
20#include <stdio.h>
21#include "hdr.h"
c96ddd80
RH
22
23int blklin = TRUE;
c96ddd80
RH
24
25int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000,
26 010000,020000,040000,0100000};
27
28
29init(command) /* everything for 1st time run */
30char *command; /* command we were called with */
49016dbd 31{
c96ddd80
RH
32 rdata(); /* read data from orig. file */
33 linkdata();
34 poof();
c96ddd80
RH
35}
36
49016dbd
KB
37char *decr(a,b,c,d,e)
38char a,b,c,d,e;
39{
40 static char buf[6];
41
42 buf[0] = a-'+';
43 buf[1] = b-'-';
44 buf[2] = c-'#';
45 buf[3] = d-'&';
46 buf[4] = e-'%';
47 buf[5] = 0;
48 return buf;
49}
c96ddd80
RH
50
51linkdata() /* secondary data manipulation */
52{ register int i,j;
49016dbd 53
c96ddd80
RH
54 /* array linkages */
55 for (i=1; i<=LOCSIZ; i++)
56 if (ltext[i].seekadr!=0 && travel[i] != 0)
57 if ((travel[i]->tverb)==1) cond[i]=2;
58 for (j=100; j>0; j--)
59 if (fixd[j]>0)
60 { drop(j+100,fixd[j]);
61 drop(j,plac[j]);
62 }
63 for (j=100; j>0; j--)
64 { fixed[j]=fixd[j];
65 if (plac[j]!=0 && fixd[j]<=0) drop(j,plac[j]);
66 }
67
68 maxtrs=79;
69 tally=0;
70 tally2=0;
71
72 for (i=50; i<=maxtrs; i++)
73 { if (ptext[i].seekadr!=0) prop[i] = -1;
74 tally -= prop[i];
75 }
76
77 /* define mnemonics */
49016dbd
KB
78 keys = vocab(DECR(k,e,y,s,\0), 1);
79 lamp = vocab(DECR(l,a,m,p,\0), 1);
80 grate = vocab(DECR(g,r,a,t,e), 1);
81 cage = vocab(DECR(c,a,g,e,\0),1);
82 rod = vocab(DECR(r,o,d,\0,\0),1);
c96ddd80 83 rod2=rod+1;
49016dbd
KB
84 steps=vocab(DECR(s,t,e,p,s),1);
85 bird = vocab(DECR(b,i,r,d,\0),1);
86 door = vocab(DECR(d,o,o,r,\0),1);
87 pillow= vocab(DECR(p,i,l,l,o), 1);
88 snake = vocab(DECR(s,n,a,k,e), 1);
89 fissur= vocab(DECR(f,i,s,s,u), 1);
90 tablet= vocab(DECR(t,a,b,l,e), 1);
91 clam = vocab(DECR(c,l,a,m,\0),1);
92 oyster= vocab(DECR(o,y,s,t,e), 1);
93 magzin= vocab(DECR(m,a,g,a,z), 1);
94 dwarf = vocab(DECR(d,w,a,r,f), 1);
95 knife = vocab(DECR(k,n,i,f,e), 1);
96 food = vocab(DECR(f,o,o,d,\0),1);
97 bottle= vocab(DECR(b,o,t,t,l), 1);
98 water = vocab(DECR(w,a,t,e,r), 1);
99 oil = vocab(DECR(o,i,l,\0,\0),1);
100 plant = vocab(DECR(p,l,a,n,t), 1);
c96ddd80 101 plant2=plant+1;
49016dbd
KB
102 axe = vocab(DECR(a,x,e,\0,\0),1);
103 mirror= vocab(DECR(m,i,r,r,o), 1);
104 dragon= vocab(DECR(d,r,a,g,o), 1);
105 chasm = vocab(DECR(c,h,a,s,m), 1);
106 troll = vocab(DECR(t,r,o,l,l), 1);
c96ddd80 107 troll2=troll+1;
49016dbd
KB
108 bear = vocab(DECR(b,e,a,r,\0),1);
109 messag= vocab(DECR(m,e,s,s,a), 1);
110 vend = vocab(DECR(v,e,n,d,i), 1);
111 batter= vocab(DECR(b,a,t,t,e), 1);
112
113 nugget= vocab(DECR(g,o,l,d,\0),1);
114 coins = vocab(DECR(c,o,i,n,s), 1);
115 chest = vocab(DECR(c,h,e,s,t), 1);
116 eggs = vocab(DECR(e,g,g,s,\0),1);
117 tridnt= vocab(DECR(t,r,i,d,e), 1);
118 vase = vocab(DECR(v,a,s,e,\0),1);
119 emrald= vocab(DECR(e,m,e,r,a), 1);
120 pyram = vocab(DECR(p,y,r,a,m), 1);
121 pearl = vocab(DECR(p,e,a,r,l), 1);
122 rug = vocab(DECR(r,u,g,\0,\0),1);
123 chain = vocab(DECR(c,h,a,i,n), 1);
124
125 back = vocab(DECR(b,a,c,k,\0),0);
126 look = vocab(DECR(l,o,o,k,\0),0);
127 cave = vocab(DECR(c,a,v,e,\0),0);
128 null = vocab(DECR(n,u,l,l,\0),0);
129 entrnc= vocab(DECR(e,n,t,r,a), 0);
130 dprssn= vocab(DECR(d,e,p,r,e), 0);
131 enter = vocab(DECR(e,n,t,e,r), 0);
132
133 pour = vocab(DECR(p,o,u,r,\0), 2);
134 say = vocab(DECR(s,a,y,\0,\0),2);
135 lock = vocab(DECR(l,o,c,k,\0),2);
136 throw = vocab(DECR(t,h,r,o,w), 2);
137 find = vocab(DECR(f,i,n,d,\0),2);
138 invent= vocab(DECR(i,n,v,e,n), 2);
139
c96ddd80
RH
140 /* initialize dwarves */
141 chloc=114;
142 chloc2=140;
143 for (i=1; i<=6; i++)
144 dseen[i]=FALSE;
145 dflag=0;
146 dloc[1]=19;
147 dloc[2]=27;
148 dloc[3]=33;
149 dloc[4]=44;
150 dloc[5]=64;
151 dloc[6]=chloc;
152 daltlc=18;
153
154 /* random flags & ctrs */
155 turns=0;
156 lmwarn=FALSE;
157 iwest=0;
158 knfloc=0;
159 detail=0;
160 abbnum=5;
161 for (i=0; i<=4; i++)
162 if (rtext[2*i+81].seekadr!=0) maxdie=i+1;
163 numdie=holdng=dkill=foobar=bonus=0;
164 clock1=30;
165 clock2=50;
166 saved=0;
167 closng=panic=closed=scorng=FALSE;
168}
169
170
171
172trapdel() /* come here if he hits a del */
173{ delhit++; /* main checks, treats as QUIT */
174 signal(2,trapdel); /* catch subsequent DELs */
175}
176
177
178startup()
699b2c2e
KB
179{
180 time_t time();
181
c96ddd80 182 demo=start(0);
699b2c2e
KB
183 srand((int)(time((time_t *)NULL))); /* random seed */
184 /* srand(371); /* non-random seed */
c96ddd80
RH
185 hinted[3]=yes(65,1,0);
186 newloc=1;
49016dbd 187 delhit = 0;
c96ddd80
RH
188 limit=330;
189 if (hinted[3]) limit=1000; /* better batteries if instrucs */
190}