ScummVM API documentation
agos.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGOS_AGOS_H
23 #define AGOS_AGOS_H
24 
25 #include "engines/engine.h"
26 
27 #include "common/array.h"
28 #include "common/error.h"
29 #include "common/keyboard.h"
30 #include "common/random.h"
31 #include "common/rect.h"
32 #include "common/stack.h"
33 #include "common/util.h"
34 #include "audio/mixer.h"
35 
36 #include "agos/vga.h"
37 #include "agos/detection.h"
38 
53 namespace Common {
54 class File;
55 class SeekableReadStream;
56 }
57 
58 namespace Graphics {
59 struct Surface;
60 class FontSJIS;
61 }
62 
63 namespace AGOS {
64 
65 enum {
66  kDebugOpcode = 1 << 0,
67  kDebugVGAOpcode = 1 << 1,
68  kDebugSubroutine = 1 << 2,
69  kDebugVGAScript = 1 << 3,
70  kDebugImageDump = 1 << 4
71 };
72 
73 uint fileReadItemID(Common::SeekableReadStream *in);
74 
75 #define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y))
76 
77 #ifdef ENABLE_AGOS2
78 class MoviePlayer;
79 #endif
80 
81 class Sound;
82 class MidiPlayer;
83 
84 struct Child;
85 struct SubObject;
86 struct RoomState;
87 struct SubRoom;
88 struct SubSuperRoom;
89 
90 struct Item;
91 struct WindowBlock;
92 struct Subroutine;
93 struct SubroutineLine;
94 struct TimeEvent;
95 
96 struct TextLocation {
97  int16 x, y, width;
98  TextLocation() { memset(this, 0, sizeof(*this)); }
99 };
100 
101 struct HitArea {
102  uint16 x, y;
103  uint16 width, height;
104  uint16 flags;
105  uint16 id;
106  uint16 data;
107  WindowBlock *window;
108  Item *itemPtr;
109  uint16 verb;
110  uint16 priority;
111 
112  // Personal Nightmare specific
113  uint16 msg1, msg2;
114  HitArea() { memset(this, 0, sizeof(*this)); }
115 };
116 
118  byte *vgaFile1;
119  byte *vgaFile1End;
120  byte *vgaFile2;
121  byte *vgaFile2End;
122  byte *sfxFile;
123  byte *sfxFileEnd;
124  VgaPointersEntry() { memset(this, 0, sizeof(*this)); }
125 };
126 
127 struct VgaSprite {
128  uint16 id;
129  int16 image;
130  uint16 palette;
131  int16 x, y;
132  uint16 flags;
133  uint16 priority;
134  uint16 windowNum;
135  uint16 zoneNum;
136  VgaSprite() { reset(); }
137 
138  void reset() {
139  id = 0;
140  image = 0;
141  palette = 0;
142  x = y = 0;
143  flags = 0;
144  priority = 0;
145  windowNum = 0;
146  zoneNum = 0;
147  }
148 };
149 
151  uint16 ident;
152  const byte *codePtr;
153  uint16 id;
154  uint16 zoneNum;
155  VgaSleepStruct() { memset(this, 0, sizeof(*this)); }
156 };
157 
159  int16 delay;
160  const byte *codePtr;
161  uint16 id;
162  uint16 zoneNum;
163  uint8 type;
164  VgaTimerEntry() { memset(this, 0, sizeof(*this)); }
165 };
166 
167 struct AnimTable {
168  const byte *srcPtr;
169  int16 x;
170  int16 y;
171  uint16 width;
172  uint16 height;
173  uint16 windowNum;
174  uint16 id;
175  uint16 zoneNum;
176  AnimTable() { memset(this, 0, sizeof(*this)); }
177 };
178 
179 enum EventType {
180  ANIMATE_INT = 1 << 1,
181  ANIMATE_EVENT = 1 << 2,
182  SCROLL_EVENT = 1 << 3,
183  PLAYER_DAMAGE_EVENT = 1 << 4,
184  MONSTER_DAMAGE_EVENT = 1 << 5
185 };
186 
187 struct GameSpecificSettings;
188 
189 class Debugger;
190 
191 // This is to help devices with small memory (PDA, smartphones, ...)
192 // to save a bit of memory used by opcode names in the AGOS engine.
193 
194 #ifndef REDUCE_MEMORY_USAGE
195 # define _OPCODE(ver, x) { &ver::x, #x }
196 #else
197 # define _OPCODE(ver, x) { &ver::x, "" }
198 #endif
199 
200 class AGOSEngine : public Engine {
201 protected:
202  // List of Simon 1 DOS floppy SFX which use rhythm notes.
203  static const byte SIMON1_RHYTHM_SFX[];
204 
205  // Music index base for Simon 2 GM data.
206  static const uint16 MUSIC_INDEX_BASE_SIMON2_GM = 1128 / 4;
207  // Music index base for Simon 2 MT-32 data.
208  static const uint16 MUSIC_INDEX_BASE_SIMON2_MT32 = (1128 + 612) / 4;
209 
210 protected:
211  friend class Debugger;
212 
213  // Engine APIs
214  virtual Common::Error init();
215  virtual Common::Error go();
216  Common::Error run() override {
217  Common::Error err;
218  err = init();
219  if (err.getCode() != Common::kNoError)
220  return err;
221  return go();
222  }
223 
224  bool hasFeature(EngineFeature f) const override;
225  void syncSoundSettings() override;
226  // Applies AGOS engine internal sound settings to ConfigManager, digital
227  // sound channels and MIDI.
228  void syncSoundSettingsIntern();
229  void pauseEngineIntern(bool pause) override;
230 
231  virtual void setupOpcodes();
232  uint16 _numOpcodes, _opcode;
233 
234  typedef void (AGOSEngine::*VgaOpcodeProc) ();
235 
236  void setupVgaOpcodes();
237  VgaOpcodeProc _vga_opcode_table[100];
238  uint8 _numVideoOpcodes;
239 
240  virtual void setupVideoOpcodes(VgaOpcodeProc *op);
241 
242  const AGOSGameDescription * const _gameDescription;
243 
244 public:
245  virtual void setupGame();
246 
247  int getGameId() const;
248  int getGameType() const;
249  uint32 getFeatures() const;
250  const char *getExtra() const;
251  Common::Language getLanguage() const;
252  Common::Platform getPlatform() const;
253  const char *getFileName(int type) const;
254 
255 protected:
256  const byte *_vcPtr; /* video code ptr */
257  uint16 _vcGetOutOfCode;
258 
259 
260  uint32 *_gameOffsetsPtr;
261 
262  uint8 _numMusic, _numSFX;
263  uint16 _numSpeech;
264  uint16 _numZone;
265 
266  uint8 _numBitArray1, _numBitArray2, _numBitArray3, _numItemStore;
267  uint16 _numVars;
268 
269  uint8 _vgaBaseDelay, _vgaPeriod;
270 
271  uint16 _musicIndexBase;
272  uint16 _soundIndexBase;
273  uint16 _tableIndexBase;
274  uint16 _textIndexBase;
275 
276  uint32 _itemMemSize;
277  uint32 _tableMemSize;
278  uint32 _vgaMemSize;
279 
280  const GameSpecificSettings *gss;
281 
282  Common::KeyState _keyPressed;
283 
284  Common::File *_gameFile;
285 
286  byte *_strippedTxtMem;
287  byte *_textMem;
288  uint32 _textSize;
289  uint32 _stringTabNum, _stringTabPos, _stringTabSize;
290  byte **_stringTabPtr;
291 
292  Item **_itemArrayPtr;
293  uint32 _itemArraySize;
294  uint32 _itemArrayInited;
295 
296  Common::Array<byte *> _itemHeap;
297 
298  byte *_iconFilePtr;
299 
300  const byte *_codePtr;
301 
302  byte **_localStringtable;
303  uint16 _stringIdLocalMin, _stringIdLocalMax;
304 
305  RoomState *_roomStates;
306  uint16 _numRoomStates;
307 
308  byte *_menuBase;
309  byte *_roomsList;
310  byte *_roomsListPtr;
311 
312  byte *_xtblList;
313  byte *_xtablesHeapPtrOrg;
314  uint32 _xtablesHeapCurPosOrg;
315  Subroutine *_xsubroutineListOrg;
316 
317  byte *_tblList;
318  byte *_tablesHeapPtr, *_tablesHeapPtrOrg, *_tablesheapPtrNew;
319  uint32 _tablesHeapSize, _tablesHeapCurPos, _tablesHeapCurPosOrg;
320  uint32 _tablesHeapCurPosNew;
321  Subroutine *_subroutineListOrg;
322 
323  Subroutine *_subroutineList;
324 
325  uint8 _recursionDepth;
326 
327  uint32 _lastVgaTick;
328 
329  uint16 _marks;
330  bool _scanFlag;
331 
332  bool _scriptVar2;
333  bool _runScriptReturn1;
334  bool _runScriptCondition[40];
335  int16 _runScriptReturn[40];
336  bool _skipVgaWait;
337  bool _noParentNotify;
338  bool _beardLoaded;
339  bool _litBoxFlag;
340  bool _mortalFlag;
341  uint16 _displayFlag;
342  bool _syncFlag2;
343  bool _inCallBack;
344  bool _cepeFlag;
345  bool _fastMode;
346  bool _backFlag;
347 
348  Common::Language _language;
349  bool _copyProtection;
350  bool _pause;
351  bool _speech;
352  bool _subtitles;
353  bool _vgaVar9;
354  int16 _chanceModifier;
355  bool _restoreWindow6;
356  int16 _scrollX, _scrollXMax;
357  int16 _scrollY, _scrollYMax;
358  int16 _scrollCount, _scrollFlag;
359  uint16 _scrollWidth, _scrollHeight;
360  const byte *_scrollImage;
361  byte _boxStarHeight;
362  bool _forceAscii;
363 
364  SubroutineLine *_classLine;
365  int16 _classMask, _classMode1, _classMode2;
366  Item *_findNextPtr;
367  Subroutine *_currentTable;
368  SubroutineLine *_currentLine;
369 
370  uint8 _agosMenu;
371  byte _textMenu[10];
372  uint16 _currentRoom, _superRoomNumber;
373  uint8 _wallOn;
374 
375  uint16 _hyperLink, _newLines;
376  uint16 _oracleMaxScrollY, _noOracleScroll;
377  uint16 _interactY;
378 
379  int16 _scriptVerb, _scriptNoun1, _scriptNoun2;
380  int16 _scriptAdj1, _scriptAdj2;
381 
382  uint16 _curWindow;
383  WindowBlock *_inputWindow, *_textWindow;
384 
385  Item *_subjectItem, *_objectItem;
386  Item *_currentPlayer;
387 
388  Item *_hitAreaObjectItem;
389  HitArea *_lastHitArea;
390  HitArea *_lastNameOn;
391  HitArea *_lastHitArea3;
392  Item *_hitAreaSubjectItem;
393  HitArea *_currentBox, *_currentVerbBox, *_lastVerbOn;
394  uint16 _currentBoxNum;
395  uint16 _needHitAreaRecalc;
396  uint16 _verbHitArea;
397  uint16 _defaultVerb;
398  bool _iOverflow;
399  bool _nameLocked;
400 
401  bool _dragAccept;
402  bool _dragEnd;
403  bool _dragFlag;
404  bool _dragMode;
405  uint8 _dragCount;
406  HitArea *_lastClickRem;
407 
408  uint16 _windowNum;
409 
410  int16 _printCharCurPos, _printCharMaxPos, _printCharPixelCount;
411  uint16 _numLettersToPrint;
412 
413  uint8 _numTextBoxes;
414 
415  uint32 getTime() const;
416 
417  uint32 _lastMinute; // Used in processSpecialKeys()
418  uint32 _lastTime;
419  uint32 _clockStopped, _gameStoppedClock;
420  uint32 _timeStore;
421 
422  TimeEvent *_firstTimeStruct, *_pendingDeleteTimeEvent;
423 
424  bool _initMouse;
425  Common::Point _mouse;
426  Common::Point _mouseOld;
427 
428  byte *_mouseData;
429  bool _animatePointer;
430  byte _maxCursorWidth, _maxCursorHeight;
431  byte _mouseAnim, _mouseAnimMax, _mouseCursor;
432  byte _currentMouseAnim, _currentMouseCursor;
433  byte _oldMouseAnimMax, _oldMouseCursor;
434  uint16 _mouseHideCount;
435  bool _mouseToggle;
436 
437  bool _leftButtonDown, _rightButtonDown;
438  byte _leftButton, _leftButtonCount, _leftButtonOld;
439  byte _oneClick;
440  bool _clickOnly;
441  bool _leftClick, _rightClick;
442  bool _noRightClick;
443 
444  Item *_dummyItem1;
445  Item *_dummyItem2;
446  Item *_dummyItem3;
447 
448  volatile uint16 _videoLockOut;
449  uint16 _scrollUpHitArea;
450  uint16 _scrollDownHitArea;
451 
452  bool _fastFadeOutFlag;
453  byte _paletteFlag;
454  bool _bottomPalette;
455  uint16 _fastFadeCount;
456  volatile uint16 _fastFadeInFlag;
457  bool _neverFade;
458 
459  uint16 _screenWidth, _screenHeight;
460  uint16 _internalWidth, _internalHeight;
461 
462  uint16 _noOverWrite;
463  bool _rejectBlock;
464 
465  bool _exitCutscene, _picture8600;
466 
467  uint16 _soundFileId;
468  int16 _lastMusicPlayed;
469  int16 _nextMusicToPlay;
470  bool _showPreposition;
471  bool _showMessageFlag;
472 
473  bool _newDirtyClip;
474  bool _wiped;
475  uint16 _copyScnFlag, _vgaSpriteChanged;
476 
477  byte *_block, *_blockEnd;
478  byte *_vgaMemPtr, *_vgaMemEnd, *_vgaMemBase;
479  byte *_vgaFrozenBase, *_vgaRealBase;
480  byte *_zoneBuffers;
481 
482  byte *_curVgaFile1;
483  byte *_curVgaFile2;
484 
485  uint16 _syncCount;
486 
487  uint16 _frameCount;
488 
489  uint16 _zoneNumber;
490  uint16 _vgaWaitFor, _lastVgaWaitFor;
491  uint16 _vgaCurSpriteId, _vgaCurZoneNum;
492 
493  int16 _baseY;
494  float _scale;
495  Common::Rect _feebleRect;
496  int16 _scaleX, _scaleY, _scaleWidth, _scaleHeight;
497 
498  VgaTimerEntry *_nextVgaTimerToProcess;
499 
500  uint8 _opcode177Var1, _opcode177Var2;
501  uint8 _opcode178Var1, _opcode178Var2;
502 
503  Item *_objectArray[50];
504  Item *_itemStore[50];
505 
506  uint16 _shortText[40];
507  uint16 _shortTextX[40];
508  uint16 _shortTextY[40];
509  uint16 _longText[40];
510  uint16 _longSound[40];
511 
512  uint16 _bitArray[128];
513  uint16 _bitArrayTwo[16];
514  uint16 _bitArrayThree[16];
515  int16 *_variableArray;
516  int16 *_variableArray2;
517  int16 *_variableArrayPtr;
518 
519  WindowBlock *_dummyWindow;
520  WindowBlock *_windowArray[80];
521 
522  byte _fcsData1[8];
523  bool _fcsData2[8];
524 
525  TextLocation _textLocation1, _textLocation2, _textLocation3, _textLocation4;
526 
527  byte _awaitTwoByteToken;
528  byte *_byteTokens;
529  byte *_byteTokenStrings;
530  byte *_twoByteTokens;
531  byte *_twoByteTokenStrings;
532  byte *_secondTwoByteTokenStrings;
533  byte *_thirdTwoByteTokenStrings;
534  byte _textBuffer[180];
535  int _textCount;
536 
537  int _freeStringSlot;
538 
539  byte _stringReturnBuffer[2][180];
540 
541  HitArea _hitAreas[250];
542  HitArea *_hitAreaList;
543 
544  AnimTable _screenAnim1[90];
545  VgaPointersEntry _vgaBufferPointers[450];
546  VgaSprite _vgaSprites[200];
547  VgaSleepStruct _onStopTable[60];
548  VgaSleepStruct _waitEndTable[60];
549  VgaSleepStruct _waitSyncTable[60];
550 
551  const uint16 *_pathFindArray[100];
552 
553  uint8 _pathValues[400];
554  uint16 _PVCount;
555  uint16 _GPVCount;
556 
557  uint8 _pathValues1[400];
558  uint16 _PVCount1;
559  uint16 _GPVCount1;
560 
561  uint8 _currentPalette[768];
562  uint8 _displayPalette[768];
563 
564  byte *_planarBuf;
565  byte _videoBuf1[32000];
566  uint16 _videoWindows[128];
567  const byte *_pak98Buf;
568  byte _paletteModNext;
569 
570  uint8 _window3Flag;
571  uint8 _window4Flag;
572  uint8 _window6Flag;
573 
574  uint16 _moveXMin, _moveYMin;
575  uint16 _moveXMax, _moveYMax;
576 
577  VgaTimerEntry _vgaTimerList[205];
578 
579  WindowBlock *_windowList;
580 
581  byte _lettersToPrintBuf[80];
582 
583  MidiPlayer *_midi;
584  bool _midiEnabled;
585 
586  int _vgaTickCounter;
587 
588  Audio::SoundHandle _modHandle;
589 
590  Sound *_sound;
591 
592  bool _effectsMuted;
593  bool _ambientMuted;
594  bool _musicMuted;
595  // The current music volume, or the last used music volume if music is
596  // currently muted.
597  uint16 _musicVolume;
598  // The current SFX and ambient volume, or the last used volume if SFX
599  // and/or ambient sounds are currently muted.
600  uint16 _effectsVolume;
601  bool _useDigitalSfx;
602 
603  uint8 _saveGameNameLen;
604  uint16 _saveLoadRowCurPos;
605  uint16 _numSaveGameRows;
606  bool _saveDialogFlag;
607  bool _saveOrLoad;
608  bool _saveLoadEdit;
609 
610  byte _saveLoadType, _saveLoadSlot;
611  char _saveLoadName[108];
612  char _saveBuf[200];
613 
614  Graphics::Surface *_backGroundBuf;
615  Graphics::Surface *_backBuf;
616  Graphics::Surface *_scaleBuf;
617  Graphics::Surface *_window4BackScn;
618  Graphics::Surface *_window6BackScn;
619 
621 
622  const byte *_vc10BasePtrOld;
623  byte _hebrewCharWidths[32];
624 
625 public:
626  AGOSEngine(OSystem *system, const AGOSGameDescription *gd);
627  ~AGOSEngine() override;
628 
629  byte *_curSfxFile;
630  uint32 _curSfxFileSize;
631  uint16 _sampleEnd, _sampleWait;
632 
633 protected:
634  virtual uint16 to16Wrapper(uint value);
635  virtual uint16 readUint16Wrapper(const void *src);
636  virtual uint32 readUint32Wrapper(const void *src);
637 
638 #ifdef ENABLE_AGOS2
639  void loadArchives();
640 #endif
641 
642  int allocGamePcVars(Common::SeekableReadStream *in);
643  void createPlayer();
644  void allocateStringTable(int num);
645  void setupStringTable(byte *mem, int num);
646  void setupLocalStringTable(byte *mem, int num);
647  void readGamePcText(Common::SeekableReadStream *in);
648  virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
649  void readItemFromGamePc(Common::SeekableReadStream *in, Item *item);
650  virtual void loadGamePcFile();
651  void readGamePcFile(Common::SeekableReadStream *in);
652  void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
653  void decompressPN(Common::Stack<uint32> &dataList, uint8 *&dataOut, int &dataOutSize);
654  void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
655  void loadSound(uint16 sound, int16 pan, int16 vol, uint16 type);
656  void playSfx(uint16 sound, uint16 freq, uint16 flags, bool digitalOnly = false, bool midiOnly = false);
657  void loadSound(uint16 sound, uint16 freq, uint16 flags);
658  void loadMidiSfx();
659  virtual void playMidiSfx(uint16 sound);
660  void loadVoice(uint speechId);
661  void stopAllSfx();
662 
663  void loadSoundFile(const char *filename);
664 
665  int getUserFlag(Item *item, int a);
666  int getUserFlag1(Item *item, int a);
667  int getUserItem(Item *item, int n);
668  void setUserFlag(Item *item, int a, int b);
669  void setUserItem(Item *item, int n, int m);
670 
671  void paletteFadeOut(byte *palPtr, uint num, uint size);
672 
673  void *allocateItem(uint size);
674  void *allocateTable(uint size);
675  void alignTableMem();
676 
677  Child *findChildOfType(Item *i, uint child);
678  Child *allocateChildBlock(Item *i, uint type, uint size);
679 
680  void allocItemHeap();
681  void allocTablesHeap();
682 
683  Subroutine *createSubroutine(uint16 a);
684  void readSubroutine(Common::SeekableReadStream *in, Subroutine *sub);
685  SubroutineLine *createSubroutineLine(Subroutine *sub, int a);
686  void readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *newTable, Subroutine *sub);
687  byte *readSingleOpcode(Common::SeekableReadStream *in, byte *ptr);
688  void readSubroutineBlock(Common::SeekableReadStream *in);
689 
690  Subroutine *getSubroutineByID(uint subroutineId);
691 
692  /* used in debugger */
693  void dumpAllSubroutines();
694  void dumpAllVgaImageFiles();
695  void dumpAllVgaScriptFiles();
696  void dumpSubroutines();
697  void dumpSubroutine(Subroutine *sub);
698  void dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub);
699  const byte *dumpOpcode(const byte *p);
700 
701  int startSubroutine(Subroutine *sub);
702  int startSubroutineEx(Subroutine *sub);
703 
704  bool checkIfToRunSubroutineLine(SubroutineLine *sl, Subroutine *sub);
705 
706  int runScript();
707  virtual void executeOpcode(int opcode) = 0;
708 
709  byte getByte();
710  int getNextWord();
711 
712  uint getNextVarContents();
713  uint getVarWrapper();
714  uint getVarOrWord();
715  uint getVarOrByte();
716  uint readVariable(uint16 variable);
717  void writeNextVarContents(uint16 contents);
718  void writeVariable(uint16 variable, uint16 contents);
719 
720  Item *derefItem(uint item);
721  Item *getNextItemPtr();
722  uint getNextItemID();
723  uint getItem1ID() {return 1;}
724  uint itemPtrToID(Item *id);
725  Item *me();
726  Item *actor();
727 
728  void uncompressText(byte *ptr);
729  byte *uncompressToken(byte a, byte *ptr);
730 
731  void showMessageFormat(MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
732  const byte *getStringPtrByID(uint16 stringId, bool upperCase = false);
733  const byte *getLocalStringByID(uint16 stringId);
734  uint getNextStringID();
735 
736  void addTimeEvent(int32 timeout, uint16 subroutineId);
737  void delTimeEvent(TimeEvent *te);
738 
739  Item *findInByClass(Item *i, int16 m);
740  Item *nextInByClass(Item *i, int16 m);
741  Item *findMaster(int16 a, int16 n);
742  Item *nextMaster(Item *item, int16 a, int16 n);
743  int wordMatch(Item *item, int16 a, int16 n);
744 
745  bool isRoom(Item *item);
746  bool isObject(Item *item);
747  bool isPlayer(Item *item);
748 
749  void itemChildrenChanged(Item *item);
750  void unlinkItem(Item *item);
751  void linkItem(Item *item, Item *parent);
752 
753  void setItemParent(Item *item, Item *parent);
754  void setItemState(Item *item, int value);
755 
756  void stopAnimate(uint16 a);
757  void stopAnimateSimon2(uint16 a, uint16 b);
758 
759  void enableBox(uint hitarea);
760  void disableBox(uint hitarea);
761  void moveBox(uint hitarea, int x, int y);
762  bool isBoxDead(uint hitarea);
763  void undefineBox(uint hitarea);
764  void defineBox(int id, int x, int y, int width, int height, int flags, int verb, Item *itemPtr);
765  void defineBox(uint16 id, uint16 x, uint16 y, uint16 width, uint16 height, uint16 msg1, uint16 msg2, uint16 flags);
766 
767  HitArea *findEmptyHitArea();
768 
769  virtual void resetVerbs();
770  virtual void setVerb(HitArea * ha);
771  virtual void hitarea_leave(HitArea * ha, bool state = false);
772  void leaveHitAreaById(uint hitarea_id);
773 
774  void sendSync(uint a);
775  void waitForSync(uint a);
776 
777  uint getOffsetOfChild2Param(SubObject *child, uint prop);
778  void scriptMouseOff();
779  void freezeBottom();
780  void unfreezeBottom();
781 
782  TextLocation *getTextLocation(uint a);
783 
784  uint setVerbText(HitArea *ha);
785  void waitForInput();
786  void setup_cond_c_helper();
787 
788  uint16 getBackExit(int n);
789  uint16 getDoorState(Item *item, uint16 d);
790  uint16 getExitOf(Item *item, uint16 d);
791  void changeDoorState(SubRoom *r, uint16 d, uint16 n);
792  void setDoorState(Item *i, uint16 d, uint16 n);
793 
794  // Elvira 1 specific
795  Item *getDoorOf(Item *item, uint16 d);
796  Item *getExitOf_e1(Item *item, uint16 d);
797  virtual void moveDirn(Item *i, uint x);
798 
799  virtual int canPlace(Item *x, Item *y);
800  int contains(Item *a, Item *b);
801  int sizeContents(Item *x);
802  virtual int sizeOfRec(Item *o, int d);
803  int sizeRec(Item *x, int d);
804  int weighUp(Item *x);
805  int weightRec(Item *x, int d);
806  virtual int weightOf(Item *x);
807  void xPlace(Item *x, Item *y);
808 
809  void restoreMenu();
810  void drawMenuStrip(uint windowNum, uint menuNum);
811  void lightMenuStrip(int a);
812  void unlightMenuStrip();
813  void lightMenuBox(uint hitarea);
814 
815  uint menuFor_e2(Item *item);
816  uint menuFor_ww(Item *item, uint id);
817  void clearMenuStrip();
818  void doMenuStrip(uint menuNum);
819 
820  void mouseOff();
821  void mouseOn();
822 
823  bool loadRoomItems(uint16 item);
824 
825  virtual bool loadTablesIntoMem(uint16 subrId);
826  bool loadXTablesIntoMem(uint16 subrId);
827  void loadTextIntoMem(uint16 stringId);
828 
829  uint loadTextFile(const char *filename, byte *dst);
830  Common::SeekableReadStream *openTablesFile(const char *filename);
831  void closeTablesFile(Common::SeekableReadStream *in);
832 
833  uint loadTextFile_simon1(const char *filename, byte *dst);
834  Common::SeekableReadStream *openTablesFile_simon1(const char *filename);
835  Common::SeekableReadStream *openTablesFile_pak98(const char *filename);
836  Common::SeekableReadStream *createPak98FileStream(const char *filename);
837  void convertPC98Image(VC10_state &state);
838 
839  uint loadTextFile_gme(const char *filename, byte *dst);
840  Common::SeekableReadStream *openTablesFile_gme(const char *filename);
841 
842  void invokeTimeEvent(TimeEvent *te);
843  bool kickoffTimeEvents();
844  void killAllTimers();
845 
846  void endCutscene();
847  virtual void runSubroutine101();
848 
849  virtual void inventoryUp(WindowBlock *window);
850  virtual void inventoryDown(WindowBlock *window);
851 
852  WindowBlock *openWindow(uint x, uint y, uint w, uint h, uint flags, uint fillColor, uint textColor);
853  uint getWindowNum(WindowBlock *window);
854  void clearWindow(WindowBlock *window);
855  void changeWindow(uint a);
856  void closeWindow(uint a);
857  void setTextColor(uint color);
858  virtual void windowPutChar(WindowBlock *window, byte c, byte b = 0);
859  void waitWindow(WindowBlock *window);
860 
861  HitArea *findBox(uint hitarea_id);
862  virtual void boxController(uint x, uint y, uint mode);
863  void handleVerbClicked(uint verb);
864  virtual void clearName();
865  void displayName(HitArea * ha);
866  void resetNameWindow();
867  void displayBoxStars();
868  void invertBox(HitArea * ha, byte a, byte b, byte c, byte d);
869 
870  virtual void handleMouseWheelUp();
871  virtual void handleMouseWheelDown();
872 
873  virtual void initMouse();
874  virtual void handleMouseMoved();
875  virtual void drawMousePointer();
876 
877  void drawArrow(uint16 x, uint16 y, int8 dir);
878  virtual void addArrows(WindowBlock *window, uint8 num);
879  virtual void removeArrows(WindowBlock *window, uint num);
880 
881  virtual void drawIcon(WindowBlock *window, uint icon, uint x, uint y);
882  virtual bool hasIcon(Item *item);
883  virtual uint itemGetIconNumber(Item *item);
884  virtual uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr);
885 
886  virtual void drawIconArray(uint i, Item *itemPtr, int line, int classMask);
887  void removeIconArray(uint num);
888 
889  void loadIconData();
890  void loadIconFile();
891  void loadMenuFile();
892 
893  virtual bool processSpecialKeys();
894  void hitarea_stuff_helper();
895 
896  void permitInput();
897 
898  uint getFeebleFontSize(byte chr);
899  void justifyStart();
900  void justifyOutPut(byte chr);
901 
902  void loadZone(uint16 zoneNum, bool useError = true);
903 
904  void animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, int16 x, int16 y, uint16 palette, bool vgaScript = false);
905  void setImage(uint16 vgaSpriteId, bool vgaScript = false);
906  void setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCase = false);
907  virtual void setWindowImageEx(uint16 mode, uint16 vgaSpriteId);
908  void drawEdging();
909 
910  void skipSpeech();
911 
912  const char *getPixelLength(const char *string, uint16 maxWidth, uint16 &pixels);
913  bool printNameOf(Item *item, uint x, uint y);
914  bool printTextOf(uint a, uint x, uint y);
915  void printVerbOf(uint hitarea_id);
916  void showActionString(const byte *string);
917 
918  virtual void printScreenText(uint vgaSpriteId, uint color, const char *stringPtr, int16 x, int16 y, int16 width);
919 
920  void renderStringAmiga(uint vgaSpriteId, uint color, uint width, uint height, const char *txt);
921  void renderString(uint vgaSpriteId, uint color, uint width, uint height, const char *txt);
922 
923  void writeChar(WindowBlock *window, int x, int y, int offs, int val);
924 
925  byte *allocBlock(uint32 size);
926  void checkNoOverWrite();
927  void checkRunningAnims();
928  void checkAnims(uint a);
929  void checkZonePtrs();
930  void setZoneBuffers();
931 
932  void runVgaScript();
933 
934 public:
935  bool getBitFlag(uint bit);
936  void setBitFlag(uint bit, bool value);
937 
938  // Video Script Opcodes, Common
939  void vc1_fadeOut();
940  void vc2_call();
941  virtual void vc3_loadSprite();
942  void vc4_fadeIn();
943  void vc5_ifEqual();
944  void vc6_ifObjectHere();
945  void vc7_ifObjectNotHere();
946  void vc8_ifObjectIsAt();
947  void vc9_ifObjectStateIs();
948  void vc10_draw();
949  void vc12_delay();
950  void vc13_addToSpriteX();
951  void vc14_addToSpriteY();
952  void vc15_sync();
953  void vc16_waitSync();
954  void vc18_jump();
955  void vc19_loop();
956  void vc20_setRepeat();
957  void vc21_endRepeat();
958  virtual void vc22_setPalette();
959  void vc23_setPriority();
960  void vc24_setSpriteXY();
961  void vc25_halt_sprite();
962  void vc26_setSubWindow();
963  void vc27_resetSprite();
964  void vc28_playSFX();
965  void vc29_stopAllSounds();
966  void vc30_setFrameRate();
967  void vc31_setWindow();
968  void vc33_setMouseOn();
969  void vc34_setMouseOff();
970  void vc35_clearWindow();
971  virtual void vc36_setWindowImage();
972  void vc38_ifVarNotZero();
973  void vc39_setVar();
974  void vc40_scrollRight();
975  void vc41_scrollLeft();
976  void vc42_delayIfNotEQ();
977 
978  // Video Script Opcodes, Personal Nightmare
979  void vc11_onStop();
980  void vc36_pause();
981  void vc39_volume();
982  void vc44_enableBox();
983  void vc45_disableBox();
984  void vc46_maxBox();
985  void vc48_specialEffect();
986  void vc50_setBox();
987  void vc55_scanFlag();
988 
989  // Video Script Opcodes, Elvira 1
990  void vc17_waitEnd();
991  void vc32_saveScreen();
992  void vc37_pokePalette();
993 
994  // Video Script Opcodes, Elvira 2
995  void vc43_ifBitSet();
996  void vc44_ifBitClear();
997  void vc45_setWindowPalette();
998  void vc46_setPaletteSlot1();
999  void vc47_setPaletteSlot2();
1000  void vc48_setPaletteSlot3();
1001  void vc49_setBit();
1002  void vc50_clearBit();
1003  void vc51_enableBox();
1004  void vc52_playSound();
1005  void vc53_dissolveIn();
1006  void vc54_dissolveOut();
1007  void vc55_moveBox();
1008  void vc56_fullScreen();
1009  void vc57_blackPalette();
1010  void vc58_checkCodeWheel();
1011  void vc58_changePriority();
1012  void vc59_ifEGA();
1013 
1014  // Video Script Opcodes, Waxworks
1015  void vc60_stopAnimation();
1016  void vc61();
1017  void vc62_fastFadeOut();
1018  virtual void vc63_fastFadeIn();
1019 
1020  // Video Script Opcodes, Simon 1
1021  void vc11_clearPathFinder();
1022  void vc17_setPathfinderItem();
1023  void vc32_copyVar();
1024  void vc37_addToSpriteY();
1025  void vc45_setSpriteX();
1026  void vc46_setSpriteY();
1027  void vc47_addToVar();
1028  virtual void vc48_setPathFinder();
1029  void vc59_ifSpeech();
1030  void vc61_setMaskImage();
1031 
1032  // Video Script Opcodes, Simon 2
1033  void vc56_delayLong();
1034  void vc59_stopAnimations();
1035  void vc64_ifSpeech();
1036  void vc65_slowFadeIn();
1037  void vc66_ifEqual();
1038  void vc67_ifLE();
1039  void vc68_ifGE();
1040  void vc69_playSeq();
1041  void vc70_joinSeq();
1042  void vc71_ifSeqWaiting();
1043  void vc72_segue();
1044  void vc73_setMark();
1045  void vc74_clearMark();
1046 
1047  // Video Script Opcodes, Feeble Files
1048  void vc75_setScale();
1049  void vc76_setScaleXOffs();
1050  void vc77_setScaleYOffs();
1051  void vc78_computeXY();
1052  void vc79_computePosNum();
1053  void vc80_setOverlayImage();
1054  void vc81_setRandom();
1055  void vc82_getPathValue();
1056  void vc83_playSoundLoop();
1057  void vc84_stopSoundLoop();
1058 
1059  void setScriptCondition(bool cond);
1060  bool getScriptCondition();
1061  void setScriptReturn(int ret);
1062  int getScriptReturn();
1063 
1064  // Opcodes, common
1065  void o_invalid();
1066  void o_at();
1067  void o_notAt();
1068  void o_carried();
1069  void o_notCarried();
1070  void o_isAt();
1071  void o_zero();
1072  void o_notZero();
1073  void o_eq();
1074  void o_notEq();
1075  void o_gt();
1076  void o_lt();
1077  void o_eqf();
1078  void o_notEqf();
1079  void o_ltf();
1080  void o_gtf();
1081  void o_chance();
1082  void o_isRoom();
1083  void o_isObject();
1084  void o_state();
1085  void o_oflag();
1086  void o_destroy();
1087  void o_place();
1088  void o_copyff();
1089  void o_clear();
1090  void o_let();
1091  void o_add();
1092  void o_sub();
1093  void o_addf();
1094  void o_subf();
1095  void o_mul();
1096  void o_div();
1097  void o_mulf();
1098  void o_divf();
1099  void o_mod();
1100  void o_modf();
1101  void o_random();
1102  void o_goto();
1103  void o_oset();
1104  void o_oclear();
1105  void o_putBy();
1106  void o_inc();
1107  void o_dec();
1108  void o_setState();
1109  void o_print();
1110  void o_message();
1111  void o_msg();
1112  void o_end();
1113  void o_done();
1114  void o_process();
1115  void o_when();
1116  void o_if1();
1117  void o_if2();
1118  void o_isCalled();
1119  void o_is();
1120  void o_debug();
1121  void o_comment();
1122  void o_haltAnimation();
1123  void o_restartAnimation();
1124  void o_getParent();
1125  void o_getNext();
1126  void o_getChildren();
1127  void o_picture();
1128  void o_loadZone();
1129  void o_killAnimate();
1130  void o_defWindow();
1131  void o_window();
1132  void o_cls();
1133  void o_closeWindow();
1134  void o_addBox();
1135  void o_delBox();
1136  void o_enableBox();
1137  void o_disableBox();
1138  void o_moveBox();
1139  void o_doIcons();
1140  void o_isClass();
1141  void o_setClass();
1142  void o_unsetClass();
1143  void o_waitSync();
1144  void o_sync();
1145  void o_defObj();
1146  void o_here();
1147  void o_doClassIcons();
1148  void o_playTune();
1149  void o_setAdjNoun();
1150  void o_saveUserGame();
1151  void o_loadUserGame();
1152  void o_copysf();
1153  void o_restoreIcons();
1154  void o_freezeZones();
1155  void o_placeNoIcons();
1156  void o_clearTimers();
1157  void o_setDollar();
1158  void o_isBox();
1159 
1160  int16 moreText(Item *i);
1161  void lobjFunc(Item *i, const char *f);
1162  uint confirmYesOrNo(uint16 x, uint16 y);
1163  uint continueOrQuit();
1164  void printScroll();
1165  virtual void printStats();
1166  void synchChain(Item *i);
1167 
1168 protected:
1169  bool drawImage_clip(VC10_state *state);
1170 
1171  void drawImage_init(int16 image, uint16 palette, int16 x, int16 y, uint16 flags);
1172 
1173  virtual void drawImage(VC10_state *state);
1174  void drawBackGroundImage(VC10_state *state);
1175  void drawVertImage(VC10_state *state);
1176  void drawVertImageCompressed(VC10_state *state);
1177  void drawVertImageUncompressed(VC10_state *state);
1178 
1179  void setMoveRect(uint16 x, uint16 y, uint16 width, uint16 height);
1180 
1181  void horizontalScroll(VC10_state *state);
1182  void verticalScroll(VC10_state *state);
1183 
1184  Graphics::Surface *getBackendSurface() const;
1185  void updateBackendSurface(Common::Rect *area = 0) const;
1186  virtual void clearHiResTextLayer() {}
1187 
1188  int vcReadVarOrWord();
1189  uint vcReadNextWord(bool forceLERead = false);
1190  uint vcReadNextByte();
1191  uint vcReadVar(uint var);
1192  void vcWriteVar(uint var, int16 value);
1193  void vcSkipNextInstruction();
1194 
1195  int getScale(int16 y, int16 x);
1196  void checkScrollX(int16 x, int16 xpos);
1197  void checkScrollY(int16 y, int16 ypos);
1198  void centerScroll();
1199 
1200  virtual void clearVideoWindow(uint16 windowNum, uint16 color);
1201  void clearVideoBackGround(uint16 windowNum, uint16 color);
1202 
1203  void setPaletteSlot(uint16 srcOffs, uint8 dstOffs);
1204  void checkOnStopTable();
1205  void checkWaitEndTable();
1206 
1207  virtual bool ifObjectHere(uint16 val);
1208  virtual bool ifObjectAt(uint16 a, uint16 b);
1209  virtual bool ifObjectState(uint16 a, int16 b);
1210 
1211  bool isVgaQueueEmpty();
1212  void haltAnimation();
1213  void restartAnimation();
1214  void addVgaEvent(uint16 num, uint8 type, const byte *codePtr, uint16 curSprite, uint16 curZoneNum);
1215  void deleteVgaEvent(VgaTimerEntry * vte);
1216  void processVgaEvents();
1217  void animateEvent(const byte *codePtr, uint16 curZoneNum, uint16 curSprite);
1218  void scrollEvent();
1219  void drawStuff(const byte *src, uint offs);
1220  void playerDamageEvent(VgaTimerEntry * vte, uint dx);
1221  void monsterDamageEvent(VgaTimerEntry * vte, uint dx);
1222 
1223  VgaSprite *findCurSprite();
1224 
1225  bool isSpriteLoaded(uint16 id, uint16 zoneNum);
1226 
1227  void resetWindow(WindowBlock *window);
1228  void freeBox(uint index);
1229 
1230  void sendWindow(uint a);
1231 
1232  virtual void colorWindow(WindowBlock *window);
1233  void colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, uint16 h);
1234 
1235  void restoreWindow(WindowBlock *window);
1236  void restoreBlock(uint16 left, uint16 top, uint16 right, uint16 bottom);
1237 
1238  byte *getBackBuf();
1239  byte *getBackGround();
1240  byte *getScaleBuf();
1241 
1242  byte *convertAmigaImage(VC10_state *state, bool compressed);
1243 
1244  bool decrunchFile(byte *src, byte *dst, uint32 size);
1245  void loadVGABeardFile(uint16 id);
1246  void loadVGAVideoFile(uint16 id, uint8 type, bool useError = true);
1247  bool loadVGASoundFile(uint16 id, uint8 type);
1248 
1249  void openGameFile();
1250  void readGameFile(void *dst, uint32 offs, uint32 size);
1251 
1252  virtual void timerProc();
1253 
1254  virtual void animateSprites();
1255 
1256  void dirtyClips();
1257  void dirtyClipCheck(int16 x, int16 y, int16 w, int16 h);
1258  void dirtyBackGround();
1259  void restoreBackGround();
1260  void saveBackGround(VgaSprite *vsp);
1261 
1262  void clearSurfaces();
1263  void displayScreen();
1264 
1265  void dumpVideoScript(const byte *src, bool singeOpcode);
1266  virtual void dumpVgaFile(const byte *vga);
1267  void dumpVgaScript(const byte *ptr, uint16 res, uint16 id);
1268  void dumpVgaScriptAlways(const byte *ptr, uint16 res, uint16 id);
1269 
1270  void dumpVgaBitmaps(uint16 zoneNum);
1271 
1272  void dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base);
1273  void dumpBitmap(const char *filename, const byte *offs, uint16 w, uint16 h, int flags, const byte *palette, byte base);
1274  void palLoad(byte *pal, const byte *vga1, int a, int b);
1275 
1276  void fillBackFromBackGround(uint16 height, uint16 width);
1277  void fillBackFromFront();
1278  void fillBackGroundFromBack();
1279  void fillBackGroundFromFront();
1280 
1281  virtual void doOutput(const byte *src, uint len);
1282  void clsCheck(WindowBlock *window);
1283 
1284  virtual void quickLoadOrSave();
1285 
1286  byte *vc10_uncompressFlip(const byte *src, uint16 w, uint16 h);
1287  byte *vc10_flip(const byte *src, uint16 w, uint16 h);
1288 
1289  Item *getNextItemPtrStrange();
1290 
1291  virtual bool loadGame(const Common::String &filename, bool restartMode = false);
1292  virtual bool saveGame(uint slot, const char *caption);
1293 
1294  void openTextWindow();
1295  void tidyIconArray(uint i);
1296 
1297  virtual void windowNewLine(WindowBlock *window);
1298  void windowScroll(WindowBlock *window);
1299  virtual void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr);
1300 
1301  // Loads the MIDI data for the specified track. The forceSimon2GmData
1302  // parameter forces loading the MIDI data from the GM data set.
1303  // The useSimon2Remapping parameter activates GM to MT-32 instrument
1304  // remapping. These parameters are useful only for a specific
1305  // workaround (see AGOSEngine_Simon2::playMusic for more details).
1306  void loadMusic(uint16 track, bool forceSimon2GmData = false, bool useSimon2Remapping = false);
1307  void playModule(uint16 music);
1308  virtual void playMusic(uint16 music, uint16 track);
1309  void stopMusic();
1310 
1311  void delay(uint delay);
1312  void pause();
1313 
1314  void waitForMark(uint i);
1315  void scrollScreen();
1316 
1317  void decodeColumn(byte *dst, const byte *src, uint16 height, uint16 pitch);
1318  void decodeRow(byte *dst, const byte *src, uint16 width, uint16 pitch);
1319  void hitarea_stuff_helper_2();
1320  void fastFadeIn();
1321  void slowFadeIn();
1322  void fullFade();
1323 
1324  virtual void vcStopAnimation(uint16 zone, uint16 sprite);
1325 
1326  virtual bool confirmOverWrite(WindowBlock *window);
1327  int16 matchSaveGame(const char *name, uint16 max);
1328  void disableFileBoxes();
1329  virtual void userGame(bool load);
1330  void userGameBackSpace(WindowBlock *window, int x, byte b = 0);
1331  void fileError(WindowBlock *window, bool saveError);
1332 
1333  int countSaveGames();
1334 
1335  virtual Common::String genSaveName(int slot) const;
1336 };
1337 
1338 class AGOSEngine_PN : public AGOSEngine {
1339 
1340  Common::Error go() override;
1341  void demoSeq();
1342  void introSeq();
1343  void setupBoxes();
1344  int readfromline();
1345 public:
1346  AGOSEngine_PN(OSystem *system, const AGOSGameDescription *gd);
1347  ~AGOSEngine_PN() override;
1348 
1349  void setupGame() override;
1350  void setupOpcodes() override;
1351  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1352 
1353  void executeOpcode(int opcode) override;
1354 
1355  int actCallD(int n);
1356 
1357  void opn_opcode00();
1358  void opn_add();
1359  void opn_sub();
1360  void opn_mul();
1361  void opn_div();
1362  void opn_opcode05();
1363  void opn_opcode06();
1364  void opn_opcode07();
1365  void opn_opcode08();
1366  void opn_opcode09();
1367  void opn_opcode10();
1368  void opn_opcode11();
1369  void opn_opcode12();
1370  void opn_opcode13();
1371  void opn_opcode14();
1372  void opn_opcode15();
1373  void opn_opcode16();
1374  void opn_lt();
1375  void opn_gt();
1376  void opn_eq();
1377  void opn_neq();
1378  void opn_opcode21();
1379  void opn_opcode22();
1380  void opn_opcode23();
1381  void opn_opcode24();
1382  void opn_opcode25();
1383  void opn_opcode26();
1384  void opn_opcode27();
1385  void opn_opcode28();
1386  void opn_opcode29();
1387  void opn_opcode30();
1388  void opn_opcode31();
1389  void opn_opcode32();
1390  void opn_opcode33();
1391  void opn_opcode34();
1392  void opn_opcode35();
1393  void opn_opcode36();
1394  void opn_opcode37();
1395  void opn_opcode38();
1396  void opn_opcode39();
1397  void opn_opcode40();
1398  void opn_opcode41();
1399  void opn_opcode42();
1400  void opn_opcode43();
1401  void opn_opcode44();
1402  void opn_opcode45();
1403  void opn_opcode46();
1404  void opn_opcode47();
1405  void opn_opcode48();
1406  void opn_opcode49();
1407  void opn_opcode50();
1408  void opn_opcode51();
1409  void opn_opcode52();
1410  void opn_opcode53();
1411  void opn_opcode54();
1412  void opn_opcode55();
1413  void opn_opcode56();
1414  void opn_opcode57();
1415  void opn_opcode62();
1416  void opn_opcode63();
1417 
1418 protected:
1419  struct StackFrame {
1420  StackFrame *nextframe;
1421  int16 flag[6];
1422  int16 param[8];
1423  int16 classnum;
1424  uint8 *linpos;
1425  uint8 *lbase;
1426  int16 ll;
1427  int16 linenum;
1428  int16 process;
1430  StackFrame() { memset(this, 0, sizeof(*this)); }
1431  };
1432 
1433 
1434  StackFrame *_stackbase;
1435 
1437  int _dolineReturnVal;
1438 
1439  byte *_dataBase, *_textBase;
1440  uint32 _dataBaseSize, _textBaseSize;
1441 
1442  HitArea _invHitAreas[45];
1443 
1444  char _buffer[80];
1445  char _inputline[61];
1446  char _saveFile[20];
1447  char _sb[80];
1448  uint8 _wordcp[7];
1449 
1450  const char *_mouseString, *_mouseString1;
1451  char _objectName1[15], _objectName2[15];
1452  char _inMessage[20];
1453  char _placeMessage[15];
1454  bool _inputReady;
1455  bool _inputting;
1456  uint16 _intputCounter, _inputMax;
1457  uint16 _mousePrintFG;
1458  HitArea *_dragStore;
1459  uint8 _hitCalled;
1460 
1461  uint32 _quickptr[16];
1462  uint16 _quickshort[12];
1463 
1464  bool _noScanFlag;
1465  char _keyboardBuffer[61];
1466 
1467  uint16 _objects;
1468  int16 _objectCountS;
1469 
1470  int16 _bp;
1471  int16 _xofs;
1472  int16 _havinit;
1473  uint16 _seed;
1474 
1475  char *_curwrdptr;
1476  char *_inpp;
1477  int _fnst;
1478  int _procnum;
1479  int _linct;
1480  int _linembr;
1481  uint8 *_linebase;
1482  uint8 *_workptr;
1483 
1484  uint16 getptr(uint32 pos);
1485  uint32 getlong(uint32 pos);
1486 
1487  void loadGamePcFile() override;
1488 
1489  int bitextract(uint32 ptr, int offs);
1490  int doaction();
1491  int doline(int needsave);
1492  int setposition(int process, int line);
1493  int varval();
1494 
1495  char *getMessage(char *msg, uint16 num);
1496  void getResponse(uint16 charNum, uint16 objNum, uint16 &msgNum1, uint16 &msgNum2);
1497  void getObjectName(char *v, uint16 x);
1498 
1499  void processor();
1500  void setbitf(uint32 ptr, int offs, int val);
1501  void setqptrs();
1502  void writeval(uint8 *ptr, int val);
1503 
1504  void addstack(int type);
1505  void dumpstack();
1506  void popstack(int type);
1507  void funccpy(int *store);
1508  void funcentry(int *storestore, int procn);
1509 
1510  int findentry();
1511  int findset();
1512  int gvwrd(uint8 *wptr, int mask);
1513  int wrdmatch(uint8 *word1, int mask1, uint8 *word2, int mask2);
1514 
1515  bool testContainer(uint16 a);
1516  bool testObvious(uint16 a);
1517  bool testSeen(uint16 a);
1518 
1519  bool ifObjectInInv(uint16 a);
1520  int inventoryOn(int val);
1521  int inventoryOff();
1522  void mouseHit();
1523  void execMouseHit(HitArea *ha);
1524  void hitBox1(HitArea *ha);
1525  void hitBox2(HitArea *ha);
1526  void hitBox3(HitArea *ha);
1527  void hitBox4(HitArea *ha);
1528  void hitBox5(HitArea *ha);
1529  void hitBox6(HitArea *ha);
1530  void hitBox7(HitArea *ha);
1531  void hitBox8(HitArea *ha);
1532  void hitBox9(HitArea *ha);
1533  void hitBox11(HitArea *ha);
1534 
1535  void drawIconHitBar();
1536  void iconPage();
1537  void printIcon(HitArea *ha, uint8 i, uint8 r);
1538  void windowPutChar(WindowBlock *window, byte c, byte b = 0) override;
1539 
1540  bool badload(int8 errorNum);
1541  int loadFile(const Common::String &name);
1542  int saveFile(const Common::String &name);
1543  void getFilename();
1544  void sysftodb();
1545  void dbtosysf();
1546 
1547  uint32 ftext(uint32 base, int n);
1548  char *unctok(char *c, int n);
1549  void uncomstr(char *c, uint32 x);
1550  void patok(int n);
1551  void pcf(uint8 ch);
1552  void pcl(const char *s);
1553  void pmesd(int n);
1554  void plocd(int n, int m);
1555  void pobjd(int n, int m);
1556  void ptext(uint32 tptr);
1557 
1558  void clearVideoWindow(uint16 windowNum, uint16 color) override;
1559  void setWindowImageEx(uint16 mode, uint16 vga_res) override;
1560 
1561  bool ifObjectHere(uint16 val) override;
1562  bool ifObjectAt(uint16 a, uint16 b) override;
1563  bool ifObjectState(uint16 a, int16 b) override;
1564 
1565  void boxController(uint x, uint y, uint mode) override;
1566  void timerProc() override;
1567 
1568  void addChar(uint8 chr);
1569  void clearCursor(WindowBlock *window);
1570  void clearInputLine();
1571  void handleKeyboard();
1572  void handleMouseMoved() override;
1573  void interact(char *buffer, uint8 size);
1574 
1575  bool processSpecialKeys() override;
1576 protected:
1577  typedef void (AGOSEngine_PN::*OpcodeProcPN) ();
1578  struct OpcodeEntryPN {
1579  OpcodeProcPN proc;
1580  const char *desc;
1581  };
1582 
1583  const OpcodeEntryPN *_opcodesPN;
1584 };
1585 
1587 public:
1588  AGOSEngine_Elvira1(OSystem *system, const AGOSGameDescription *gd);
1589  ~AGOSEngine_Elvira1() override;
1590  Common::Error init() override;
1591 
1592  void setupGame() override;
1593  void setupOpcodes() override;
1594  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1595 
1596  void executeOpcode(int opcode) override;
1597 
1598  void oe1_present();
1599  void oe1_notPresent();
1600  void oe1_worn();
1601  void oe1_notWorn();
1602  void oe1_notCarried();
1603  void oe1_isNotAt();
1604  void oe1_sibling();
1605  void oe1_notSibling();
1606  void oe1_isIn();
1607  void oe1_isNotIn();
1608  void oe1_isPlayer();
1609  void oe1_canPut();
1610  void oe1_create();
1611  void oe1_copyof();
1612  void oe1_copyfo();
1613  void oe1_whatO();
1614  void oe1_weigh();
1615  void oe1_setFF();
1616  void oe1_moveDirn();
1617  void oe1_score();
1618  void oe1_look();
1619  void oe1_doClass();
1620  void oe1_pObj();
1621  void oe1_pName();
1622  void oe1_pcName();
1623  void oe1_isCalled();
1624  void oe1_cFlag();
1625  void oe1_rescan();
1626  void oe1_setUserItem();
1627  void oe1_getUserItem();
1628  void oe1_whereTo();
1629  void oe1_doorExit();
1630  void oe1_loadGame();
1631  void oe1_clearUserItem();
1632  void oe1_findMaster();
1633  void oe1_nextMaster();
1634  void oe1_animate();
1635  void oe1_stopAnimate();
1636  void oe1_menu();
1637  void oe1_addBox();
1638  void oe1_enableInput();
1639  void oe1_setTime();
1640  void oe1_ifTime();
1641  void oe1_playTune();
1642  void oe1_bitClear();
1643  void oe1_bitSet();
1644  void oe1_bitTest();
1645  void oe1_zoneDisk();
1646  void oe1_printStats();
1647  void oe1_stopTune();
1648  void oe1_printPlayerDamage();
1649  void oe1_printMonsterDamage();
1650  void oe1_pauseGame();
1651  void oe1_printPlayerHit();
1652  void oe1_printMonsterHit();
1653 
1654 protected:
1655  typedef void (AGOSEngine_Elvira1::*OpcodeProcElvira1) ();
1657  OpcodeProcElvira1 proc;
1658  const char *desc;
1659  };
1660 
1661  const OpcodeEntryElvira1 *_opcodesElvira1;
1662 
1663  void drawIcon(WindowBlock *window, uint icon, uint x, uint y) override;
1664  void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) override;
1665  void addHiResTextDirtyRect(Common::Rect rect);
1666  void clearHiResTextLayer() override;
1667 
1668  Common::String genSaveName(int slot) const override;
1669 
1670  Graphics::FontSJIS *_sjisFont;
1671  Common::Array<Common::Rect> _sjisTextFields;
1672  uint16 _sjisCurChar;
1673 };
1674 
1676 public:
1677  AGOSEngine_Elvira2(OSystem *system, const AGOSGameDescription *gd);
1678  //~AGOSEngine_Elvira2();
1679 
1680  void setupGame() override;
1681  void setupOpcodes() override;
1682  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1683 
1684  void executeOpcode(int opcode) override;
1685 
1686  void oe2_moveDirn();
1687  void oe2_doClass();
1688  void oe2_pObj();
1689  void oe2_isCalled();
1690  void oe2_menu();
1691  void oe2_drawItem();
1692  void oe2_doTable();
1693  void oe2_pauseGame();
1694  void oe2_setDoorOpen();
1695  void oe2_setDoorClosed();
1696  void oe2_setDoorLocked();
1697  void oe2_ifDoorOpen();
1698  void oe2_ifDoorClosed();
1699  void oe2_ifDoorLocked();
1700  void oe2_storeItem();
1701  void oe2_getItem();
1702  void oe2_bSet();
1703  void oe2_bClear();
1704  void oe2_bZero();
1705  void oe2_bNotZero();
1706  void oe2_getOValue();
1707  void oe2_setOValue();
1708  void oe2_ink();
1709  void oe2_printStats();
1710  void oe2_setSuperRoom();
1711  void oe2_getSuperRoom();
1712  void oe2_setExitOpen();
1713  void oe2_setExitClosed();
1714  void oe2_setExitLocked();
1715  void oe2_ifExitOpen();
1716  void oe2_ifExitClosed();
1717  void oe2_ifExitLocked();
1718  void oe2_playEffect();
1719  void oe2_getDollar2();
1720  void oe2_setSRExit();
1721  void oe2_printPlayerDamage();
1722  void oe2_printMonsterDamage();
1723  void oe2_isAdjNoun();
1724  void oe2_b2Set();
1725  void oe2_b2Clear();
1726  void oe2_b2Zero();
1727  void oe2_b2NotZero();
1728 
1729  void printStats() override;
1730 protected:
1731  typedef void (AGOSEngine_Elvira2::*OpcodeProcElvira2) ();
1733  OpcodeProcElvira2 proc;
1734  const char *desc;
1735  };
1736 
1737  const OpcodeEntryElvira2 *_opcodesElvira2;
1738 
1739  void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp) override;
1740 
1741  bool loadGame(const Common::String &filename, bool restartMode = false) override;
1742  bool saveGame(uint slot, const char *caption) override;
1743 
1744  void addArrows(WindowBlock *window, uint8 num) override;
1745  void removeArrows(WindowBlock *window, uint num) override;
1746 
1747  void drawIcon(WindowBlock *window, uint icon, uint x, uint y) override;
1748  bool hasIcon(Item *item) override;
1749  uint itemGetIconNumber(Item *item) override;
1750  uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr) override;
1751 
1752  void moveDirn(Item *i, uint x) override;
1753  int canPlace(Item *x, Item *y) override;
1754  int sizeOfRec(Item *o, int d) override;
1755  int weightOf(Item *x) override;
1756 
1757  int changeExitStates(SubSuperRoom *sr, int n, int d, uint16 s);
1758  uint16 getExitState(Item *item, uint16 x, uint16 d);
1759  void setExitState(Item *i, uint16 n, uint16 d, uint16 s);
1760  void setSRExit(Item *i, int n, int d, uint16 s);
1761 
1762  void handleMouseWheelUp() override;
1763  void handleMouseWheelDown() override;
1764 
1765  virtual void listSaveGames();
1766  bool confirmOverWrite(WindowBlock *window) override;
1767  void userGame(bool load) override;
1768  virtual int userGameGetKey(bool *b, uint maxChar);
1769 
1770  Common::String genSaveName(int slot) const override;
1771 };
1772 
1774 public:
1775  AGOSEngine_Waxworks(OSystem *system, const AGOSGameDescription *gd);
1776  //~AGOSEngine_Waxworks();
1777 
1778  void setupGame() override;
1779  void setupOpcodes() override;
1780  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1781 
1782  void executeOpcode(int opcode) override;
1783 
1784  void boxTextMessage(const char *x);
1785  void boxTextMsg(const char *x);
1786  void printBox();
1787  uint16 getBoxSize();
1788  uint16 checkFit(char *Ptr, int width, int lines);
1789 
1790  void oww_goto();
1791  void oww_addTextBox();
1792  void oww_setShortText();
1793  void oww_setLongText();
1794  void oww_printLongText();
1795  void oww_whereTo();
1796  void oww_textMenu();
1797  void oww_pauseGame();
1798  void oww_boxMessage();
1799  void oww_boxMsg();
1800  void oww_boxLongText();
1801  void oww_printBox();
1802  void oww_boxPObj();
1803  void oww_lockZones();
1804  void oww_unlockZones();
1805 
1806 protected:
1807  typedef void (AGOSEngine_Waxworks::*OpcodeProcWaxworks) ();
1809  OpcodeProcWaxworks proc;
1810  const char *desc;
1811  };
1812 
1813  const OpcodeEntryWaxworks *_opcodesWaxworks;
1814 
1815  bool _boxCR;
1816  char _boxBuffer[310];
1817  char *_boxBufferPtr;
1818  int _boxLineCount;
1819  int _lineCounts[6];
1820  char *_linePtrs[6];
1821 
1822  void drawIcon(WindowBlock *window, uint icon, uint x, uint y) override;
1823 
1824  void boxController(uint x, uint y, uint mode) override;
1825 
1826  void addArrows(WindowBlock *window, uint8 num) override;
1827  void removeArrows(WindowBlock *window, uint num) override;
1828 
1829  uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr) override;
1830 
1831  bool loadTablesIntoMem(uint16 subrId) override;
1832 
1833  void moveDirn(Item *i, uint x) override;
1834 
1835  bool confirmOverWrite(WindowBlock *window) override;
1836 
1837  Common::String genSaveName(int slot) const override;
1838 };
1839 
1841 private:
1842  // Simon 1 DOS CD and Acorn CD GMF data sizes.
1843  static const int SIMON1_GMF_SIZE[];
1844 
1845 public:
1846  AGOSEngine_Simon1(OSystem *system, const AGOSGameDescription *gd);
1847  //~AGOSEngine_Simon1();
1848 
1849  void setupGame() override;
1850  void setupOpcodes() override;
1851  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1852 
1853  void executeOpcode(int opcode) override;
1854 
1855  void vc22_setPalette() override;
1856 
1857  // Opcodes, Simon 1
1858  void os1_animate();
1859  void os1_pauseGame();
1860  void os1_screenTextBox();
1861  void os1_screenTextMsg();
1862  void os1_playEffect();
1863  void os1_screenTextPObj();
1864  void os1_getPathPosn();
1865  void os1_scnTxtLongText();
1866  void os1_mouseOn();
1867  void os1_mouseOff();
1868  void os1_loadBeard();
1869  void os1_unloadBeard();
1870  void os1_unloadZone();
1871  void os1_loadStrings();
1872  void os1_unfreezeZones();
1873  void os1_specialFade();
1874 
1875 protected:
1876  typedef void (AGOSEngine_Simon1::*OpcodeProcSimon1) ();
1878  OpcodeProcSimon1 proc;
1879  const char *desc;
1880  };
1881 
1882  const OpcodeEntrySimon1 *_opcodesSimon1;
1883 
1884  void drawImage(VC10_state *state) override;
1885  void drawMaskedImage(VC10_state *state);
1886  void draw32ColorImage(VC10_state *state);
1887 
1888  void dumpVgaFile(const byte *vga) override;
1889 
1890  void clearName() override;
1891 
1892  void handleMouseWheelUp() override;
1893  void handleMouseWheelDown() override;
1894 
1895  void drawIcon(WindowBlock *window, uint icon, uint x, uint y) override;
1896 
1897  void initMouse() override;
1898  void handleMouseMoved() override;
1899 
1900  void addArrows(WindowBlock *window, uint8 num) override;
1901  void removeArrows(WindowBlock *window, uint num) override;
1902 
1903  uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr) override;
1904 
1905  virtual void playSpeech(uint16 speechId, uint16 vgaSpriteId);
1906 
1907  void listSaveGames() override;
1908  void userGame(bool load) override;
1909  int userGameGetKey(bool *b, uint maxChar) override;
1910 
1911  void playMusic(uint16 music, uint16 track) override;
1912  void playMidiSfx(uint16 sound) override;
1913 
1914  void vcStopAnimation(uint16 zone, uint16 sprite) override;
1915 
1916  Common::String genSaveName(int slot) const override;
1917 };
1918 
1920 public:
1921  AGOSEngine_Simon2(OSystem *system, const AGOSGameDescription *gd);
1922  //~AGOSEngine_Simon2();
1923 
1924  void setupGame() override;
1925  void setupOpcodes() override;
1926  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1927 
1928  void executeOpcode(int opcode) override;
1929 
1930  void os2_printLongText();
1931  void os2_rescan();
1932  void os2_animate();
1933  void os2_stopAnimate();
1934  void os2_playTune();
1935  void os2_screenTextPObj();
1936  void os2_mouseOn();
1937  void os2_mouseOff();
1938  void os2_isShortText();
1939  void os2_clearMarks();
1940  void os2_waitMark();
1941 
1942 protected:
1943  typedef void (AGOSEngine_Simon2::*OpcodeProcSimon2) ();
1945  OpcodeProcSimon2 proc;
1946  const char *desc;
1947  };
1948 
1949  const OpcodeEntrySimon2 *_opcodesSimon2;
1950 
1951  void clearName() override;
1952 
1953  void drawIcon(WindowBlock *window, uint icon, uint x, uint y) override;
1954 
1955  void addArrows(WindowBlock *window, uint8 num) override;
1956  uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr) override;
1957 
1958  void clearVideoWindow(uint16 windowNum, uint16 color) override;
1959 
1960  void playSpeech(uint16 speechId, uint16 vgaSpriteId) override;
1961  // This overload plays the music track specified in the second parameter.
1962  // The first parameter is ignored; music data must be loaded using the
1963  // loadMusic method before calling this method.
1964  void playMusic(uint16 music, uint16 track) override;
1965 
1966  Common::String genSaveName(int slot) const override;
1967 };
1968 
1969 #ifdef ENABLE_AGOS2
1970 class AGOSEngine_Feeble : public AGOSEngine_Simon2 {
1971 public:
1972  AGOSEngine_Feeble(OSystem *system, const AGOSGameDescription *gd);
1973  ~AGOSEngine_Feeble() override;
1974 
1975  void setupGame() override;
1976  void setupOpcodes() override;
1977  void setupVideoOpcodes(VgaOpcodeProc *op) override;
1978 
1979  void executeOpcode(int opcode) override;
1980 
1981  void vc36_setWindowImage() override;
1982  void vc48_setPathFinder() override;
1983 
1984  void off_chance();
1985  void off_jumpOut();
1986  void off_addTextBox();
1987  void off_printLongText();
1988  void off_addBox();
1989  void off_oracleTextDown();
1990  void off_oracleTextUp();
1991  void off_ifTime();
1992  void off_setTime();
1993  void off_saveUserGame();
1994  void off_loadUserGame();
1995  void off_listSaveGames();
1996  void off_checkCD();
1997  void off_screenTextBox();
1998  void off_b2Set();
1999  void off_isAdjNoun();
2000  void off_hyperLinkOn();
2001  void off_hyperLinkOff();
2002  void off_checkPaths();
2003  void off_screenTextPObj();
2004  void off_mouseOn();
2005  void off_mouseOff();
2006  void off_loadVideo();
2007  void off_playVideo();
2008  void off_centerScroll();
2009  void off_resetPVCount();
2010  void off_setPathValues();
2011  void off_stopClock();
2012  void off_restartClock();
2013  void off_setColor();
2014  void off_b3Set();
2015  void off_b3Clear();
2016  void off_b3Zero();
2017  void off_b3NotZero();
2018 
2019 protected:
2020  friend class MoviePlayer;
2021  friend class MoviePlayerDXA;
2022  friend class MoviePlayerSMK;
2023 
2024  typedef void (AGOSEngine_Feeble::*OpcodeProcFeeble) ();
2025  struct OpcodeEntryFeeble {
2026  OpcodeProcFeeble proc;
2027  const char *desc;
2028  };
2029 
2030  const OpcodeEntryFeeble *_opcodesFeeble;
2031 
2032  MoviePlayer *_moviePlayer;
2033 
2034  uint8 _interactiveVideo;
2035  uint16 _vgaCurSpritePriority;
2036 
2037  uint16 to16Wrapper(uint value) override;
2038  uint16 readUint16Wrapper(const void *src) override;
2039  uint32 readUint32Wrapper(const void *src) override;
2040 
2041  void setLoyaltyRating(byte rating);
2042 
2043  void playVideo(const char *filename, bool lastSceneUsed = false);
2044  void stopInteractiveVideo();
2045 
2046  void drawImage(VC10_state *state) override;
2047  void scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY);
2048 
2049  void handleMouseWheelUp() override;
2050  void handleMouseWheelDown() override;
2051 
2052  void drawMousePart(int image, byte x, byte y);
2053  void initMouse() override;
2054  void drawMousePointer() override;
2055 
2056  void animateSprites() override;
2057  void animateSpritesByY();
2058 
2059  void oracleLogo();
2060  void swapCharacterLogo();
2061  void timerProc() override;
2062 
2063  void addArrows(WindowBlock *window, uint8 num) override;
2064  uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr) override;
2065 
2066  void resetVerbs() override;
2067  void setVerb(HitArea * ha) override;
2068  void hitarea_leave(HitArea * ha, bool state = false) override;
2069  void invertBox(HitArea *ha, bool state);
2070 
2071  void windowNewLine(WindowBlock *window) override;
2072  void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) override;
2073 
2074  void clearName() override;
2075 
2076  void drawIconArray(uint i, Item *itemPtr, int line, int classMask) override;
2077 
2078  void colorWindow(WindowBlock *window) override;
2079 
2080  void dumpVgaFile(const byte *vga) override;
2081 
2082  void doOutput(const byte *src, uint len) override;
2083 
2084  void printScreenText(uint vgaSpriteId, uint color, const char *stringPtr, int16 x, int16 y, int16 width) override;
2085 
2086  void printInteractText(uint16 num, const char *string);
2087  void sendInteractText(uint16 num, MSVC_PRINTF const char *fmt, ...) GCC_PRINTF(3, 4);
2088 
2089  void checkLinkBox();
2090  void hyperLinkOn(uint16 x);
2091  void hyperLinkOff();
2092  void linksUp();
2093  void linksDown();
2094 
2095  void runSubroutine101() override;
2096 
2097  void checkUp(WindowBlock *window);
2098  void checkDown(WindowBlock *window);
2099  void inventoryUp(WindowBlock *window) override;
2100  void inventoryDown(WindowBlock *window) override;
2101 
2102  void oracleTextUp();
2103  void oracleTextDown();
2104  void scrollOracle();
2105  void scrollOracleUp();
2106  void scrollOracleDown();
2107 
2108  void listSaveGamesFeeble();
2109  void saveUserGame(int slot);
2110  void windowBackSpace(WindowBlock *window);
2111 
2112  Common::String genSaveName(int slot) const override;
2113  void quickLoadOrSave() override;
2114 };
2115 
2116 class AGOSEngine_FeebleDemo : public AGOSEngine_Feeble {
2117 public:
2118  AGOSEngine_FeebleDemo(OSystem *system, const AGOSGameDescription *gd);
2119 
2120 protected:
2121  bool _filmMenuUsed;
2122 
2123  Common::Error go() override;
2124 
2125  void initMouse() override;
2126  void drawMousePointer() override;
2127 
2128  void exitMenu();
2129  void filmMenu();
2130  void handleText();
2131  void handleWobble();
2132  void mainMenu();
2133  void startInteractiveVideo(const char *filename);
2134  void waitForSpace();
2135 };
2136 
2137 class AGOSEngine_PuzzlePack : public AGOSEngine_Feeble {
2138 public:
2139  AGOSEngine_PuzzlePack(OSystem *system, const AGOSGameDescription *gd);
2140  //~AGOSEngine_PuzzlePack();
2141 
2142  void setupGame() override;
2143  void setupOpcodes() override;
2144 
2145  void executeOpcode(int opcode) override;
2146 
2147  void vc3_loadSprite() override;
2148  void vc63_fastFadeIn() override;
2149 
2150  void opp_iconifyWindow();
2151  void opp_restoreOopsPosition();
2152  void opp_loadMouseImage();
2153  void opp_message();
2154  void opp_setShortText();
2155  void opp_loadHiScores();
2156  void opp_checkHiScores();
2157  void opp_sync();
2158  void opp_saveUserGame();
2159  void opp_loadUserGame();
2160  void opp_playTune();
2161  void opp_saveOopsPosition();
2162  void opp_resetGameTime();
2163  void opp_resetPVCount();
2164  void opp_setPathValues();
2165  void opp_pauseClock();
2166 
2167 protected:
2168  typedef void (AGOSEngine_PuzzlePack::*OpcodeProcPuzzlePack) ();
2169  struct OpcodeEntryPuzzlePack {
2170  OpcodeProcPuzzlePack proc;
2171  const char *desc;
2172  };
2173 
2174  const OpcodeEntryPuzzlePack *_opcodesPuzzlePack;
2175 
2176  bool _oopsValid;
2177  uint32 _gameTime;
2178 
2179  void initMouse() override;
2180  void handleMouseMoved() override;
2181  void drawMousePointer() override;
2182 
2183  void resetVerbs() override;
2184 
2185  void loadMouseImage();
2186 
2187  void startOverlayAnims();
2188  void startAnOverlayAnim();
2189 
2190  void printInfoText(const char *itemText);
2191 
2192  Common::String genSaveName(int slot) const override;
2193 };
2194 
2195 
2196 class AGOSEngine_DIMP : public AGOSEngine_PuzzlePack {
2197 public:
2198  AGOSEngine_DIMP(OSystem *system, const AGOSGameDescription *gd);
2199  //~AGOSEngine_DIMP();
2200 
2201  void setupOpcodes() override;
2202 
2203  void executeOpcode(int opcode) override;
2204 
2205 protected:
2206  typedef void (AGOSEngine_DIMP::*OpcodeProcDIMP) ();
2207  struct OpcodeEntryDIMP {
2208  OpcodeProcDIMP proc;
2209  const char *desc;
2210  };
2211 
2212  const OpcodeEntryDIMP *_opcodesDIMP;
2213 
2214  int16 _iconToggleCount, _voiceCount;
2215  uint32 _lastTickCount;
2216  uint32 _startSecondCount, _tSecondCount;
2217 
2218  void odp_saveUserGame();
2219  void odp_loadUserGame();
2220 
2221  void dimpIdle();
2222  void timerProc() override;
2223 
2224 };
2225 #endif
2226 
2227 } // End of namespace AGOS
2228 
2229 #endif
Definition: sound.h:40
Definition: agos.h:1586
Definition: str.h:59
Definition: surface.h:66
EngineFeature
Definition: engine.h:250
Definition: agos.h:1419
Definition: error.h:84
ErrorCode getCode() const
Definition: error.h:115
Definition: agos.h:1919
Definition: agos.h:101
Definition: agos.h:1656
Definition: random.h:44
Definition: intern.h:124
Definition: agos.h:1338
Definition: vga.h:113
Definition: midi.h:38
No error occurred.
Definition: error.h:48
Definition: rect.h:144
Definition: intern.h:181
Definition: agos.h:117
Definition: intern.h:116
Definition: stream.h:745
int tagOfParentDoline
tag of the doline "instance" to which this StackFrame belongs
Definition: agos.h:1429
Definition: agos.h:127
Definition: intern.h:190
Definition: agos.h:200
Definition: intern.h:175
Definition: mixer.h:49
Definition: intern.h:48
int FORCEINLINE GCC_PRINTF(2, 0) int vsprintf_s(T(&dst)[N]
Definition: agos.h:63
Definition: file.h:47
Definition: agos.h:1944
Definition: intern.h:151
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: agos.h:1808
Definition: agos.h:158
Definition: rect.h:45
Definition: detection.h:40
Definition: intern.h:196
Definition: agos.h:1578
Definition: agos.h:1732
Definition: agos.h:150
Definition: intern.h:57
Definition: keyboard.h:294
Definition: intern.h:65
Definition: agos.h:1675
Definition: agos.h:96
Definition: debugger.h:31
Definition: system.h:167
int _tagOfActiveDoline
tag of the active doline "instance"
Definition: agos.h:1436
Definition: stack.h:102
Definition: engine.h:143
Definition: agos.h:167
Definition: agos.h:1840
Definition: intern.h:43
Definition: agos.h:1773
Platform
Definition: platform.h:46
Common::Error run() override
Definition: agos.h:216
Language
Definition: language.h:45
Definition: agos.h:1877