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