-
Notifications
You must be signed in to change notification settings - Fork 38
/
actions.zap
1945 lines (1734 loc) · 52.7 KB
/
actions.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 SWORD-FCN
ZERO? SWORD-IN-STONE? /?ELS5
EQUAL? PRSA,V?MOVE,V?TAKE \FALSE
RANDOM 100
GRTR? 10,STACK \?ELS16
PRINTR "Who do you think you are? Arthur?"
?ELS16: PRINTR "The sword is deeply imbedded within the rock. You can't even begin to budge it."
?ELS5: EQUAL? PRSA,V?TAKE \FALSE
EQUAL? WINNER,ADVENTURER \FALSE
CALL QUEUE,I-SWORD,-1
PUT STACK,0,1
RFALSE
.FUNCT LANTERN
EQUAL? PRSA,V?THROW \?ELS5
PRINTI "The lamp has smashed into the floor, and the light has gone out."
CRLF
CALL INT,I-LANTERN
PUT STACK,0,0
REMOVE LAMP
SET 'CURRENT-LAMP,BROKEN-LAMP
MOVE BROKEN-LAMP,HERE
RTRUE
?ELS5: EQUAL? PRSA,V?LAMP-ON \?ELS9
FSET? LAMP,LIGHTBIT /?ELS14
PRINTR "A burned-out lamp won't light."
?ELS14: CALL INT,I-LANTERN
PUT STACK,0,1
RFALSE
?ELS9: EQUAL? PRSA,V?LAMP-OFF \?ELS20
FSET? LAMP,LIGHTBIT /?ELS25
PRINTR "The lamp has already burned out."
?ELS25: CALL INT,I-LANTERN
PUT STACK,0,0
RFALSE
?ELS20: EQUAL? PRSA,V?EXAMINE \FALSE
FSET? LAMP,LIGHTBIT /?ELS34
PRINTI "The lamp has burned out."
JUMP ?CND32
?ELS34: FSET? LAMP,ONBIT \?ELS38
PRINTI "The lamp is on."
JUMP ?CND32
?ELS38: PRINTI "The lamp is turned off."
?CND32: CRLF
RTRUE
.FUNCT I-LANTERN,TICK,TBL
VALUE 'LAMP-TABLE >TBL
GET TBL,0 >TICK
CALL QUEUE,I-LANTERN,TICK
PUT STACK,0,1
CALL LIGHT-INT,LAMP,TBL,TICK
ZERO? TICK /TRUE
ADD TBL,4 >LAMP-TABLE
RTRUE
.FUNCT LIGHT-INT,OBJ,TBL,TICK
ZERO? TICK \?CND1
FCLEAR OBJ,LIGHTBIT
FCLEAR OBJ,ONBIT
?CND1: CALL HELD?,OBJ
ZERO? STACK \?THN9
IN? OBJ,HERE \FALSE
?THN9: ZERO? TICK \?ELS15
PRINTI "You'd better have more light than from the "
PRINTD OBJ
PRINTR "."
?ELS15: GET TBL,1
PRINT STACK
CRLF
RTRUE
.FUNCT CRETIN
EQUAL? PRSA,V?GIVE \?ELS5
CALL PERFORM,V?TAKE,PRSO
RSTACK
?ELS5: EQUAL? PRSA,V?EAT \?ELS7
PRINTR "Auto-cannibalism is not the answer."
?ELS7: EQUAL? PRSA,V?MUNG,V?KILL \?ELS11
CALL JIGS-UP,STR?65
RSTACK
?ELS11: EQUAL? PRSA,V?TAKE \?ELS13
PRINTR "How romantic!"
?ELS13: EQUAL? PRSA,V?DISEMBARK \?ELS17
PRINTR "You'll have to do that on your own."
?ELS17: EQUAL? PRSA,V?EXAMINE \?ELS21
PRINTR "That's difficult unless your eyes are prehensile."
?ELS21: EQUAL? PRSA,V?MAKE \FALSE
PRINTR "Only you can do that."
.FUNCT CHASM-FCN
EQUAL? PRSA,V?LEAP /?THN6
EQUAL? PRSA,V?PUT \?ELS5
EQUAL? PRSO,ME \?ELS5
?THN6: PRINTR "You look before leaping and realize you would never survive."
?ELS5: EQUAL? PRSA,V?CROSS \?ELS13
PRINTR "You'll have to find a bridge."
?ELS13: EQUAL? PRSA,V?PUT \FALSE
EQUAL? PRSI,PSEUDO-OBJECT \FALSE
PRINTI "The "
PRINTD PRSO
PRINTI " drops out of sight into the chasm."
CRLF
REMOVE PRSO
RTRUE
.FUNCT PATH-OBJECT
EQUAL? PRSA,V?FOLLOW,V?TAKE \?ELS5
PRINTR "You must specify a direction to go."
?ELS5: EQUAL? PRSA,V?FIND \FALSE
PRINTR "I can't help you there...."
.FUNCT TUNNEL-OBJECT
EQUAL? PRSA,V?THROUGH \?ELS5
GETP HERE,P?IN
ZERO? STACK /?ELS5
CALL DO-WALK,P?IN
RTRUE
?ELS5: CALL PATH-OBJECT
RSTACK
.FUNCT GROUND-FCN
EQUAL? PRSA,V?PUT \?ELS5
EQUAL? PRSI,GROUND \?ELS5
CALL PERFORM,V?DROP,PRSO
RTRUE
?ELS5: EQUAL? PRSA,V?DIG \FALSE
PRINTR "The ground is too hard for digging here."
.FUNCT GRUE-FUNCTION
EQUAL? PRSA,V?EXAMINE \?ELS5
PRINTR "The grue is a sinister, lurking presence in the dark places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale."
?ELS5: EQUAL? PRSA,V?FIND \?ELS9
PRINTR "There is no grue here, but I'm sure there is at least one lurking in the darkness nearby. I wouldn't let my light go out if I were you!"
?ELS9: EQUAL? PRSA,V?LISTEN \FALSE
PRINTR "It makes no sound but is always lurking in the darkness nearby."
.FUNCT CPEXIT,FX,NFX,?TMP1
SET 'CP-MOVED,FALSE-VALUE
EQUAL? PRSO,P?UP \?ELS5
EQUAL? CPHERE,1 \?ELS10
GET CPTABLE,2
EQUAL? STACK,-2 \?ELS15
PRINTI "With the help of the ladder, you exit the puzzle."
CRLF
RETURN CP-ANTE
?ELS15: PRINTI "The exit is too far above your head."
CRLF
RFALSE
?ELS10: PRINTI "There is no way up."
CRLF
RFALSE
?ELS5: EQUAL? CPHERE,33 \?ELS27
EQUAL? PRSO,P?WEST \?ELS27
ZERO? CP-FLAG /?ELS27
FCLEAR CP,TOUCHBIT
RETURN CP-OUT
?ELS27: EQUAL? PRSO,P?DOWN \?ELS31
PRINTI "There's no way down here."
CRLF
RFALSE
?ELS31: EQUAL? CPHERE,33 \?ELS35
EQUAL? PRSO,P?WEST \?ELS35
PRINTI "The metal door bars the way."
CRLF
RFALSE
?ELS35: CALL LKP,PRSO,CPEXITS >FX
ADD FX,CPHERE >NFX
GRTR? NFX,36 /?THN45
LESS? NFX,0 /?THN45
CALL ILLCP,CPHERE,FX
ZERO? STACK /?ELS44
?THN45: PRINTI "There is a wall there."
CRLF
RFALSE
?ELS44: LESS? FX,0 \?ELS55
SUB 0,FX
JUMP ?CND51
?ELS55: PUSH FX
?CND51: EQUAL? STACK,1,6 \?ELS50
CALL CPMOVE,FX
RFALSE
?ELS50: GRTR? FX,0 \?ELS59
ADD CPHERE,6
GET CPTABLE,STACK >?TMP1
SUB FX,6
ADD CPHERE,STACK
GET CPTABLE,STACK
EQUAL? 0,?TMP1,STACK \?ELS59
CALL CPMOVE,FX
RFALSE
?ELS59: LESS? FX,0 \?ELS63
SUB CPHERE,6
GET CPTABLE,STACK >?TMP1
ADD CPHERE,6
ADD STACK,FX >STACK
GET CPTABLE,STACK
EQUAL? 0,?TMP1,STACK \?ELS63
CALL CPMOVE,FX
RFALSE
?ELS63: PRINTI "There is a wall there."
CRLF
RFALSE
.FUNCT ILLCP,ONE,TWO
MOD ONE,6
ZERO? STACK \?ELS5
EQUAL? TWO,MINUS-FIVE,1,7 /TRUE
?ELS5: MOD ONE,6
EQUAL? STACK,1 \?ELS9
EQUAL? TWO,MINUS-SEVEN,MINUS-ONE,5 /TRUE
?ELS9: LESS? ONE,7 \?ELS13
LESS? TWO,MINUS-FOUR /TRUE
?ELS13: GRTR? ONE,30 \FALSE
GRTR? TWO,4 /TRUE
RFALSE
.FUNCT CPMOVE,FX
ADD CPHERE,FX >FX
GET CPTABLE,FX
ZERO? STACK \?ELS5
CALL CPGOTO,FX
RSTACK
?ELS5: PRINTR "There is a wall there."
.FUNCT CPENTER
EQUAL? YEAR,YEAR-PRESENT \?THN6
ZERO? CPBLOCK-FLAG /?ELS5
?THN6: PRINTI "The hole is blocked by sandstone."
CRLF
RFALSE
?ELS5: SET 'CPHERE,1
RETURN CP
.FUNCT CPANT-ROOM,RARG
EQUAL? RARG,M-LOOK \FALSE
PRINTI "This is a small square room, in the middle of which is a perfectly round hole"
ZERO? CPBLOCK-FLAG \?THN13
EQUAL? YEAR,YEAR-PRESENT /?ELS12
?THN13: PRINTR " which is blocked by smooth sandstone."
?ELS12: PRINTR " through which you can discern the floor some ten feet below. The place under the hole is dark, but it appears to be completely enclosed in rock. In any event, it doesn't seem likely that you could climb back up. Exits are west and, up a few steps, north."
.FUNCT CPLADDER-OBJECT,FLG=0
SUB CPHERE,1
GET CPTABLE,STACK
EQUAL? STACK,-3 /?THN6
ADD CPHERE,1
GET CPTABLE,STACK
EQUAL? STACK,-2 \?ELS5
SET 'FLG,TRUE-VALUE
ZERO? FLG /?ELS5
?THN6: EQUAL? PRSA,V?CLIMB-FOO,V?CLIMB-UP \?ELS14
ZERO? FLG /?ELS19
EQUAL? CPHERE,1 \?ELS19
SET 'CPSOLVE-FLAG,TRUE-VALUE
CALL GOTO,CP-ANTE
RSTACK
?ELS19: PRINTR "You hit your head on the ceiling and fall off the ladder."
?ELS14: PRINTR "Come, come!"
?ELS5: PRINTR "I can't see any ladder here."
.FUNCT CPWALL-OBJECT,WL,NWL,NXT,NNXT,CNT,TOP,SNAP=0
EQUAL? PRSA,V?MOVE \?ELS5
PRINTR "You can't grab the wall to pull it."
?ELS5: EQUAL? PRSA,V?PUSH \FALSE
CALL CPNEXT,CPHERE,PRSO >NXT
ZERO? NXT \?CND10
PRINTR "The wall doesn't budge."
?CND10: GET CPTABLE,NXT >WL
ZERO? WL \?ELS19
PRINTR "There is only a passage in that direction."
?ELS19: EQUAL? WL,1 \?ELS23
PRINTR "The wall doesn't budge."
?ELS23: CALL CPNEXT,NXT,PRSO >NNXT
ZERO? NNXT \?ELS27
PRINTR "The wall barely gives."
?ELS27: GET CPTABLE,NNXT >NWL
ZERO? NWL /?ELS31
PRINTR "The wall barely gives."
?ELS31: PRINTI "The wall slides forward and you follow it"
ZERO? CPPUSH-FLAG /?ELS40
PRINTI " to this position:"
CRLF
JUMP ?CND38
?ELS40: INC 'SCORE
PRINTI "....
The architecture of this region is getting complex, so that further descriptions will be diagrams of the immediate vicinity in a 3x3 grid. The walls here are rock, but of two different types - sandstone and marble. The following notations will be used:
"
GET 0,8
BOR STACK,2
PUT 0,8,STACK
PRINTI "
.. = your position (middle of grid)
MM = marble wall
SS = sandstone wall
?? = unknown (blocked by walls)
"
GET 0,8
BAND STACK,-3
PUT 0,8,STACK
?CND38: SET 'CPPUSH-FLAG,TRUE-VALUE
PUT CPTABLE,NXT,0
PUT CPTABLE,NNXT,WL
ZERO? NNXT /?CND50
SUB NNXT,1
MUL 8,STACK >TOP
GET CPOBJS,TOP >CNT
?PRG53: ZERO? CNT \?ELS57
JUMP ?CND50
?ELS57: INC 'TOP
GET CPOBJS,TOP
MOVE STACK,CP-OUT
ZERO? SNAP \?CND60
SET 'SNAP,TRUE-VALUE
PRINTI "You hear a soft ""snap"" from behind the wall you were pushing."
CRLF
?CND60: DEC 'CNT
JUMP ?PRG53
?CND50: EQUAL? NNXT,1 \?CND65
SET 'CPBLOCK-FLAG,TRUE-VALUE
?CND65: CALL CPGOTO,NXT
RSTACK
.FUNCT CPGOTO,FX,F,X,CNT,TOP
SET 'CP-MOVED,TRUE-VALUE
FCLEAR HERE,TOUCHBIT
SUB CPHERE,1
MUL 8,STACK >TOP
ADD TOP,1 >CNT
FIRST? CP >F /?KLU22
?KLU22:
?PRG1: NEXT? F >X /?KLU23
?KLU23: ZERO? F \?ELS5
JUMP ?REP2
?ELS5: EQUAL? F,ADVENTURER \?ELS7
JUMP ?CND3
?ELS7: PUT CPOBJS,CNT,F
REMOVE F
INC 'CNT
?CND3: ZERO? X \?ELS12
JUMP ?REP2
?ELS12: SET 'F,X
JUMP ?PRG1
?REP2: SUB CNT,TOP
SUB STACK,1
PUT CPOBJS,TOP,STACK
SET 'CPHERE,FX
SUB CPHERE,1
MUL 8,STACK >TOP
GET CPOBJS,TOP >CNT
?PRG15: ZERO? CNT \?ELS19
JUMP ?REP16
?ELS19: INC 'TOP
GET CPOBJS,TOP
MOVE STACK,CP
DEC 'CNT
JUMP ?PRG15
?REP16: CALL PERFORM,V?LOOK
RTRUE
.FUNCT CPNEXT,RM,OBJ,FX
CALL LKP,OBJ,CPWALLS >FX
CALL ILLCP,RM,FX
ZERO? STACK \FALSE
ADD RM,FX
RSTACK
.FUNCT CPDOOR-F
EQUAL? HERE,CP \?ELS5
EQUAL? CPHERE,33 /?ELS5
PRINTR "I can't see any steel door here."
?ELS5: EQUAL? PRSA,V?OPEN \?ELS11
ZERO? CP-FLAG /?ELS16
PRINTR "The steel door has already opened."
?ELS16: PRINTR "You can't force it open."
?ELS11: EQUAL? PRSA,V?CLOSE \?ELS25
ZERO? CP-FLAG /?ELS30
PRINTR "There doesn't seem to be any way to close it."
?ELS30: PRINTR "Do you think it isn't already?"
?ELS25: EQUAL? PRSA,V?MUNG \?ELS39
PRINTR "The door is, to a first approximation, indestructible."
?ELS39: EQUAL? PRSA,V?KNOCK \FALSE
PRINTR "Besides a great amount of reverberation, nothing happens."
.FUNCT CP-ROOM,RARG
EQUAL? RARG,M-ENTER \?ELS5
EQUAL? PRSO,P?DOWN \?ELS10
PUSH 1
JUMP ?CND6
?ELS10: PUSH 33
?CND6: SET 'CPHERE,STACK
RETURN CPHERE
?ELS5: EQUAL? RARG,M-LOOK \FALSE
ZERO? CPPUSH-FLAG /?ELS19
CALL CPWHERE
RSTACK
?ELS19: PRINTR "You are in a small square room bounded to the north and west with marble walls and to the east and south with sandstone walls."
.FUNCT CPNS,NUM
GRTR? NUM,36 /TRUE
LESS? NUM,1 /TRUE
GET CPTABLE,NUM
RSTACK
.FUNCT CPEW,NUM,FOO
MOD NUM,6
EQUAL? STACK,FOO /TRUE
GET CPTABLE,NUM
RSTACK
.FUNCT CPWHERE,N,S,E,W
ADD CPHERE,-6
CALL CPNS,STACK >N
ADD CPHERE,6
CALL CPNS,STACK >S
ADD CPHERE,1
CALL CPEW,STACK,1 >E
ADD CPHERE,-1
CALL CPEW,STACK,0 >W
GET 0,8
BOR STACK,2
PUT 0,8,STACK
PRINTI " +"
CALL CP-CORNER,MINUS-SEVEN,N,W
PRINTI " "
CALL CP-ORTHO,N
PRINTI " "
CALL CP-CORNER,MINUS-FIVE,N,E
PRINTI "+"
CRLF
PRINTI "West +"
CALL CP-ORTHO,W
PRINTI " .. "
CALL CP-ORTHO,E
PRINTI "+ East"
CRLF
PRINTI " +"
CALL CP-CORNER,5,S,W
PRINTI " "
CALL CP-ORTHO,S
PRINTI " "
CALL CP-CORNER,7,S,E
PRINTI "+"
CRLF
GET 0,8
BAND STACK,-3
PUT 0,8,STACK
EQUAL? CPHERE,1 \?ELS25
PRINTI "In the ceiling above you is a large circular opening."
CRLF
JUMP ?CND23
?ELS25: EQUAL? CPHERE,22 \?ELS29
PRINTI "The center of the floor here is noticeably depressed."
CRLF
JUMP ?CND23
?ELS29: EQUAL? CPHERE,33 \?CND23
PRINTI "In the center of the west wall is a steel door which is "
ZERO? CP-FLAG /?ELS38
PRINTI "open"
JUMP ?CND36
?ELS38: PRINTI "closed"
?CND36: PRINTI ". On one side of the door is a narrow slot."
CRLF
?CND23: EQUAL? E,-2 \?CND48
PRINTI "There is a ladder here, firmly attached to the east wall."
CRLF
?CND48: EQUAL? W,-3 \FALSE
PRINTR "There is a ladder here, firmly attached to the west wall."
.FUNCT CP-ORTHO,CONTENTS
ZERO? CONTENTS \?ELS5
PRINTI " "
RTRUE
?ELS5: EQUAL? CONTENTS,1 \?ELS9
PRINTI "MM"
RTRUE
?ELS9: PRINTI "SS"
RTRUE
.FUNCT CP-CORNER,DIR,COL,ROW,LOCN
ADD CPHERE,DIR >LOCN
ZERO? COL /?ELS5
ZERO? ROW /?ELS5
PRINTI "??"
RTRUE
?ELS5: CALL ILLCP,CPHERE,DIR
ZERO? STACK /?ELS11
PRINTI "MM"
RTRUE
?ELS11: LESS? LOCN,1 /?THN21
GRTR? LOCN,36 \?ELS20
?THN21: PUSH 1
JUMP ?CND16
?ELS20: GET CPTABLE,LOCN
?CND16: SET 'COL,STACK
ZERO? COL \?ELS15
PRINTI " "
RTRUE
?ELS15: EQUAL? COL,1 \?ELS28
PRINTI "MM"
RTRUE
?ELS28: PRINTI "SS"
RTRUE
.FUNCT CP-SLOT-FCN
EQUAL? PRSA,V?PUT \FALSE
GETP PRSO,P?SIZE
GRTR? STACK,10 \?CND6
PRINTR "It doesn't fit."
?CND6: REMOVE PRSO
EQUAL? PRSO,LORE-BOOK \?ELS15
SET 'CP-FLAG,TRUE-VALUE
PRINTR "The book drops easily into the slot and vanishes. The metal door slides open, revealing a passageway to the west, as a previously unseen sign flashes:
""Royal Puzzle Exit Fee Paid
Item Confiscated"""
?ELS15: FSET? PRSO,VICBIT /?THN20
FSET? PRSO,VILLAIN \?ELS19
?THN20: CALL PICK-ONE,YUKS
PRINT STACK
CRLF
RTRUE
?ELS19: PRINTI "The item vanishes into the slot. A moment later, a previously unseen sign flashes ""Garbage In, Garbage Out"" and spews the "
PRINTD PRSO
PRINTR " (now atomized) through the slot."
.FUNCT CPOUT-ROOM,RARG
EQUAL? RARG,M-LOOK \FALSE
PRINTI "You are in a narrow room, lit from above. A flight of steps leads up toward the north, and a "
ZERO? CP-FLAG /?ELS10
PRINTI "passage"
JUMP ?CND8
?ELS10: PRINTI "metal door"
?CND8: PRINTR " leads to the east."
.FUNCT MRGO,TORM
EQUAL? PRSO,P?NORTH,P?NW,P?NE \?ELS3
CALL LKP,HERE,R-NORTHS >TORM
JUMP ?CND1
?ELS3: CALL LKP,HERE,R-SOUTHS >TORM
?CND1: EQUAL? PRSO,P?NORTH,P?SOUTH \?ELS10
EQUAL? MLOC,TORM \?ELS15
MOD MDIR,180
ZERO? STACK \?ELS20
PRINTI "There is a wooden wall blocking your way."
CRLF
RFALSE
?ELS20: CALL MIRIN,FALSE-VALUE
ZERO? STACK /?ELS24
RETURN IN-MIRROR
?ELS24: CALL MIRBLOCK
RFALSE
?ELS15: RETURN TORM
?ELS10: EQUAL? MLOC,TORM \?ELS30
MOD MDIR,180
ZERO? STACK \?ELS35
CALL GO-E-W,TORM
RSTACK
?ELS35: CALL MIRBLOCK
RFALSE
?ELS30: RETURN TORM
.FUNCT MIRBLOCK,MD
SET 'MD,MDIR
EQUAL? PRSO,P?SOUTH \?CND1
ADD MDIR,180
MOD STACK,360 >MD
?CND1: EQUAL? MD,270 \?ELS12
ZERO? MR1-FLAG /?THN9
?ELS12: EQUAL? MD,90 \?ELS8
ZERO? MR2-FLAG \?ELS8
?THN9: PRINTR "There is a large broken mirror blocking your way."
?ELS8: PRINTR "There is a large mirror blocking your way."
.FUNCT GO-E-W,RM
EQUAL? PRSO,P?NE,P?SE \?ELS5
CALL LKP,RM,R-EASTS
RSTACK
?ELS5: CALL LKP,RM,R-WESTS
RSTACK
.FUNCT EWTELL,RM,EAST?=0,M1?=0,MWIN
EQUAL? RM,MRAE,MRBE,MRCE /?THN4
EQUAL? RM,MRGE,MRCE \?CND1
?THN4: SET 'EAST?,TRUE-VALUE
?CND1: ZERO? EAST? /?ELS13
PUSH 0
JUMP ?CND9
?ELS13: PUSH 180
?CND9: ADD MDIR,STACK
EQUAL? STACK,180 \?CND6
SET 'M1?,TRUE-VALUE
?CND6: ZERO? M1? /?ELS19
SET 'MWIN,MR1-FLAG
JUMP ?CND17
?ELS19: SET 'MWIN,MR2-FLAG
?CND17: PRINTI "You are in a narrow room, whose "
ZERO? EAST? /?ELS29
PUSH STR?66
JUMP ?CND25
?ELS29: PUSH STR?67
?CND25: PRINT STACK
PRINTI " wall is a large "
ZERO? MWIN /?ELS37
PUSH STR?68
JUMP ?CND33
?ELS37: PUSH STR?69
?CND33: PRINT STACK
CRLF
ZERO? M1? /?CND41
ZERO? MIRROR-OPEN-FLAG /?CND41
ZERO? MWIN /?ELS52
PUSH STR?70
JUMP ?CND48
?ELS52: PUSH STR?71
?CND48: PRINT STACK
CRLF
?CND41: PRINTR "The opposite wall is solid rock."
.FUNCT MRDEW,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL EWTELL,HERE
SET 'GUARDIANS-SEEN,TRUE-VALUE
PRINTI "Somewhat to the south"
PRINT GUARDSTR
CRLF
RTRUE
.FUNCT MRCEW,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL EWTELL,HERE
SET 'GUARDIANS-SEEN,TRUE-VALUE
PRINTI "Somewhat to the north"
PRINT GUARDSTR
CRLF
RTRUE
.FUNCT MRBEW,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL EWTELL,HERE
PRINTR "To the north and south are large hallways."
.FUNCT MRAEW,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL EWTELL,HERE
PRINTR "To the north is a large hallway."
.FUNCT LOOK-TO,RMN,RMS,NORTH?=0,NTELL=0,STELL=0,MIR?,M1?=0,DIR
EQUAL? HERE,MREYE,FRONT-DOOR /?CND1
PRINTI "This is a part of the long hallway. The east and west walls are dressed stone. In the center of the hall is a shallow stone channel. In the center of the room the channel widens into a large hole around which is engraved a compass rose."
CRLF
?CND1: EQUAL? HERE,MRG \?ELS8
SET 'GUARDIANS-SEEN,TRUE-VALUE
PRINTI "On either side of you are identical stone statues holding bludgeons. They appear ready to strike, though, for the moment, they remain impassive."
CRLF
JUMP ?CND6
?ELS8: EQUAL? HERE,MRC \?ELS12
SET 'GUARDIANS-SEEN,TRUE-VALUE
PRINTI "Somewhat to the north"
PRINT GUARDSTR
CRLF
SET 'NTELL,TRUE-VALUE
JUMP ?CND6
?ELS12: EQUAL? HERE,FRONT-DOOR \?ELS16
PRINTI "You are in a north-south hallway which ends, to the north, at a large wooden door."
CRLF
SET 'NTELL,TRUE-VALUE
JUMP ?CND6
?ELS16: EQUAL? HERE,MRD \?ELS20
SET 'GUARDIANS-SEEN,TRUE-VALUE
PRINTI "Somewhat to the south"
PRINT GUARDSTR
CRLF
SET 'STELL,TRUE-VALUE
JUMP ?CND6
?ELS20: EQUAL? HERE,MRA \?CND6
PRINTI "The hallway continues to the south."
CRLF
SET 'STELL,TRUE-VALUE
?CND6: EQUAL? MLOC,RMN,RMS \?CND27
EQUAL? MLOC,RMN \?ELS32
SET 'NORTH?,TRUE-VALUE
SET 'NTELL,TRUE-VALUE
SET 'DIR,STR?73
JUMP ?CND30
?ELS32: SET 'STELL,TRUE-VALUE
SET 'DIR,STR?74
?CND30: ZERO? NORTH? /?ELS39
GRTR? MDIR,180 \?ELS39
LESS? MDIR,359 \?ELS39
SET 'M1?,TRUE-VALUE
PUSH MR1-FLAG
JUMP ?CND35
?ELS39: ZERO? NORTH? \?ELS43
GRTR? MDIR,0 \?ELS43
LESS? MDIR,179 \?ELS43
SET 'M1?,TRUE-VALUE
PUSH MR1-FLAG
JUMP ?CND35
?ELS43: PUSH MR2-FLAG
?CND35: SET 'MIR?,STACK
MOD MDIR,180
ZERO? STACK \?ELS50
PRINTI "The "
PRINT DIR
PRINTI "th side of the room is divided by a wooden wall into small hallways to the "
PRINT DIR
PRINTI "theast and "
PRINT DIR
PRINTI "thwest."
CRLF
JUMP ?CND27
?ELS50: ZERO? MIR? /?ELS65
PUSH STR?75
JUMP ?CND61
?ELS65: PUSH STR?76
?CND61: PRINT STACK
PRINT DIR
PRINTI "th side of the hallway."
CRLF
ZERO? M1? /?CND48
ZERO? MIRROR-OPEN-FLAG /?CND48
ZERO? MIR? /?ELS80
PUSH STR?70
JUMP ?CND76
?ELS80: PUSH STR?71
?CND76: PRINT STACK
CRLF
?CND48:
?CND27: ZERO? NTELL \?ELS86
ZERO? STELL \?ELS86
PRINTR "The corridor continues north and south."
?ELS86: ZERO? NTELL \?ELS92
PRINTR "The corridor continues north."
?ELS92: ZERO? STELL \TRUE
PRINTR "The corridor continues south."
.FUNCT MRDF,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL LOOK-TO,FRONT-DOOR,MRG
RSTACK
.FUNCT MRCF,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL LOOK-TO,MRG,MRB
RSTACK
.FUNCT MRBF,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL LOOK-TO,MRC,MRA
RSTACK
.FUNCT MRAF,RARG=0
EQUAL? RARG,M-LOOK \FALSE
CALL LOOK-TO,MRB,FALSE-VALUE
RSTACK
.FUNCT EG-INFESTED?,R
EQUAL? MLOC,MRG \?ELS5
EQUAL? R,IN-MIRROR /?THN1
?ELS5: EQUAL? R,MRGE,MRG,MRGW \FALSE
PUSH 1
?THN1: RSTACK
.FUNCT GUARDIANS,RARG=0
EQUAL? RARG,M-LOOK \?ELS5
EQUAL? HERE,MRG \?ELS10
CALL LOOK-TO,MRD,MRC
RSTACK
?ELS10: CALL EWTELL,HERE
PRINTR "To the east and west are the Guardians of Zork, in perfect symmetry. From here, it's hard to tell which of the two is a reflection!"
?ELS5: EQUAL? RARG,M-ENTER \?ELS16
ZERO? INVIS \?ELS16
CALL JIGS-UP,STR?77
RSTACK
?ELS16: EQUAL? RARG,M-END \FALSE
EQUAL? PRSA,V?EXAMINE \?ELS22
EQUAL? HERE,IN-MIRROR \?ELS27
PRINTR "You can't see them from here."
?ELS27: PRINTR "The guardians are quite impressive. I wouldn't get in their way if I were you!"
?ELS22: EQUAL? PRSA,V?THROW \?ELS35
EQUAL? PRSI,GUARDIAN \?ELS35
PRINTI "The "
PRINTD PRSO
PRINTI " flies within sight of the guardians, who, in perfect unison, destroy it utterly. Satisfied, they resume their posts."
CRLF
REMOVE PRSO
RTRUE
?ELS35: EQUAL? PRSA,V?ATTACK \?ELS41
PRINTR "You aren't close enough to fight them and even if you were, the contest would be a bit one-sided."
?ELS41: EQUAL? PRSA,V?HELLO \FALSE
PRINTR "The statues are impassive."
.FUNCT MIRROR-DIR?,DIR,RM,TBL
EQUAL? DIR,P?NORTH \?ELS5
PUSH R-NORTHS
JUMP ?CND1
?ELS5: PUSH R-SOUTHS
?CND1: SET 'TBL,STACK
GETPT RM,DIR
ZERO? STACK /FALSE
CALL LKP,RM,TBL
EQUAL? MLOC,STACK \FALSE
EQUAL? DIR,P?NORTH \?ELS19
GRTR? MDIR,180 \?ELS19
LESS? MDIR,360 /TRUE
?ELS19: EQUAL? DIR,P?SOUTH \?ELS23
GRTR? MDIR,0 \?ELS23
LESS? MDIR,180 /TRUE
?ELS23: RETURN 2
.FUNCT WOODEN-WALL-F
MOD MDIR,180
ZERO? STACK \?ELS5
CALL MIRROR-DIR?,P?NORTH,HERE
ZERO? STACK \?THN8
CALL MIRROR-DIR?,P?SOUTH,HERE
ZERO? STACK /?ELS5
?THN8: EQUAL? PRSA,V?PUSH \FALSE
PRINTR "The structure won't budge."
?ELS5: PRINTR "I can't see any wooden wall here."
.FUNCT MIRROR-HERE?,RM,TMP
EQUAL? HERE,MRAE,MRAW,MRBE /?THN6
EQUAL? HERE,MRBW,MRCE,MRCW /?THN6
EQUAL? HERE,MRGE,MRGW,MRDE /?THN6
EQUAL? HERE,MRDW \?ELS5
?THN6: EQUAL? RM,MRAE,MRBE,MRCE /?THN18
EQUAL? RM,MRGE,MRDE \?ELS17
?THN18: PUSH 0
JUMP ?CND13
?ELS17: PUSH 180
?CND13: ADD MDIR,STACK
EQUAL? 180,STACK /TRUE
RETURN 2
?ELS5: MOD MDIR,180
ZERO? STACK /FALSE
CALL MIRROR-DIR?,P?NORTH,RM >TMP
ZERO? TMP /?ELS27
RETURN TMP
?ELS27: CALL MIRROR-DIR?,P?SOUTH,RM >TMP
ZERO? TMP /FALSE
RETURN TMP
.FUNCT MIRROR-FUNCTION,MIRROR
CALL MIRROR-HERE?,HERE >MIRROR
ZERO? MIRROR \?ELS5
PRINTR "I can't see any mirror here."
?ELS5: EQUAL? PRSA,V?MOVE,V?OPEN \?ELS9
PRINTR "I don't see a way to open the mirror here."
?ELS9: EQUAL? PRSA,V?LOOK-INSIDE \?ELS13
EQUAL? MIRROR,1 \?ELS22
ZERO? MR1-FLAG \?THN19
?ELS22: ZERO? MR2-FLAG /?ELS18
?THN19: ZERO? INVIS /?ELS27
PRINTR "Amazingly, you have no reflection!"
?ELS27: PRINTR "A disheveled adventurer stares back at you."
?ELS18: PRINTR "You have destroyed the mirror, or have you forgotten?"
?ELS13: EQUAL? PRSA,V?MUNG \?ELS40
EQUAL? MIRROR,1 \?ELS45
ZERO? MR1-FLAG /?ELS50
SET 'MR1-FLAG,FALSE-VALUE
PRINTR "The mirror breaks, revealing a wooden panel behind it. The glistening fragments of mirror quietly sparkle into nonexistance."
?ELS50: PRINTR "The mirror has already been broken."
?ELS45: ZERO? MR2-FLAG /?ELS59
SET 'MR2-FLAG,FALSE-VALUE
PRINTR "The mirror breaks, revealing a wooden panel behind it. The glistening fragments of mirror quietly sparkle into nonexistance."
?ELS59: PRINTR "The mirror has already been broken."
?ELS40: EQUAL? MIRROR,1 \?ELS72
ZERO? MR1-FLAG /?THN69
?ELS72: ZERO? MR2-FLAG \?ELS68
?THN69: PRINTR "There's no mirror left."
?ELS68: EQUAL? PRSA,V?PUSH \FALSE
EQUAL? MIRROR,1 \?ELS83
PUSH STR?78
JUMP ?CND79
?ELS83: PUSH STR?79
?CND79: PRINT STACK
CRLF
RTRUE
.FUNCT PANEL-FUNCTION,MIRROR
CALL MIRROR-HERE?,HERE >MIRROR
ZERO? MIRROR \?ELS5
PRINTR "I can't see any panel here."
?ELS5: EQUAL? PRSA,V?MOVE,V?OPEN \?ELS9
PRINTR "I don't see a way to open the panel here."
?ELS9: EQUAL? PRSA,V?MUNG \?ELS13
EQUAL? MIRROR,1 \?ELS18
ZERO? MR1-FLAG /?ELS23
PRINTR "To break the panel you would have to break the mirror first."
?ELS23: PRINTR "The panel is not that easily destroyed."
?ELS18: ZERO? MR2-FLAG /?ELS32
PRINTR "To break the panel you would have to break the mirror first."
?ELS32: PRINTR "The panel is not that easily destroyed."
?ELS13: EQUAL? PRSA,V?PUSH \FALSE
EQUAL? MIRROR,1 \?ELS48
PUSH STR?80
JUMP ?CND44
?ELS48: PUSH STR?81
?CND44: PRINT STACK
CRLF
RTRUE
.FUNCT MIROUT,DIR,RM
EQUAL? PRSO,P?OUT \?ELS3
SET 'DIR,1
JUMP ?CND1
?ELS3: CALL LKP,PRSO,DIRVEC >DIR
?CND1: ZERO? MIRROR-OPEN-FLAG /?ELS10
EQUAL? DIR,1 /?THN17
ADD MDIR,270
MOD STACK,360
EQUAL? STACK,DIR \FALSE
?THN17: MOD MDIR,180
ZERO? STACK \?ELS23
CALL MIREW
RSTACK
?ELS23: LESS? MDIR,180 /?PRD26
PUSH 0
JUMP ?PRD27
?PRD26: PUSH 1
?PRD27: CALL MIRNS,STACK,TRUE-VALUE
RSTACK
?ELS10: ZERO? WOOD-OPEN-FLAG /?ELS31
EQUAL? DIR,1 /?THN38
ADD MDIR,180
MOD STACK,360
EQUAL? STACK,DIR \?ELS37
?THN38: ZERO? MDIR \?ELS42
SET 'RM,FALSE-VALUE
JUMP ?CND40
?ELS42: SET 'RM,TRUE-VALUE
?CND40: CALL MIRNS,RM,TRUE-VALUE >RM
ZERO? RM /?ELS49
PRINTI "As you leave, the door swings shut."
CRLF
SET 'WOOD-OPEN-FLAG,FALSE-VALUE
RETURN RM
?ELS49: PRINTI "You can't go that way."
CRLF
RFALSE
?ELS37: PRINTI "You would hit one of the panels."
CRLF
RFALSE
?ELS31: PRINTI "You are inside a closed box!"
CRLF
RFALSE