forked from historicalsource/deadline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.zil
82 lines (67 loc) · 2.25 KB
/
clock.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
"CLOCK for
DEADLINE
Copyright 1982 Infocom, Inc. All rights reserved.
"
<CONSTANT C-TABLELEN 300>
<GLOBAL C-TABLE <ITABLE NONE 300>>
<GLOBAL C-DEMONS 300>
<GLOBAL C-INTS 300>
<CONSTANT C-INTLEN 6>
<CONSTANT C-ENABLED? 0>
<CONSTANT C-TICK 1>
<CONSTANT C-RTN 2>
<ROUTINE DEMON (RTN TICK "AUX" CINT)
#DECL ((RTN) ATOM (TICK) FIX (CINT) <PRIMTYPE VECTOR>)
<PUT <SET CINT <INT .RTN T>> ,C-TICK .TICK>
.CINT>
<ROUTINE QUEUE (RTN TICK "AUX" CINT)
#DECL ((RTN) ATOM (TICK) FIX (CINT) <PRIMTYPE VECTOR>)
<PUT <SET CINT <INT .RTN>> ,C-TICK .TICK>
.CINT>
<ROUTINE INT (RTN "OPTIONAL" (DEMON <>) E C INT)
#DECL ((RTN) ATOM (DEMON) <OR ATOM FALSE> (E C INT) <PRIMTYPE
VECTOR>)
<SET E <REST ,C-TABLE ,C-TABLELEN>>
<SET C <REST ,C-TABLE ,C-INTS>>
<REPEAT ()
<COND (<==? .C .E>
<SETG C-INTS <- ,C-INTS ,C-INTLEN>>
<AND .DEMON <SETG C-DEMONS <- ,C-DEMONS ,C-INTLEN>>>
<SET INT <REST ,C-TABLE ,C-INTS>>
<PUT .INT ,C-RTN .RTN>
<RETURN .INT>)
(<==? <GET .C ,C-RTN> .RTN> <RETURN .C>)>
<SET C <REST .C ,C-INTLEN>>>>
<GLOBAL CLOCK-WAIT <>>
;"SCORE INDICATES HOURS / MOVES = MINUTES"
<GLOBAL SCORE 8>
<GLOBAL MOVES 0>
<ROUTINE CLOCKER ("AUX" C E TICK (FLG <>))
#DECL ((C E) <PRIMTYPE VECTOR> (TICK) FIX (FLG) <OR FALSE ATOM>)
<COND (,CLOCK-WAIT <SETG CLOCK-WAIT <>> <RFALSE>)>
<SETG PRESENT-TIME <+ ,PRESENT-TIME 1>>
<COND (<G? ,PRESENT-TIME 1199>
<TELL
"Chief Inspector Klutz walks up to you, seemingly from out of nowhere.
\"I'm sorry, Inspector, but your time is up here. I'm sorry that you
didn't have any more time to investigate the case. Maybe next time...\"
He escorts you to a waiting police car, in which you go off into the
sunset." CR>
<QUIT>)>
<COND (<G? <SETG MOVES <+ ,MOVES 1>> 59>
<SETG MOVES 0>
<COND (<G? <SETG SCORE <+ ,SCORE 1>> 23>
<SETG SCORE 0>)>)>
<SET C <REST ,C-TABLE <COND (,P-WON ,C-INTS) (T ,C-DEMONS)>>>
<SET E <REST ,C-TABLE ,C-TABLELEN>>
<REPEAT ()
<COND (<==? .C .E> <RETURN .FLG>)
(<NOT <0? <GET .C ,C-ENABLED?>>>
<SET TICK <GET .C ,C-TICK>>
<COND (<0? .TICK>)
(T
<PUT .C ,C-TICK <- .TICK 1>>
<COND (<AND <NOT <G? .TICK 1>>
<APPLY <GET .C ,C-RTN>>>
<SET FLG T>)>)>)>
<SET C <REST .C ,C-INTLEN>>>>