aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/alan3/acode.h
blob: 6e663fabd081db5fa4bbefc77d83927bbc38e331 (plain)
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef GLK_ACODE
#define GLK_ACODE

#include "common/scummsys.h"
#include "common/serializer.h"

namespace Glk {
namespace Alan3 {

#define ACODEEXTENSION ".a3c"

typedef uint32 Aptr;         /* Type for an ACODE memory address used in the structures */
/* TODO: Here's the major 32->64bit problem: Aptrs are 32 bit to fit
   into the 32-bit structure of the Amachine, but sometimes this is
   used to store a *real* pointer value, which on 64-bit machines are
   64bits. */

typedef uint32 Aword;       /* Type for an ACODE word */
typedef uint32 Aaddr;       /* Type for an ACODE address */
typedef uint32 Aid;         /* Type for an ACODE Instance Id value */
typedef int32 Abool;        /* Type for an ACODE Boolean value */
typedef int32 Aint;         /* Type for an ACODE Integer value */
typedef int32 Aset;         /* Type for an ACODE Set value */
typedef int CodeValue;      /* Definition for the packing process */

#ifndef TRUE
#define TRUE (0==0)
#endif
#ifndef FALSE
#define FALSE (!TRUE)
#endif

/* Constants for the Acode file, words/block & bytes/block */
#define BLOCKLEN 256L
#define BLOCKSIZE (BLOCKLEN*sizeof(Aword))


/* Definitions for the packing process */
#define VALUEBITS 16

#define EOFChar 256
#define TOPVALUE (((CodeValue)1<<VALUEBITS) - 1) /* Highest value possible */

/* Half and quarter points in the code value range */
#define ONEQUARTER (TOPVALUE/4+1)   /* Point after first quarter */
#define HALF (2*ONEQUARTER)     /* Point after first half */
#define THREEQUARTER (3*ONEQUARTER) /* Point after third quarter */


/* AMACHINE Word Classes, bit positions */
typedef int WordKind;
#define  SYNONYM_WORD 0
#define  SYNONYM_BIT (((Aword)1)<<SYNONYM_WORD)

#define  ADJECTIVE_WORD (SYNONYM_WORD+1)
#define  ADJECTIVE_BIT (((Aword)1)<<ADJECTIVE_WORD)

#define  ALL_WORD (ADJECTIVE_WORD+1)
#define  ALL_BIT (((Aword)1)<<ALL_WORD)

#define  EXCEPT_WORD (ALL_WORD+1)
#define  EXCEPT_BIT (((Aword)1)<<EXCEPT_WORD)

#define  CONJUNCTION_WORD (EXCEPT_WORD+1)
#define  CONJUNCTION_BIT (((Aword)1)<<CONJUNCTION_WORD)

#define  PREPOSITION_WORD (CONJUNCTION_WORD+1)
#define  PREPOSITION_BIT (((Aword)1)<<PREPOSITION_WORD)

#define  DIRECTION_WORD (PREPOSITION_WORD+1)
#define  DIRECTION_BIT (((Aword)1)<<DIRECTION_WORD)

#define  IT_WORD (DIRECTION_WORD+1)
#define  IT_BIT (((Aword)1)<<IT_WORD)

#define  NOISE_WORD (IT_WORD+1)
#define  NOISE_BIT (((Aword)1)<<NOISE_WORD)

#define  NOUN_WORD (NOISE_WORD+1)
#define  NOUN_BIT (((Aword)1)<<NOUN_WORD)

#define  THEM_WORD (NOUN_WORD+1)
#define  THEM_BIT (((Aword)1)<<THEM_WORD)

#define  VERB_WORD (THEM_WORD+1)
#define  VERB_BIT (((Aword)1)<<VERB_WORD)

#define  PRONOUN_WORD (VERB_WORD+1)
#define  PRONOUN_BIT (((Aword)1)<<PRONOUN_WORD)

#define  WRD_CLASSES (PRONOUN_WORD+1)


/* The #nowhere and NO_LOCATION constants */
#define NO_LOCATION 0
#define NOWHERE 1


/* Syntax element classifications */
// End of file/data
#define EOD (uint32)-1
// End Of Syntax
#define EOS (uint32)-2

/* Syntax element flag bits */
#define MULTIPLEBIT 0x1
#define OMNIBIT 0x2


/* Parameter Classes */
enum ClaKind {      /* NOTE! These must have the same order as */
	CLA_OBJ = 1,            /* the name classes in NAM.H */
	CLA_CNT = (int)CLA_OBJ << 1,
	CLA_ACT = (int)CLA_CNT << 1,
	CLA_NUM = (int)CLA_ACT << 1,
	CLA_STR = (int)CLA_NUM << 1,
	CLA_COBJ = (int)CLA_STR << 1,
	CLA_CACT = (int)CLA_COBJ << 1
};


/* Verb Qualifiers */
enum QualClass {
	Q_DEFAULT,
	Q_AFTER,
	Q_BEFORE,
	Q_ONLY
};


/* The AMACHINE Operations */
enum OpClass {
	C_CONST,
	C_STMOP,
	C_CURVAR
};

/* AMACHINE Text Styles */
enum TextStyle {
	NORMAL_STYLE,
	EMPHASIZED_STYLE,
	PREFORMATTED_STYLE,
	ALERT_STYLE,
	QUOTE_STYLE
};


#define CONSTANT(op) ((Aword)op)
#define INSTRUCTION(op) ((((Aword)C_STMOP)<<28)|((Aword)op))
#define CURVAR(op) ((((Aword)C_CURVAR)<<28)|((Aword)op))

enum InstClass {
	I_LINE,                    /* Source line debug info */
	I_PRINT,                   /* Print a string from the text file */
	I_STYLE,                   /* Set output text style */
	I_QUIT,
	I_LOOK,
	I_SAVE,
	I_RESTORE,
	I_LIST,                     /* List contents of a container */
	I_EMPTY,
	I_SCORE,
	I_VISITS,
	I_SCHEDULE,
	I_CANCEL,
	I_LOCATE,
	I_MAKE,                     /* Set a boolean attribute to the */
	/* value on top of stack */
	I_SET,                      /* Set a numeric attribute to the */
	/* value on top of stack */
	I_SETSTR,                   /* Set a string valued attribute to */
	/* the string on top of stack, */
	/* deallocate current contents first */
	I_SETSET,                   /* Set a Set valued attribute to */
	/* the Set on top of stack, */
	/* deallocate current contents first */
	I_NEWSET,                   /* Push a new, empty set at the top of stack */
	I_ATTRIBUTE,                /* Push the value of an attribute */
	I_ATTRSTR,                  /* Push a copy of a string attribute */
	I_ATTRSET,                  /* Push a copy of a set attribute */
	I_UNION,                    /* Add a set from the top of stack to a */
	/* set valued attribute */
	I_GETSTR,                   /* Get a string contents from text
                                   file, create a copy and push it
                                   on top of stack */
	I_INCR,                     /* Increase an attribute */
	I_DECR,                     /* Decrease a numeric attribute */
	I_INCLUDE,                  /* Include a value in the set on stack top */
	I_EXCLUDE,                  /* Remove a value from the set on stack top */
	I_SETSIZE,                  /* Push number of members in a set */
	I_SETMEMB,                  /* Push the member with index <top>-1
                                   from set <top> */
	I_CONTSIZE,                 /* Push number of members in a container */
	I_CONTMEMB,                 /* Push the member with index <top>-1
                                   from container <top> */
	I_USE,
	I_STOP,
	I_AT,
	I_IN,
	I_INSET,
	I_HERE,
	I_NEARBY,
	I_NEAR,
	I_WHERE,                    /* Current position of an instance */
	I_LOCATION,                 /* The *location* an instance is at */
	I_DESCRIBE,
	I_SAY,
	I_SAYINT,
	I_SAYSTR,
	I_IF,
	I_ELSE,
	I_ENDIF,
	I_AND,
	I_OR,
	I_NE,
	I_EQ,
	I_STREQ,            /* String compare */
	I_STREXACT,         /* Exact match */
	I_LE,
	I_GE,
	I_LT,
	I_GT,
	I_PLUS,
	I_MINUS,
	I_MULT,
	I_DIV,
	I_NOT,
	I_UMINUS,
	I_RND,
	I_RETURN,
	I_SYSTEM,
	I_RESTART,
	I_BTW,
	I_CONTAINS,
	I_DUP,
	I_DEPEND,
	I_DEPCASE,
	I_DEPEXEC,
	I_DEPELSE,
	I_ENDDEP,
	I_ISA,
	I_FRAME,
	I_SETLOCAL,
	I_GETLOCAL,
	I_ENDFRAME,
	I_LOOP,
	I_LOOPNEXT,
	I_LOOPEND,
	I_SUM,                /* Aggregates: */
	I_MAX,
	I_MIN,
	I_COUNT,              /* COUNT aggregate & limit meta-attribute */
	I_SHOW,
	I_PLAY,
	I_CONCAT,
	I_STRIP,
	I_POP,
	I_TRANSCRIPT,
	I_DUPSTR              /* Duplicate the string on the top of the stack */
};

enum SayForm {
	SAY_SIMPLE,
	SAY_DEFINITE,
	SAY_INDEFINITE,
	SAY_NEGATIVE,
	SAY_PRONOUN
};

enum VarClass {
	V_PARAM,
	V_CURLOC,
	V_CURACT,
	V_CURVRB,
	V_SCORE,
	V_CURRENT_INSTANCE,
	V_MAX_INSTANCE
};

/* For transitivity in HERE, IN etc. */
enum ATrans {
	TRANSITIVE = 0,
	DIRECT = 1,
	INDIRECT = 2
};

/* Predefined attributes, one is for containers and the other for locations
   and since instances cannot be both, the attributes can have the same number */
#define OPAQUEATTRIBUTE 1
#define VISITSATTRIBUTE 1
#define PREDEFINEDATTRIBUTES OPAQUEATTRIBUTE

#define I_CLASS(x) ((x)>>28)
#define I_OP(x)    ((x&0x08000000)?(x)|0xf0000000:(x)&0x0fffffff)


/* AMACHINE Table entry types */

#define AwordSizeOf(x) (sizeof(x)/sizeof(Aword))

#include "common/pack-start.h"  // START STRUCT PACKING

struct ArticleEntry {
	Aaddr address;      /* Address of article code */
	Abool isForm;       /* Is the article a complete form? */
} PACKED_STRUCT;

struct ClassEntry { /* CLASS TABLE */
	Aword code;             /* Own code */
	Aaddr id;               /* Address to identifier string */
	Aint parent;            /* Code for the parent class, 0 if none */
	Aaddr name;             /* Address to name printing code */
	Aint pronoun;           /* Code for the pronoun word */
	Aaddr initialize;       /* Address to initialization statements */
	Aaddr descriptionChecks;     /* Address of description checks */
	Aaddr description;           /* Address of description code */
	ArticleEntry definite;       /* Definite article entry */
	ArticleEntry indefinite;     /* Indefinite article entry */
	ArticleEntry negative;       /* Negative article entry */
	Aaddr mentioned;        /* Address of code for Mentioned clause */
	Aaddr verbs;            /* Address of verb table */
	Aaddr entered;          /* Address of code for Entered clause */
} PACKED_STRUCT;

struct InstanceEntry {  /* INSTANCE TABLE */
	Aint code;                  /* Own code */
	Aaddr id;                   /* Address to identifier string */
	Aint parent;                /* Code for the parent class, 0 if none */
	Aaddr name;                 /* Address to name printing code */
	Aint pronoun;               /* Word code for the pronoun */
	Aint initialLocation;       /* Code for current location */
	Aaddr initialize;           /* Address to initialization statements */
	Aint container;             /* Code for a possible container property */
	Aaddr initialAttributes;    /* Address of attribute list */
	Aaddr checks;               /* Address of description checks */
	Aaddr description;          /* Address of description code */
	ArticleEntry definite;      /* Definite article entry */
	ArticleEntry indefinite;    /* Indefinite article entry */
	ArticleEntry negative;      /* Negative article entry */
	Aaddr mentioned;            /* Address to short description code */
	Aaddr verbs;                /* Address of local verb list */
	Aaddr entered;              /* Address of entered code (location only) */
	Aaddr exits;                /* Address of exit list */
} PACKED_STRUCT;

struct AttributeEntry {         /* ATTRIBUTE LIST */
	Aint code;                  /* Its code */
	Aptr value;                 /* Its value, a string has a dynamic
                                   string pointer, a set has a pointer
                                   to a dynamically allocated set */
	Aaddr id;                   /* Address to the name */

