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