Debian Codegraph @

terps/alan2/types.h

raw symbols SCIP
1 #ifndef _ATYPES_H_
2 #define _ATYPES_H_
3 /*----------------------------------------------------------------------*\
4
5 types.h
6
7 Header file for the Alan interpreter module.
8
9 \*----------------------------------------------------------------------*/
10
11
12 #include "sysdep.h"
13 #include "acode.h"
14
15
16 /* CONSTANTS */
17
18 #ifndef __mac__
19 #ifndef TRUE
20 #define TRUE (0==0)
21 #endif
22 #ifndef FALSE
23 #define FALSE (!TRUE)
24 #endif
25 #endif
26
27 #define ACTMIN (header->actmin)
28 #define ACTMAX (header->actmax)
29 #define OBJMIN (header->objmin)
30 #define OBJMAX (header->objmax)
31 #define LOCMIN (header->locmin)
32 #define LOCMAX (header->locmax)
33 #define CNTMIN (header->cntmin)
34 #define CNTMAX (header->cntmax)
35 #define LITMIN (header->locmax+1)
36 #define LITMAX (header->locmax+1+litCount)
37 #define EVTMIN (header->evtmin)
38 #define EVTMAX (header->evtmax)
39
40 #define HERO ACTMIN
41
42
43 #define addrTo(x) (&memory[x])
44
45 /* The word classes are represented as numbers but in the dictonary they are generated as bits */
46 #define isVerb(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_VRB))!=0)
47 #define isConj(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_CONJ))!=0)
48 #define isBut(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_BUT))!=0)
49 #define isThem(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_THEM))!=0)
50 #define isIt(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_IT))!=0)
51 #define isNoun(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_NOUN))!=0)
52 #define isAdj(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_ADJ))!=0)
53 #define isPrep(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_PREP))!=0)
54 #define isAll(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_ALL))!=0)
55 #define isDir(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_DIR))!=0)
56 #define isNoise(word) (word < dictsize && (dict[word].class&((Aword)1L<<WRD_NOISE))!=0)
57 #define isLiteral(word) (word >= dictsize)
58
59
60 /* TYPES */
61
62 #ifndef __mac__
63 typedef int Boolean; /* Boolean values within interpreter */
64 #endif
65
66 /* Amachine variables */
67 typedef struct CurVars {
68 int
69 vrb,
70 obj,
71 loc,
72 act,
73 tick,
74 score,
75 visits;
76 } CurVars;
77
78 /* The various tables */
79 typedef struct WrdElem { /* Dictionary */
80 Aaddr wrd; /* ACODE address to string */
81 Aword class; /* Word class */
82 Aword code;
83 Aaddr adjrefs; /* Address to reference list */
84 Aaddr nounrefs; /* Address to reference list */
85 } WrdElem;
86
87 typedef struct ActElem { /* ACTOR TABLE */
88 Aword loc; /* Location */
89 Abool describe; /* Description flag */
90 Aaddr nam; /* Address to name printing code */
91 Aaddr atrs; /* Address to attribute list */
92 Aword cont; /* Code for the container props if any */
93 Aword script; /* Which script is he using */
94 Aaddr scradr; /* Address to script table */
95 Aword step;
96 Aword count;
97 Aaddr vrbs;
98 Aaddr dscr; /* Address of description code */
99 } ActElem;
100
101 typedef struct ScrElem { /* SCRIPT TABLE */
102 Aword code; /* Script number */
103 Aaddr dscr; /* Optional description statements */
104 Aaddr steps; /* Address to steps */
105 } ScrElem;
106
107 typedef struct StepElem { /* STEP TABLE */
108 Aword after; /* After how many ticks? */
109 Aaddr exp; /* Address to expression saying when */
110 Aaddr stm; /* Address to the actual code */
111 } StepElem;
112
113 typedef struct LocElem { /* LOCATION TABLE */
114 Aaddr nams; /* Address of name printing code */
115 Aaddr dscr; /* Address of description code */
116 Aaddr does; /* Address of does code */
117 Aword describe; /* Description flag & counter */
118 Aaddr atrs; /* Address of attribute list */
119 Aaddr exts; /* Address of exit list */
120 Aaddr vrbs; /* Address of local verb list */
121 } LocElem;
122
123 typedef struct ExtElem { /* EXIT TABLE structure */
124 Abool done; /* Flag for reverse/convert process */
125 Aword code; /* Direction code */
126 Aaddr checks; /* Address of check table */
127 Aaddr action; /* Address of action code */
128 Aword next; /* Number of next location */
129 } ExtElem;
130
131 typedef struct ChkElem { /* CHECK TABLE */
132 Aaddr exp; /* ACODE address to expression code */
133 Aaddr stms; /* ACODE address to statement code */
134 } ChkElem;
135
136 typedef struct VrbElem { /* VERB TABLE */
137 Aword code; /* Code for the verb */
138 Aaddr alts; /* Address to alternatives */
139 } VrbElem;
140
141 typedef struct StxElem { /* SYNTAX TABLE */
142 Aword code; /* Code for verb word */
143 Aaddr elms; /* Address to element tables */
144 } StxElem;
145
146 typedef struct ElmElem26 { /* ELEMENT TABLES */
147 Aword code; /* Code for this element, 0 -> parameter */
148 Abool multiple; /* May be multiple (if parameter) */
149 Aaddr next; /* Address to next element table ... */
150 /* ... or class check if EOS */
151 } ElmElem26;
152
153 typedef struct ElmElem { /* ELEMENT TABLES */
154 Aword code; /* Code for this element, 0 -> parameter */
155 Aword flags; /* Flags for multiple/omni (if parameter) */
156 /* CHANGED: v2.7 from Abool for multiple */
157 Aaddr next; /* Address to next element table ... */
158 /* ... or class check if EOS */
159 } ElmElem;
160
161 typedef struct ClaElem { /* CLASS DEFINITION TABLE */
162 Aword code; /* Parameter number */
163 Aword classes; /* Parameter classes */
164 Aaddr stms; /* Exception statements */
165 } ClaElem;
166
167 typedef struct AltElem { /* VERB ALTERNATIVE TABLE */
168 Abool done; /* Flag for patching (reverse/convert) process */
169 Aword param; /* Parameter number */
170 Aword qual; /* Verb execution qualifier */
171 Aaddr checks; /* Address of the check table */
172 Aaddr action; /* Address of the action code */
173 } AltElem;
174
175 typedef struct AtrElem { /* ATTRIBUTE LIST */
176 Aword val; /* Its value */
177 Aaddr stradr; /* Address to the name */
178 } AtrElem;
179
180 typedef struct ObjElem25 { /* OBJECT TABLE of 2.5 format*/
181 Aword loc; /* Current location */
182 Abool describe; /* Describe flag */
183 Aaddr atrs; /* Address of attribute list */
184 Aword cont; /* Index to container properties if any */
185 Aaddr vrbs; /* Address to local verb table */
186 Aaddr dscr1; /* Address to Aword description code */
187 Aaddr dscr2; /* Address to short description code */
188 } ObjElem25;
189
190 typedef struct ObjElem { /* OBJECT TABLE */
191 Aword loc; /* Current location */
192 Abool describe; /* Describe flag */
193 Aaddr atrs; /* Address of attribute list */
194 Aword cont; /* Index to container properties if any */
195 Aaddr vrbs; /* Address to local verb table */
196 Aaddr dscr1; /* Address to Aword description code */
197 Aaddr art; /* Article printing code? Else use default */
198 /* INTRODUCED: v2.6 */
199 Aaddr dscr2; /* Address to short description code */
200 } ObjElem;
201
202 typedef struct CntElem { /* CONTAINER TABLE */
203 Aaddr lims; /* Address to limit check code */
204 Aaddr header; /* Address to header code */
205 Aaddr empty; /* Address to empty code */
206 Aword parent; /* Object or actor index */
207 Aaddr nam; /* Address to statement printing name */
208 } CntElem;
209
210 typedef struct LimElem { /* LIMIT Type */
211 Aword atr; /* Attribute that limits */
212 Aword val; /* And the limiting value */
213 Aaddr stms; /* Statements if fail */
214 } LimElem;
215
216 typedef struct RulElem { /* RULE TABLE */
217 Abool run; /* Is rule already run? */
218 Aaddr exp; /* Address to expression code */
219 Aaddr stms; /* Address to run */
220 } RulElem;
221
222 typedef struct EvtElem { /* EVENT TABLE */
223 Aaddr stradr; /* Address to name string */
224 Aaddr code; /* Address of code to run */
225 } EvtElem;
226
227 typedef struct EvtqElem { /* EVENT QUEUE ELEMENT */
228 int time;
229 int event;
230 int where;
231 } EvtqElem;
232
233 typedef struct IniElem { /* STRING INITIALISATION TABLE */
234 Aword fpos; /* File position */
235 Aword len; /* Length */
236 Aword adr; /* Where to store the string */
237 } IniElem;
238
239 typedef struct MsgElem26 { /* MESSAGE TABLE */
240 Aword fpos; /* File position */
241 Aword len; /* Length of message */
242 } MsgElem26;
243
244 typedef struct MsgElem { /* MESSAGE TABLE */
245 Aaddr stms; /* Address to statements*/
246 /* Changed v2.7 from fpos+len in .dat */
247 } MsgElem;
248
249
250 typedef struct ParamElem { /* PARAMETER */
251 Aword code; /* Code for this parameter (0=multiple) */
252 Aword firstWord; /* Index to first word used by player */
253 Aword lastWord; /* d:o to last */
254 } ParamElem;
255
256 typedef enum Type {TYPNUM, TYPSTR} Type;
257
258 typedef struct LitElem { /* LITERAL */
259 Type type;
260 Aptr value;
261 } LitElem;
262
263 #define MAXPARAMS 9
264 #define MAXENTITY (header->actmax)
265
266 #endif