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