-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrealtime.zil
249 lines (213 loc) · 6.12 KB
/
realtime.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
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
"REALTIME for
BORDER ZONE
(c) Copyright 1987 Infocom, Inc. All Rights Reserved."
<GLOBAL CHRONOGRAPH-TIME 0>
<GLOBAL CHRONOGRAPH-ON <>>
<ROUTINE CHRONOGRAPH-TELL ("AUX" N)
<SET N </ <MOD ,CHRONOGRAPH-TIME 3600> 60>>
<COND (<G? .N 59>
<SET N <- .N 60>>)>
<COND (<L? .N 10>
<TELL "0">)>
<TELL N .N ":">
<SET N <MOD ,CHRONOGRAPH-TIME 60>>
<COND (<L? .N 10>
<TELL "0">)>
<TELL N .N>>
<GLOBAL CLOCK-TIME 0>
<GLOBAL CLOCK-TBL <>>
<GLOBAL CLOCK-TBL-1 <TABLE I-TOWER 32767
I-FUSE 32767
I-FUSE 32767>>
<CONSTANT CLOCK-INTS-1 3>
<CONSTANT I-SLOW-CLOCK-OFF 3>
<CONSTANT I-RANDOM-QUEUE-OFF 5>
<GLOBAL CLOCK-TBL-2 <TABLE I-TOWER 32767
I-FUSE 32767
I-DOGS 68
I-SEARCHLIGHTS 1
I-CARS 180
I-30-SECONDS 30
I-200-SECONDS 200>>
<CONSTANT CLOCK-INTS-2 7>
<CONSTANT I-FUSE-OFF 3>
<CONSTANT I-RT-QUEUE-OFF 1>
<GLOBAL CLOCK-INTS <>>
<GLOBAL INT-FLAG T>
<GLOBAL CLOCK-TICKS 0>
<ROUTINE SLOW-CLOCK-QUEUE (FCN TIM "AUX" (OFF ,I-SLOW-CLOCK-OFF))
<PUT ,CLOCK-TBL <- .OFF 1> .FCN>
<PUT ,CLOCK-TBL .OFF .TIM>>
<ROUTINE SLOW-CLOCK-QUEUED? (FCN "AUX" (OFF ,I-SLOW-CLOCK-OFF))
<AND <EQUAL? <GET ,CLOCK-TBL <- .OFF 1>> .FCN>
<NOT <EQUAL? <GET ,CLOCK-TBL .OFF> 32767>>>>
<ROUTINE DE-QUEUE (OFF)
<PUT ,CLOCK-TBL .OFF 32767>>
<ROUTINE DE-RT-QUEUE ()
<DE-QUEUE ,I-RT-QUEUE-OFF>>
<ROUTINE DE-RANDOM-QUEUE ()
<DE-QUEUE ,I-RANDOM-QUEUE-OFF>>
<ROUTINE DE-SLOW-CLOCK-QUEUE ()
<DE-QUEUE ,I-SLOW-CLOCK-OFF>>
<ROUTINE RT-QUEUE (FCN TIM "OPTIONAL" (OFF ,I-RT-QUEUE-OFF))
<PUT ,CLOCK-TBL <- .OFF 1> .FCN>
<PUT ,CLOCK-TBL .OFF <+ <INT-TIME> .TIM>>>
<ROUTINE RANDOM-QUEUE (FCN TIM "AUX" (OFF ,I-RANDOM-QUEUE-OFF))
<PUT ,CLOCK-TBL <- .OFF 1> .FCN>
<PUT ,CLOCK-TBL .OFF <+ <INT-TIME> .TIM>>>
<ROUTINE RT-QUEUED? (FCN "AUX" (OFF ,I-RT-QUEUE-OFF))
<AND <EQUAL? <GET ,CLOCK-TBL <- .OFF 1>> .FCN>
<NOT <EQUAL? <GET ,CLOCK-TBL .OFF> 32767>>>>
<ROUTINE I-CLOCKER ("OPTIONAL" (TICKS 1) "AUX" SCENE CNT TBL TIM)
<SET SCENE ,SCENARIO>
<SET CNT ,CLOCK-INTS>
<SET TBL ,CLOCK-TBL>
<COND (<AND <EQUAL? .TICKS 1> <NOT ,INT-FLAG>>
;"If real-time interrupts are turned off"
<RFALSE>)>
<SETG CLOCK-TICKS .TICKS>
<REPEAT ()
<COND (<NOT <EQUAL? .SCENE ,SCENARIO>>
<COND (<NOT ,PRSA> <SETG READ-INTERRUPTED T>)>
<RETURN>)
(<L? <SET CNT <- .CNT 1>> 0>
<UPDATE-CLOCK .TICKS>
<RETURN>)
(<L? .TICKS <SET TIM <GET .TBL 1>>>
<COND (<NOT <L? <+ .TICKS <MOD ,CLOCK-TIME .TIM>>
.TIM>>
<APPLY <GET .TBL 0>>)>)
(T
<MULTAPPLY <GET .TBL 0> </ .TICKS .TIM>>)>
<SET TBL <REST .TBL 4>>>
;<RFALSE>
,READ-INTERRUPTED>
<ROUTINE UPDATE-CLOCK (TICKS "OPTIONAL" (FORCE? <>))
<SETG CLOCK-TIME <+ ,CLOCK-TIME .TICKS>>
;<COND (,CHRONOGRAPH-ON <UPDATE-CHRONOGRAPH .TICKS .FORCE?>)>
<UPDATE-CHRONOGRAPH .TICKS .FORCE?>
<SETG REAL-UPDATE <+ ,REAL-UPDATE .TICKS>>
<COND (<G? ,REAL-UPDATE 59>
<SETG REAL-UPDATE <MOD ,REAL-UPDATE 60>>
<UPDATE-TIME>)>>
<ROUTINE MULTAPPLY (FCN NUM)
;<COND (,DEBUG <TELL "[MULTAPPLY x " N .NUM "]" CR>)>
<REPEAT ()
<COND (<L? <SET NUM <- .NUM 1>> 0>
<RETURN>)
(T
<APPLY .FCN>)>>>
<GLOBAL REAL-UPDATE 0>
<GLOBAL START-HOUR 17>
<GLOBAL START-MINUTE 44>
<ROUTINE UPDATE-TIME ("AUX" MIN TMP)
<BUFOUT <>>
<SCREEN 1>
<CURSET 1 <- <GETB 0 33> 5>>
<HLIGHT ,H-INVERSE>
<SET MIN <+ </ ,CLOCK-TIME 60> ,START-MINUTE>>
<SET TMP <+ ,START-HOUR </ .MIN 60>>>
<COND (<G? .TMP 23>
<TELL "0">
<SET TMP <- .TMP 24>>)>
<TELL N .TMP ":">
<SET MIN <MOD .MIN 60>>
<COND (<L? .MIN 10> <TELL "0">)>
<TELL N .MIN>
<SCREEN-0>>
<ROUTINE UPDATE-CHRONOGRAPH (TICKS "OPTIONAL" (FORCE? <>) (SCR <>))
<COND (,CHRONOGRAPH-ON
<SCREEN-1>
<SET SCR T>
<COND (<G? <GETB 0 33> 58>
<CURSET 1 <- </ <GETB 0 33> 2> 3>>)
(T
<CURSET 1 27>)>
<SETG CHRONOGRAPH-TIME <+ ,CHRONOGRAPH-TIME .TICKS>>
<COND (<EQUAL? ,SCENARIO 2>
<CHRONOGRAPH-TELL>)
(T
<TELL " ">)>
<TELL " ">)>
<COND (,SL-WATCH
<COND (<NOT .SCR> <SCREEN-1> <SET SCR T>)>
<SL-WATCHER>)>
<COND (<AND ,G-WATCH
<OR .FORCE? <ZERO? <MOD ,CHRONOGRAPH-TIME 5>>>>
<COND (<NOT .SCR> <SCREEN-1> <SET SCR T>)>
<GUARD-WATCHER>)>
<COND (.SCR <SCREEN-0>)>
<RTRUE>>
<ROUTINE I-SEARCHLIGHTS () <TURN-SL> ;<TELL "[SL]" CR>>
<ROUTINE SL-WATCHER ()
<CURSET 2 8>
<TELL <SL-POS-STR-AB 1> " ">
<CURSET 2 <+ </ <GETB 0 33> 2> 2>>
<TELL <SL-POS-STR-AB 2> " ">
<CURSET 2 <- <GETB 0 33> 4>>
<TELL <SL-POS-STR-AB 3> " ">>
<GLOBAL G-WATCH <>>
<GLOBAL GUARD-MARGIN 0>
<ROUTINE GUARD-WATCHER ("OPTIONAL" (INIT? <>) "AUX" MT FACE? OFF SW)
<SET SW <GETB 0 33>>
<COND (,GUARD-MARGIN
<SET OFF ,GUARD-MARGIN>)
(T
<COND (<L? .SW 41>
<SET OFF 2>)
(T
<SET OFF <- </ <- .SW 36> 2> 4>>)>
<SETG GUARD-MARGIN .OFF>)>
<COND (.INIT?
<SCREEN-1>
<CURSET 2 .OFF>
<TELL "T">
<CURSET 2 <+ 18 .OFF>>
<TELL "T">
<CURSET 2 <+ 36 .OFF>>
<TELL "T">
<CURSET 3 <+ .OFF </ <GETP ,HERE ,P?GPOS> 5>>>
<TELL "*">)>
<SET FACE? <GUARDS-FACING-EACH-OTHER?>>
<SET MT <MOD ,CLOCK-TIME 180>>
<COND (<NOT <L? .MT 90>> <SET MT <- 180 .MT>>)>
<COND (,GUARD-CHASE
<SET FACE? T>
<SET MT <- ,GUARD-CHASE <- ,CLOCK-TIME ,GUARD-CHASE-TIME>>>
<SET MT <- 90 .MT>>)>
<COND (,G-WATCH
<CURSET 2 <+ .OFF <- ,G-WATCH 1>>>
<COND (<EQUAL? ,G-WATCH 1 19>
<TELL "T">)
(T <TELL " ">)>
<CURSET 2 <+ .OFF <- 37 ,G-WATCH>>>
<COND (<EQUAL? ,G-WATCH 1 19>
<TELL "T">)
(T <TELL " ">)>)>
<SETG G-WATCH <+ </ .MT 5> 1>>
<CURSET 2 <+ .OFF <- ,G-WATCH 1>>>
<COND (.FACE? <TELL ">">)
(T <TELL "<">)>
<CURSET 2 <+ .OFF <- 37 ,G-WATCH>>>
<COND (.FACE? <TELL "<">)
(T <TELL ">">)>
<COND (.INIT?
<SCREEN-0>)>
<RTRUE>>
<ROUTINE GUARDS-FACING-EACH-OTHER? ()
<ZERO? <MOD </ ,CLOCK-TIME 90> 2>>>
<ROUTINE GUARDS-FACING-PLAYER? ()
<OR <NOT <EQUAL? <GETP ,HERE ,P?GPOS> 90>>
<ZERO? <MOD </ ,CLOCK-TIME 90> 2>>>>
<ROUTINE SCREEN-1 ()
<BUFOUT <>>
<SCREEN 1>
<HLIGHT ,H-INVERSE>>
<ROUTINE SCREEN-0 ()
<HLIGHT ,H-NORMAL>
<SCREEN 0>
<BUFOUT T>>
<ROUTINE HLIGHTELL (STR "OPTIONAL" (HL ,H-ITALIC))
<HLIGHT .HL>
<TELL .STR>
<HLIGHT ,H-NORMAL>>