-
Notifications
You must be signed in to change notification settings - Fork 15
/
be.zap
374 lines (309 loc) · 6.56 KB
/
be.zap
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
.FUNCT V-STATEMENT:ANY:0:0
CALL1 V-DO?
RSTACK
.FUNCT V-BE:ANY:0:0,TMP,NOT?,ADJ?,LOC?,OBJ,PREP
GET PARSE-RESULT,16
BAND PARSE-NOT,STACK >NOT?
GET PARSE-RESULT,11 >ADJ?
GET PARSE-RESULT,9 >LOC?
EQUAL? PRSA,V?HOW /?CTR2
EQUAL? PRSA,V?WHEN,V?WHY,V?WHERE /?CTR2
EQUAL? PRSA,V?WHAT,V?WHO,V?BE? \?CCL3
?CTR2: EQUAL? PRSI,INTADJ \?CCL9
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE,STR?56
CALL2 IS-PRSO-ADJ?,ADJ?
ZERO? STACK \?CND10
PRINTI "n't"
?CND10: PRINTC 32
PRINTB ADJ?
PRINTC 46
CRLF
RTRUE
?CCL9: EQUAL? PRSI,INTPP \?CCL13
CALL1 P-PP-PREP >PREP
ZERO? PREP /?CCL16
CALL1 P-PP-OBJ >OBJ
ZERO? OBJ /?CCL16
EQUAL? PRSA,V?BE? \?CCL21
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE,STR?56
CALL RIGHT-PREP?,PREP,PRSO,OBJ
ZERO? STACK \?CND22
PRINTI "n't"
?CND22: PRINTC 32
PRINTB PREP
ICALL RT-PRINT-OBJ,OBJ,K-ART-THE
PRINTC 46
CRLF
RTRUE
?CCL21: PRINTI "You want to know "
ICALL1 TELL-Q-WORD
ICALL2 PRSO-IS,NOT?
PRINTC 32
PRINTB PREP
ICALL RT-PRINT-OBJ,OBJ,K-ART-THE
PRINTC 46
CRLF
RTRUE
?CCL16: PRINTI "You want to know "
ICALL1 TELL-Q-WORD
ICALL2 PRSO-IS,NOT?
PRINTC 32
GET LOC?,1
PRINTB STACK
PRINTC 32
GET LOC?,2
ICALL2 NP-PRINT,STACK
PRINTC 46
CRLF
RTRUE
?CCL13: ZERO? PRSI \?CCL25
EQUAL? PRSA,V?WHERE \?CCL25
LOC PRSO >LOC?
IN? PRSO,HERE \?CCL30
ICALL PRSO-IS,FALSE-VALUE,TRUE-VALUE
PRINTR " here."
?CCL30: EQUAL? LOC?,GLOBAL-OBJECTS \?CCL32
PRINTI "No doubt"
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE
ICALL RT-PRINT-VERB,PRSO,STR?56
PRINTR " around here somewhere."
?CCL32: EQUAL? LOC?,LOCAL-GLOBALS \?CCL34
CALL GLOBAL-IN?,PRSO,HERE
ZERO? STACK /?CCL34
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE,STR?56
PRINTR " nearby."
?CCL34: FSET? LOC?,FL-PERSON \?CCL38
ICALL RT-PRINT-OBJ,LOC?,K-ART-THE,TRUE-VALUE,STR?111
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE
PRINTC 46
CRLF
RTRUE
?CCL38: CALL2 META-LOC,PRSO
EQUAL? STACK,HERE \?CCL40
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE,STR?56
ICALL2 RT-IN-ON-MSG,LOC?
ICALL RT-PRINT-OBJ,LOC?,K-ART-THE
PRINTC 46
CRLF
RTRUE
?CCL40: IN? LOC?,ROOMS \?CCL42
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE
PRINTI " is probably "
FSET? PRSO,TOUCHBIT \?CCL45
PRINTI "still in"
ICALL RT-PRINT-OBJ,LOC?,K-ART-THE
PRINTC 46
CRLF
RTRUE
?CCL45: PRINTR "lying around somewhere."
?CCL42: PRINTI "That's an excellent question. Just where"
ICALL RT-PRINT-VERB,PRSO,STR?56
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE
PRINTC 63
CRLF
RTRUE
?CCL25: PRINTI "You want to know "
ICALL1 TELL-Q-WORD
ICALL2 PRSO-IS,NOT?
ZERO? PRSI /?CND46
ICALL RT-PRINT-OBJ,PRSI,K-ART-A
?CND46: PRINTC 63
CRLF
RTRUE
?CCL3: EQUAL? PRSI,INTADJ \?CCL50
CALL2 IS-PRSO-ADJ?,ADJ?
ZERO? STACK /?CCL53
ZERO? NOT? /?CCL56
PRINTI "Wrong,"
JUMP ?CND54
?CCL56: PRINTI "Right,"
?CND54: ICALL2 PRSO-IS,FALSE-VALUE
JUMP ?CND51
?CCL53: ZERO? NOT? /?CCL59
PRINTI "Right,"
JUMP ?CND57
?CCL59: PRINTI "Wrong,"
?CND57: ICALL2 PRSO-IS,TRUE-VALUE
?CND51: PRINTC 32
PRINTB ADJ?
PRINTC 46
CRLF
RTRUE
?CCL50: EQUAL? PRSI,INTPP \?CCL61
PRINTI "So, you say"
ICALL2 PRSO-IS,NOT?
CALL1 P-PP-PREP >PREP
ZERO? PREP /?CCL64
CALL1 P-PP-OBJ >OBJ
ZERO? OBJ /?CCL64
PRINTB PREP
ICALL RT-PRINT-OBJ,OBJ,K-ART-THE
JUMP ?CND62
?CCL64: GET LOC?,1
PRINTB STACK
GET LOC?,2
CALL2 NP-PRINT,STACK
ICALL RT-PRINT-OBJ,STACK,K-ART-THE
?CND62: PRINTC 46
CRLF
RTRUE
?CCL61: PRINTI "So you think"
ICALL2 PRSO-IS,NOT?
ZERO? PRSI /?CND67
ICALL RT-PRINT-OBJ,PRSI,K-ART-A
?CND67: PRINTC 63
CRLF
RTRUE
.FUNCT TELL-Q-WORD:ANY:0:0
EQUAL? PRSA,V?BE? \?CCL3
PRINTI "if"
RTRUE
?CCL3: EQUAL? PRSA,V?WHY \?CCL5
PRINTI "why"
RTRUE
?CCL5: EQUAL? PRSA,V?WHO \?CCL7
PRINTI "who"
RTRUE
?CCL7: EQUAL? PRSA,V?WHAT \?CCL9
PRINTI "what"
RTRUE
?CCL9: EQUAL? PRSA,V?WHERE \?CCL11
PRINTI "where"
RTRUE
?CCL11: EQUAL? PRSA,V?WHEN \?CCL13
PRINTI "when"
RTRUE
?CCL13: EQUAL? PRSA,V?HOW \?CCL15
PRINTI "how"
RTRUE
?CCL15: PRINTB P-PRSA-WORD
RTRUE
.FUNCT RIGHT-PREP?:ANY:3:3,PREP,OBJ,CONT
IN? OBJ,CONT \FALSE
EQUAL? PREP,W?IN,W?INSIDE \?CCL5
CALL2 RT-SEE-INSIDE?,CONT
ZERO? STACK /FALSE
RTRUE
?CCL5: EQUAL? PREP,W?ON \FALSE
FSET? CONT,FL-SURFACE /TRUE
RFALSE
.FUNCT IS-QUIET?:ANY:1:1,OBJ
RTRUE
.FUNCT IS-OUTSIDE?:ANY:1:1,OBJ
FSET? HERE,FL-INDOORS /FALSE
RTRUE
.FUNCT IS-OPEN?:ANY:1:1,OBJ
FSET? OBJ,FL-OPENABLE \FALSE
FSET? OBJ,FL-OPEN /TRUE
RFALSE
.FUNCT IS-CLOSED?:ANY:1:1,OBJ
FSET? OBJ,FL-OPENABLE \FALSE
FSET? OBJ,FL-OPEN /FALSE
RTRUE
.FUNCT IS-LOCKED?:ANY:1:1,OBJ
FSET? OBJ,FL-OPENABLE \FALSE
FSET? OBJ,FL-LOCKED /TRUE
RFALSE
.FUNCT IS-UNLOCKED?:ANY:1:1,OBJ
FSET? OBJ,FL-OPENABLE \FALSE
FSET? OBJ,FL-LOCKED /FALSE
RTRUE
.FUNCT IS-DEAD?:ANY:1:1,OBJ
FSET? OBJ,FL-PERSON \FALSE
FSET? OBJ,FL-ALIVE /FALSE
RTRUE
.FUNCT IS-ALIVE?:ANY:1:1,OBJ
FSET? OBJ,FL-PERSON \FALSE
FSET? OBJ,FL-ALIVE /TRUE
RFALSE
.FUNCT IS-HERE?:ANY:1:1,OBJ,L
LOC OBJ >L
?PRG1: ZERO? L /FALSE
EQUAL? L,GLOBAL-OBJECTS,LOCAL-GLOBALS,ROOMS /FALSE
EQUAL? L,HERE /TRUE
LOC L >L
JUMP ?PRG1
.FUNCT PRSO-IS:ANY:1:2,NOT?,CAP?
ZERO? CAP? /?CCL3
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE
JUMP ?CND1
?CCL3: ICALL RT-PRINT-OBJ,PRSO,K-ART-THE
?CND1: ICALL RT-PRINT-VERB,PRSO,STR?56
ZERO? NOT? /FALSE
PRINTI "n't"
RTRUE
.FUNCT IS-PRSO-ADJ?:ANY:1:1,ADJ,TMP
GETPT PRSO,P?ADJECTIVE >TMP
ZERO? TMP /?CCL3
PTSIZE TMP
DIV STACK,2
INTBL? ADJ,TMP,STACK /TRUE
?CCL3: GET ADJ-TABLE,0
INTBL? ADJ,ADJ-TABLE,STACK >TMP \FALSE
GET TMP,1
CALL STACK,PRSO
ZERO? STACK \TRUE
RFALSE
.FUNCT YES-BUT?:ANY:2:2,STR1,STR2
GET PARSE-RESULT,10
ZERO? STACK \FALSE
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE
PRINTC 32
PRINT STR1
PRINTI ", but "
PRINT STR2
ICALL RT-PRINT-OBJ,PRSO,K-ART-HE
PRINTC 63
CRLF
RTRUE
.FUNCT V-CAN?:ANY:0:0
CALL YES-BUT?,STR?112,STR?113
RSTACK
.FUNCT V-MAY?:ANY:0:0
CALL YES-BUT?,STR?113,STR?112
RSTACK
.FUNCT V-DO?:ANY:0:0
GET PARSE-RESULT,10
ZERO? STACK \FALSE
ICALL RT-PRINT-OBJ,PRSO,K-ART-THE,TRUE-VALUE,STR?66
PRINTR ", but why?"
.FUNCT V-COULD?:ANY:0:0
CALL YES-BUT?,STR?114,STR?115
RSTACK
.FUNCT V-WOULD?:ANY:0:0
CALL YES-BUT?,STR?115,STR?114
RSTACK
.FUNCT V-SHOULD?:ANY:0:0
CALL YES-BUT?,STR?116,STR?117
RSTACK
.FUNCT V-MIGHT?:ANY:0:0
CALL YES-BUT?,STR?118,STR?117
RSTACK
.FUNCT V-WILL?:ANY:0:0
CALL YES-BUT?,STR?117,STR?116
RSTACK
.FUNCT V-MUST?:ANY:0:0
CALL YES-BUT?,STR?119,STR?112
RSTACK
.FUNCT V-BE?:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-WHO:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-WHAT:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-WHEN:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-WHERE:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-WHY:ANY:0:0
CALL1 V-BE
RSTACK
.FUNCT V-HOW:ANY:0:0
CALL1 V-BE
RSTACK
.ENDI