
#pragma pack(1)  


#define maxFilesOpen 5
#define MAXLOAD 2000 // Else ASSERTION! 
                     // I had some troubles with loads.
                     // Loads can be larger but this is a nice
                     // number for debugging purposes.


struct MouseQueueEnt;
struct ITEMQ;

void TranslateFullscreen(int a, int b, int& x, int& y);

enum SPEEDS
{
  SPEED_GLACIAL,
  SPEED_MOLASSES,
  SPEED_VERYSLOW,
  SPEED_SLOW,
  SPEED_NORMAL,
  SPEED_FAST,
  SPEED_QUICK,
  SPEED_NUMSPEED
};

class SPEEDTABLE
{
public:
  int vblPerTick;
};

extern SPEEDTABLE speedTable[SPEED_NUMSPEED];
extern bool playerClock;
extern bool extraTicks;
extern SPEEDS gameSpeed;
extern int totalMoveCount;
extern bool NoSound;
extern bool NoSleep;
extern bool AutoEnlarge;
extern bool ThreeDMovements;
extern bool GravityGame;
extern bool gravityMove;
extern bool DM_rules;
extern int nextGravityMoveTime;
extern char moveHistory[4];
extern int  ExtendedFeaturesSize;
extern char ExtendedFeaturesVersion;
extern int RememberToPutObjectInHand;
extern char *dungeonName;
extern char *folderName;
extern char *folderParentName;
extern char *folderSavedGame;
extern char *root;
extern int  *videoSegSize;
extern int  *videoSegSrcX;
extern int  *videoSegSrcY;
extern int  *videoSegWidth;
extern int  *videoSegHeight;
extern int  *videoSegX;
extern int  *videoSegY;


// File handles are indexes into this table.
extern FILETABLE fileTable[maxFilesOpen];
extern i16 TraceFile;
class RECORDFILE 
{
private:
  i16  m_fileNum;
public:
  RECORDFILE(void) {m_fileNum = -1;};
  ~RECORDFILE(void) {if (m_fileNum >= 0) CLOSE(m_fileNum);};
  bool IsOpen(void) {return m_fileNum >= 0;};
  void Open(void);
  void Close(void);
  void Record(MouseQueueEnt *happening);
  void Record(int x, int y, int func);
  void CycleRandom(int n);
};

extern RECORDFILE RecordFile;

class PLAYFILE 
{
private:
  i16 m_file;
  i32 m_time, m_x, m_y, m_num, m_oldTime, m_oldCallCount;
  ui32 m_ran;
public:
  PLAYFILE(void) {m_file=-1; m_time=-1;};
  ~PLAYFILE(void) {if (m_file >= 0) CLOSE(m_file);};
  bool IsOpen(void) {return m_file >= 0;};
  void Open(void);
  void Close(void);
  bool Play(MouseQueueEnt *);
  void Backspace(MouseQueueEnt *);
};

extern PLAYFILE PlayFile;

extern bool TimerTraceActive;
extern bool AttackTraceActive;

extern i32 NoSpeedLimit;
extern bool NoClock;
extern bool BeginRecordOK;
extern bool ItemsRemainingOK;
extern i32 keyboardMode;
extern i32 NumberFloppyDrives;
extern bool gameFrozen;
extern i32 screenSize;
extern bool DiskMenuNeeded;
extern i32 GameTime;
extern i32  MostRecentlyAdjustedSkills[2];
extern i32  LatestSkillValues[2];
extern i32  AdjustedSkillNumber;
extern char *tracePrefix;
char *initialTracePrefix(bool trace);
char *nextTracePrefix(char *trace);


struct SD
{
  SD *pnext;
  char name[16];
  i32 minimum;
  float level;
  float y_intercept;
  float slope;
};

class SDLIST
{ // A class so destructor will release memory
  SD *psd;
public:
  SDLIST(void) { psd=NULL; };
  ~SDLIST(void);
  SD *newSD(char *,i32,float,float,float);
  SD *First(void);
  SD *Next(SD *ent);
};

extern SDLIST sdList;

struct SDENT
{
  i32 minimum;
  float level;
  float y_intercept;
  float slope;
};

extern SDENT sdTable[199];

#define FILL(a,b) i8 fill##a[a-b];

#define IllegalWallDecorationWarning 1

struct DBank {
  i16 LZWrepeatChar; // (23408) repeated by character 0x90 0xxx sequence
                     //    except that 0x90 0x00 means 0x90.
  i16 Word23406;
  i16 LZWBitNumber; // (23404) Bit number within 9-byte I/O buffer
  i8  RightOneMask[9];      // 23402
  FILL(23393,23392)
  i8  RightZeroMask[9];     // 23392
  FILL(23383,23382)
  i16 Word23382;
  i16 LZWNextCode;    // (23380)
  i8  IOBuffer[12]; // (23378)how big should this be????? At least 9!
  i16 Word23366;
  i16 LZWMaxCode;  //(23364)Maximum code value (eg: 511 for 9 bit code)
  i16 LZWCodeSize; //(23362)Number of bits.
  i16 LZWrepeatFlag; //(23360)
  i32 Long23358; // copied from 11718 = d.Time
                 // While d.Time == this value the second part
                 // of the graphic list is not cleared.
  i16 newFlags;//Unused23354;//BigMemory; //23354// Set if lots of memory. (>370000 avail)
       // See the flags devinitions at top of struct.
  ITEMQ *pqFirstGraphic2;//23352; //First ITEMQ in 2nd part of list
  ITEMQ *pqLastGraphic; //23348; // Last ITEMQ in list?
  ITEMQ *pqFirstGraphic;//23344; // First ITEMQ in list
            // There is a list of graphics.  The first entry in the list
            // is   pqFirstGraphic and the last is    pqLastGraphic.
            // ** BUT ** the list is divided into two parts and the first
            // entry in the second part is   pqFirstGraphic2.
  ITEMQ *pgUnused; //23340; First free graphics buffer
  i32 Long23336; //space remaining?
  ITEMQ **ppqBuffers;//23332; // pointer to 5100 bytes initially zero
                           // Each pointer points to an ITEMQ
                           // which is followed by a bitmap
                           // and another longword with the size repeated.
                           // So each buffer has the form:
                           //  i32 size (Negative if allocated)
                           //  i16 flag
                           //  i16 index of previous
                           //  i16 index of next
                           //  i16 graphic number
                           //  (size - 16) bytes of graphic
                           //  i32 size (Negative if allocated)
  i16 Word23328;
  i32 Long23326;    //  Static memory remaining size.
  pnt Pointer23322;  // Start of remainder of static memory.
  pnt Pointer23318;  // Next available memory location.  Increments as memory allocated.
  pnt Pointer23314;
  pnt Pointer23310;
  i32 Long23306;     // 'malloc' memory remaining size
  FILL(23302,23298)
  pnt Pointer23298;  // Address of remainder of 'malloc' memory.
  pnt Pointer23294;  // Address of end of 'malloc' memory
  i16 CacheInvalid;  // (23290) non-zero if contents of ClusterCache is invalid
  pnt ClusterCache;  // (23288) Pointer to 1024 bytes
  pnt Pointer23284;  // 10000 below initially allocated memory blocks
  pnt Pointer23280;  // Start of 'malloc' memory
  i16 ClusterInCache;// (23276) Current cluster in ClusterCache
  i16 *pwPointer23274;  // Pointer to 1460 bytes of memory
  i16 *GraphicIndex;//23270;  
                        // 730 words filled with -1 initially
                        // For each graphic number, this is the index in 
                        // the graphic cache.
  i16 *pwPointer23266;  // Each graphics index in ppq23332.
          // 23266 and 23270 contain the graphics buffer index for each 
          // of the graphics numbers.
          // There are two types of graphics:  Those with graphics numbers
          // with bit 15 set (0x8000) are listed in 23270 and those with
          // bit 15 clear are listed in 23266.
          // A graphic is located at ppqBuffers[pwPointernnnn[graphicNum]].
  pnt *ppPointer23262;  // See immediately below.
  ui16 *GraphicExpSizes; //(23258) Sizes of expanded graphics
  ui16 *GraphicSizes;    //(23254) Array .. size of each graphic.
  i32 GraphicFileEOF;   //(23250) End+1 of GRAPHICS.DAT file
  ui16 NumGraphic;      //(23246) First two bytes of file are put here.(handle Word23242)
                  // This is the number of graphics in GRAPHICS.DAT
                  // Sizes put at *Pointer23254 
                  // Second block put at *Pointer23258;
                  // *Pointer23262 is a buffer twice the block size
                  //   with first half cleared.
                  // *Pointer 23266 is a blocksize buffer filled with -1;
  i16 Word23244; // File open count? Reference count?
  i16 GraphicHandle; // (23242)File handle
  FILL(23240,23236)

