GLK: ALAN2: astyle formatting

This commit is contained in:
dreammaster 2019-06-22 03:43:17 +01:00 committed by Paul Gilbert
parent a3fa9d12a9
commit 2450df501c
26 changed files with 3964 additions and 3956 deletions

View File

@ -47,32 +47,32 @@ typedef int CodeValue; /* Definition for the packing process */
#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 */
#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 */
typedef int WrdKind;
#define WRD_SYN 0 /* 1 - Synonym */
#define WRD_ADJ 1 /* 2 - Adjective */
#define WRD_ALL 2 /* 4 - All */
#define WRD_BUT 3 /* 8 - But */
#define WRD_CONJ 4 /* 16 - Conjunction */
#define WRD_PREP 5 /* 32 - Preposition */
#define WRD_DIR 6 /* 64 - Direction */
#define WRD_IT 7 /* 128 - It */
#define WRD_NOISE 8 /* 256 - Noise word */
#define WRD_NOUN 9 /* 512 - Noun */
#define WRD_ACT 10 /* 1024 - Actor */
#define WRD_THEM 11 /* 2048 - Them */
#define WRD_VRB 12 /* 4096 - Verb */
#define WRD_SYN 0 /* 1 - Synonym */
#define WRD_ADJ 1 /* 2 - Adjective */
#define WRD_ALL 2 /* 4 - All */
#define WRD_BUT 3 /* 8 - But */
#define WRD_CONJ 4 /* 16 - Conjunction */
#define WRD_PREP 5 /* 32 - Preposition */
#define WRD_DIR 6 /* 64 - Direction */
#define WRD_IT 7 /* 128 - It */
#define WRD_NOISE 8 /* 256 - Noise word */
#define WRD_NOUN 9 /* 512 - Noun */
#define WRD_ACT 10 /* 1024 - Actor */
#define WRD_THEM 11 /* 2048 - Them */
#define WRD_VRB 12 /* 4096 - Verb */
#define WRD_CLASSES 13
/* Syntax element classifications */
#define EOS (-2) /* End Of Syntax */
#define EOS (-2) /* End Of Syntax */
/* Syntax element flag bits */
#define MULTIPLEBIT 0x1
@ -80,210 +80,210 @@ typedef int WrdKind;
/* Parameter Classes */
typedef 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
typedef 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
} ClaKind;
/* Verb Qualifiers */
typedef enum QualClass {
Q_DEFAULT,
Q_AFTER,
Q_BEFORE,
Q_ONLY
Q_DEFAULT,
Q_AFTER,
Q_BEFORE,
Q_ONLY
} QualClass;
/* The AMACHINE Operations */
typedef enum OpClass {
C_CONST,
C_STMOP,
C_CURVAR
C_CONST,
C_STMOP,
C_CURVAR
} OpClass;
typedef enum InstClass {
I_PRINT, /* Print a string from the text file */
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,
I_SET, /* Set a numeric attribute to the */
/* value on top of stack */
I_STRSET, /* Set a string valued attribute to a */
/* copy of the string on top of stack, */
/* deallocate current contents first */
I_GETSTR, /* Get a string contents from text */
/* file, create a copy and push it */
/* on top of stack */
I_INCR, /* Increment an attribute */
I_DECR, /* Decrement a numeric attribute */
I_USE,
I_IN,
I_DESCRIBE,
I_SAY,
I_SAYINT,
I_SAYSTR,
I_IF,
I_ELSE,
I_ENDIF,
I_ATTRIBUTE,
I_STRATTR, /* Push a copy of a string attribute */
I_HERE,
I_NEAR,
I_WHERE,
I_AND,
I_OR,
I_NE,
I_EQ,
I_STREQ, /* String compare */
I_STREXACT,
I_LE,
I_GE,
I_LT,
I_GT,
I_PLUS,
I_MINUS,
I_MULT,
I_DIV,
I_NOT,
I_UMINUS,
I_RND,
I_SUM, /* SUM-aggregate */
I_MAX, /* MAX-aggregate */
I_COUNT, /* COUNT-aggregate */
I_RETURN,
I_SYSTEM,
I_RESTART, /* INTRODUCED: v2.7 */
I_BTW, /* INTRODUCED: v2.8 */
I_CONTAINS, /* -""- */
I_DEPSTART, /* -""- */
I_DEPCASE, /* -""- */
I_DEPEXEC, /* -""- */
I_DEPELSE, /* -""- */
I_DEPEND /* -""- */
I_PRINT, /* Print a string from the text file */
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,
I_SET, /* Set a numeric attribute to the */
/* value on top of stack */
I_STRSET, /* Set a string valued attribute to a */
/* copy of the string on top of stack, */
/* deallocate current contents first */
I_GETSTR, /* Get a string contents from text */
/* file, create a copy and push it */
/* on top of stack */
I_INCR, /* Increment an attribute */
I_DECR, /* Decrement a numeric attribute */
I_USE,
I_IN,
I_DESCRIBE,
I_SAY,
I_SAYINT,
I_SAYSTR,
I_IF,
I_ELSE,
I_ENDIF,
I_ATTRIBUTE,
I_STRATTR, /* Push a copy of a string attribute */
I_HERE,
I_NEAR,
I_WHERE,
I_AND,
I_OR,
I_NE,
I_EQ,
I_STREQ, /* String compare */
I_STREXACT,
I_LE,
I_GE,
I_LT,
I_GT,
I_PLUS,
I_MINUS,
I_MULT,
I_DIV,
I_NOT,
I_UMINUS,
I_RND,
I_SUM, /* SUM-aggregate */
I_MAX, /* MAX-aggregate */
I_COUNT, /* COUNT-aggregate */
I_RETURN,
I_SYSTEM,
I_RESTART, /* INTRODUCED: v2.7 */
I_BTW, /* INTRODUCED: v2.8 */
I_CONTAINS, /* -""- */
I_DEPSTART, /* -""- */
I_DEPCASE, /* -""- */
I_DEPEXEC, /* -""- */
I_DEPELSE, /* -""- */
I_DEPEND /* -""- */
} InstClass;
typedef enum VarClass {
V_PARAM,
V_CURLOC,
V_CURACT,
V_CURVRB,
V_SCORE
V_PARAM,
V_CURLOC,
V_CURACT,
V_CURVRB,
V_SCORE
} VarClass;
#define I_CLASS(x) ((x)>>28)
#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
#include "common/pack-start.h" // START STRUCT PACKING
#include "common/pack-start.h" // START STRUCT PACKING
/**
* Game header
* Game header
*/
struct AcdHdr {
/* Important info */
char vers[4]; /* 01 - Version of compiler */
Aword size; /* 02 - Size of ACD-file in Awords */
char vers[4]; /* 01 - Version of compiler */
Aword size; /* 02 - Size of ACD-file in Awords */
/* Options */
Abool pack; /* 03 - Is the text packed ? */
Aword paglen; /* 04 - Length of a page */
Aword pagwidth; /* 05 - and width */
Aword debug; /* 06 - Option debug */
Abool pack; /* 03 - Is the text packed ? */
Aword paglen; /* 04 - Length of a page */
Aword pagwidth; /* 05 - and width */
Aword debug; /* 06 - Option debug */
/* Data structures */
Aaddr dict; /* 07 - Dictionary */
Aaddr oatrs; /* 08 - Object default attributes */
Aaddr latrs; /* 09 - Location default attributes */
Aaddr aatrs; /* 0a - Actor default attributes */
Aaddr acts; /* 0b - Actor table */
Aaddr objs; /* 0c - Object table */
Aaddr locs; /* 0d - Location table */
Aaddr stxs; /* 0e - Syntax table */
Aaddr vrbs; /* 0f - Verb table */
Aaddr evts; /* 10 - Event table */
Aaddr cnts; /* 11 - Container table */
Aaddr ruls; /* 12 - Rule table */
Aaddr init; /* 13 - String init table */
Aaddr start; /* 14 - Start code */
Aword msgs; /* 15 - Messages table */
Aaddr dict; /* 07 - Dictionary */
Aaddr oatrs; /* 08 - Object default attributes */
Aaddr latrs; /* 09 - Location default attributes */
Aaddr aatrs; /* 0a - Actor default attributes */
Aaddr acts; /* 0b - Actor table */
Aaddr objs; /* 0c - Object table */
Aaddr locs; /* 0d - Location table */
Aaddr stxs; /* 0e - Syntax table */
Aaddr vrbs; /* 0f - Verb table */
Aaddr evts; /* 10 - Event table */
Aaddr cnts; /* 11 - Container table */
Aaddr ruls; /* 12 - Rule table */
Aaddr init; /* 13 - String init table */
Aaddr start; /* 14 - Start code */
Aword msgs; /* 15 - Messages table */
/* Miscellaneous */
Aword objmin, objmax; /* 16 - Interval for object codes */
Aword actmin, actmax; /* 18 - Interval for actor codes */
Aword cntmin, cntmax; /* 1a - Interval for container codes */
Aword locmin, locmax; /* 1c - Interval for location codes */
Aword dirmin, dirmax; /* 1e - Interval for direction codes */
Aword evtmin, evtmax; /* 20 - Interval for event codes */
Aword rulmin, rulmax; /* 22 - Interval for rule codes */
Aword maxscore; /* 24 - Maximum score */
Aaddr scores; /* 25 - Score table */
Aaddr freq; /* 26 - Address to Char freq's for coding */
Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
Aword txtcrc; /* 28 - Checksum for text data file */
Aword objmin, objmax; /* 16 - Interval for object codes */
Aword actmin, actmax; /* 18 - Interval for actor codes */
Aword cntmin, cntmax; /* 1a - Interval for container codes */
Aword locmin, locmax; /* 1c - Interval for location codes */
Aword dirmin, dirmax; /* 1e - Interval for direction codes */
Aword evtmin, evtmax; /* 20 - Interval for event codes */
Aword rulmin, rulmax; /* 22 - Interval for rule codes */
Aword maxscore; /* 24 - Maximum score */
Aaddr scores; /* 25 - Score table */
Aaddr freq; /* 26 - Address to Char freq's for coding */
Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
Aword txtcrc; /* 28 - Checksum for text data file */
} PACKED_STRUCT;
#include "common/pack-end.h" // END STRUCT PACKING
#include "common/pack-end.h" // END STRUCT PACKING
/* Error message numbers */
typedef enum MsgKind {
M_HUH, /* Obsolete */
M_WHAT,
M_WHAT_ALL,
M_WHAT_IT,
M_WHAT_THEM,
M_MULTIPLE,
M_WANT,
M_NOUN,
M_AFTER_BUT,
M_BUT_ALL,
M_NOT_MUCH,
M_WHICH_ONE,
M_NO_SUCH,
M_NO_WAY,
M_CANT0,
M_CANT,
M_NOTHING, /* Obsolete */
M_SEEOBJ1,
M_SEEOBJ2,
M_SEEOBJ3,
M_SEEOBJ4,
M_SEEACT,
M_CONTAINS1,
M_CONTAINS2,
M_CONTAINS3,
M_CONTAINS4,
M_CONTAINS5,
M_EMPTY1,
M_EMPTY2,
M_SCORE1,
M_SCORE2,
M_UNKNOWN_WORD,
M_MORE,
M_AGAIN,
M_SAVEWHERE,
M_SAVEOVERWRITE,
M_SAVEFAILED,
M_SAVEMISSING,
M_SAVEVERS,
M_SAVENAME,
M_RESTOREFROM,
M_REALLY, /* CHANGED: v2.7 from M_RESTART */
M_QUITACTION, /* INTRODUCED: v2.7, so M_ARTICLE moved */
M_ARTICLE, /* INTRODUCED: v2.6 but replaced the M_NOMSG*/
MSGMAX
M_HUH, /* Obsolete */
M_WHAT,
M_WHAT_ALL,
M_WHAT_IT,
M_WHAT_THEM,
M_MULTIPLE,
M_WANT,
M_NOUN,
M_AFTER_BUT,
M_BUT_ALL,
M_NOT_MUCH,
M_WHICH_ONE,
M_NO_SUCH,
M_NO_WAY,
M_CANT0,
M_CANT,
M_NOTHING, /* Obsolete */
M_SEEOBJ1,
M_SEEOBJ2,
M_SEEOBJ3,
M_SEEOBJ4,
M_SEEACT,
M_CONTAINS1,
M_CONTAINS2,
M_CONTAINS3,
M_CONTAINS4,
M_CONTAINS5,
M_EMPTY1,
M_EMPTY2,
M_SCORE1,
M_SCORE2,
M_UNKNOWN_WORD,
M_MORE,
M_AGAIN,
M_SAVEWHERE,
M_SAVEOVERWRITE,
M_SAVEFAILED,
M_SAVEMISSING,
M_SAVEVERS,
M_SAVENAME,
M_RESTOREFROM,
M_REALLY, /* CHANGED: v2.7 from M_RESTART */
M_QUITACTION, /* INTRODUCED: v2.7, so M_ARTICLE moved */
M_ARTICLE, /* INTRODUCED: v2.6 but replaced the M_NOMSG*/
MSGMAX
} MsgKind;
#define M_ARTICLE26 M_QUITACTION

