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