forked from historicalsource/seastalker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.zil
161 lines (142 loc) · 4.17 KB
/
macros.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
"MACROS for SEASTALKER
Copyright (c) 1984 Infocom, Inc. All rights reserved."
<SETG C-ENABLED? 0>
<SETG C-ENABLED 1>
<SETG C-DISABLED 0>
<ZSTR-OFF>
<DEFMAC TELL ("ARGS" A)
<FORM PROG ()
!<MAPF ,LIST
<FUNCTION ("AUX" E P O)
<COND (<EMPTY? .A> <MAPSTOP>)
(<SET E <NTH .A 1>>
<SET A <REST .A>>)>
<COND (<TYPE? .E ATOM>
<COND (<OR <=? <SET P <SPNAME .E>>
"CRLF">
<=? .P "CR">>
<MAPRET '<CRLF>>)
;(<=? .P "V">
<MAPRET '<VPRINT>>)
(<=? .P "PRSO">
<MAPRET '<PRSO-PRINT>>)
(<=? .P "PRSI">
<MAPRET '<PRSI-PRINT>>)
(<=? .P "THE-PRSO">
<MAPRET '<THE-PRSO-PRINT>>)
(<=? .P "THE-PRSI">
<MAPRET '<THE-PRSI-PRINT>>)
(<=? .P "FN">
<MAPRET '<PRINT-NAME ,FIRST-NAME>>)
(<=? .P "LN">
<MAPRET '<PRINT-NAME ,LAST-NAME>>)
(<EMPTY? .A>
<ERROR INDICATOR-AT-END? .E>)
(ELSE
<SET O <NTH .A 1>>
<SET A <REST .A>>
<COND (<OR <=? <SET P <SPNAME .E>>
"DESC">
<=? .P "D">
<=? .P "OBJ">
<=? .P "O">>
<MAPRET <FORM PRINTD .O>>)
(<OR <=? .P "A">
<=? .P "AN">>
<MAPRET <FORM PRINTA .O>>)
(<OR <=? .P "T">
<=? .P "THE">>
<MAPRET <FORM PRINTT .O>>)
(<OR <=? .P "NUM">
<=? .P "N">>
<MAPRET <FORM PRINTN .O>>)
(<OR <=? .P "CHAR">
<=? .P "CHR">
<=? .P "C">>
<MAPRET <FORM PRINTC .O>>)
(ELSE
<MAPRET
<FORM PRINT
<FORM GETP .O .E>>>)>)>)
(<TYPE? .E STRING ZSTRING>
<COND ;(<==? 1 <LENGTH .E>>
<MAPRET <FORM PRINTC <ASCII <1 .E>>>>)
(T <MAPRET <FORM PRINTI .E>>)>)
(<TYPE? .E FORM LVAL GVAL>
<MAPRET <FORM PRINT .E>>)
(ELSE <ERROR UNKNOWN-TYPE .E>)>>>>>
<ROUTINE PRINTT (O)
<COND (<EQUAL? .O ,TURN>
<TELL " " N ,P-NUMBER " turns">)
(T
<THE? .O>
<TELL " " D .O>)>>
<ROUTINE PRINTA (O)
<COND (<OR <FSET? .O ,PERSON> <FSET? .O ,NARTICLEBIT>> T)
(<FSET? .O ,VOWELBIT> <TELL "an ">)
(T <TELL "a ">)>
<TELL D .O>>
<DEFMAC VERB? ("TUPLE" ATMS "AUX" (O ()) (L ()))
<REPEAT ()
<COND (<EMPTY? .ATMS>
<RETURN!- <COND (<LENGTH? .O 1> <NTH .O 1>)
(ELSE <FORM OR !.O>)>>)>
<REPEAT ()
<COND (<EMPTY? .ATMS> <RETURN!->)>
<SET ATM <NTH .ATMS 1>>
<SET L
(<CHTYPE <PARSE <STRING "V?"<SPNAME .ATM>>> GVAL>
!.L)>
<SET ATMS <REST .ATMS>>
<COND (<==? <LENGTH .L> 3> <RETURN!->)>>
<SET O (<FORM EQUAL? ',PRSA !.L> !.O)>
<SET L ()>>>
<DEFMAC DOBJ? ("TUPLE" ATMS "AUX" (O ()) (L ()))
<REPEAT ()
<COND (<EMPTY? .ATMS>
<RETURN!- <COND (<LENGTH? .O 1> <NTH .O 1>)
(ELSE <FORM OR !.O>)>>)>
<REPEAT ()
<COND (<EMPTY? .ATMS> <RETURN!->)>
<SET ATM <NTH .ATMS 1>>
<SET L (<CHTYPE .ATM GVAL> !.L)>
<SET ATMS <REST .ATMS>>
<COND (<==? <LENGTH .L> 3> <RETURN!->)>>
<SET O (<FORM EQUAL? ',PRSO !.L> !.O)>
<SET L ()>>>
<DEFMAC IOBJ? ("TUPLE" ATMS "AUX" (O ()) (L ()))
<REPEAT ()
<COND (<EMPTY? .ATMS>
<RETURN!- <COND (<LENGTH? .O 1> <NTH .O 1>)
(ELSE <FORM OR !.O>)>>)>
<REPEAT ()
<COND (<EMPTY? .ATMS> <RETURN!->)>
<SET ATM <NTH .ATMS 1>>
<SET L (<CHTYPE .ATM GVAL> !.L)>
<SET ATMS <REST .ATMS>>
<COND (<==? <LENGTH .L> 3> <RETURN!->)>>
<SET O (<FORM EQUAL? ',PRSI !.L> !.O)>
<SET L ()>>>
<DEFMAC RFATAL ()
'<PROG () <PUSH 2> <RSTACK>>>
<DEFMAC PROB ('BASE? "OPTIONAL" 'LOSER?)
<COND (<ASSIGNED? LOSER?> <FORM ZPROB .BASE?>)
(ELSE <FORM G? .BASE? '<RANDOM 100>>)>>
;<ROUTINE ZPROB (BASE)
<G? .BASE <RANDOM 100>>>
<ROUTINE PICK-ONE (FROB)
<GET .FROB <RANDOM <GET .FROB 0>>>>
<DEFMAC ENABLE ('INT) <FORM PUT .INT ,C-ENABLED? 1>>
<DEFMAC DISABLE ('INT) <FORM PUT .INT ,C-ENABLED? 0>>
<DEFMAC FLAMING? ('OBJ)
<FORM AND <FORM FSET? .OBJ ',FLAMEBIT>
<FORM FSET? .OBJ ',ONBIT>>>
<DEFMAC OPENABLE? ('OBJ)
<FORM OR <FORM FSET? .OBJ ',DOORBIT>
<FORM FSET? .OBJ ',CONTBIT>>>
<DEFMAC ABS ('NUM)
<FORM COND (<FORM L? .NUM 0> <FORM - 0 .NUM>)
(T .NUM)>>
<ZSTR-ON>
<ROUTINE SPLIT-SCREEN? ()
<NOT <==? <BAND <GETB 0 1> 32> 0>>>