    // VBL handler fetches these function pointers but
    // it appears that the use of the pointers has
    // been 'NOP'ed out.
  void (*pFunc23236)(i32 P1);
  void (*pFunc23232)(void);
  i16 Word23228;
  i16 Word23226;
  i16 OnMouseSwitchActionLock;//Word23224; // Test/Set for Mouse interrupt
  RectPos wRectPos23222;
  RectPos wRectPos23214;
  i8  Byte23206[4];
  i8  Byte23202[4];
  pnt SavedCursorPixels; //Pointer23198; 
  pnt ScreenCursorAddress;// Area saved uder cursor//Pointer23194; 
  pnt Pointer23190;
  pnt Pointer23186;
  pnt Pointer23182;
  pnt Pointer23178;
  pnt CursorBitmap; //Pointer23174; Adjusted to be on word boundary
  pnt Pointer23170; // used in VBL handler
  i16 CursorWidth; //Word23166// in 16-pixel units
  i16 CursorHeight; //Word23164
  i16 NewCursorY; //Word23162// new cursor x pos
  i16 NewCursorX; //Word23160// new cursor y pos
  i16 Word23158; // Cursor Hotspot y???
  i16 Word23156; // Cursor Hotspot x???
  i16 CurCursorY; //Word23154// current cursor x pos
  i16 CurCursorX; //Word23152// current cursor y pos
i16 Word23150;
  i16 CursorShape;//23148; 0 = Arrow
  i16 Word23146; // used in vertical blank handler
  i16 Word23144; // Special cursor flag??? Ordinal 
                 // of character whose position is moving
  i16 NewCursorShape; //Word23142;// 0 or 1
  i16 Word23140; // used in mouse interrupt handler
                 // Set when showing skill levels
  i16 Word23138; // used in vertical blank handler
  i16 Word23136; // Cursor is being displayed. Save area valid.
  i16 Word23134; // Referenced in mouse interrupt
  i16 Word23132; // used in vertical blank handler
  i16 Word23130;
  i16 CurMouseY; //Word23128;
  i16 CurMouseX; //Word23126;
  i16 NewMouseY; //Word23124;
  i16 NewMouseX; //Word23122;
  i16 MouseSwitches;//23120; // Mouse interrupt
  i16 Word23118; // Hide cursor counter???
  i16 Word23116;
  i8  Byte23114;
  FILL(23113,23046)
  i16 Word23046;   //if non-zero then volume
  i16 CurrentSound;//23044;
  i8  Byte23042; // Save old keyclick state from $484
  FILL(23041,23040)
  pnt Pointer23040; // Pointer to $484 = conterm = keyclick
  i16 Word23036;
  FILL(23034,23032)
  i16 UseByteCoordinates;//23032; // Affects whether bytes or 
                         // words are used in RectPos in
                         //  Bitmap operations
  i8  Byte23030;
  FILL(23029,23024)
  i8  Byte23024;
  FILL(23023,23008)
  i8  Byte23008;
  FILL(23007,22992)
  i16 DualFloppyDrive;//Word22992; // Set to 1 if 2 floppy drives
  FILL(22990,22988)
  pnt Pointer22988; // Set to "DRIVE."
  pnt Pointer22984; // Set to "DRIVE."
  pnt Pointer22980;  
  pnt SaveGameFilename;//22976;
  i16 Word22972;
  i16 SingleFloppyDrive; //Word22970; // Set to 1 if not 2 floppy drives
  pnt Pointer22968; // Graphic #534
  pnt Pointer22964; // Graphic #535
  pnt Pointer22960; // Graphic #5
  pnt Pointer22956; // Graphic #4 Prison entrance minus door
  pnt Pointer22952; // Graphic #2 Prison door - left
  pnt Pointer22948; //  ShrinkBLT (Graphic #2)
  pnt Pointer22944; //  ShrinkBLT (Graphic #2)
  pnt Pointer22940; //  ShrinkBLT (Graphic #2)
  pnt Pointer22936; // Graphic #3 Prison door - right
  pnt Pointer22932; //  ShrinkBLT (Graphic #3)
  pnt Pointer22928; //  ShrinkBLT (Graphic #3)
  pnt Pointer22924; //  ShrinkBLT (Graphic #3)
  pnt Pointer22920;
  pnt Pointer22916; // Prison dungeon interior
  pnt Pointer22912;
  pnt Pointer22908;
  pnt Pointer22904;
  pnt Pointer22900;
  pnt Pointer22896;
  pnt Pointer22892;
  pnt Pointer22888;
  pnt Pointer22884;
  pnt Pointer22880;
  pnt Pointer22876;
  pnt Pointer22872;
  pnt Pointer22868;
  pnt Pointer22864;
  pnt Pointer22860;
  pnt Pointer22856;
  pnt Pointer22852;
  pnt Pointer22848;
  pnt Pointer22844;
  pnt Pointer22840;
  pnt Pointer22836;
  pnt Pointer22832;
  pnt Pointer22828;
  pnt Pointer22824;
  pnt Pointer22820;
  pnt Pointer22816;
  pnt Pointer22812;
  i8  Byte22808[132]; // read/write as unit to CSBGAME.DAT
  i8  Byte22676;
  FILL(22675,22608)
  i32 inStreamLeft; // 22608 // #bytes left in input stream
  pnt inStreamNext; // 22604 // Next byte in input stream
  i16 inStreamBuffered; // 22600 flag if input from buffer
  i16 Word22598;
  i16 Word22596; // equals 1 or 2 ; I have never seen anything
                 // but a 2.
  i16 Word22594;
  i16 Word22592; // From bytes 6 and 7 of dungeon.dat file = 0x000c
                 // distinguish between DM and CSB????
  i32 RandomGameID;//22590; // Set to random when prison opened
  i16 CanRestartFromSavegame;// Word22586; 
                 //Set to 1 after loading savegame.
                 //Set to 1 after saving game.
                 //Set to 0 after loading dungeon.
                 //Set to 0 after winning game with 4 corbum.
                 //Set to zero after printing "THE END"
                 //Set to zero before killing entire party.
  i16 PartyHasDied;//Word22584;  //Set when party died
  FILL (22582,22578)
  i16 datafileHandle; // 22578// Dungeon.dat file handle
  FILL(22576,22572)
  RN  MonsterUnderAttack;//22572
  i8  Byte22570[186];
  //i16 Word22386;
  i16 Word22384;
  FILL(22382,21994)
  i8  Byte21994[576]; // Magic menu???
  i8  Byte21418[576]; // Magic menu???
  i8  Byte20842[576]; // The magic menu outline, maybe???
  i16 MagicCaster;//20266;
  i16 Word20264;
  i16 Word20262;
  i8  PossibleAttackTypes[4];//20260; // Up to 4 different attack types
  i8  Byte20256[4]; // Parallel to 20260.  See GetLegalAttackTypes.
  i16 Word20252;
  i16 Word20250;
  i16 Word20248;// compared to button # (#Attack options???)
  i16 AttackingCharacterOrdinal;//20246;
  i8  Byte20244[2];
                    // Start of graphic 0x230
  i16 Word20242[4]; // Rectpos
  RectPos  wRectPos20234; //Swapped when read
  RectPos  wRectPos20226; //Swapped when read
  RectPos  wRectPos20218; //Swapped when read
  RectPos  wRectPos20210; //Swapped when read
  RectPos  wRectPos20202; //Swapped when read
  i8  Byte20194;
  FILL(20193,20178)
  i8  experienceForAttacking[44]; //Byte20178[44];// Indexed by attack type
  i8  SkillNumber[44];// 20134;
                   //Which skill needed for attack??
                   //small integers. Largest = 18.
                   //Indexed by attack type.
  i8  Byte20090[44];
  i8  Byte20046[44];//Indexed by attack type
  i8  Byte20002[44];//Strength required????
  i8  Byte19958[44];
  i8  Byte19914[44];// indexed by attack type
                    // very small integers (2, 6,12, 5) the
                    // largest is 38.
  i8  AttackNames[300];//19870; //"KICK PUNCH BASH etc"
  i8  Byte19570[1];// Groups of eight?. Weapon action???
  FILL(19569,19218)
  i16 Word19218; // 12777 is some magic number here
  SPELL Spells[25];//19216 8 bytes each // Long0, word6 swapped when read
  //                  ID   Type
  // [00] 1-4     0x666f00  3 Party Shield
  // [01] 1-5-2   0x667073  3 Magic Footprints
  // [02] 3-2-6   0x686d77  3 Invisibility
  // [03] 3-1     0x686c00  2 Poison Cloud Missile ff87
  // [04] 3-2-5   0x686d76  3 See Thru Walls
  // [05] 3-3-5   0x686e76  2 Missile ff82
  // [06] 3-4-5   0x686f76  3 Light
  // [07] 4       0x690000  3 Torch
  // [08] 4-4     0x696f00  2 Missile ff80 Fireball
  // [09] 4-5-1   0x697072  1 Strength Potion - KU Potion
  // [10] 4-5-4   0x697075  3 FireShield
  // [11] 5-2     0x6a6d00  2 Missile ff83 Damage non-Material
  // [12] 5-1     0x6a6c00  3 Poison Bolt
  // [13] 5-4-6   0x6a6f77  3 Darkness
  // [14] 6       0x6b0000  2 Missile ff84 Open Door
  // [15] 1-5     0x667000  1 Shield Potion(12) YA Potion
  // [16] 1       0x660000  1 Stamina Potion(11) MON Potion
  // [17] 1-5-3   0x667074  1 Wisdom Potion(8) DANE Potion
  // [18] 1-5-4   0x667075  1 Vitality Potion(9) NETA potion
  // [19] 2       0x670000  1 Potion(14) Cure Wounds - VI Potion
  // [20] 2-5     0x677000  1 Potion(10) Cure Poison - ANTIVENOM
  // [21] 3-5-2   0x687073  1 Dexterity Potion(6) ROS Potion
  // [22] 6-5-5   0x6b7076  1 Mana Potion(13) EE Potion
  // [23] 6-1     0x6b6c76  1 Poison Potion(3) VEN Potion
  // [24] 6-3-5   0x6b6e76  3 ZoKathRa
  i8  Byte19016[6];
  i8  Byte19010[24];
                       // Last part of graphic 0x230
  btn *Pointer18986;
  btn *Pointer18982;
  KeyXlate *pKeyXlate18978;
  KeyXlate *pKeyXlate18974;
  btn *pButn18970[2][4]; // The menu button lists
  i8  Byte18938[2];      // Start of graphic 0x231
  btn Buttons18936[5];   // swapped when read
  btn Buttons18876[4];   //    ""      ...
  btn Buttons18828[3];   //    ""      ...
  btn Buttons18792[2];   //    ""      ...
  btn Buttons18768[5];   //    ""      ...
  btn Buttons18708[4];   //    ""      ...
  btn Buttons18660[3];   //    ""      ...
  btn Buttons18624[2]; //      ""    ...
  i8  Byte18600[8];    // RectPos swapped when read        ...
  i8  Byte18592[8];    // RectPos swapped when read        ...
  i8  Byte18584[8];    // RectPos swapped when read        ...
  i8  Byte18576[8];    // RectPos swapped when read        ...
  i16 Word18568[4];    // deltax[dir] NESW swapped when read        ...
  i16 Word18560[4];    // deltay[dir] NESW swapped when read         ...
  i16 Word18552[28];   // Swapped when read.  Magic buttons???         ...
  MOVEBUTN MoveButn18496[4]; // MF, MR, MB, ML Swapped when read
  ui8 DropAreas[16];//18464 X andY in screen coordinates
  i8  Byte18448[8];     // KeyXlate swapped when read        ...
  i8  Byte18440[12];    //  KeyXlate swapped when read        ...
  KeyXlate Byte18428[7];//  KeyXlate swapped when read        ...
  i8  Byte18400[28];    //  KeyXlate swapped when read
  btn Buttons18372[4];  //
  btn Buttons18324[9];  // Swapped when read... chest buttons
  btn Buttons18216[13]; // Swapped when read
  btn Buttons18060[9];  // Swapped when read
  btn Buttons17952[5];  // Swapped when read
  btn Buttons17892[5];  // Swapped when read
  btn Buttons17832[3];  // Swapped when read         ...
  btn Buttons17796[3];  // Swapped when read  [864-4*12]
  btn Buttons17760[38]; // Swapped when read
  btn Buttons17304[9];  // Swapped when read         ...
  btn Buttons17196[20]; // Swapped when read         ...
  btn Buttons16956[2];  // Swapped when read         ...
  btn Buttons16932[4];  // Swapped when read
                        // End of graphic 0x231
  KeyXlate *pKeyXlate1; //16884;
  KeyXlate *pKeyXlate2; //16880;
  btn *SecondaryButtonList;//16876;
  btn *PrimaryButtonList;  //16872;
  i16 Word16868; // Mouse click something
  i16 FakeMouseButton;//16866; // Fake Mouse click buttons
  i16 FakeMouseY;     //16864; // Fake Mouse click y
  i16 FakeMouseX;     //16862; // Fake Mouse click x
  i16 FakeMouseClick; //16860; // Fake Mouse click occurred
    // Fake mouse clicks are also created when we need to
    // save a click while the Test/Set word is set.  The
    // click is then acted upon later.