View File

@ -39,7 +39,7 @@ namespace Alan2 {
Alan2 *g_vm = nullptr;
Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
vm_exited_cleanly(false) {
vm_exited_cleanly(false) {
g_vm = this;
}
@ -62,7 +62,7 @@ void Alan2::initialize() {
g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1);
glkStatusWin = g_vm->glk_window_open(glkMainWin, winmethod_Above |
winmethod_Fixed, 1, wintype_TextGrid, 0);
winmethod_Fixed, 1, wintype_TextGrid, 0);
g_vm->glk_set_window(glkMainWin);
// Set up the code file to point to the already opened game file
@ -106,30 +106,30 @@ void Alan2::synchronizeSave(Common::Serializer &s) {
// Save actors
for (i = ACTMIN; i <= ACTMAX; ++i) {
syncVal(s, &acts[i-ACTMIN].loc);
syncVal(s, &acts[i-ACTMIN].script);
syncVal(s, &acts[i-ACTMIN].step);
syncVal(s, &acts[i-ACTMIN].count);
syncVal(s, &acts[i - ACTMIN].loc);
syncVal(s, &acts[i - ACTMIN].script);
syncVal(s, &acts[i - ACTMIN].step);
syncVal(s, &acts[i - ACTMIN].count);
if (acts[i-ACTMIN].atrs) {
for (atr = (AtrElem *)addrTo(acts[i-ACTMIN].atrs); !endOfTable(atr); ++atr)
if (acts[i - ACTMIN].atrs) {
for (atr = (AtrElem *)addrTo(acts[i - ACTMIN].atrs); !endOfTable(atr); ++atr)
syncVal(s, &atr->val);
}
}
// Sync locations
for (i = LOCMIN; i <= LOCMAX; ++i) {
syncVal(s, &locs[i-LOCMIN].describe);
if (locs[i-LOCMIN].atrs)
for (atr = (AtrElem *)addrTo(locs[i-LOCMIN].atrs); !endOfTable(atr); atr++)
syncVal(s, &locs[i - LOCMIN].describe);
if (locs[i - LOCMIN].atrs)
for (atr = (AtrElem *)addrTo(locs[i - LOCMIN].atrs); !endOfTable(atr); atr++)
syncVal(s, &atr->val);
}
// Sync objects
for (i = OBJMIN; i <= OBJMAX; ++i) {
syncVal(s, &objs[i-OBJMIN].loc);
if (objs[i-OBJMIN].atrs)
for (atr = (AtrElem *)addrTo(objs[i-OBJMIN].atrs); !endOfTable(atr); atr++)
syncVal(s, &objs[i - OBJMIN].loc);
if (objs[i - OBJMIN].atrs)
for (atr = (AtrElem *)addrTo(objs[i - OBJMIN].atrs); !endOfTable(atr); atr++)
syncVal(s, &atr->val);
}

View File

@ -67,7 +67,9 @@ public:
/**
* Returns the running interpreter type
*/
virtual InterpreterType getInterpreterType() const override { return INTERPRETER_ALAN2; }
virtual InterpreterType getInterpreterType() const override {
return INTERPRETER_ALAN2;
}
/**
* Load a savegame from the passed Quetzal file chunk stream

View File

@ -26,20 +26,20 @@ namespace Glk {
namespace Alan2 {
Product alan = {
"Alan",
"Adventure Language System",
"Alan 2.8(6)",
"Alan 2.8(6) -- Adventure Language System (2001-07-13 14:35)",
"2001-07-13",
"14:35:07",
"Thomas Nilsson",
"",
"cygwin",
{"2.8(6)", 2, 8, 6, 995034907, ""}
"Alan",
"Adventure Language System",
"Alan 2.8(6)",
"Alan 2.8(6) -- Adventure Language System (2001-07-13 14:35)",
"2001-07-13",
"14:35:07",
"Thomas Nilsson",
"",
"cygwin",
{"2.8(6)", 2, 8, 6, 995034907, ""}
};
static char *alanId =
"@(#)RELEASE ";
"@(#)RELEASE ";
} // End of namespace Alan2
} // End of namespace Glk

View File

@ -33,26 +33,26 @@ namespace Alan2 {
static void switches(unsigned argc, char *argv[]) {
}
void args(int argc, char * argv[]) {
char *prgnam;
void args(int argc, char *argv[]) {
char *prgnam;
if ((prgnam = strrchr(argv[0], '\\')) == NULL
&& (prgnam = strrchr(argv[0], '/')) == NULL
&& (prgnam = strrchr(argv[0], ':')) == NULL)
prgnam = argv[0];
else
prgnam++;
if (strlen(prgnam) > 4
&& (strcmp(&prgnam[strlen(prgnam)-4], ".EXE") == 0
|| strcmp(&prgnam[strlen(prgnam)-4], ".exe") == 0))
prgnam[strlen(prgnam)-4] = '\0';
/* Now look at the switches and arguments */
switches(argc, argv);
if (advnam[0] == '\0')
/* No game given, try program name */
if (stricmp(prgnam, PROGNAME) != 0
&& strstr(prgnam, PROGNAME) == 0)
advnam = strdup(argv[0]);
if ((prgnam = strrchr(argv[0], '\\')) == NULL
&& (prgnam = strrchr(argv[0], '/')) == NULL
&& (prgnam = strrchr(argv[0], ':')) == NULL)
prgnam = argv[0];
else
prgnam++;
if (strlen(prgnam) > 4
&& (strcmp(&prgnam[strlen(prgnam) - 4], ".EXE") == 0
|| strcmp(&prgnam[strlen(prgnam) - 4], ".exe") == 0))
prgnam[strlen(prgnam) - 4] = '\0';
/* Now look at the switches and arguments */
switches(argc, argv);
if (advnam[0] == '\0')
/* No game given, try program name */
if (stricmp(prgnam, PROGNAME) != 0
&& strstr(prgnam, PROGNAME) == 0)
advnam = strdup(argv[0]);
}
} // End of namespace Alan2

View File

@ -35,227 +35,228 @@ namespace Glk {
namespace Alan2 {
static void showatrs(Aword atradr) {
AtrElem *at;
int i;
char str[80];
AtrElem *at;
int i;
char str[80];
if (atradr == 0) return;
if (atradr == 0) return;
i = 1;
for (at = (AtrElem *) addrTo(atradr); !endOfTable(at); at++) {
sprintf(str, "$i%3ld: %ld (%s)", (long) i, (unsigned long) at->val, (char *) addrTo(at->stradr));
output(str);
i++;
}
i = 1;
for (at = (AtrElem *) addrTo(atradr); !endOfTable(at); at++) {
sprintf(str, "$i%3ld: %ld (%s)", (long) i, (unsigned long) at->val, (char *) addrTo(at->stradr));
output(str);
i++;
}
}
static void showobjs() {
char str[80];
int obj;
char str[80];
int obj;
output("OBJECTS:");
for (obj = OBJMIN; obj <= OBJMAX; obj++) {
sprintf(str, "$i%3ld: ", (long) obj);
output(str);
say(obj);
}
output("OBJECTS:");
for (obj = OBJMIN; obj <= OBJMAX; obj++) {
sprintf(str, "$i%3ld: ", (long) obj);
output(str);
say(obj);
}
}
static void showobj(int obj) {
char str[80];
char str[80];
#define OBJ (obj-OBJMIN)
if (!isObj(obj)) {
sprintf(str, "Object number out of range. Between %ld and %ld, please.", (unsigned long) OBJMIN, (unsigned long) OBJMAX);
output(str);
return;
}
if (!isObj(obj)) {
sprintf(str, "Object number out of range. Between %ld and %ld, please.", (unsigned long) OBJMIN, (unsigned long) OBJMAX);
output(str);
return;
}
sprintf(str, "OBJECT %d :", obj);
output(str);
say(obj);
sprintf(str, "OBJECT %d :", obj);
output(str);
say(obj);
sprintf(str, "$iLocation = %ld", (unsigned long) where(obj));
output(str);
if (isLoc(objs[OBJ].loc))
say(objs[OBJ].loc);
else if (isCnt(objs[OBJ].loc)) {
if (isObj(objs[OBJ].loc)) {
output("in");
say(objs[OBJ].loc);
} else if (isAct(objs[OBJ].loc)) {
output("carried by");
say(objs[OBJ].loc);
} else
interpret(cnts[objs[OBJ].loc-CNTMIN].nam);
} else if (objs[OBJ].loc == 0)
output("nowhere");
else
output("Illegal location!");
sprintf(str, "$iLocation = %ld", (unsigned long) where(obj));
output(str);
if (isLoc(objs[OBJ].loc))
say(objs[OBJ].loc);
else if (isCnt(objs[OBJ].loc)) {
if (isObj(objs[OBJ].loc)) {
output("in");
say(objs[OBJ].loc);
} else if (isAct(objs[OBJ].loc)) {
output("carried by");
say(objs[OBJ].loc);
} else
interpret(cnts[objs[OBJ].loc - CNTMIN].nam);
} else if (objs[OBJ].loc == 0)
output("nowhere");
else
output("Illegal location!");
output("$iAttributes =");
showatrs(objs[OBJ].atrs);
output("$iAttributes =");
showatrs(objs[OBJ].atrs);
#undef OBJ
}
static void showcnts() {
char str[80];
int cnt;
char str[80];
int cnt;
#define CNT (cnt-CNTMIN)
output("CONTAINERS:");
for (cnt = CNTMIN; cnt <= CNTMAX; cnt++) {
sprintf(str, "$i%3ld: ", (long) cnt);
output(str);
if (cnts[CNT].nam != 0)
interpret(cnts[CNT].nam);
if (cnts[CNT].parent != 0)
say(cnts[CNT].parent);
}
output("CONTAINERS:");
for (cnt = CNTMIN; cnt <= CNTMAX; cnt++) {
sprintf(str, "$i%3ld: ", (long) cnt);
output(str);
if (cnts[CNT].nam != 0)
interpret(cnts[CNT].nam);
if (cnts[CNT].parent != 0)
say(cnts[CNT].parent);
}
#undef CNT
}
static void showcnt(int cnt) {
char str[80];
int i;
Abool found = FALSE;
char str[80];
int i;
Abool found = FALSE;
#define CNT (cnt-CNTMIN)
if (cnt < CNTMIN || cnt > CNTMAX) {
sprintf(str, "Container number out of range. Between %ld and %ld, please.", (unsigned long) CNTMIN, (unsigned long) CNTMAX);
output(str);
return;
}
if (cnt < CNTMIN || cnt > CNTMAX) {
sprintf(str, "Container number out of range. Between %ld and %ld, please.", (unsigned long) CNTMIN, (unsigned long) CNTMAX);
output(str);
return;
}
sprintf(str, "CONTAINER %d :", cnt);
output(str);
if (cnts[CNT].nam != 0)
interpret(cnts[CNT].nam);
if (cnts[CNT].parent != 0) {
cnt = cnts[CNT].parent;
say(cnt);
sprintf(str, "$iLocation = %ld", (unsigned long) where(cnt));
output(str);
}
output("$iContains ");
for (i = OBJMIN; i <= OBJMAX; i++) {
if (in(i, cnt)) { /* Yes, it's in this container */
if (!found) {
output("$n");
found = TRUE;
}
sprintf(str, "$t$t%d: ", i);
output(str);
say(i);
}
}
if (!found)
output("nothing");
sprintf(str, "CONTAINER %d :", cnt);
output(str);
if (cnts[CNT].nam != 0)
interpret(cnts[CNT].nam);
if (cnts[CNT].parent != 0) {
cnt = cnts[CNT].parent;
say(cnt);
sprintf(str, "$iLocation = %ld", (unsigned long) where(cnt));
output(str);
}
output("$iContains ");
for (i = OBJMIN; i <= OBJMAX; i++) {
if (in(i, cnt)) { /* Yes, it's in this container */
if (!found) {
output("$n");
found = TRUE;
}
sprintf(str, "$t$t%d: ", i);
output(str);
say(i);
}
}
if (!found)
output("nothing");
#undef CNT
}
static void showlocs() {
char str[80];
int loc;
char str[80];
int loc;
output("LOCATIONS:");
for (loc = LOCMIN; loc <= LOCMAX; loc++) {
sprintf(str, "$i%3ld: ", (long) loc);
output(str);
say(loc);
}
output("LOCATIONS:");
for (loc = LOCMIN; loc <= LOCMAX; loc++) {
sprintf(str, "$i%3ld: ", (long) loc);
output(str);
say(loc);
}
}
static void showloc(int loc) {
char str[80];
char str[80];
if (!isLoc(loc)) {
sprintf(str, "Location number out of range. Between %ld and %ld, please.", (unsigned long) LOCMIN, (unsigned long) LOCMAX);
output(str);
return;
}
sprintf(str, "LOCATION %d :", loc);
output(str);
say(loc);
if (!isLoc(loc)) {
sprintf(str, "Location number out of range. Between %ld and %ld, please.", (unsigned long) LOCMIN, (unsigned long) LOCMAX);
output(str);
return;
}
output("$iAttributes =");
showatrs(locs[loc-LOCMIN].atrs);
sprintf(str, "LOCATION %d :", loc);
output(str);
say(loc);
output("$iAttributes =");
showatrs(locs[loc - LOCMIN].atrs);
}
static void showacts() {
char str[80];
int act;
char str[80];
int act;
output("ACTORS:");
for (act = ACTMIN; act <= ACTMAX; act++) {
sprintf(str, "$i%3ld:", (long) act);
output(str);
say(act);
}
output("ACTORS:");
for (act = ACTMIN; act <= ACTMAX; act++) {
sprintf(str, "$i%3ld:", (long) act);
output(str);
say(act);
}
}
static void showact(int act) {
char str[80];
Boolean oldstp;
if (!isAct(act)) {
sprintf(str, "Actor number out of range. Between %ld and %ld, please.", (unsigned long) ACTMIN, (unsigned long) ACTMAX);
output(str);
return;
}
sprintf(str, "ACTOR %d :", act);
output(str);
oldstp = stpflg; stpflg = FALSE; /* Make sure not to trace this! */
say(act);
stpflg = oldstp;
char str[80];
Boolean oldstp;
sprintf(str, "$iLocation = %ld", (unsigned long) acts[act-ACTMIN].loc);
output(str);
if (isLoc(acts[act-ACTMIN].loc))
say(acts[act-ACTMIN].loc);
else if (acts[act-ACTMIN].loc == 0)
output("nowhere");
else
output("Illegal location!");
if (!isAct(act)) {
sprintf(str, "Actor number out of range. Between %ld and %ld, please.", (unsigned long) ACTMIN, (unsigned long) ACTMAX);
output(str);
return;
}
sprintf(str, "$iScript = %ld", (unsigned long) acts[act-ACTMIN].script);
output(str);
sprintf(str, "ACTOR %d :", act);
output(str);
oldstp = stpflg;
stpflg = FALSE; /* Make sure not to trace this! */
say(act);
stpflg = oldstp;
sprintf(str, "$iStep = %ld", (unsigned long) acts[act-ACTMIN].step);
output(str);
sprintf(str, "$iLocation = %ld", (unsigned long) acts[act - ACTMIN].loc);
output(str);
if (isLoc(acts[act - ACTMIN].loc))
say(acts[act - ACTMIN].loc);
else if (acts[act - ACTMIN].loc == 0)
output("nowhere");
else
output("Illegal location!");
output("$iAttributes =");
showatrs(acts[act-ACTMIN].atrs);
sprintf(str, "$iScript = %ld", (unsigned long) acts[act - ACTMIN].script);
output(str);
sprintf(str, "$iStep = %ld", (unsigned long) acts[act - ACTMIN].step);
output(str);
output("$iAttributes =");
showatrs(acts[act - ACTMIN].atrs);
}
static void showevts() {
int evt, i;
char str[80];
Boolean scheduled;
int evt, i;
char str[80];
Boolean scheduled;
output("EVENTS:");
for (evt = EVTMIN; evt <= EVTMAX; evt++) {
sprintf(str, "$i%d (%s):", evt, (char *)addrTo(evts[evt-EVTMIN].stradr));
output(str);
scheduled = FALSE;
for (i = 0; i < etop; i++)
if ((scheduled = (eventq[i].event == evt)))
break;
if (scheduled) {
sprintf(str, "Scheduled for +%d, at ", eventq[i].time-cur.tick);
output(str);
say(eventq[i].where);
} else
output("Not scheduled.");
}
output("EVENTS:");
for (evt = EVTMIN; evt <= EVTMAX; evt++) {
sprintf(str, "$i%d (%s):", evt, (char *)addrTo(evts[evt - EVTMIN].stradr));
output(str);
scheduled = FALSE;
for (i = 0; i < etop; i++)
if ((scheduled = (eventq[i].event == evt)))
break;
if (scheduled) {
sprintf(str, "Scheduled for +%d, at ", eventq[i].time - cur.tick);
output(str);
say(eventq[i].where);
} else
output("Not scheduled.");
}
}
@ -263,43 +264,46 @@ static Boolean trc, stp;
static int loc;
void saveInfo() {
/* Save some important things */
trc = trcflg; trcflg = FALSE;
stp = stpflg; stpflg = FALSE;
loc = cur.loc; cur.loc = where(HERO);
/* Save some important things */
trc = trcflg;
trcflg = FALSE;
stp = stpflg;
stpflg = FALSE;
loc = cur.loc;
cur.loc = where(HERO);
}
void restoreInfo() {
/* Restore! */
trcflg = trc;
stpflg = stp;
cur.loc = loc;
/* Restore! */
trcflg = trc;
stpflg = stp;
cur.loc = loc;
}
void debug() {
char buf[256];
char c;
int i;
char buf[256];
char c;
int i;
saveInfo();
while (TRUE) {
if (anyOutput)
para();
do {
output("ABUG> ");
(void)readline(buf);
saveInfo();
while (TRUE) {
if (anyOutput)
para();
do {
output("ABUG> ");
(void)readline(buf);
lin = 1;
c = buf[0];
i = 0;
sscanf(&buf[1], "%d", &i);
} while (buf && c == '\0');
lin = 1;
c = buf[0];
i = 0;
sscanf(&buf[1], "%d", &i);
} while (buf && c == '\0');
switch (toUpper(c)) {
case 'H':
case '?':
output(alan.longHeader);
output("$nABUG Commands:\
switch (toUpper(c)) {
case 'H':
case '?':
output(alan.longHeader);
output("$nABUG Commands:\
$iO [n] -- show object[s]\
$iA [n] -- show actor[s]\
$iL [n] -- show location[s]\
@ -310,58 +314,58 @@ void debug() {
$iS -- toggle step mode\
$iX -- exit debug mode\
$iQ -- quit game");
break;
case 'Q':
terminate(0);
case 'X':
dbgflg = FALSE; /* Fall through to 'G' */
case 'G':
restoreInfo();
return;
case 'O':
if (i == 0)
showobjs();
else
showobj(i);
break;
case 'C':
if (i == 0)
showcnts();
else
showcnt(i);
break;
case 'A':
if (i == 0)
showacts();
else
showact(i);
break;
case 'L':
if (i == 0)
showlocs();
else
showloc(i);
break;
case 'E':
showevts();
break;
case 'S':
if ((stp = !stp))
printf("Step on.");
else
printf("Step off.");
break;
case 'T':
if ((trc = !trc))
printf("Trace on.");
else
printf("Trace off.");
break;
default:
output("Unknown ABUG command. ? for help.");
break;
}
}
break;
case 'Q':
terminate(0);
case 'X':
dbgflg = FALSE; /* Fall through to 'G' */
case 'G':
restoreInfo();
return;
case 'O':
if (i == 0)
showobjs();
else
showobj(i);
break;
case 'C':
if (i == 0)
showcnts();
else
showcnt(i);
break;
case 'A':
if (i == 0)
showacts();
else
showact(i);
break;
case 'L':
if (i == 0)
showlocs();
else
showloc(i);
break;
case 'E':
showevts();
break;
case 'S':
if ((stp = !stp))
printf("Step on.");
else
printf("Step off.");
break;
case 'T':
if ((trc = !trc))
printf("Trace on.");
else
printf("Trace off.");
break;
default:
output("Unknown ABUG command. ? for help.");
break;
}
}
}
@ -374,16 +378,16 @@ void debug() {
*/
void debugsay(int item) {
saveInfo();
needsp = FALSE;
col = 1;
if (item == 0)
printf("$null$");
else
say(item);
needsp = FALSE;
col = 1;
restoreInfo();
saveInfo();
needsp = FALSE;
col = 1;
if (item == 0)
printf("$null$");
else
say(item);
needsp = FALSE;
col = 1;
restoreInfo();
}
} // End of namespace Alan2

View File

@ -28,94 +28,94 @@ namespace Glk {
namespace Alan2 {
/* Bit output */
static int decodeBuffer; /* Bits to be input */
static int bitsToGo; /* Bits still in buffer */
static int garbageBits; /* Bits past EOF */
static int decodeBuffer; /* Bits to be input */
static int bitsToGo; /* Bits still in buffer */
static int garbageBits; /* Bits past EOF */
static int inputBit() {
int bit;
int bit;
if (!bitsToGo) { /* More bits available ? */
decodeBuffer = txtfil->readByte(); /* No, so get more */
if (decodeBuffer == EOF) {
garbageBits++;
if (garbageBits > VALUEBITS-2)
syserr("Error in encoded data file.");
} else
bitsToGo = 8; /* Another Char, 8 new bits */
}
bit = decodeBuffer&1; /* Get next bit */
decodeBuffer = decodeBuffer>>1; /* and remove it */
bitsToGo--;
return bit;
if (!bitsToGo) { /* More bits available ? */
decodeBuffer = txtfil->readByte(); /* No, so get more */
if (decodeBuffer == EOF) {
garbageBits++;
if (garbageBits > VALUEBITS - 2)
syserr("Error in encoded data file.");
} else
bitsToGo = 8; /* Another Char, 8 new bits */
}
bit = decodeBuffer & 1; /* Get next bit */
decodeBuffer = decodeBuffer >> 1; /* and remove it */
bitsToGo--;
return bit;
}
/* Current state of decoding */
static CodeValue value; /* Currently seen code value */
static CodeValue low, high; /* Current code region */
static CodeValue value; /* Currently seen code value */
static CodeValue low, high; /* Current code region */
void startDecoding() {
int i;
int i;
bitsToGo = 0;
garbageBits = 0;
bitsToGo = 0;
garbageBits = 0;
value = 0;
for (i = 0; i < VALUEBITS; i++)
value = 2*value + inputBit();
low = 0;
high = TOPVALUE;
value = 0;
for (i = 0; i < VALUEBITS; i++)
value = 2 * value + inputBit();
low = 0;
high = TOPVALUE;
}
int decodeChar() {
long range;
int f;
int symbol;
long range;
int f;
int symbol;
range = (long)(high-low) + 1;
f = (((long)(value-low)+1)*freq[0]-1)/range;
range = (long)(high - low) + 1;
f = (((long)(value - low) + 1) * freq[0] - 1) / range;
/* Find the symbol */
for (symbol = 1; (int)freq[symbol] > f; symbol++);
/* Find the symbol */
for (symbol = 1; (int)freq[symbol] > f; symbol++);
high = low + range*freq[symbol-1]/freq[0]-1;
low = low + range*freq[symbol]/freq[0];
high = low + range * freq[symbol - 1] / freq[0] - 1;
low = low + range * freq[symbol] / freq[0];
for (;;) {
if (high < HALF)
;
else if (low >= HALF) {
value = value - HALF;
low = low - HALF;
high = high - HALF;
} else if (low >= ONEQUARTER && high < THREEQUARTER) {
value = value - ONEQUARTER;
low = low - ONEQUARTER;
high = high - ONEQUARTER;
} else
break;
for (;;) {
if (high < HALF)
;
else if (low >= HALF) {
value = value - HALF;
low = low - HALF;
high = high - HALF;
} else if (low >= ONEQUARTER && high < THREEQUARTER) {
value = value - ONEQUARTER;
low = low - ONEQUARTER;
high = high - ONEQUARTER;
} else
break;
/* Scale up the range */
low = 2*low;
high = 2*high+1;
value = 2*value + inputBit();
}
return symbol-1;
/* Scale up the range */
low = 2 * low;
high = 2 * high + 1;
value = 2 * value + inputBit();
}
return symbol - 1;
}
/* Structure for saved decode info */
typedef struct DecodeInfo {
long fpos;
int buffer;
int bits;
CodeValue value;
CodeValue high;
CodeValue low;
long fpos;
int buffer;
int bits;
CodeValue value;
CodeValue high;
CodeValue low;
} DecodeInfo;
@ -128,16 +128,16 @@ typedef struct DecodeInfo {
*/
void *pushDecode() {
DecodeInfo *info;
DecodeInfo *info;
info = (DecodeInfo *) allocate(sizeof(DecodeInfo));
info->fpos = txtfil->pos();
info->buffer = decodeBuffer;
info->bits = bitsToGo;
info->value = value;
info->high = high;
info->low = low;
return(info);
info = (DecodeInfo *) allocate(sizeof(DecodeInfo));
info->fpos = txtfil->pos();
info->buffer = decodeBuffer;
info->bits = bitsToGo;
info->value = value;
info->high = high;
info->low = low;
return (info);
}
@ -150,15 +150,15 @@ void *pushDecode() {
*/
void popDecode(void *i) {
DecodeInfo *info = (DecodeInfo *) i;
fseek(txtfil, info->fpos, 0);
decodeBuffer = info->buffer;
bitsToGo = info->bits;
value = info->value;
high = info->high;
low = info->low;
DecodeInfo *info = (DecodeInfo *) i;
fseek(txtfil, info->fpos, 0);
decodeBuffer = info->buffer;
bitsToGo = info->bits;
value = info->value;
high = info->high;
low = info->low;
free(info);
free(info);
}
} // End of namespace Alan2

File diff suppressed because it is too large Load Diff

View File

@ -32,10 +32,10 @@ namespace Glk {
namespace Alan2 {
/* The event queue */
extern EvtqElem eventq[]; /* Event queue */
extern int etop; /* Event queue top pointer */
extern Boolean looking; /* LOOKING? flag */
extern int dscrstkp; /* Point into describe stack */
extern EvtqElem eventq[]; /* Event queue */
extern int etop; /* Event queue top pointer */
extern Boolean looking; /* LOOKING? flag */
extern int dscrstkp; /* Point into describe stack */
extern void sys(Aword fpos, Aword len);
extern Boolean confirm(MsgKind msgno);

View File

@ -34,7 +34,7 @@ void glkio_printf(char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
if (glkMainWin) {
char buf[1024]; /* FIXME: buf size should be foolproof */
char buf[1024]; /* FIXME: buf size should be foolproof */
vsprintf(buf, fmt, argp);
g_vm->glk_put_string(buf);
} else {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef GLK_ALAN2_MAIN
#define GLK_ALAN2_MAIN
@ -35,9 +35,9 @@ namespace Alan2 {
#define MEMORYSIZE 1000L
extern int memTop; /* Top of memory */
extern int memTop; /* Top of memory */
extern int conjWord; /* First conjunction in dictionary */
extern int conjWord; /* First conjunction in dictionary */
/* The Amachine memory */
extern Aword *memory;
@ -47,20 +47,20 @@ extern AcdHdr *header;
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 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 */
extern int dictsize; /* Number of entries in dictionary */
/* The text and message file */
extern Common::File *txtfil;

View File

@ -28,74 +28,74 @@ namespace Glk {
namespace Alan2 {
void compact(ParamElem a[]) {
int i, j;
for (i = 0, j = 0; a[j].code != (Aword)EOF; j++)
if (a[j].code != 0)
a[i++] = a[j];
a[i].code = (Aword)EOF;
int i, j;
for (i = 0, j = 0; a[j].code != (Aword)EOF; j++)
if (a[j].code != 0)
a[i++] = a[j];
a[i].code = (Aword)EOF;
}
int lstlen(ParamElem a[]) {
int i = 0;
int i = 0;
while (a[i].code != (Aword)EOF)
i++;
return (i);
while (a[i].code != (Aword)EOF)
i++;
return (i);
}
Boolean inlst(ParamElem l[], Aword e) {
int i;
int i;
for (i = 0; l[i].code != (Aword)EOF && l[i].code != e; i++);
return (l[i].code == e);
for (i = 0; l[i].code != (Aword)EOF && l[i].code != e; i++);
return (l[i].code == e);
}
void lstcpy(ParamElem a[], ParamElem b[]) {
int i;
int i;
for (i = 0; b[i].code != (Aword)EOF; i++)
a[i] = b[i];
a[i].code = (Aword)EOF;
for (i = 0; b[i].code != (Aword)EOF; i++)
a[i] = b[i];
a[i].code = (Aword)EOF;
}
void sublst(ParamElem a[], ParamElem b[]) {
int i;
int i;
for (i = 0; a[i].code != (Aword)EOF; i++)
if (inlst(b, a[i].code))
a[i].code = 0; /* Mark empty */
compact(a);
for (i = 0; a[i].code != (Aword)EOF; i++)
if (inlst(b, a[i].code))
a[i].code = 0; /* Mark empty */
compact(a);
}
void mrglst(ParamElem a[], ParamElem b[]) {
int i,last;
int i, last;
for (last = 0; a[last].code != (Aword)EOF; last++); /* Find end of list */
for (i = 0; b[i].code != (Aword)EOF; i++)
if (!inlst(a, b[i].code)) {
a[last++] = b[i];
a[last].code = (Aword)EOF;
}
for (last = 0; a[last].code != (Aword)EOF; last++); /* Find end of list */
for (i = 0; b[i].code != (Aword)EOF; i++)
if (!inlst(a, b[i].code)) {
a[last++] = b[i];
a[last].code = (Aword)EOF;
}
}
void isect(ParamElem a[], ParamElem b[]) {
int i, last = 0;
int i, last = 0;
for (i = 0; a[i].code != (Aword)EOF; i++)
if (inlst(b, a[i].code))
a[last++] = a[i];
a[last].code = (Aword)EOF;
for (i = 0; a[i].code != (Aword)EOF; i++)
if (inlst(b, a[i].code))
a[last++] = a[i];
a[last].code = (Aword)EOF;
}
void cpyrefs(ParamElem p[], Aword r[]) {
int i;
int i;
for (i = 0; r[i] != (Aword)EOF; i++) {
p[i].code = r[i];
p[i].firstWord = (Aword)EOF;
}
p[i].code = (Aword)EOF;
for (i = 0; r[i] != (Aword)EOF; i++) {
p[i].code = r[i];
p[i].firstWord = (Aword)EOF;
}
p[i].code = (Aword)EOF;
}
} // End of namespace Alan2

File diff suppressed because it is too large Load Diff

View File

@ -28,10 +28,10 @@
namespace Glk {
namespace Alan2 {
extern int wrds[]; /* List of Parsed Word */
extern int wrdidx; /* and an index into it */
extern int wrds[]; /* List of Parsed Word */
extern int wrdidx; /* and an index into it */
extern ParamElem *params; /* List of parameters */
extern ParamElem *params; /* List of parameters */
extern Boolean plural;
extern LitElem litValues[];

View File

@ -38,25 +38,23 @@ namespace Alan2 {
*/
/* 4f - length of user buffer should be used */
Boolean readline(char usrbuf[])
{
event_t event;
g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
/* FIXME: buffer size should be infallible: all existing calls use 256 or
80 character buffers, except parse which uses LISTLEN (currently 100)
*/
do
{
g_vm->glk_select(&event);
if (evtype_Arrange == event.type)
statusline();
if (g_vm->shouldQuit())
return false;
Boolean readline(char usrbuf[]) {
event_t event;
g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
/* FIXME: buffer size should be infallible: all existing calls use 256 or
80 character buffers, except parse which uses LISTLEN (currently 100)
*/
do {
g_vm->glk_select(&event);
if (evtype_Arrange == event.type)
statusline();
if (g_vm->shouldQuit())
return false;
} while (event.type != evtype_LineInput);
} while (event.type != evtype_LineInput);
usrbuf[event.val1] = 0;
return TRUE;
usrbuf[event.val1] = 0;
return TRUE;
}
} // End of namespace Alan2

View File

@ -35,307 +35,307 @@ namespace Alan2 {
*/
Aword reversed(Aword w /* IN - The ACODE word to swap bytes of */) {
Aword s; /* The swapped ACODE word */
char *wp, *sp;
int i;
wp = (char *) &w;
sp = (char *) &s;
Aword s; /* The swapped ACODE word */
char *wp, *sp;
int i;
for (i = 0; i < sizeof(Aword); i++)
sp[sizeof(Aword)-1 - i] = wp[i];
wp = (char *) &w;
sp = (char *) &s;
return s;
for (i = 0; i < sizeof(Aword); i++)
sp[sizeof(Aword) - 1 - i] = wp[i];
return s;
}
void reverse(Aword *w /* IN - The ACODE word to reverse bytes in */) {
*w = reversed(*w);
*w = reversed(*w);
}
static void reverseTable(Aword adr, int len) {
Aword *e = &memory[adr];
int i;
Aword *e = &memory[adr];
int i;
if (adr != 0)
while (!endOfTable(e)) {
for (i = 0; i < len/(int)sizeof(Aword); i++) {
reverse(e);
e++;
}
}
if (adr != 0)
while (!endOfTable(e)) {
for (i = 0; i < len / (int)sizeof(Aword); i++) {
reverse(e);
e++;
}
}
}
static void reverseStms(Aword adr) {
Aword *e = &memory[adr];
Aword *e = &memory[adr];
if (adr != 0)
while (TRUE) {
reverse(e);
if (*e == ((Aword)C_STMOP<<28|(Aword)I_RETURN)) break;
e++;
}
if (adr != 0)
while (TRUE) {
reverse(e);
if (*e == ((Aword)C_STMOP << 28 | (Aword)I_RETURN)) break;
e++;
}
}
static void reverseMsgs(Aword adr) {
MsgElem *e = (MsgElem *) &memory[adr];
MsgElem *e = (MsgElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(MsgElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(MsgElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
}
static void reverseWrds(Aword adr) {
WrdElem *e = (WrdElem *) &memory[adr];
WrdElem *e = (WrdElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(WrdElem));
while (!endOfTable(e)) {
if ((e->_class & (1L<<WRD_SYN)) == 0) { /* Do not do this for synonyms */
reverseTable(e->adjrefs, sizeof(Aword));
reverseTable(e->nounrefs, sizeof(Aword));
}
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(WrdElem));
while (!endOfTable(e)) {
if ((e->_class & (1L << WRD_SYN)) == 0) { /* Do not do this for synonyms */
reverseTable(e->adjrefs, sizeof(Aword));
reverseTable(e->nounrefs, sizeof(Aword));
}
e++;
}
}
}
static void reverseChks(Aword adr) {
ChkElem *e = (ChkElem *) &memory[adr];
ChkElem *e = (ChkElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ChkElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stms);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ChkElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stms);
e++;
}
}
}
static void reverseAlts(Aword adr) {
AltElem *e = (AltElem *)&memory[adr];
AltElem *e = (AltElem *)&memory[adr];
if (adr != 0 && !endOfTable(e) && !e->done) {
reverseTable(adr, sizeof(AltElem));
e->done = TRUE;
while (!endOfTable(e)) {
reverseChks(e->checks);
reverseStms(e->action);
e++;
}
}
}
if (adr != 0 && !endOfTable(e) && !e->done) {
reverseTable(adr, sizeof(AltElem));
e->done = TRUE;
while (!endOfTable(e)) {
reverseChks(e->checks);
reverseStms(e->action);
e++;
}
}
}
static void reverseVrbs(Aword adr) {
VrbElem *e = (VrbElem *)&memory[adr];
VrbElem *e = (VrbElem *)&memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(VrbElem));
while (!endOfTable(e)) {
reverseAlts(e->alts);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(VrbElem));
while (!endOfTable(e)) {
reverseAlts(e->alts);
e++;
}
}
}
static void reverseSteps(Aword adr) {
StepElem *e = (StepElem *) &memory[adr];
StepElem *e = (StepElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(StepElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stm);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(StepElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stm);
e++;
}
}
}
static void reverseScrs(Aword adr) {
ScrElem *e = (ScrElem *) &memory[adr];
ScrElem *e = (ScrElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ScrElem));
while (!endOfTable(e)) {
reverseStms(e->dscr);
reverseSteps(e->steps);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ScrElem));
while (!endOfTable(e)) {
reverseStms(e->dscr);
reverseSteps(e->steps);
e++;
}
}
}
static void reverseActs(Aword adr) {
ActElem *e = (ActElem *) &memory[adr];
ActElem *e = (ActElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ActElem));
while (!endOfTable(e)) {
reverseStms(e->nam);
reverseTable(e->atrs, sizeof(AtrElem));
reverseScrs(e->scradr);
reverseVrbs(e->vrbs);
reverseStms(e->dscr);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ActElem));
while (!endOfTable(e)) {
reverseStms(e->nam);
reverseTable(e->atrs, sizeof(AtrElem));
reverseScrs(e->scradr);
reverseVrbs(e->vrbs);
reverseStms(e->dscr);
e++;
}
}
}
static void reverseObjs(Aword adr, Boolean v2_5) {
ObjElem *e = (ObjElem *) &memory[adr];
ObjElem25 *e25 = (ObjElem25 *) &memory[adr];
ObjElem *e = (ObjElem *) &memory[adr];
ObjElem25 *e25 = (ObjElem25 *) &memory[adr];
if (v2_5) {
if (adr != 0 && !endOfTable(e25)) {
reverseTable(adr, sizeof(ObjElem25));
while (!endOfTable(e25)) {
reverseTable(e25->atrs, sizeof(AtrElem));
reverseVrbs(e25->vrbs);
reverseStms(e25->dscr1);
reverseStms(e25->dscr2);
e25++;
}
}
} else {
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ObjElem));
while (!endOfTable(e)) {
reverseTable(e->atrs, sizeof(AtrElem));
reverseVrbs(e->vrbs);
reverseStms(e->art);
reverseStms(e->dscr1);
reverseStms(e->dscr2);
e++;
}
}
}
if (v2_5) {
if (adr != 0 && !endOfTable(e25)) {
reverseTable(adr, sizeof(ObjElem25));
while (!endOfTable(e25)) {
reverseTable(e25->atrs, sizeof(AtrElem));
reverseVrbs(e25->vrbs);
reverseStms(e25->dscr1);
reverseStms(e25->dscr2);
e25++;
}
}
} else {
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ObjElem));
while (!endOfTable(e)) {
reverseTable(e->atrs, sizeof(AtrElem));
reverseVrbs(e->vrbs);
reverseStms(e->art);
reverseStms(e->dscr1);
reverseStms(e->dscr2);
e++;
}
}
}
}
static void reverseExts(Aword adr) {
ExtElem *e = (ExtElem *) &memory[adr];
ExtElem *e = (ExtElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ExtElem));
while (!endOfTable(e)) {
if (!e->done) {
reverseChks(e->checks);
reverseStms(e->action);
}
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ExtElem));
while (!endOfTable(e)) {
if (!e->done) {
reverseChks(e->checks);
reverseStms(e->action);
}
e++;
}
}
}
static void reverseLocs(Aword adr) {
LocElem *e = (LocElem *) &memory[adr];
LocElem *e = (LocElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(LocElem));
while (!endOfTable(e)) {
reverseStms(e->nams);
reverseStms(e->dscr);
reverseStms(e->does);
reverseTable(e->atrs, sizeof(AtrElem));
reverseExts(e->exts);
reverseVrbs(e->vrbs);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(LocElem));
while (!endOfTable(e)) {
reverseStms(e->nams);
reverseStms(e->dscr);
reverseStms(e->does);
reverseTable(e->atrs, sizeof(AtrElem));
reverseExts(e->exts);
reverseVrbs(e->vrbs);
e++;
}
}
}
static void reverseClas(Aword adr) {
ClaElem *e = (ClaElem *) &memory[adr];
ClaElem *e = (ClaElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ClaElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
if (adr)
reverse(&((Aword *)e)[1]); /* The verb code is stored after the table */
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ClaElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
if (adr)
reverse(&((Aword *)e)[1]); /* The verb code is stored after the table */
}
static void reverseElms(Aword adr) {
ElmElem *e = (ElmElem *) &memory[adr];
ElmElem *e = (ElmElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ElmElem));
while (!endOfTable(e)) {
if (e->code == EOS) reverseClas(e->next);
else reverseElms(e->next);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(ElmElem));
while (!endOfTable(e)) {
if (e->code == EOS) reverseClas(e->next);
else reverseElms(e->next);
e++;
}
}
}
static void reverseStxs(Aword adr) {
StxElem *e = (StxElem *) &memory[adr];
StxElem *e = (StxElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(StxElem));
while (!endOfTable(e)) {
reverseElms(e->elms);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(StxElem));
while (!endOfTable(e)) {
reverseElms(e->elms);
e++;
}
}
}
static void reverseEvts(Aword adr) {
EvtElem *e = (EvtElem *) &memory[adr];
EvtElem *e = (EvtElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(EvtElem));
while (!endOfTable(e)) {
reverseStms(e->code);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(EvtElem));
while (!endOfTable(e)) {
reverseStms(e->code);
e++;
}
}
}
static void reverseLims(Aword adr) {
LimElem *e = (LimElem *) &memory[adr];
LimElem *e = (LimElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(LimElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(LimElem));
while (!endOfTable(e)) {
reverseStms(e->stms);
e++;
}
}
}
static void reverseCnts(Aword adr) {
CntElem *e = (CntElem *) &memory[adr];
CntElem *e = (CntElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(CntElem));
while (!endOfTable(e)) {
reverseLims(e->lims);
reverseStms(e->header);
reverseStms(e->empty);
reverseStms(e->nam);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(CntElem));
while (!endOfTable(e)) {
reverseLims(e->lims);
reverseStms(e->header);
reverseStms(e->empty);
reverseStms(e->nam);
e++;
}
}
}
static void reverseRuls(Aword adr) {
RulElem *e = (RulElem *) &memory[adr];
RulElem *e = (RulElem *) &memory[adr];
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(RulElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stms);
e++;
}
}
}
if (adr != 0 && !endOfTable(e)) {
reverseTable(adr, sizeof(RulElem));
while (!endOfTable(e)) {
reverseStms(e->exp);
reverseStms(e->stms);
e++;
}
}
}
/*----------------------------------------------------------------------
@ -346,11 +346,11 @@ static void reverseRuls(Aword adr) {
*/
void reverseHdr(AcdHdr *hdr) {
int i;
int i;
/* Reverse all words in the header except the first (version marking) */
for (i = 1; i < sizeof(AcdHdr)/sizeof(Aword); i++)
reverse(&((Aword *)hdr)[i]);
/* Reverse all words in the header except the first (version marking) */
for (i = 1; i < sizeof(AcdHdr) / sizeof(Aword); i++)
reverse(&((Aword *)hdr)[i]);
}
/*----------------------------------------------------------------------
@ -363,25 +363,25 @@ void reverseHdr(AcdHdr *hdr) {
*/
void reverseACD(Boolean v2_5) {
reverseHdr(header);
reverseWrds(header->dict);
reverseTable(header->oatrs, sizeof(AtrElem));
reverseTable(header->latrs, sizeof(AtrElem));
reverseTable(header->aatrs, sizeof(AtrElem));
reverseActs(header->acts);
reverseObjs(header->objs, v2_5);
reverseLocs(header->locs);
reverseStxs(header->stxs);
reverseVrbs(header->vrbs);
reverseEvts(header->evts);
reverseCnts(header->cnts);
reverseRuls(header->ruls);
reverseTable(header->init, sizeof(IniElem));
reverseStms(header->start);
reverseMsgs(header->msgs);
reverseTable(header->scores, sizeof(Aword));
reverseTable(header->freq, sizeof(Aword));
reverseHdr(header);
reverseWrds(header->dict);
reverseTable(header->oatrs, sizeof(AtrElem));
reverseTable(header->latrs, sizeof(AtrElem));
reverseTable(header->aatrs, sizeof(AtrElem));
reverseActs(header->acts);
reverseObjs(header->objs, v2_5);
reverseLocs(header->locs);
reverseStxs(header->stxs);
reverseVrbs(header->vrbs);
reverseEvts(header->evts);
reverseCnts(header->cnts);
reverseRuls(header->ruls);
reverseTable(header->init, sizeof(IniElem));
reverseStms(header->start);
reverseMsgs(header->msgs);
reverseTable(header->scores, sizeof(Aword));
reverseTable(header->freq, sizeof(Aword));
}
} // End of namespace Alan2

