1 /* Main program for DUNGEON */
2
3 /* COPYRIGHT 1980, 1990, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. */
4 /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
5 /* WRITTEN BY R. M. SUPNIK */
6 /* Translated from Fortran to C by Andrew Plotkin <erkyrath@netcom.com>
7 on 10/4/98. */
8
9 /* 16-Aug-94 RMS Version 3.2. */
10 /* 30-Jun-92 RMS Changed file names to lower case. */
11 /* 29-Jun-92 RMS Changed OUTCH to 6 for VAX, UNIX compatibility. */
12
13 #include "glk.h"
14 #include "miscfort.h"
15 #include "funcs.h"
16 #include "commons.h"
17
18 /* Initialized data */
19
20 struct misc_1_ misc_1 = {
21 0, 0, 0, 0, 0, 0,
22 {66, 67, 68, 69, 70, 71, 72, 65, 73},
23 0, 0, 0, 0, 0, 0,
24 3, 2, {"B"}
25 };
26
27 struct curxt_1_ curxt_1 = { {1, 2, 3, 3}, 0, 0, 0, 0, 0 };
28
29 struct screen_1_ screen_1 = { 0, 0, 0,
30 { 1024, 153, 5120, 154, 3072, 152, 7168, 151},
31 { 151, 271, 3072, 152, 272, 7168, 153, 270, 5120, 154, 269, 1024}};
32
33 struct puzzle_1_ puzzle_1 = {
34 { 1024, -8, 2048, -7, 3072, 1, 4096, 9, 5120, 8, 6144, 7, 7168, -1, 8192, -9 },
35 { 269, -8, 270, 8, 271, 1, 272, -1 },
36 { 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 0, -1, 0, 0, -1, 0, 1,
38 1, -1, 0, 1, 0, -2, 0, 1,
39 1, 0, 0, 0, 0, 1, 0, 1,
40 1, -3, 0, 0, -1, -1, 0, 1,
41 1, 0, 0, -1, 0, 0, 0, 1,
42 1, 1, 1, 0, 0, 0, 1, 1,
43 1, 1, 1, 1, 1, 1, 1, 1 } };
44
45
46 /* Main program */
dungeon_main(void)47 int dungeon_main(void)
48 {
49 /* Local variables */
50 integer i__, x;
51
52
53 /* Declarations */
54
55
56 /* Data statements for constant arrays */
57
58
59
60
61
62 /* DUNGEON, PAGE 2 */
63
64 /* 1) Initialize data structures */
65 /* 2) Initialize files */
66 /* 3) Play game */
67
68 rmsg_1.mlnt = 0;
69 /* init array counters. */
70 objcts_1.olnt = 0;
71 /* array limits are param */
72 rooms_1.rlnt = 0;
73 vill_1.vlnt = 0;
74 advs_1.alnt = 0;
75 cevent_1.clnt = 0;
76 exits_1.xlnt = 1;
77 oroom2_1.r2lnt = 0;
78
79 play_1.ltshft = 10;
80 /* set up state variables */
81 play_1.mxscor = play_1.ltshft;
82 play_1.egscor = 0;
83 play_1.egmxsc = 0;
84 play_1.mxload = 100;
85 play_1.rwscor = 0;
86 play_1.deaths = 0;
87 play_1.moves = 0;
88 misc_1.pltime = 0;
89 play_1.mungrm = 0;
90 play_1.hs = 0;
91 prsvec_1.prsa = 0;
92 /* clear parse vector. */
93 prsvec_1.prsi = 0;
94 prsvec_1.prso = 0;
95 prsvec_1.prscon = 1;
96 prssta_1.oflag = 0;
97 /* clear orphans. */
98 prssta_1.oact = 0;
99 prssta_1.oprep1 = 0;
100 prssta_1.oobj1 = 0;
101 prssta_1.oprep = 0;
102 s_copy(prssta_1.oname, " ", 8L, 1L);
103 prssta_1.oprep2 = 0;
104 prssta_1.oobj2 = 0;
105 prssta_1.bunlnt = 0;
106 /* clear bunch vector. */
107 prssta_1.bunsub = 0;
108 for (i__ = 1; i__ <= 10; ++i__) {
109 prssta_1.bunvec[i__ - 1] = 0;
110 /* L100: */
111 }
112 hack_1.thfflg = FALSE_;
113 /* thief not introduced b */
114 hack_1.thfact = TRUE_;
115 /* is active. */
116 hack_1.swdact = FALSE_;
117 /* sword is inactive. */
118 hack_1.swdsta = 0;
119
120 /* sword is off. */
121 misc_1.mbase = 0;
122 /* init melee base. */
123 misc_1.inpch = 5;
124 /* tty input */
125 misc_1.outch = 6;
126 /* tty output. */
127 misc_1.dbch = 2;
128 /* DUNGEON, PAGE 3 */
129
130 /* Init all arrays. */
131
132 /* data base. */
133 for (i__ = 1; i__ <= 30; ++i__) {
134 /* clear clock events */
135 cevent_1.cflag[i__ - 1] = FALSE_;
136 cevent_1.ccncel[i__ - 1] = FALSE_;
137 cevent_1.ctick[i__ - 1] = 0;
138 cevent_1.cactio[i__ - 1] = 0;
139 /* L200: */
140 }
141
142 /* clear flags. */
143 /* clear switches. */
144 v_set(&findex_1, sizeof(struct findex_1_), 0);
145 /*
146 for (i__ = 1; i__ <= 56; ++i__) {
147 flags[i__ - 1] = FALSE_;
148 }
149 for (i__ = 1; i__ <= 24; ++i__) {
150 switch__[i__ - 1] = 0;
151 }
152 */
153
154 findex_1.egyptf = TRUE_;
155 /* some start as true. */
156 findex_1.cagetf = TRUE_;
157 findex_1.mr1f = TRUE_;
158 findex_1.mr2f = TRUE_;
159 findex_1.follwf = TRUE_;
160 findex_1.ormtch = 4;
161 /* number of matches. */
162 findex_1.lcell = 1;
163 findex_1.pnumb = 1;
164 findex_1.mdir = 270;
165 findex_1.mloc = 162;
166 findex_1.cphere = 10;
167
168 for (i__ = 1; i__ <= 20; ++i__) {
169 /* clear room 2 array. */
170 oroom2_1.r2[i__ - 1] = 0;
171 oroom2_1.o2[i__ - 1] = 0;
172 /* L500: */
173 }
174
175 for (i__ = 1; i__ <= 1000; ++i__) {
176 /* clear travel array. */
177 exits_1.travel[i__ - 1] = 0;
178 /* L600: */
179 }
180
181 for (i__ = 1; i__ <= 4; ++i__) {
182 /* clear villains arrays. */
183 vill_1.vopps[i__ - 1] = 0;
184 vill_1.vprob[i__ - 1] = 0;
185 vill_1.villns[i__ - 1] = 0;
186 vill_1.vbest[i__ - 1] = 0;
187 vill_1.vmelee[i__ - 1] = 0;
188 /* L700: */
189 }
190 /* DUNGEON, PAGE 4 */
191
192 for (i__ = 1; i__ <= 300; ++i__) {
193 /* clear object arrays. */
194 objcts_1.odesc1[i__ - 1] = 0;
195 objcts_1.odesc2[i__ - 1] = 0;
196 objcts_1.odesco[i__ - 1] = 0;
197 objcts_1.oread[i__ - 1] = 0;
198 objcts_1.oactio[i__ - 1] = 0;
199 objcts_1.oflag1[i__ - 1] = 0;
200 objcts_1.oflag2[i__ - 1] = 0;
201 objcts_1.ofval[i__ - 1] = 0;
202 objcts_1.otval[i__ - 1] = 0;
203 objcts_1.osize[i__ - 1] = 0;
204 objcts_1.ocapac[i__ - 1] = 0;
205 objcts_1.ocan[i__ - 1] = 0;
206 objcts_1.oadv[i__ - 1] = 0;
207 objcts_1.oroom[i__ - 1] = 0;
208 /* L800: */
209 }
210
211 rooms_1.rdesc2 = 0;
212 /* clear desc base ptr. */
213 for (i__ = 1; i__ <= 200; ++i__) {
214 /* clear room arrays. */
215 rooms_1.rdesc1[i__ - 1] = 0;
216 rooms_1.ractio[i__ - 1] = 0;
217 rooms_1.rflag[i__ - 1] = 0;
218 rooms_1.rval[i__ - 1] = 0;
219 rooms_1.rexit[i__ - 1] = 0;
220 /* L900: */
221 }
222
223 for (i__ = 1; i__ <= 1500; ++i__) {
224 /* clear message director */
225 rmsg_1.rtext[i__ - 1] = 0;
226 /* L1000: */
227 }
228
229 for (i__ = 1; i__ <= 4; ++i__) {
230 /* clear adventurer's arr */
231 advs_1.aroom[i__ - 1] = 0;
232 advs_1.ascore[i__ - 1] = 0;
233 advs_1.avehic[i__ - 1] = 0;
234 advs_1.aobj[i__ - 1] = 0;
235 advs_1.aactio[i__ - 1] = 0;
236 advs_1.astren[i__ - 1] = 0;
237 advs_1.aflag[i__ - 1] = 0;
238 /* L1100: */
239 }
240
241 misc_1.dbgflg = 0;
242 misc_1.prsflg = 0;
243 misc_1.gdtflg = 1;
244
245 screen_1.fromdr = 0;
246 /* init scol goodies. */
247 screen_1.scolrm = 0;
248 screen_1.scolac = 0;
249
250 if (initfl_(&x)) {
251 game_();
252 }
253 /* if init files, play ga */
254 s_stop(" ", 1L);
255 /* done */
256 return 0;
257 } /* MAIN__ */
258
259
260
261 /* TXCRYP - Subroutine to encrypt/decrypt text strings. */
262
263 /* This subroutine performs a reversible encryption on a text string. */
264 /* The purpose is not to protect the data base but to make it more */
265 /* difficult for the casual game user to read the data base file. */
266 /* It is located here, rather than in the SUBRoutine module, because */
267 /* it is used by both the game and the separate data base compiler. */
268
txcryp_(integer * r__,char * line,ftnlen line_len)269 /* Subroutine */ int txcryp_(integer *r__, char *line, ftnlen line_len)
270 {
271 /* System generated locals */
272 integer i__1;
273
274 /* Local variables */
275 integer i__, x;
276
277
278 i__1 = i_len(line, line_len);
279 for (i__ = 1; i__ <= i__1; ++i__) {
280 x = (*r__ & 31) + i__;
281 *(unsigned char *)&line[i__ - 1] = (char) (*(unsigned char *)&line[
282 i__ - 1] ^ x);
283 /* L100: */
284 }
285 return 0;
286 } /* txcryp_ */
287
288
289