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