    // Some sort of queue.
  i16 MouseInterlock;//16858; // Test/Set so we don't reference the queue twice.
  i16 MouseQEnd;  //16856; Last entry in queue (0 to 4)
  i16 MouseQStart;//16854; Next entry to remove from queue (0 to 4)
  //              // The queu is empty when Start = End+1
  MouseQueueEnt MouseQueue[5]; //16852
  pnt Pointer16822[7];//"STRENGTH", "DEXTERITY", etc
  pnt DirectionNames[4];//16794;
  pnt Pointer16778;
  i16 *pwPointer16774; // Points to d.Word918 initially
  pnt Pointer16770[17];//"Novice", "Master", etc
  i8  Byte16702;
  FILL(16701,16634)
  RN  objOpenChest;//16634; The one opened and on display
  RN  rnChestContents[8];//16632; 
            // Contents of opened chest.  Commonly 
            // referenced as 16692[place] because
            // place number 30 is the start of the 
            // chest.
  i16 WpnChestOrScroll;// 16616; 
                 // Set to 2 if scroll in weapon hand
                 // Set to 4 if chest in weapon hand
                 // Set to 5 during "Resurrect or Reincarnate"
                 // if ==4 then we search chest as well as backpack.
  i16 SelectedCharacterOrdinal;//16614; Selected to see backpack.
  i16 Word16612;
  i16 Word16610;
  i16 Word16608;
  i8  Byte16606[6];
  i32 Long16600;
  pnt Pointer16596[4];//"FIGHTER", "NINJA", etc
  i16 Word16580;
  i16 EmptyHanded;//16578;
  RN  objectInHand;//16576; //object in hand cursor?
  i16 ObjectType16574; // OBJECTTYPE//must say i16 to keep space use to 2 bytes
  pnt Pointer16572;
  i16 HandChar;// 16568; //Whose hand does that cursor belong to?  
                 //Contains character index or -1
  i16 PendingOuches[4];//16566// Main loop 'or's these to characters' ouches
  i16 PendingDamage[4];//16558// Main loop subtracts from HP
  i8  Byte16550;
  FILL(16549,16482)
    // 3328 bytes read into byte16482 .... 16482-3328 = 13154
  CHARDESC CH16482[4];  //part of 16482
  i16 Brightness;  //13282;//part of 16482 //swapped when read
  i8  SeeThruWalls;//13280;//part of 16482
  i8  Byte13279;       //part of 16482
  i16 Word13278;       //part of 16482 //Party shield timer
  i16 Word13276;       //part of 16482 //Spell effect
  i16 Word13274;       //part of 16482 //Spell effect
  i8  NumHistEnt;//13272;//part of 16482  #entries in 13268???
  ui8 uByte13271;      //part of 16482 //Life frozen time
  i8  Byte13270;       //part of 16482  index of entry in 13268
  i8  Byte13269;       //part of 16482  index of entry in 13268
  i16 Word13268[24];   //part of 16482 history of moves???
                       // bits 0-4 = mapX
                       // bits 5_9 = mapY
                       // bits 10_15 = loaded level
  i8  Byte13220[24]; // parallels 13268??  
                     // Is this a once-only kind of thing?
  i8  Invisible;     //13196;//part of 16482
  i8  Byte13195[41]; //part of 16482
  /////////////  End of Character portion of save file /////////////
  i16 DelayedActuatorActionPos;//13154; // -1 means position ignored?
  i16 DelayedActuatorActionY;//13152; //mapY
  i16 DelayedActuatorActionX;//13150; //mapX
  i16 DelayedActuatorAction;
  i16 SupressPitDamage;// 13146; //set to 1 when we climb rope
         // Perhaps this is to avoid damage from
         // falling into pit.  This gets cleared
         // after we fall one floor,
  i16 NewPos;  //13144; //objectPosition
                        //Set to new position by MoveObject
  i16 NewDir;  //13142; 
                        //Set to new direction by MoveObject
  i16 NewLevel;//13140; //objectLevel
                        //Set to new level by MoveObject
  i16 NewY;    //13138; //Set to newY when party moves 
                        //Set to newY by MoveObject
  i16 NewX;    //13136; //Set to newX when party moves.
                        //Set to newX by MoveObject
  ITEM16 *pI1613134;
  i32 Time13130;
  ui8 uByte13126[8];
  i8  Byte13118;
  FILL(13117,13050)
  i8  Byte13050[4]; // stack
  i16 Word13046; // # entries in 13050
  i16 Word13044;
  i16 Word13042;
  RN  Obj13040;
  i16 Word13038;
  i16 Word13036;
  i8  Byte13034[4];
  i8  Byte13030[4]; // Guessed at size.  See TAG00c442.
  i16 Word13026;
  i16 Word13024; // Direction monster is facing?????? Should face?????
  i16 Word13022; // used while computing monster movement
  RN  Obj13020;
  i16 Word13018;
  i16 Word13016;
  i16 ITEM16QueLen;//13014;
  i16 MaxITEM16;   //13012;//#entries in 13010.  60 under some circumstances.
  ITEM16 *Item16;  //13010; // Word13012  16-byte units?
                   // Initialized with -1 in word 0 of each enrty.
                   // Constructed by TAG00b062???
                   // This appears to be a queue of some sort.
                   // Word13014 is maybe the number of active
                   // entries.  TAG00bd40 seems to remove the 
                   // active entries.
  i32 WatchdogTime;//13006; // Always one TIMER in queue.
  i16 NextAvailTimer;//13002;
  i16 numTimer;//13000; // ++/-- counter
  i16 *timerQue;//12998; // Appears to point to an array of words 
                     // that in turn serve as
                     // indexes into array Pointer12994;
  TIMER *Timers;// 12994;//Array of TIMER structures
  i16 MaxTimers;//12990; //# items in Pointer12994 and 12998 array?
  pnt Pointer12988[6];

  i16 Word12964; // These two words set by 
  i16 Word12962; // function that determines damage due to missile
                 // 12962 a function of damage???
                 // 12964 = 1, 3, 5, or 7???

