home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / chip_20022115.iso / amiga / chipgame / scummvm_aga.lha / ScummVM_AGA / src / scumm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-01-05  |  36.9 KB  |  1,676 lines

  1. /* ScummVM - Scumm Interpreter
  2.  * Copyright (C) 2001  Ludvig Strigeus
  3.  *
  4.  * This program is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU General Public License
  6.  * as published by the Free Software Foundation; either version 2
  7.  * of the License, or (at your option) any later version.
  8.  
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17.  *
  18.  * $Header: /cvsroot/scummvm/scummvm/scumm.h,v 1.22 2001/11/09 18:54:14 strigeus Exp $
  19.  *
  20.  */
  21.  
  22. #include "scummsys.h"
  23. #include <graphics/gfx.h>
  24.  
  25. #define SWAP(a,b) do{int tmp=a; a=b; b=tmp; } while(0)
  26.  
  27. struct Scumm;
  28. struct Actor;
  29.  
  30. typedef void (Scumm::*OpcodeProc)();
  31.  
  32. #define NUM_SCRIPT_SLOT 25
  33.  
  34. #pragma START_PACK_STRUCTS
  35.  
  36. //#undef tPoint
  37. //#undef Point
  38.  
  39. /*struct Point {
  40.     int x,y;
  41. };*/
  42.  
  43. struct AdjustBoxResult {
  44.     int16 x,y;
  45.     uint16 dist;
  46. };
  47.  
  48. #define SIZEOF_BOX 20
  49. struct Box { /* file format */
  50.     int16 ulx,uly;
  51.     int16 urx,ury;
  52.     int16 llx,lly;
  53.     int16 lrx,lry;
  54.     byte mask;
  55.     byte flags;
  56.     uint16 scale;
  57. };
  58.  
  59. struct VerbSlot {
  60.     int16 x,y;
  61.     int16 right, bottom;
  62.     int16 oldleft, oldtop, oldright,oldbottom;
  63.     uint8 verbid;
  64.     uint8 color,hicolor,dimcolor,bkcolor,type;
  65.     uint8 charset_nr,curmode;
  66.     uint8 saveid;
  67.     uint8 key;
  68.     bool center;
  69.     uint8 field_1B;
  70.     uint16 imgindex;
  71. };
  72.  
  73. struct VirtScreen {
  74.     int number;
  75.     uint16 unk1;
  76.     uint16 topline;
  77.     uint16 width,height;
  78.     uint16 size;
  79.     byte alloctwobuffers;
  80.     byte scrollable;
  81.     uint16 xstart;
  82.     byte tdirty[40];
  83.     byte bdirty[40];
  84. };
  85.  
  86. struct ActorWalkData {
  87.     int16 destx,desty;
  88.     byte destbox;
  89.     byte destdir;
  90.     byte curbox;
  91.     byte field_7;
  92.     int16 x,y,newx,newy;
  93.     int32 XYFactor, YXFactor;
  94.     uint16 xfrac,yfrac;
  95. };
  96.  
  97. struct CostumeData {
  98.     uint16 hdr;
  99.     uint16 animCounter1;
  100.     byte animCounter2;
  101.     byte x_1;
  102.     uint16 a[16], b[16], c[16], d[16];
  103. };
  104.  
  105. struct MouseCursor {
  106.     int8 hotspot_x, hotspot_y;
  107.     byte colors[4];
  108.     byte data[32];
  109. };
  110.  
  111. struct ScriptSlot {
  112.     uint32 offs;
  113.     int32 delay;
  114.     uint16 number;
  115.     uint16 newfield;
  116.     byte status;
  117.     byte type;
  118.     byte unk1,unk2,freezeCount,didexec;
  119.     byte cutsceneOverride;
  120.     byte unk5;
  121. };
  122.  
  123. struct NestedScript {
  124.     uint16 number;
  125.     uint8 type;
  126.     uint8 slot;
  127. };
  128.  
  129. struct ResHeader {
  130.     uint32 size;
  131. };
  132.  
  133. class ObjectData {
  134. public:
  135.     uint32 offs_obim_to_room;
  136.     uint32 offs_obcd_to_room;
  137.     uint16 walk_x, walk_y;
  138.     uint16 obj_nr;
  139.     int16 x_pos;
  140.     int16 y_pos;
  141.     uint16 numstrips;
  142.     uint16 height;
  143.     byte actordir;
  144.     byte parent;
  145.     byte parentstate;
  146.     byte ownerstate;
  147.     byte fl_object_index;
  148.     byte unk_3;
  149. };
  150.  
  151. struct RoomHeader {
  152.     uint32 tag, size;
  153.     uint16 width,height;
  154.     uint16 numObjects;
  155. };
  156.  
  157. struct CodeHeader {
  158.     uint32 id;
  159.     uint32 size;
  160.     uint16 obj_id;
  161.  
  162.     union {
  163.         struct {
  164.             byte x,y,w,h;
  165.             byte flags;
  166.             byte parent;
  167.             uint16 walk_x;
  168.             uint16 walk_y;
  169.             byte actordir;
  170.         } v5;
  171.  
  172.         struct {
  173.             int16 x, y;
  174.             uint16 w,h;
  175.             byte flags, parent;
  176.             uint16 unk1;
  177.             uint16 unk2;
  178.             byte actordir;
  179.         } v6;
  180.     };
  181. };
  182.  
  183. struct ImageHeader { /* file format */
  184.     uint32 id;
  185.     uint32 size;
  186.     uint16 obj_id;
  187.     uint16 unk[5];
  188.     uint16 img_w;
  189.     uint16 img_h;
  190.     uint16 unk_2;
  191.     struct {
  192.         int16 x,y;
  193.     } hotspot[15];
  194. };
  195.  
  196. #pragma END_PACK_STRUCTS
  197.  
  198. struct PathNode {
  199.     uint index;
  200.     struct PathNode *left, *right;
  201. };
  202.  
  203. struct PathVertex {
  204.     PathNode *left;
  205.     PathNode *right;
  206. };
  207.  
  208.  
  209. enum {
  210.     sleByte = 1,
  211.     sleUint8 = 1,
  212.     sleInt8 = 1,
  213.     sleInt16 = 2,
  214.     sleUint16 = 3,
  215.     sleInt32 = 4,
  216.     sleUint32 = 5
  217. };
  218.  
  219. enum ScummVars {
  220.     VAR_EGO = 1,
  221.     VAR_CAMERA_CUR_POS = 2,
  222.     VAR_HAVE_MSG = 3,
  223.     VAR_ROOM = 4,
  224.     VAR_OVERRIDE = 5,
  225.     VAR_NUM_ACTOR = 8,
  226.     VAR_CURRENTDRIVE = 10,
  227.     VAR_TMR_1 = 11,
  228.     VAR_TMR_2 = 12,
  229.     VAR_TMR_3 = 13,
  230.     VAR_CAMERA_MIN = 17,
  231.     VAR_CAMERA_MAX = 18,
  232.     VAR_TIMER_NEXT = 19,
  233.     VAR_VIRT_MOUSE_X = 20,
  234.     VAR_VIRT_MOUSE_Y = 21,
  235.     VAR_ROOM_RESOURCE = 22,
  236.     VAR_LAST_SOUND = 23,
  237.     VAR_CUTSCENEEXIT_KEY = 24,
  238.     VAR_TALK_ACTOR = 25,
  239.     VAR_CAMERA_FAST = 26,
  240.     VAR_SCROLL_SCRIPT = 27,
  241.     VAR_ENTRY_SCRIPT = 28,
  242.     VAR_ENTRY_SCRIPT2 = 29,
  243.     VAR_EXIT_SCRIPT = 30,
  244.     VAR_EXIT_SCRIPT2 = 31,
  245.     VAR_VERB_SCRIPT = 32,
  246.     VAR_SENTENCE_SCRIPT = 33,
  247.     VAR_HOOK_SCRIPT = 34,
  248.     VAR_CUTSCENE_START_SCRIPT = 35,
  249.     VAR_CUTSCENE_END_SCRIPT = 36,
  250.     VAR_CHARINC = 37,
  251.     VAR_WALKTO_OBJ = 38,
  252.     VAR_DEBUGMODE = 39,
  253.     VAR_HEAPSPACE = 40,
  254.     VAR_RESTART_KEY = 42,
  255.     VAR_PAUSE_KEY = 43,
  256.     VAR_MOUSE_X = 44,
  257.     VAR_MOUSE_Y = 45,
  258.     VAR_TIMER = 46,
  259.     VAR_TMR_4 = 47,
  260.     VAR_SOUNDCARD = 48,
  261.     VAR_VIDEOMODE = 49,
  262.     VAR_SAVELOADDIALOG_KEY = 50,
  263.     VAR_FIXEDDISK = 51,
  264.     VAR_CURSORSTATE = 52,
  265.     VAR_USERPUT = 53,
  266.     VAR_SOUNDRESULT = 56,
  267.     VAR_TALKSTOP_KEY = 57,
  268.     VAR_59 = 59,
  269.     
  270.     VAR_SOUNDPARAM = 64,
  271.     VAR_SOUNDPARAM2 = 65,
  272.     VAR_SOUNDPARAM3 = 66,
  273.     VAR_MOUSEPRESENT = 67,
  274.     VAR_PERFORMANCE_1 = 68,
  275.     VAR_PERFORMANCE_2 = 69,
  276.     VAR_ROOM_FLAG = 70,
  277.     VAR_GAME_LOADED = 71,
  278.     VAR_NEW_ROOM = 72,
  279.     VAR_VERSION = 75,
  280.  
  281.     VAR_V5_DRAWFLAGS = 9,
  282.     VAR_MI1_TIMER = 14,
  283.     VAR_V5_OBJECT_LO = 15,
  284.     VAR_V5_OBJECT_HI = 16,
  285.     VAR_V5_TALK_STRING_Y = 54,
  286.     VAR_V5_CHARFLAG = 60,
  287.  
  288.     VAR_V6_SCREEN_WIDTH = 41,
  289.     VAR_V6_SCREEN_HEIGHT = 54,
  290.     VAR_V6_EMSSPACE = 76,
  291.     VAR_V6_RANDOM_NR = 118,
  292.  
  293. };
  294.  
  295. enum ResTypes {
  296.     rtRoom = 1,
  297.     rtScript = 2,
  298.     rtCostume = 3,
  299.     rtSound = 4,
  300.     rtInventory = 5,
  301.     rtCharset = 6,
  302.     rtString = 7,
  303.     rtVerb = 8,
  304.     rtActorName = 9,
  305.     rtBuffer = 10,
  306.     rtScaleTable = 11,
  307.     rtTemp = 12,
  308.     rtFlObject = 13,
  309.     rtMatrix = 14,
  310.     rtBox = 15,
  311.     rtObjectName = 16,
  312.  
  313. };
  314.  
  315. #define _maxRooms res.num[rtRoom]
  316. #define _maxScripts res.num[rtScript]
  317. #define _maxCostumes res.num[rtCostume]
  318. #define _maxInventoryItems res.num[rtInventory]
  319. #define _maxCharsets res.num[rtCharset]
  320. #define _maxStrings res.num[rtString]
  321. #define _maxVerbs res.num[rtVerb]
  322. #define _maxActorNames res.num[rtActorName]
  323. #define _maxBuffer res.num[rtBuffer]
  324. #define _maxScaleTable res.num[rtScaleTable]
  325. #define _maxTemp res.num[rtTemp]
  326. #define _maxFLObject res.num[rtFlObject]
  327. #define _maxMatrixes res.num[rtMatrix]
  328. #define _maxBoxes res.num[rtBox]
  329.  
  330. #define _baseRooms res.address[rtRoom]
  331. #define _baseScripts res.address[rtScript]
  332. #define _baseInventoryItems res.address[rtInventory]
  333. #define _baseFLObject res.address[rtFlObject]
  334. #define _baseArrays res.address[rtString]
  335.  
  336. #define _roomFileOffsets res.roomoffs[rtRoom]
  337.  
  338. struct CharsetRenderer {
  339.     Scumm *_vm;
  340.     int _top;
  341.     int _drawTop;
  342.     int _left, _left2;
  343.     byte _center;
  344.     int _right;
  345.     byte _color;
  346.     bool _hasMask;
  347.     bool _blitAlso;
  348.     
  349.     int _strLeft, _strRight, _strTop, _strBottom;
  350.     byte _curId;
  351.  
  352.     int _xpos2, _ypos2;
  353.     
  354.     byte _bufPos;
  355.     byte _unk12,_disableOffsX;
  356.     byte *_ptr;
  357.     byte _unk2, _bpp;
  358.     byte _invNumBits;
  359.     uint32 _charOffs;
  360.     byte *_charPtr;
  361.     int _width, _height;
  362.     int _offsX,_offsY;
  363.     byte _bitMask, _revBitMask;
  364.     int _bottom;
  365.     int _virtScreenHeight;
  366.  
  367.     byte _ignoreCharsetMask;
  368.  
  369.     byte *_backbuff_ptr, *_bgbak_ptr;
  370.     byte *_mask_ptr;
  371.     byte *_bg_ptr2;
  372.         
  373.     byte _colorMap[16];
  374.     byte _buffer[256];
  375.  
  376.     void drawBits();
  377.     void printChar(int chr);
  378.     int getStringWidth(int a, byte *str, int pos);
  379.     void addLinebreaks(int a, byte *str, int pos, int maxwidth);
  380. };
  381.  
  382. struct CostumeRenderer {
  383.     Scumm *_vm;
  384.     byte *_ptr;
  385.     byte _numColors;
  386.     byte *_dataptr;
  387.     byte *_frameptr;
  388.     byte *_srcptr;
  389.     byte *_bgbak_ptr, *_backbuff_ptr, *_mask_ptr, *_mask_ptr_dest;
  390.     int _actorX, _actorY;
  391.     byte _zbuf;
  392.     uint _scaleX, _scaleY;
  393.     int _xmove, _ymove;
  394.     bool _mirror;
  395.     byte _maskval;
  396.     byte _shrval;
  397.     byte _width2;
  398.     int _width;
  399.     byte _height2;
  400.     int _height;
  401.     int _xpos, _ypos;
  402.     
  403.     int _scaleIndexXStep;
  404.     int _scaleIndexYStep;
  405.     byte _scaleIndexX; /* must wrap at 256*/
  406.     byte _scaleIndexY, _scaleIndexYTop;
  407.     int _left,_right;
  408.     int _dir2;
  409.     int _top,_bottom;
  410.     int _ypostop;
  411.     uint _vscreenheight;
  412.     int _ypitch;
  413.     byte _docontinue;
  414.     int _imgbufoffs;
  415.     byte _repcolor;
  416.     byte _replen;
  417.     byte _palette[32];
  418.     byte _transEffect[0x100];
  419.  
  420.     void proc6();
  421.     void proc5();
  422.     void proc4();
  423.     void proc3();
  424.     void proc2();
  425.     void proc1();
  426.     byte mainRoutine(Actor *a, int slot, int frame);
  427.     void ignorePakCols(int num);
  428.  
  429.     void loadCostume(int id);
  430.     byte drawOneSlot(Actor *a, int slot);
  431.     byte drawCostume(Actor *a);
  432.  
  433.     byte animateOneSlot(Actor *a, int slot);
  434.     byte animate(Actor *a);
  435. };
  436.  
  437. struct Actor {
  438.     int x,y,top,bottom;
  439.     int elevation;
  440.     uint width;
  441.     byte number;
  442.     byte facing;
  443.     uint16 costume;
  444.     byte room;
  445.     byte talkColor;
  446.     byte scalex,scaley;
  447.     byte charset;
  448.     byte newDirection;
  449.     byte moving;
  450.     byte ignoreBoxes;
  451.     byte neverZClip;
  452.     byte initFrame,walkFrame,standFrame,talkFrame1,talkFrame2;
  453.     bool needRedraw, needBgReset,costumeNeedsInit,visible;
  454.     uint speedx,speedy;
  455.     byte data8; /* unused */
  456.     byte animIndex;
  457.     byte walkbox;
  458.     byte mask;
  459.     byte animProgress, animSpeed;
  460.     int16 new_1,new_2;
  461.     byte new_3;
  462.     byte sound[8];
  463.     ActorWalkData walkdata;
  464.     CostumeData cost;
  465.     byte palette[32];
  466. };
  467.  
  468. struct CameraData {
  469.     int16 _destPos, _curPos, _lastPos;
  470.     int16 _leftTrigger, _rightTrigger;
  471.     byte _follows, _mode;
  472.     uint16 _movingToActor;
  473. };
  474.  
  475. #define ARRAY_HDR_SIZE 6
  476. struct ArrayHeader {
  477.     int16 dim1_size;
  478.     int16 type;
  479.     int16 dim2_size;
  480.     byte data[1];
  481. };
  482.  
  483. struct SentenceTab {
  484.         byte unk5;
  485.         byte unk2;
  486.         uint16 unk4;
  487.         uint16 unk3;
  488.         byte unk;
  489.         byte pad;
  490. };
  491.  
  492. struct StringTab {
  493.     int16 t_xpos, t_ypos;
  494.     int16 t_right;
  495.     int16 xpos, ypos;
  496.     int16 right;
  497.     byte color, t_color;
  498.     byte charset, t_charset;
  499.     bool center, t_center;
  500.     bool overhead, t_overhead;
  501.     bool no_talk_anim,t_no_talk_anim;
  502. };
  503.  
  504. struct ColorCycle {
  505.     uint16 delay;
  506.     uint16 counter;
  507.     uint16 flags;
  508.     byte start;
  509.     byte end;
  510. };
  511.  
  512. struct Gdi {
  513.     Scumm *_vm;
  514.  
  515.     byte *_readPtr;
  516.     uint _readOffs;
  517.  
  518.     int8 _cursorActive;
  519.  
  520.     int _numZBuffer;
  521.     int _imgBufOffs[4];
  522.     byte _disable_zbuffer;
  523.  
  524.     bool _useOrDecompress;
  525.     byte _numLinesToProcess;
  526.     byte _tempNumLines;
  527.     byte _currentX;
  528.     byte _hotspot_x;
  529.     byte _hotspot_y;
  530.     int16 _drawMouseX;
  531.     int16 _drawMouseY;
  532.     int16 _mask_top, _mask_bottom, _mask_right, _mask_left;
  533.     byte _currentCursor;
  534.     byte _mouseColors[4];
  535.     byte _mouseColor;
  536.     byte _mouseClipMask1, _mouseClipMask2, _mouseClipMask3;
  537.     byte _mouseColorIndex;
  538.     byte *_mouseMaskPtr;
  539.     byte *_smap_ptr;
  540.     byte *_backbuff_ptr;
  541.     byte *_bgbak_ptr;
  542.     byte *_mask_ptr;
  543.     byte *_mask_ptr_dest;
  544.     byte *_z_plane_ptr;
  545.  
  546.     byte _decomp_shr, _decomp_mask;
  547.     byte _transparency;
  548.     uint16 _vertStripNextInc;
  549.     byte *_backupIsWhere;
  550.     
  551.     byte _mouseMask[0x200];
  552.  
  553.     void unkDecode1();
  554.     void unkDecode2();
  555.     void unkDecode3();
  556.     void unkDecode4();
  557.     void unkDecode5();
  558.     void unkDecode6();
  559.     void unkDecode7();
  560.  
  561.     void decompressBitmap();
  562.  
  563.     void drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, int stripnr, int numstrip, bool flag);
  564.     void clearUpperMask();
  565.  
  566.     void disableZBuffer() { _disable_zbuffer++; }
  567.     void enableZBuffer() { _disable_zbuffer--; }
  568.  
  569.     void draw8ColWithMasking();
  570.     void clear8ColWithMasking();
  571.     void clear8Col();
  572.     void decompressMaskImgOr();
  573.     void decompressMaskImg();
  574.  
  575.     void resetBackground(byte top, byte bottom, int strip);
  576.     void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
  577.     void updateDirtyScreen(VirtScreen *vs);
  578. };
  579.  
  580.  
  581. enum GameId {
  582.     GID_TENTACLE = 1,
  583.     GID_MONKEY2 = 2,
  584.     GID_INDY4 = 3,
  585.     GID_MONKEY = 4,
  586.     GID_SAMNMAX = 5,
  587. };
  588.  
  589. struct ScummDebugger;
  590. struct Serializer;
  591.  
  592. struct Scumm {
  593.     const char *_gameText;
  594.     byte _gameId;
  595.     byte _majorScummVersion;
  596.     byte _middleScummVersion;
  597.     byte _minorScummVersion;
  598.     ScummDebugger *_debugger;
  599.     void *_gui; /* actually a pointer to a Gui */
  600.     
  601.     int _lastLoadedRoom;
  602.     int _roomResource;
  603.     byte _encbyte;
  604.     void *_fileHandle;
  605.     void *_sfxFile;
  606.     char *_exe_name;
  607.  
  608.     byte _saveLoadFlag;
  609.     byte _saveLoadSlot;
  610.     bool _saveLoadCompatible;
  611.  
  612.     bool _dynamicRoomOffsets;
  613.     byte _resFilePathId;
  614.  
  615.     bool _useTalkAnims;
  616.     
  617.     char *_resFilePrefix;
  618.     char *_resFilePath;
  619.  
  620.     int _keyPressed;
  621.  
  622.     void *_soundDriver;
  623.  
  624.     uint16 *_inventory;
  625.     byte *_arrays;
  626.     VerbSlot *_verbs;
  627.     ObjectData *_objs;
  628.     uint16 *_newNames;
  629.     int16 *_vars;
  630.     byte *_bitVars;
  631.  
  632.     const OpcodeProc *_opcodes;
  633.  
  634.     byte _curActor;
  635.     int _curVerb;
  636.     int _curVerbSlot;
  637.  
  638.     int _curPalIndex;
  639.  
  640.     VirtScreen *_curVirtScreen;
  641.  
  642.     int _numVariables;
  643.     int _numBitVariables;
  644.     int _numLocalObjects;
  645.     int _numGlobalObjects;
  646.     int _numArray;
  647.     int _numVerbs;
  648.     int _numFlObject;
  649.     int _numInventory;
  650.     int _numRooms;
  651.     int _numScripts;
  652.     int _numSounds;
  653.     int _numCharsets;
  654.     int _numCostumes;
  655.  
  656.     byte *_msgPtrToAdd;
  657.     
  658.     uint8 *_roomFileIndexes;
  659.     byte *_objectFlagTable;
  660.     uint32 *_classData;
  661.  
  662.     byte _numGlobalScripts;
  663.     byte *_scriptPointer, *_scriptOrgPointer;
  664.     byte *_scriptPointerStart;
  665.     byte _opcode;
  666.     
  667.     byte _expire_counter;
  668.  
  669.     bool _noTalkAnims;
  670.  
  671.     bool _mouthSyncMode;
  672.     bool _endOfMouthSync;
  673.  
  674.     uint32 _randSeed1;
  675.     uint32 _randSeed2;
  676.  
  677.     uint16 _screenB, _screenH;
  678.  
  679.     uint16 _defaultTalkDelay;
  680.     byte _haveMsg;
  681.     byte _newEffect;
  682.     bool _fullRedraw;
  683.     uint16 _soundParam,_soundParam2,_soundParam3;
  684.     
  685.     byte _switchRoomEffect2, _switchRoomEffect;
  686.  
  687.     bool _egoPositioned;
  688.     bool _doEffect;
  689.     bool _screenEffectFlag;
  690.     bool _keepText;
  691.  
  692.     uint32 _maxHeapThreshold;
  693.     uint32 _minHeapThreshold;
  694.     
  695.     bool _fullScreen;
  696.  
  697.     byte _bkColor;
  698.     uint16 _lastXstart;
  699.         
  700.     int16 _talkDelay;
  701.     int16 _shakeMode;
  702.  
  703.     int16 _virtual_mouse_x, _virtual_mouse_y;
  704.  
  705.     int _cursorHotspotX, _cursorHotspotY;
  706.     int _cursorWidth, _cursorHeight;
  707.     byte _cursorAnimateIndex;
  708.     byte _cursorAnimate;
  709.  
  710.     byte _charsetColor;
  711.  
  712.     uint16 _debugMode;
  713.  
  714.     byte *_messagePtr;
  715.  
  716.     byte _numNestedScripts;
  717.     byte _currentScript;
  718.  
  719.     byte _currentRoom;
  720.     byte _numObjectsInRoom;
  721.     byte _actorToPrintStrFor;
  722.  
  723.     int16 _screenStartStrip;
  724.     int16 _screenEndStrip;
  725.  
  726.     byte _fastMode;
  727.     
  728.     bool _completeScreenRedraw;
  729.  
  730.     int8 _userPut;
  731.     int8 _cursorState;
  732.  
  733.     byte _sfxMode;
  734.  
  735.     uint16 _mouseButStat;
  736.     byte _leftBtnPressed, _rightBtnPressed;
  737.  
  738.     int _numInMsgStack;
  739.  
  740.     uint32 _localScriptList[0x39];
  741.  
  742.     VirtScreen virtscr[4];
  743.  
  744.     uint32 _ENCD_offs, _EXCD_offs;
  745.     uint32 _CLUT_offs, _EPAL_offs;
  746.     uint32 _IM00_offs;
  747.     uint32 _PALS_offs;
  748.  
  749.     uint32 _allocatedSize;
  750.  
  751.     uint32 _talk_sound_a, _talk_sound_b;
  752.     byte _talk_sound_mode;
  753.  
  754.     int _drawObjectQueNr;
  755.     byte _drawObjectQue[200];
  756.  
  757.     uint16 _currentDrive;
  758.     uint16 _soundCardType;
  759.     byte _mousePresent;
  760.  
  761.     int16 _palManipStart;
  762.     int16 _palManipEnd;
  763.     int16 _palManipCounter;
  764.  
  765.     struct {
  766.         byte mode[17];
  767.         uint16 num[17];
  768.         uint32 tags[17];
  769.         const char *name[17];
  770.         byte **address[17];
  771.         byte *flags[17];
  772.         byte *roomno[17];
  773.         uint32 *roomoffs[17];
  774.     } res;
  775.  
  776.     struct {
  777.         uint32 cutScenePtr[5];
  778.         byte cutSceneScript[5];
  779.         int16 cutSceneData[5];
  780.         int16 cutSceneScriptIndex;
  781.         byte cutSceneStackPointer;
  782.         ScriptSlot slot[NUM_SCRIPT_SLOT];
  783.         NestedScript nest[15];
  784.         int16 localvar[NUM_SCRIPT_SLOT][17];
  785.     } vm;
  786.  
  787.     struct {
  788.         int16 x,y;
  789.     } mouse;
  790.  
  791.     Actor actor[13];
  792.  
  793.     uint16 actorDrawBits[200];
  794.  
  795.     struct {
  796.         int upperLeftX;
  797.         int upperRightX;
  798.         int lowerLeftX;
  799.         int lowerRightX;
  800.         int upperLeftY;
  801.         int upperRightY;
  802.         int lowerLeftY;
  803.         int lowerRightY;
  804.     } box;
  805.  
  806.     CharsetRenderer charset;
  807.     
  808.     byte _charsetData[10][16];
  809.  
  810.     byte _resourceMapper[128];
  811.  
  812.     byte **_lastCodePtr;
  813.     
  814.     int _numSoundTags;
  815.     byte *_soundTagTable;
  816.  
  817.     int16 _bootParam;
  818.  
  819.     uint32 _fileOffset;
  820.  
  821.     byte _fileReadFailed;
  822.     byte _fileMode;
  823.  
  824.     uint32 _whereInResToRead;
  825.  
  826.     int _xPos, _yPos;
  827.     byte _dir;
  828.  
  829.     CameraData camera;
  830.  
  831.     int _resultVarNumber;
  832.  
  833.     byte _sentenceIndex;
  834.     SentenceTab sentence[6];
  835.  
  836.     StringTab string[6];
  837.  
  838.     CostumeRenderer cost;
  839.  
  840.     uint16 _mouthSyncTimes[52];
  841.  
  842.     int16 _soundQuePos;
  843.     int16 _soundQue[0x100];
  844.  
  845.     byte _soundQue2Pos;
  846.     byte _soundQue2[10];
  847.  
  848.     int16 _vararg_temp_pos[16];
  849.  
  850.     uint16 _curExecScript;
  851.  
  852.     int _scrWidthIn8Unit;
  853.     int _scrHeight;
  854.  
  855.     byte _currentPalette[0x300];
  856.  
  857.     int _palDirtyMin, _palDirtyMax;
  858.  
  859.     uint _curSoundPos;
  860.  
  861.     ColorCycle _colorCycle[16];
  862.  
  863.     Gdi gdi;
  864.     
  865.     bool _BgNeedsRedraw;
  866.  
  867.     int16 _localParamList[16];
  868.  
  869.     uint16 _verbMouseOver;
  870.  
  871.     int16 _foundPathX;
  872.     int16 _foundPathY;
  873.  
  874.     uint16 _lastKeyHit;
  875.  
  876.     int _scummStackPos;
  877.     int16 _scummStack[100];
  878.  
  879.     int _maxBoxVertexHeap;
  880.     byte *_boxMatrixPtr4, *_boxMatrixPtr1, *_boxMatrixPtr3;
  881.     int _boxPathVertexHeapIndex;
  882.     int _boxMatrixItem;
  883.  
  884.     byte _grabbedCursor[1024];
  885.  
  886.     char _saveLoadName[32];
  887.  
  888.     OpcodeProc getOpcode(int i) { return _opcodes[i]; }
  889.  
  890.     void openRoom(int room);
  891.     void deleteRoomOffsets();
  892.     void readRoomsOffsets();
  893.     void askForDisk(const char *filename);
  894.  
  895.     
  896.     bool openResourceFile(const char *filename);
  897.     
  898.     void fileClose(void *file);
  899.     void *fileOpen(const char *filename, int mode);
  900.     void fileSeek(void *file, long offs, int whence);
  901.     void fileRead(void *handle, void *ptr, uint32 size);
  902.     bool fileEof(void *handle);
  903.  
  904.     int fileReadByte();
  905.     uint32 fileReadDwordLE();
  906.     uint32 fileReadDwordBE();
  907. #if defined(SCUMM_LITTLE_ENDIAN)
  908.     uint32 fileReadDword() { return fileReadDwordLE(); }
  909. #elif defined(SCUMM_BIG_ENDIAN)
  910.     uint32 fileReadDword() { return fileReadDwordBE(); }
  911. #endif
  912.     uint fileReadWordLE();
  913.     uint fileReadWordBE();
  914.  
  915.     static byte *alloc(int size);
  916.     static void free(void *mem);
  917.  
  918.     void readResTypeList(int id, uint32 tag, const char *name);
  919.     void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode);
  920.  
  921.     void initThingsV5();
  922.     void initThingsV6();
  923.  
  924.     void initRandSeeds();
  925.  
  926.     uint getRandomNumber(uint max);
  927.  
  928.     void loadCharset(int i);
  929.     void nukeCharset(int i);
  930.     void initScreens(int a, int b, int w, int h);
  931.  
  932.     void setShake(int mode);
  933.     void setCursor(int cursor);
  934.  
  935.     void clearDrawObjectQueue();
  936.  
  937.     byte *createResource(int type, int index, uint32 size);
  938.  
  939.     void initScummVars();
  940.     void getGraphicsPerformance();
  941.  
  942.     void nukeResource(int type, int i);
  943.     byte *getResourceAddress(int type, int i);
  944.     byte *getStringAddress(int i);
  945.     void ensureResourceLoaded(int type, int i);
  946.     int loadResource(int type, int i);
  947.     int getResourceRoomNr(int type, int index);
  948.     int readSoundResource(int type, int index);
  949.     void setResourceCounter(int type, int index, byte flag);
  950.     void validateResource(const char *str, int type, int index);
  951.     
  952.     void initVirtScreen(int slot, int top, int height, bool twobufs, bool fourextra);
  953.     void setDirtyRange(int slot, int a, int height);
  954.     void drawDirtyScreenParts();
  955.     void updateDirtyScreen(int slot);
  956.     void unkVirtScreen4(int a);
  957.     
  958.     void restoreMouse();
  959.     void initActor(Actor *a, int mode);
  960.     bool checkFixedDisk();
  961.  
  962.     void setActorWalkSpeed(Actor *a, uint speed1, uint speed2);
  963.     int calcMovementFactor(Actor *a, int newx, int newy);
  964.     int actorWalkStep(Actor *a);
  965.     int getProgrDirChange(Actor *a, int mode);
  966.  
  967.     bool checkXYInBoxBounds(int box, int x, int y);
  968.     void setupActorScale(Actor *a);
  969.     
  970.     void checkRange(int max, int min, int no, const char *str);
  971.  
  972.     bool fileReadFailed(void *handle);
  973.     void clearFileReadFailed(void *handle);
  974.  
  975.     bool getClass(int obj, int cls);
  976.     void putClass(int obj, int cls, bool set);
  977.     int getState(int obj);
  978.     void putState(int obj, int state);
  979.     int getOwner(int obj);
  980.     void putOwner(int obj, int owner);
  981.  
  982.     void main();
  983.  
  984.     uint distanceFromPt(int x, int y, int ptx, int pty);
  985.     Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y);
  986.     bool getSideOfLine(int x1,int y1, int x2, int y2, int x, int y, int box);
  987.     void getBoxCoordinates(int box);
  988.     byte getMaskFromBox(int box);
  989.     Box *getBoxBaseAddr(int box);
  990.     byte getBoxFlags(int box);
  991.     int getBoxScale(int box);
  992.     byte getNumBoxes();
  993.     byte *getBoxMatrixBaseAddr();
  994.  
  995.     void startAnimActor(Actor *a, int frame, byte direction);
  996.     void initActorCostumeData(Actor *a);
  997.     void fixActorDirection(Actor *a, byte direction);
  998.     void decodeCostData(Actor *a, int frame, uint mask);
  999.  
  1000.     void scummInit();
  1001.     void scummMain(int argc, char **argv);
  1002.  
  1003.     void runScript(int script, int a, int b, int16 *lvarptr);
  1004.     void stopScriptNr(int script);
  1005.     int getScriptSlot();
  1006.     void runScriptNested(int script);
  1007.     void updateScriptPtr();
  1008.     void getScriptBaseAddress();
  1009.     void getScriptEntryPoint();
  1010.     void executeScript();
  1011.     byte fetchScriptByte();
  1012.     int fetchScriptWord();
  1013.     void ignoreScriptWord() { fetchScriptWord(); }
  1014.     void ignoreScriptByte() { fetchScriptByte(); }
  1015.     int getVarOrDirectWord(byte mask);
  1016.     int getVarOrDirectByte(byte mask);
  1017.     int readVar(uint var);
  1018.     void writeVar(uint var, int value);
  1019.     void getResultPos();
  1020.     void setResult(int result);
  1021.     
  1022.     int getObjectIndex(int object);
  1023.  
  1024.     void o5_actorFollowCamera();
  1025.     void o5_actorFromPos();
  1026.     void o5_actorSet();
  1027.     void o5_actorSetClass();
  1028.     void o5_add();
  1029.     void o5_and();
  1030.     void o5_animateActor();
  1031.     void o5_badOpcode();
  1032.     void o5_breakHere();
  1033.     void o5_chainScript();
  1034.     void o5_cursorCommand();
  1035.     void o5_cutscene();
  1036.     void o5_debug();
  1037.     void o5_decrement();
  1038.     void o5_delay();
  1039.     void o5_delayVariable();
  1040.     void o5_divide();
  1041.     void o5_doSentence();
  1042.     void o5_drawBox();
  1043.     void o5_drawObject();
  1044.     void o5_dummy();
  1045.     void o5_endCutscene();
  1046.     void o5_equalZero();
  1047.     void o5_expression();
  1048.     void o5_faceActor();
  1049.     void o5_findInventory();
  1050.     void o5_findObject();
  1051.     void o5_freezeScripts();
  1052.     void o5_getActorCostume();
  1053.     void o5_getActorElevation();
  1054.     void o5_getActorFacing();
  1055.     void o5_getActorMoving();
  1056.     void o5_getActorRoom();
  1057.     void o5_getActorScale();
  1058.     void o5_getActorWalkBox();
  1059.     void o5_getActorWidth();
  1060.     void o5_getActorX();
  1061.     void o5_getActorY();
  1062.     void o5_getAnimCounter();
  1063.     void o5_getClosestObjActor();
  1064.     void o5_getDist();
  1065.     void o5_getInventoryCount();
  1066.     void o5_getObjectOwner();
  1067.     void o5_getObjectState();
  1068.     void o5_getRandomNr();
  1069.     void o5_getScriptRunning();
  1070.     void o5_getVerbEntrypoint();
  1071.     void o5_ifClassOfIs();
  1072.     void o5_increment();
  1073.     void o5_isActorInBox();
  1074.     void o5_isEqual();
  1075.     void o5_isGreater();
  1076.     void o5_isGreaterEqual();
  1077.     void o5_isLess();
  1078.     void o5_isNotEqual();
  1079.     void o5_isSoundRunning();
  1080.     void o5_jumpRelative();
  1081.     void o5_lessOrEqual();
  1082.     void o5_lights();
  1083.     void o5_loadRoom();
  1084.     void o5_loadRoomWithEgo();
  1085.     void o5_matrixOps();
  1086.     void o5_move();
  1087.     void o5_multiply();
  1088.     void o5_notEqualZero();
  1089.     void o5_or();
  1090.     void o5_overRide();
  1091.     void o5_panCameraTo();
  1092.     void o5_pickupObject();
  1093.     void o5_print();
  1094.     void o5_printEgo();
  1095.     void o5_pseudoRoom();
  1096.     void o5_putActor();
  1097.     void o5_putActorAtObject();
  1098.     void o5_putActorInRoom();
  1099.     void o5_quitPauseRestart();
  1100.     void o5_resourceRoutines();
  1101.     void o5_roomOps();
  1102.     void o5_saveRestoreVerbs();
  1103.     void o5_setCameraAt();
  1104.     void o5_setObjectName();
  1105.     void o5_setOwnerOf();
  1106.     void o5_setState();
  1107.     void o5_setVarRange();
  1108.     void o5_soundKludge();
  1109.     void o5_startMusic();
  1110.     void o5_startObject();
  1111.     void o5_startScript();
  1112.     void o5_startSound();
  1113.     void o5_stopMusic();
  1114.     void o5_stopObjectCode();
  1115.     void o5_stopObjectScript();
  1116.     void o5_stopScript();
  1117.     void o5_stopSound();
  1118.     void o5_stringOps();
  1119.     void o5_subtract();
  1120.     void o5_verbOps();
  1121.     void o5_wait();
  1122.     void o5_walkActorTo();
  1123.     void o5_walkActorToActor();
  1124.     void o5_walkActorToObject();
  1125.  
  1126.     void o6_pushByte();
  1127.     void o6_pushWord();
  1128.     void o6_pushByteVar();
  1129.     void o6_pushWordVar();
  1130.     void o6_invalid();
  1131.     void o6_byteArrayRead();
  1132.     void o6_wordArrayRead();
  1133.     void o6_byteArrayIndexedRead();
  1134.     void o6_wordArrayIndexedRead();
  1135.     void o6_dup();
  1136.     void o6_zero();
  1137.     void o6_eq();
  1138.     void o6_neq();
  1139.     void o6_gt();
  1140.     void o6_lt();
  1141.     void o6_le();
  1142.     void o6_ge();
  1143.     void o6_add();
  1144.     void o6_sub();
  1145.     void o6_mul();
  1146.     void o6_div();
  1147.     void o6_land();
  1148.     void o6_lor();
  1149.     void o6_kill();
  1150.     void o6_writeByteVar();
  1151.     void o6_writeWordVar();
  1152.     void o6_byteArrayWrite();
  1153.     void o6_wordArrayWrite();
  1154.     void o6_byteArrayIndexedWrite();
  1155.     void o6_wordArrayIndexedWrite();
  1156.     void o6_byteVarInc();
  1157.     void o6_wordVarInc();
  1158.     void o6_byteArrayInc();
  1159.     void o6_wordArrayInc();
  1160.     void o6_byteVarDec();
  1161.     void o6_wordVarDec();
  1162.     void o6_byteArrayDec();
  1163.     void o6_wordArrayDec();
  1164.     void o6_jumpTrue();
  1165.     void o6_jumpFalse();
  1166.     void o6_jump();
  1167.     void o6_startScriptEx();
  1168.     void o6_startScript();
  1169.     void o6_startObject();
  1170.     void o6_setObjectState();
  1171.     void o6_setObjectXY();
  1172.     void o6_stopObjectCode();
  1173.     void o6_endCutscene();
  1174.     void o6_cutScene();
  1175.     void o6_stopMusic();
  1176.     void o6_freezeUnfreeze();
  1177.     void o6_cursorCommand();
  1178.     void o6_breakHere();
  1179.     void o6_ifClassOfIs();
  1180.     void o6_setClass();
  1181.     void o6_getState();
  1182.     void o6_setState();
  1183.     void o6_setOwner();
  1184.     void o6_getOwner();
  1185.     void o6_startSound();
  1186.     void o6_stopSound();
  1187.     void o6_startMusic();
  1188.     void o6_stopObjectScript();
  1189.     void o6_panCameraTo();
  1190.     void o6_actorFollowCamera();
  1191.     void o6_setCameraAt();
  1192.     void o6_loadRoom();
  1193.     void o6_stopScript();
  1194.     void o6_walkActorToObj();
  1195.     void o6_walkActorTo();
  1196.     void o6_putActorInRoom();
  1197.     void o6_putActorAtObject();
  1198.     void o6_faceActor();
  1199.     void o6_animateActor();
  1200.     void o6_doSentence();
  1201.     void o6_pickupObject();
  1202.     void o6_loadRoomWithEgo();
  1203.     void o6_getRandomNumber();
  1204.     void o6_getRandomNumberRange();
  1205.     void o6_getActorMoving();
  1206.     void o6_getScriptRunning();
  1207.     void o6_getActorRoom();
  1208.     void o6_getObjectX();
  1209.     void o6_getObjectY();
  1210.     void o6_getObjectDir();
  1211.     void o6_getActorWalkBox();
  1212.     void o6_getActorCostume();
  1213.     void o6_findInventory();
  1214.     void o6_getInventoryCount();
  1215.     void o6_getVerbFromXY();
  1216.     void o6_beginOverride();
  1217.     void o6_endOverride();
  1218.     void o6_setObjectName();
  1219.     void o6_isSoundRunning();
  1220.     void o6_setBoxFlags();
  1221.     void o6_createBoxMatrix();
  1222.     void o6_resourceRoutines();
  1223.     void o6_roomOps();
  1224.     void o6_actorSet();
  1225.     void o6_verbOps();
  1226.     void o6_getActorFromXY();
  1227.     void o6_findObject();
  1228.     void o6_pseudoRoom();
  1229.     void o6_getActorElevation();
  1230.     void o6_getVerbEntrypoint();
  1231.     void o6_arrayOps();
  1232.     void o6_saveRestoreVerbs();
  1233.     void o6_drawBox();
  1234.     void o6_getActorWidth();
  1235.     void o6_wait();
  1236.     void o6_getActorScaleX();
  1237.     void o6_getActorAnimCounter1();
  1238.     void o6_soundKludge();
  1239.     void o6_isAnyOf();
  1240.     void o6_quitPauseRestart();
  1241.     void o6_isActorInBox();
  1242.     void o6_delay();
  1243.     void o6_delayLonger();
  1244.     void o6_delayVeryLong();
  1245.     void o6_stopSentence();
  1246.     void o6_print_0();
  1247.     void o6_print_1();
  1248.     void o6_print_2();
  1249.     void o6_print_3();
  1250.     void o6_printActor();
  1251.     void o6_printEgo();
  1252.     void o6_talkActor();
  1253.     void o6_talkEgo();
  1254.     void o6_dim();
  1255.     void o6_runVerbCodeQuick();
  1256.     void o6_runScriptQuick();
  1257.     void o6_dim2();
  1258.     void o6_abs();
  1259.     void o6_distObjectObject();
  1260.     void o6_distObjectPt();
  1261.     void o6_distPtPt();
  1262.     void o6_dummy_stacklist();
  1263.     void o6_miscOps();
  1264.     void o6_breakMaybe();
  1265.     void o6_pickOneOf();
  1266.     void o6_pickOneOfDefault();
  1267.  
  1268.     void soundKludge(int16 *list);
  1269.  
  1270.     void stopObjectCode();
  1271.     void stopObjectScript(int script);
  1272.     void putActor(Actor *a, int x, int y, byte room);
  1273.     void clearMsgQueue();
  1274.     void adjustActorPos(Actor *a);
  1275.     
  1276.     void hideActor(Actor *a);
  1277.     void showActor(Actor *a);
  1278.     void showActors();
  1279.     void turnToDirection(Actor *a, int newdir);
  1280.  
  1281.     int whereIsObject(int object);
  1282.     int getObjectOrActorXY(int object);
  1283.     void addSoundToQueue(int sound);
  1284.     void addSoundToQueue2(int sound);
  1285.     bool isScriptInUse(int script);
  1286.     int getActorXYPos(Actor *a);
  1287.     void getObjectXYPos(int object);
  1288.     AdjustBoxResult adjustXYToBeInBox(Actor *a, int x, int y);
  1289.  
  1290.     int getWordVararg(int16 *ptr);
  1291.  
  1292.     int getObjActToObjActDist(int a, int b);
  1293.     void processSoundQues();
  1294.     bool inBoxQuickReject(int box, int x, int y, int threshold);
  1295.     AdjustBoxResult getClosestPtOnBox(int box, int x, int y);
  1296.  
  1297.     void setCameraAt(int dest);
  1298.     void stopTalk();
  1299.     void restoreCharsetBg();
  1300.  
  1301.     void setCameraFollows(Actor *a);
  1302.     void runHook(int i);
  1303.     void startScene(int room, Actor *a, int b);
  1304.  
  1305.     void freezeScripts(int scr);
  1306.     void unfreezeScripts();
  1307.  
  1308.     void runAllScripts();
  1309.  
  1310.     int findObject(int x, int y);
  1311.     void stopCycle(int i);
  1312.     void killScriptsAndResources();
  1313.     void runExitScript();
  1314.     void runEntryScript();
  1315.  
  1316.     void increaseResourceCounter();
  1317.     bool isResourceInUse(int type, int i);
  1318.     void initRoomSubBlocks();
  1319.     void loadRoomObjects();
  1320.  
  1321.     void setPaletteFromRes();
  1322.     void initCycl(byte *ptr);
  1323.     void initBGBuffers();
  1324.     void setDirtyColors(int min, int max);
  1325.  
  1326.     void setScaleItem(int slot, int a, int b, int c, int d);
  1327.  
  1328.     void cyclePalette();
  1329.  
  1330.     void moveMemInPalRes(int start, int end, byte direction);
  1331.  
  1332.     void redrawBGAreas();
  1333.     void drawRoomObjects(int arg);
  1334.     void redrawBGStrip(int start, int num);
  1335.     void drawObject(int obj, int arg);
  1336.  
  1337.     int hasCharsetMask(int x, int y, int x2, int y2);
  1338.  
  1339.     void restoreBG(int left, int top, int right, int bottom);
  1340.     void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint16 dirtybits);
  1341.     VirtScreen *findVirtScreen(int y);
  1342.  
  1343.     void unkScreenEffect1();
  1344.     void unkScreenEffect2();
  1345.     void unkScreenEffect3();
  1346.     void unkScreenEffect4();
  1347.     void unkScreenEffect5(int a);
  1348.     void unkScreenEffect6();
  1349.     void unkScreenEffect7(int a);
  1350.     
  1351.     void playSound(int sound);
  1352.  
  1353.     void decreaseScriptDelay(int amount);
  1354.     void processKbd();
  1355.     
  1356.     void redrawVerbs();
  1357.     void checkExecVerbs();
  1358.     void checkAndRunVar33();
  1359.     void CHARSET_1();
  1360.     void walkActors();
  1361.     void moveCamera();
  1362.     void fixObjectFlags();
  1363.     void clear_fullRedraw();
  1364.     void palManipulate();
  1365.     void screenEffect(int effect);
  1366.     void clearClickedStatus();
  1367.     void verbMouseOver(int verb);
  1368.     int checkMouseOver(int x, int y);
  1369.     void playActorSounds();
  1370.     void processDrawQue();
  1371.     void setActorRedrawFlags();
  1372.     void resetActorBgs();
  1373.     void processActors();
  1374.     void drawVerb(int verb, int mode);
  1375.  
  1376.     void runInputScript(int a, int cmd, int mode);
  1377.  
  1378.     void cameraMoved();
  1379.  
  1380.     void walkActor(Actor *a);
  1381.  
  1382.     int checkKeyHit();
  1383.  
  1384.     int getPathToDestBox(int from, int to);
  1385.     int findPathTowards(Actor *a, int box, int box2, int box3);
  1386.  
  1387.     void setActorCostPalette(Actor *a);
  1388.     void drawActorCostume(Actor *a);
  1389.     void actorAnimate(Actor *a);
  1390.  
  1391.     int getActorFromPos(int x, int y);
  1392.  
  1393.     void restoreVerbBG(int verb);
  1394.  
  1395.     void drawString(int a);
  1396.     void drawVerbBitmap(int vrb, int x, int y);
  1397.  
  1398.     void setActorCostume(Actor *a, int c);
  1399.     void loadPtrToResource(int type, int i, byte *ptr);
  1400.  
  1401.     void push(int a);
  1402.     int pop();
  1403.  
  1404.     void walkActorTo(Actor *a, int x, int y, int direction);
  1405.  
  1406.     void setCursorImg(uint cursor, uint img);
  1407.     void setCursorHotspot(int cursor, int x, int y);
  1408.     void initCharset(int charset);
  1409.     void addObjectToDrawQue(int object);
  1410.     int getVerbEntrypoint(int obj, int entry);
  1411.     int isSoundRunning(int a);
  1412.     void startWalkActor(Actor *a, int x, int y, int dir);
  1413.     void setBoxFlags(int box, int val);
  1414.     void setBoxScale(int box, int b);
  1415.     void createBoxMatrix();
  1416.     void addObjectToInventory(uint obj, uint room);
  1417.     void removeObjectFromRoom(int obj);
  1418.     void decodeParseString();
  1419.     void pauseGame(int i);
  1420.     void shutDown(int i);
  1421.     void lock(int type, int i);
  1422.     void unlock(int type, int i);
  1423.     void heapClear(int mode);
  1424.     void unkHeapProc2(int a, int b);
  1425.     void loadFlObject(int a, int b);
  1426.     void setPalColor(int index, int r, int g, int b);
  1427.     void darkenPalette(int a, int b, int c, int d, int e);
  1428.     void unkRoomFunc3(int a, int b, int c, int d, int e);
  1429.     void unkRoomFunc4(int a, int b, int c, int d, int e);
  1430.     int getVerbSlot(int id, int mode);
  1431.     void killVerb(int slot);
  1432.     byte *getObjectAddress(int obj);
  1433.     byte *getObjOrActorName(int obj);
  1434.     void clearOwnerOf(int obj);
  1435.     void runVerbCode(int script, int entry, int a, int b, int16 *vars);
  1436.     void setVerbObject(uint room, uint object, uint verb);
  1437.     void unkMessage1();
  1438.     void unkMessage2();
  1439.     void actorTalk();
  1440.  
  1441.     byte *addMessageToStack(byte *msg);
  1442.  
  1443.     void unkAddMsgToStack2(int var);
  1444.     void unkAddMsgToStack3(int var);
  1445.     void unkAddMsgToStack4(int var);
  1446.     void unkAddMsgToStack5(int var);
  1447.  
  1448.     byte *getActorName(Actor *a);
  1449.     uint32 getOBCDOffs(int object);
  1450.  
  1451.     byte isMaskActiveAt(int l, int t, int r, int b, byte *mem);
  1452.  
  1453.     int getInventorySlot();
  1454.  
  1455.  
  1456.     int getKeyInput(int a);
  1457.     void convertKeysToClicks();
  1458.  
  1459.     void drawBox(int x, int y, int x2, int y2, int color);
  1460.  
  1461.     void drawMouse();
  1462.  
  1463.     void dumpResource(char *tag, int index, byte *ptr);
  1464.  
  1465.     bool saveState(int slot, bool compat);
  1466.     bool loadState(int slot, bool compat);
  1467.     void saveOrLoad(Serializer *s);
  1468.  
  1469.     void saveLoadResource(Serializer *ser, int type, int index);
  1470.     bool isResourceLoaded(int type, int index);
  1471.  
  1472.  
  1473.     Actor *derefActor(int id) { return &actor[id]; }
  1474.     Actor *derefActorSafe(int id, const char *errmsg);
  1475.     Actor *getFirstActor() { return actor; } 
  1476.  
  1477.     void setupCostumeRenderer(CostumeRenderer *c, Actor *a);
  1478.  
  1479.     PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node);
  1480.     PathNode *unkMatrixProc2(PathVertex *vtx, int i);
  1481.     bool areBoxesNeighbours(int i, int j);
  1482.     void addToBoxMatrix(byte b);
  1483.     PathVertex *addPathVertex();
  1484.     void *addToBoxVertexHeap(int size);
  1485.  
  1486.     void parseCommandLine(int argc, char **argv);
  1487.  
  1488.     void showHelpAndExit();
  1489.     
  1490.     char *getGameName();
  1491.     bool detectGame();
  1492.  
  1493.     void setupOpcodes();
  1494.     void setupOpcodes2();
  1495.     void endCutscene();
  1496.     void cutscene(int16 *args);
  1497.  
  1498.     void setOwnerOf(int obj, int owner);
  1499.     void panCameraTo(int x);
  1500.     void actorFollowCamera(int act);
  1501.     void setCameraAtEx(int at);
  1502.  
  1503.     void setCursorHotspot2(int x,int y);
  1504.  
  1505.     void makeCursorColorTransparent(int a);
  1506.  
  1507.     void faceActorToObj(int act, int obj);
  1508.     void animateActor(int act, int anim);
  1509.     int getScriptRunning(int script);
  1510.     int getObjX(int obj);
  1511.     int getObjY(int obj);
  1512.     int getObjDir(int obj);
  1513.     int findInventory(int owner, int index);
  1514.     int getInventoryCount(int owner);
  1515.  
  1516.     void beginOverride();
  1517.     void endOverride();
  1518.  
  1519.     void setPalette(int pal);
  1520.     void setPaletteFromPtr(byte *ptr);
  1521.     byte *findPalInPals(byte *pal, int index);
  1522.  
  1523.     int getStringLen(byte *ptr);
  1524.  
  1525.     void readArrayFromIndexFile();
  1526.     void readMAXS();
  1527.     void readIndexFileV6();
  1528.  
  1529.     int readArray(int array, int index, int base);
  1530.     void writeArray(int array, int index, int base, int value);
  1531.     
  1532.     int getStackList(int16 *args, uint maxnum);
  1533.     void setObjectState(int obj, int state, int x, int y);
  1534.  
  1535.     void setStringVars(int i);
  1536.     void decodeParseString2(int a, int b);
  1537.  
  1538.     void arrayop_1(int a, byte *ptr);
  1539.     
  1540.     void copyString(byte *dst, byte *src, int len);
  1541.     int getArrayId();
  1542.  
  1543.     void nukeArray(int a);
  1544.     int defineArray(int a, int b, int c, int d);
  1545.     int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f);
  1546.     void grabCursor(int x, int y, int w, int h);
  1547.     void unkMiscOp9();
  1548.     void startManiac();
  1549.     void readIndexFileV5(int i);
  1550.     void grabCursor(byte *ptr, int width, int height);
  1551.     byte *getPalettePtr();
  1552.     void setupSound();
  1553.     void stopAllSounds();
  1554.     void stopSound(int sound);
  1555.     bool isSoundInQueue(int sound);
  1556.     void clearSoundQue();
  1557.     void talkSound(uint32 a, uint32 b, int mode);
  1558.     void processSfxQueues();
  1559.     void startTalkSound(uint32 a, uint32 b, int mode);
  1560.     bool isMouthSyncOff(uint pos);
  1561.     void startSfxSound(void *file);
  1562.     void *openSfxFile();
  1563.     void resourceStats();
  1564.     bool isCostumeInUse(int i);
  1565.     void expireResources(uint32 size);
  1566.     
  1567.     void freeResources();
  1568.     void destroy();
  1569.  
  1570.     void useIm01Cursor(byte *im, int w, int h);
  1571.     void useBompCursor(byte *im, int w, int h);
  1572.  
  1573.     void decompressBomp(byte *dst, byte *src, int w, int h);
  1574.  
  1575.     void setupCursor() { _cursorAnimate = 1; }
  1576.  
  1577.     void decompressDefaultCursor(int index);
  1578.  
  1579.     void allocateArrays();
  1580.  
  1581.     void initializeLocals(int slot, int16 *vars);
  1582.  
  1583.     static void setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom);
  1584.     int scummLoop(int delta);
  1585.  
  1586.     bool getSavegameName(int slot, char *desc);
  1587.     void makeSavegameName(char *out, int slot, bool compatible);
  1588.  
  1589.     void exitCutscene();
  1590. };
  1591.  
  1592. struct ScummDebugger {
  1593.     Scumm *_s;
  1594.     byte _command;
  1595.     char *_parameters;
  1596.  
  1597.     bool _welcome;
  1598.  
  1599.     int _go_amount;
  1600.     
  1601.     char _cmd_buffer[256];
  1602.     
  1603.     void on_frame();
  1604.     bool do_command();
  1605.     void enter();
  1606.     int get_command();
  1607.     void attach(Scumm *s);
  1608.     void detach();
  1609.  
  1610.     void printActors(int act);
  1611.     void printScripts();
  1612. };
  1613.  
  1614. struct SaveLoadEntry {
  1615.     uint16 offs;
  1616.     uint8 type;
  1617.     uint8 size;
  1618. };
  1619.  
  1620. typedef int SerializerSaveReference(void *me, byte type, void *ref);
  1621. typedef void *SerializerLoadReference(void *me, byte type, int ref);
  1622.  
  1623.  
  1624. struct Serializer {
  1625.     FILE *_saveLoadStream;
  1626.  
  1627.     union {
  1628.         SerializerSaveReference *_save_ref;
  1629.         SerializerLoadReference *_load_ref;
  1630.     };
  1631.     void *_ref_me;
  1632.  
  1633.     bool _saveOrLoad;
  1634.  
  1635.     void saveLoadBytes(void *b, int len);
  1636.     void saveLoadArrayOf(void *b, int len, int datasize, byte filetype);
  1637.     void saveLoadEntries(void *d, const SaveLoadEntry *sle);
  1638.     void saveLoadArrayOf(void *b, int num, int datasize, const SaveLoadEntry *sle);
  1639.  
  1640.     void saveUint32(uint32 d);
  1641.     void saveWord(uint16 d);
  1642.     void saveByte(byte b);
  1643.  
  1644.     byte loadByte();
  1645.     uint16 loadWord();
  1646.     uint32 loadUint32();
  1647.  
  1648.     bool isSaving() { return _saveOrLoad; }
  1649. };
  1650.  
  1651.  
  1652.  
  1653. void waitForTimer(Scumm *s);
  1654. void outputdisplay2(Scumm *s, int disp);
  1655. extern const byte revBitMask[8];
  1656. void blitToScreen(Scumm *s, byte *src, int x, int y, int w, int h);
  1657.  
  1658. #if defined(__GNUC__)
  1659. void CDECL error(const char *s, ...) NORETURN;
  1660. #else
  1661. void CDECL NORETURN error(const char *s, ...);
  1662. #endif
  1663.  
  1664. void CDECL warning(const char *s, ...);
  1665. void CDECL debug(int level, const char *s, ...);
  1666. void checkHeap();
  1667. void initGraphics(Scumm *s, bool fullScreen);
  1668. void updateScreen(Scumm *s);
  1669.  
  1670. void drawMouse(Scumm *s, int x, int y, int color, byte *mask, bool visible);
  1671. void drawMouse(Scumm *s, int x, int y, int w, int h, byte *buf, bool visible);
  1672. void blit(byte *dst, byte *src, int w, int h);
  1673. byte *findResource(uint32 id, byte *searchin, int index);
  1674. void playSfxSound(void *sound, uint32 size, uint rate);
  1675. bool isSfxFinished();
  1676.