-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.zap
474 lines (428 loc) · 12.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
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
.FUNCT GO
START::
?FCN: CALL2 INIT-STATUS-LINE,TRUE-VALUE
SET 'LIT,TRUE-VALUE
PUTB P-LEXV,0,59
PUTB YES-LEXV,0,4
SET 'WINNER,PLAYER
CALL QUEUE,I-PROMPT,1
PUT STACK,0,1
CALL1 INTRO
FSET HERE,SEENBIT
CALL1 START-MOVEMENT
CALL1 V-LOOK
CALL1 MAIN-LOOP
JUMP ?FCN
.FUNCT INTRO,N
SET 'HERE,GAME
PRINTI "Copyright (c) 1985 Infocom, Inc. All rights reserved.
Welcome to "
PRINTD GAME
PRINTI " (TM) - interactive fiction from Infocom!
"
PRINTI "[Note to testers: this story has the command GO TO, and the concept of not being able to see things behind your back. The unit of currency in this story is the Frotzian slimpuk, whose symbol is """
PRINTC CURRENCY-SYMBOL
PRINTI """.
Messages in square brackets [] will not be in the final release.
Remember: you can shorten your words only to NINE (9) letters.
But you can use C for COMPARTMENT, V for VESTIBULE, and F for FORWARD.]
"
PRINTI "Do you want the viewpoint of the traveler or the spy? "
CALL READ-WORD,W?TRAVELER,W?SPY,W?T,W?S,W?TRAVELLER >N
EQUAL? N,W?SPY,W?S \?ELS11
SET 'VARIATION,3
JUMP ?CND9
?ELS11: SET 'VARIATION,1
?CND9: PRINTI "Do you want the short variation or the long one? "
CALL READ-WORD,W?SHORT,W?LONG,W?S,W?L >N
PRINTI "Then let the story begin!"
CRLF
EQUAL? N,W?L,W?LONG \?CND23
INC 'VARIATION
CALL ZMEMZ,MCGUFFIN,BRIEFCASE-TBL
PUT BRIEFCASE-TBL,STACK,0
FSET MCGUFFIN,NDESCBIT
FCLEAR MCGUFFIN,TAKEBIT
?CND23: CALL1 TAKE-YOUR-PLACES
EQUAL? VARIATION,2,4 \?CND26
MOVE MCGUFFIN,LIMBO-REAR
?CND26: CALL1 START-TRAIN
CLEAR 0
EQUAL? VARIATION,3,4 \?ELS31
REMOVE BOND
MOVE BOND-OTHER,HERE
CALL QUEUE,I-BOND-OTHER,-1
PUT STACK,0,1
PRINTI "Why did you want to be a spy anyway? You could have had a nice restful job, like an air-traffic controller. You could have tended flowers behind a white picket fence around your country cottage. At least they could let you grab a few winks between one job and the next. But no -- you finish debriefing in some dirty little city in Frotzerland, and before you can even find a phone book, let alone a hotel, they volunteer you for another assignment.
""You've got to intercept "
CALL2 PRINTA,MCGUFFIN
PRINTI "!"" they told you. ""Then deliver it to our agent in Gola so the leak can be traced. We don't know where it is for sure, but we think it's in a briefcase that's leaving town on the next train. You're the only agent that's close enough and experienced enough to be sent after it. And at the end of the trip, there will be a plane ticket to home waiting for you.""
So that's why you're climbing all over this stupid train. Finding the briefcase was easy enough, but the dude carrying it was something else. Even your well-placed bullet didn't make him drop. Now, if only he'll take the bait and follow you up here, you can .... Wait! Here he comes from the forward end! But he's not carrying the case!
"
JUMP ?CND29
?ELS31: PRINTI "With your business deal behind you, you want only to get out of this bleak corner of Eastern Europe. The frontier is now only a few hours away, and from there it's not far to Vienna, and civilization....
The ride seems endless, and you're dozing off again. The wheels of the train are ticking like a clock, ticking off the segments of track you're passing, and the compartment is rocking you back and forth, back and forth, making your eyelids slowly close.
Your slumber is cut short as a man staggers into your compartment, panting strangely. From his demeanor, you guess that he has drunk too much. But before you can dismiss him, you notice that he's grasping a bright red spot on his shirt. He speaks quietly, but in a hurry.
""I've got only a moment, so listen carefully! Since you were reading the International Herald over lunch, I assume you're an American. I am an agent of our government, and I've been sent to "
EQUAL? VARIATION,2,4 \?ELS40
PRINTI "pick up some kind of "
PRINTD MCGUFFIN
PRINTI " in Frbz and take it"
JUMP ?CND38
?ELS40: PRINTI "deliver a "
PRINTD MCGUFFIN
?CND38: PRINTI " to our special agent in Gola. An enemy agent spotted me on the train, and I only barely managed to escape."" He groans softly, examining his wound.
""The best I can do now is throw the enemy off the scent, but I need you, and your country needs you, to carry out my assignment."" You start to interrupt, a thousand questions racing through your mind. ""There's no time! Here! Take my briefcase, but be careful with it! Our enemies are all around us! My contact in "
EQUAL? VARIATION,2,4 \?ELS51
PRINTD STATION-FRBZ
JUMP ?CND49
?ELS51: PRINTD STATION-GOLA
?CND49: PRINTI " is "
CALL2 PRINTA,CONTACT
PRINTI ", and I was to display "
EQUAL? VARIATION,2,4 /?CND58
CALL2 PRINTA,PASSOBJECT
PRINTI ", then use the word"
EQUAL? PASSWORD,CAMERA,HANKY,SCARF \?CND63
PRINTI "s"
?CND63: PRINTI " '"
PRINTD PASSWORD
PRINTI "' "
?CND58: PRINTI "...."" Then he stops and listens. Before you can say anything, he checks the corridor and races out.
"
CALL QUEUE,I-BOND,1
PUT STACK,0,1
?CND29: CALL1 V-VERSION
CRLF
CALL1 INIT-STATUS-LINE
RSTACK
.FUNCT READ-WORD,WD1,WD2,WD3=0,WD4=0,WD5=0,N,L
?FCN: PRINTI ">"
READ P-INBUF,P-LEXV
GETB P-LEXV,P-LEXWORDS
ZERO? STACK \?CND3
CALL PLEASE-TYPE-OR,WD1,WD2
JUMP ?FCN
?CND3: SET 'L,P-LEXSTART
?PRG6: GET P-LEXV,L >N
CALL WT?,N,PS?BUZZ-WORD
ZERO? STACK \?CND8
JUMP ?REP7
?CND8: ADD L,P-LEXELEN >L
JUMP ?PRG6
?REP7: EQUAL? N,WD1,WD2 /?THN14
EQUAL? N,WD3,WD4,WD5 \?CND11
?THN14: RETURN N
?CND11: CALL WT?,N,PS?VERB,P1?VERB >N
EQUAL? N,ACT?QUIT \?ELS18
QUIT
CALL1 TELL-FAILED
JUMP ?FCN
?ELS18: EQUAL? N,ACT?RESTART \?ELS20
RESTART
CALL1 TELL-FAILED
JUMP ?FCN
?ELS20: EQUAL? N,ACT?$VERIFY \?ELS22
CALL1 V-$VERIFY
JUMP ?FCN
?ELS22: EQUAL? N,ACT?RELEASE \?ELS24
CALL1 V-VERSION
JUMP ?FCN
?ELS24: EQUAL? N,ACT?RESTORE \?CND16
CALL1 V-RESTORE
ZERO? STACK /?FCN
CALL1 TELL-FAILED
JUMP ?FCN
?CND16: CALL PLEASE-TYPE-OR,WD1,WD2
JUMP ?FCN
.FUNCT PLEASE-TYPE-OR,WD1,WD2
PRINTI "Please type """
PRINTB WD1
PRINTI """ or """
PRINTB WD2
PRINTI """. "
RTRUE
.FUNCT RANDOM-PER-VAR,L,N
MUL VARIATION,L
DIV STACK,MAX-VAR
ADD 1,STACK >N
GRTR? N,L \?ELS5
RETURN L
?ELS5: RETURN N
.FUNCT TAKE-YOUR-PLACES,P,N,L,?TMP1
PUTP WAITER,P?CAR,DINER-CAR
PUTP COOK,P?CAR,DINER-CAR
CALL2 PICK-ONE,CAR-ROOMS-COMPS >COMPARTMENT-START
EQUAL? VARIATION,3,4 \?CND1
ADD 1,CAR-START >CAR-HERE
?CND1: CALL2 TAKE-YOUR-PLACES-CAST,EXTRA-TABLE
CALL2 TAKE-YOUR-PLACES-CAST,SPY-TABLE
CALL TAKE-YOUR-PLACES-CAST,MARKS-TABLE,FALSE-VALUE,FALSE-VALUE,FALSE-VALUE
GET SPY-TABLE,0
CALL2 RANDOM-PER-VAR,STACK
GET SPY-TABLE,STACK >BAD-SPY
GETP BAD-SPY,P?CHARACTER >BAD-SPY-C
GETP BAD-SPY,P?ACTION >BAD-SPY-DEFAULT-F
EQUAL? VARIATION,3,4 /?ELS6
SET 'HERE,COMPARTMENT-START
CALL2 GENERIC-SEAT-F,0 >PLAYER-SEATED
MOVE BLOOD-SPOT,HERE
MOVE BRIEFCASE,PLAYER-SEATED
PUTP BRIEFCASE,P?CAR,CAR-HERE
PUTP BAD-SPY,P?ACTION,BAD-SPY-F
ADD 1,CAR-START
PUTP BAD-SPY,P?CAR,STACK
MOVE BAD-SPY,OTHER-ROOF
JUMP ?CND4
?ELS6: SET 'HERE,ROOF
PUTP PLAYER,P?CAR,CAR-HERE
MOVE BRIEFCASE,BAD-SPY
PUTP BRIEFCASE,P?CAR,CAR-START
FCLEAR BRIEFCASE,TAKEBIT
SET 'N,0
GET BRIEFCASE-TBL,0 >L
?PRG9: IGRTR? 'N,L \?ELS13
JUMP ?REP10
?ELS13: GET BRIEFCASE-TBL,N >P
ZERO? P /?PRG9
FCLEAR P,TAKEBIT
JUMP ?PRG9
?REP10: RANDOM 6
ADD 9,STACK
CALL QUEUE,I-TRAVELER-TO-GRNZ,STACK
PUT STACK,0,1
PUTP BAD-SPY,P?ACTION,TRAVELER-F
PUTP BAD-SPY,P?CAR,CAR-START
PUTP BAD-SPY,P?LDESC,35
GETP COMPARTMENT-START,P?OTHER >L
MOVE BAD-SPY,L
SET 'BAD-SPY-DONE-PEEKING,TRUE-VALUE
MOVE BLOOD-SPOT,L
FCLEAR GUN,NDESCBIT
FSET GUN,TAKEBIT
MOVE GUN,POCKET
?CND4: MOVE PLAYER,HERE
SET 'LAST-CAR-HERE,CAR-HERE
ADD 1,CONTACT-MAX >?TMP1
CALL2 RANDOM-PER-VAR,CONTACT-MAX
SUB ?TMP1,STACK
GET EXTRA-TABLE,STACK >CONTACT
GETP CONTACT,P?ACTION >CONTACT-DEFAULT-F
PUTP CONTACT,P?ACTION,CONTACT-F
EQUAL? VARIATION,2,4 \?CND16
CALL1 MOVE-CONTACT
PUTP TICKET,P?CAPACITY,STATION-WIEN
PUTP TICKET-OTHER,P?CAPACITY,STATION-WIEN
SET 'LATCH-TURNED,FALSE-VALUE
CALL PICK-ONE-NOT,SPY-TABLE,BAD-SPY >PICKPOCKET
CALL PICK-ONE-NOT,SPY-TABLE,BAD-SPY >PEEKER
ADD 2,CAR-START
PUTP PEEKER,P?CAR,STACK
MOVE PEEKER,OTHER-VESTIBULE-REAR
GETP PEEKER,P?CHARACTER
GET GOAL-TABLES,STACK
PUT STACK,GOAL-ENABLE,1
CALL ESTABLISH-GOAL-TRAIN,PEEKER,VESTIBULE-FWD,1
PUTP PEEKER,P?LDESC,PEEKING-CODE
?CND16: CALL1 SET-PASSES
RSTACK
.FUNCT SET-PASSES,NUM=0,L,N,P
SET 'PASSWORD-GIVEN,FALSE-VALUE
SET 'PASSWORD-GIVEN-OTHER,FALSE-VALUE
SET 'PASSOBJECT-GIVEN,FALSE-VALUE
SET 'PASSOBJECT-GIVEN-OTHER,FALSE-VALUE
ZERO? NUM /?CND1
FSET SPY-LIST,MUNGBIT
?CND1: SET 'L,6
ADD NUM,VARIATION >P
GET PASS-TABLE,P >PASSOBJECT
CALL2 RANDOM-PER-VAR,L
ADD NUM,STACK >N
EQUAL? P,N \?CND4
IGRTR? 'N,L \?CND4
SET 'N,1
?CND4: GET PASS-TABLE,N >PASSWORD
RETURN PASSWORD
.FUNCT TAKE-YOUR-PLACES-CAST,TBL,NEW?=0,STA-ONLY?=0,PEOPLE?=1,P,OBJ,N,L,M,X
GET TBL,0 >P
GET CAR-ROOMS,0 >M
?PRG1: GET TBL,P >OBJ
ZERO? PEOPLE? /?CND3
FSET OBJ,LOCKED
?CND3: RANDOM M
GET CAR-ROOMS,STACK >L
RANDOM CAR-MAX >N
EQUAL? N,DINER-CAR,FANCY-CAR \?CND7
DEC 'N
?CND7: ZERO? PEOPLE? \?ELS12
JUMP ?CND10
?ELS12: ZERO? NEW? \?ELS14
EQUAL? L,COMPARTMENT-START \?ELS14
EQUAL? N,CAR-START \?ELS14
DEC 'N
JUMP ?CND10
?ELS14: CALL ZMEMQ,L,CAR-ROOMS-REST
ZERO? STACK /?CND10
FSET? OBJ,PLURALBIT /?THN22
CALL OCCUPIED?,L,N
ZERO? STACK /?ELS21
?THN22: GETPT L,P?OUT
GET STACK,REXIT >L
JUMP ?CND10
?ELS21: EQUAL? N,CAR-HERE \?ELS25
CALL FIND-FLAG-LG,L,DOORBIT
FSET STACK,LOCKED
JUMP ?CND10
?ELS25: CALL FIND-FLAG-LG,L,DOORBIT
FCLEAR STACK,LOCKED
?CND10: ZERO? PEOPLE? /?THN31
CALL TAKE-YOUR-PLACE-TEST,OBJ,STA-ONLY?
ZERO? STACK /?CND28
?THN31: EQUAL? N,CAR-HERE,DINER-CAR,FANCY-CAR \?ELS35
MOVE OBJ,L
JUMP ?CND33
?ELS35: GETP L,P?OTHER >X
ZERO? X /?CND33
MOVE OBJ,X
?CND33: PUTP OBJ,P?CAR,N
?CND28: ZERO? NEW? /?CND38
ZERO? PEOPLE? /?CND38
CALL ZMEMQ,OBJ,EXTRA-TABLE >X
ZERO? X /?CND43
GET EXTRA-SEEN-TABLE,X
SUB 0,STACK
PUT EXTRA-SEEN-TABLE,X,STACK
?CND43: EQUAL? OBJ,BAD-SPY /?CND38
FCLEAR OBJ,SEENBIT
FCLEAR OBJ,TOUCHBIT
PUTP OBJ,P?LDESC,0
?CND38: DLESS? 'P,1 \?PRG1
RTRUE
.FUNCT TAKE-YOUR-PLACE-TEST,OBJ,STA-ONLY?,X
EQUAL? OBJ,CONTACT /FALSE
CALL IN-MOTION?,OBJ,TRUE-VALUE
ZERO? STACK \FALSE
CALL2 META-LOC,OBJ
CALL ZMEMQ,STACK,STATION-ROOMS >X
ZERO? STA-ONLY? /?ELS10
RETURN X
?ELS10: ZERO? X /TRUE
RFALSE
.FUNCT OCCUPIED?,L,N
EQUAL? L,GAS-CAR-RM \?ELS3
EQUAL? N,GAS-CAR /TRUE
?ELS3: EQUAL? N,CAR-HERE,DINER-CAR,FANCY-CAR /?CND1
GETP L,P?OTHER >L
?CND1: CALL FIND-FLAG-CAR,L,N,PERSONBIT
RSTACK
.FUNCT MOVE-CONTACT,N
SUB PLATFORM-MAX,1
RANDOM STACK
ADD 1,STACK >N
PUTP CONTACT,P?CAR,N
GET STATION-ROOMS,N
MOVE CONTACT,STACK
FSET CONTACT,NDESCBIT
FCLEAR CONTACT,TOUCHBIT
PUTP CONTACT,P?LDESC,10
RTRUE
.FUNCT INIT-STATUS-LINE,FIRST=0
GETB 0,18
ZERO? STACK /TRUE
ZERO? FIRST /?CND4
CLEAR -1
SPLIT 2
?CND4: SCREEN 1
BUFOUT FALSE-VALUE
CALL2 INVERSE-LINE,1
HLIGHT H-INVERSE
ZERO? FIRST /?ELS10
GETB 0,33
SUB STACK,10
DIV STACK,2
CURSET 1,STACK
PRINTD GAME
JUMP ?CND8
?ELS10: CURSET 1,1
PRINTI "You are "
CURSET 1,63
PRINTI "It is now "
?CND8: SET 'PLAYER-NOT-FACING-OLD,99
BUFOUT TRUE-VALUE
HLIGHT H-NORMAL
SCREEN 0
RTRUE
.FUNCT INVERSE-LINE,LIN,CNT=79
CURSET LIN,1
HLIGHT H-INVERSE
CALL2 PRINT-SPACES,CNT
HLIGHT H-NORMAL
RTRUE
.FUNCT PRINT-SPACES,CNT
?PRG1: DLESS? 'CNT,0 /TRUE
PRINTC 32
JUMP ?PRG1
.FUNCT STATUS-LINE,LEN,X=0
GETB 0,18
ZERO? STACK /TRUE
EQUAL? LAST-PLAYER-LOC,HERE \?THN7
EQUAL? PLAYER-NOT-FACING-OLD,PLAYER-NOT-FACING \?THN7
EQUAL? PLAYER-SEATED-OLD,PLAYER-SEATED /?CND4
?THN7: SET 'X,TRUE-VALUE
?CND4: ZERO? X \?CND9
ZERO? CLOCK-WAIT \TRUE
?CND9: BUFOUT FALSE-VALUE
SCREEN 1
HLIGHT H-INVERSE
ZERO? X /?CND16
SET 'LAST-PLAYER-LOC,HERE
SET 'PLAYER-NOT-FACING-OLD,PLAYER-NOT-FACING
SET 'PLAYER-SEATED-OLD,PLAYER-SEATED
DIROUT -1
DIROUT 3,SL-BUFFER
CALL1 TELL-LOCATION
DIROUT -3
DIROUT 1
GET SL-BUFFER,0 >LEN
CURSET 1,9
CALL1 TELL-LOCATION
SUB 54,LEN
CALL2 PRINT-SPACES,STACK
?CND16: CURSET 1,73
CALL2 TIME-PRINT,PRESENT-TIME
PRINTI ". "
SCREEN 0
BUFOUT TRUE-VALUE
HLIGHT H-NORMAL
RTRUE
.FUNCT TELL-LOCATION,DIR
EQUAL? HERE,UNCONSCIOUS \?CND1
PRINTI "unconscious."
RTRUE
?CND1: ZERO? PLAYER-SEATED \?ELS8
JUMP ?CND6
?ELS8: LESS? 0,PLAYER-SEATED \?ELS10
PRINTI "sitting "
JUMP ?CND6
?ELS10: PRINTI "lying "
?CND6: FSET? HERE,SURFACEBIT \?ELS19
PRINTI "on"
JUMP ?CND17
?ELS19: EQUAL? HERE,BESIDE-TRACKS /?CND17
PRINTI "in"
?CND17: CALL2 PRINTT,HERE
ZERO? PLAYER-NOT-FACING /?CND28
PRINTI ", facing "
CALL2 OPP-DIR,PLAYER-NOT-FACING >DIR
EQUAL? DIR,P?EAST \?ELS35
ZERO? ON-TRAIN /?ELS35
PRINTI "the right side"
JUMP ?CND28
?ELS35: EQUAL? DIR,P?WEST \?ELS41
ZERO? ON-TRAIN /?ELS41
PRINTI "the left side"
JUMP ?CND28
?ELS41: CALL2 DIR-PRINT,DIR
?CND28: PRINTI "."
RTRUE
.ENDI