  i16 Word12960;
  i16 Word12958;
  DIRECTION Dir12956; // Set to random 1 or 3 when bump into wall
  i32 Long12954; // Time at which party last moved???
  i32 Long12950; // Time we last called TAG00c8c0???
  i32 TextTimeout[4];// 12946[4]; 
                    // One per text line at 
                    // bottom of screen
                    // This is the time at which the line 
                    //  should be removed from the screen.
  i16 PrintColumn;//12930; // Current scrolling text column number.
  i16 PrintRow;//12928; In scrolling area.  0 to 3
  pnt Pointer12926;
  pnt newTextLine; //12922
           // This line contains the text to
           // be scrolled into the bottom of the
           // screen. 12916 is set to 0 to get the
           // process started. (qv)
  i16 Word12918; // used in vertical blank handler
  i16 TextAlreadyScrolledCount; //12916; // 
           // This is the number of lines of Pointer12922
           // that have already been scrolled onto the
           // text area at the bottom of the screen.
           // Set to -1 if no text is in Pointer12922.
  i8  Byte12914[128];
  //FILL(12913,12786)
  pnt ObjectNames[199];//12786;
  i16 Word11990; // used in vertical blank hadler
  i16 Word11988; // used in vertical blank handler
  ui32 RandomNumber;      // 11986  Initially set from GEMDOS Random function
  pnt LogicalScreenBase; // 11982
  PALETTE Palette11978; 
  PALETTE Palette11946;  // Current palette???
  PALETTE Palette11914;  // Used as palette
  FILL(11882,11850)
  i8  Byte11850;
  FILL(11849,11782)
  pnt Pointer11782; // Graphic zero??
  i16 Word11778; // used in vertical blank handler
  i16 Word11776; // used in vertical blank handler
  i16 FlashButnActive; //Word11774; 
  i16 FlashButnY2; //Word11772; // 
  i16 FlashButnY1; //Word11770; // 
  i16 FlashButnX2; //Word11768; // 
  i16 FlashButnX1; //Word11766; //
  i16 Word11764; // Menu option result???
  i16 Word11762;
  i16 Word11760; // Set when showing food/water
  i16 Word11758;
  i16 Word11756; // Set when showing skill levels
  i16 Word11754;
  i16 Word11752;
  i16 Word11750; // used in vertical blank handler
  i16 Word11748;
  i16 Word11746;
  i16 Word11744;
  i16 ViewportUpdated; //11742;
                    // Set when new Viewport has been created.  VBLinterrupt
                    // then copies Viewport to screen and clears the flag.
  i16 Word11740;
  i16 DynamicPaletteSwitching;//11738; 
          // During the adventuring state we change the 
          // palette twice during each vertical scan.  The
          // portraits get Palette11978, the viewport and
          // buttons get Palette11946, and the text gets
          // Palette11978 again.
  i16 clockTick; //11736;// Every 'Speed' vbls.  
                         // Also set by player actions .
  FILL(11734,11732)
  i32 Long11732; // compared to 11718 = Time.  Set equal to
                 // Time when a game is loaded.
  i16 Speed;     // 11728; Number of VBLs per "clockTick"(11736)
  i16 vblCount; //11726; // Increment by vbl interrupt.
                         // Cleared in main loop.
  i16 Word11724; // bit 0 important
  i16 Word11722; // bit 0 important
  i16 Word11720;
  i32 Time;// 11718;// time (units of "clockTicks") See "Speed"
                    // Should be about 1/6 seconds
  i16 Word11714;
  i16 Word11712;
  i16 Word11710;
  i16 partyLevel;  // 11708  See TAG016e54
  i16 partyFacing; // 11706
  i16 partyY;      // 11704;
  i16 partyX;      // 11702
  i16 NumCharacter; //11700; // # characters????
  // 11698 seems to be an index into an array of palettes
  // in TAG00c202 this number is divided by 2.
  i16 CurrentPalette; //11698// used in vertical blank handler
                 // Palette to use based on light level 
                 // (d.Brightness) plus torches
  i16 GameIsLost; //Word11696; // The game is lost.
                 //There are no living characters.
  i16 Word11694; //Set when game is won.
                 //This stops monster movement, prevents
                 //processing of Timer function 24, and
                 //stops any damage to characters.
  i16 ClockRunning;//11692
  i16 PartySleeping;//11690;
  i16 PotentialCharacterOrdinal;//11688; // Almost but not quite added to party
  i16 dungeonFormat; //Word11686;
  i16 Word11684; // Set when menu is showing???
  pnt pViewportBMP; //11682; // 15232 bytes - This is an image of the
                    // viewport
  i8  Byte11678;
  FILL(11677,11270)
  i16 Word11270;
  FILL(11268,10654)
  ui8 LevelCleared[16];//10654;//One per DBNum. Initially all zero.
                       //This is the level we most recently discared
                       //and object from when we needed room for
                       //additional objects.
  i8  Byte10638;
  FILL(10637,10574)
  RN  rn10574[5];// Is RN right??? Is 5 right??? 
  ui8 ViewportObjectButtons[6][4];//10564; 
                    // DrawViewport constructs a button for
                    // each object that can be clicked.
  RN  rn10540;
  i16 Word10538;
  i16 Word10536;
  i16 Word10534;
  i16 FacingAlcove;//Word10532
  i16 CellTypeJustAhead;//10530;
                // Cell type of cell immediately ahead of party
                // Set by DrawCellF1 // Convert to/from ROOMTYPE
                // because we need it to be 16 bits.
  //DBCOMMON *misc10528[16]; 
  pnt unused10528[16];  // Placeholder.  
  //This has been replaced by an instance of DATABASES named "db".
          // Array of pointers to miscellaneous data.
          // Each points to an array.  The dungeonDatIndex[i+6]
          // defines the number of entries read from dungeon.dat
          // and is updated to the total number of entries at runtime.
          // Byte7302[i] defines the number of extra entries
          // allocated for each array.  And Byte7286[i] defines
          // the (byte) size of each entry.  The empty entries
          // have word 0 set to -1.  Several of the arrays
          // have zero space allocated.
          //  0 -  4 +   0  4-byte entries  //Doors???
          //       word2 bit 0 = door condition???
          //  1 -  0 +   0  6-byte entries
          //  2 - 26 +   0  2-word entries both words swapped when read
          //                2nd word is Compressed Text ID.  
          //  3 - 30 +   0  8-byte entries
          //       First guess.  Pressure pad????  
          // Databases 0, 1, 2, and 3 cannot be drawn?????
          //  4 - 12 +  75 16-byte entries //Entries class DB4
          //       I guess type 4 is monsters.  Just a guess.
          //       ITEM16.word0 contains an index into this dataase.
          //  5 -  0 + 100  4-byte entries
          //       A torch seems to be in DB5.
          //       A sword
          //  6 -  0 + 120  4-byte entries
          //       A small Shield is in DB6
          //  7 -  0 +   0  4-byte entries
          //       Text (scroll???)
          //  8 -  0 +   5  4-byte entries
          //  9 -  0 +   0  8-byte entries // Chests???
          // 10 -  0 + 140  4-byte entries //BITS0_6(word[1])+127=weaponIndex???
          //                   corn        // word2 = 0x..85 bones; chIdx in bits 14,15
          // 11 -  0 +   0  0-byte entries
          // 12 -  0 +   0  0-byte entries
          // 13 -  0 +   0  0-byte entries
          // 14 -  0 +  60  8-byte entries //Entries class DB14
                                           //Fireball??? Missile??? 
          //                               //word 6 = timer index
          // 15 -  0 +  50  4-byte entries

