aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/alan2/main.h
blob: c7bdefc509e1495b1b5f5178f0bcc87bf6363d5f (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
/* 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_ALAN2_MAIN
#define GLK_ALAN2_MAIN

/* Header file for main unit of ARUN Alan System interpreter */

#include "common/file.h"
#include "glk/alan2/types.h"
#include "glk/jumps.h"

namespace Glk {
namespace Alan2 {

/* DATA */

#define MEMORYSIZE 1000L

extern Aaddr memTop;        // Top of memory

extern int conjWord;        // First conjunction in dictionary

/* The Amachine memory */
extern Aword *memory;
extern AcdHdr *header;

/* Amachine variables */
extern CurVars cur;

/* Amachine data structures */
extern WrdElem *dict;       /* Dictionary pointer */
extern ActElem *acts;       /* Actor table pointer */
extern LocElem *locs;       /* Location table pointer */
extern VrbElem *vrbs;       /* Verb table pointer */
extern StxElem *stxs;       /* Syntax table pointer */
extern ObjElem *objs;       /* Object table pointer */
extern CntElem *cnts;       /* Container table pointer */
extern RulElem *ruls;       /* Rule table pointer */
extern EvtElem *evts;       /* Event table pointer */
extern MsgElem *msgs;       /* Message table pointer */
extern Aword *scores;       /* Score table pointer */
extern Aword *freq;     /* Cumulated frequencies */

extern int dictsize;        /* Number of entries in dictionary */

/* The text and message file */
extern Common::File *txtfil;
extern Common::WriteStream *logfil;
extern Common::SeekableReadStream *codfil;

#undef ftell
#undef fgetc
#undef getc
#undef fseek
#undef fclose
#define ftell(FP) FP->pos()
#define fgetc(FP) (FP->pos() >= FP->size()) ? EOD : FP->readByte()
#define getc(FP) (FP->pos() >= FP->size()) ? EOD : FP->readByte()
#define fseek(FP, OFS, WHENCE) FP->seek(OFS, WHENCE)
#define fclose(FP) delete FP


/* File names */
extern const char *advnam;

/* Screen formatting info */
extern int col, lin;

extern Boolean verbose, errflg, trcflg, dbgflg, stpflg, logflg, statusflg;
extern Boolean fail;
extern Boolean anyOutput;
extern Boolean needsp;

#define endOfTable(x) eot((Aword *) x)

extern void *allocate(unsigned long len);
extern void terminate(CONTEXT, int code);
extern void usage(void);
extern void error(CONTEXT, MsgKind msg);
extern void syserr(const char *msg);
extern void statusline(void);
extern void output(const char string[]);
extern void prmsg(MsgKind msg);
extern void para(void);
extern void newline(void);

extern Boolean checklim(Aword cnt, Aword obj);
extern Boolean possible(void);
extern Boolean exitto(int to, int from);
extern void action(CONTEXT, ParamElem *plst);
extern void go(CONTEXT, int dir);

extern Boolean eot(Aword *adr);
extern Boolean isObj(Aword x);
extern Boolean isCnt(Aword x);
extern Boolean isAct(Aword x);
extern Boolean isLoc(Aword x);
extern Boolean isLit(Aword x);
extern Boolean isNum(Aword x);
extern Boolean isStr(Aword x);

/* Run the game! */
extern void run(void);

} // End of namespace Alan2
} // End of namespace Glk

#endif