	/**
	 * Save/resotre data from save file
	 */
	void synchronize(Common::Serializer &s);
} PACKED_STRUCT;

struct AttributeHeaderEntry {   /* ATTRIBUTE LIST in header */
	Aint code;                          /* Its code */
	Aword value;                /* Its value, a string has a dynamic
                                   string pointer, a set has a pointer
                                   to a dynamically allocated set */
	Aaddr id;                   /* Address to the name */
} PACKED_STRUCT;

struct ExitEntry {  /* EXIT TABLE structure */
	Aword code;             /* Direction code */
	Aaddr checks;           /* Address of check table */
	Aaddr action;           /* Address of action code */
	Aword target;           /* Id for the target location */
} PACKED_STRUCT;


struct RuleEntry {      /* RULE TABLE */
	Abool alreadyRun;
	Aaddr exp;                    /* Address to expression code */
	Aaddr stms;                   /* Address to run */
} PACKED_STRUCT;


#define RESTRICTIONCLASS_CONTAINER (-2)
#define RESTRICTIONCLASS_INTEGER (-3)
#define RESTRICTIONCLASS_STRING (-4)

struct RestrictionEntry {         /* PARAMETER RESTRICTION TABLE */
	Aint parameterNumber;         /* Parameter number */
	Aint _class;                  /* Parameter class code */
	Aaddr stms;                   /* Exception statements */
} PACKED_STRUCT;

struct ContainerEntry { /* CONTAINER TABLE */
	Aword owner;                /* Owner instance index */
	Aint _class;                /* Class to allow in container */
	Aaddr limits;               /* Address to limit check code */
	Aaddr header;               /* Address to header code */
	Aaddr empty;                /* Address to code for header when empty */
	Aaddr extractChecks;        /* Address to check before extracting */
	Aaddr extractStatements;    /* Address to execute when extracting */
} PACKED_STRUCT;


struct ElementEntry {   /* SYNTAX ELEMENT TABLES */
	Aint code;                  /* Code for this element, 0 -> parameter */
	Aword flags;                /* Flags for multiple/omni (if parameter), syntax number/verb of EOS */
	Aaddr next;                 /* Address to next element table ... */
	/* ... or restrictions if code == EOS */
} PACKED_STRUCT;

struct SyntaxEntryPreBeta2 {    /* SYNTAX TABLE */
	Aint code;                          /* Code for verb word */
	Aaddr elms;                         /* Address to element tables */
} PACKED_STRUCT;

struct SyntaxEntry {     /* SYNTAX TABLE */
	Aint code;                   /* Code for verb word, or 0 if starting with parameter */
	Aaddr elms;                  /* Address to element tables */
	Aaddr parameterNameTable;    /* Address to a table of id-addresses giving the names of the parameters */
} PACKED_STRUCT;

struct ParameterMapEntry {  /* PARAMETER MAPPING TABLE */
	Aint syntaxNumber;
	Aaddr parameterMapping;
	Aint verbCode;
} PACKED_STRUCT;

struct EventEntry { /* EVENT TABLE */
	Aaddr id;                   /* Address to name string */
	Aaddr code;
} PACKED_STRUCT;

struct ScriptEntry {    /* SCRIPT TABLE */
	Aaddr id;                   /* Address to name string */
	Aint code;          /* Script number */
	Aaddr description;      /* Optional description statements */
	Aaddr steps;        /* Address to steps */
} PACKED_STRUCT;

struct StepEntry {  /* STEP TABLE */
	Aaddr after;        /* Expression to say after how many ticks? */
	Aaddr exp;          /* Expression to condition saying when */
	Aaddr stms;         /* Address to the actual code */
} PACKED_STRUCT;

struct AltEntry {   /* VERB ALTERNATIVE TABLE */
	Aword qual;         /* Verb execution qualifier */
	Aint param;         /* Parameter number */
	Aaddr checks;       /* Address of the check table */
	Aaddr action;       /* Address of the action code */
} PACKED_STRUCT;

struct SourceFileEntry { /* SOURCE FILE NAME TABLE */
	Aint fpos;
	Aint len;
} PACKED_STRUCT;

struct SourceLineEntry { /* SOURCE LINE TABLE */
	Aint file;
	Aint line;
} PACKED_STRUCT;

struct StringInitEntry { /* STRING INITIALISATION TABLE */
	Aword fpos;                  /* File position */
	Aword len;                   /* Length */
	Aint instanceCode;           /* Where to store it */
	Aint attributeCode;
} PACKED_STRUCT;

struct SetInitEntry {   /* SET INITIALISATION TABLE */
	Aint size;                  /* Size of the initial set */
	Aword setAddress;           /* Address to the initial set */
	Aint instanceCode;          /* Where to store it */
	Aint attributeCode;
} PACKED_STRUCT;

struct DictionaryEntry { /* Dictionary */
	Aaddr string;                /* ACODE address to string */
	Aword classBits;             /* Word class */
	Aword code;
	Aaddr adjectiveRefs;        /* Address to reference list */
	Aaddr nounRefs;             /* Address to reference list */
	Aaddr pronounRefs;          /* Address to reference list */
} PACKED_STRUCT;



/* AMACHINE Header */

struct ACodeHeader {
	/* Important info */
	char tag[4];              /* "ALAN" */
	byte version[4];          /* Version of compiler */
	Aword uid;                /* Unique id of the compiled game */
	Aword size;               /* Size of ACD-file in Awords */
	/* Options */
	Abool pack;               /* Is the text packed and encoded ? */
	Aword stringOffset;       /* Offset to string data in game file */
	Aword pageLength;         /* Length of a displayed page */
	Aword pageWidth;          /* and width */
	Aword debug;              /* Option: debug */
	/* Data structures */
	Aaddr classTableAddress;
	Aword classMax;
	Aword entityClassId;
	Aword thingClassId;
	Aword objectClassId;
	Aword locationClassId;
	Aword actorClassId;
	Aword literalClassId;
	Aword integerClassId;
	Aword stringClassId;
	Aaddr instanceTableAddress; /* Instance table */
	Aword instanceMax;          /* Highest number of an instance */
	Aword theHero;              /* The hero instance code (id) */
	Aaddr containerTableAddress;
	Aword containerMax;
	Aaddr scriptTableAddress;
	Aword scriptMax;
	Aaddr eventTableAddress;
	Aword eventMax;
	Aaddr syntaxTableAddress;
	Aaddr parameterMapAddress;
	Aword syntaxMax;
	Aaddr dictionary;
	Aaddr verbTableAddress;
	Aaddr ruleTableAddress;
	Aaddr messageTableAddress;
	/* Miscellaneous */
	Aint attributesAreaSize;    /* Size of attribute data area in Awords */
	Aint maxParameters;     /* Maximum number of parameters in any syntax */
	Aaddr stringInitTable;  /* String init table address */
	Aaddr setInitTable;     /* Set init table address */
	Aaddr start;        /* Address to Start code */
	Aword maximumScore;     /* Maximum score */
	Aaddr scores;       /* Score table */
	Aint scoreCount;        /* Max index into scores table */
	Aaddr sourceFileTable;  /* Table of fpos/len for source filenames */
	Aaddr sourceLineTable;  /* Table of available source lines to break on */
	Aaddr freq;         /* Address to Char freq's for coding */
	Aword acdcrc;       /* Checksum for acd code (excl. hdr) */
	Aword txtcrc;       /* Checksum for text data file */
	Aaddr ifids;        /* Address to IFIDS */
	Aaddr prompt;
} PACKED_STRUCT;

struct Pre3_0beta2Header {
	/* Important info */
	char tag[4];        /* "ALAN" */
	byte version[4];    /* Version of compiler */
	Aword uid;          /* Unique id of the compiled game */
	Aword size;         /* Size of ACD-file in Awords */
	/* Options */
	Abool pack;         /* Is the text packed ? */
	Aword stringOffset;     /* Offset to string data in game file */
	Aword pageLength;       /* Length of a page */
	Aword pageWidth;        /* and width */
	Aword debug;        /* Option: debug */
	/* Data structures */
	Aaddr classTableAddress;    /* Class table */
	Aword classMax;     /* Number of classes */
	Aword entityClassId;
	Aword thingClassId;
	Aword objectClassId;
	Aword locationClassId;
	Aword actorClassId;
	Aword literalClassId;
	Aword integerClassId;
	Aword stringClassId;
	Aaddr instanceTableAddress; /* Instance table */
	Aword instanceMax;      /* Highest number of an instance */
	Aword theHero;      /* The hero instance code (id) */
	Aaddr containerTableAddress;
	Aword containerMax;
	Aaddr scriptTableAddress;
	Aword scriptMax;
	Aaddr eventTableAddress;
	Aword eventMax;
	Aaddr syntaxTableAddress;
	Aaddr parameterMapAddress;
	Aword syntaxMax;
	Aaddr dictionary;
	Aaddr verbTableAddress;
	Aaddr ruleTableAddress;
	Aaddr messageTableAddress;
	/* Miscellaneous */
	Aint attributesAreaSize;    /* Size of attribute data area in Awords */
	Aint maxParameters;     /* Maximum number of parameters in any syntax */
	Aaddr stringInitTable;  /* String init table address */
	Aaddr setInitTable;     /* Set init table address */
	Aaddr start;        /* Address to Start code */
	Aword maximumScore;     /* Maximum score */
	Aaddr scores;       /* Score table */
	Aint scoreCount;        /* Max index into scores table */
	Aaddr sourceFileTable;  /* Table of fpos/len for source filenames */
	Aaddr sourceLineTable;  /* Table of available source lines to break on */
	Aaddr freq;         /* Address to Char freq's for coding */
	Aword acdcrc;       /* Checksum for acd code (excl. hdr) */
	Aword txtcrc;       /* Checksum for text data file */
	Aaddr ifids;        /* Address to IFIDS */
} PACKED_STRUCT;

struct Pre3_0alpha5Header {
	/* Important info */
	char tag[4];        /* "ALAN" */
	byte version[4];    /* Version of compiler */
	Aword uid;          /* Unique id of the compiled game */
	Aword size;         /* Size of ACD-file in Awords */
	/* Options */
	Abool pack;         /* Is the text packed ? */
	Aword stringOffset;     /* Offset to string data in game file */
	Aword pageLength;       /* Length of a page */
	Aword pageWidth;        /* and width */
	Aword debug;        /* Option: debug */
	/* Data structures */
	Aaddr classTableAddress;    /* Class table */
	Aword classMax;     /* Number of classes */
	Aword entityClassId;
	Aword thingClassId;
	Aword objectClassId;
	Aword locationClassId;
	Aword actorClassId;
	Aword literalClassId;
	Aword integerClassId;
	Aword stringClassId;
	Aaddr instanceTableAddress; /* Instance table */
	Aword instanceMax;      /* Highest number of an instance */
	Aword theHero;      /* The hero instance code (id) */
	Aaddr containerTableAddress;
	Aword containerMax;
	Aaddr scriptTableAddress;
	Aword scriptMax;
	Aaddr eventTableAddress;
	Aword eventMax;
	Aaddr syntaxTableAddress;
	Aaddr parameterMapAddress;
	Aword syntaxMax;
	Aaddr dictionary;
	Aaddr verbTableAddress;
	Aaddr ruleTableAddress;
	Aaddr messageTableAddress;
	/* Miscellaneous */
	Aint attributesAreaSize;    /* Size of attribute data area in Awords */
	Aint maxParameters;     /* Maximum number of parameters in any syntax */
	Aaddr stringInitTable;  /* String init table address */
	Aaddr setInitTable;     /* Set init table address */
	Aaddr start;        /* Address to Start code */
	Aword maximumScore;     /* Maximum score */
	Aaddr scores;       /* Score table */
	Aint scoreCount;        /* Max index into scores table */
	Aaddr sourceFileTable;  /* Table of fpos/len for source filenames */
	Aaddr sourceLineTable;  /* Table of available source lines to break on */
	Aaddr freq;         /* Address to Char freq's for coding */
	Aword acdcrc;       /* Checksum for acd code (excl. hdr) */
	Aword txtcrc;       /* Checksum for text data file */
} PACKED_STRUCT;

#include "common/pack-end.h"    // END STRUCT PACKING

/* Error message numbers */
enum MsgKind {
	M_UNKNOWN_WORD,
	M_WHAT,
	M_WHAT_WORD,
	M_MULTIPLE,
	M_NOUN,
	M_AFTER_BUT,
	M_BUT_ALL,
	M_NOT_MUCH,
	M_WHICH_ONE_START,
	M_WHICH_ONE_COMMA,
	M_WHICH_ONE_OR,
	M_NO_SUCH,
	M_NO_WAY,
	M_CANT0,
	M_SEE_START,
	M_SEE_COMMA,
	M_SEE_AND,
	M_SEE_END,
	M_CONTAINS,
	M_CARRIES,
	M_CONTAINS_COMMA,
	M_CONTAINS_AND,
	M_CONTAINS_END,
	M_EMPTY,
	M_EMPTYHANDED,
	M_CANNOTCONTAIN,
	M_SCORE,
	M_MORE,
	M_AGAIN,
	M_SAVEWHERE,
	M_SAVEOVERWRITE,
	M_SAVEFAILED,
	M_RESTOREFROM,
	M_SAVEMISSING,
	M_NOTASAVEFILE,
	M_SAVEVERS,
	M_SAVENAME,
	M_REALLY,
	M_QUITACTION,
	M_UNDONE,
	M_NO_UNDO,
	M_WHICH_PRONOUN_START,
	M_WHICH_PRONOUN_FIRST,
	M_IMPOSSIBLE_WITH,
	M_CONTAINMENT_LOOP,
	M_CONTAINMENT_LOOP2,
	MSGMAX
};

#define NO_MSG MSGMAX

} // End of namespace Alan3
} // End of namespace Glk

#endif