1 /* ENCRYP-- ENCRYPT PASSWORD */
2
3 /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
4 /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
5 /* WRITTEN BY R. M. SUPNIK */
6
7 #include <stdio.h>
8 #include "funcs.h"
9 #include "vars.h"
10
encryp_(inw,outw)11 void encryp_(inw, outw)
12 const char *inw;
13 char *outw;
14 {
15 /* Initialized data */
16
17 const char *keyw = "ECORMS";
18
19 integer i, j, uinw[6], usum;
20 char ukeyw[1*6];
21 integer uinws, ukeyws;
22
23 /* Parameter adjustments */
24 --outw;
25 --inw;
26
27 /* Function Body */
28
29 uinws = 0;
30 /* !UNBIASED INW SUM. */
31 ukeyws = 0;
32 /* !UNBIASED KEYW SUM. */
33 j = 1;
34 /* !POINTER IN KEYWORD. */
35 for (i = 1; i <= 6; ++i) {
36 /* !UNBIAS, COMPUTE SUMS. */
37 ukeyw[i - 1] = (keyw[i - 1] - 64);
38 if (inw[j] <= '@') {
39 j = 1;
40 }
41 uinw[i - 1] = inw[j] - 64;
42 ukeyws += ukeyw[i - 1];
43 uinws += uinw[i - 1];
44 ++j;
45 /* L100: */
46 }
47
48 usum = uinws % 8 + (ukeyws % 8 << 3);
49 /* !COMPUTE MASK. */
50 for (i = 1; i <= 6; ++i) {
51 j = (uinw[i - 1] ^ ukeyw[i - 1] ^ usum) & 31;
52 usum = (usum + 1) % 32;
53 if (j > 26) {
54 j %= 26;
55 }
56 outw[i] = (max(1,j) + 64);
57 /* L200: */
58 }
59 } /* encryp_ */
60
61 /* CPGOTO-- MOVE TO NEXT STATE IN PUZZLE ROOM */
62
63 /* DECLARATIONS */
64
cpgoto_(st)65 void cpgoto_(st)
66 integer st;
67 {
68 /* System generated locals */
69 integer i__1, i__2;
70
71 /* Local variables */
72 integer i;
73
74 rooms_1.rflag[rindex_1.cpuzz - 1] &= ~ RSEEN;
75 i__1 = objcts_1.olnt;
76 for (i = 1; i <= i__1; ++i) {
77 /* !RELOCATE OBJECTS. */
78 if (objcts_1.oroom[i - 1] == rindex_1.cpuzz && (objcts_1.oflag2[i - 1]
79 & ACTRBT + VILLBT) == 0) {
80 i__2 = findex_1.cphere * hyper_1.hfactr;
81 newsta_(i, 0, i__2, 0, 0);
82 }
83 if (objcts_1.oroom[i - 1] == st * hyper_1.hfactr) {
84 newsta_(i, 0, rindex_1.cpuzz, 0, 0);
85 }
86 /* L100: */
87 }
88 findex_1.cphere = st;
89 } /* cpgoto_ */
90
91 /* CPINFO-- DESCRIBE PUZZLE ROOM */
92
93 /* DECLARATIONS */
94
cpinfo_(rmk,st)95 void cpinfo_(rmk, st)
96 integer rmk;
97 integer st;
98 {
99 /* Initialized data */
100
101 static const integer dgmoft[8] = { -9,-8,-7,-1,1,7,8,9 };
102 const char *pict = "SSS M";
103
104 /* Local variables */
105 integer i, j, k, l;
106 char dgm[1*8];
107
108 rspeak_(rmk);
109 for (i = 1; i <= 8; ++i) {
110 j = dgmoft[i - 1];
111 dgm[i - 1] = pict[puzzle_1.cpvec[st + j - 1] + 3];
112 /* !GET PICTURE ELEMENT. */
113 if (abs(j) == 1 || abs(j) == 8) {
114 goto L100;
115 }
116 k = 8;
117 if (j < 0) {
118 k = -8;
119 }
120 /* !GET ORTHO DIR. */
121 l = j - k;
122 if (puzzle_1.cpvec[st + k - 1] != 0 && puzzle_1.cpvec[st + l - 1] !=
123 0) {
124 dgm[i - 1] = '?';
125 }
126 L100:
127 ;
128 }
129
130 more_output(NULL);
131 printf(" |%c%c %c%c %c%c|\n", dgm[0], dgm[0], dgm[1], dgm[1],
132 dgm[2], dgm[2]);
133 more_output(NULL);
134 printf(" West |%c%c .. %c%c| East\n", dgm[3], dgm[3], dgm[4], dgm[4]);
135 more_output(NULL);
136 printf(" |%c%c %c%c %c%c|\n", dgm[5], dgm[5], dgm[6], dgm[6],
137 dgm[7], dgm[7]);
138
139 if (st == 10) {
140 rspeak_(870);
141 }
142 /* !AT HOLE? */
143 if (st == 37) {
144 rspeak_(871);
145 }
146 /* !AT NICHE? */
147 i = 872;
148 /* !DOOR OPEN? */
149 if (findex_1.cpoutf) {
150 i = 873;
151 }
152 if (st == 52) {
153 rspeak_(i);
154 }
155 /* !AT DOOR? */
156 if (puzzle_1.cpvec[st] == -2) {
157 rspeak_(874);
158 }
159 /* !EAST LADDER? */
160 if (puzzle_1.cpvec[st - 2] == -3) {
161 rspeak_(875);
162 }
163 /* !WEST LADDER? */
164 } /* cpinfo_ */
165