  RN *objectList; //prn10464; 
               // One word for each room containing some sort
               // of object.  10420 is a shortcut giving the 
               // index of the first entry for each column of
               // the current level.  The word contains the 
               // DBRecordName
               // of the first object in the room (an RN).
               // Points to array of words..  The first small
               // part of this aray is read from dungeon.dat
               // and 300 additional words are allocated and
               // filled with -1;
               // The size of this array is found in
               // dungeonDatIndex[5] (10446)
               // littleEndian applied when read from file.
               // Bits 10-13 are a field..4 is special
  ui16 numColumnPointers; //10460;// total in both halves of 10450
                         // All levels included.
                         // This includes a pointer to the first
                         // column of each level and a pointer for
                         // each column in each level.  So it is 
                         // the total number of columns in the dungeon
                         // plus the number of levels.
  ui16 *objectLevelIndex;//*puwPointer10458; 
                         //Index in pwPointer10454 of first
                         //column in each level.
  ui16 *objectListIndex; //*pwPointer10454; 
                         // One word for each DUDAD (numDUDADpointers).
                         // Small integers (0x00 - 0x41) sorted with
                         // a couple of duplicates.
                         // LittleEndian when read from dungeon.dat.
  CELLFLAG ***pppdPointer10450;
      // Actually, the 10450 array has two parts.  The first
      // <numlevel> pointers in the array point repectively to the
      // second part for each level.  
      // Each level then has an array of pointers to the
      // contents of the cells in each of the maze's columns.
  DUNGEONDATINDEX *dungeonDatIndex; 
                        //10446; // points to 22-word array.
                        // All 22 words swapped when read.
                        // Word[0] used by TAG00a41c.
                        // Word[2] bits 8-15 = number of levels
                        // Words reversed when read from file
                        // Word[5] = size of array 10464
                        // At runtime, word[i+6] is the number
                        // of entries allocated for database[i].
                        // In general, many will be empty.
  LEVELDESC *pLevelDescriptors;//10442; 
                        // points to array of 16-byte structures
                        // read from dungeon.dat.  Parallels the 
                        // array at Pointer10458.
                        // Words 0, 8, 10, 12, and 14 are switched
                        // to littleEndian when we read the file.
  CELLFLAG *cellFlagArray;//pdPointer10438;
     // This is the CELLFLAG array.  Seldom used.  10450 is set
     // to point to the start of each level and to the start
     // of each column within each level.
  i16 DoorTOC[2];   //Word10434
                    // Characteristics of the two door types on this level.
                    // Bits 8-15 are flags
                    //   0x01 has to do with monster passage
                    //   0x02 has to do with missile encounters
                    //   0x04 causes 'lightning' door.  Random orientation.
                    // Low byte is strength of door.
                    // Copied from d.Word9760 which was swapped when read.
  i16 height;//10430 //Dungeon level height
  i16 width; //10428;//Dungeon level width
  i16 LoadedLevel;//10426; // Currently loaded level
  CELLFLAG **LevelCellFlags; //10424
         // This points to an array of pointers to the
         // first CELLFLAG in each column of the currently
         // loaded level.
         // You should generally reference it as:
         //   CELLFLAG cf = d.LevelCellFlags[x][y];
         //       *** NOTE ***
         // At the the end of the cellflags for each level there
         // are some tables that describe such things as 
         // which wall decorations are used on the level,
         //  - monsters allowed on level
         //  - wall decorations used on level
         // what monsters are allowed on the level, etc.
         // See the function SetPartyLevel().
  ui16 *pCurrentLevelObjectIndex;
                       //pwPointer10420;
                       //for each column of the level there is a
                       // index of the first object-list in that
                       // column.
  LEVELDESC *pCurLevelDesc;//10416; // current Level descriptor. See 10442.
  i16 Word10412[1];
  i16 Word10410[3];  //The indicies on this level of alcove wall decorations
  i16 Word10404;     //The index on this level of the ornate alcove
  i16 NumWallDecoration;//10402;
  CELLFLAG *EndOfCELLFLAGS;//10400; // Points to last CELLFLAG +1;
  i8  DoorDecorationTOC[18];//Byte10396
  i8  FloorDecorationTOC[16];//Byte10378
  ui8 WallDecorationTOC[16];//10362[1];//For current level
  pnt textArray;//Pointer10346; //Do your own littleEndian!
                    // Something to do with text.
  i8  Byte10342[2];
  //*******************************************************
  // Start graphic 0x22f
  //*******************************************************
  i8           Byte10340[4];   
  i8           Byte10336[256]; //       ...
  i8           Byte10080[64];  //       ...
  i8           Byte10016[256]; //       ...
  i16          DoorCharacteristics[4]; //9760// swapped when read.
  i16          MonsterDroppings[40];   //9752// 
  ui8          uByte9672[8];   // Sound numbers???
  MONSTERDESC  MonsterDescriptor[27];//9664
  i16          FoodValue[8];//8962 // obj_Apple to obj_DragonSteak      ...
                // swapped when read
  i8           Byte8946[54];   //
  i16          Word8892;       //       ...
  CLOTHINGDESC ClothingDesc[58]; //8890 
  WEAPONDESC   weapons[46];//8658   // Used for Database5 objects
                 // word4 swapped when read;
                 // pDB5->weaponType() is index
  OBJDESC      ObjDesc[180];//8382
                 // -object Type
                 // -effect of objects when attacking?
                 // -Words 0 and 4 swapped when read
                 // -
                 // -Word4 bit 0 = consumable??
                 // -indexed by Object Index
                 //    = scroll type   +  0 //  1 Scroll type
                 //    = chest type    +  1 //  1 Chest types
                 //    = potion type   +  2 // 21 Potion types
                 //    = weapon type   + 23 // 46 Weapon types
                 //    = clothing type + 69 // 58 Clothing types
                 //    = food type     +127 // 53 Misc types
           
  i8           Byte7302[16];   //  #extra entries in each 'misc' database     ...
  i8           DBEntrySize[16];//7286 // Size of entries in each 'misc' database     ...
                        // Always an even number! Sometimes zero.
  i16          DeltaY[4]; //7270  // deltay for 4 directions
  i16          DeltaX[4]; //7262    // deltax for 4 directions End of 22f
                 // deltax and deltay littleEndian when expanded
  i16          Word7254;   
  i16          CurrentWallGraphic;//Word7252; // Some sort of graphic number????
  i16          CurrentFloorAndCeilingGraphic; //Word7250;
  i8           Byte7248[2];
  //*******************************************************
  //              Start of graphic 0x22e
  //*******************************************************
  i16 Word7246[12];  // Swapped when read
  i16 Word7222[30];  // Swapped when read
  i16 Word7162[60];  // Swapped when read
  i16 Word7042[30];  // Swapped when read
  ITEM110 s6982[3]; // Three groups of 110
  i8  Byte6652[24];  // +/- small integers to shift image
  i8  Byte6628[16];
  i8  Byte6612[16];
  i16 Word6596[13][7];
  ITEM12 Item6414[27];//      ...
  ITEM100 s6090[3];  //      ... 100-byte entries each with 10-byte entries
                     // Nominal positions in viewport for
                     //  [0] Objects within room--on floor--fireballs
                     //  [1] ??? A sword on floor pointed here
                     //  [2] ???
                     // Each 100-byte entry has 10 entries, one for each
                     // relative room number (9=room party is in).  And each
                     // 10-byte entry has 5 2-byte entries, one for each relative
                     // position within the room and one for ??? (object in niche?).
                     //   [0] = far left
                     //   [1] = far right
                     //   [2] = near right
                     //   [3] = near left
                     //   [4] = niche??
  i8  Byte5790[32];  //
  i8  Byte5758[6];   //
  i8  Byte5752[8];   //      ...
  i8  Byte5744[16];  //      ...
  i8  Byte5728[16];  //      ...
  i8  Byte5712[16];  //
  i8  Byte5696[8];   //      ...
  i8  Byte5688[84];  // You must littleEndian these.. (14) 6-byte entries
  ITEM6 s5604[85];   //      ... (85) 6-byte entries 
  i8  Byte5094[6];   //      ...
  i8  Byte5088[12];  //      ...
  i8  Byte5076[6];   //      ...
  i8  Byte5070[12];  //      ... 6-byte RectPos for doors?
  i8  Byte5058[60];  //      ... 18-byte entries????
  i8  Byte4998[162]; // 6-byte entries     ...
  i8  Byte4836[60];  //      ...
  i8  Byte4776[563]; //      ... 78-byte entries?
  i8  Byte4213[17];  //      ...
  i8  Byte4196[4];   //      ...
  i8  Byte4192[4];   //      ...
  i8  Byte4188[16];  //      ... 
  i8  Byte4172[16];  //      ... 
  i8  Byte4156[16];  //      ...
  i8  Byte4140[16];  //      ...
  i8  Byte4124[2];   //      ...
  i8  Byte4122[12];  //      ...
  i8  Byte4110[10];  //      ...
  i8  Byte4100[60];  //      ...
  i16 Word4040[1];   //      ...
  i8  Byte4038[4];   //      ... These are wall graphics that define
                     //          alcoves.  The numbers here are 1, 2, and 3
                     //          in CSB.  Square Alcove, VI Altar, Ornate Alcove.
  i8  Byte4034[10];  //      ...
  i8  Byte4024[12];  //      ...
  i16 Word4012;      //      ...
  i8  Byte4010[8];   //      ...
  i8  Byte4002[8];   //      ...
  i8  Byte3994[8];   //      ...
  i8  Byte3986[8];   //      ...
  i8  Byte3978[8];   //      ...
  i8  Byte3970[8];   //      ...
  i8  Byte3962[8];   //      ...
  i8  Byte3954[8];   //      ...
  i8  Byte3946[8];   //      ...
  i8  Byte3938[8];   //      ...
  i8  Byte3930[8];   //      ...
  i8  Byte3922[8];   //      ...
  i8  Byte3914[80];  //      ...
  i8  Byte3834[80];  //      ...
  i8  Byte3754[80];  //      ...
  i8  Byte3674[80];  //      ...
  i8  Byte3594[80];  //      ...
  i8  Byte3514[80];  //      ...
  i8  Byte3434[80];  //      ...
  i8  Byte3354[80];  //      ...
  i8  Byte3274[80];  //      ...
  i8  Byte3194[8];   // RectPos  ...
  i8  Byte3186[8];   // RectPos  ...
  i8  Byte3178[8];   // RectPos  ...
  i8  Byte3170[8];   // RectPos  ...
  i8  Byte3162[8];   // RectPos  ...
  i8  Byte3154[8];   // RectPos  ...
  i8  Byte3146[8];   // RectPos  ...
  i8  Byte3138[4];   // RectPos  ...
  i8  Byte3134;      //      ...
  i8  Byte3133;      //      ...
  i8  Byte3132[2];   //      ...
  i8  Byte3130[8];   // RectPos  ...
  i8  Byte3122[8];   //      ...
  i8  Byte3114[8];   // RectPos  ...
  i8  Byte3106[8];   //      ...
  i8  Byte3098[8];   // RectPos  ...
  i8  Byte3090[8];   //      ...
  i8  Byte3082[8];   // RectPos  ...
  i8  Byte3074[8];   // RectPos  ...
  i8  Byte3066[8];   // RectPos  ...
  i8  Byte3058[8];   // RectPos  ...
  i8  Byte3050[8];   // RectPos  ...
  i8  Byte3042[8];   // RectPos  ...
  i8  Byte3034[8];   // RectPos  ...
  ui8 uByte3026[8];   // RectPos  ...
  i8  Byte3018[8];   // RectPos  ...
  i8  Byte3010[8];   // RectPos     ...
  i8  Byte3002[8];   //      ...
  ui8 uByte2994[8];   // RectPos  ...
  i8  Byte2986[8];   // RectPos  ...
  i8  Byte2978[8];   // RectPos  ...
  i8  Byte2970[8];   // RectPos  ...
  i8  Byte2962[4];   // byte RectPos     ...
  i8  Byte2958[4];   // byte Rectpos ...
  i8  Byte2954[8];   //byte RectPos      ...
  i8  Byte2946[8];   //byte RectPos      ...
  i8  Byte2938[8];   //byte RectPos      ...
  i8  Byte2930[8];   //byte RectPos      ...
  i8  Byte2922[8];   //byte RectPos      ...
  i8  Byte2914[8];   //byte RectPos      ...
  i8  Byte2906[8];   //byte RectPos      ...
  i8  Byte2898[8];   //byte RectPos      ...
  i8  Byte2890[8];   //byte Rectpos      ...
  i8  Byte2882[8];   //RectPos (byte)      ...
  i8  Byte2874[8];   //RectPos (byte)      ...
  i8  Byte2866[8];   //RectPos (byte)      ...
  i8  Byte2858[8];   //RectPos (byte)      ...
  i8  Byte2850[8];   //RectPos (byte)      ...
  i8  Byte2842[8];   //RectPos (byte)      ...
  i8  Byte2834[8];   //RectPos (byte)      ...
  i8  Byte2826[8];   //RectPos (byte)      ...
  i8  Byte2818[8];   //RectPos (byte)      ...
  i8  Byte2810[8];   //RectPos (byte)      ...
  i8  Byte2802[8];   //RectPos (byte)      ...
  i8  Byte2794[8];   //RectPos (byte)      ...
  i8  Byte2786[8];   //RectPos (byte)      ...
  i8  Byte2778[8];   //RectPos (byte)      ...
  i8  Byte2770[8];   //RectPos (byte)      ...
  i8  Byte2762[8];   //RectPos (byte)      ...
  i8  Byte2754[8];   //RectPos (byte)      ...
  i8  Byte2746[8];   //RectPos (byte)      ...
  i8  Byte2738[8];   //RectPos (byte)      ...
  i8  Byte2730[8];   //RectPos (byte)      ...
  i8  Byte2722[8];   //RectPos (byte)      ...
  i8  Byte2714[8];   //RectPos (byte)      ...
  i8  Byte2706[8];   //RectPos (byte)      ...
  i8  Byte2698[8];   //RectPos (byte)      ...
  i8  Byte2690[8];   //RectPos (byte)      ...
  i8  Byte2682[8];   //RectPos (byte)      ...
  i8  Byte2674[8];   //RectPos (byte)      ...
  i8  Byte2666[8];   //RectPos (byte)      ...
  i8  Byte2658[8];   //RectPos (byte)      ...
  i8  Byte2650[8];   //RectPos (byte)      ...
  i8  Byte2642[8];   //RectPos (byte)      ...
  i8  Byte2634[8];   //RectPos (byte)      ...
  i8  Byte2626[8];   //RectPos (byte)      ...
  i8  Byte2618[8];   //RectPos (byte)      ...
  i8  Byte2610[8];   //RectPos (byte)      ...
  i8  Byte2602[8];   //RectPos (byte)      ...
  i8  Byte2594[8];   //RectPos (byte)      ...
  i8  Byte2586[8];   //RectPos (byte)      ...
  i8  Byte2578[8];   //RectPos (byte)      ...
  i8  Byte2570[8];   //RectPos (byte)      ...
  i8  Byte2562[8];   //RectPos (byte)      ...
  i8  Byte2554[8];   //RectPos (byte)      ...
  i8  Byte2546[4];   //
  ui8 uByte2542[4];  //Rectpos (byte)
  i16 Word2538[2];   //      ... rectpos (byte)
  ui8 uByte2534[4];   //      ... rectpos?
  //i16 Word2532[1];   //
  i16 Word2530[2];   // last part of graphic at 7246
//********************************************************
//  End graphic 0x22e
//********************************************************
  i16 *Pointer2526[3]; //&Word2050, &Word2210, &Word2318
  i16 Word2514[1][2];
  FILL(2510,2446)
  i8  Byte2446;  // 4-byte entries
  FILL(2445,2386)
  i16 Word2386;
  i16 Word2384;
  i16 Word2382[16][2]; // funny RectPos??? Thought there were two. Then three. 
                      // Then more.  Who knows?? 
                      // One per BITS0_3(d.pCurLevelDesc[0].word10)
  i16 Word2318[34];
  //FILL(2316,2250)

