1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GLK_AGT_AGILITY
24 #define GLK_AGT_AGILITY
25 
26 #include "glk/agt/config.h"
27 #include "common/str.h"
28 
29 namespace Glk {
30 namespace AGT {
31 
32 /* This indicates the AGiliTy version code for the current version. */
33 /*  0=0.8.7 and the numbers are assigned sequentially from there.
34 	1=0.8.8
35 	2=1.0
36 	(pre-0.8.7 versions of AGiliTy don't have version codes) */
37 /* Don't touch this unless you know exactly what you're doing. */
38 #define AGIL_VERID 3
39 
40 /*
41 	This is the master header file for all of the AGT stuff.
42 	  It includes the global variables, the data types, etc.
43 	  (everything that is read in from the game file).
44 	Variables not read in from the game file but used internally
45 	  by the AGiliTy interpreter are declared in interp.h.
46 	Magx specific things are in comp.h.
47 */
48 
49 /* ------------------------------------------------------------------- */
50 /* This is a preprocessor trick to ensure that space is only allocated
51    for global variables once.  'global' should only be defined in one
52    source file; for all of the other modules, it will be converted to
53    extern by the following lines */
54 /* ------------------------------------------------------------------- */
55 #ifndef global    /* Don't touch this */
56 #define global extern
57 #define global_defined_agtread
58 #endif
59 
60 
61 /* ------------------------------------------------------------------- */
62 /* DEFINITIONS OF SPECIAL DATA TYPES                       */
63 /* These should by platform-independent.                               */
64 /* ------------------------------------------------------------------- */
65 
66 #ifdef force16  /* This is for debugging purposes */
67 #define int short int
68 #endif
69 
70 /* General data types */
71 
72 typedef byte uchar;
73 typedef int8 schar;
74 typedef int16 integer;
75 typedef uchar rbool;
76 
77 enum { INT8_MAX_VAL = 127, BYTE_MAX_VAL = 255 };
78 
79 #define WORD_LENG 25
80 
81 /* Game-specific data type */
82 typedef char tline[81]; /* Both of these must include terminating null */
83 typedef char words[WORD_LENG]; /* ...23 in classic, 16 in master's */
84 typedef short word;     /* A pointer into the dictionary */
85 typedef short slist; /* Index into synlist marking beginning of this
86 			synonym list.  [SYNCNT]
87 			list of word pointers -- eg synonyms */
88 typedef char *descr_line; /* This is the type used to return descriptions.
89 				 They are actually returned as an array of
90 				 pointers to char, one for each line.
91 				 It is NULL terminated. */
92 typedef char *filename;  /* Datatype used for picture, sound, etc. names*/
93 
94 
95 typedef enum {fNONE,
96 			  fDA1, fDA2, fDA3, fDA4, fDA5, fDA6, fDSS,
97 			  fHNT, fOPT, fTTL,
98 			  fSAV, fSCR, fLOG,
99 			  fAGX, fINS, fVOC, fCFG,
100 			  fAGT, fDAT, fMSG, fCMD, fSTD, fAGT_STD
101 			 } filetype;
102 
103 
104 /* ------------------------------------------------------------------- */
105 /* GLOBAL FLAGS                                                        */
106 /* Many of the following should be made into command line options      */
107 /* ------------------------------------------------------------------- */
108 
109 /* #define AGT_16BIT */ /* Force interpreter to use 16-bit quantities */
110 /* #define DUMP_VLIST  */ /* Dump out the verb list info */
111 /* #define USE_CMD_INDEX */  /* Read in metacommand index data for objects */
112 
113 
114 #define SS_GRAIN 1024  /* Granularity of size request for static string
115 			  array (to avoid calling rrealloc too often) */
116 #define SYN_GRAIN 32 /* Granularity of requests for synonym array; this
117 			   is in units of sizeof(word) */
118 #define MAX_BADTOK 10  /* How many bad tokens to report before giving
119 			  up */
120 
121 
122 
123 /* The following are defaults that can be overridden from the command line */
124 /* The real variable has the name without the "def_"  */
125 
126 #define def_DIAG 0   /* Print out diagnostic data? */
127 #define def_interp_arg 1  /* Decipher arguments to opcodes? */
128 #define def_debug_da1 0  /* used to analyse .DA1 files */
129 #define def_RAW_CMD_OUT 0  /*Print CMDs out raw, undecoded; sometimes useful
130 			when trying to understand new gamefile version */
131 #define def_ERR_LEVEL 2    /* Level of error reporting. */
132 /* 0== almost none */
133 /* 1== Report possibly serious conditions */
134 /* 2== Report any fall from perfection */
135 
136 
137 
138 
139 
140 
141 
142 /* ------------------------------------------------------------------- */
143 /* DEFINES OF GLOBAL PARAMETERS                                        */
144 /* ------------------------------------------------------------------- */
145 
146 #define FORMAT_CODE 0xFF  /* Character used for special formatting codes:
147 				 --in 1.8x games, it designates bold
148 				 --in AGX+ games, it will prefix format codes
149 				 --otherwise it designates black (replacing
150 				 0, which has obvious problems) */
151 #define LAST_TEXTCODE 8  /* Last ascii code to be used for text attributes */
152 
153 
154 
155 #define MAX_PIX 31
156 #define MAX_FLAG_NOUN 31
157 
158 
159 
160 #define OLD_VERB 59    /* Number of built in verbs in original interpreters--
161 			  this number includes ANY, which is verb 0. */
162 #define DIR_ADDR_CODE (OLD_VERB+17)  /* Verb ID used for direct address */
163 #define AUX_VERB 18    /* Additional verbs supported by the interpreter */
164 #define BASE_VERB (OLD_VERB+AUX_VERB)  /* Total number of built-in verbs */
165 #define DUMB_VERB (DVERB+MAX_SUB)  /* Number of dummy verbs and subroutines */
166 #define TOTAL_VERB (BASE_VERB+DUMB_VERB)  /* Total count of verbs */
167 
168 
169 /* The following numbers refer to the ideal code we are translating into,
170    not the parameters for the actual data file we're reading. */
171 #define MAX_COND 143     /* Last condition token id */
172 #define START_ACT 1000  /* First action code */
173 #define PREWIN_ACT 1161 /* Last action code before WinGame */
174 #define WIN_ACT 2000    /* Value of WinGame opcode */
175 #define END_ACT (WIN_ACT+2)  /* Lowest command-terminating action code */
176 #define MAX_ACT (WIN_ACT+4)  /* Highest action code */
177 
178 /* Note: the following values are used by Magx internally:
179    3000-- Used to mark 'no entry' in the opcode hash table.
180    8000-- Used for NEXT
181    8001-- Used for PREV
182  */
183 
184 #define MAX_TOKEN_ID 250   /* Upper limit on legal (raw) token values
185 				  read from AGT files. Doesn't need to be exact. */
186 
187 /* Number of built in properties and attributes. */
188 #define NUM_PROP 14
189 #define NUM_ATTR 26
190 
191 
192 /*
193    None of these are used any more, but I leave them here for reference
194    #define MAX_ROOM 300
195    #define MAX_NOUN 300
196    #define MAX_CREAT 200
197    #define MAX_CMD 1500
198    #define MAX_QUEST 100
199    #define MAX_MSG 1000
200    #define MAX_PICT 250
201    #define ABS_MAX_REC_CMD 34
202    #define MAX_OBJ (MAX_ROOM+MAX_NOUN+MAX_CREAT)
203    #define SYNCNT 15
204 */
205 
206 
207 
208 /* --------------------------------------------------------------------- */
209 /* DATA STRUCTURE DEFINITIONS                                            */
210 /*                                                                       */
211 /* All of the internal data structures used to store the contents of the */
212 /*   game file                                                           */
213 /* --------------------------------------------------------------------- */
214 
215 /* First, pointers to game descriptions */
216 /*    start and size may be measured in units of characters or in units */
217 /*    of tline  */
218 typedef struct {
219 	long start;
220 	long size;
221 } descr_ptr;
222 
223 
224 /* Entries in the opcode tables:  the name of the opcode, the number of
225    arguments, and the types of those arguments */
226 typedef struct {
227 	const char *opcode;
228 	integer argnum;
229 	integer arg1, arg2;
230 } opdef;  /* Opcode table entry */
231 
232 
233 
234 /* This is the data type for opcode correction entries */
235 /*   These are used to translate the opcodes from the various versions */
236 /*   to a uniform internal format. */
237 /*   The actual translation tables built with this are in agtdata.c */
238 typedef struct {
239 	integer told, tnew; /* Old and new values. */
240 } cmd_fix_rec;
241 
242 typedef const cmd_fix_rec *fix_array;
243 
244 
245 /* ROOMS */
246 typedef struct {
247 	const char *name;  /* [31] */
248 	int32 flag_noun_bits, PIX_bits; /* Master's Ed. only */
249 	slist replacing_word;  /* List of words to be replaced */
250 	word replace_word;   /* Word that does replacing */
251 	word autoverb;     /* Verb automatically executed on entry to room */
252 	integer path[13];
253 	integer key;
254 	integer contents;   /* Used internally by the interpreter; not read in
255 			 from the game file */
256 	integer points;
257 	integer light;  /* Object that lights room; 0=none needed, 1=any */
258 	integer pict, initdesc;
259 	integer oclass;
260 	rbool seen, locked_door;
261 	rbool end, win, killplayer;
262 	rbool unused; /* True if this room entry is unused */
263 } room_rec;
264 
265 
266 /* NOUNS */
267 typedef struct {
268 	const char *shortdesc; /* tline */
269 	const char *position;
270 	/* 23 characters in position for classic ed, 31 for ME */
271 	const char *initpos; /*Starting value of position;used for RESTART/RESTORE*/
272 	int scratch;  /* Scratch space for use by various parser routines. */
273 	slist syns;   /* List of synonyms */
274 	word name, adj;
275 	word related_name;  /* Word that should appear on menu when this noun
276 			  is in scope */
277 	word pos_prep, pos_name;   /* Used internally by the interpreter */
278 	/* pos_prep==-1 means use noun.position */
279 	integer nearby_noun; /* Noun this noun is behind */
280 	integer num_shots;
281 	integer points;
282 	integer weight, size;
283 	integer key;
284 	integer initdesc, pict;
285 	integer location;    /* 1=carried, 1000=worn */
286 	integer contents, next;   /* Used internally by the interpreter; not read in
287 			 from the game file */
288 	integer oclass;
289 	integer flagnum; /* Number of associated flag + 1. 0=no flag. */
290 	rbool scope;   /* Used internally by the interpreter */
291 	rbool isglobal; /* True if global object */
292 	uchar plural;
293 	rbool something_pos_near_noun;  /* Anybody behind us? */
294 	rbool has_syns;
295 	rbool pushable, pullable, turnable, playable, readable;
296 	rbool on, closable, open, lockable, locked, edible, wearable;
297 	rbool drinkable, poisonous, movable, light;
298 	rbool shootable;
299 	rbool win;
300 	rbool unused; /* True if this noun entry is unused */
301 	rbool seen;  /* True if this noun has been seen by the player */
302 	rbool proper;  /* True if noun's name is to be treated as proper noun. */
303 } noun_rec;
304 
305 
306 /* CREATURES */
307 typedef struct {
308 	const char *shortdesc; /* tline */
309 	int scratch;  /* Scratch space for use by various parser routines. */
310 	slist syns;
311 	word name;
312 	word adj;
313 	integer location;
314 	integer contents, next;   /* Used internally by the interpreter; not read in
315 				   from the game file */
316 	integer weapon;  /* Killed by this */
317 	integer points;
318 	integer counter;  /* How many times has player been nasty to it? */
319 	integer threshold, timethresh, timecounter;
320 	integer pict, initdesc;
321 	integer oclass;
322 	integer flagnum; /* Number of associated flag + 1. 0=no flag. */
323 	rbool scope; /* Used internally by the interpreter */
324 	rbool isglobal; /* True if global object */
325 	rbool has_syns;
326 	rbool groupmemb;
327 	rbool hostile;
328 	uchar gender;
329 	rbool unused; /* True if this creature entry is unused */
330 	rbool seen;  /* True if this creature has been seen by the player */
331 	rbool proper; /* True if this creature's name is to be treated as a proper
332 		   noun (i.e. not prepended with "the") */
333 } creat_rec;
334 
335 /* These records are used to hold reference information for
336    user-defined flags and properties */
337 /* These give the base index offset in objflag/objprop of each flag/prop
338  for rooms, nouns, and creatures.  The flag record also contains the
339  bit offset in the given byte. */
340 /* This approach allows for a single property to be located in different
341    places for each of the three types of objects. */
342 /* A value of -1 for any of the three fields indicates that this
343    property doesn't exist for the given type of object. */
344 
345 typedef struct {
346 	long r, n, c;
347 	long str_cnt;  /* values from 0..(str_cnt-1) have assoc strings */
348 	long str_list; /* Index into propstr[] array */
349 } propdef_rec;
350 
351 typedef struct {
352 	long r, n, c;
353 	char rbit, nbit, cbit;
354 	const char *ystr, *nstr; /* Yes and no strings */
355 } attrdef_rec;
356 
357 typedef struct {
358 	long str_cnt;
359 	long str_list;
360 } vardef_rec;
361 
362 
363 typedef struct {
364 	const char *ystr, *nstr;
365 } flagdef_rec;
366 
367 /*  Metacommand headers and a pointer to the actual sequence of tokens
368 	to execute if the metacommand is run. */
369 typedef struct {
370 	integer actor;  /* Contains the actor object number;
371 			   1==self(no explicit actor) 2=anybody
372 			   It is multiplied by negative one for redirected
373 			   commands */
374 	/* 0 in any of the following word variables denotes ANY;
375 	   -1 denotes <*none*> and will only occur in Magx-generated files.
376 	   (verbcmd cannot be equal to -1).  Support for -1 is still experimental */
377 	word verbcmd, nouncmd, objcmd, prep;  /* prep only in ME games */
378 	word noun_adj, obj_adj;  /* Adjectives for noun and obj; not
379 				  supported in original AGT games */
380 	integer noun_obj, obj_obj; /* Actual object numbers,
381 				or 0 if none specified */
382 	integer *data; /* MaxSizeCommand */
383 	integer cmdsize; /* Number of commands */
384 	/*  integer ptr; */ /* In ME games-- see below for replacement */
385 } cmd_rec;
386 
387 
388 /* FRS=file record size; these are the sizes to be allocated to the buffer
389    used to read in the various records from the files; they should be at
390    least as big as the worst case scenario. */
391 #define FRS_ROOM 220
392 #define FRS_NOUN 310
393 #define FRS_CREAT 240
394 #define FRS_CMD 150
395 
396 
397 /* This is the record used to hold menu information for verbs */
398 typedef struct {  /*verb menu entry */
399 	word verb; /* Verb word */
400 	word prep; /* Associated preposition */
401 	short objnum; /* Number of objects */
402 } verbentry_rec;
403 
404 
405 /* This is the datatype that will be used (tenatively) for hint info */
406 /* This isn't implemented yet. */
407 typedef struct {
408 	integer dtype;  /* The hint element type */
409 	integer child;  /* The hint element value */
410 	const char *name; /* The hint element name */
411 } hint_rec;
412 
413 
414 /* This is the data type used to hold information about
415    built-in attributes and properties */
416 struct prop_struct {
417 	const char *name; /* Property name. */
418 	int room, noun, creature; /* Offsets for the various object types. */
419 };
420 
421 
422 /* The following data structure is used to store info on fields of a struct
423    that may need to be read from/written to a file. */
424 /* They are used by both the AGX and the Savefile routines */
425 /* They should be organized in ftype==0 terminated arrays,
426    in the order they occur in the file (the file is assumed to have
427    no padding, so we don't need file offsets: they can be computed) */
428 /* The following is used for both global variables and fields in
429    structures. For global variables, ptr is set to point at the variable
430    and offset is 0. For fields, offset is set to the offset of the field
431    in the structure and ptr is set internally */
432 struct file_info {
433 	int ftype; /* Type in file */
434 	int dtype; /* Data type of field in memory; often ignored */
435 	void *ptr;   /* Pointer to variable */
436 	size_t offset; /* Offset of field in structure */
437 } ;
438 
439 
440 
441 /* This contains all of the information needed to find files. */
442 #ifndef REPLACE_FC
443 struct file_context_rec {
444 	char *gamename;   /* Name as entered by user */
445 	char *path;       /* The path */
446 	char *shortname;  /* The filename w/o directory information */
447 	char *ext;        /* The preexisting extension/prefix */
448 	filetype ft;      /* The filetype corresponding to ext */
449 	int special;      /* Used to mark special files, such as UNIX pipes */
450 };
451 
452 typedef file_context_rec *fc_type;
453 
454 #endif
455 
456 
457 /* ------------------------------------------------------------------- */
458 /* GLOBAL VARIABLES                                                    */
459 /* ------------------------------------------------------------------- */
460 
461 /* ------------------------------------------------------------------- */
462 /* Flags used internally by the interpreter and reading routines */
463 
464 global uchar DIAG, interp_arg, debug_da1, RAW_CMD_OUT;
465 global int ERR_LEVEL;
466 
467 global rbool agx_file;  /* Are we reading an AGX file? */
468 global rbool have_opt;      /* Do we have an OPT file? */
469 global rbool skip_descr; /* Causes read_filerec() to skip over description
470 			   pointers without actually reading them in.
471 			   Used to support RESTORE for multi-part games
472 			   such as Klaustrophobia */
473 global rbool no_auxsyn; /* Prevents building of auxsyn and preplist
474 		  synonym lists; used by agt2agx. */
475 
476 
477 global rbool BATCH_MODE, make_test;
478 /* These indicates we are in testing mode:
479 	 -- The random number generator should be set to a standard state.
480 	 -- Automatically send output to <gamename>.scr
481 	 -- Automatically read/write input from <gamename>.log
482 	  (depending on whether we are in BATCH_MODE or make_test mode,
483 	  respectivly).
484 */
485 
486 
487 /* ------------------------------------------------------------------- */
488 /* Flags reflecting game version and configuration */
489 
490 global rbool have_meta; /* Do we have any metacommands? */
491 global rbool debug_mode, freeze_mode, milltime_mode, bold_mode;
492 global uchar score_mode, statusmode;
493 global rbool intro_first;
494 global rbool box_title;
495 global rbool mars_fix;
496 global rbool fix_ascii_flag;  /* Translate IBM characters?
497 				   Defaults to fix_ascii #define'd above */
498 global rbool dbg_nomsg;  /* Causes printing of <msg> arguments by
499 			   debug disassembler to be supressed */
500 
501 global rbool irun_mode;  /* If true, all messages will be in 1st person */
502 global rbool verboseflag;
503 
504 global int font_status; /* 0=unknown; 1=force fixed font,
505 			   2=allow proportional font. */
506 
507 
508 /*   The following are AGT 'purity' flags; they turn off features of */
509 /* my interpreter that are not fully consistent with the original AGT. */
510 /* They are defined in auxfile.c (see also interp.h and agil.c for */
511 /* interpreter-specific flags)  */
512 /* Anything added here should also be correctly initialized in agt2agx */
513 
514 extern rbool PURE_ANSWER, PURE_TIME, PURE_ROOMTITLE;
515 extern rbool PURE_AND, PURE_METAVERB, PURE_ERROR;
516 extern rbool PURE_SYN, PURE_NOUN, PURE_ADJ, PURE_SIZE;
517 extern rbool PURE_DUMMY, PURE_SUBNAME, PURE_PROSUB;
518 extern rbool PURE_HOSTILE, PURE_GETHOSTILE;
519 extern rbool PURE_DISAMBIG, PURE_ALL, PURE_OBJ_DESC;
520 extern rbool PURE_GRAMMAR, PURE_SYSMSG, PURE_AFTER;
521 extern rbool PURE_PROPER;
522 
523 extern rbool TWO_CYCLE, FORCE_VERSION;
524 extern rbool MASTERS_OR;
525 
526 /* ------------------------------------------------------------------- */
527 /*  Variables containing limits and counts of objects  */
528 
529 global integer FLAG_NUM, CNT_NUM, VAR_NUM;  /* (255, 50, 50) */
530 global integer MAX_USTR;  /* Maximum number of user strings (25)  */
531 global integer MAX_SUB;   /* Number of subroutines (15) */
532 global integer DVERB;     /* Number of real dummy_verbs (50) */
533 global integer NUM_ERR;  /* For ME is 185 */
534 
535 /* Number of objflags and objprops for each type of object */
536 /*  The flag counts are for groups of 8 flags. */
537 global integer num_rflags, num_nflags, num_cflags;
538 global integer num_rprops, num_nprops, num_cprops;
539 global integer oprop_cnt, oflag_cnt; /* Size of flag and property tables */
540 
541 global integer maxroom, maxnoun, maxcreat;
542 global long MaxQuestion;
543 global integer first_room, first_noun, first_creat, last_obj;
544 global long last_message, last_cmd;
545 global long numglobal; /* Number of global nouns */
546 global long maxpict, maxpix, maxfont, maxsong;
547 global long num_prep; /* Number of user-defined prepositions */
548 global int num_auxcomb;
549 global int num_comb;
550 
551 global integer exitmsg_base; /* Number added to messages used as
552 			 "illegal direction" messages */
553 
554 
555 /* ------------------------------------------------------------------- */
556 /*   Miscellaneous other variables read in from the game file */
557 
558 global integer start_room, treas_room, resurrect_room, max_lives;
559 global long max_score;
560 global integer startup_time, delta_time;
561 
562 /* ver contains the size of the game, aver indicates its version */
563 /*  See the #define's below for details */
564 global int ver, aver; /* ver: 0=unknown, 1=small, 2=big, 4=masters1.5 */
565 global long game_sig; /* 2-byte quantity used to identify game files */
566 /* (It's declared long to avoid overflow problems when
567 computing it) */
568 global int vm_size;  /* Size of verb menu */
569 
570 global int min_ver;  /* Lowest version of AGiliTy this will run on. */
571 
572 /* ------------------------------------------------------------------- */
573 /*  Miscellaneous Game Data Structures */
574 
575 /* All of the following are allocated dynamically */
576 global room_rec *room; /* [MAX_ROOM]; */
577 global creat_rec *creature; /* [MAX_CREAT]; */
578 global noun_rec *noun; /* [MAX_NOUN]; */
579 global cmd_rec *command;
580 
581 global unsigned char *objflag;
582 global long *objprop;
583 
584 /* Next we have tables linking abstract flag/property values to
585    the indices with the objflag/objprop arrays. */
586 global attrdef_rec *attrtable;
587 global propdef_rec *proptable;
588 global vardef_rec *vartable; /* For itemized variables */
589 global flagdef_rec *flagtable;
590 
591 /* Output strings associated with various property values. */
592 /*    See propdef_rec */
593 global const char **propstr;
594 global long propstr_size;
595 
596 global tline *userstr; /*[MAX_USTR];*/
597 global word *sub_name;  /* [MAX_SUB] Dictionary id's of all subroutines */
598 
599 /* Verb information */
600 global verbentry_rec *verbinfo; /* Verb information */
601 global short *verbptr, *verbend; /* [TOTAL_VERB] */
602 global slist *synlist;  /* [MAX_VERBS+1];*/
603 global slist *comblist; /* Global combination list */
604 global word *old_agt_verb; /* List of non-canonical verb synonyms in the
605 				  original AGT; these are not allowed to be
606 				  expanded as dummy verbs. */
607 
608 
609 global slist *userprep; /* Array of user-defined prepostions */
610 
611 global word flag_noun[MAX_FLAG_NOUN], *globalnoun;
612 global word pix_name[MAX_PIX];
613 global filename *pictlist, *pixlist, *fontlist, *songlist;
614 
615 global uchar opt_data[14];  /* Contents of OPT file. For the format of this
616 				   block, see the comments to read_opt() in
617 				   agtread.c */
618 
619 /* These are built by reinit_dict */
620 
621 global slist *auxsyn; /* [TOTAL_VERB]  Built-in synonym list */
622 global slist *preplist;  /* [TOTAL_VERB] */
623 global uchar *verbflag;  /* [TOTAL_VERB]  Verb flags; see below */
624 global slist *auxcomb; /* Built-in combination lists (for multi-word
625 			  verbs) */
626 
627 #ifdef PATH_SEP
628 global char **gamepath;
629 #endif
630 
631 /* ------------------------------------------------------------------- */
632 /*  Description Pointers   */
633 
634 
635 global descr_ptr intro_ptr;
636 global descr_ptr title_ptr, ins_ptr; /* Only defined if agx_file is true */
637 global descr_ptr *err_ptr; /* [NUM_ERR];*/
638 
639 global descr_ptr *msg_ptr; /* [MAX_MSG];*/
640 global descr_ptr *help_ptr, *room_ptr, *special_ptr; /*[ROOM] */
641 global descr_ptr *noun_ptr, *text_ptr, *turn_ptr, /* [NOUN] */
642 	   *push_ptr, *pull_ptr, *play_ptr;
643 global descr_ptr *talk_ptr, *ask_ptr, *creat_ptr; /* [CREAT] */
644 
645 global descr_ptr *quest_ptr, *ans_ptr; /* [MAX_QUEST] */
646 global tline *question, *answer; /* [MAX_QUEST] */
647 
648 
649 
650 /* ------------------------------------------------------------------------ */
651 /* Dynamically allocated data blocks (which are pointed to from elsewhere)  */
652 
653 global char **dict;  /* dict[n] points to the nth dictionary word */
654 global long dp;  /* Dictionary pointer: number of words in dict */
655 
656 #define DICT_INIT 12*1024 /* Starting size of dictstr */
657 #define DICT_GRAN 1024  /* Granularity of dictstr size requests
658 			   must be at least 4. */
659 global char *dictstr;  /* Pointer to memory block containing dict words */
660 global long dictstrptr, dictstrsize;
661 /* dictstrptr points to the first unused byte in dictstr.
662    dictstrsize points to the end of the space currently allocated for
663 	  dictstr.
664 */
665 
666 global char *static_str; /*Static string space */
667 global long ss_end; /* Pointer to end of used space in above */
668 global long ss_size; /* Current size of static string space */
669 
670 global word *syntbl;  /* Synonym list space */
671 global slist synptr; /* Points to end of used space */
672 global long syntbl_size; /* Long so we can catch overflows */
673 
674 global long descr_maxmem;
675 global char *mem_descr; /* Copy of descriptor in memory */
676 
677 
678 
679 /* ------------------------------------------------------------------------ */
680 /*  Data structures used internally by agtread.c   */
681 
682 /*The following are all set to NULL after agtread finishes. */
683 global long *cmd_ptr; /* ME only;Points to cmd start locs in gamefile.*/
684 global long *room_name, *noun_sdesc, *noun_pos, *creat_sdesc;
685 global long *t_pictlist, *t_pixlist, *t_songlist, *t_fontlist;
686 
687 /* These are only used by agtout (to allow the AGT reading routines to
688    pass back the count of nouns inside the given object) */
689 global integer *room_inside, *noun_inside, *creat_inside;
690 
691 /* This is used to translate ASCII codes */
692 global uchar fixchar[256];
693 
694 global rbool text_file;  /* Set if we are currently opening a binary file. */
695 #ifdef OPEN_AS_TEXT
696 global rbool open_as_binary;  /* Open text files as binary, anyhow. */
697 #endif
698 
699 
700 /* ------------------------------------------------------------------ */
701 /* SYMBOLIC CONSTANTS: VERSION CODES                                  */
702 /*   These are the values stored in the variable 'aver'.              */
703 /* ------------------------------------------------------------------ */
704 
705 #define AGT10 1     /* SPA */
706 #define AGT118 2    /* TAMORET, PORK II  */
707 #define AGT12  3   /* SOS,... */
708 #define AGTCOS 4   /* COSMOS and SOGGY: enhanced versions of 1.3x */
709 #define AGT135 5   /* By far the most common version; includes practically
710 			  every version of Classic AGT from 1.19 to 1.7 */
711 #define AGT182 6
712 #define AGT183 7
713 #define AGT15 8   /* HOTEL */
714 #define AGT15F 9  /* MDTHIEF */
715 #define AGT16 10  /* PORK  */
716 #define AGTME10 11  /* CLIFF2, ELF20  */
717 #define AGTME10A 12  /* HURRY */
718 #define AGTME15 13    /* WOK */
719 #define AGTME155 14 /* TJA */
720 #define AGTME16 15 /* also includes v1.56 and 1.7 */
721 #define AGX00 16   /* Tenative */
722 
723 #define AGTMAST AGTME16
724 #define AGTCLASS AGT16  /* Dividing line between master's ed and classic */
725 #define AGT18 AGT182  /* Defines lowest 1.8x version */
726 #define AGT18MAX AGT183 /* Defines the highest 1.8x version */
727 #define AGTSTD AGT135  /* "Default" version of AGT */
728 
729 
730 
731 /* ------------------------------------------------------------------ */
732 /* SYMBOLIC CONSTANTS: ARGUMENT TYPES                                 */
733 /*   These are used to encode the argument types of metacommands for  */
734 /*   opcode tables.                                                   */
735 /* ------------------------------------------------------------------ */
736 
737 #define AGT_UNK 0     /* Unknown argument type */
738 
739 /* The following can all mix and match in various ways and so are
740    put together as powers of two. */
741 #define AGT_NONE 1  /* 0 is allowed */
742 #define AGT_SELF 2  /* 1 is allowed */
743 #define AGT_WORN 4  /* 1000 is allowed */
744 #define AGT_ROOM 8  /* A room # is allowed */
745 #define AGT_ITEM 16 /* An item # is allowed */
746 #define AGT_CREAT 32  /* A creature # is allowed */
747 
748 /* AGT_VAR is special, since it is always combined with another type--
749    the type that the variable is expected to be */
750 #define AGT_VAR 64
751 
752 /* The rest of the values are always distinct; they never mix and so
753    they can be given simple consecutive indices */
754 #define AGT_NUM 128
755 #define AGT_FLAG 129
756 #define AGT_QUEST 130   /* Question */
757 #define AGT_MSG 131     /* Message */
758 #define AGT_STR 132    /* String */
759 #define AGT_CNT 133  /* Counter */
760 #define AGT_DIR 134   /* Direction */
761 #define AGT_SUB 135   /* Subroutine */
762 #define AGT_PIC 136    /* Picture */
763 #define AGT_PIX 137   /* Room picture */
764 #define AGT_FONT 138
765 #define AGT_SONG 139
766 #define AGT_ROOMFLAG 140
767 #define AGT_TIME 141
768 #define AGT_ERR 142
769 #define AGT_OBJFLAG 143  /* User defined object flags */
770 #define AGT_OBJPROP 144  /* User defined object properties */
771 #define AGT_ATTR    145  /* Built-in attribute */
772 #define AGT_PROP    146  /* Built-in property */
773 
774 
775 /* These next three may not occur as operand types */
776 #define AGT_EXIT 147  /* Valid values for an exit: room, msg+msgbase, 0 */
777 #define AGT_GENFLAG 148 /* PIX or Room Flag; used internally by compiler */
778 #define AGT_GENPROP 149  /* ObjProp/Property */
779 
780 /* certain restrictions.  Used internally
781 				by the compiler in the parsing
782 				of "[obj].[prop].[prop].[flag]"
783 				constructions. */
784 
785 #define AGT_LVAL   150  /* Used by the compiler in certain psuedo-ops */
786 
787 
788 #define AGT_DEFINE 256
789 
790 
791 
792 /* ------------------------------------------------------------------ */
793 /* Verb flags for verbflag[]; these should be powers of 2 */
794 
795 #define VERB_TAKEOBJ 1
796 #define VERB_META 2
797 #define VERB_MULTI 4  /* Can the verb take mulitple objects? */
798 #define VERB_GLOBAL 8  /* Does the verb have global scope? */
799 
800 /* ------------------------------------------------------------------ */
801 /* SYMBOLIC CONSTANTS: FILE DATA TYPES                                */
802 /*   Data type specifiers for file i/o routines                       */
803 /*   The FT_* constants specify file data types                       */
804 /*   The DT_* constants specify internal data types                   */
805 /* ------------------------------------------------------------------ */
806 
807 #define FT_COUNT 17 /* Number of file data types */
808 
809 #define FT_END 0  /* End of list of fields/variables in file */
810 #define FT_INT16 1   /* DT_SHORT */
811 #define FT_UINT16 2  /* DT_LONG */
812 #define FT_INT32 3   /* DT_LONG */
813 #define FT_UINT32 4
814 #define FT_BYTE 5   /* aka uchar; DT_UCHAR */
815 #define FT_VERSION 6 /* Game version */
816 #define FT_BOOL 7   /* DT_BOOL. Adjacent rbooleans are packed */
817 #define FT_DESCPTR 8  /* DT_DESCPTR */
818 #define FT_STR 9  /* Integer pointer into static string array */
819 #define FT_SLIST 10 /* Synonym list index */
820 #define FT_WORD FT_INT16 /* Index into dictionary */
821 #define FT_PATHARRAY 11 /* 13 integers in an array of directions */
822 #define FT_CMDPTR 12   /* Pointer into command block */
823 #define FT_DICTPTR 13  /* Pointer into dictionary text */
824 #define FT_TLINE 14    /* TextLine */
825 #define FT_CHAR 15     /* Characters. */
826 #define FT_CFG 16      /* Configuration byte; 0=false, 1=true,
827 			  2=none (don't change) */
828 
829 #define DT_DEFAULT 0  /* Default internal type for <ftype> */
830 #define DT_LONG 1
831 #define DT_DESCPTR 2 /* Description pointer, which are treated specially */
832 #define DT_CMDPTR 3  /* Command block pointer, also treated specially */
833 
834 /* This is the end marker for the file definitions used by the file I/O
835    routines */
836 #define endrec {FT_END,0,NULL,0}
837 
838 
839 /* ------------------------------------------------------------------- */
840 /* Date type macros                                                    */
841 /* ------------------------------------------------------------------- */
842 #define troom(x) ((x)>=first_room && (x)<=maxroom)
843 #define tnoun(x) ((x)>=first_noun && (x)<=maxnoun)
844 #define tcreat(x) ((x)>=first_creat && (x)<=maxcreat)
845 
846 
847 /* ------------------------------------------------------------------- */
848 /* FUNCTION PROTOTYPES AND INITIALIZED TABLES                          */
849 /* ------------------------------------------------------------------- */
850 
851 /* This is intended for removing whitespace in AGT data files. */
852 #define rspace(c) ((c)==' ' || (c)=='\t')
853 
854 /* ------------------------------------------------------------------- */
855 /* In GAMEDATA.C                                                       */
856 /* This module contains the major initialized data structures and      */
857 /*  routines to manipulate game data structures, in particular the     */
858 /*  game's dictionary                              */
859 /* ------------------------------------------------------------------- */
860 
861 void init_dict(void); /* 1=set of verblist, 0=don't */
862 void build_verblist(void);  /* Creates verblist */
863 void reinit_dict(void);
864 void free_dict(void);
865 word search_dict(const char *);
866 word add_dict(const char *);
867 const char *gdict(word w);  /* Almost equivalent to dict[w], but with
868 				   some error checking and handling for
869 				   the w==-1 case. */
870 
871 int verb_code(word);
872 int verb_builtin(word);
873 int verb_authorsyn(word);
874 void addsyn(word);
875 slist add_multi_word(word);
876 
877 /* Commands to manipulate object flags */
878 long objextsize(char op);
879 long op_objprop(int op, int obj, int propid, long val);
880 rbool op_objflag(int op, integer obj, int flagid);
881 long lookup_objflag(int id, int t, char *ofs);
882 long lookup_objprop(int id, int t);
883 rbool have_objattr(rbool prop, integer obj, int id);
884 int num_oattrs(int t, rbool isflag);
885 rbool op_simpflag(uchar *flag, char ofs, int op);
886 /* op: 0=clear, 1=set, 2=nop, 3=toggle    two bits: <ab> */
887 const char *get_objattr_str(int dtype, int id, long val);
888 
889 
890 const opdef *get_opdef(integer op);
891 char *objname(int);
892 void sort_cmd(void);
893 
894 void agtwarn(const char *, int elev);
895 void agtnwarn(const char *, int, int elev);
896 
897 void init_flags(void);
898 
899 #ifdef ZIP
900 #define fatal agil_fatal
901 #endif
902 void fatal(const char *);
903 
904 long new_str(char *buff, int max_leng, rbool pasc);
905 
906 descr_line *read_descr(long start, long size);
907 void free_descr(descr_line *p);
908 
909 extern const char trans_ibm[];
910 extern const char nonestr[];
911 
912 /* Tables of opcodes */
913 extern const opdef cond_def[], act_def[], end_def[], illegal_def;
914 
915 /* Table of built in properties and attributes */
916 extern const prop_struct proplist[NUM_PROP];
917 extern const prop_struct attrlist[NUM_ATTR];
918 
919 global words *verblist; /* List of prexisting words, intialized by init_dict */
920 extern const fix_array FIX_LIST[];
921 extern const char *exitname[13];
922 extern const char *verstr[], *averstr[];
923 extern const char *version_str, *portstr;
924 
925 
926 /* ------------------------------------------------------------------- */
927 /* In AGTREAD.C                                                        */
928 /* Routines to read in AGT data files                                  */
929 /* ------------------------------------------------------------------- */
930 
931 void open_descr(fc_type fc);
932 void close_descr(void);
933 descr_line *agt_read_descr(long start, long len);
934 rbool readagt(fc_type fc, rbool diag);
935 void free_all_agtread(void); /* Cleans up everything allocated in agtread
936 				  should only be called at the very end of
937 				  the program */
938 void free_ttl(descr_line *title);
939 
940 
941 /* ------------------------------------------------------------------- */
942 /* In AGXFILE.C                                                    */
943 /*   Routines to read and write AGX files                  */
944 /* ------------------------------------------------------------------- */
945 
946 int read_agx(fc_type fc, rbool diag);
947 descr_line *agx_read_descr(long start, long size);
948 void agx_close_descr(void);
949 
950 /* The following are in the order they should be called */
951 void agx_create(fc_type fc);
952 void write_descr(descr_ptr *dp, descr_line *txt);
953 void agx_write(void);
954 void agx_wclose(void);
955 
956 /* ------------------------------------------------------------------- */
957 /*  In AUXFILE.C                                                       */
958 /*    Routines to read VOC, OPT, CFG, TTL, INS, etc. files             */
959 /* ------------------------------------------------------------------- */
960 void read_opt(fc_type fc);
961 void read_config(genfile cfgfile, rbool lastpass);
962 rbool parse_config_line(char *s, rbool lastpass);
963 
964 descr_line *read_ttl(fc_type fc); /* This returns the title. The return string
965 					  must be freed with free_ttl() and not
966 					  with free_descr */
967 void free_ttl(descr_line *title);
968 
969 void read_voc(fc_type fc);
970 void init_verbrec(void);
971 void add_verbrec(const char *verbline, rbool addnew); /* addnew should be 0 */
972 void finish_verbrec(void);
973 
974 descr_line *read_ins(fc_type fc);
975 void free_ins(descr_line *instr);
976 rbool open_ins_file(fc_type fc, rbool report_error);
977 char *read_ins_line(void); /* Reuses buffer, so return value should be copied
978 			  if it needs to be used past the next call to
979 			  read_ins_line or close_ins_file */
980 void close_ins_file(void);
981 
982 void build_fixchar(void);
983 
984 /* ------------------------------------------------------------------- */
985 /* In or used by DISASSEMBLE.C                             */
986 /*   Routines to disassemble metacommands (used by the interpreter for */
987 /*   tracing and by agtout to produce the metacommand output).         */
988 /* ------------------------------------------------------------------- */
989 
990 global rbool *dbgflagptr;
991 global long *dbgvarptr;
992 global short  *dbgcntptr;
993 
994 void dbgprintf(const char *fmt, ...);
995 void debugout(const char *s);
996 int argout(int dtype, int dval, int optype);
997 
998 /* ------------------------------------------------------------------- */
999 /* In INTERFACE.C, AGIL.C and/or AGILSTUB.C                            */
1000 /*   agilstub.c provides minimal versions of these routines for use by */
1001 /*   programs other than the interpreter                       */
1002 /* ------------------------------------------------------------------- */
1003 
1004 void writeln(const char *s);
1005 void writestr(const char *s);
1006 void agil_option(int optnum, char *optstr[], rbool setflag, rbool lastpass);
1007 void close_interface(void);
1008 
1009 void print_tos(void); /* Called by the disassembler; in either TOKEN.C
1010 			 or AGTOUT.C */
1011 
1012 
1013 /* ------------------------------------------------------------------- */
1014 /* In UTIL.C                                   */
1015 /*   Low-level utilites, including memory allocation, string manip.,   */
1016 /*   and buffered file I/O.                        */
1017 /* ------------------------------------------------------------------- */
1018 
1019 global uchar trans_ascii[256];  /* Table to translate ascii values read
1020 				   in from file */
1021 
1022 void build_trans_ascii(void); /* Set up the above table. */
1023 
1024 void rprintf(const char *fmt, ...); /* General output routine, mainly used
1025 					   for diagnostics. There can be a newline
1026 					   at the end, but there shouldn't be
1027 					   one in the middle of the string */
1028 
1029 
1030 
1031 /* Memory management variables and routines */
1032 
1033 extern rbool rm_trap; /* Trap memory allocation failures? */
1034 global rbool rm_acct; /* Turn on rmem accounting, to locate memory leaks */
1035 global long rfree_cnt, ralloc_cnt; /* # of allocs/frees since acct turned on */
1036 global long rm_size, rm_freesize; /* These hold worst case values */
1037 
1038 long get_rm_size(void);   /* These get the current values */
1039 long get_rm_freesize(void);
1040 void *rmalloc(long size);
1041 void r_free(void *p);
1042 #define rfree(p) (r_free(p),p=NULL) /* Traps errors & catch memory leaks */
1043 void *rrealloc(void *p, long size);
1044 char *rstrdup(const char *s);
1045 
1046 
1047 /* String utilities */
1048 
1049 char *concdup(const char *s1, const char *s2); /* Concacate and duplicate */
1050 char *rstrncpy(char *dest, const char *src, int max);
1051 /* Copy at most max-1 characters */
1052 rbool match_str(const char **pstr, const char *match);
1053 
1054 #ifdef NEED_STR_CMP
1055 #undef strcasecmp
1056 //define strcasecmp Common::scumm_strcasecmp
1057 extern int strcasecmp(const char *s1, const char *s2);
1058 #endif
1059 #ifdef NEED_STRN_CMP
1060 #undef strncasecmp
1061 //define strncasecmp Common::scumm_strnicmp
1062 extern int strncasecmp(const char *s1, const char *s2, size_t len);
1063 #endif
1064 
1065 #undef isspace
1066 #define isspace Common::isSpace
1067 #undef isprint
1068 #define isprint Common::isPrint
1069 #undef isalpha
1070 #define isalpha Common::isAlpha
1071 #undef isalnum
1072 #define isalnum Common::isAlnum
1073 #undef islower
1074 #define islower Common::isLower
1075 #undef isupper
1076 #define isupper Common::isUpper
1077 #undef ispunct
1078 #define ispunct Common::isPunct
1079 
1080 /* The fixsign.. routines put together unsigned bytes to form signed ints */
1081 
1082 #ifndef FAST_FIXSIGN
1083 short fixsign16(uchar n1, uchar n2);
1084 long fixsign32(uchar n1, uchar n2, uchar n3, uchar n4);
1085 #else
1086 #define fixsign16(u1,u2) ( (u1) | ((u2)<<8) )
1087 #define fixsign32(u1,u2,u3,u4)  ( ((long)u1) | (((long)u2)<<8) | \
1088 								  (((long)u3)<<16) | (((long)u4)<<24) )
1089 #endif
1090 
1091 
1092 /* Miscellaneous */
1093 long rangefix(long n);
1094 
1095 /* File routines */
1096 genfile openfile(fc_type fc, filetype ext, const char *err, rbool ferr);
1097 genfile openbin(fc_type fc, filetype ext, const char *err, rbool ferr);
1098 
1099 #undef fopen
1100 genfile fopen(const char *name, const char *how);
1101 #undef fseek
1102 int fseek(genfile stream, long int offset, int whence);
1103 #undef fread
1104 size_t fread(void *ptr, size_t size, size_t nmemb, genfile stream);
1105 #undef fwrite
1106 size_t fwrite(const void *ptr, size_t size, size_t nmemb, genfile stream);
1107 #undef fclose
1108 #define fclose(f) delete f
1109 #undef ftell
1110 size_t ftell(genfile f);
1111 
1112 char *readln(genfile f, char *buff, int n);
1113 /* Read a line from a 'text' file */
1114 
1115 /* (None of the following routines are at all reentrant) */
1116 long buffopen(fc_type fc, filetype ext,
1117 			  long minbuffsize, const char *rectype, long recnum);
1118 /* Open file for our buffered routines and make it our current file;
1119 returns the record size. Prints out error message on failure
1120 rectype="noun","room",etc.; recnum=expected # of objects in file */
1121 uchar *buffread(long index);
1122 /* seek to index*recsize, read buff_rsize bytes, return pointer to a
1123    buffer with them. */
1124 void buffclose(void); /* Close the current file */
1125 
1126 void bw_open(fc_type fc, filetype ext); /* Open buffered file for writing */
1127 void bw_close(void); /* Close buffered file */
1128 
1129 /* "Universal" file routines */
1130 extern const size_t ft_leng[FT_COUNT];  /* File lengths of the data types */
1131 long compute_recsize(file_info *recinfo);
1132 void *read_recblock(void *base, int ftype, long numrec, long offset,
1133 					long blocksize);
1134 /* Only works for FT_BYTE, FT_SLIST, FT_WORD, FT_DICTTEXT, FT_INT16 */
1135 void *read_recarray(void *base, long eltsize, long numelts,
1136 					file_info *field_info, const char *rectype,
1137 					long file_offset, long file_blocksize);
1138 void read_globalrec(file_info *global_info, const char *rectype,
1139 					long file_offset, long file_blocksize);
1140 
1141 long write_recarray(void *base, long eltsize, long numelts,
1142 					file_info *field_info, long file_offset);
1143 long write_globalrec(file_info *global_info, long file_offset);
1144 long write_recblock(void *base, int ftype, long numrec, long offset);
1145 
1146 char *textgets(genfile f, char *buf, size_t n);
1147 char textgetc(genfile f);
1148 void textungetc(genfile f, char c);
1149 bool texteof(genfile f);
1150 void textputs(genfile f, const char *s);
1151 
1152 void set_internal_buffer(void *p);
1153 /* Causes all of the above routines to write to the block of memory pointed
1154    at by p instead of to a file */
1155 
1156 #ifdef PROFILE_SUPPORT
1157 /* These are functions to do quick-and-dirty timing of routines;
1158    I added them to check the performance of the AGX code.
1159    They aren't likely to work on anything other than a *nix box */
1160 void resetwatch(void);
1161 void startwatch(void);
1162 char *stopwatch(void);
1163 char *timestring(void);
1164 #define runwatch(cmd) do{resetwatch();cmd;printf("%s\n",stopwatch());}while(0)
1165 #else
1166 #define runwatch(cmd) cmd
1167 #endif
1168 
1169 
1170 
1171 /* ------------------------------------------------------------------- */
1172 /* In FILENAME.C                               */
1173 /*   The low-level file routines                                       */
1174 /* ------------------------------------------------------------------- */
1175 
1176 fc_type init_file_context(const char *game_name, filetype ft);
1177 /* This sets up the filename system, based around a game with name
1178    "gamename".  Must be called before any of the following are called
1179    with relative filetypes (all filetypes that depend on the game's
1180    name and location-- everything but the global config file.)  */
1181 /* ft indicates the file type class. At the moment, it can be
1182    fAGX, fSAV, fSCR, fLOG
1183 	  */
1184 void fix_file_context(fc_type fc, filetype ft);
1185 fc_type convert_file_context(fc_type fc, filetype ft, const char *name);
1186 void release_file_context(fc_type *pfc);
1187 
1188 
1189 char *formal_name(fc_type fc, filetype ft); /* Used for messages */
1190 genfile badfile(filetype ft);   /* Bad file of type ft */
1191 rbool fileexist(fc_type fc, filetype ft);
1192 
1193 genfile readopen(fc_type fc, filetype ft, const char **errstr);
1194 genfile writeopen(fc_type fc, filetype ft,
1195 				  file_id_type *pfileid, const char **errstr);
1196 rbool filevalid(genfile f, filetype ft);
1197 void readclose(genfile f);
1198 void writeclose(genfile f, file_id_type fileid);
1199 
1200 void binseek(genfile f, long offset);
1201 rbool binread(genfile f, void *buff, long recsize, long recnum, const char **errstr);
1202 long varread(genfile f, void *buff, long recsize, long recnum, const char **errstr);
1203 rbool binwrite(genfile f, void *buff, long recsize, long recnum, rbool ferr);
1204 long binsize(genfile f); /* Size of an open binary file */
1205 
1206 rbool textrewind(genfile f);
1207 
1208 char *assemble_filename(const char *path, const char *root,
1209 						const char *ext);
1210 
1211 
1212 #ifdef global_defined_agtread
1213 #undef global
1214 #undef global_defined_agtread
1215 #endif
1216 
1217 } // End of namespace AGT
1218 } // End of namespace Glk
1219 
1220 #endif
1221