-
Notifications
You must be signed in to change notification settings - Fork 19
/
mumble.zil
295 lines (268 loc) · 8.39 KB
/
mumble.zil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
"MAZE-PROG for BUREAUCRACY: Copyright (C)1987 Infocom, Inc.
All rights reserved."
<FILE-FLAGS MDL-ZIL?>
<INCLUDE "FORMDEFS" "COMPUTERDEFS">
<MSETG MAX-CHARS <* ,COMPUTER-HEIGHT ,COMPUTER-WIDTH>>
<MSETG MAX-CHARS/4 </ ,MAX-CHARS 4>>
<MSETG MAX-CHARS/16 </ ,MAX-CHARS 16>>
<MSETG QSIZE </ ,MAX-CHARS 4>>
<MSETG COMPUTER-HEIGHT/2 </ ,COMPUTER-HEIGHT 2>>
<MSETG COMPUTER-WIDTH/2 </ ,COMPUTER-WIDTH 2>>
<SETG20 TST
<IVECTOR ,COMPUTER-WIDTH '<ISTRING ,COMPUTER-HEIGHT <ASCII 32>>>>
<DEFINE20 LD-FILE (FILE
"AUX" (CH <OPEN "READ" .FILE>) N:FIX
(TS <STACK <ISTRING ,COMPUTER-WIDTH>>)
(COLS:VECTOR ,TST) (CS <1 .COLS>))
<COND (.CH
<SET N <MIN ,MAX-CHARS <FILE-LENGTH .CH>>>
<REPEAT (RD)
<COND (<0? <SET RD <READSTRING .TS .CH " ">>>
<RETURN>)>
<COND (<==? .RD <+ <LENGTH .CS> 1>>
<SUBSTRUC .TS 0 <- .RD 1> .CS>
<SET COLS <REST .COLS>>
<SET CS <1 .COLS>>)
(<G? .RD <LENGTH .CS>>
<SET COLS <REST .COLS>>
<SET CS <1 .COLS>>
<SUBSTRUC .TS 0 .RD .CS>
<SET CS <REST .CS .RD>>)
(T
<SUBSTRUC .TS 0 .RD .CS>
<SET CS <REST .CS .RD>>)>>
<CLOSE .CH>)
(ELSE .CH)>>
<DEFINE20 TABLEIZE ( )
<MAPF ,TABLE
<FUNCTION (ST:STRING "AUX" (FIRST? T))
<MAPF ,TABLE
<FUNCTION (CHR:CHARACTER "AUX" NEW)
<SET NEW <TRANS .CHR>>
<COND (.FIRST?
<SET FIRST? <>>
<MAPRET '(BYTE) <CHTYPE .NEW FIX>>)
(T
<CHTYPE .NEW FIX>)>>
.ST>>
,TST>>
" 0 ==> space, 1...26 ==> A...Z, 27...53 ==> a...z,
54 ==> .
55 ==> ,
56 ==> ;
57...63 ==> 0...6
"
<DEFINE20 TRANS (CHAR)
<SET CHAR <CHTYPE .CHAR FIX>>
<COND (<==? .CHAR 32> 0)
(<AND <G=? .CHAR <ASCII !\A>>
<L=? .CHAR <ASCII !\Z>>>
<- .CHAR <ASCII !\A> -1>)
(<AND <G=? .CHAR <ASCII !\a>>
<L=? .CHAR <ASCII !\z>>>
<- .CHAR <ASCII !\a> -27>)
(<AND <G=? .CHAR <ASCII !\0>>
<L=? .CHAR <ASCII !\6>>>
<- .CHAR <ASCII !\0> -57>)
(<==? .CHAR <ASCII !\.>> 54)
(<==? .CHAR <ASCII !\,>> 55)
(<==? .CHAR <ASCII !\;>> 56)>>
<LD-FILE "SS:<BUREAUCRACY>TEXT.FILE">
<CONSTANT PROG-TABLE <TABLEIZE>>
<MSETG QLEFT 0>
<MSETG QRIGHT 1>
<MSETG QTOP 2>
<MSETG QBOT 3>
<CONSTANT PUNCT-TABLE
<TABLE (PURE BYTE)
%<ASCII !\.> %<ASCII !\,> %<ASCII !\;>>>
<DEFINE PROG-FIRST (A B C)
<DO-PROG 0 *100*>>
<DEFINE PROG-SECOND (A B C)
<DO-PROG 1 *200*>>
<DEFINE PROG-THIRD (A B C)
<DO-PROG 2 *300*>>
<DEFINE PROG-FOURTH (A B C)
<DO-PROG 3 *300*>>
<CONSTANT QTOPS
<PTABLE (BYTE) 0 0 </ ,COMPUTER-HEIGHT 2> </ ,COMPUTER-HEIGHT 2>>>
<CONSTANT QLEFTS
<PTABLE (BYTE) </ ,COMPUTER-WIDTH 2> 0 0 </ ,COMPUTER-WIDTH 2>>>
<ROUTINE-FLAGS CLEAN-STACK?>
<DEFINE DO-PROG DP (NQN "OPT" (MB 0) "AUX" NBCHRS NGCHRS (QN .NQN))
<COND (<G=? .NQN 0>
<CLEAR-QUADRANT .QN>)
(T
<SET QN 0>)>
; "Clear written bits for appropriate quadrants"
<REPEAT ((N <- 4 .QN>) RT TOP (CQ 3))
<COND (<==? .CQ 0>
<SET RT <ZREST ,PROG-TABLE ,COMPUTER-WIDTH>>
<SET TOP 0>)
(<==? .CQ 1>
<SET RT ,PROG-TABLE>
<SET TOP 0>)
(<==? .CQ 2>
<SET RT ,PROG-TABLE>
<SET TOP </ ,COMPUTER-HEIGHT 2>>)
(T
<SET RT <REST ,PROG-TABLE ,COMPUTER-WIDTH>>
<SET TOP </ ,COMPUTER-HEIGHT 2>>)>
<PUTB ,LAST-USED <* .CQ 2> 255>
<PUTB ,LAST-USED <+ <* .CQ 2> 1> 255>
<REPEAT (I (CT 0) TBL)
<SET TBL <ZREST <ZGET .RT .CT> .TOP>>
<SET I 0>
<REPEAT ()
<PUTB .TBL .I <ANDB <GETB .TBL .I> *77*>>
<COND (<G=? <SET I <+ .I 1>> </ ,COMPUTER-HEIGHT 2>>
<RETURN>)>>
<COND (<G=? <SET CT <+ .CT 1>> </ ,COMPUTER-WIDTH 2>>
<RETURN>)>>
<SET CQ <- .CQ 1>>
<COND (<L=? <SET N <- .N 1>> 0> <RETURN>)>>
<COND (<L? .NQN 0> <RETURN T .DP>)>
<SET NBCHRS <* </ ,MAX-CHARS 4> <+ .QN 1>>>
<SET NGCHRS <* </ ,MAX-CHARS 16> <+ <* .QN 2> 1>>>
<SET NBCHRS <- .NBCHRS .NGCHRS>>
; "e.g., q0 makes 1/4 screen's worth of chars; 1/4 of those
(1/16 of total) will be good;
q1 is 1/2 & 3/16;
q2 is 3/4 & 5/16;
q3 is 1 and 7/16. q0 good chars are confined to q0; q1 to
q0&q1, etc. Further, a bad char may not overwrite an existing
good char, but q0 clears all good bits; q1 all but q0; q2 all
but q0 & q1; etc"
<REPEAT ()
<COND (<NOT <L? <SET NBCHRS <- .NBCHRS 1>> 0>>
<GEN-BAD-CHAR .QN .MB>)>
<COND (<NOT <L? <SET NGCHRS <- .NGCHRS 1>> 0>>
<GEN-GOOD-CHAR .QN .MB>)>
<COND (<AND <L=? .NGCHRS 0>
<L=? .NBCHRS 0>>
<RETURN>)>>
<>>
<DEFINE GEN-BAD-CHAR (QN:FIX MB "AUX" BQ X Y)
<SET BQ <ZRANDOM 3>>
<COND (<==? .BQ .QN>
<SET BQ 0>)>
<SET X <ZRANDOM </ ,COMPUTER-WIDTH 2>>>
<SET X <+ <SET X <- .X 1>> <GETB ,QLEFTS .BQ>>>
<SET Y <ZRANDOM </ ,COMPUTER-HEIGHT 2>>>
<SET Y <+ <SET Y <- .Y 1>> <GETB ,QTOPS .BQ>>>
<COND (<TEST-CHAR .X .Y .MB <>>
<FORCE-CHAR <GEN-CHAR .X .Y> .X .Y>)>>
<DEFINE TEST-CHAR (X Y BIT "OPT" (SET? T) "AUX" TBL CHR NB)
<SET TBL <ZGET ,PROG-TABLE .X>>
<SET NB <ANDB <SET CHR <GETB .TBL .Y>> *300*>>
<COND (<AND <T? .NB>
<L=? .NB .BIT>>
; "Q2 can write on stuff dumped by the Q3 and Q4 progs, but
not Q1 or Q2..."
<>)
(.SET?
<PUTB .TBL .Y <ORB .CHR *100*>>
<INVERT-CHAR .CHR>)
(T T)>>
<CONSTANT LAST-USED <TABLE (BYTE) 0 0 0 0 0 0 0 0>>
<ROUTINE-FLAGS CLEAN-STACK?>
<DEFINE GEN-GOOD-CHAR (QN:FIX MB:FIX "AUX" GQ X Y (QCT 0))
<SET GQ <- <SET GQ <ZRANDOM <+ <* .QN 2> 1>>> 1>>
<COND (<G=? .GQ .QN> <SET GQ .QN>)>
<SET X <ZRANDOM </ ,COMPUTER-WIDTH 2>>>
<SET X <- .X 1>>
<SET Y <- <SET Y <ZRANDOM </ ,COMPUTER-HEIGHT 2>>> 1>>
<PROG (CL CT RX RY GQ*2)
<SET CL <GETB ,QLEFTS .GQ>>
<SET CT <GETB ,QTOPS .GQ>>
<SET RX <+ .CL .X>>
<SET RY <+ .CT .Y>>
<REPEAT (CHR (DUMP? <>))
<COND (<G? .QCT 5> <RETURN>)
(<NOT <SET CHR <TEST-CHAR .RX .RY .MB>>>
<COND (<NOT .DUMP?>
<SET DUMP? T>
; "Start at virtual top left (this is actual char
addr last written in this mode, so OK to add
1 below"
<COND (<==? <SET X
<GETB ,LAST-USED <SET GQ*2 <* .GQ 2>>>>
255>
<SET X -1>)>
<COND (<==? <SET Y <GETB ,LAST-USED <+ .GQ*2 1>>>
255>
<SET Y 0>)>
<COND (<G=? .Y </ ,COMPUTER-HEIGHT 2>>
<SET X </ ,COMPUTER-WIDTH 2>>)>
<SET RX <+ .CL .X>>
<SET RY <+ .CT .Y>>)>
<PROG ()
<COND (<G? .QCT 5> <RETURN>)
(<G=? <SET X <+ .X 1>> </ ,COMPUTER-WIDTH 2>>
; "End of line, so go to next"
<COND (<G=? <SET Y <+ .Y 1>> </ ,COMPUTER-HEIGHT 2>>
; "End of quadrant, so go to next"
<PUTB ,LAST-USED .GQ*2 .X>
<PUTB ,LAST-USED <+ .GQ*2 1> .Y>
<SET QCT <+ .QCT 1>>
<COND (<G? <SET GQ <+ .GQ 1>> .QN>
<SET GQ 0>)>
<SET CL <GETB ,QLEFTS .GQ>>
<SET CT <GETB ,QTOPS .GQ>>
<SET GQ*2 <* .GQ 2>>
; "255 means never touched, so make sure we
get 0"
<COND (<==? <SET X <GETB ,LAST-USED .GQ*2>>
255>
<SET X -1>)>
<COND (<==? <SET Y
<GETB ,LAST-USED <+ .GQ*2 1>>>
255>
<SET Y 0>)
(<G=? .Y </ ,COMPUTER-HEIGHT 2>>
<SET X </ ,COMPUTER-WIDTH 2>>)>
<SET RY <+ .Y .CT>>
<AGAIN>)
(T
<SET X 0>)>
<SET RY <+ .CT .Y>>)>>
<SET RX <+ .X .CL>>)
(T
<FORCE-CHAR .CHR .RX .RY>
<COND (.DUMP?
<PUTB ,LAST-USED .GQ*2 .X>
<PUTB ,LAST-USED <+ .GQ*2 1> .Y>)>
<RETURN>)>>>>
<MSETG NCHARS 64>
<CONSTANT FUNNY-FIELDS <ITABLE ,COMPUTER-HEIGHT 0>>
<DEFINE GEN-CHAR (H:FIX V:FIX "AUX" (FF ,FUNNY-FIELDS) (CHR -1) TF
(V1 <+ .V 1>) SW)
<COND (<0? <MOD .V 2>>
<COND (<F? <SET TF <ZGET .FF .V>>>
<SET TF <ZREST <PICK-ONE ,LICENSE-FORM>
<- ,FIELD-DATA-OFFSET 1>>>
<COND (<L=? <+ .H <GETB .TF 0>> ,COMPUTER-WIDTH>
<ZPUT .FF .V .TF>
<ZPUT .FF .V1 .H>)
(T
<SET TF <>>)>)>
<COND (<AND .TF
<G=? .H <SET SW <ZGET .FF .V1>>>>
<SET CHR
<GETB .TF <+ 1 <MOD <- .H .SW> <GETB .TF 0>>>>>)>)>
<COND (<==? .CHR -1>
<INVERT-CHAR <- <ZRANDOM ,NCHARS> 1>>)
(T
<CHTYPE .CHR FIX>)>>
<DEFINE INVERT-CHAR (N)
<SET N <ANDB .N *77*>>
<COND (<==? .N 0> <SET N 32>)
(<L? .N 27> <SET N <+ .N %<- <ASCII !\A> 1>>>)
(<L? .N 54> <SET N <+ .N %<- <ASCII !\a> 27>>>)
(<G=? .N 57> <SET N <+ .N %<- <ASCII !\0> 57>>>)
(ELSE <SET N <GETB ,PUNCT-TABLE <- .N 54>>>)>
.N>
<DEFINE20 TCOMP ()
<MOVE ,COMPUTER ,PLAYER>
<MOVE ,RANDOM-CARTRIDGE ,PLAYER>
<PERFORM ,V?PUT ,RANDOM-CARTRIDGE ,COMPUTER>>