View File

@ -33,41 +33,41 @@ namespace Glk {
namespace Alan2 {
void rules() {
Boolean change = TRUE;
int i;
for (i = 1; !endOfTable(&ruls[i-1]); i++)
ruls[i-1].run = FALSE;
while (change) {
change = FALSE;
for (i = 1; !endOfTable(&ruls[i-1]); i++)
if (!ruls[i-1].run) {
if (trcflg) {
printf("\n<RULE %d (at ", i);
debugsay(cur.loc);
if (!stpflg)
printf("), Evaluating");
else
printf("), Evaluating:>\n");
Boolean change = TRUE;
int i;
for (i = 1; !endOfTable(&ruls[i - 1]); i++)
ruls[i - 1].run = FALSE;
while (change) {
change = FALSE;
for (i = 1; !endOfTable(&ruls[i - 1]); i++)
if (!ruls[i - 1].run) {
if (trcflg) {
printf("\n<RULE %d (at ", i);
debugsay(cur.loc);
if (!stpflg)
printf("), Evaluating");
else
printf("), Evaluating:>\n");
}
interpret(ruls[i - 1].exp);
if (pop()) {
change = TRUE;
ruls[i - 1].run = TRUE;
if (trcflg)
if (!stpflg)
printf(", Executing:>\n");
else {
printf("\nRULE %d (at ", i);
debugsay(cur.loc);
printf("), Executing:>\n");
}
interpret(ruls[i - 1].stms);
} else if (trcflg && !stpflg)
printf(":>\n");
}
}
interpret(ruls[i-1].exp);
if (pop()) {
change = TRUE;
ruls[i-1].run = TRUE;
if (trcflg)
if (!stpflg)
printf(", Executing:>\n");
else {
printf("\nRULE %d (at ", i);
debugsay(cur.loc);
printf("), Executing:>\n");
}
interpret(ruls[i-1].stms);
} else if (trcflg && !stpflg)
printf(":>\n");
}
}
}
} // End of namespace Alan2

View File

@ -37,19 +37,19 @@ static int stackp = 0;
void push(Aptr i) {
if (stackp == STACKSIZE)
syserr("Out of stack space.");
stack[stackp++] = i;
if (stackp == STACKSIZE)
syserr("Out of stack space.");
stack[stackp++] = i;
}
Aptr pop() {
if (stackp == 0)
syserr("Stack underflow.");
return(stack[--stackp]);
if (stackp == 0)
syserr("Stack underflow.");
return (stack[--stackp]);
}
Aptr top() {
return(stack[stackp-1]);
return (stack[stackp - 1]);
}
} // End of namespace Alan2

View File

@ -40,183 +40,165 @@ void fprintf(Common::WriteStream *ws, const char *fmt, ...) {
/* Note to Glk maintainers: 'native' characters are used for output, in this
case, Glk's Latin-1. ISO characters are Alan's internal representation,
stored in the .DAT file, and must be converted to native before printing.
Glk could just use the ISO routines directly, but its safer to maintain
stored in the .DAT file, and must be converted to native before printing.
Glk could just use the ISO routines directly, but its safer to maintain
its own tables to guard against future changes in either Alan or Glk (ie. a
move to Unicode).
*/
static char spcChrs[] =
{
'\x0A', /* linefeed */
'\x20', /* space */
'\xA0', /* non-breaking space */
'\x00'
static char spcChrs[] = {
'\x0A', /* linefeed */
'\x20', /* space */
'\xA0', /* non-breaking space */
'\x00'
};
static char lowChrs[] =
{
'\x61', /* a */ '\x62', /* b */ '\x63', /* c */ '\x64', /* d */
'\x65', /* e */ '\x66', /* f */ '\x67', /* g */ '\x68', /* h */
'\x69', /* i */ '\x6A', /* j */ '\x6B', /* k */ '\x6C', /* l */
'\x6D', /* m */ '\x6E', /* n */ '\x6F', /* o */ '\x70', /* p */
'\x71', /* q */ '\x72', /* r */ '\x73', /* s */ '\x74', /* t */
'\x75', /* u */ '\x76', /* v */ '\x77', /* w */ '\x78', /* x */
'\x79', /* y */ '\x7A', /* z */ '\xDF', /* ss <small sharp s> */
'\xE0', /* a grave */ '\xE1', /* a acute */
'\xE2', /* a circumflex */ '\xE3', /* a tilde */
'\xE4', /* a diaeresis */ '\xE5', /* a ring */
'\xE6', /* ae */ '\xE7', /* c cedilla */
'\xE8', /* e grave */ '\xE9', /* e acute */
'\xEA', /* e circumflex */ '\xEB', /* e diaeresis */
'\xEC', /* i grave */ '\xED', /* i acute */
'\xEE', /* i circumflex */ '\xEF', /* i diaeresis */
'\xF0', /* <small eth> */ '\xF1', /* n tilde */
'\xF2', /* o grave */ '\xF3', /* o acute */
'\xF4', /* o circumflex */ '\xF5', /* o tilde */
'\xF6', /* o diaeresis */ '\xF8', /* o slash */
'\xF9', /* u grave */ '\xFA', /* u acute */
'\xFB', /* u circumflex */ '\xFC', /* u diaeresis */
'\xFD', /* y acute */ '\xFE', /* <small thorn> */
'\xFF', /* y diaeresis */ '\x00'
static char lowChrs[] = {
'\x61', /* a */ '\x62', /* b */ '\x63', /* c */ '\x64', /* d */
'\x65', /* e */ '\x66', /* f */ '\x67', /* g */ '\x68', /* h */
'\x69', /* i */ '\x6A', /* j */ '\x6B', /* k */ '\x6C', /* l */
'\x6D', /* m */ '\x6E', /* n */ '\x6F', /* o */ '\x70', /* p */
'\x71', /* q */ '\x72', /* r */ '\x73', /* s */ '\x74', /* t */
'\x75', /* u */ '\x76', /* v */ '\x77', /* w */ '\x78', /* x */
'\x79', /* y */ '\x7A', /* z */ '\xDF', /* ss <small sharp s> */
'\xE0', /* a grave */ '\xE1', /* a acute */
'\xE2', /* a circumflex */ '\xE3', /* a tilde */
'\xE4', /* a diaeresis */ '\xE5', /* a ring */
'\xE6', /* ae */ '\xE7', /* c cedilla */
'\xE8', /* e grave */ '\xE9', /* e acute */
'\xEA', /* e circumflex */ '\xEB', /* e diaeresis */
'\xEC', /* i grave */ '\xED', /* i acute */
'\xEE', /* i circumflex */ '\xEF', /* i diaeresis */
'\xF0', /* <small eth> */ '\xF1', /* n tilde */
'\xF2', /* o grave */ '\xF3', /* o acute */
'\xF4', /* o circumflex */ '\xF5', /* o tilde */
'\xF6', /* o diaeresis */ '\xF8', /* o slash */
'\xF9', /* u grave */ '\xFA', /* u acute */
'\xFB', /* u circumflex */ '\xFC', /* u diaeresis */
'\xFD', /* y acute */ '\xFE', /* <small thorn> */
'\xFF', /* y diaeresis */ '\x00'
};
/* FIXME: ss <small sharp s> and y diaeresis have no UC analogues
Are they really considered LC?
Are they really considered LC?
*/
static char uppChrs[] =
{
'\x41', /* A */ '\x42', /* B */ '\x43', /* C */ '\x44', /* D */
'\x45', /* E */ '\x46', /* F */ '\x47', /* G */ '\x48', /* H */
'\x49', /* I */ '\x4A', /* J */ '\x4B', /* K */ '\x4C', /* L */
'\x4D', /* M */ '\x4E', /* N */ '\x4F', /* O */ '\x50', /* P */
'\x51', /* Q */ '\x52', /* R */ '\x53', /* S */ '\x54', /* T */
'\x55', /* U */ '\x56', /* V */ '\x57', /* W */ '\x58', /* X */
'\x59', /* Y */ '\x5A', /* Z */
'\xC0', /* A grave */ '\xC1', /* A acute */
'\xC2', /* A circumflex */ '\xC3', /* A tilde */
'\xC4', /* A diaeresis */ '\xC5', /* A ring */
'\xC6', /* AE */ '\xC7', /* C cedilla */
'\xC8', /* E grave */ '\xC9', /* E acute */
'\xCA', /* E circumflex */ '\xCB', /* E diaeresis */
'\xCC', /* I grave */ '\xCD', /* I acute */
'\xCE', /* I circumflex */ '\xCF', /* I diaeresis */
'\xD0', /* <capital eth> */ '\xD1', /* N tilde */
'\xD2', /* O grave */ '\xD3', /* O acute */
'\xD4', /* O circumflex */ '\xD5', /* O tilde */
'\xD6', /* O diaeresis */ '\xD8', /* O slash */
'\xD9', /* U grave */ '\xDA', /* U acute */
'\xDB', /* U circumflex */ '\xDC', /* U diaeresis */
'\xDD', /* Y acute */ '\xDE', /* <capital thorn> */
'\x00'
static char uppChrs[] = {
'\x41', /* A */ '\x42', /* B */ '\x43', /* C */ '\x44', /* D */
'\x45', /* E */ '\x46', /* F */ '\x47', /* G */ '\x48', /* H */
'\x49', /* I */ '\x4A', /* J */ '\x4B', /* K */ '\x4C', /* L */
'\x4D', /* M */ '\x4E', /* N */ '\x4F', /* O */ '\x50', /* P */
'\x51', /* Q */ '\x52', /* R */ '\x53', /* S */ '\x54', /* T */
'\x55', /* U */ '\x56', /* V */ '\x57', /* W */ '\x58', /* X */
'\x59', /* Y */ '\x5A', /* Z */
'\xC0', /* A grave */ '\xC1', /* A acute */
'\xC2', /* A circumflex */ '\xC3', /* A tilde */
'\xC4', /* A diaeresis */ '\xC5', /* A ring */
'\xC6', /* AE */ '\xC7', /* C cedilla */
'\xC8', /* E grave */ '\xC9', /* E acute */
'\xCA', /* E circumflex */ '\xCB', /* E diaeresis */
'\xCC', /* I grave */ '\xCD', /* I acute */
'\xCE', /* I circumflex */ '\xCF', /* I diaeresis */
'\xD0', /* <capital eth> */ '\xD1', /* N tilde */
'\xD2', /* O grave */ '\xD3', /* O acute */
'\xD4', /* O circumflex */ '\xD5', /* O tilde */
'\xD6', /* O diaeresis */ '\xD8', /* O slash */
'\xD9', /* U grave */ '\xDA', /* U acute */
'\xDB', /* U circumflex */ '\xDC', /* U diaeresis */
'\xDD', /* Y acute */ '\xDE', /* <capital thorn> */
'\x00'
};
int isSpace(int c) /* IN - Native character to test */
{
return (c != '\0' && strchr(spcChrs, c) != 0);
int isSpace(int c) { /* IN - Native character to test */
return (c != '\0' && strchr(spcChrs, c) != 0);
}
int isLower(int c) /* IN - Native character to test */
{
return (c != '\0' && strchr(lowChrs, c) != 0);
int isLower(int c) { /* IN - Native character to test */
return (c != '\0' && strchr(lowChrs, c) != 0);
}
int isUpper(int c) /* IN - Native character to test */
{
return (c != '\0' && strchr(uppChrs, c) != 0);
int isUpper(int c) { /* IN - Native character to test */
return (c != '\0' && strchr(uppChrs, c) != 0);
}
int isLetter(int c) /* IN - Native character to test */
{
return(c != '\0' && (isLower(c)? !0: isUpper(c)));
int isLetter(int c) { /* IN - Native character to test */
return (c != '\0' && (isLower(c) ? !0 : isUpper(c)));
}
int toLower(int c) /* IN - Native character to convert */
{
return g_vm->glk_char_to_lower(c);
int toLower(int c) { /* IN - Native character to convert */
return g_vm->glk_char_to_lower(c);
}
int toUpper(int c) /* IN - Native character to convert */
{
return g_vm->glk_char_to_upper(c);
int toUpper(int c) { /* IN - Native character to convert */
return g_vm->glk_char_to_upper(c);
}
char *strlow(char str[]) /* INOUT - Native string to convert */
{
char *s;
char *strlow(char str[]) { /* INOUT - Native string to convert */
char *s;
for (s = str; *s; s++)
*s = toLower(*s);
return(str);
for (s = str; *s; s++)
*s = toLower(*s);
return (str);
}
char *strupp(char str[]) /* INOUT - Native string to convert */
{
char *s;
char *strupp(char str[]) { /* INOUT - Native string to convert */
char *s;
for (s = str; *s; s++)
*s = toUpper(*s);
return(str);
for (s = str; *s; s++)
*s = toUpper(*s);
return (str);
}
/* The following work on ISO characters */
int isLowerCase(int c) /* IN - ISO character to test */
{
static char lowChrs[] = "abcdefghijklmnopqrstuvwxyz\340\341\342\343\344\345\346\347\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377";
return (c != '\0' && strchr(lowChrs, c) != 0);
int isLowerCase(int c) { /* IN - ISO character to test */
static char lowChrs[] = "abcdefghijklmnopqrstuvwxyz\340\341\342\343\344\345\346\347\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377";
return (c != '\0' && strchr(lowChrs, c) != 0);
}
int isUpperCase(int c) /* IN - ISO character to test */
{
static char uppChrs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
return (c != '\0' && strchr(uppChrs, c) != 0);
int isUpperCase(int c) { /* IN - ISO character to test */
static char uppChrs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
return (c != '\0' && strchr(uppChrs, c) != 0);
}
int isISOLetter(int c) /* IN - ISO character to test */
{
return (isLowerCase(c) || isUpperCase(c));
int isISOLetter(int c) { /* IN - ISO character to test */
return (isLowerCase(c) || isUpperCase(c));
}
char toLowerCase(int c) /* IN - ISO character to convert */
{
return (isUpperCase(c)? c + ('a' - 'A'): c);
char toLowerCase(int c) { /* IN - ISO character to convert */
return (isUpperCase(c) ? c + ('a' - 'A') : c);
}
char toUpperCase(int c) /* IN - ISO character to convert */
{
return (isLowerCase(c)? c - ('a' - 'A'): c);
char toUpperCase(int c) { /* IN - ISO character to convert */
return (isLowerCase(c) ? c - ('a' - 'A') : c);
}
char *stringLower(char str[]) /* INOUT - ISO string to convert */
{
char *s;
char *stringLower(char str[]) { /* INOUT - ISO string to convert */
char *s;
for (s = str; *s; s++)
*s = toLowerCase(*s);
return(str);
for (s = str; *s; s++)
*s = toLowerCase(*s);
return (str);
}
char *stringUpper(char str[]) /* INOUT - ISO string to convert */
{
char *s;
char *stringUpper(char str[]) { /* INOUT - ISO string to convert */
char *s;
for (s = str; *s; s++)
*s = toUpperCase(*s);
return(str);
for (s = str; *s; s++)
*s = toUpperCase(*s);
return (str);
}
@ -229,65 +211,66 @@ char *stringUpper(char str[]) /* INOUT - ISO string to convert */
*/
void toIso(char copy[], /* OUT - Mapped string */
char original[], /* IN - string to convert */
int charset) /* IN - the current character set */
{
static unsigned char macMap[256]
= {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0A,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
0xC4,0xC5,0xC7,0xC9,0xD1,0xD6,0xDC,0xE1,0xE0,0xE2,0xE4,0xE3,0xE5,0xE7,0xE9,0xE8,
0xEA,0xEB,0xED,0xEC,0xEE,0xEF,0xF1,0xF3,0xF2,0xF4,0xF6,0xF5,0xFA,0xF9,0xFB,0xFC,
0xB9,0xB0,0xA2,0xA3,0xA7,0xB7,0xB6,0xDF,0xAE,0xA9,0xB2,0xB4,0xA8,0xD7,0xC6,0xD8,
0xA4,0xB1,0xCD,0xCC,0xA5,0xB5,0xF0,0xCA,0xDE,0xFE,0xA6,0xAA,0xBA,0xD4,0xE6,0xF8,
0xBF,0xA1,0xAC,0xCE,0xCF,0xC8,0xD0,0xAB,0xBB,0xCB,0xA0,0xC0,0xC3,0xD5,0xDD,0xFD,
0xAD,0xAF,0xDA,0xD9,0xB8,0xB3,0xF7,0xC2,0xFF,0xBC,0xBD,0xBE,0xC1,0xD2,0xD3,0xDB,
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F};
char original[], /* IN - string to convert */
int charset) { /* IN - the current character set */
static unsigned char macMap[256]
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0A, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0xC4, 0xC5, 0xC7, 0xC9, 0xD1, 0xD6, 0xDC, 0xE1, 0xE0, 0xE2, 0xE4, 0xE3, 0xE5, 0xE7, 0xE9, 0xE8,
0xEA, 0xEB, 0xED, 0xEC, 0xEE, 0xEF, 0xF1, 0xF3, 0xF2, 0xF4, 0xF6, 0xF5, 0xFA, 0xF9, 0xFB, 0xFC,
0xB9, 0xB0, 0xA2, 0xA3, 0xA7, 0xB7, 0xB6, 0xDF, 0xAE, 0xA9, 0xB2, 0xB4, 0xA8, 0xD7, 0xC6, 0xD8,
0xA4, 0xB1, 0xCD, 0xCC, 0xA5, 0xB5, 0xF0, 0xCA, 0xDE, 0xFE, 0xA6, 0xAA, 0xBA, 0xD4, 0xE6, 0xF8,
0xBF, 0xA1, 0xAC, 0xCE, 0xCF, 0xC8, 0xD0, 0xAB, 0xBB, 0xCB, 0xA0, 0xC0, 0xC3, 0xD5, 0xDD, 0xFD,
0xAD, 0xAF, 0xDA, 0xD9, 0xB8, 0xB3, 0xF7, 0xC2, 0xFF, 0xBC, 0xBD, 0xBE, 0xC1, 0xD2, 0xD3, 0xDB,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
};
static unsigned char dosMap[256]
= {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0A,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
0xC7,0xFC,0xE9,0xE2,0xE4,0xE0,0xE5,0xE7,0xEA,0xEB,0xE8,0xEF,0xEE,0xEC,0xC4,0xC5,
0xC9,0xE6,0xC6,0xF4,0xF6,0xF2,0xFB,0xF9,0xFF,0xD6,0xDC,0xA2,0xA3,0xA5,0xDE,0xA6,
0xE1,0xED,0xF3,0xFA,0xF1,0xD1,0xAA,0xBA,0xBF,0xC0,0xC1,0xBD,0xBC,0xCF,0xAB,0xBB,
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
0xA1,0xA7,0xAD,0xB3,0xB8,0xB9,0xC3,0xCE,0xD2,0xD3,0xDB,0xDD,0xE3,0xF5,0xF8,0xFD,
0xA9,0xDF,0xC8,0xB6,0xCA,0xA4,0xB5,0xAE,0xD5,0xD0,0xD4,0xF0,0xD7,0xD8,0xCB,0xC2,
0xBE,0xB1,0xD9,0xDA,0xCD,0xCC,0xF7,0xA8,0xB0,0xB7,0xAF,0xAC,0xFE,0xB2,0xB4,0xA0};
unsigned char *o, *c;
static unsigned char dosMap[256]
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0A, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7, 0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5,
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9, 0xFF, 0xD6, 0xDC, 0xA2, 0xA3, 0xA5, 0xDE, 0xA6,
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA, 0xBF, 0xC0, 0xC1, 0xBD, 0xBC, 0xCF, 0xAB, 0xBB,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA1, 0xA7, 0xAD, 0xB3, 0xB8, 0xB9, 0xC3, 0xCE, 0xD2, 0xD3, 0xDB, 0xDD, 0xE3, 0xF5, 0xF8, 0xFD,
0xA9, 0xDF, 0xC8, 0xB6, 0xCA, 0xA4, 0xB5, 0xAE, 0xD5, 0xD0, 0xD4, 0xF0, 0xD7, 0xD8, 0xCB, 0xC2,
0xBE, 0xB1, 0xD9, 0xDA, 0xCD, 0xCC, 0xF7, 0xA8, 0xB0, 0xB7, 0xAF, 0xAC, 0xFE, 0xB2, 0xB4, 0xA0
};
unsigned char *o, *c;
switch (charset) {
case 0: /* ISO */
if (copy != original)
(void)strcpy(copy, original);
break;
case 1: /* Mac */
for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++)
*c = macMap[*o];
*c = '\0';
break;
switch (charset) {
case 0: /* ISO */
if (copy != original)
(void)strcpy(copy, original);
break;
case 1: /* Mac */
for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++)
*c = macMap[*o];
*c = '\0';
break;
case 2: /* Dos */
for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++)
*c = dosMap[*o];
*c = '\0';
break;
}
case 2: /* Dos */
for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++)
*c = dosMap[*o];
*c = '\0';
break;
}
}
/*----------------------------------------------------------------------
@ -299,10 +282,9 @@ static unsigned char dosMap[256]
*/
void fromIso(char copy[], /* OUT - Mapped string */
char original[]) /* IN - string to convert */
{
if (copy != original)
(void)strcpy(copy, original);
char original[]) { /* IN - string to convert */
if (copy != original)
(void)strcpy(copy, original);
}
@ -314,13 +296,12 @@ void fromIso(char copy[], /* OUT - Mapped string */
the case of the compiler might be other than the native.
*/
void toNative(char copy[], /* OUT - Mapped string */
char original[], /* IN - string to convert */
int charset) /* IN - the current character set */
{
toIso(copy, original, charset);
if (NATIVECHARSET != 0)
fromIso(copy, copy);
void toNative(char copy[], /* OUT - Mapped string */
char original[], /* IN - string to convert */
int charset) { /* IN - the current character set */
toIso(copy, original, charset);
if (NATIVECHARSET != 0)
fromIso(copy, copy);
}
} // End of namespace Alan2

View File

@ -81,15 +81,15 @@ extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */
/* ISO string conversion functions */
extern void toIso(char copy[], /* OUT - Mapped string */
char original[], /* IN - string to convert */
int charset); /* IN - The current character set */
char original[], /* IN - string to convert */
int charset); /* IN - The current character set */
extern void fromIso(char copy[], /* OUT - Mapped string */
char original[]); /* IN - string to convert */
char original[]); /* IN - string to convert */
extern void toNative(char copy[], /* OUT - Mapped string */
char original[], /* IN - string to convert */
int charset); /* IN - current character set */
char original[], /* IN - string to convert */
int charset); /* IN - current character set */
} // End of namespace Alan2
} // End of namespace Glk

View File

@ -35,8 +35,8 @@ namespace Alan2 {
*/
void getPageSize() {
paglen = 0;
pagwidth = 0;
paglen = 0;
pagwidth = 0;
}
} // End of namespace Alan2

View File

@ -27,8 +27,8 @@ namespace Alan2 {
// This works around gcc errors for passing packed structure fields
static void syncVal(Common::Serializer &s, int *fld) {
int &v = *fld;
s.syncAsSint32LE(v);
int &v = *fld;
s.syncAsSint32LE(v);
}
void CurVars::synchronize(Common::Serializer &s) {

View File

@ -75,218 +75,218 @@ namespace Alan2 {
/* TYPES */
typedef int Boolean; /* Boolean values within interpreter */
typedef int Boolean; /* Boolean values within interpreter */
/* Amachine variables */
struct CurVars {
int
vrb,
obj,
loc,
act,
tick,
score,
visits;
int
vrb,
obj,
loc,
act,
tick,
score,
visits;
/**
* Read or write data to/from a save file
*/
void synchronize(Common::Serializer &s);
void synchronize(Common::Serializer &s);
};
#include "common/pack-start.h" // START STRUCT PACKING
#include "common/pack-start.h" // START STRUCT PACKING
/* The various tables */
struct WrdElem { /* Dictionary */
Aaddr wrd; /* ACODE address to string */
Aword _class; /* Word class */
Aword code;
Aaddr adjrefs; /* Address to reference list */
Aaddr nounrefs; /* Address to reference list */
struct WrdElem { /* Dictionary */
Aaddr wrd; /* ACODE address to string */
Aword _class; /* Word class */
Aword code;
Aaddr adjrefs; /* Address to reference list */
Aaddr nounrefs; /* Address to reference list */
} PACKED_STRUCT;
struct ActElem { /* ACTOR TABLE */
Aword loc; /* Location */
Abool describe; /* Description flag */
Aaddr nam; /* Address to name printing code */
Aaddr atrs; /* Address to attribute list */
Aword cont; /* Code for the container props if any */
Aword script; /* Which script is he using */
Aaddr scradr; /* Address to script table */
Aword step;
Aword count;
Aaddr vrbs;
Aaddr dscr; /* Address of description code */
struct ActElem { /* ACTOR TABLE */
Aword loc; /* Location */
Abool describe; /* Description flag */
Aaddr nam; /* Address to name printing code */
Aaddr atrs; /* Address to attribute list */
Aword cont; /* Code for the container props if any */
Aword script; /* Which script is he using */
Aaddr scradr; /* Address to script table */
Aword step;
Aword count;
Aaddr vrbs;
Aaddr dscr; /* Address of description code */
} PACKED_STRUCT;
struct ScrElem { /* SCRIPT TABLE */
Aword code; /* Script number */
Aaddr dscr; /* Optional description statements */
Aaddr steps; /* Address to steps */
struct ScrElem { /* SCRIPT TABLE */
Aword code; /* Script number */
Aaddr dscr; /* Optional description statements */
Aaddr steps; /* Address to steps */
} PACKED_STRUCT;
struct StepElem { /* STEP TABLE */
Aword after; /* After how many ticks? */
Aaddr exp; /* Address to expression saying when */
Aaddr stm; /* Address to the actual code */
struct StepElem { /* STEP TABLE */
Aword after; /* After how many ticks? */
Aaddr exp; /* Address to expression saying when */
Aaddr stm; /* Address to the actual code */
} PACKED_STRUCT;
struct LocElem { /* LOCATION TABLE */
Aaddr nams; /* Address of name printing code */
Aaddr dscr; /* Address of description code */
Aaddr does; /* Address of does code */
Aword describe; /* Description flag & counter */
Aaddr atrs; /* Address of attribute list */
Aaddr exts; /* Address of exit list */
Aaddr vrbs; /* Address of local verb list */
struct LocElem { /* LOCATION TABLE */
Aaddr nams; /* Address of name printing code */
Aaddr dscr; /* Address of description code */
Aaddr does; /* Address of does code */
Aword describe; /* Description flag & counter */
Aaddr atrs; /* Address of attribute list */
Aaddr exts; /* Address of exit list */
Aaddr vrbs; /* Address of local verb list */
} PACKED_STRUCT;
struct ExtElem { /* EXIT TABLE structure */
Abool done; /* Flag for reverse/convert process */
Aword code; /* Direction code */
Aaddr checks; /* Address of check table */
Aaddr action; /* Address of action code */
Aword next; /* Number of next location */
struct ExtElem { /* EXIT TABLE structure */
Abool done; /* Flag for reverse/convert process */
Aword code; /* Direction code */
Aaddr checks; /* Address of check table */
Aaddr action; /* Address of action code */
Aword next; /* Number of next location */
} PACKED_STRUCT;
struct ChkElem { /* CHECK TABLE */
Aaddr exp; /* ACODE address to expression code */
Aaddr stms; /* ACODE address to statement code */
struct ChkElem { /* CHECK TABLE */
Aaddr exp; /* ACODE address to expression code */
Aaddr stms; /* ACODE address to statement code */
} PACKED_STRUCT;
struct VrbElem { /* VERB TABLE */
Aword code; /* Code for the verb */
Aaddr alts; /* Address to alternatives */
struct VrbElem { /* VERB TABLE */
Aword code; /* Code for the verb */
Aaddr alts; /* Address to alternatives */
} PACKED_STRUCT;
struct StxElem { /* SYNTAX TABLE */
Aword code; /* Code for verb word */
Aaddr elms; /* Address to element tables */
struct StxElem { /* SYNTAX TABLE */
Aword code; /* Code for verb word */
Aaddr elms; /* Address to element tables */
} PACKED_STRUCT;
struct ElmElem26 { /* ELEMENT TABLES */
Aword code; /* Code for this element, 0 -> parameter */
Abool multiple; /* May be multiple (if parameter) */
Aaddr next; /* Address to next element table ... */
/* ... or class check if EOS */
struct ElmElem26 { /* ELEMENT TABLES */
Aword code; /* Code for this element, 0 -> parameter */
Abool multiple; /* May be multiple (if parameter) */
Aaddr next; /* Address to next element table ... */
/* ... or class check if EOS */
} PACKED_STRUCT;
struct ElmElem { /* ELEMENT TABLES */
Aword code; /* Code for this element, 0 -> parameter */
Aword flags; /* Flags for multiple/omni (if parameter) */
/* CHANGED: v2.7 from Abool for multiple */
Aaddr next; /* Address to next element table ... */
/* ... or class check if EOS */
struct ElmElem { /* ELEMENT TABLES */
Aword code; /* Code for this element, 0 -> parameter */
Aword flags; /* Flags for multiple/omni (if parameter) */
/* CHANGED: v2.7 from Abool for multiple */
Aaddr next; /* Address to next element table ... */
/* ... or class check if EOS */
} PACKED_STRUCT;
struct ClaElem { /* CLASS DEFINITION TABLE */
Aword code; /* Parameter number */
Aword classes; /* Parameter classes */
Aaddr stms; /* Exception statements */
struct ClaElem { /* CLASS DEFINITION TABLE */
Aword code; /* Parameter number */
Aword classes; /* Parameter classes */
Aaddr stms; /* Exception statements */
} PACKED_STRUCT;
struct AltElem { /* VERB ALTERNATIVE TABLE */
Abool done; /* Flag for patching (reverse/convert) process */
Aword param; /* Parameter number */
Aword qual; /* Verb execution qualifier */
Aaddr checks; /* Address of the check table */
Aaddr action; /* Address of the action code */
struct AltElem { /* VERB ALTERNATIVE TABLE */
Abool done; /* Flag for patching (reverse/convert) process */
Aword param; /* Parameter number */
Aword qual; /* Verb execution qualifier */
Aaddr checks; /* Address of the check table */
Aaddr action; /* Address of the action code */
} PACKED_STRUCT;
struct AtrElem { /* ATTRIBUTE LIST */
Aword val; /* Its value */
Aaddr stradr; /* Address to the name */
struct AtrElem { /* ATTRIBUTE LIST */
Aword val; /* Its value */
Aaddr stradr; /* Address to the name */
} PACKED_STRUCT;
struct ObjElem25 { /* OBJECT TABLE of 2.5 format*/
Aword loc; /* Current location */
Abool describe; /* Describe flag */
Aaddr atrs; /* Address of attribute list */
Aword cont; /* Index to container properties if any */
Aaddr vrbs; /* Address to local verb table */
Aaddr dscr1; /* Address to Aword description code */
Aaddr dscr2; /* Address to short description code */
struct ObjElem25 { /* OBJECT TABLE of 2.5 format*/
Aword loc; /* Current location */
Abool describe; /* Describe flag */
Aaddr atrs; /* Address of attribute list */
Aword cont; /* Index to container properties if any */
Aaddr vrbs; /* Address to local verb table */
Aaddr dscr1; /* Address to Aword description code */
Aaddr dscr2; /* Address to short description code */
} PACKED_STRUCT;
struct ObjElem { /* OBJECT TABLE */
Aword loc; /* Current location */
Abool describe; /* Describe flag */
Aaddr atrs; /* Address of attribute list */
Aword cont; /* Index to container properties if any */
Aaddr vrbs; /* Address to local verb table */
Aaddr dscr1; /* Address to Aword description code */
Aaddr art; /* Article printing code? Else use default */
/* INTRODUCED: v2.6 */
Aaddr dscr2; /* Address to short description code */
struct ObjElem { /* OBJECT TABLE */
Aword loc; /* Current location */
Abool describe; /* Describe flag */
Aaddr atrs; /* Address of attribute list */
Aword cont; /* Index to container properties if any */
Aaddr vrbs; /* Address to local verb table */
Aaddr dscr1; /* Address to Aword description code */
Aaddr art; /* Article printing code? Else use default */
/* INTRODUCED: v2.6 */
Aaddr dscr2; /* Address to short description code */
} PACKED_STRUCT;
struct CntElem { /* CONTAINER TABLE */
Aaddr lims; /* Address to limit check code */
Aaddr header; /* Address to header code */
Aaddr empty; /* Address to empty code */
Aword parent; /* Object or actor index */
Aaddr nam; /* Address to statement printing name */
struct CntElem { /* CONTAINER TABLE */
Aaddr lims; /* Address to limit check code */
Aaddr header; /* Address to header code */
Aaddr empty; /* Address to empty code */
Aword parent; /* Object or actor index */
Aaddr nam; /* Address to statement printing name */
} PACKED_STRUCT;
struct LimElem { /* LIMIT Type */
Aword atr; /* Attribute that limits */
Aword val; /* And the limiting value */
Aaddr stms; /* Statements if fail */
struct LimElem { /* LIMIT Type */
Aword atr; /* Attribute that limits */
Aword val; /* And the limiting value */
Aaddr stms; /* Statements if fail */
} PACKED_STRUCT;
struct RulElem { /* RULE TABLE */
Abool run; /* Is rule already run? */
Aaddr exp; /* Address to expression code */
Aaddr stms; /* Address to run */
struct RulElem { /* RULE TABLE */
Abool run; /* Is rule already run? */
Aaddr exp; /* Address to expression code */
Aaddr stms; /* Address to run */
} PACKED_STRUCT;
struct EvtElem { /* EVENT TABLE */
Aaddr stradr; /* Address to name string */
Aaddr code; /* Address of code to run */
struct EvtElem { /* EVENT TABLE */
Aaddr stradr; /* Address to name string */
Aaddr code; /* Address of code to run */
} PACKED_STRUCT;
struct EvtqElem { /* EVENT QUEUE ELEMENT */
int time;
int event;
int where;
struct EvtqElem { /* EVENT QUEUE ELEMENT */
int time;
int event;
int where;
/**
* Read or write data to/from a save file
*/
void synchronize(Common::Serializer &s);
/**
* Read or write data to/from a save file
*/
void synchronize(Common::Serializer &s);
} PACKED_STRUCT;
struct IniElem { /* STRING INITIALISATION TABLE */
Aword fpos; /* File position */
Aword len; /* Length */
Aword adr; /* Where to store the string */
struct IniElem { /* STRING INITIALISATION TABLE */
Aword fpos; /* File position */
Aword len; /* Length */
Aword adr; /* Where to store the string */
} PACKED_STRUCT;
struct MsgElem26 { /* MESSAGE TABLE */
Aword fpos; /* File position */
Aword len; /* Length of message */
struct MsgElem26 { /* MESSAGE TABLE */
Aword fpos; /* File position */
Aword len; /* Length of message */
} PACKED_STRUCT;
struct MsgElem { /* MESSAGE TABLE */
Aaddr stms; /* Address to statements*/
/* Changed v2.7 from fpos+len in .dat */
struct MsgElem { /* MESSAGE TABLE */
Aaddr stms; /* Address to statements*/
/* Changed v2.7 from fpos+len in .dat */
} PACKED_STRUCT;
struct ParamElem { /* PARAMETER */
Aword code; /* Code for this parameter (0=multiple) */
Aword firstWord; /* Index to first word used by player */
Aword lastWord; /* d:o to last */
struct ParamElem { /* PARAMETER */
Aword code; /* Code for this parameter (0=multiple) */
Aword firstWord; /* Index to first word used by player */
Aword lastWord; /* d:o to last */
} PACKED_STRUCT;
typedef enum Type {TYPNUM, TYPSTR} Type;
struct LitElem { /* LITERAL */
Type type;
Aptr value;
struct LitElem { /* LITERAL */
Type type;
Aptr value;
} PACKED_STRUCT;
#include "common/pack-end.h" // END STRUCT PACKING
#include "common/pack-end.h" // END STRUCT PACKING
#define MAXPARAMS 9
#define MAXENTITY (header->actmax)

View File

@ -31,25 +31,25 @@ namespace Alan2 {
typedef int64 Time;
struct Version {
char* string;
int version;
int revision;
int correction;
Time time;
char *state;
char *string;
int version;
int revision;
int correction;
Time time;
char *state;
};
struct Product {
char* name;
char* slogan;
char* shortHeader;
char* longHeader;
char* date;
char* time;
char* user;
char* host;
char* ostype;
Version version;
char *name;
char *slogan;
char *shortHeader;
char *longHeader;
char *date;
char *time;
char *user;
char *host;
char *ostype;
Version version;
};