  pnt Pointer2250; // 5 Longwords moved between here and 2110
  pnt Pointer2246; // 5 Longwords moved between here and 2110
  pnt Pointer2242; // 5 Longwords moved between here and 2110
  pnt Pointer2238; // 5 Longwords moved between here and 2110
  pnt Pointer2234; // 5 Longwords moved between here and 2110

  pnt Pointer2230; // 5 Longwords moved between here and 2110
  pnt Pointer2226; // 5 Longwords moved between here and 2110
  pnt Pointer2222; // 5 Longwords moved between here and 2110
  pnt Pointer2218; // 5 Longwords moved between here and 2110
  pnt Pointer2214; // 5 Longwords moved between here and 2110

  i16 Word2210[34];

  pnt Pointer2142; // 1504 bytes

  pnt pWallBitmaps[13]; 
  //pnt Pointer2138; // [0]  1968 bytes
  //pnt Pointer2134; // [1]  1504 bytes
  //pnt Pointer2130; // [2]  1560 bytes
  //pnt Pointer2126; // [3]   704 bytes
  //pnt Pointer2122; // [4]   688 bytes
  //pnt Pointer2118; // [5]   256 bytes
  //pnt Pointer2114; // [6]   144 bytes

  // 5 pointerss moved as group between here and 2230
  //pnt Pointer2110; // [7]  2176 bytes
  //pnt Pointer2106; // [8]  2176 bytes 
  //pnt Pointer2102; // [9]  1408 bytes
  //pnt Pointer2098; // [10] 5112 bytes
  //pnt Pointer2094; // [11] 3264 bytes

  //pnt Pointer2090; // [12]  392 bytes

  pnt Pointer2086; // 392 bytes

  pnt pViewportFloor;   //2082 - 7840 byte  //Address of floor in viewportBMP
  pnt pViewportBlack;   //2078 - 4144 bytes //Address of space between floor
                                            // and ceiling in viewportBMP
  pnt pCeilingBitmap;   //2074 - 3248 bytes  
  pnt pFloorBitmap;     //2070 - 7840 bytes

  pnt Pointer2066[4];
  i16 Word2050[34];
//  FILL(2048,1982)
  i8  Byte1982;
  FILL(1981,1918)
  i16 Word1918[2];
  i16 Word1914[2];
  i16 Word1910[2];
  i16 Word1906;
  i16 Word1904;
  i16 Word1902;
  i16 Word1900;
  i16 Word1898;
  i16 Word1896;
  i16 Word1894;
  i16 Word1892;
  i16 Word1890;
  i16 Word1888;
  i16 Word1886;
  i16 Word1884;
  i16 Word1882;
  i16 Word1880;
  i16 Word1878;
  i16 Word1876;
  i16 Word1874;
  i16 Word1872;
  i16 Word1870; // Set to 1 by TAG00456c
  i16 Word1868;
  i16 UseMirrorImages; //1866; 
  pnt Pointer1864[1]; // how many???
  pnt Pointer1860;
  pnt Pointer1856;
  pnt Pointer1852;
  pnt Pointer1848; // 8880 Bytes. Temp during draw viewport
  i16 Word1844;
  i16 Word1842;
  i16 Word1840;
  i16 Word1838;
  i16 Word1836; // Set to 15 by TAG00456c
  i16 Word1834;
  i8  Byte1832[2];
  i8  Byte1830[2];  // Start of graphic 0x232
  i32 Long1828[4]; // masks for text !not reversed!
  i32 Long1812[4]; // masks for text !not reversed!
  RectPos wRectPos1796;   // swapped when read       ...
  RectPos wRectPos1788;   // swapped when read      ...
  RectPos wRectPos1780;   // swapped when read      ...
  SOUND sound1772[22]; //        ...
  i8  Byte1596[8];
  i16 Word1588;      //
  i16 DropOrder[30];//1586 //Order in which possessions are dropped
  i16 Word1526[4][3];   // swapped when read
  i16 Word1502[4][6];   // swapped when read
  RectPos wRectPos1454[4];  // RectPos swapped when read/facing
  i8  SpecialChars[6]; //1422 comma,period,semi-colon,colon,space; 
  i8  Byte1416[2];
  i8  Byte1414[2];
  i8  Byte1412[6];
  i16 Word1406[4];   // Rectpos swapped when read
  i16 Word1398[4];   // RectPos swapped when read
  i8  Byte1390[4];   // 
  i8  Byte1386[4];   //
  i8  Byte1382[16];  //
  i8  Byte1366[16];  //
  i8  Byte1350[128]; //        ...
  i8  Byte1222[128]; // Arrow cursor...
  i8  Byte1094[8];   // RectPos swapped when read
  i16 PaletteBrightness[6];//1086;   // swapped when read
                     // Value of Brightness for each palette.
  i16 Word1074[16];  // swapped when read       ...
                     // [2] added to 13282 when we put a
                     // Illumulet necklace on a character
  i16 CarryLocation[38];//1042 //swapped when read
                     // Word for each location that
                     // an object can be carried.
                     // See HandleClothingClick for a
                     // list of the locations and their
                     // numbers.  For example, not all
                     // objects can be put in all locations.
                     // You cannot put shoes on your head!
                     // There are 30 locations for body and
                     // backpack and 8 for the chest.
  RectPos wRectPos966;// swapped when read
  RectPos wRectPos958;// swapped when read
  RectPos wRectPos950;// swapped when read
  RectPos wRectPos942;// swapped when read
  RectPos wRectPos934;// swapped when read
  RectPos wRectPos926;// swapped when read
  i16 Word918;        //
  ICONDISPLAY IconDisplay[46]; //916// swapped when read 
                      // 46 entries.
                      //   8 for hands in portraits
                      //  30 for clothing/backpack
                      //   8 for chest
                      // 
  i8  Byte640[1];     //        ...
  FILL(639,624)       //
  RectPos wRectPos624;// Swapped when read
  FILL(616,612)       //
  i16 Word612[7];     // Swapped when read
                      // The various objects in the game
                      // have bitmaps grouped in larger
                      // graphics.  This array tells the
                      // first OBJECTTYPE in each of the
                      // seven graphics.
  FILL(598,590)
  ui8 uByte590[4];    //
  i8  Byte586[8][4];// Function of direction facing/moving?
  i16 Word554;       // Swapped when read       ...
  PALETTE Palette552[6]; // Swapped when read  ...
//  i8  Byte520[160];  //        ...
  PALETTE Palette360;   // Palette...// Swapped when read from file
  PALETTE Palette328;   // Palette...// Swapped when read from file
  ui16 DefaultGraphicList[70];  //uw296  //  Bytes swapped when read from file      ...
  i8  Byte156[16];   //        ... 16 bytes = { 0, 10, 20, 30, ...}
  i16 Word140[4];    // RectPos    We swapped the bytes immediately after reading from file
  i16 Word132[4];    // RectPos             "
  i16 Word124[4];    //              "
  i16 Word116[4];    //              "
  i16 Word108[4];    //              "
  i16 Word100[4];    // RectPos      "
  i16 Word92[4];     // RectPos      "
  i16 Word84[4];     // RectPos      "
  i16 Word76[4];     // RectPos      "  
  i16 Word68[4];     // RectPos      "
  i16 Word60[4];     // RectPos      "
  i16 Word52[4];     // RectPos      "
  i16 Word44[4];     // RectPos      "
  i16 Word36[4];     // RectPos      "
  i16 Word28[4];     // RectPos?     "
  i16 Word20[4];     //              "
  i16 Word12[4];     // Rectpos
                     // End of graphic 0x232
  pnt Pointer4;      
};

