-
Notifications
You must be signed in to change notification settings - Fork 15
/
prare.zap
1042 lines (971 loc) · 21 KB
/
prare.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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.SEGMENT "0"
.FUNCT TOO-MANY-NEW:ANY:1:1,WHAT
PRINTI "[Warning: there are too many new "
PRINT WHAT
PRINTR "s.]"
.FUNCT NAKED-OOPS:ANY:0:0
PRINTR "[Please type a word(s) after OOPS.]"
.FUNCT CANT-OOPS:ANY:0:0
PRINTR "[There was no word to replace in that sentence.]"
.FUNCT CANT-AGAIN:ANY:0:0
PRINTR "[What do you want to do again?]"
.FUNCT CANT-USE-MULTIPLE:ANY:2:2,LOSS,WD
SET 'CLOCK-WAIT,TRUE-VALUE
PRINTI "[You can't use more than one object at a time with """
ICALL2 PRINT-VOCAB-WORD,WD
PRINTR """!]"
.FUNCT MAKE-ROOM-FOR-TOKENS:ANY:3:3,CNT,LEXV,WHERE,LEN,?TMP2,?TMP1
GETB LEXV,0
MUL 2,STACK >LEN
MUL P-LEXELEN,CNT
ADD WHERE,STACK
LESS? LEN,STACK \?CND1
SUB LEN,WHERE
DIV STACK,P-LEXELEN >CNT
ICALL2 TOO-MANY-NEW,STR?57
?CND1: GETB LEXV,P-LEXWORDS >LEN
ADD CNT,LEN
PUTB LEXV,P-LEXWORDS,STACK
MUL 2,WHERE
ADD LEXV,STACK >LEXV
MUL CNT,4
ADD LEXV,STACK >?TMP1
MUL 2,LEN >?TMP2
SUB WHERE,P-LEXSTART
SUB ?TMP2,STACK
MUL 2,STACK
COPYT LEXV,?TMP1,STACK
RTRUE
.FUNCT REPLACE-ONE-TOKEN:ANY:5:5,N,FROM-LEXV,PTR,TO-LEXV,WHERE,CNT,X,?TMP1,?TMP2
SUB N,1 >CNT
ZERO? CNT /?CND1
ICALL MAKE-ROOM-FOR-TOKENS,CNT,TO-LEXV,WHERE
?CND1: SET 'CNT,N
?PRG3: DLESS? 'CNT,0 /TRUE
ADD PTR,P-LEXELEN >PTR
GET FROM-LEXV,PTR
PUT TO-LEXV,WHERE,STACK
MUL PTR,P-LEXELEN
ADD STACK,2 >X
GETB FROM-LEXV,X >?TMP2
ADD X,1
GETB FROM-LEXV,STACK >?TMP1
MUL WHERE,P-LEXELEN
ADD STACK,3
CALL INBUF-ADD,?TMP2,?TMP1,STACK
ZERO? STACK \?CND7
ICALL2 TOO-MANY-NEW,STR?58
RTRUE
?CND7: ADD WHERE,P-LEXELEN >WHERE
JUMP ?PRG3
.FUNCT V-$REFRESH:ANY:0:1,LOOK?
ASSIGNED? 'LOOK? /?CND1
SET 'LOOK?,TRUE-VALUE
?CND1: GET 0,8
BAND STACK,-5
PUT 0,8,STACK
CLEAR -1
ICALL1 INIT-STATUS-LINE
ZERO? LOOK? /TRUE
ICALL1 V-LOOK
RTRUE
.FUNCT PRINT-INTQUOTE:ANY:0:0,NP,?TMP2,?TMP1
CALL2 GET-NP,INTQUOTE >NP
GET NP,7
ADD STACK,4 >?TMP1
GET NP,8 >?TMP2
GET NP,7
SUB ?TMP2,STACK
DIV STACK,4
ADD -1,STACK
CALL PRINT-LEXV,-1,?TMP1,STACK
RSTACK
.FUNCT PRINT-LEXV:ANY:0:3,QUIET,X,LEN,WD,IN-QUOTE,OWD
ASSIGNED? 'X /?CND1
MUL QUIET,4
ADD TLEXV,STACK >X
?CND1: ASSIGNED? 'LEN /?CND3
SUB P-LEN,QUIET >LEN
?CND3: ZERO? QUIET /?CCL6
GRTR? 0,P-OFLAG \?CND5
?CCL6: PRINTI "[In other words:"
?CND5: SET 'IN-QUOTE,FALSE-VALUE
EQUAL? QUIET,-1 \?CCL11
SET 'OWD,W?APOSTROPHE
JUMP ?PRG12
?CCL11: SET 'OWD,0
?PRG12: GET X,0 >WD
EQUAL? WD,W?PERIOD,W?COMMA,W?APOSTROPHE /?CND14
EQUAL? WD,W?NO.WORD /?CND14
EQUAL? OWD,W?APOSTROPHE /?CND14
EQUAL? OWD,W?QUOTE \?CCL22
ZERO? IN-QUOTE \?CCL22
SET 'IN-QUOTE,TRUE-VALUE
JUMP ?CND14
?CCL22: EQUAL? WD,W?QUOTE \?CCL26
ZERO? IN-QUOTE /?CCL26
SET 'IN-QUOTE,FALSE-VALUE
JUMP ?CND14
?CCL26: PRINTC 32
?CND14: EQUAL? WD,W?NO.WORD /?CND29
CALL2 CAPITAL-NOUN?,WD
ZERO? STACK /?CCL33
ICALL2 CAPITALIZE,X
JUMP ?CND29
?CCL33: EQUAL? WD,0,W?INT.NUM,W?INT.TIM \?CCL35
ADD X,P-WORDLEN
ICALL BUFFER-PRINT,X,STACK,FALSE-VALUE,TRUE-VALUE
JUMP ?CND29
?CCL35: ICALL2 PRINT-VOCAB-WORD,WD
?CND29: DLESS? 'LEN,1 /?REP13
EQUAL? WD,W?NO.WORD /?CND38
SET 'OWD,WD
?CND38: ADD X,4 >X
JUMP ?PRG12
?REP13: ZERO? QUIET /?CCL42
GRTR? 0,P-OFLAG \FALSE
?CCL42: PRINTR "]"
.FUNCT COPY-INPUT:ANY:0:1,QUIET,LEN,?TMP1
COPYT G-LEXV,P-LEXV,LEXV-LENGTH-BYTES
GETB P-LEXV,P-LEXWORDS >P-LEN
GET OOPS-TABLE,O-START >TLEXV
COPYT G-INBUF,P-INBUF,61
GETB P-LEXV,P-LEXWORDS
MUL 4,STACK >LEN
DEC 'LEN
GETB TLEXV,LEN >?TMP1
DEC 'LEN
GETB TLEXV,LEN
ADD ?TMP1,STACK
PUT OOPS-TABLE,O-END,STACK
ZERO? QUIET \?CND1
ICALL2 PRINT-LEXV,QUIET
?CND1: SET 'P-OFLAG,FALSE-VALUE
RETURN P-OFLAG
.ENDSEG
.SEGMENT "0"
.FUNCT BUFFER-PRINT:ANY:2:4,BEG,END,CP,NOSP,WRD,NW,FIRST??,PN,TMP
SET 'FIRST??,TRUE-VALUE
?PRG1: EQUAL? BEG,END /TRUE
ZERO? NOSP \?CTR6
EQUAL? NW,W?PERIOD,W?COMMA,W?APOSTROPHE \?CCL7
?CTR6: SET 'NOSP,FALSE-VALUE
JUMP ?CND5
?CCL7: PRINTC 32
?CND5: GET BEG,0 >WRD
ADD BEG,P-WORDLEN
EQUAL? END,STACK \?CCL12
SET 'NW,0
JUMP ?CND10
?CCL12: GET BEG,P-LEXELEN >NW
?CND10: EQUAL? WRD,W?NO.WORD \?CCL15
SET 'NOSP,TRUE-VALUE
JUMP ?CND13
?CCL15: EQUAL? WRD,W?MY \?CCL17
PRINTB W?YOUR
JUMP ?CND13
?CCL17: EQUAL? WRD,W?ME \?CCL19
PRINTB W?YOU
SET 'PN,TRUE-VALUE
JUMP ?CND13
?CCL19: EQUAL? WRD,W?ONE \?CCL21
PRINTI "object"
JUMP ?CND13
?CCL21: EQUAL? WRD,FALSE-VALUE,W?ALL,W?PERIOD /?CCL23
EQUAL? WRD,W?APOSTROPHE /?CCL23
GET WRD,4 >TMP
ZERO? TMP \?CCL23
GET WRD,3
ZERO? STACK \?CCL23
BTST TMP,32768 /?PRD32
BAND TMP,4
BAND STACK,32767
ZERO? STACK \?CCL23
?PRD32: BTST TMP,32768 /?CTR22
BAND TMP,2
BAND STACK,32767
ZERO? STACK \?CCL23
?CTR22: SET 'NOSP,TRUE-VALUE
JUMP ?CND13
?CCL23: CALL2 CAPITAL-NOUN?,WRD
ZERO? STACK /?CCL38
ICALL2 CAPITALIZE,BEG
SET 'PN,TRUE-VALUE
JUMP ?CND13
?CCL38: ZERO? FIRST?? /?CND39
ZERO? PN \?CND39
ZERO? CP /?CND39
EQUAL? WRD,W?HER,W?HIM,W?YOUR /?CND39
PRINTI "the "
?CND39: EQUAL? WRD,W?IT \?CCL48
CALL2 VISIBLE?,P-IT-OBJECT
ZERO? STACK /?CCL48
ICALL2 RT-PRINT-DESC,P-IT-OBJECT
JUMP ?CND46
?CCL48: EQUAL? WRD,W?THEM \?CCL52
CALL2 VISIBLE?,P-THEM-OBJECT
ZERO? STACK /?CCL52
ICALL2 RT-PRINT-DESC,P-THEM-OBJECT
JUMP ?CND46
?CCL52: EQUAL? WRD,W?HER \?CCL56
ZERO? PN \?CCL56
ICALL2 RT-PRINT-DESC,P-HER-OBJECT
JUMP ?CND46
?CCL56: EQUAL? WRD,W?HIM \?CCL60
ZERO? PN \?CCL60
ICALL2 RT-PRINT-DESC,P-HIM-OBJECT
JUMP ?CND46
?CCL60: EQUAL? WRD,W?INT.NUM,W?INT.TIM \?CCL64
GET BEG,1
PRINTN STACK
JUMP ?CND46
?CCL64: ICALL2 WORD-PRINT,BEG
?CND46: SET 'FIRST??,FALSE-VALUE
?CND13: ADD BEG,P-WORDLEN >BEG
JUMP ?PRG1
.FUNCT CAPITALIZE:ANY:1:1,PTR,?TMP1
GETB PTR,3
GETB P-INBUF,STACK
SUB STACK,32
PRINTC STACK
GETB PTR,2
SUB STACK,1 >?TMP1
GETB PTR,3
ADD STACK,1
CALL WORD-PRINT,PTR,?TMP1,STACK
RSTACK
.FUNCT PRINT-PARSER-FAILURE:ANY:0:0,CLASS,OTHER,OTHER2,TMP,PR,N,X,?TMP1
GET ERROR-ARGS,1 >CLASS
GET ERROR-ARGS,2 >OTHER
GET ERROR-ARGS,3 >OTHER2
EQUAL? CLASS,PARSER-ERROR-ORPH-S \?CCL3
GET ORPHAN-S,O-LEXPTR
SUB STACK,P-LEXV
DIV STACK,2 >P-OFLAG
COPYT G-LEXV,O-LEXV,LEXV-LENGTH-BYTES
COPYT G-INBUF,O-INBUF,61
GET OOPS-TABLE,O-START
PUT OOPS-TABLE,O-AGAIN,STACK
ICALL MAKE-ROOM-FOR-TOKENS,1,O-LEXV,P-OFLAG
PUT O-LEXV,P-OFLAG,W?NO.WORD
PRINTI "[Wh"
GET ORPHAN-S,O-VERB
EQUAL? STACK,W?WALK,W?GO,W?RUN \?CCL8
PRINTI "ere"
JUMP ?CND6
?CCL8: GET ORPHAN-S,O-WHICH
EQUAL? STACK,1 \?CCL13
GET ORPHAN-S,O-SYNTAX
GETB STACK,4
JUMP ?CND11
?CCL13: GET ORPHAN-S,O-SYNTAX
GETB STACK,8
?CND11: EQUAL? PERSONBIT,STACK \?CCL10
PRINTI "om"
JUMP ?CND6
?CCL10: PRINTI "at"
?CND6: PRINTC 32
GET ORPHAN-S,O-SUBJECT >PR
ZERO? PR /?CCL16
GET ORPHAN-S,O-VERB >TMP
ADD WORD-FLAG-TABLE,2 >?TMP1
GET WORD-FLAG-TABLE,0
INTBL? TMP,?TMP1,STACK,132 >X \?CCL21
GET X,1
JUMP ?CND19
?CCL21: PUSH FALSE-VALUE
?CND19: BTST STACK,512 \?CCL16
PRINTI "did "
ICALL2 TELL-THE,PR
PRINTC 32
JUMP ?CND14
?CCL16: PRINTI "do you want "
EQUAL? WINNER,PLAYER /?CND22
ICALL2 RT-PRINT-DESC,WINNER
PRINTC 32
?CND22: PRINTI "to "
?CND14: GET ORPHAN-S,O-VERB
CALL2 ROOT-VERB,STACK
ICALL2 PRINT-VOCAB-WORD,STACK
GET ORPHAN-S,O-PART >TMP
EQUAL? TMP,0,1 /?CND24
PRINTC 32
ICALL2 PRINT-VOCAB-WORD,TMP
?CND24: GET ERROR-ARGS,2 >TMP
ZERO? TMP /?CND26
PRINTC 32
GET ORPHAN-S,O-OBJECT >PR
ZERO? PR /?CCL30
ICALL2 TELL-THE,PR
JUMP ?CND28
?CCL30: ICALL2 NP-PRINT,TMP
?CND28: GET ORPHAN-S,O-SYNTAX >TMP
ZERO? TMP /?CND26
GET ORPHAN-S,O-WHICH
EQUAL? STACK,1 \?CCL35
GET TMP,1 >TMP
JUMP ?CND33
?CCL35: GET TMP,3 >TMP
?CND33: ZERO? TMP /?CND26
GETB O-LEXV,P-LEXWORDS >N
SUB P-OFLAG,P-LEXELEN
GET O-LEXV,STACK >PR
GET PR,4
ZERO? STACK \?CND38
GET PR,3 >PR
?CND38: EQUAL? TMP,PR /?CND40
INC 'N
PUTB O-LEXV,P-LEXWORDS,N
PUT O-LEXV,P-OFLAG,TMP
ADD P-OFLAG,P-LEXELEN >P-OFLAG
?CND40: PUT O-LEXV,P-OFLAG,W?NO.WORD
MUL P-WORDLEN,N
ADD 1,STACK
ICALL INBUF-PRINT,TMP,O-INBUF,O-LEXV,STACK
PRINTC 32
ICALL2 PRINT-VOCAB-WORD,TMP
?CND26: PRINTR "?]"
?CCL3: EQUAL? CLASS,PARSER-ERROR-ORPH-NP \?CND1
CALL2 WHICH-PRINT,OTHER
ZERO? STACK \TRUE
?CND1: EQUAL? CLASS,PARSER-ERROR-NOMULT \?CCL47
ICALL CANT-USE-MULTIPLE,OTHER,OTHER2
RTRUE
?CCL47: EQUAL? CLASS,PARSER-ERROR-NOOBJ \?CCL49
ICALL CANT-FIND-OBJECT,OTHER,OTHER2
RTRUE
?CCL49: EQUAL? CLASS,PARSER-ERROR-TMNOUN \?CCL51
GET PARSE-RESULT,1
ICALL2 TOO-MANY-NOUNS,STACK
RTRUE
?CCL51: GRTR? P-LEN,0 \?CND52
SUB OTLEXV,4 >OTHER2
CALL2 CHANGE-AND-TO-THEN?,OTHER2
ZERO? STACK \?CCL53
SET 'OTHER2,OTLEXV
CALL2 CHANGE-AND-TO-THEN?,OTHER2
ZERO? STACK /?CND52
?CCL53: ICALL CHANGE-LEXV,OTHER2,W?THEN
GET OOPS-TABLE,O-LENGTH >P-LEN
GET OOPS-TABLE,O-START >TLEXV
ICALL1 PRINT-LEXV
CALL2 PARSE-IT,FALSE-VALUE
RSTACK
?CND52: SET 'OTHER2,OTLEXV
ZERO? P-LEN \?PRD61
CALL2 NAKED-ADJECTIVE?,OTHER2
ZERO? STACK \?CCL59
?PRD61: SUB OTLEXV,4 >OTHER2
LESS? P-LEXV,OTHER2 \?CND58
LESS? 0,P-LEN \?CND58
CALL2 NAKED-ADJECTIVE?,OTHER2
ZERO? STACK /?CND58
GET OTLEXV,0
EQUAL? STACK,W?COMMA,W?AND /?CCL59
GET OTLEXV,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD74
PUSH ?TMP1
JUMP ?PEN72
?PRD74: GET OTLEXV,0
GET STACK,3
GET STACK,4
?PEN72: BAND STACK,32768
EQUAL? STACK,-32768 \?CND58
GET OTLEXV,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD77
PUSH ?TMP1
JUMP ?PEN75
?PRD77: GET OTLEXV,0
GET STACK,3
GET STACK,4
?PEN75: BAND STACK,32769
BAND STACK,32767
ZERO? STACK /?CND58
?CCL59: SUB OTHER2,P-LEXV
DIV STACK,2
ADD P-LEXELEN,STACK >CLASS
ICALL MAKE-ROOM-FOR-TOKENS,1,P-LEXV,CLASS
ICALL MAKE-ROOM-FOR-TOKENS,1,G-LEXV,CLASS
ADD OTHER2,4
ICALL CHANGE-LEXV,STACK,W?ONE
GETB P-LEXV,P-LEXWORDS >P-LEN
GET OOPS-TABLE,O-START >TLEXV
CALL2 PARSE-IT,FALSE-VALUE
RSTACK
?CND58: CALL1 DONT-UNDERSTAND
RSTACK
.FUNCT NAKED-ADJECTIVE?:ANY:1:1,PTR,WD,?TMP1
GET PTR,0 >WD
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD6
PUSH ?TMP1
JUMP ?PEN4
?PRD6: GET WD,3
GET STACK,4
?PEN4: BAND STACK,32768
ZERO? STACK \FALSE
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD10
PUSH ?TMP1
JUMP ?PEN8
?PRD10: GET WD,3
GET STACK,4
?PEN8: BAND STACK,4
BAND STACK,32767
ZERO? STACK /FALSE
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD16
PUSH ?TMP1
JUMP ?PEN14
?PRD16: GET WD,3
GET STACK,4
?PEN14: BTST STACK,32768 /?PRD11
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD19
PUSH ?TMP1
JUMP ?PEN17
?PRD19: GET WD,3
GET STACK,4
?PEN17: BAND STACK,64
BAND STACK,32767
ZERO? STACK \FALSE
?PRD11: EQUAL? WD,W?ONE /FALSE
RTRUE
.FUNCT CHANGE-AND-TO-THEN?:ANY:1:1,PTR,?TMP1
GET PTR,0
EQUAL? STACK,W?AND,W?COMMA \FALSE
ADD PTR,4 >PTR
GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD11
PUSH ?TMP1
JUMP ?PEN9
?PRD11: GET PTR,0
GET STACK,3
GET STACK,4
?PEN9: BTST STACK,32768 /?PRD6
GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD14
PUSH ?TMP1
JUMP ?PEN12
?PRD14: GET PTR,0
GET STACK,3
GET STACK,4
?PEN12: BAND STACK,1
BAND STACK,32767
ZERO? STACK \TRUE
?PRD6: GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD20
PUSH ?TMP1
JUMP ?PEN18
?PRD20: GET PTR,0
GET STACK,3
GET STACK,4
?PEN18: BTST STACK,32768 /?PRD15
GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD23
PUSH ?TMP1
JUMP ?PEN21
?PRD23: GET PTR,0
GET STACK,3
GET STACK,4
?PEN21: BAND STACK,64
BAND STACK,32767
ZERO? STACK \TRUE
?PRD15: GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD29
PUSH ?TMP1
JUMP ?PEN27
?PRD29: GET PTR,0
GET STACK,3
GET STACK,4
?PEN27: BAND STACK,32768
EQUAL? STACK,-32768 \FALSE
GET PTR,0
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD33
PUSH ?TMP1
JUMP ?PEN31
?PRD33: GET PTR,0
GET STACK,3
GET STACK,4
?PEN31: BAND STACK,32769
BAND STACK,32767
ZERO? STACK /FALSE
RTRUE
.FUNCT DONT-UNDERSTAND:ANY:0:0,?TMP1
SET 'CLOCK-WAIT,TRUE-VALUE
GETB P-LEXV,P-LEXWORDS
EQUAL? 1,STACK \?CND1
GET P-LEXV,P-LEXSTART
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD11
PUSH ?TMP1
JUMP ?PEN9
?PRD11: GET P-LEXV,P-LEXSTART
GET STACK,3
GET STACK,4
?PEN9: BTST STACK,32768 /?PRD6
GET P-LEXV,P-LEXSTART
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD14
PUSH ?TMP1
JUMP ?PEN12
?PRD14: GET P-LEXV,P-LEXSTART
GET STACK,3
GET STACK,4
?PEN12: BAND STACK,2
BAND STACK,32767
ZERO? STACK \?CCL2
?PRD6: GET P-LEXV,P-LEXSTART
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD19
PUSH ?TMP1
JUMP ?PEN17
?PRD19: GET P-LEXV,P-LEXSTART
GET STACK,3
GET STACK,4
?PEN17: BTST STACK,32768 /?CND1
GET P-LEXV,P-LEXSTART
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD22
PUSH ?TMP1
JUMP ?PEN20
?PRD22: GET P-LEXV,P-LEXSTART
GET STACK,3
GET STACK,4
?PEN20: BAND STACK,4
BAND STACK,32767
ZERO? STACK /?CND1
?CCL2: ICALL2 MISSING,STR?59
RTRUE
?CND1: PRINTR "[Sorry, but I don't understand. Please say that another way, or try something else.]"
.FUNCT MISSING:ANY:1:1,NV
PRINTI "[I think there's a "
PRINT NV
PRINTR " missing in that sentence!]"
.FUNCT CANT-FIND-OBJECT:ANY:2:2,NP,SEARCH,OTHER
EQUAL? NP,ORPHAN-NP \?CCL3
CALL2 NP-CANT-SEE,NP
RSTACK
?CCL3: PRINTI "[There isn't anything to "
GET PARSE-RESULT,1 >OTHER
ZERO? OTHER /?CCL6
ICALL2 PRINT-VOCAB-WORD,OTHER
JUMP ?CND4
?CCL6: PRINTI "do that to"
?CND4: PRINTR ".]"
.FUNCT NP-CANT-SEE:ANY:0:1,NP,OTHER
ASSIGNED? 'NP /?CND1
CALL1 GET-NP >NP
?CND1: GET NP,2 >OTHER
ZERO? OTHER \?CTR4
GET NP,3
ZERO? STACK /?CCL5
?CTR4: PRINTC 91
ICALL RT-PRINT-OBJ,WINNER,K-ART-THE,TRUE-VALUE
PRINTI " can't see "
ZERO? OTHER /?CCL10
PRINTI "any "
ICALL2 NP-PRINT,NP
JUMP ?CND8
?CCL10: ICALL NP-PRINT,NP,TRUE-VALUE
?CND8: PRINTC 32
GET NP,5 >OTHER
ZERO? OTHER /?CCL13
GETB OTHER,1
EQUAL? STACK,4 /?CTR12
GETB OTHER,1
EQUAL? STACK,6 \?CCL13
GET OTHER,2 >OTHER
ZERO? OTHER /?CCL13
?CTR12: PRINTI "in"
GET OTHER,3
ICALL RT-PRINT-OBJ,STACK,K-ART-THE
JUMP ?CND11
?CCL13: PRINTI "right "
PRINTI "here"
?CND11: PRINTR ".]"
?CCL5: CALL1 MORE-SPECIFIC
RSTACK
.FUNCT WINNER-SAYS-WHICH?:ANY:1:1,NP
RFALSE
.FUNCT WHICH-LIST?:ANY:2:2,NP,SR,CT
GET SR,1 >CT
GET SR,0
GRTR? CT,STACK /FALSE
EQUAL? CT,1 \TRUE
GET ORPHAN-SR+8,0
EQUAL? STACK,PSEUDO-OBJECT \TRUE
RFALSE
.FUNCT WHICH-PRINT:ANY:1:1,NP,SR,LEN,SZ,NS,N,S,VEC,REM,OBJ
SET 'SR,ORPHAN-SR
GET SR,1 >LEN
GET SR,0 >SZ
CALL WHICH-LIST?,NP,SR
ZERO? STACK /?CND1
SET 'NS,0
SET 'N,LEN
SET 'S,SZ
ADD SR,8 >VEC
?PRG3: DLESS? 'N,0 /?CND1
DLESS? 'S,0 /?CND1
GET VEC,0
FSET? STACK,FL-SEEN \?CND9
INC 'NS
?CND9: ADD VEC,2 >VEC
JUMP ?PRG3
?CND1: EQUAL? WINNER,CH-PLAYER /?CCL13
PRINTI "[You must specify "
CALL WHICH-LIST?,NP,SR
ZERO? STACK /?CCL16
GRTR? NS,1 \?CCL16
PRINTI "if"
JUMP ?CND11
?CCL16: PRINTI "which"
ZERO? NP /?CND11
PRINTC 32
ICALL2 NP-PRINT,NP
JUMP ?CND11
?CCL13: PRINTI "[Which"
ZERO? NP /?CND21
PRINTC 32
ICALL2 NP-PRINT,NP
?CND21: PRINTI " do"
?CND11: PRINTI " you mean"
CALL WHICH-LIST?,NP,SR
ZERO? STACK /?CND23
GRTR? NS,1 \?CND23
EQUAL? WINNER,CH-PLAYER \?CND27
PRINTC 44
?CND27: SET 'N,LEN
SET 'S,SZ
ADD SR,8 >VEC
SET 'REM,NS
?PRG29: DLESS? 'N,0 /?CND23
DLESS? 'S,0 /?CND23
GET VEC,0 >OBJ
FSET? OBJ,FL-SEEN \?CND35
ICALL RT-PRINT-OBJ,OBJ,K-ART-THE
DEC 'REM
EQUAL? REM,1 \?CCL39
EQUAL? NS,2 /?CND40
PRINTC 44
?CND40: PRINTI " or"
JUMP ?CND35
?CCL39: GRTR? REM,1 \?CND35
PRINTC 44
?CND35: ADD VEC,2 >VEC
JUMP ?PRG29
?CND23: EQUAL? WINNER,CH-PLAYER \?CCL45
PRINTR "?]"
?CCL45: PRINTR ".]"
.FUNCT NP-PRINT:ANY:1:2,NP,DO-QUANT,LEN,OBJ,CT,?TMP1
LESS? 0,NP \?CCL3
GRTR? NP,LAST-OBJECT /?CCL3
CALL2 TELL-THE,NP
RSTACK
?CCL3: GETB NP,1
EQUAL? STACK,3 \?CCL7
?PRG8: GET NP,2 >LEN
ZERO? LEN /?CND10
ICALL2 NP-PRINT,LEN
?CND10: GET NP,1 >NP
ZERO? NP /TRUE
PRINTI " and "
JUMP ?PRG8
?CCL7: GETB NP,1
EQUAL? STACK,4 \?CCL16
GET NP,1 >LEN
ZERO? LEN /FALSE
DEC 'LEN
?PRG20: MUL CT,2
ADD NOUN-PHRASE-HEADER-LEN,STACK
GET NP,STACK >OBJ
ZERO? OBJ /?CND22
ICALL2 TELL-THE,OBJ
?CND22: IGRTR? 'CT,LEN /TRUE
PRINTI ", "
JUMP ?PRG20
?CCL16: ZERO? DO-QUANT /?CND27
GET NP,3 >LEN
ZERO? LEN /?CND27
CALL2 GET-QUANTITY-WORD,LEN
PRINTB STACK
GET NP,2
ZERO? STACK /?CND27
PRINTC 32
?CND27: GET NP,1 >LEN
ZERO? LEN /?CND33
ICALL2 ADJS-PRINT,LEN
?CND33: GET NP,8 >LEN
ZERO? LEN /?CCL37
GET LEN,0 >?TMP1
GET NP,2
EQUAL? ?TMP1,STACK /?CTR36
GET LEN,0
GET STACK,4
BAND STACK,32768
EQUAL? STACK,-32768 \?CCL37
GET LEN,0
GET STACK,4
BAND STACK,32769
BAND STACK,32767
ZERO? STACK /?CCL37
SUB LEN,4 >LEN
LESS? P-LEXV,LEN \?CCL37
GET LEN,0 >?TMP1
GET NP,2
EQUAL? ?TMP1,STACK \?CCL37
?CTR36: ADD LEN,P-WORDLEN
ICALL BUFFER-PRINT,LEN,STACK,FALSE-VALUE,TRUE-VALUE
JUMP ?CND35
?CCL37: GET NP,2 >LEN
ZERO? LEN /?CND35
ICALL2 PRINT-VOCAB-WORD,LEN
?CND35: GET NP,4 >LEN
ZERO? LEN /?CND47
CALL2 PMEM?,LEN
ZERO? STACK /?CND47
GETB LEN,1
EQUAL? STACK,2 \?CND47
PRINTI " of "
ICALL2 NP-PRINT,LEN
?CND47: GET NP,6 >LEN
ZERO? LEN /FALSE
CALL2 PMEM?,LEN
ZERO? STACK /FALSE
GETB LEN,1
EQUAL? STACK,2 \FALSE
PRINTI " except "
CALL2 NP-PRINT,LEN
RSTACK
.FUNCT ADJS-PRINT:ANY:1:1,ADJT,LEN,WD,CT,TMP
GET ADJT,2 >LEN
ZERO? LEN /?CND1
EQUAL? LEN,PLAYER,ME \?CCL5
PRINTI "your "
JUMP ?CND1
?CCL5: ICALL2 NP-PRINT,LEN
PRINTI "'s "
?CND1: GET ADJT,4 >LEN
ZERO? LEN /FALSE
ADD ADJT,10 >ADJT
GRTR? LEN,ADJS-MAX-COUNT \?CND9
SET 'LEN,ADJS-MAX-COUNT
?CND9: DEC 'LEN
MUL 2,LEN
ADD ADJT,STACK >ADJT
?PRG11: GET ADJT,0 >WD
ZERO? WD /?CND13
EQUAL? WD,W?MY \?CCL17
PRINTI "your "
JUMP ?CND13
?CCL17: EQUAL? WD,W?INT.NUM,W?INT.TIM \?CCL19
PRINTN P-NUMBER
PRINTC 32
JUMP ?CND13
?CCL19: EQUAL? WD,W?NO.WORD /?CND13
CALL2 CAPITAL-NOUN?,WD
ZERO? STACK /?CCL23
GETB P-LEXV,P-LEXWORDS >TMP
ZERO? TMP /?CCL23
INTBL? WD,P-LEXV+2,TMP,132 >TMP \?CCL23
ICALL2 CAPITALIZE,TMP
JUMP ?CND21
?CCL23: ICALL2 PRINT-VOCAB-WORD,WD
?CND21: PRINTC 32
?CND13: IGRTR? 'CT,LEN /TRUE
SUB ADJT,2 >ADJT
JUMP ?PRG11
.FUNCT TOO-MANY-NOUNS:ANY:1:1,WD
PRINTI "[I can't understand that many nouns with "
ZERO? WD /?CCL3
PRINTC 34
ICALL2 PRINT-VOCAB-WORD,WD
PRINTC 34
JUMP ?CND1
?CCL3: PRINTI "that verb"
?CND1: PRINTR ".]"
.FUNCT INBUF-ADD:ANY:3:3,LEN,BEG,SLOT,DBEG,TMP,?TMP1
GET OOPS-TABLE,O-END >TMP
ZERO? TMP /?CCL3
SET 'DBEG,TMP
JUMP ?CND1
?CCL3: GET OOPS-TABLE,O-LENGTH
MUL P-WORDLEN,STACK >TMP
GETB G-LEXV,TMP >?TMP1
ADD TMP,1
GETB G-LEXV,STACK
ADD ?TMP1,STACK >DBEG
?CND1: SUB LEN,1
ADD DBEG,STACK
LESS? INBUF-LENGTH,STACK /FALSE
ADD DBEG,LEN
PUT OOPS-TABLE,O-END,STACK
ADD P-INBUF,BEG >?TMP1
ADD G-INBUF,DBEG
COPYT ?TMP1,STACK,LEN
PUTB G-LEXV,SLOT,DBEG
SUB SLOT,1
PUTB G-LEXV,STACK,LEN
RTRUE
.FUNCT INBUF-PRINT:ANY:4:4,WD,INBUF,LEXV,SLOT,DBEG,CTR,TMP,LEN,?TMP1
SET 'LEN,11
GET OOPS-TABLE,O-END >TMP
ZERO? TMP /?CCL3
SET 'DBEG,TMP
JUMP ?CND1
?CCL3: GET OOPS-TABLE,O-LENGTH
MUL P-WORDLEN,STACK >TMP
GETB LEXV,TMP >?TMP1
ADD TMP,1
GETB LEXV,STACK
ADD ?TMP1,STACK >DBEG
?CND1: GETB INBUF,0 >?TMP1
SUB LEN,1
ADD DBEG,STACK
LESS? ?TMP1,STACK /FALSE
ADD INBUF,DBEG
DIROUT D-TABLE-ON,STACK
ICALL2 PRINT-VOCAB-WORD,WD
DIROUT D-TABLE-OFF
ADD 1,DBEG
GETB INBUF,STACK >LEN
ADD 2,DBEG >DBEG
ADD DBEG,LEN
PUT OOPS-TABLE,O-END,STACK
PUTB LEXV,SLOT,DBEG
SUB SLOT,1
PUTB LEXV,STACK,LEN
RTRUE
.FUNCT YES?:ANY:0:1,NO-Q,WORD,VAL
ZERO? NO-Q \?PRG3
PRINTC 63
?PRG3: CRLF
PRINTI "Please answer YES or NO >"
PUTB YES-INBUF,1,0
?PRG5: READ YES-INBUF,YES-LEXV >VAL
EQUAL? VAL,10,13 \?PRG5
ICALL2 RT-SCRIPT-INBUF,YES-INBUF
GETB YES-LEXV,P-LEXWORDS
ZERO? STACK /?PRG3
GET YES-LEXV,P-LEXSTART >WORD
ZERO? WORD /?PRG3
GET WORD,4
BTST STACK,32768 /?CCL15
GET WORD,4
BAND STACK,1
BAND STACK,32767
ZERO? STACK /?CCL15
GET WORD,3 >VAL
JUMP ?CND13
?CCL15: SET 'VAL,FALSE-VALUE
?CND13: EQUAL? VAL,ACT?YES /?CTR19
EQUAL? WORD,W?Y \?CCL20
?CTR19: SET 'VAL,TRUE-VALUE
RETURN VAL
?CCL20: EQUAL? VAL,ACT?NO /?CTR23
EQUAL? WORD,W?N \?CCL24
?CTR23: SET 'VAL,FALSE-VALUE
RETURN VAL
?CCL24: EQUAL? VAL,ACT?RESTART \?CCL28
ICALL1 V-RESTART
JUMP ?PRG3
?CCL28: EQUAL? VAL,ACT?RESTORE \?CCL30
ICALL1 V-RESTORE
JUMP ?PRG3
?CCL30: EQUAL? VAL,ACT?QUIT \?PRG3
ICALL1 V-QUIT
JUMP ?PRG3
.FUNCT SETUP-ORPHAN:ANY:1:3,STR,A,B
DIROUT D-TABLE-ON,O-INBUF
PRINT STR
ZERO? A /?CND1
ICALL2 RT-PRINT-DESC,A
ZERO? B /?CND1
PRINT B
?CND1: DIROUT D-TABLE-OFF
PUTB O-INBUF,0,INBUF-LENGTH
LEX O-INBUF,O-LEXV
GETB O-LEXV,P-LEXWORDS >A
ZERO? A /FALSE
INTBL? 0,O-LEXV+2,A,132 /FALSE
GETB O-LEXV,P-LEXWORDS
MUL P-LEXELEN,STACK
ADD 1,STACK >P-OFLAG
ICALL MAKE-ROOM-FOR-TOKENS,1,O-LEXV,P-OFLAG
PUT O-LEXV,P-OFLAG,W?NO.WORD
SUB 0,P-OFLAG >P-OFLAG
PUT OOPS-TABLE,O-AGAIN,P-LEXV+2
RTRUE
.FUNCT SETUP-ORPHAN-NP:ANY:3:4,STR,OBJ1,OBJ2,OBJ3,NUM,VEC
DIROUT D-TABLE-ON,O-INBUF
PRINT STR
DIROUT D-TABLE-OFF
PUTB O-INBUF,0,INBUF-LENGTH
LEX O-INBUF,O-LEXV
GETB O-LEXV,P-LEXWORDS >NUM
ZERO? NUM /FALSE
INTBL? 0,O-LEXV+2,NUM,132 /FALSE
GETB O-LEXV,P-LEXWORDS
MUL P-LEXELEN,STACK
SUB 1,STACK >P-OFLAG
PUT OOPS-TABLE,O-AGAIN,P-LEXV+2
SET 'VEC,ORPHAN-SR+8
PUT VEC,0,OBJ1
PUT VEC,1,OBJ2
SET 'NUM,2
ZERO? OBJ3 /?CND6
INC 'NUM
PUT VEC,2,OBJ3
?CND6: PUT ORPHAN-SR,1,NUM
RTRUE
.FUNCT INSERT-ADJS:ANY:1:1,E,CT,PTR,WD
LESS? P-OFLAG,0 \?CCL3
SUB 0,P-OFLAG >PTR
JUMP ?CND1