-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathparser.zap
2416 lines (2263 loc) · 49.9 KB
/
parser.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
.FUNCT PARSER,PTR=P-LEXSTART,WRD,VAL=0,VERB=0,OF-FLAG=0,LEN,DIR=0,NW=0,LW=0,CNT=-1,OWINNER,OMERGED,TEMP=0,?TMP2,?TMP1
?PRG1: IGRTR? 'CNT,P-ITBLLEN /?REP2
ZERO? P-OFLAG \?CND8
GET P-ITBL,CNT
PUT P-OTBL,CNT,STACK
?CND8: PUT P-ITBL,CNT,0
JUMP ?PRG1
?REP2: SET 'OMERGED,P-MERGED
SET 'P-MERGED,FALSE-VALUE
SET 'P-END-ON-PREP,FALSE-VALUE
PUT P-PRSO,P-MATCHLEN,0
PUT P-PRSI,P-MATCHLEN,0
PUT P-BUTS,P-MATCHLEN,0
SET 'OWINNER,WINNER
ZERO? P-OFLAG \?CND11
SET 'P-PRSA-WORD,FALSE-VALUE
?CND11: ZERO? QUOTE-FLAG \?CND14
EQUAL? WINNER,PLAYER /?CND14
SET 'WINNER,PLAYER
SET 'LAST-PLAYER-LOC,HERE
LOC WINNER
FSET? STACK,VEHBIT /?CND19
SET 'LAST-PLAYER-LOC,HERE
LOC WINNER >HERE
?CND19: CALL LIT?,HERE >LIT
?CND14: ZERO? RESERVE-PTR /?ELS24
SET 'PTR,RESERVE-PTR
CALL STUFF,P-LEXV,RESERVE-LEXV
ZERO? VERBOSITY /?CND26
EQUAL? PLAYER,WINNER \?CND26
CRLF
?CND26: SET 'RESERVE-PTR,FALSE-VALUE
SET 'P-CONT,FALSE-VALUE
JUMP ?CND22
?ELS24: ZERO? P-CONT /?ELS32
SET 'PTR,P-CONT
SET 'P-CONT,FALSE-VALUE
ZERO? SAYING? /?ELS36
SET 'SAYING?,FALSE-VALUE
JUMP ?CND22
?ELS36: ZERO? VERBOSITY /?CND22
EQUAL? PLAYER,WINNER \?CND22
CRLF
JUMP ?CND22
?ELS32: SET 'SAYING?,FALSE-VALUE
SET 'WINNER,PLAYER
SET 'QUOTE-FLAG,FALSE-VALUE
SET 'LAST-PLAYER-LOC,HERE
LOC WINNER
FSET? STACK,VEHBIT /?CND44
SET 'LAST-PLAYER-LOC,HERE
LOC WINNER >HERE
?CND44: CALL LIT?,HERE >LIT
ZERO? VERBOSITY /?CND47
CRLF
?CND47: PUTB P-LEXV,0,59
PRINTC 62
READ P-INBUF,P-LEXV
?CND22: GETB P-LEXV,P-LEXWORDS >P-LEN
GET P-LEXV,PTR
EQUAL? W?QUOTE,STACK \?CND50
CALL QCONTEXT-GOOD?
ZERO? STACK /?CND50
ADD PTR,P-LEXELEN >PTR
DEC 'P-LEN
?CND50: GET P-LEXV,PTR
EQUAL? W?THEN,STACK \?CND55
ADD PTR,P-LEXELEN >PTR
DEC 'P-LEN
?CND55: LESS? 1,P-LEN \?CND58
GET P-LEXV,PTR
EQUAL? W?GO,STACK \?CND58
ADD PTR,P-LEXELEN
GET P-LEXV,STACK >NW
ZERO? NW /?CND58
CALL WT?,NW,64
ZERO? STACK /?CND58
ADD PTR,P-LEXELEN >PTR
DEC 'P-LEN
?CND58: ZERO? P-LEN \?ELS65
PRINTI "[Beg pardon?]"
CRLF
RFALSE
?ELS65: GET P-LEXV,PTR
EQUAL? STACK,W?OOPS \?ELS67
GRTR? P-LEN,1 /?ELS70
PRINTI "[You can't use OOPS that way.]"
CRLF
RFALSE
?ELS70: GET OOPS-TABLE,O-PTR
ZERO? STACK /?ELS72
GET OOPS-TABLE,O-PTR >?TMP1
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
PUT AGAIN-LEXV,?TMP1,STACK
SET 'WINNER,OWINNER
MUL PTR,P-LEXELEN
ADD STACK,6
GETB P-LEXV,STACK >?TMP2
MUL PTR,P-LEXELEN
ADD STACK,7
GETB P-LEXV,STACK >?TMP1
GET OOPS-TABLE,O-PTR
MUL STACK,P-LEXELEN
ADD STACK,3
CALL INBUF-ADD,?TMP2,?TMP1,STACK
CALL STUFF,P-LEXV,AGAIN-LEXV
GETB P-LEXV,P-LEXWORDS >P-LEN
GET OOPS-TABLE,O-START >PTR
CALL INBUF-STUFF,P-INBUF,OOPS-INBUF
JUMP ?CND63
?ELS72: PUT OOPS-TABLE,O-END,FALSE-VALUE
PRINTI "[There was no word to replace!]"
CRLF
RFALSE
?ELS67: PUT OOPS-TABLE,O-END,FALSE-VALUE
?CND63: GET P-LEXV,PTR
EQUAL? STACK,W?AGAIN,W?G \?ELS79
ZERO? P-OFLAG \?THN83
ZERO? P-WON \?ELS82
?THN83: PRINTI "[You can't use AGAIN that way.]"
CRLF
RFALSE
?ELS82: GRTR? P-LEN,1 \?ELS86
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?PERIOD,W?COMMA,W?THEN /?THN90
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?AND \?ELS89
?THN90: ADD PTR,4 >PTR
GETB P-LEXV,P-LEXWORDS
SUB STACK,2
PUTB P-LEXV,P-LEXWORDS,STACK
JUMP ?CND80
?ELS89: PRINTI "[I couldn't understand that sentence.]"
CRLF
RFALSE
?ELS86: ADD PTR,P-LEXELEN >PTR
GETB P-LEXV,P-LEXWORDS
SUB STACK,1
PUTB P-LEXV,P-LEXWORDS,STACK
?CND80: GETB P-LEXV,P-LEXWORDS
GRTR? STACK,0 \?ELS98
CALL STUFF,RESERVE-LEXV,P-LEXV
SET 'RESERVE-PTR,PTR
JUMP ?CND96
?ELS98: SET 'RESERVE-PTR,FALSE-VALUE
?CND96: SET 'WINNER,OWINNER
SET 'P-MERGED,OMERGED
CALL INBUF-STUFF,P-INBUF,OOPS-INBUF
CALL STUFF,P-LEXV,AGAIN-LEXV
SET 'CNT,-1
SET 'DIR,P-WALK-DIR
?PRG101: IGRTR? 'CNT,P-ITBLLEN /?CND77
GET P-OTBL,CNT
PUT P-ITBL,CNT,STACK
JUMP ?PRG101
?ELS79: SET 'P-NUMBER,-1
SET 'P-NAM,FALSE-VALUE
SET 'P-ADJ,FALSE-VALUE
SET 'P-ADVERB,FALSE-VALUE
CALL STUFF,AGAIN-LEXV,P-LEXV
CALL INBUF-STUFF,OOPS-INBUF,P-INBUF
PUT OOPS-TABLE,O-START,PTR
MUL 4,P-LEN
PUT OOPS-TABLE,O-LENGTH,STACK
SET 'RESERVE-PTR,FALSE-VALUE
SET 'LEN,P-LEN
SET 'P-NCN,0
SET 'P-GETFLAGS,0
PUT P-ITBL,P-VERBN,0
SET 'P-SENTENCE,PTR
?PRG110: DLESS? 'P-LEN,0 \?ELS114
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND77
?ELS114: GET P-LEXV,PTR >WRD
CALL BUZZER-WORD?,WRD
ZERO? STACK \FALSE
ZERO? WRD \?THN119
CALL NUMBER?,PTR >WRD
ZERO? WRD /?ELS118
?THN119: ZERO? P-LEN \?ELS123
SET 'NW,0
JUMP ?CND121
?ELS123: ADD PTR,P-LEXELEN
GET P-LEXV,STACK >NW
?CND121: EQUAL? WRD,W?TO \?ELS128
EQUAL? VERB,ACT?TELL,ACT?ASK \?ELS128
PUT P-ITBL,P-VERB,ACT?TELL
SET 'WRD,W?QUOTE
JUMP ?CND126
?ELS128: EQUAL? WRD,W?THEN \?CND126
ZERO? VERB \?CND126
ZERO? QUOTE-FLAG \?CND126
GET P-ITBL,P-NC1
ZERO? STACK /?CND126
PUT P-ITBL,P-VERB,ACT?TELL
PUT P-ITBL,P-VERBN,0
SET 'WRD,W?QUOTE
?CND126: EQUAL? WRD,W?PERIOD \?ELS137
EQUAL? LW,W?MR,W?MISS,W?MRS \?ELS137
SET 'LW,0
JUMP ?CND112
?ELS137: EQUAL? WRD,W?THEN,W?PERIOD,W?QUOTE \?ELS141
EQUAL? WRD,W?QUOTE \?CND142
ZERO? QUOTE-FLAG /?ELS147
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND142
?ELS147: SET 'QUOTE-FLAG,TRUE-VALUE
?CND142: ZERO? P-LEN /?THN151
ADD PTR,P-LEXELEN >P-CONT
?THN151: PUTB P-LEXV,P-LEXWORDS,P-LEN
JUMP ?CND77
?ELS141: CALL WT?,WRD,16,3 >VAL
ZERO? VAL /?ELS154
EQUAL? VERB,FALSE-VALUE,ACT?WALK,ACT?GO \?ELS154
EQUAL? LEN,1 /?THN157
EQUAL? LEN,2 \?ELS160
EQUAL? VERB,ACT?WALK,ACT?GO /?THN157
?ELS160: EQUAL? NW,W?THEN,W?PERIOD,W?QUOTE \?ELS162
GRTR? LEN,1 /?THN157
?ELS162: ZERO? QUOTE-FLAG /?ELS164
EQUAL? LEN,2 \?ELS164
EQUAL? NW,W?QUOTE /?THN157
?ELS164: GRTR? LEN,2 \?ELS154
EQUAL? NW,W?COMMA,W?AND \?ELS154
?THN157: SET 'DIR,VAL
EQUAL? NW,W?COMMA,W?AND \?CND167
ADD PTR,P-LEXELEN
CALL CHANGE-LEXV,STACK,W?THEN
?CND167: GRTR? LEN,2 /?CND112
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND77
?ELS154: CALL WT?,WRD,64,1 >VAL
ZERO? VAL /?ELS174
ZERO? VERB \?ELS174
SET 'P-PRSA-WORD,WRD
SET 'VERB,VAL
PUT P-ITBL,P-VERB,VAL
PUT P-ITBL,P-VERBN,P-VTBL
PUT P-VTBL,0,WRD
MUL PTR,2
ADD STACK,2 >TEMP
GETB P-LEXV,TEMP
PUTB P-VTBL,2,STACK
ADD TEMP,1
GETB P-LEXV,STACK
PUTB P-VTBL,3,STACK
JUMP ?CND112
?ELS174: CALL WT?,WRD,8,0 >VAL
ZERO? VAL \?THN179
EQUAL? WRD,W?A /?THN183
EQUAL? WRD,W?BOTH,W?ALL,W?EVERYTHING /?THN183
CALL WT?,WRD,32
ZERO? STACK \?THN183
CALL WT?,WRD,128
ZERO? STACK /?ELS178
?THN183: SET 'VAL,0 \?ELS178
?THN179: GRTR? P-LEN,1 \?ELS187
EQUAL? NW,W?OF \?ELS187
EQUAL? VERB,ACT?TAKE /?ELS187
ZERO? VAL \?ELS187
EQUAL? WRD,W?A /?ELS187
EQUAL? WRD,W?ALL,W?BOTH,W?EVERYTHING /?ELS187
SET 'OF-FLAG,TRUE-VALUE
JUMP ?CND112
?ELS187: ZERO? VAL /?ELS191
ZERO? P-LEN /?THN194
EQUAL? NW,W?THEN,W?PERIOD \?ELS191
?THN194: SET 'P-END-ON-PREP,TRUE-VALUE
LESS? P-NCN,2 \?CND112
PUT P-ITBL,P-PREP1,VAL
PUT P-ITBL,P-PREP1N,WRD
JUMP ?CND112
?ELS191: EQUAL? P-NCN,2 \?ELS200
PRINTI "[There are too many nouns in that sentence!]"
CRLF
RFALSE
?ELS200: INC 'P-NCN
CALL CLAUSE,PTR,VAL,WRD >PTR
ZERO? PTR /FALSE
LESS? PTR,0 \?CND112
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND77
?ELS178: EQUAL? WRD,W?OF \?ELS209
ZERO? OF-FLAG /?THN213
EQUAL? NW,W?PERIOD,W?THEN \?ELS212
?THN213: CALL CANT-USE,PTR
RFALSE
?ELS212: SET 'OF-FLAG,FALSE-VALUE
JUMP ?CND112
?ELS209: CALL WT?,WRD,4
ZERO? STACK \?CND112
EQUAL? VERB,ACT?TELL \?ELS220
CALL WT?,WRD,64
ZERO? STACK /?ELS220
CALL WAY-TO-TALK
RFALSE
?ELS220: CALL CANT-USE,PTR
RFALSE
?ELS118: CALL UNKNOWN-WORD,PTR
RFALSE
?CND112: SET 'LW,WRD
ADD PTR,P-LEXELEN >PTR
JUMP ?PRG110
?CND77: PUT OOPS-TABLE,O-PTR,FALSE-VALUE
ZERO? DIR /?CND227
SET 'PRSA,V?WALK
SET 'P-WALK-DIR,DIR
SET 'PRSO,DIR
SET 'P-OFLAG,FALSE-VALUE
RTRUE
?CND227: SET 'P-WALK-DIR,FALSE-VALUE
ZERO? P-OFLAG /?CND231
CALL ORPHAN-MERGE
ZERO? STACK /?CND231
SET 'WINNER,OWINNER
?CND231: ZERO? P-CONT /?CND236
GET P-ITBL,P-VERB
ZERO? STACK \?CND236
GET P-ITBL,P-NC1
ZERO? STACK /?CND236
PUT P-ITBL,P-VERB,ACT?TELL
?CND236: CALL SYNTAX-CHECK
ZERO? STACK /FALSE
CALL SNARF-OBJECTS
ZERO? STACK /FALSE
CALL MANY-CHECK
ZERO? STACK /FALSE
CALL TAKE-CHECK
ZERO? STACK /FALSE
RTRUE
.FUNCT CHANGE-LEXV,PTR,WRD
PUT P-LEXV,PTR,WRD
PUT AGAIN-LEXV,PTR,WRD
RTRUE
.FUNCT WAY-TO-TALK
PRINTR "[Refer to your HOLLYWOOD HIJINX manual for the correct way to talk to characters.]"
.FUNCT WT?,PTR,BIT,B1=5,OFFS=P-P1OFF,TYP
GETB PTR,P-PSOFF >TYP
BTST TYP,BIT \FALSE
GRTR? B1,4 /TRUE
BAND TYP,P-P1BITS >TYP
EQUAL? TYP,B1 /?CND13
INC 'OFFS
?CND13: GETB PTR,OFFS
RSTACK
.FUNCT CLAUSE,PTR,VAL,WRD,OFF,NUM,ANDFLG=0,FIRST??=1,NW,LW=0,LEN,?TMP1
SUB P-NCN,1
MUL STACK,2 >OFF
ZERO? VAL /?ELS3
GET P-LEXV,PTR
EQUAL? STACK,W?RIGHT,W?LEFT \?ELS3
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?END \?ELS3
SET 'VAL,0
INC 'P-LEN
JUMP ?CND1
?ELS3: ZERO? VAL /?ELS7
ADD P-PREP1,OFF >NUM
PUT P-ITBL,NUM,VAL
ADD NUM,1
PUT P-ITBL,STACK,WRD
ADD PTR,P-LEXELEN >PTR
EQUAL? WRD,W?TO /?CND1
SET 'LEN,P-LEN
?PRG11: DEC 'LEN
GET P-LEXV,PTR >WRD
EQUAL? WRD,W?LEFT,W?RIGHT \?CND1
GRTR? LEN,0 \?CND1
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?END /?CND1
CALL WT?,WRD,8,0 >VAL
PUT P-ITBL,NUM,VAL
ADD NUM,1
PUT P-ITBL,STACK,WRD
ADD PTR,P-LEXELEN >PTR
JUMP ?PRG11
?ELS7: INC 'P-LEN
?CND1: ZERO? P-LEN \?CND22
DEC 'P-NCN
RETURN -1
?CND22: ADD P-NC1,OFF >NUM
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,NUM,STACK
GET P-LEXV,PTR
EQUAL? STACK,W?THE,W?A,W?AN \?CND25
GET P-ITBL,NUM
ADD STACK,4
PUT P-ITBL,NUM,STACK
ADD PTR,P-LEXELEN >PTR
DEC 'P-LEN
?CND25:
?PRG28: DLESS? 'P-LEN,0 \?CND30
ADD NUM,1 >?TMP1
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
RETURN -1
?CND30: GET P-LEXV,PTR >WRD
CALL BUZZER-WORD?,WRD
ZERO? STACK \FALSE
ZERO? WRD \?THN38
CALL NUMBER?,PTR >WRD
ZERO? WRD /?ELS37
?THN38: ZERO? P-LEN \?ELS42
SET 'NW,0
JUMP ?CND40
?ELS42: ADD PTR,P-LEXELEN
GET P-LEXV,STACK >NW
?CND40: EQUAL? WRD,W?PERIOD \?ELS47
EQUAL? LW,W?MR,W?MRS,W?MISS \?ELS47
SET 'LW,0
JUMP ?CND33
?ELS47: EQUAL? WRD,W?AND,W?COMMA \?ELS51
SET 'ANDFLG,TRUE-VALUE
JUMP ?CND33
?ELS51: EQUAL? WRD,W?ALL,W?BOTH,W?EVERYTHING \?ELS53
EQUAL? NW,W?OF \?CND33
DEC 'P-LEN
ADD PTR,P-LEXELEN >PTR
JUMP ?CND33
?ELS53: EQUAL? WRD,W?THEN,W?PERIOD /?THN59
CALL WT?,WRD,8
ZERO? STACK /?ELS58
GET P-ITBL,P-VERB
ZERO? STACK /?ELS58
ZERO? FIRST?? \?ELS58
?THN59: INC 'P-LEN
ADD NUM,1 >?TMP1
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
SUB PTR,P-LEXELEN
RSTACK
?ELS58: ZERO? ANDFLG /?ELS64
GET P-ITBL,P-VERBN
ZERO? STACK /?THN67
CALL VERB-DIR-ONLY?,WRD
ZERO? STACK /?ELS64
?THN67: SUB PTR,4 >PTR
ADD PTR,2
CALL CHANGE-LEXV,STACK,W?THEN
ADD P-LEN,2 >P-LEN
JUMP ?CND33
?ELS64: CALL WT?,WRD,128
ZERO? STACK /?ELS70
GRTR? P-LEN,0 \?ELS73
EQUAL? NW,W?OF \?ELS73
EQUAL? WRD,W?ALL,W?EVERYTHING \?CND33
?ELS73: CALL WT?,WRD,32
ZERO? STACK /?ELS77
ZERO? NW /?ELS77
CALL WT?,NW,128
ZERO? STACK \?CND33
?ELS77: ZERO? ANDFLG \?ELS81
EQUAL? NW,W?BUT,W?EXCEPT /?ELS81
EQUAL? NW,W?AND,W?COMMA /?ELS81
ADD NUM,1 >?TMP1
ADD PTR,2
MUL STACK,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
RETURN PTR
?ELS81: SET 'ANDFLG,FALSE-VALUE
JUMP ?CND33
?ELS70: CALL WT?,WRD,32
ZERO? STACK \?CND33
CALL WT?,WRD,4
ZERO? STACK \?CND33
ZERO? ANDFLG /?ELS91
GET P-ITBL,P-VERB
ZERO? STACK \?ELS91
SUB PTR,4 >PTR
ADD PTR,2
CALL CHANGE-LEXV,STACK,W?THEN
ADD P-LEN,2 >P-LEN
JUMP ?CND33
?ELS91: CALL WT?,WRD,8
ZERO? STACK \?CND33
CALL CANT-USE,PTR
RFALSE
?ELS37: CALL UNKNOWN-WORD,PTR
RFALSE
?CND33: SET 'LW,WRD
SET 'FIRST??,FALSE-VALUE
ADD PTR,P-LEXELEN >PTR
JUMP ?PRG28
.FUNCT THIS-IS-IT,OBJ
EQUAL? OBJ,FALSE-VALUE,PLAYER,NOT-HERE-OBJECT /TRUE
EQUAL? OBJ,INTDIR /TRUE
EQUAL? PRSA,V?WALK,V?WALK-TO \?ELS9
EQUAL? OBJ,PRSO /TRUE
?ELS9: SET 'P-THEM-OBJECT,OBJ
SET 'P-IT-OBJECT,OBJ
RTRUE
.FUNCT REFERRING,WHO=0
PRINTI "[I don't see wh"
ZERO? WHO /?ELS3
PRINTI "om"
JUMP ?CND1
?ELS3: PRINTI "at"
?CND1: PRINTR " you're referring to.]"
.FUNCT FAKE-ORPHAN,TMP,?TMP1
CALL ORPHAN,P-SYNTAX,FALSE-VALUE
PRINTI "[Be specific: what object do you want to "
GET P-OTBL,P-VERBN >TMP
ZERO? TMP \?ELS3
PRINTI "tell"
JUMP ?CND1
?ELS3: GETB P-VTBL,2
ZERO? STACK \?ELS5
GET TMP,0
PRINTB STACK
JUMP ?CND1
?ELS5: GETB TMP,2 >?TMP1
GETB TMP,3
CALL WORD-PRINT,?TMP1,STACK
PUTB P-VTBL,2,0
?CND1: SET 'P-OFLAG,TRUE-VALUE
SET 'P-WON,FALSE-VALUE
PRINTR "?]"
.FUNCT SEE-VERB?
EQUAL? PRSA,V?LOOK,V?EXAMINE,V?LOOK-INSIDE /TRUE
EQUAL? PRSA,V?SEARCH,V?FIND,V?LOOK-ON /TRUE
EQUAL? PRSA,V?OPEN /TRUE
EQUAL? PRSA,V?LOOK-UNDER,V?LOOK-BEHIND,V?READ /TRUE
EQUAL? PRSA,V?LOOK-THRU,V?LOOK-DOWN,V?COUNT /TRUE
EQUAL? PRSA,V?PLAY \FALSE
RTRUE
.FUNCT PERFORM,A,O=0,I=0,V,OA,OO,OI
ZERO? DEBUG /?CND1
PRINTI "[Perform: "
PRINTN A
ZERO? O /?CND5
PRINTC 47
EQUAL? A,V?WALK \?ELS11
PRINTN O
JUMP ?CND5
?ELS11: CALL DPRINT,O
?CND5: ZERO? I /?CND14
PRINTC 47
CALL DPRINT,I
?CND14: PRINTC 93
CRLF
?CND1: SET 'OA,PRSA
SET 'OO,PRSO
SET 'OI,PRSI
SET 'PRSA,A
ZERO? LIT \?ELS20
CALL SEE-VERB?
ZERO? STACK /?ELS20
CALL TOO-DARK
RETURN 2
?ELS20: EQUAL? A,V?WALK /?CND18
EQUAL? IT,I,O \?CND27
ZERO? P-IT-OBJECT /?ELS32
CALL ACCESSIBLE?,P-IT-OBJECT
ZERO? STACK \?CND27
?ELS32: ZERO? I \?ELS39
CALL FAKE-ORPHAN
RETURN 2
?ELS39: CALL REFERRING
RETURN 2
?CND27: EQUAL? THEM,I,O \?CND44
ZERO? P-THEM-OBJECT /?ELS49
CALL VISIBLE?,P-THEM-OBJECT
ZERO? STACK /?ELS49
ZERO? DEBUG /?CND52
PRINTI "[them="
CALL DPRINT,P-THEM-OBJECT
PRINTC 93
CRLF
?CND52: EQUAL? THEM,O \?CND56
SET 'O,P-THEM-OBJECT
?CND56: EQUAL? THEM,I \?CND44
SET 'I,P-THEM-OBJECT
JUMP ?CND44
?ELS49: ZERO? I \?ELS66
CALL FAKE-ORPHAN
RETURN 2
?ELS66: CALL REFERRING,TRUE-VALUE
RETURN 2
?CND44: EQUAL? HER,I,O \?CND71
ZERO? P-HER-OBJECT /?ELS76
CALL VISIBLE?,P-HER-OBJECT
ZERO? STACK /?ELS76
ZERO? DEBUG /?CND79
PRINTI "[her="
CALL DPRINT,P-HER-OBJECT
PRINTC 93
CRLF
?CND79: EQUAL? HER,O \?CND83
SET 'O,P-HER-OBJECT
?CND83: EQUAL? HER,I \?CND71
SET 'I,P-HER-OBJECT
JUMP ?CND71
?ELS76: ZERO? I \?ELS93
CALL FAKE-ORPHAN
RETURN 2
?ELS93: CALL REFERRING,TRUE-VALUE
RETURN 2
?CND71: EQUAL? HIM,I,O \?CND98
ZERO? P-HIM-OBJECT /?ELS103
CALL VISIBLE?,P-HIM-OBJECT
ZERO? STACK /?ELS103
ZERO? DEBUG /?CND106
PRINTI "[him="
CALL DPRINT,P-HIM-OBJECT
PRINTC 93
CRLF
?CND106: EQUAL? HIM,O \?CND110
SET 'O,P-HIM-OBJECT
?CND110: EQUAL? HIM,I \?CND98
SET 'I,P-HIM-OBJECT
JUMP ?CND98
?ELS103: ZERO? I \?ELS120
CALL FAKE-ORPHAN
RETURN 2
?ELS120: CALL REFERRING,TRUE-VALUE
RETURN 2
?CND98: EQUAL? O,IT \?CND125
SET 'O,P-IT-OBJECT
ZERO? DEBUG /?CND125
PRINTI "[it="
CALL DPRINT,O
PRINTC 93
CRLF
?CND125: EQUAL? I,IT \?CND18
SET 'I,P-IT-OBJECT
ZERO? DEBUG /?CND18
PRINTI "[it="
CALL DPRINT,O
PRINTC 93
CRLF
?CND18: SET 'PRSI,I
SET 'PRSO,O
SET 'V,FALSE-VALUE
EQUAL? A,V?WALK /?CND139
EQUAL? NOT-HERE-OBJECT,PRSO,PRSI \?CND139
CALL NOT-HERE-OBJECT-F >V
ZERO? V /?CND139
SET 'P-WON,FALSE-VALUE
?CND139: CALL THIS-IS-IT,PRSI
CALL THIS-IS-IT,PRSO
SET 'O,PRSO
SET 'I,PRSI
ZERO? V \?CND148
GETP WINNER,P?ACTION
CALL STACK >V
?CND148: ZERO? V \?CND151
LOC WINNER
GETP STACK,P?ACTION
CALL STACK,M-BEG >V
?CND151: ZERO? V \?CND154
GET PREACTIONS,A
CALL STACK >V
?CND154: ZERO? V \?CND157
ZERO? I /?CND157
EQUAL? A,V?WALK /?CND157
LOC I
ZERO? STACK /?CND157
LOC I
GETP STACK,P?CONTFCN >V
ZERO? V /?CND157
CALL V,M-CONT >V
?CND157: ZERO? V \?CND166
ZERO? I /?CND166
GETP I,P?ACTION
CALL STACK >V
?CND166: ZERO? V \?CND171
ZERO? O /?CND171
EQUAL? A,V?WALK /?CND171
LOC O
ZERO? STACK /?CND171
LOC O
GETP STACK,P?CONTFCN >V
ZERO? V /?CND171
CALL V,M-CONT >V
?CND171: ZERO? V \?CND180
ZERO? O /?CND180
EQUAL? A,V?WALK /?CND180
GETP O,P?ACTION
CALL STACK >V
ZERO? V /?CND180
CALL THIS-IS-IT,O
?CND180: ZERO? V \?CND189
GET ACTIONS,A
CALL STACK >V
?CND189: EQUAL? V,M-FATAL /?CND192
CALL GAME-VERB?
ZERO? STACK \?CND192
GETP HERE,P?ACTION
CALL STACK,M-END >V
?CND192: SET 'PRSA,OA
SET 'PRSO,OO
SET 'PRSI,OI
RETURN V
.FUNCT BUZZER-WORD?,WORD
CALL NUMBER-WORD?,WORD
ZERO? STACK \TRUE
CALL NAUGHTY-WORD?,WORD
ZERO? STACK /FALSE
RTRUE
.FUNCT NUMBER-WORD?,WRD
EQUAL? WRD,W?ONE /?THN6
EQUAL? WRD,W?TWO,W?THREE,W?FOUR /?THN6
EQUAL? WRD,W?FIVE,W?SIX,W?SEVEN /?THN6
EQUAL? WRD,W?EIGHT,W?NINE,W?TEN /?THN6
EQUAL? WRD,W?ELEVEN,W?TWELVE,W?THIRTE /?THN6
EQUAL? WRD,W?FOURTE,W?FIFTEE,W?SIXTEE /?THN6
EQUAL? WRD,W?SEVENT,W?EIGHTE,W?NINETE /?THN6
EQUAL? WRD,W?TWENTY,W?THIRTY,W?FORTY /?THN6
EQUAL? WRD,W?FIFTY,W?SIXTY,W?EIGHTY /?THN6
EQUAL? WRD,W?NINETY,W?HUNDRE,W?THOUSA /?THN6
EQUAL? WRD,W?MILLIO,W?BILLIO,W?ZERO \FALSE
?THN6: PRINTR "[Use numerals for numbers, for example ""10.""]"
.FUNCT NAUGHTY-WORD?,WORD
EQUAL? WORD,W?CURSE,W?GODDAMNED,W?CUSS /?THN6
EQUAL? WORD,W?DAMN,W?SHIT,W?FUCK /?THN6
EQUAL? WORD,W?SHITHEAD,W?PISS,W?SUCK /?THN6
EQUAL? WORD,W?BASTARD,W?SCREW,W?FUCKING /?THN6
EQUAL? WORD,W?DAMNED,W?PEE,W?COCKSUCKER /?THN6
EQUAL? WORD,W?FUCKED,W?CUNT,W?ASSHOLE /?THN6
EQUAL? WORD,W?BITCH \FALSE
?THN6: CALL PICK-ONE,OFFENDED
PRINT STACK
CRLF
RTRUE
.FUNCT VERB-DIR-ONLY?,WRD,?ORTMP
CALL WT?,WRD,128
ZERO? STACK \FALSE
CALL WT?,WRD,32
ZERO? STACK \FALSE
CALL WT?,WRD,16
POP '?ORTMP
ZERO? ?ORTMP /?ORP6
RETURN ?ORTMP
?ORP6: CALL WT?,WRD,64
RSTACK
.FUNCT STUFF,DEST,SRC,MAX=29,PTR=P-LEXSTART,CTR=1,BPTR
GETB SRC,0
PUTB DEST,0,STACK
GETB SRC,1
PUTB DEST,1,STACK
?PRG1: GET SRC,PTR
PUT DEST,PTR,STACK
MUL PTR,2
ADD STACK,2 >BPTR
GETB SRC,BPTR
PUTB DEST,BPTR,STACK
MUL PTR,2
ADD STACK,3 >BPTR
GETB SRC,BPTR
PUTB DEST,BPTR,STACK
ADD PTR,P-LEXELEN >PTR
IGRTR? 'CTR,MAX \?PRG1
RTRUE
.FUNCT INBUF-STUFF,DEST,SRC,CNT=-1
?PRG1: IGRTR? 'CNT,59 /TRUE
GETB SRC,CNT
PUTB DEST,CNT,STACK
JUMP ?PRG1
.FUNCT INBUF-ADD,LEN,BEG,SLOT,DBEG,CTR=0,TMP,?TMP1
GET OOPS-TABLE,O-END >TMP
ZERO? TMP /?ELS3
SET 'DBEG,TMP
JUMP ?CND1
?ELS3: GET OOPS-TABLE,O-LENGTH >TMP
GETB AGAIN-LEXV,TMP >?TMP1
ADD TMP,1
GETB AGAIN-LEXV,STACK
ADD ?TMP1,STACK >DBEG
?CND1: ADD DBEG,LEN
PUT OOPS-TABLE,O-END,STACK
?PRG6: ADD DBEG,CTR >?TMP1
ADD BEG,CTR
GETB P-INBUF,STACK
PUTB OOPS-INBUF,?TMP1,STACK
INC 'CTR
EQUAL? CTR,LEN \?PRG6
PUTB AGAIN-LEXV,SLOT,DBEG
SUB SLOT,1
PUTB AGAIN-LEXV,STACK,LEN
RTRUE
.FUNCT NUMBER?,PTR,CNT,BPTR,CHR,SUM=0,TIM=0,EXC=0,NOHYP?=0,?TMP1
MUL PTR,2
ADD P-LEXV,STACK
GETB STACK,2 >CNT
EQUAL? CNT,7 \?CND1
SET 'NOHYP?,TRUE-VALUE
?CND1: MUL PTR,2
ADD P-LEXV,STACK
GETB STACK,3 >BPTR
?PRG4: DLESS? 'CNT,0 /?REP5
GETB P-INBUF,BPTR >CHR
ZERO? NOHYP? /?CND11
EQUAL? CNT,3 \?CND11
EQUAL? CHR,45 /?CND11
ZERO? TIM \FALSE
SET 'EXC,SUM
SET 'SUM,0
?CND11: EQUAL? CHR,58 \?ELS22
ZERO? EXC \FALSE
SET 'TIM,SUM
SET 'SUM,0
JUMP ?CND20
?ELS22: EQUAL? CHR,45 \?ELS28
SET 'NOHYP?,FALSE-VALUE
ZERO? TIM \FALSE
SET 'EXC,SUM
SET 'SUM,0
JUMP ?CND20
?ELS28: GRTR? SUM,9999 \?ELS34
SET 'SUM,10000
JUMP ?REP5
?ELS34: LESS? CHR,58 \FALSE
GRTR? CHR,47 \FALSE
MUL SUM,10 >?TMP1
SUB CHR,48
ADD ?TMP1,STACK >SUM
?CND20: INC 'BPTR
JUMP ?PRG4
?REP5: PUT P-LEXV,PTR,W?INTNUM
PUT AGAIN-LEXV,PTR,W?INTNUM
ZERO? EXC /?ELS43
SET 'P-EXCHANGE,EXC
JUMP ?CND41
?ELS43: ZERO? TIM /?ELS46
SET 'P-EXCHANGE,0
GRTR? TIM,23 /FALSE
GRTR? TIM,19 /?CND48
GRTR? TIM,12 /FALSE
GRTR? TIM,7 /?CND48
ADD 12,TIM >TIM
?CND48: MUL TIM,60
ADD SUM,STACK >SUM
JUMP ?CND41
?ELS46: SET 'P-EXCHANGE,0
?CND41: SET 'P-NUMBER,SUM
RETURN W?INTNUM
.FUNCT ORPHAN-MERGE,CNT=-1,TEMP,VERB,BEG,END,ADJ=0,WRD,?TMP1
SET 'P-OFLAG,FALSE-VALUE
GET P-ITBL,P-VERBN
GET STACK,0 >WRD
CALL WT?,WRD,64,1 >?TMP1
GET P-OTBL,P-VERB
EQUAL? ?TMP1,STACK /?THN4
CALL WT?,WRD,32
ZERO? STACK /?ELS3
?THN4: SET 'ADJ,TRUE-VALUE
JUMP ?CND1
?ELS3: CALL WT?,WRD,128,0
ZERO? STACK /?CND1
ZERO? P-NCN \?CND1
PUT P-ITBL,P-VERB,0
PUT P-ITBL,P-VERBN,0
ADD P-LEXV,2
PUT P-ITBL,P-NC1,STACK
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
SET 'P-NCN,1
?CND1: GET P-ITBL,P-VERB >VERB
ZERO? VERB /?ELS12
ZERO? ADJ \?ELS12
GET P-OTBL,P-VERB
EQUAL? VERB,STACK \FALSE
?ELS12: EQUAL? P-NCN,2 /FALSE
GET P-OTBL,P-NC1
EQUAL? STACK,1 \?ELS18
GET P-ITBL,P-PREP1 >TEMP
ZERO? TEMP /?THN22
GET P-OTBL,P-PREP1
EQUAL? TEMP,STACK \FALSE
?THN22: ZERO? ADJ /?ELS26
ADD P-LEXV,2
PUT P-OTBL,P-NC1,STACK
GET P-ITBL,P-NC1L
ZERO? STACK \?CND28
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
?CND28: ZERO? P-NCN \?CND24
SET 'P-NCN,1
JUMP ?CND24
?ELS26: GET P-ITBL,P-NC1
PUT P-OTBL,P-NC1,STACK
?CND24: GET P-ITBL,P-NC1L
PUT P-OTBL,P-NC1L,STACK
JUMP ?CND10
?ELS18: GET P-OTBL,P-NC2
EQUAL? STACK,1 \?ELS39
GET P-ITBL,P-PREP1 >TEMP
ZERO? TEMP /?THN43
GET P-OTBL,P-PREP2
EQUAL? TEMP,STACK \FALSE
?THN43: ZERO? ADJ /?CND45
ADD P-LEXV,2
PUT P-ITBL,P-NC1,STACK
GET P-ITBL,P-NC1L
ZERO? STACK \?CND45
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
?CND45: GET P-ITBL,P-NC1
PUT P-OTBL,P-NC2,STACK
GET P-ITBL,P-NC1L
PUT P-OTBL,P-NC2L,STACK
SET 'P-NCN,2
JUMP ?CND10
?ELS39: ZERO? P-ACLAUSE /?CND10
EQUAL? P-NCN,1 /?ELS59
ZERO? ADJ \?ELS59
SET 'P-ACLAUSE,FALSE-VALUE
RFALSE
?ELS59: GET P-ITBL,P-NC1 >BEG
ZERO? ADJ /?CND64
ADD P-LEXV,2 >BEG
SET 'ADJ,FALSE-VALUE
?CND64: GET P-ITBL,P-NC1L >END
?PRG68: GET BEG,0 >WRD
EQUAL? BEG,END \?ELS72
ZERO? ADJ /?ELS75
CALL CLAUSE-WIN,ADJ
JUMP ?CND10
?ELS75: SET 'P-ACLAUSE,FALSE-VALUE
RFALSE
?ELS72: EQUAL? WRD,W?ALL,W?ONE /?THN81
GETB WRD,P-PSOFF
BTST STACK,32 \?ELS80
CALL ADJ-CHECK,WRD,ADJ
ZERO? STACK /?ELS80
?THN81: SET 'ADJ,WRD
JUMP ?CND70
?ELS80: EQUAL? WRD,W?ONE \?ELS86
CALL CLAUSE-WIN,ADJ
JUMP ?CND10
?ELS86: GETB WRD,P-PSOFF
BTST STACK,128 \?CND70
ADD BEG,P-WORDLEN
EQUAL? STACK,END \?CND70
EQUAL? WRD,P-ANAM \?ELS93
CALL CLAUSE-WIN,ADJ
JUMP ?CND10
?ELS93: CALL CLAUSE-WIN
JUMP ?CND10
?CND70: ADD BEG,P-WORDLEN >BEG
ZERO? END \?PRG68
SET 'END,BEG
SET 'P-NCN,1
SUB BEG,4
PUT P-ITBL,P-NC1,STACK
PUT P-ITBL,P-NC1L,BEG
JUMP ?PRG68
?CND10: GET P-OVTBL,0
PUT P-VTBL,0,STACK
GETB P-OVTBL,2
PUTB P-VTBL,2,STACK
GETB P-OVTBL,3
PUTB P-VTBL,3,STACK