-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmaze.zap
772 lines (715 loc) · 19.1 KB
/
maze.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
.SEGMENT "MAZE"
.FUNCT HOUSE-F:ANY:0:0
EQUAL? PRSA,V?EXAMINE \?CCL3
PRINTR "Houses and shops crowd the street on all sides, some dark and some lit by oil lamps flickering through the paper panels of the shojis."
?CCL3: EQUAL? PRSA,V?ENTER,V?BOARD,V?THROUGH \FALSE
PRINTR "As you start to move off from the cortege, Mariko calls you back, speaking in Latin.""No, Pilot, that is not the way."""
.FUNCT RONIN-F:ANY:0:1,RARG
EQUAL? RARG,M-WINNER \FALSE
PRINTI "The ronin take orders only from Toranaga."
CRLF
CALL1 END-QUOTE
RSTACK
.FUNCT FISH-GATE-F:ANY:0:0
EQUAL? PRSA,V?EXAMINE \FALSE
PRINTR "It's just a weathered old gate with a fish carved on it."
.FUNCT AMBUSHERS-DESC:ANY:2:2,RARG,OBJ
EQUAL? RARG,M-OBJDESC? /TRUE
PRINTI "Dim figures can be seen on one of the tiled roofs of a nearby house."
RTRUE
.FUNCT AMBUSHERS-F:ANY:0:1,RARG
EQUAL? RARG,M-SUBJ /FALSE
EQUAL? RARG,M-WINNER \?CCL5
PRINT STR?211
CRLF
RTRUE
?CCL5: EQUAL? PRSA,V?EXAMINE \FALSE
PRINTR "From here, in the dark, they are merely dim dark outlines."
.FUNCT MESSENGER-F:ANY:0:1,RARG
IN? MESSENGER,LOCAL-GLOBALS \?CCL3
CALL1 PASSIVE-VERB?
ZERO? STACK \?CCL3
PRINTR "He's gone!"
?CCL3: EQUAL? RARG,M-SUBJ /FALSE
EQUAL? RARG,M-WINNER \?CCL9
CALL1 WAKARIMASEN
RSTACK
?CCL9: EQUAL? PRSA,V?STOP /?CCL11
CALL1 HOSTILE-VERB?
ZERO? STACK /FALSE
?CCL11: FSET? MESSENGER,DEAD \?CCL16
PRINTR "Buntaro hacked him to pieces."
?CCL16: FSET? MESSENGER,RMUNGBIT /?CCL18
FSET MESSENGER,RMUNGBIT
PRINTR "You stretch to intercept the man, grabbing and nearly tackling him, and he tumbles to the ground."
?CCL18: PRINTI "Desperately you struggle with the messenger and manage to knock him down a second time."
CRLF
CALL2 SCORE-OBJECT,MESSENGER
RSTACK
.FUNCT AMBUSH-SITE-F:ANY:0:1,RARG
EQUAL? RARG,M-BEG \FALSE
EQUAL? PRSA,V?WALK \?CCL6
PRINTR "You are pinned down by the attack.To run would be suicidal!"
?CCL6: EQUAL? PRSA,V?PUSH,V?TAKE,V?HELP /?PRD10
EQUAL? PRSA,V?PULL-BEHIND \?CCL8
?PRD10: EQUAL? PRSO,MARIKO \?CCL8
FSET? MARIKOS-LITTER,SCOREBIT \?CCL8
ICALL1 B-LIE-DOWN
PRINTI "You roll for cover, taking Mariko with you into the lee of the tumbled litter."
CRLF
CALL2 SCORE-OBJECT,MARIKOS-LITTER
RSTACK
?CCL8: EQUAL? PRSA,V?DODGE /?PRD17
EQUAL? PRSA,V?HIDE-BEHIND,V?HIDE-UNDER \FALSE
EQUAL? PRSO,MARIKOS-LITTER \FALSE
?PRD17: FSET? MARIKOS-LITTER,SCOREBIT \FALSE
ICALL1 B-LIE-DOWN
PRINTR "You roll for cover into the lee of the tumbled litter."
.FUNCT I-AMBUSH-START:ANY:0:0
GRTR? AMBUSH-PROB,100 /?CCL3
RANDOM 100
LESS? AMBUSH-PROB,STACK \?CCL3
ICALL QUEUE,I-AMBUSH-START,5
EQUAL? MACHINE,APPLE-2E,APPLE-2C,APPLE-2GS \?CCL8
PUSH 12
JUMP ?CND6
?CCL8: PUSH 6
?CND6: ADD AMBUSH-PROB,STACK >AMBUSH-PROB
RFALSE
?CCL3: SET 'XAMBUSH,X
SET 'YAMBUSH,Y
ICALL MOVE-ALL,MAZE,AMBUSH-SITE
IN? BLACKTHORNE,MARIKOS-LITTER \?CCL11
MOVE MARIKOS-LITTER,MAZE
JUMP ?CND9
?CCL11: MOVE BLACKTHORNE,MAZE
?CND9: MOVE AMBUSHERS,AMBUSH-SITE
ICALL QUEUE,I-AMBUSH,-1
CRLF
PRINTI "The arrows come out of the night, the first impaling the captain through the throat.His lungs fill with molten fire and death swallows him.His last thought is one of wonder, for did not Lord Kiyama, his master, tell him the ambush was to be later, beside the wharves, and directed at the pirate?"
CRLF
CRLF
CALL2 GOTO,AMBUSH-SITE
RSTACK
.FUNCT I-AMBUSH:ANY:0:0
INC 'DELAY-CNT
EQUAL? AMBUSH-CNT,5 \?CND3
FSET? MESSENGER,SCOREBIT \?CCL7
FSET? MESSENGER,RMUNGBIT \?CCL10
FSET? MESSENGER,SURFACEBIT /?CCL10
FSET MESSENGER,SURFACEBIT
CRLF
PRINTR "Immediately he rolls and is on his feet again!"
?CCL10: MOVE MESSENGER,LOCAL-GLOBALS
FCLEAR MESSENGER,SCOREBIT
CRLF
PRINTR "This time the messenger scuttles away from you and is off like a hare chased by hounds."
?CCL7: IN? MESSENGER,LOCAL-GLOBALS /?CND3
FSET? MESSENGER,DEAD /?CND3
FSET MESSENGER,DEAD
CRLF
PRINTR "This time Buntaro, with a vicious chop of his sword, cuts the man down."
?CND3: SET 'DELAY-CNT,0
INC 'AMBUSH-CNT
EQUAL? AMBUSH-CNT,1 \?CCL18
CRLF
PRINTI "An arrow slams into the litter post an inch from your head!Two arrows pierce the curtains of Kiritsubo's litter, and another strikes one of the maids in the waist.As she screams, the litter bearers take to their heels into the darkness.Mariko "
FSET? MARIKOS-LITTER,SCOREBIT \?CCL21
PRINTI "stands in the open"
JUMP ?CND19
?CCL21: PRINTI "clings to you"
?CND19: PRINTR ", staring in shock at the dying maid."
?CCL18: EQUAL? AMBUSH-CNT,2 \?CCL23
CRLF
PRINTI "A shower of arrows straddles both litters."
FSET? MARIKOS-LITTER,SCOREBIT \?CCL26
FSET MARIKO,DEAD
PRINTI "One strikes Mariko in the back as she starts to run for cover.She falls to the ground and is still."
CRLF
CALL1 FAILED-SCENE
RSTACK
?CCL26: PRINTR "One thuds into the ground where Mariko was an instant ago."
?CCL23: EQUAL? AMBUSH-CNT,3 \?CCL28
MOVE TORANAGA,HERE
REMOVE TORANAGA-IN-DRAG
FSET CURTAINS,OPENBIT
CALL MARGINAL-PIC,P-IN-DRAG,TRUE-VALUE,P-IN-DRAG-CORNER,TRUE-VALUE
ZERO? STACK \?CND29
CRLF
?CND29: PRINTR "Buntaro shields Toranaga's litter with his body as best he can, then whips open the curtains.Two arrows are imbedded in Toranaga's chest and side, and he jerks them out of the armor he wears beneath the kimono.He fights his way out of the litter and stands in the street, sword drawn, an incongruous figure in kimono and hat."
?CCL28: EQUAL? AMBUSH-CNT,4 \?CCL32
REMOVE AMBUSHERS
CRLF
PRINTR "Another volley of arrows comes out of the darkness, one missing you so narrowly that it takes skin off of your cheek, and then all is silent.
Buntaro and some of his men are near the wall in pursuit but the ambushers vanish into the blackness.A dozen men race in pursuit but all know it's hopeless."
?CCL32: EQUAL? AMBUSH-CNT,5 \?CCL34
MOVE MESSENGER,HERE
FCLEAR MESSENGER,INVISIBLE
ICALL2 THIS-IS-IT,MESSENGER
SET 'OPPONENT,MESSENGER
CRLF
PRINTR "One of the officer Grays says, ""Toranaga!"" and though it is said quietly, everyone hears.Here, incredibly, is the enemy of his master, free, outside the castle walls.""You will wait here, Lord Toranaga.You,"" he snaps at one of his men, ""report to Lord Ishido at once!""The man races toward you, heading back toward the castle!"
?CCL34: EQUAL? AMBUSH-CNT,6 \?CCL36
ICALL REPLACE-SYNONYM,CORTEGE,W?GRAYS,W?BROWNS
MOVE GRAYS,HERE
ICALL2 THIS-IS-IT,GRAYS
CRLF
PRINTR "The rest of the Grays attack, trying to reach Toranaga.One officer whips out his two-handed sword and leaps for Toranaga but Buntaro parries.The Browns and Grays, all intermixed, erupt into a swirling melee.
The Grays fight courageously.Four join in a suicidal charge at Toranaga.The Browns break it and the Grays regroup and charge again.Then a senior officer orders three to retreat for help and the rest to guard the retreat."
?CCL36: EQUAL? AMBUSH-CNT,7 \FALSE
ICALL2 DEQUEUE,I-AMBUSH
FSET? MESSENGER,DEAD \?CCL41
REMOVE MESSENGER
JUMP ?CND39
?CCL41: ICALL QUEUE,I-CAUGHT,150
?CND39: REMOVE GRAYS
ICALL MOVE-ALL,AMBUSH-SITE,MAZE
MOVE BLACKTHORNE,AMBUSH-SITE
CRLF
PRINTI "The three Grays tear off, and though Buntaro kills one, the other two are only wounded.The rest die."
CRLF
CRLF
CALL2 GOTO,MAZE
RSTACK
.FUNCT I-CAUGHT:ANY:0:0
EQUAL? HERE,MAZE \FALSE
ICALL1 LEAVE-MAZE
CRLF
PRINTI "Ahead of you, a mass of Gray archers materializes out of the night.Above, a mass of fireworks blooms in warning from the castle.Toranaga turns, ordering the cortege to retreat down an alley, but there are Grays there too.The party is surrounded!"
CRLF
ICALL1 JIGS-UP
RETURN M-FATAL
.FUNCT MAZE-F:ANY:1:1,RARG,XX,YY,OXX,OYY,MOVED?
EQUAL? RARG,M-LOOK \?CCL3
PRINTR "This maze of streets and alleys extends from the great castle to the harbor.At night, it is a nightmare of blind alleys, twisting overhung streets, and shadowy hurrying shapes."
?CCL3: EQUAL? RARG,M-ENTER \?CCL5
ICALL2 TOUCH-SEG,P-MAZE-BACKGROUND
PICSET MAZE-PICS
FSET? HERE,TOUCHBIT /?CND6
ICALL MOVE-ALL,CITY,MAZE
PRINTI "The cortege continues through the winding, curling city streets, the pedestrians bowing and the very poor on their knees until you pass."
CRLF
CRLF
ICALL QUEUE,I-AMBUSH-START,5
PRINTI "[Building Osaka.]"
CRLF
CRLF
ICALL1 BUILDMAZE
?CND6: EQUAL? OHERE,WAREHOUSE \?CCL10
SET 'XX,XGOAL
SET 'YY,YGOAL
PRINTI "You have returned to the"
PRINT STR?563
CRLF
JUMP ?CND8
?CCL10: EQUAL? OHERE,AMBUSH-SITE \?CCL12
SET 'XX,XAMBUSH
SET 'YY,YAMBUSH
PRINTI "The cortege re-forms and prepares to continue the escape.The urgency is now great, as the escaped Grays will spread the alarm."
CRLF
JUMP ?CND8
?CCL12: SET 'XX,XSTART
SET 'YY,YSTART
PRINTI "You have entered a"
PRINT STR?563
CRLF
?CND8: CRLF
ICALL1 TYPE-ANY-KEY
ICALL1 DISPLAY-MAZE
ICALL MAZE-MOVE,XX,YY
RTRUE
?CCL5: EQUAL? RARG,M-LEAVE \?CCL14
CALL1 LEAVE-MAZE
RSTACK
?CCL14: EQUAL? RARG,M-BEG \FALSE
EQUAL? PRSA,V?DEFINE \?CCL19
CLEAR MAZE-WINDOW
RFALSE
?CCL19: EQUAL? PRSA,V?COLOR \?CCL21
PRINTR "[Sorry, you can't change colors in this part of Osaka.]"
?CCL21: EQUAL? PRSA,V?WALK \?CCL23
SET 'MOVED?,FALSE-VALUE
?PRG24: SET 'XX,X
SET 'YY,Y
SET 'OXX,X
SET 'OYY,Y
EQUAL? P-WALK-DIR,P?NORTH \?CCL28
GRTR? YY,0 \?CCL28
DEC 'YY
JUMP ?CND26
?CCL28: EQUAL? P-WALK-DIR,P?EAST \?CCL32
SUB MAZE-WIDTH,1
LESS? XX,STACK \?CCL32
INC 'XX
JUMP ?CND26
?CCL32: EQUAL? P-WALK-DIR,P?WEST \?CCL36
GRTR? XX,0 \?CCL36
DEC 'XX
JUMP ?CND26
?CCL36: EQUAL? P-WALK-DIR,P?SOUTH \?CCL40
SUB MAZE-HEIGHT,1
LESS? YY,STACK \?CCL40
INC 'YY
JUMP ?CND26
?CCL40: EQUAL? P-WALK-DIR,P?NE \?CCL44
SUB MAZE-WIDTH,1
LESS? XX,STACK \?CCL44
GRTR? YY,0 \?CCL44
INC 'XX
DEC 'YY
JUMP ?CND26
?CCL44: EQUAL? P-WALK-DIR,P?SE \?CCL49
SUB MAZE-WIDTH,1
LESS? XX,STACK \?CCL49
SUB MAZE-HEIGHT,1
LESS? YY,STACK \?CCL49
INC 'XX
INC 'YY
JUMP ?CND26
?CCL49: EQUAL? P-WALK-DIR,P?SW \?CCL54
GRTR? XX,0 \?CCL54
SUB MAZE-HEIGHT,1
LESS? YY,STACK \?CCL54
DEC 'XX
INC 'YY
JUMP ?CND26
?CCL54: EQUAL? P-WALK-DIR,P?NW \?CCL59
GRTR? XX,0 \?CCL59
GRTR? YY,0 \?CCL59
DEC 'XX
DEC 'YY
?CND26: EQUAL? XX,XSTART \?CCL65
EQUAL? YY,YSTART \?CCL65
ICALL2 GOTO,CITY
RTRUE
?CCL59: PRINTR "You can't go that way."
?CCL65: EQUAL? XX,XGOAL \?CCL69
EQUAL? YY,YGOAL \?CCL69
ICALL2 GOTO,WAREHOUSE
RTRUE
?CCL69: CALL MGETB,XX,YY
BTST STACK,128 /?CCL73
EQUAL? XX,OXX /?CTR72
EQUAL? YY,OYY /?CTR72
CALL MGETB,XX,OYY
BTST STACK,128 \?CTR72
CALL MGETB,OXX,YY
BTST STACK,128 /?CCL73
?CTR72: ICALL MAZE-MOVE,XX,YY
EQUAL? XX,XFISH \?CCL82
EQUAL? YY,YFISH \?CCL82
LOC FISH-GATE
ZERO? STACK \?CCL82
MOVE FISH-GATE,HERE
FSET? FISH-GATE,SCOREBIT \TRUE
MOVE RONIN,HERE
ICALL2 SCORE-OBJECT,FISH-GATE
PRINT STR?564
PRINTI "Toranaga stops the cortege outside a battered gate.A fish is etched into its timbers.He knocks in code.The door opens at once, and an ill-kempt samurai bows.""Bring your men and follow me,"" Toranaga says.Fifteen men dressed as "
ICALL2 PRINTUNDER,STR?565
PRINTR " follow him and slip into place as advance and rear guard.Others spread the alarm to other secret cadres.Soon there are fifty troops with you and a hundred guarding your flanks."
?CCL82: EQUAL? OXX,XFISH \?CND80
EQUAL? OYY,YFISH \?CND80
REMOVE FISH-GATE
?CND80: EQUAL? P-WALK-DIR,P?NORTH,P?SOUTH \?CCL93
SUB XX,1
CALL MGETB,STACK,YY
BTST STACK,128 \?REP25
ADD XX,1
CALL MGETB,STACK,YY
BTST STACK,128 \?REP25
SET 'MOVED?,TRUE-VALUE
JUMP ?PRG24
?CCL93: EQUAL? P-WALK-DIR,P?EAST,P?WEST \?PRG24
SUB YY,1
CALL MGETB,XX,STACK
BTST STACK,128 \?REP25
ADD YY,1
CALL MGETB,XX,STACK
BTST STACK,128 \?REP25
SET 'MOVED?,TRUE-VALUE
JUMP ?PRG24
?CCL73: ZERO? MOVED? \?REP25
PRINTR "There's a house there."
?REP25: PRINT STR?564
CRLF
RTRUE
?CCL23: EQUAL? PRSA,V?DROP \FALSE
IN? WINNER,MAZE \FALSE
CALL1 IDROP
ZERO? STACK /TRUE
REMOVE PRSO
ICALL1 CTHE-PRINT-PRSO
PRINTR " drops to the ground and is lost from sight in the dark and confusion."
.FUNCT LEAVE-MAZE:ANY:0:0,YY,?TMP1
WINGET S-TEXT,WYPOS >?TMP1
WINGET S-TEXT,WTOP
ADD ?TMP1,STACK >YY
ICALL1 SETUP-TEXT-AND-STATUS
EQUAL? MACHINE,APPLE-2E,APPLE-2C,APPLE-2GS \?CND1
ICALL1 DISPLAY-BORDER
?CND1: SCREEN S-TEXT
WINGET S-TEXT,WTOP
SUB YY,STACK
CURSET STACK,1
RTRUE
.FUNCT MAZE-MOUSE-F:ANY:1:1,TRM,DIR,WX,WY,BX,BY,?TMP1,?TMP2
GET MAZE-BOX-TBL,1 >BX
GET MAZE-BOX-TBL,0 >BY
WINGET MAZE-WINDOW,WTOP
ADD STACK,YOFFSET >?TMP2
MUL Y,BY
ADD ?TMP2,STACK >?TMP1
DIV BY,2
ADD ?TMP1,STACK >WY
WINGET MAZE-WINDOW,WLEFT
ADD STACK,XOFFSET >?TMP2
MUL X,BX
ADD ?TMP2,STACK >?TMP1
DIV BX,2
ADD ?TMP1,STACK >WX
SUB MOUSE-LOC-Y,WY >WY
SUB MOUSE-LOC-X,WX >WX
LESS? WX,0 /?CCL3
LESS? WY,0 \?CCL6
SUB 0,WY >WY
MUL WY,3
GRTR? WX,STACK \?CCL9
SET 'DIR,EAST-STR
JUMP ?CND1
?CCL9: MUL WX,3
GRTR? WY,STACK \?CCL11
SET 'DIR,NORTH-STR
JUMP ?CND1
?CCL11: SET 'DIR,NE-STR
JUMP ?CND1
?CCL6: MUL WY,3
GRTR? WX,STACK \?CCL14
SET 'DIR,EAST-STR
JUMP ?CND1
?CCL14: MUL WX,3
GRTR? WY,STACK \?CCL16
SET 'DIR,SOUTH-STR
JUMP ?CND1
?CCL16: SET 'DIR,SE-STR
JUMP ?CND1
?CCL3: LESS? WY,0 \?CCL18
SUB 0,WY >WY
SUB 0,WX >WX
MUL WY,3
GRTR? WX,STACK \?CCL21
SET 'DIR,WEST-STR
JUMP ?CND1
?CCL21: MUL WX,3
GRTR? WY,STACK \?CCL23
SET 'DIR,NORTH-STR
JUMP ?CND1
?CCL23: SET 'DIR,NW-STR
JUMP ?CND1
?CCL18: SUB 0,WX >WX
MUL WY,3
GRTR? WX,STACK \?CCL26
SET 'DIR,WEST-STR
JUMP ?CND1
?CCL26: MUL WX,3
GRTR? WY,STACK \?CCL28
SET 'DIR,SOUTH-STR
JUMP ?CND1
?CCL28: SET 'DIR,SW-STR
?CND1: DIV BX,2
GRTR? WX,STACK /?CCL31
DIV BY,2
GRTR? WY,STACK \FALSE
?CCL31: ZERO? DIR /FALSE
ICALL ADD-TO-INPUT,DIR,13
RETURN 13
.FUNCT MGETB:ANY:2:2,X,Y
MUL Y,MAZE-WIDTH
ADD STACK,X
GETB MAZE-MAP,STACK
RSTACK
.FUNCT MPUTB:ANY:3:3,X,Y,VAL
MUL Y,MAZE-WIDTH
ADD STACK,X
PUTB MAZE-MAP,STACK,VAL
RTRUE
.FUNCT DISPLAY-MAZE-PIC:ANY:3:3,VAL,Y,X,BY,BX,OY,OX,?TMP1,?TMP2
ZERO? VAL /FALSE
GET MAZE-BOX-TBL,0 >BY
GET MAZE-BOX-TBL,1 >BX
ADD 1,YOFFSET >?TMP2
MUL Y,BY
ADD ?TMP2,STACK >?TMP1
ADD 1,XOFFSET >?TMP2
MUL X,BX
ADD ?TMP2,STACK
DISPLAY VAL,?TMP1,STACK
RTRUE
.FUNCT MAZE-MOVE:ANY:2:2,?LCL-X,?LCL-Y,?TMP1
SCREEN MAZE-WINDOW
SET 'X,?LCL-X
SET 'Y,?LCL-Y
SUB ?LCL-X,1 >?TMP1
SUB ?LCL-Y,1
ICALL MPUTC,?TMP1,STACK
SUB ?LCL-Y,1
ICALL MPUTC,?LCL-X,STACK
ADD ?LCL-X,1 >?TMP1
SUB ?LCL-Y,1
ICALL MPUTC,?TMP1,STACK
SUB ?LCL-X,1
ICALL MPUTC,STACK,?LCL-Y
ADD ?LCL-X,1
ICALL MPUTC,STACK,?LCL-Y
SUB ?LCL-X,1 >?TMP1
ADD ?LCL-Y,1
ICALL MPUTC,?TMP1,STACK
ADD ?LCL-Y,1
ICALL MPUTC,?LCL-X,STACK
ADD ?LCL-X,1 >?TMP1
ADD ?LCL-Y,1
ICALL MPUTC,?TMP1,STACK
ICALL MPUTC,?LCL-X,?LCL-Y,P-MAZE-PARTY
SCREEN S-TEXT
RTRUE
.FUNCT MPUTC:ANY:2:3,X,Y,VAL,OVAL
CALL VALID,X,Y
ZERO? STACK /FALSE
CALL MGETB,X,Y >OVAL
ZERO? VAL \?CND4
SET 'VAL,OVAL
BTST VAL,128 /?CCL8
EQUAL? X,XSTART \?CCL11
EQUAL? Y,YSTART \?CCL11
SET 'VAL,P-MAZE-CASTLE
JUMP ?CND4
?CCL11: EQUAL? X,XGOAL \?CCL15
EQUAL? Y,YGOAL \?CCL15
SET 'VAL,P-MAZE-DOCK
JUMP ?CND4
?CCL15: EQUAL? X,XFISH \?CCL19
EQUAL? Y,YFISH \?CCL19
SET 'VAL,P-MAZE-FISH
JUMP ?CND4
?CCL19: SET 'VAL,P-MAZE-STREET
JUMP ?CND4
?CCL8: SET 'VAL,P-MAZE-WALL
?CND4: BAND OVAL,MWALL
BOR VAL,STACK >VAL
EQUAL? VAL,OVAL /FALSE
ICALL MPUTB,X,Y,VAL
BAND VAL,127
CALL DISPLAY-MAZE-PIC,STACK,Y,X
RSTACK
.FUNCT DISPLAY-MAZE:ANY:0:0,Y,BY,BX,MH,MW,TH,SH,FH,?TMP2,?TMP3,?TMP1
ICALL1 RESET-MARGIN
CLEAR S-TEXT
PICINF P-MAZE-BACKGROUND,YX-TBL /?BOGUS1
?BOGUS1: WINGET S-FULL,WHIGH >FH
WINGET S-STATUS,WHIGH >SH
GET YX-TBL,0 >MH
GET YX-TBL,1 >MW
ADD SH,MH >?TMP1
MUL 2,FONT-Y
ADD ?TMP1,STACK
GRTR? STACK,FH \?CND2
SUB FH,SH >?TMP1
MUL 2,FONT-Y
SUB ?TMP1,STACK >MH
?CND2: WINGET S-TEXT,WWIDE
GRTR? MW,STACK \?CND4
WINGET S-TEXT,WWIDE >MW
?CND4: WINGET S-STATUS,WTOP
ADD STACK,SH >Y
WINGET S-TEXT,WLEFT
ICALL WINDEF,MAZE-WINDOW,Y,STACK,MH,MW
SUB FH,SH >TH
ADD Y,MH >?TMP3
WINGET S-TEXT,WLEFT >?TMP2
SUB TH,MH >?TMP1
WINGET S-TEXT,WWIDE
ICALL WINDEF,S-TEXT,?TMP3,?TMP2,?TMP1,STACK
CLEAR S-TEXT
SCREEN MAZE-WINDOW
PICINF P-MAZE-BOX,MAZE-BOX-TBL /?BOGUS6
?BOGUS6: GET MAZE-BOX-TBL,0 >BY
GET MAZE-BOX-TBL,1 >BX
WINGET MAZE-WINDOW,WHIGH >?TMP1
MUL MAZE-HEIGHT,BY
SUB ?TMP1,STACK >YOFFSET
LESS? YOFFSET,0 \?CCL9
SET 'YOFFSET,0
JUMP ?CND7
?CCL9: DIV YOFFSET,2 >YOFFSET
?CND7: WINGET MAZE-WINDOW,WWIDE >?TMP1
MUL MAZE-WIDTH,BX
SUB ?TMP1,STACK >XOFFSET
LESS? XOFFSET,0 \?CCL12
SET 'XOFFSET,0
JUMP ?CND10
?CCL12: DIV XOFFSET,2 >XOFFSET
?CND10: ICALL1 PRINTM
SCREEN S-TEXT
RTRUE
.FUNCT PRINTM:ANY:0:0,M,OFFS,Y,X
DISPLAY P-MAZE-BACKGROUND,1,1
?PRG1: LESS? Y,MAZE-HEIGHT \TRUE
SET 'X,0
?PRG5: LESS? X,MAZE-WIDTH \?REP6
GETB MAZE-MAP,OFFS
BAND STACK,127 >M
ICALL DISPLAY-MAZE-PIC,M,Y,X
INC 'OFFS
INC 'X
JUMP ?PRG5
?REP6: INC 'Y
JUMP ?PRG1
.FUNCT BUILDMAZE:ANY:0:0,LEFT,PLEN,D,YY,XX,?TMP1
EQUAL? MACHINE,APPLE-2E,APPLE-2C,APPLE-2GS \?CND1
SET 'MAZE-WIDTH,19
SET 'MAZE-HEIGHT,15
?CND1: DIV MAZE-WIDTH,2 >?TMP1
DIV MAZE-HEIGHT,2
MUL ?TMP1,STACK >SIZE
SET 'PMAX,SIZE
SET 'LEFT,SIZE
RANDOM 5
ADD 10,STACK >FLEN
?PRG3: LESS? YY,MAZE-HEIGHT \?REP4
SET 'XX,0
?PRG7: LESS? XX,MAZE-WIDTH \?REP8
ICALL MPUTB,XX,YY,MWALL
INC 'XX
JUMP ?PRG7
?REP8: INC 'YY
JUMP ?PRG3
?REP4: SET 'YY,1
?PRG11: LESS? YY,MAZE-HEIGHT \?REP12
SET 'XX,1
?PRG15: LESS? XX,MAZE-WIDTH \?REP16
ICALL MPUTB,XX,YY,0
ADD XX,2 >XX
JUMP ?PRG15
?REP16: ADD YY,2 >YY
JUMP ?PRG11
?REP12: SUB MAZE-WIDTH,2 >XGOAL
SET 'XSTART,XGOAL
SET 'X,XGOAL
DIV MAZE-HEIGHT,2
SUB STACK,1
RANDOM STACK
MUL STACK,2
ADD STACK,1 >YGOAL
SET 'YSTART,YGOAL
SET 'Y,YGOAL
ICALL MPUTB,X,Y,1
SET 'LEN,1
SET 'LMAX,1
SET 'XX,0
?PRG19: DEC 'LEFT
GRTR? LEFT,0 \?REP20
?PRG23: CALL MGETB,X,Y
ZERO? STACK /?CTR26
LESS? XX,PMAX \?CTR26
CALL FINDMOVE,X,Y >D
LESS? D,0 \?REP24
?CTR26: ICALL1 BACKUP
SET 'XX,0
JUMP ?PRG23
?REP24: ICALL2 REMOVEWALL,D
INC 'XX
JUMP ?PRG19
?REP20: SET 'YY,1
?PRG31: LESS? YY,MAZE-HEIGHT \?REP32
SET 'XX,1
?PRG35: LESS? XX,MAZE-WIDTH \?REP36
ICALL MPUTB,XX,YY,0
ADD XX,2 >XX
JUMP ?PRG35
?REP36: ADD YY,2 >YY
JUMP ?PRG31
?REP32: SET 'XX,0
?PRG39: LESS? XX,MAZE-WIDTH \?REP40
ICALL MPUTB,XX,0,MWALL
SUB MAZE-HEIGHT,1
ICALL MPUTB,XX,STACK,MWALL
INC 'XX
JUMP ?PRG39
?REP40: SET 'YY,1
?PRG43: SUB MAZE-HEIGHT,1
LESS? YY,STACK \?REP44
ICALL MPUTB,0,YY,MWALL
SUB MAZE-WIDTH,1
ICALL MPUTB,STACK,YY,MWALL
INC 'YY
JUMP ?PRG43
?REP44: INC 'XGOAL
CALL MPUTB,XGOAL,YGOAL,0
RSTACK
.FUNCT VISITED:ANY:2:2,XLOC,YLOC
CALL VALID,XLOC,YLOC
ZERO? STACK /TRUE
CALL MGETB,XLOC,YLOC
ZERO? STACK /FALSE
RTRUE
.FUNCT VALID:ANY:2:2,XLOC,YLOC
LESS? XLOC,0 /FALSE
LESS? XLOC,MAZE-WIDTH \FALSE
LESS? YLOC,0 /FALSE
LESS? YLOC,MAZE-HEIGHT /TRUE
RFALSE
.FUNCT FINDMOVE:ANY:2:2,XLOC,YLOC,DV,D,I,?PR-I,?TMP1
RANDOM 23 >DV
?PRG1: LESS? ?PR-I,4 /?CND3
RETURN D
?CND3: GET DIR,DV
GETB STACK,?PR-I >D
GET XOFF2,D
ADD XLOC,STACK >?TMP1
GET YOFF2,D
ADD YLOC,STACK
CALL VISITED,?TMP1,STACK
ZERO? STACK \?CCL7
RETURN D
?CCL7: SET 'D,-1
INC '?PR-I
JUMP ?PRG1
.FUNCT BACKUP:ANY:0:0,D,XX,YY,?PR-D
DEC 'LEN
?PRG1: LESS? ?PR-D,4 \?REP2
GET XOFF2,?PR-D
ADD X,STACK >XX
GET YOFF2,?PR-D
ADD Y,STACK >YY
CALL VALID,XX,YY
ZERO? STACK /?CND5
CALL MGETB,XX,YY
EQUAL? STACK,LEN /?REP2
?CND5: INC '?PR-D
JUMP ?PRG1
?REP2: SET 'X,XX
SET 'Y,YY
RTRUE
.FUNCT REMOVEWALL:ANY:1:1,D,?TMP1
GET XOFF1,D
ADD X,STACK >?TMP1
GET YOFF1,D
ADD Y,STACK
ICALL MPUTB,?TMP1,STACK,0
CALL MGETB,X,Y
ADD STACK,1 >LEN
GET XOFF2,D
ADD X,STACK >X
GET YOFF2,D
ADD Y,STACK >Y
ICALL MPUTB,X,Y,LEN
EQUAL? LEN,FLEN \?CND1
SET 'XFISH,X
SET 'YFISH,Y
?CND1: GRTR? LEN,LMAX \TRUE
SET 'LMAX,LEN
SET 'XSTART,X
SET 'YSTART,Y
RTRUE
.ENDSEG
.ENDI