//extern i32 D0,D1,D2,D3,D4,D5,D6,D7;
//extern pnt A0,A1,A2,A3,A4,A5,A6,A7;


extern DBank d;
extern DATABASES db;

extern i32 data000b2c;
extern i32 data000b30;
//extern i16 data009032[];

extern bool verticalIntEnabled;

//********************************************//(WCS/RCS)
// A few functions to "Write/Read w/Check Sum"//(WCS/RCS)
unsigned int WCS(int handle);                 //(WCS/RCS)
unsigned int RCS(int handle);                 //(WCS/RCS)
void WCS(char *, int count=1);                //(WCS/RCS)
void RCS(char *, int count=1);                //(WCS/RCS)
void WCS(ui16 *, int count=1);                //(WCS/RCS)
void RCS(ui16 *, int count=1);                //(WCS/RCS)
void WCS(ui8 *, int count=1);                 //(WCS/RCS)
void RCS(ui8 *, int count=1);                 //(WCS/RCS)
void WCS(int *, int count=1);                 //(WCS/RCS)
void RCS(int *, int count=1);                 //(WCS/RCS)
void WCS(unsigned int *, int count=1);        //(WCS/RCS)
void RCS(unsigned int *, int count=1);        //(WCS/RCS)
//********************************************//(WCS/RCS)
//
//********************************************//DSA
enum DSACOMMAND                               //DSA
{                                             //DSA
  DSACMD_MESSAGE          = 1,                //DSA
  DSACMD_OVERRIDE         = 2,                //DSA
  DSACMD_NOOP             = 3,                //DSA
  DSACMD_COPYTELEPORTER   = 4,                //DSA
  DSACMD_GOSUB            = 5,                //DSA
  DSACMD_LOAD             = 6,                //DSA
  DSACMD_FETCH            = 7,                //DSA
  DSACMD_EQUAL            = 8,                //DSA
  DSACMD_QUESTION         = 9,                //DSA
  DSACMD_RANDOM           =10,                //DSA
  DSACMD_AMPERSAND        =11,                //DSA
  DSACMD_JUMP             =12                 //DSA
};                                            //DSA
                                              //DSA
enum STKOP                                    //DSA
{                                             //DSA
    STKOP_Noop      =  0,                     //DSA
    STKOP_Plus      =  1,                     //DSA
    STKOP_Roll      =  2,                     //DSA
    STKOP_Pick      =  3,                     //DSA
    STKOP_Neg       =  4,                     //DSA
    STKOP_Equal     =  5,                     //DSA
    STKOP_Poke      =  6,                     //DSA
    STKOP_Drop      =  7,                     //DSA
    STKOP_Type      =  8,                     //DSA
    STKOP_Del       =  9,                     //DSA
    STKOP_Add       = 10,                     //DSA
    STKOP_Dup       = 11,                     //DSA
    STKOP_1Minus    = 12,                     //DSA
    STKOP_Swap      = 13,                     //DSA
    STKOP_1Plus     = 14,                     //DSA
    STKOP_Over      = 15,                     //DSA
    STKOP_MinusRoll = 16,                     //DSA
    STKOP_Rot       = 17,                     //DSA
    STKOP_MinusRot  = 18                      //DSA
};                                            //DSA
                                              //DSA
enum MESSAGETYPE                              //DSA
{                                             //DSA
  MSG_NULL   =  0,                            //DSA
  MSG_SET    =  1,                            //DSA
  MSG_CLEAR  =  2,                            //DSA
  MSG_TOGGLE =  3                             //DSA
};                                            //DSA
                                              //DSA
enum TARGETTYPE                               //DSA
{                                             //DSA
  TARGET_A    = 0,                            //DSA
  TARGET_B    = 1,                            //DSA
  TARGET_ABS  = 2,                            //DSA
  TARGET_GEAR = 3                             //DSA
};                                            //DSA
                                              //DSA
struct DSAgeneralCmd                          //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode:6; //DSACOMMAND        //DSA
  int          unused:10;                     //DSA
public:                                       //DSA
  DSACOMMAND CmdCode(void)                    //DSA
      {return (DSACOMMAND)cmdCode;};          //DSA
};                                            //DSA
                                              //DSA
struct DSAmessageCmd                          //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6; //DSACOMMAND      //DSA
  unsigned int msgType  :2; //MESSAGETYPE     //DSA
  unsigned int delay    :2; //0/X/Y/3=explicit//DSA
  unsigned int target   :2; //TARGETTYPE      //DSA
  signed int   nextState:4; //relative        //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE     = 8,                         //DSA
    MAXDELAY     = 0,                         //DSA
    COMMANDCODE  = DSACMD_MESSAGE             //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  unsigned int Delay(void){return delay;};    //DSA
  void Delay(unsigned int d){delay=d;};       //DSA
  MESSAGETYPE MsgType(void)                   //DSA
        {return (MESSAGETYPE)msgType;};       //DSA
  void MsgType(MESSAGETYPE m){msgType=m;};    //DSA
  TARGETTYPE Target(void)                     //DSA
        {return (TARGETTYPE)target;};         //DSA
  void Target(TARGETTYPE t){target=t;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<MAXSTATE;};            //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
struct DSAcopyTeleporterCmd                   //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode    :6; //DSACOMAND     //DSA
  unsigned int targetfrom :2; //TARGETTYPE    //DSA
  unsigned int targetto   :2; //TARGETTYPE    //DSA
  signed   int nextState  :6; //relative      //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE      = 32,                       //DSA
    COMMANDCODE   = DSACMD_COPYTELEPORTER     //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<MAXSTATE;};            //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  TARGETTYPE TargetFrom(void)                 //DSA
        {return (TARGETTYPE)targetfrom;};     //DSA
  void TargetFrom(TARGETTYPE t)               //DSA
        {targetfrom=t;};                      //DSA
  TARGETTYPE TargetTo(void)                   //DSA
        {return (TARGETTYPE)targetto;};       //DSA
  void TargetTo(TARGETTYPE t){targetto=t;};   //DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
enum LOADTYPE                                 //DSA
{                                             //DSA
  LOAD_$       = 28,                          //DSA
  LOAD_ABS     = 27,                          //DSA
  LOAD_INTEGER = 26                           //DSA
};                                            //DSA
                                              //DSA
struct DSAloadCmd                             //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6; //DSACOMMAND      //DSA
  unsigned int where    :5; //0->25 = A->Z    //DSA
                            //26=integer      //DSA
                            //27=abs location //DSA
                            //28=$            //DSA
  signed int   nextState:5;                   //DSA
enum                                          //DSA
{                                             //DSA
  MAXSTATE      = 16,                         //DSA
  COMMANDCODE   = DSACMD_LOAD                 //DSA
};                                            //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
      {return nextState==-MAXSTATE;};         //DSA
  bool StateFits(int r)                       //DSA
      {return abs(r)<=MAXSTATE;};             //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  unsigned int Where(void){return where;};    //DSA
  void Where(unsigned int w){where=w;};       //DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {                                           //DSA
    return (DSACOMMAND)(cmdCode=COMMANDCODE); //DSA
  };                                          //DSA
};                                            //DSA
                                              //DSA
