-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.zil
128 lines (115 loc) · 3.42 KB
/
main.zil
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
<CONSTANT M-FATAL 2>
<CONSTANT M-HANDLED 1>
<CONSTANT M-NOT-HANDLED <>>
<CONSTANT M-BEG 1>
<CONSTANT M-END <>>
<CONSTANT M-ENTER 2>
<CONSTANT M-LOOK 3>
<ROUTINE GO ()
<ENABLE <QUEUE I-FIGHT -1>>
<QUEUE I-SWORD -1>
<ENABLE <QUEUE I-THIEF -1>>
<QUEUE I-LANTERN 200>
<PUTP ,INFLATED-BOAT ,P?VTYPE ,RWATERBIT>
<PUT ,DEF1-RES 1 <REST ,DEF1 2>>
<PUT ,DEF1-RES 2 <REST ,DEF1 4>>
<PUT ,DEF2-RES 2 <REST ,DEF2B 2>>
<PUT ,DEF2-RES 3 <REST ,DEF2B 4>>
<PUT ,DEF3-RES 1 <REST ,DEF3A 2>>
<PUT ,DEF3-RES 3 <REST ,DEF3B 2>>
<SETG HERE ,WEST-OF-HOUSE>
<SETG P-IT-OBJECT ,MAILBOX>
<SETG P-IT-LOC ,HERE>
<COND (<NOT <FSET? ,HERE ,TOUCHBIT>> <V-VERSION> <CRLF>)>
<SETG LIT T>
<SETG WINNER ,ADVENTURER>
<V-LOOK>
<MAIN-LOOP>
<AGAIN>>
<ROUTINE MAIN-LOOP ("AUX" ICNT OCNT NUM CNT OBJ TBL V PTBL OBJ1)
#DECL ((CNT OCNT ICNT NUM) FIX (V) <OR 'T FIX FALSE> (OBJ) <OR FALSE OBJECT>
(OBJ1) OBJECT (TBL) TABLE (PTBL) <OR FALSE ATOM>)
<REPEAT ()
<SET CNT 0>
<SET OBJ <>>
<SET PTBL T>
<COND (<SETG P-WON <PARSER>>
<SET ICNT <GET ,P-PRSI ,P-MATCHLEN>>
<SET NUM
<COND (<0? <SET OCNT <GET ,P-PRSO ,P-MATCHLEN>>> .OCNT)
(<G? .OCNT 1>
<SET TBL ,P-PRSO>
<COND (<0? .ICNT> <SET OBJ <>>)
(T <SET OBJ <GET ,P-PRSI 1>>)>
.OCNT)
(<G? .ICNT 1>
<SET PTBL <>>
<SET TBL ,P-PRSI>
<SET OBJ <GET ,P-PRSO 1>>
.ICNT)
(T 1)>>
<COND (<AND <NOT .OBJ> <1? .ICNT>> <SET OBJ <GET ,P-PRSI 1>>)>
<COND (<==? ,PRSA ,V?WALK> <SET V <PERFORM ,PRSA ,PRSO>>)
(<0? .NUM>
<COND (<0? <BAND <GETB ,P-SYNTAX ,P-SBITS> ,P-SONUMS>>
<SET V <PERFORM ,PRSA>>)
(T
<TELL "I don't know what object you mean.">
<SET V <>>)>)
(T
<REPEAT ()
<COND (<G? <SET CNT <+ .CNT 1>> .NUM> <RETURN>)
(T
<COND (.PTBL <SET OBJ1 <GET ,P-PRSO .CNT>>)
(T <SET OBJ1 <GET ,P-PRSI .CNT>>)>
<COND (<G? .NUM 1>
<PRINTD .OBJ1>
<TELL ": ">)>
<SET V
<PERFORM ,PRSA
<COND (.PTBL .OBJ1) (T .OBJ)>
<COND (.PTBL .OBJ) (T .OBJ1)>>>
<COND (<==? .V ,M-FATAL> <RETURN>)>)>>
<SETG P-IT-OBJECT .OBJ1>
<SETG P-IT-LOC ,HERE>)>
<SETG MOVES <+ ,MOVES 1>>
<COND (<==? .V ,M-FATAL> <SETG P-CONT <>>)>)
(T
<SETG P-CONT <>>)>
<SET V <CLOCKER>>>>
<GLOBAL L-PRSA <>>
<GLOBAL L-PRSO <>>
<GLOBAL L-PRSI <>>
<ROUTINE PERFORM (A "OPTIONAL" (O <>) (I <>) "AUX" V OA OO OI)
#DECL ((A) FIX (O) <OR FALSE OBJECT FIX> (I) <OR FALSE OBJECT> (V) ANY)
<SET OA ,PRSA>
<SET OO ,PRSO>
<SET OI ,PRSI>
<SETG PRSA .A>
<COND (<AND <EQUAL? ,IT .I .O>
<NOT <EQUAL? ,P-IT-LOC ,HERE>>>
<TELL "I don't see what you are referring to." CR>
<RFATAL>)>
<COND (<==? .O ,IT> <SET O ,P-IT-OBJECT>)>
<COND (<==? .I ,IT> <SET I ,P-IT-OBJECT>)>
<SETG PRSO .O>
<SETG PRSI .I>
<COND (<NOT <==? .A ,V?AGAIN>>
<SETG L-PRSA .A>
<SETG L-PRSO .O>
<SETG L-PRSI .I>)>
<COND (<SET V <APPLY <GETP ,WINNER ,P?ACTION>>> .V)
(<SET V <APPLY <GETP <LOC ,WINNER> ,P?ACTION> ,M-BEG>> .V)
(<SET V <APPLY <GET ,PREACTIONS .A>>> .V)
(<AND .I <SET V <APPLY <GETP .I ,P?ACTION>>>> .V)
(<AND .O
<NOT <==? .A ,V?WALK>>
<SET V <APPLY <GETP .O ,P?ACTION>>>>
.V)
(<SET V <APPLY <GET ,ACTIONS .A>>> .V)>
<COND (<NOT <==? .V ,M-FATAL>>
<SET V <APPLY <GETP ,HERE ,P?ACTION> ,M-END>>)>
<SETG PRSA .OA>
<SETG PRSO .OO>
<SETG PRSI .OI>
.V>