diff options
author | Paul Gilbert | 2019-06-17 22:36:31 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-06-22 14:40:49 -0700 |
commit | 08bc570308b0698090ce668dc7dca4c0c76dd3df (patch) | |
tree | 59baa530a4f79b16185c5422ed9f2b706011c8b2 /engines/glk/alan2/types.h | |
parent | 84dfa6d3b83e080f099ad606dc7fbeb40ebe4b97 (diff) | |
download | scummvm-rg350-08bc570308b0698090ce668dc7dca4c0c76dd3df.tar.gz scummvm-rg350-08bc570308b0698090ce668dc7dca4c0c76dd3df.tar.bz2 scummvm-rg350-08bc570308b0698090ce668dc7dca4c0c76dd3df.zip |
GLK: ALAN2: Initial import of full set of interpreter files
Diffstat (limited to 'engines/glk/alan2/types.h')
-rw-r--r-- | engines/glk/alan2/types.h | 469 |
1 files changed, 241 insertions, 228 deletions
diff --git a/engines/glk/alan2/types.h b/engines/glk/alan2/types.h index 7da9e1dc58..2de31c06bf 100644 --- a/engines/glk/alan2/types.h +++ b/engines/glk/alan2/types.h @@ -23,248 +23,261 @@ #ifndef GLK_ALAN2_TYPES #define GLK_ALAN2_TYPES +#include "glk/alan2/sysdep.h" #include "glk/alan2/acode.h" namespace Glk { namespace Alan2 { -// CONSTANTS - -#define ACTMIN (_vm->header->actmin) -#define ACTMAX (_vm->header->actmax) -#define OBJMIN (_vm->header->objmin) -#define OBJMAX (_vm->header->objmax) -#define LOCMIN (_vm->header->locmin) -#define LOCMAX (_vm->header->locmax) -#define CNTMIN (_vm->header->cntmin) -#define CNTMAX (_vm->header->cntmax) -#define LITMIN (_vm->header->locmax + 1) -#define LITMAX (_vm->header->locmax + 1 + litCount) -#define EVTMIN (_vm->header->evtmin) -#define EVTMAX (_vm->header->evtmax) +/* CONSTANTS */ + +#ifndef __mac__ +#ifndef TRUE +#define TRUE (0==0) +#endif +#ifndef FALSE +#define FALSE (!TRUE) +#endif +#endif + +#define ACTMIN (header->actmin) +#define ACTMAX (header->actmax) +#define OBJMIN (header->objmin) +#define OBJMAX (header->objmax) +#define LOCMIN (header->locmin) +#define LOCMAX (header->locmax) +#define CNTMIN (header->cntmin) +#define CNTMAX (header->cntmax) +#define LITMIN (header->locmax+1) +#define LITMAX (header->locmax+1+litCount) +#define EVTMIN (header->evtmin) +#define EVTMAX (header->evtmax) #define HERO ACTMIN -#define addrTo(x) (&_vm->memory[x]) - -// The word classes are represented as numbers but in the dictonary they are generated as bits -#define isVerb(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_VRB))!=0) -#define isConj(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_CONJ))!=0) -#define isBut(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_BUT))!=0) -#define isThem(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_THEM))!=0) -#define isIt(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_IT))!=0) -#define isNoun(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_NOUN))!=0) -#define isAdj(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_ADJ))!=0) -#define isPrep(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_PREP))!=0) -#define isAll(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_ALL))!=0) -#define isDir(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_DIR))!=0) -#define isNoise(word) (word < dictsize && (dict[word].wordClass&((Aword)1L<<WRD_NOISE))!=0) +#define addrTo(x) (&memory[x]) + +/* The word classes are represented as numbers but in the dictonary they are generated as bits */ +#define isVerb(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_VRB))!=0) +#define isConj(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_CONJ))!=0) +#define isBut(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_BUT))!=0) +#define isThem(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_THEM))!=0) +#define isIt(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_IT))!=0) +#define isNoun(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_NOUN))!=0) +#define isAdj(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_ADJ))!=0) +#define isPrep(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_PREP))!=0) +#define isAll(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_ALL))!=0) +#define isDir(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_DIR))!=0) +#define isNoise(word) (word < dictsize && (dict[word]._class&((Aword)1L<<WRD_NOISE))!=0) #define isLiteral(word) (word >= dictsize) -// TYPES - -// Amachine variables -struct CurVars { - int vrb; - int obj; - int loc; - int act; - int tick; - int score; - int visits; -}; - -// The various tables -struct WrdElem { // Dictionary - Aaddr wrd; // ACODE address to string - Aword wordClass; // Word class - Aword code; - Aaddr adjrefs; // Address to reference list - Aaddr nounrefs; // Address to reference list -}; - -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 ScrElem { // SCRIPT TABLE - Aword code; // Script number - Aaddr dscr; // Optional description statements - Aaddr steps; // Address to steps -}; - -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 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 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 ChkElem { // CHECK TABLE - Aaddr exp; // ACODE address to expression code - Aaddr stms; // ACODE address to statement code -}; - -struct VrbElem { // VERB TABLE - Aword code; // Code for the verb - Aaddr alts; // Address to alternatives -}; - -struct StxElem { // SYNTAX TABLE - Aword code; // Code for verb word - Aaddr elms; // Address to element tables -}; - -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 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 ClaElem { // CLASS DEFINITION TABLE - Aword code; // Parameter number - Aword classes; // Parameter classes - Aaddr stms; // Exception statements -}; - -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 AtrElem { // ATTRIBUTE LIST - Aword val; // Its value - Aaddr stradr; // Address to the name -}; - -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 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 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 LimElem { // LIMIT Type - Aword atr; // Attribute that limits - Aword val; // And the limiting value - Aaddr stms; // Statements if fail -}; - -struct RulElem { // RULE TABLE - Abool run; // Is rule already run? - Aaddr exp; // Address to expression code - Aaddr stms; // Address to run -}; - -struct EvtElem { // EVENT TABLE - Aaddr stradr; // Address to name string - Aaddr code; // Address of code to run -}; - -struct EvtqElem { // EVENT QUEUE ELEMENT - int time; - int event; - int where; -}; - -struct IniElem { // STRING INITIALISATION TABLE - Aword fpos; // File position - Aword len; // Length - Aword adr; // Where to store the string -}; - -struct MsgElem26 { // MESSAGE TABLE - Aword fpos; // File position - Aword len; // Length of message -}; - -struct MsgElem { // MESSAGE TABLE - Aaddr stms; // Address to statements - // Changed v2.7 from fpos+len in .dat -}; - -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 -}; - -enum Type { - TYPNUM, - TYPSTR -}; - -struct LitElem { // LITERAL - Type type; - Aptr value; -}; +/* TYPES */ + +#ifndef __mac__ +typedef int Boolean; /* Boolean values within interpreter */ +#endif + +/* Amachine variables */ +typedef struct CurVars { + int + vrb, + obj, + loc, + act, + tick, + score, + visits; +} CurVars; + +/* The various tables */ +typedef 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 */ +} WrdElem; + +typedef 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 */ +} ActElem; + +typedef struct ScrElem { /* SCRIPT TABLE */ + Aword code; /* Script number */ + Aaddr dscr; /* Optional description statements */ + Aaddr steps; /* Address to steps */ +} ScrElem; + +typedef struct StepElem { /* STEP TABLE */ + Aword after; /* After how many ticks? */ + Aaddr exp; /* Address to expression saying when */ + Aaddr stm; /* Address to the actual code */ +} StepElem; + +typedef 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 */ +} LocElem; + +typedef 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 */ +} ExtElem; + +typedef struct ChkElem { /* CHECK TABLE */ + Aaddr exp; /* ACODE address to expression code */ + Aaddr stms; /* ACODE address to statement code */ +} ChkElem; + +typedef struct VrbElem { /* VERB TABLE */ + Aword code; /* Code for the verb */ + Aaddr alts; /* Address to alternatives */ +} VrbElem; + +typedef struct StxElem { /* SYNTAX TABLE */ + Aword code; /* Code for verb word */ + Aaddr elms; /* Address to element tables */ +} StxElem; + +typedef 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 */ +} ElmElem26; + +typedef 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 */ +} ElmElem; + +typedef struct ClaElem { /* CLASS DEFINITION TABLE */ + Aword code; /* Parameter number */ + Aword classes; /* Parameter classes */ + Aaddr stms; /* Exception statements */ +} ClaElem; + +typedef 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 */ +} AltElem; + +typedef struct AtrElem { /* ATTRIBUTE LIST */ + Aword val; /* Its value */ + Aaddr stradr; /* Address to the name */ +} AtrElem; + +typedef 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 */ +} ObjElem25; + +typedef 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 */ +} ObjElem; + +typedef 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 */ +} CntElem; + +typedef struct LimElem { /* LIMIT Type */ + Aword atr; /* Attribute that limits */ + Aword val; /* And the limiting value */ + Aaddr stms; /* Statements if fail */ +} LimElem; + +typedef struct RulElem { /* RULE TABLE */ + Abool run; /* Is rule already run? */ + Aaddr exp; /* Address to expression code */ + Aaddr stms; /* Address to run */ +} RulElem; + +typedef struct EvtElem { /* EVENT TABLE */ + Aaddr stradr; /* Address to name string */ + Aaddr code; /* Address of code to run */ +} EvtElem; + +typedef struct EvtqElem { /* EVENT QUEUE ELEMENT */ + int time; + int event; + int where; +} EvtqElem; + +typedef struct IniElem { /* STRING INITIALISATION TABLE */ + Aword fpos; /* File position */ + Aword len; /* Length */ + Aword adr; /* Where to store the string */ +} IniElem; + +typedef struct MsgElem26 { /* MESSAGE TABLE */ + Aword fpos; /* File position */ + Aword len; /* Length of message */ +} MsgElem26; + +typedef struct MsgElem { /* MESSAGE TABLE */ + Aaddr stms; /* Address to statements*/ + /* Changed v2.7 from fpos+len in .dat */ +} MsgElem; + + +typedef 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 */ +} ParamElem; + +typedef enum Type {TYPNUM, TYPSTR} Type; + +typedef struct LitElem { /* LITERAL */ + Type type; + Aptr value; +} LitElem; #define MAXPARAMS 9 -#define MAXENTITY (_vm->header->actmax) +#define MAXENTITY (header->actmax) } // End of namespace Alan2 } // End of namespace Glk |