-
Notifications
You must be signed in to change notification settings - Fork 38
/
main.zap
204 lines (196 loc) · 4.5 KB
/
main.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
.FUNCT GO
START::
?FCN: CALL QUEUE,I-LANTERN,200
SET 'CURRENT-LAMP,LAMP
MUL 8,21
PUT CPOBJS,STACK,1
MUL 8,21
ADD STACK,1
PUT CPOBJS,STACK,LORE-BOOK
MUL 8,32
PUT CPOBJS,STACK,1
MUL 8,32
ADD STACK,1
PUT CPOBJS,STACK,CP-SLOT
SET 'LIT,TRUE-VALUE
SET 'WINNER,ADVENTURER
SET 'PLAYER,WINNER
SET 'MLOC,MRB
SET 'HERE,ZORK2-STAIR
RANDOM 70
ADD 70,STACK
CALL QUEUE,I-CLEFT,STACK
PUT STACK,0,1
CALL QUEUE,I-VIEW-CHANGE,4
PUT STACK,0,1
SET 'P-IT-LOC,HERE
SET 'P-IT-OBJECT,FALSE-VALUE
FSET? HERE,TOUCHBIT /?CND1
PRINTI "As in a dream, you see yourself tumbling down a great, dark staircase. All about you are shadowy images of struggles against fierce opponents and diabolical traps. These give way to another round of images: of imposing stone figures, a cool, clear lake, and, now, of an old, yet oddly youthful man. He turns toward you slowly, his long, silver hair dancing about him in a fresh breeze. ""You have reached the final test, my friend! You are proved clever and powerful, but this is not yet enough! Seek me when you feel yourself worthy!"" The dream dissolves around you as his last words echo through the void...."
CRLF
CRLF
CALL V-VERSION
CRLF
?CND1: MOVE WINNER,HERE
MOVE LAMP,HERE
CALL V-LOOK
CALL MAIN-LOOP
JUMP ?FCN
.FUNCT MAIN-LOOP,ICNT,OCNT,NUM,CNT,OBJ,TBL,V,PTBL,OBJ1,TMP,?TMP1
?PRG1: SET 'CNT,0
SET 'OBJ,FALSE-VALUE
SET 'PTBL,TRUE-VALUE
CALL PARSER >P-WON
ZERO? P-WON /?ELS5
GET P-PRSI,P-MATCHLEN >ICNT
GET P-PRSO,P-MATCHLEN >OCNT
ZERO? OCNT \?ELS10
PUSH OCNT
JUMP ?CND6
?ELS10: GRTR? OCNT,1 \?ELS12
SET 'TBL,P-PRSO
ZERO? ICNT \?ELS15
SET 'OBJ,FALSE-VALUE
JUMP ?CND13
?ELS15: GET P-PRSI,1 >OBJ
?CND13: PUSH OCNT
JUMP ?CND6
?ELS12: GRTR? ICNT,1 \?ELS19
SET 'PTBL,FALSE-VALUE
SET 'TBL,P-PRSI
GET P-PRSO,1 >OBJ
PUSH ICNT
JUMP ?CND6
?ELS19: PUSH 1
?CND6: SET 'NUM,STACK
ZERO? OBJ \?CND22
EQUAL? ICNT,1 \?CND22
GET P-PRSI,1 >OBJ
?CND22: EQUAL? PRSA,V?WALK \?ELS29
CALL PERFORM,PRSA,PRSO >V
JUMP ?CND27
?ELS29: ZERO? NUM \?ELS31
GETB P-SYNTAX,P-SBITS
BAND STACK,P-SONUMS
ZERO? STACK \?ELS34
CALL PERFORM,PRSA >V
SET 'PRSO,FALSE-VALUE
JUMP ?CND27
?ELS34: ZERO? LIT \?ELS36
PRINTI "It's too dark to see."
CRLF
JUMP ?CND27
?ELS36: PRINTI "There isn't anything to "
GET P-ITBL,P-VERBN >TMP
ZERO? P-OFLAG /?ELS45
GET TMP,0
PRINTB STACK
JUMP ?CND43
?ELS45: GETB TMP,2 >?TMP1
GETB TMP,3
CALL WORD-PRINT,?TMP1,STACK
?CND43: PRINTI "!"
CRLF
SET 'V,FALSE-VALUE
JUMP ?CND27
?ELS31:
?PRG53: IGRTR? 'CNT,NUM \?ELS57
JUMP ?CND27
?ELS57: ZERO? PTBL /?ELS62
GET P-PRSO,CNT >OBJ1
JUMP ?CND60
?ELS62: GET P-PRSI,CNT >OBJ1
?CND60: GRTR? NUM,1 \?CND66
PRINTD OBJ1
PRINTI ": "
?CND66: ZERO? PTBL /?ELS75
PUSH OBJ1
JUMP ?CND71
?ELS75: PUSH OBJ
?CND71: SET 'PRSO,STACK
ZERO? PTBL /?ELS83
PUSH OBJ
JUMP ?CND79
?ELS83: PUSH OBJ1
?CND79: SET 'PRSI,STACK
CALL PERFORM,PRSA,PRSO,PRSI >V
EQUAL? V,M-FATAL \?PRG53
?CND27: EQUAL? PRSA,V?WAIT /?CND90
EQUAL? PRSA,V?VERSION,V?SCORE,V?RESTORE /?CND90
EQUAL? PRSA,V?SAVE,V?WALK,V?AGAIN \?ELS92
JUMP ?CND90
?ELS92: SET 'L-PRSA,PRSA
SET 'L-PRSO,PRSO
SET 'L-PRSI,PRSI
?CND90: EQUAL? V,M-FATAL \?CND3
SET 'P-CONT,FALSE-VALUE
JUMP ?CND3
?ELS5: SET 'P-CONT,FALSE-VALUE
?CND3: ZERO? P-WON /?PRG1
EQUAL? PRSA,V?RESTORE,V?UNSCRIPT,V?SCRIPT /?PRG1
EQUAL? PRSA,V?SCORE,V?RESTART,V?QUIT /?PRG1
EQUAL? PRSA,V?VERSION,V?SAVE,V?VERBOSE /?PRG1
EQUAL? PRSA,V?SUPER-BRIEF,V?BRIEF,V?TELL \?ELS108
JUMP ?PRG1
?ELS108: INC 'MOVES
CALL CLOCKER >V
JUMP ?PRG1
.FUNCT PERFORM,A,O=0,I=0,V,OA,OO,OI
SET 'OA,PRSA
SET 'OO,PRSO
SET 'OI,PRSI
EQUAL? IT,I,O \?CND1
EQUAL? P-IT-LOC,HERE /?CND1
PRINTI "I don't see what you are referring to."
CRLF
RETURN 2
?CND1: EQUAL? O,IT \?CND10
SET 'O,P-IT-OBJECT
?CND10: EQUAL? I,IT \?CND13
SET 'I,P-IT-OBJECT
?CND13: SET 'PRSA,A
SET 'PRSO,O
ZERO? PRSO /?CND16
EQUAL? PRSA,V?WALK /?CND16
SET 'P-IT-OBJECT,PRSO
SET 'P-IT-LOC,HERE
?CND16: SET 'PRSI,I
GETP WINNER,P?ACTION
CALL STACK >V
ZERO? V /?ELS23
JUMP ?CND21
?ELS23: LOC WINNER
GETP STACK,P?ACTION
CALL STACK,M-BEG >V
ZERO? V /?ELS25
JUMP ?CND21
?ELS25: GET PREACTIONS,A
CALL STACK >V
ZERO? V /?ELS27
JUMP ?CND21
?ELS27: ZERO? I /?ELS29
GETP I,P?ACTION
CALL STACK >V
ZERO? V /?ELS29
JUMP ?CND21
?ELS29: ZERO? O /?ELS33
EQUAL? A,V?WALK /?ELS33
GETP O,P?ACTION
CALL STACK >V
ZERO? V /?ELS33
JUMP ?CND21
?ELS33: GET ACTIONS,A
CALL STACK >V
ZERO? V /?CND21
?CND21: EQUAL? V,M-FATAL /?CND38
LOC WINNER
EQUAL? STACK,PRSO \?CND41
SET 'PRSO,FALSE-VALUE
?CND41: LOC WINNER
GETP STACK,P?ACTION
CALL STACK,M-END >V
?CND38: SET 'PRSA,OA
SET 'PRSO,OO
SET 'PRSI,OI
RETURN V
.ENDI