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