struct DSAoverrideCmd                         //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6; //DSACOMMAND      //DSA
  unsigned int what     :3;                   //DSA
  unsigned int value    :3;                   //DSA
  signed int   nextState:4;                   //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 8,                          //DSA
    COMMANDCODE = DSACMD_OVERRIDE,            //DSA
    OVERRIDE_P  = 1                           //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  unsigned int What(void){return what;};      //DSA
  void What(unsigned int w){what=w;};         //DSA
  unsigned int Value(void){return value;};    //DSA
  void Value(unsigned int v){value=v;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<=MAXSTATE;};           //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
struct DSAnoopCmd                             //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6;  //DSACOMMAND     //DSA
  signed int   nextState:10;                  //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 512,                        //DSA
    COMMANDCODE = DSACMD_NOOP                 //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<=MAXSTATE;};           //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
struct DSAjumpCmd                             //DSA 
{                                             //DSA
private:                                      //DSA 
  unsigned int cmdCode  :6;                   //DSA
  unsigned int row      :6;                   //DSA
  unsigned int column   :1;                   //DSA
  signed   int nextState:3;                   //DSA
  enum                                        //DSA
  {                                           //DSA 
    MAXSTATE    = 4,                          //DSA
    COMMANDCODE = DSACMD_JUMP                 //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  int Row(void){return row;};                 //DSA
  void Row(int r){row=r;};                    //DSA
  int Column(void){return column;};           //DSA
  void Column(int c){column=c;};              //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<MAXSTATE;};            //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
                                              //DSA
struct DSAgosubCmd                            //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6;                   //DSA
  unsigned int row      :6;                   //DSA
  unsigned int column   :1;                   //DSA
  signed   int nextState:3;                   //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 4,                          //DSA
    COMMANDCODE = DSACMD_GOSUB                //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  int Row(void){return row;};                 //DSA
  void Row(int r){row=r;};                    //DSA
  int Column(void){return column;};           //DSA
  void Column(int c){column=c;};              //DSA
  bool IsMaxState(void)                       //DSA
        {return nextState==-MAXSTATE;};       //DSA
  bool StateFits(int r)                       //DSA
        {return abs(r)<=MAXSTATE;};           //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
struct DSAquestionCmd                         //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode   :6;                  //DSA
  signed   int nextState :4;                  //DSA
  unsigned int ifColumn  :1;                  //DSA
  unsigned int ifCMD     :2;                  //DSA
                  //0=None,1=Jump,2=GoSub     //DSA
  unsigned int elseColumn:1;                  //DSA
  unsigned int elseCMD   :2;                  //DSA
                  //0=None,1=Jump,2=GoSub     //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 2,                          //DSA
    COMMANDCODE = DSACMD_QUESTION             //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IfColumn(void){return ifColumn!=0;};   //DSA
  void IfColumn(bool b){ifColumn=b?1:0;};     //DSA
  int IfCmd(void){return ifCMD;};             //DSA
  void IfCmd(int n){ifCMD=n;};                //DSA
  bool ElseColumn(void)                       //DSA
              {return elseColumn!=0;};        //DSA
  void ElseColumn(bool b){elseColumn=b?1:0;}; //DSA
  int ElseCmd(void){return elseCMD;};         //DSA
  void ElseCmd(int n){elseCMD=n;};            //DSA
  bool IsMaxState(void)                       //DSA
              {return nextState==-MAXSTATE;}; //DSA
  bool StateFits(int r)                       //DSA
              {return abs(r)<MAXSTATE;};      //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {                                           //DSA
    return (DSACOMMAND)(cmdCode=COMMANDCODE); //DSA
  };                                          //DSA
};                                            //DSA
                                              //DSA
struct DSAequalCmd                            //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6;  //DSACOMMAND     //DSA
  signed int   nextState:10;                  //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 512,                        //DSA
    COMMANDCODE = DSACMD_EQUAL                //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
          {return nextState==-MAXSTATE;};     //DSA
  bool StateFits(int r)                       //DSA
          {return abs(r)<MAXSTATE;};          //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {                                           //DSA
    return (DSACOMMAND)(cmdCode=COMMANDCODE); //DSA
  };                                          //DSA
};                                            //DSA
                                              //DSA
struct DSAampersandCmd                        //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6;  //DSACOMMAND     //DSA
  unsigned int subCode  :7;                   //DSA
  signed int   nextState:3;                   //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 8,                          //DSA
    COMMANDCODE = DSACMD_AMPERSAND            //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
      {return nextState==-MAXSTATE;};         //DSA
  bool StateFits(int r)                       //DSA
      {return abs(r)<MAXSTATE;};              //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  STKOP SubCode(void){return (STKOP)subCode;};//DSA
  void SubCode(STKOP n){subCode=n;};          //DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {return (DSACOMMAND)(cmdCode=COMMANDCODE);};//DSA
};                                            //DSA
                                              //DSA
struct DSAfetchCmd                            //DSA
{                                             //DSA
private:                                      //DSA
  unsigned int cmdCode  :6;  //DSACOMMAND     //DSA
  signed int   nextState:10;                  //DSA
  enum                                        //DSA
  {                                           //DSA
    MAXSTATE    = 512,                        //DSA
    COMMANDCODE = DSACMD_FETCH                //DSA
  };                                          //DSA
public:                                       //DSA
  int NextState(void){return nextState;};     //DSA
  void NextState(int n){nextState=n;};        //DSA
  bool IsMaxState(void)                       //DSA
          {return nextState==-MAXSTATE;};     //DSA
  bool StateFits(int r)                       //DSA
          {return abs(r)<MAXSTATE;};          //DSA
  void SetMaxState(void){nextState=MAXSTATE;};//DSA
  DSACOMMAND CmdCode(void)                    //DSA
  {                                           //DSA
    return (DSACOMMAND)(cmdCode=COMMANDCODE); //DSA
  };                                          //DSA
};                                            //DSA
                                              //DSA
                                              //DSA
union DSAcommand                              //DSA
{                                             //DSA
  DSAmessageCmd          msgCmd;              //DSA
  DSAgeneralCmd          generalCmd;          //DSA
  DSAoverrideCmd         overrideCmd;         //DSA
  DSAnoopCmd             noopCmd;             //DSA
  DSAcopyTeleporterCmd   copyTeleporterCmd;   //DSA
  DSAgosubCmd            gosubCmd;            //DSA
  DSAloadCmd             loadCmd;             //DSA
  DSAquestionCmd         questionCmd;         //DSA
  DSAequalCmd            equalCmd;            //DSA
  DSAfetchCmd            fetchCmd;            //DSA
  DSAjumpCmd             jumpCmd;             //DSA
  DSAampersandCmd        ampersandCmd;        //DSA
};                                            //DSA
                                              //DSA
class DSAAction                               //DSA
{                                             //DSA
  friend class DSAState;                      //DSA
  int         m_column;                       //DSA
  int         m_numPgmWords;                  //DSA
  ui16       *m_program;                      //DSA
public:                                       //DSA
  DSAAction(void);                            //DSA
  ~DSAAction(void);                           //DSA
  int Column(void){return m_column;};         //DSA
  void Column(int column){m_column = column;};//DSA
  void Write(void);                           //DSA
  void Read(void);                            //DSA
  ui16 *Program(void){return m_program;};     //DSA                   //DSA
  int  ProgramSize(void)                      //DSA
  {                                           //DSA
    return m_numPgmWords;                     //DSA
  };                                          //DSA
};                                            //DSA
                                              //DSA
class DSAState                                //DSA
{                                             //DSA
  int         m_numAction;                    //DSA
  DSAAction **m_pActions;                     //DSA
public:                                       //DSA
  DSAState(void);                             //DSA
  ~DSAState(void);                            //DSA
  bool operator !=(DSAState&);                //DSA
  void Write(void);                           //DSA
  void Read(void);                            //DSA
  ui16 *Program(int column);                  //DSA
  int  ProgramSize(int column);               //DSA
};                                            //DSA
                                              //DSA
class DSA                                     //DSA
{                                             //DSA
  char       m_description[80];               //DSA
  ui16       m_state;                         //DSA
  char       m_localState;                    //DSA
  ui8        m_groupID;                       //DSA
  int        m_numState;                      //DSA
  int        m_firstDisplayedState;           //DSA
  DSAState **m_pStates;                       //DSA
public:                                       //DSA
  DSA(void);                                  //DSA
  ~DSA(void);                                 //DSA
  char *Description(void)                     //DSA
  {                                           //DSA
    return m_description;                     //DSA
  };                                          //DSA
  ui8 GroupID(void){return m_groupID;};       //DSA
  int LocalState(void)                        //DSA
  {                                           //DSA
    return m_localState;                      //DSA
  };                                          //DSA
  int State(void){return m_state;};           //DSA
  bool IsMaster(void)                         //DSA
  {                                           //DSA
    return m_localState!=3;                   //DSA
  };                                          //DSA
  void State(int s){m_state = (ui16)s;};      //DSA
  int NumState(void){return m_numState;};     //DSA
  void Write(void);                           //DSA
  void Read(void);                            //DSA
  DSAState *StatePointer(int stateNum);       //DSA
};                                            //DSA
                                              //DSA
class DSAINDEX                                //DSA
{                                             //DSA
  DSA *m_pDSA[256];                           //DSA
public:                                       //DSA
  DSAINDEX(void);                             //DSA
  ~DSAINDEX(void);                            //DSA
  DSA *GetDSA(int index);                     //DSA
  void SetDSA(int index, DSA *dsa);           //DSA
};                                            //DSA
extern DSAINDEX DSAIndex;                     //DSA
extern ui16 DSALevelIndex[16][32];            //DSA