forked from scummvm/scummvm
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathagos.h
2188 lines (1757 loc) · 52.6 KB
/
agos.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef AGOS_AGOS_H
#define AGOS_AGOS_H
#include "engines/engine.h"
#include "common/array.h"
#include "common/error.h"
#include "common/keyboard.h"
#include "common/random.h"
#include "common/rect.h"
#include "common/stack.h"
#include "common/util.h"
#include "audio/mixer.h"
#include "agos/vga.h"
/**
* This is the namespace of the AGOS engine.
*
* Status of this engine: ???
*
* Games using this engine:
* - Elvira: Mistress of the Dark
* - Elvira 2: The Jaws of Cerberus
* - The Feeble Files
* - Simon the Sorcerer
* - Simon the Sorcerer 2
* - Simon the Sorcerer Puzzle Pack
*/
namespace Common {
class File;
class SeekableReadStream;
}
namespace Graphics {
struct Surface;
}
namespace AGOS {
enum {
kDebugOpcode = 1 << 0,
kDebugVGAOpcode = 1 << 1,
kDebugSubroutine = 1 << 2,
kDebugVGAScript = 1 << 3,
kDebugImageDump = 1 << 4
};
uint fileReadItemID(Common::SeekableReadStream *in);
#define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y))
#ifdef ENABLE_AGOS2
class MoviePlayer;
#endif
class Sound;
class MidiPlayer;
struct Child;
struct SubObject;
struct RoomState;
struct SubRoom;
struct SubSuperRoom;
struct Item;
struct WindowBlock;
struct Subroutine;
struct SubroutineLine;
struct TimeEvent;
struct TextLocation {
int16 x, y, width;
TextLocation() { memset(this, 0, sizeof(*this)); }
};
struct HitArea {
uint16 x, y;
uint16 width, height;
uint16 flags;
uint16 id;
uint16 data;
WindowBlock *window;
Item *itemPtr;
uint16 verb;
uint16 priority;
// Personal Nightmare specific
uint16 msg1, msg2;
HitArea() { memset(this, 0, sizeof(*this)); }
};
struct VgaPointersEntry {
byte *vgaFile1;
byte *vgaFile1End;
byte *vgaFile2;
byte *vgaFile2End;
byte *sfxFile;
byte *sfxFileEnd;
VgaPointersEntry() { memset(this, 0, sizeof(*this)); }
};
struct VgaSprite {
uint16 id;
int16 image;
uint16 palette;
int16 x, y;
uint16 flags;
uint16 priority;
uint16 windowNum;
uint16 zoneNum;
VgaSprite() { reset(); }
void reset() {
id = 0;
image = 0;
palette = 0;
x = y = 0;
flags = 0;
priority = 0;
windowNum = 0;
zoneNum = 0;
}
};
struct VgaSleepStruct {
uint16 ident;
const byte *codePtr;
uint16 id;
uint16 zoneNum;
VgaSleepStruct() { memset(this, 0, sizeof(*this)); }
};
struct VgaTimerEntry {
int16 delay;
const byte *codePtr;
uint16 id;
uint16 zoneNum;
uint8 type;
VgaTimerEntry() { memset(this, 0, sizeof(*this)); }
};
struct AnimTable {
const byte *srcPtr;
int16 x;
int16 y;
uint16 width;
uint16 height;
uint16 windowNum;
uint16 id;
uint16 zoneNum;
AnimTable() { memset(this, 0, sizeof(*this)); }
};
enum SIMONGameType {
GType_PN = 0,
GType_ELVIRA1 = 1,
GType_ELVIRA2 = 2,
GType_WW = 3,
GType_SIMON1 = 4,
GType_SIMON2 = 5,
GType_FF = 6,
GType_PP = 7
};
enum EventType {
ANIMATE_INT = 1 << 1,
ANIMATE_EVENT = 1 << 2,
SCROLL_EVENT = 1 << 3,
PLAYER_DAMAGE_EVENT = 1 << 4,
MONSTER_DAMAGE_EVENT = 1 << 5
};
struct AGOSGameDescription;
struct GameSpecificSettings;
class Debugger;
// This is to help devices with small memory (PDA, smartphones, ...)
// to save a bit of memory used by opcode names in the AGOS engine.
#ifndef REDUCE_MEMORY_USAGE
# define _OPCODE(ver, x) { &ver::x, #x }
#else
# define _OPCODE(ver, x) { &ver::x, "" }
#endif
class AGOSEngine : public Engine {
protected:
friend class Debugger;
// Engine APIs
Common::Error init();
virtual Common::Error go();
virtual Common::Error run() {
Common::Error err;
err = init();
if (err.getCode() != Common::kNoError)
return err;
return go();
}
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
virtual void pauseEngineIntern(bool pause);
virtual void setupOpcodes();
uint16 _numOpcodes, _opcode;
typedef void (AGOSEngine::*VgaOpcodeProc) ();
void setupVgaOpcodes();
VgaOpcodeProc _vga_opcode_table[100];
uint8 _numVideoOpcodes;
virtual void setupVideoOpcodes(VgaOpcodeProc *op);
const AGOSGameDescription * const _gameDescription;
public:
virtual void setupGame();
int getGameId() const;
int getGameType() const;
uint32 getFeatures() const;
const char *getExtra() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
const char *getFileName(int type) const;
protected:
void playSting(uint16 a);
const byte *_vcPtr; /* video code ptr */
uint16 _vcGetOutOfCode;
uint32 *_gameOffsetsPtr;
uint8 _numMusic, _numSFX;
uint16 _numSpeech;
uint16 _numZone;
uint8 _numBitArray1, _numBitArray2, _numBitArray3, _numItemStore;
uint16 _numVars;
uint8 _vgaBaseDelay, _vgaPeriod;
uint16 _musicIndexBase;
uint16 _soundIndexBase;
uint16 _tableIndexBase;
uint16 _textIndexBase;
uint32 _itemMemSize;
uint32 _tableMemSize;
uint32 _vgaMemSize;
const GameSpecificSettings *gss;
Common::KeyState _keyPressed;
Common::File *_gameFile;
byte *_strippedTxtMem;
byte *_textMem;
uint32 _textSize;
uint32 _stringTabNum, _stringTabPos, _stringTabSize;
byte **_stringTabPtr;
Item **_itemArrayPtr;
uint32 _itemArraySize;
uint32 _itemArrayInited;
Common::Array<byte *> _itemHeap;
byte *_iconFilePtr;
const byte *_codePtr;
byte **_localStringtable;
uint16 _stringIdLocalMin, _stringIdLocalMax;
RoomState *_roomStates;
uint16 _numRoomStates;
byte *_menuBase;
byte *_roomsList;
byte *_roomsListPtr;
byte *_xtblList;
byte *_xtablesHeapPtrOrg;
uint32 _xtablesHeapCurPosOrg;
Subroutine *_xsubroutineListOrg;
byte *_tblList;
byte *_tablesHeapPtr, *_tablesHeapPtrOrg, *_tablesheapPtrNew;
uint32 _tablesHeapSize, _tablesHeapCurPos, _tablesHeapCurPosOrg;
uint32 _tablesHeapCurPosNew;
Subroutine *_subroutineListOrg;
Subroutine *_subroutineList;
uint8 _recursionDepth;
uint32 _lastVgaTick;
uint16 _marks;
bool _scanFlag;
bool _scriptVar2;
bool _runScriptReturn1;
bool _runScriptCondition[40];
int16 _runScriptReturn[40];
bool _skipVgaWait;
bool _noParentNotify;
bool _beardLoaded;
bool _litBoxFlag;
bool _mortalFlag;
uint16 _displayFlag;
bool _syncFlag2;
bool _inCallBack;
bool _cepeFlag;
bool _fastMode;
bool _backFlag;
Common::Language _language;
bool _copyProtection;
bool _pause;
bool _speech;
bool _subtitles;
bool _vgaVar9;
int16 _chanceModifier;
bool _restoreWindow6;
int16 _scrollX, _scrollXMax;
int16 _scrollY, _scrollYMax;
int16 _scrollCount, _scrollFlag;
uint16 _scrollWidth, _scrollHeight;
const byte *_scrollImage;
byte _boxStarHeight;
SubroutineLine *_classLine;
int16 _classMask, _classMode1, _classMode2;
Item *_findNextPtr;
Subroutine *_currentTable;
SubroutineLine *_currentLine;
uint8 _agosMenu;
byte _textMenu[10];
uint16 _currentRoom, _superRoomNumber;
uint8 _wallOn;
uint16 _hyperLink, _newLines;
uint16 _oracleMaxScrollY, _noOracleScroll;
uint16 _interactY;
int16 _scriptVerb, _scriptNoun1, _scriptNoun2;
int16 _scriptAdj1, _scriptAdj2;
uint16 _curWindow;
WindowBlock *_inputWindow, *_textWindow;
Item *_subjectItem, *_objectItem;
Item *_currentPlayer;
Item *_hitAreaObjectItem;
HitArea *_lastHitArea;
HitArea *_lastNameOn;
HitArea *_lastHitArea3;
Item *_hitAreaSubjectItem;
HitArea *_currentBox, *_currentVerbBox, *_lastVerbOn;
uint16 _currentBoxNum;
uint16 _needHitAreaRecalc;
uint16 _verbHitArea;
uint16 _defaultVerb;
bool _iOverflow;
bool _nameLocked;
bool _dragAccept;
bool _dragEnd;
bool _dragFlag;
bool _dragMode;
uint8 _dragCount;
HitArea *_lastClickRem;
uint16 _windowNum;
int16 _printCharCurPos, _printCharMaxPos, _printCharPixelCount;
uint16 _numLettersToPrint;
uint8 _numTextBoxes;
uint32 getTime() const;
uint32 _lastMinute; // Used in processSpecialKeys()
uint32 _lastTime;
uint32 _clockStopped, _gameStoppedClock;
uint32 _timeStore;
TimeEvent *_firstTimeStruct, *_pendingDeleteTimeEvent;
bool _initMouse;
Common::Point _mouse;
Common::Point _mouseOld;
byte *_mouseData;
bool _animatePointer;
byte _maxCursorWidth, _maxCursorHeight;
byte _mouseAnim, _mouseAnimMax, _mouseCursor;
byte _currentMouseAnim, _currentMouseCursor;
byte _oldMouseAnimMax, _oldMouseCursor;
uint16 _mouseHideCount;
bool _mouseToggle;
bool _leftButtonDown, _rightButtonDown;
byte _leftButton, _leftButtonCount, _leftButtonOld;
byte _oneClick;
bool _clickOnly;
bool _leftClick, _rightClick;
bool _noRightClick;
Item *_dummyItem1;
Item *_dummyItem2;
Item *_dummyItem3;
volatile uint16 _videoLockOut;
uint16 _scrollUpHitArea;
uint16 _scrollDownHitArea;
bool _fastFadeOutFlag;
byte _paletteFlag;
bool _bottomPalette;
uint16 _fastFadeCount;
volatile uint16 _fastFadeInFlag;
uint16 _screenWidth, _screenHeight;
uint16 _noOverWrite;
bool _rejectBlock;
bool _exitCutscene, _picture8600;
uint16 _soundFileId;
int16 _lastMusicPlayed;
int16 _nextMusicToPlay;
bool _showPreposition;
bool _showMessageFlag;
bool _newDirtyClip;
bool _wiped;
uint16 _copyScnFlag, _vgaSpriteChanged;
byte *_block, *_blockEnd;
byte *_vgaMemPtr, *_vgaMemEnd, *_vgaMemBase;
byte *_vgaFrozenBase, *_vgaRealBase;
byte *_zoneBuffers;
byte *_curVgaFile1;
byte *_curVgaFile2;
uint16 _syncCount;
uint16 _frameCount;
uint16 _zoneNumber;
uint16 _vgaWaitFor, _lastVgaWaitFor;
uint16 _vgaCurSpriteId, _vgaCurZoneNum;
int16 _baseY;
float _scale;
Common::Rect _feebleRect;
int16 _scaleX, _scaleY, _scaleWidth, _scaleHeight;
VgaTimerEntry *_nextVgaTimerToProcess;
uint8 _opcode177Var1, _opcode177Var2;
uint8 _opcode178Var1, _opcode178Var2;
Item *_objectArray[50];
Item *_itemStore[50];
uint16 _shortText[40];
uint16 _shortTextX[40];
uint16 _shortTextY[40];
uint16 _longText[40];
uint16 _longSound[40];
uint16 _bitArray[128];
uint16 _bitArrayTwo[16];
uint16 _bitArrayThree[16];
int16 *_variableArray;
int16 *_variableArray2;
int16 *_variableArrayPtr;
WindowBlock *_dummyWindow;
WindowBlock *_windowArray[80];
byte _fcsData1[8];
bool _fcsData2[8];
TextLocation _textLocation1, _textLocation2, _textLocation3, _textLocation4;
byte _awaitTwoByteToken;
byte *_byteTokens;
byte *_byteTokenStrings;
byte *_twoByteTokens;
byte *_twoByteTokenStrings;
byte *_secondTwoByteTokenStrings;
byte *_thirdTwoByteTokenStrings;
byte _textBuffer[180];
int _textCount;
int _freeStringSlot;
byte _stringReturnBuffer[2][180];
HitArea _hitAreas[250];
HitArea *_hitAreaList;
AnimTable _screenAnim1[90];
VgaPointersEntry _vgaBufferPointers[450];
VgaSprite _vgaSprites[200];
VgaSleepStruct _onStopTable[60];
VgaSleepStruct _waitEndTable[60];
VgaSleepStruct _waitSyncTable[60];
const uint16 *_pathFindArray[100];
uint8 _pathValues[400];
uint16 _PVCount;
uint16 _GPVCount;
uint8 _pathValues1[400];
uint16 _PVCount1;
uint16 _GPVCount1;
uint8 _currentPalette[768];
uint8 _displayPalette[768];
byte *_planarBuf;
byte _videoBuf1[32000];
uint16 _videoWindows[128];
uint8 _window3Flag;
uint8 _window4Flag;
uint8 _window6Flag;
uint16 _moveXMin, _moveYMin;
uint16 _moveXMax, _moveYMax;
VgaTimerEntry _vgaTimerList[205];
WindowBlock *_windowList;
byte _lettersToPrintBuf[80];
MidiPlayer *_midi;
bool _midiEnabled;
int _vgaTickCounter;
Audio::SoundHandle _modHandle;
Sound *_sound;
bool _effectsPaused;
bool _ambientPaused;
bool _musicPaused;
Debugger *_debugger;
uint8 _saveGameNameLen;
uint16 _saveLoadRowCurPos;
uint16 _numSaveGameRows;
bool _saveDialogFlag;
bool _saveOrLoad;
bool _saveLoadEdit;
byte _saveLoadType, _saveLoadSlot;
char _saveLoadName[108];
char _saveBuf[200];
Graphics::Surface *_backGroundBuf;
Graphics::Surface *_backBuf;
Graphics::Surface *_scaleBuf;
Graphics::Surface *_window4BackScn;
Graphics::Surface *_window6BackScn;
Common::RandomSource _rnd;
const byte *_vc10BasePtrOld;
byte _hebrewCharWidths[32];
public:
AGOSEngine(OSystem *system, const AGOSGameDescription *gd);
virtual ~AGOSEngine();
byte *_curSfxFile;
uint32 _curSfxFileSize;
uint16 _sampleEnd, _sampleWait;
protected:
virtual uint16 to16Wrapper(uint value);
virtual uint16 readUint16Wrapper(const void *src);
virtual uint32 readUint32Wrapper(const void *src);
#ifdef ENABLE_AGOS2
void loadArchives();
#endif
int allocGamePcVars(Common::SeekableReadStream *in);
void createPlayer();
void allocateStringTable(int num);
void setupStringTable(byte *mem, int num);
void setupLocalStringTable(byte *mem, int num);
void readGamePcText(Common::SeekableReadStream *in);
virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
void readItemFromGamePc(Common::SeekableReadStream *in, Item *item);
virtual void loadGamePcFile();
void readGamePcFile(Common::SeekableReadStream *in);
void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
void decompressPN(Common::Stack<uint32> &dataList, uint8 *&dataOut, int &dataOutSize);
void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
void loadSound(uint16 sound, int16 pan, int16 vol, uint16 type);
void loadSound(uint16 sound, uint16 freq, uint16 flags);
void loadVoice(uint speechId);
void loadSoundFile(const char *filename);
int getUserFlag(Item *item, int a);
int getUserFlag1(Item *item, int a);
int getUserItem(Item *item, int n);
void setUserFlag(Item *item, int a, int b);
void setUserItem(Item *item, int n, int m);
void paletteFadeOut(byte *palPtr, uint num, uint size);
void *allocateItem(uint size);
void *allocateTable(uint size);
void alignTableMem();
Child *findChildOfType(Item *i, uint child);
Child *allocateChildBlock(Item *i, uint type, uint size);
void allocItemHeap();
void allocTablesHeap();
Subroutine *createSubroutine(uint16 a);
void readSubroutine(Common::SeekableReadStream *in, Subroutine *sub);
SubroutineLine *createSubroutineLine(Subroutine *sub, int a);
void readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *newTable, Subroutine *sub);
byte *readSingleOpcode(Common::SeekableReadStream *in, byte *ptr);
void readSubroutineBlock(Common::SeekableReadStream *in);
Subroutine *getSubroutineByID(uint subroutineId);
/* used in debugger */
void dumpAllSubroutines();
void dumpAllVgaImageFiles();
void dumpAllVgaScriptFiles();
void dumpSubroutines();
void dumpSubroutine(Subroutine *sub);
void dumpSubroutineLine(SubroutineLine *sl, Subroutine *sub);
const byte *dumpOpcode(const byte *p);
int startSubroutine(Subroutine *sub);
int startSubroutineEx(Subroutine *sub);
bool checkIfToRunSubroutineLine(SubroutineLine *sl, Subroutine *sub);
int runScript();
virtual void executeOpcode(int opcode) = 0;
byte getByte();
int getNextWord();
uint getNextVarContents();
uint getVarWrapper();
uint getVarOrWord();
uint getVarOrByte();
uint readVariable(uint16 variable);
void writeNextVarContents(uint16 contents);
void writeVariable(uint16 variable, uint16 contents);
Item *derefItem(uint item);
Item *getNextItemPtr();
uint getNextItemID();
uint getItem1ID() {return 1;}
uint itemPtrToID(Item *id);
Item *me();
Item *actor();
void uncompressText(byte *ptr);
byte *uncompressToken(byte a, byte *ptr);
void showMessageFormat(const char *s, ...) GCC_PRINTF(2, 3);
const byte *getStringPtrByID(uint16 stringId, bool upperCase = false);
const byte *getLocalStringByID(uint16 stringId);
uint getNextStringID();
void addTimeEvent(uint16 timeout, uint16 subroutineId);
void delTimeEvent(TimeEvent *te);
Item *findInByClass(Item *i, int16 m);
Item *nextInByClass(Item *i, int16 m);
Item *findMaster(int16 a, int16 n);
Item *nextMaster(Item *item, int16 a, int16 n);
int wordMatch(Item *item, int16 a, int16 n);
bool isRoom(Item *item);
bool isObject(Item *item);
bool isPlayer(Item *item);
void itemChildrenChanged(Item *item);
void unlinkItem(Item *item);
void linkItem(Item *item, Item *parent);
void setItemParent(Item *item, Item *parent);
void setItemState(Item *item, int value);
void stopAnimate(uint16 a);
void stopAnimateSimon2(uint16 a, uint16 b);
void enableBox(uint hitarea);
void disableBox(uint hitarea);
void moveBox(uint hitarea, int x, int y);
bool isBoxDead(uint hitarea);
void undefineBox(uint hitarea);
void defineBox(int id, int x, int y, int width, int height, int flags, int verb, Item *itemPtr);
void defineBox(uint16 id, uint16 x, uint16 y, uint16 width, uint16 height, uint16 msg1, uint16 msg2, uint16 flags);
HitArea *findEmptyHitArea();
virtual void resetVerbs();
virtual void setVerb(HitArea * ha);
virtual void hitarea_leave(HitArea * ha, bool state = false);
void leaveHitAreaById(uint hitarea_id);
void sendSync(uint a);
void waitForSync(uint a);
uint getOffsetOfChild2Param(SubObject *child, uint prop);
void scriptMouseOff();
void freezeBottom();
void unfreezeBottom();
TextLocation *getTextLocation(uint a);
uint setVerbText(HitArea *ha);
void waitForInput();
void setup_cond_c_helper();
uint16 getBackExit(int n);
uint16 getDoorState(Item *item, uint16 d);
uint16 getExitOf(Item *item, uint16 d);
void changeDoorState(SubRoom *r, uint16 d, uint16 n);
void setDoorState(Item *i, uint16 d, uint16 n);
// Elvira 1 specific
Item *getDoorOf(Item *item, uint16 d);
Item *getExitOf_e1(Item *item, uint16 d);
virtual void moveDirn(Item *i, uint x);
virtual int canPlace(Item *x, Item *y);
int contains(Item *a, Item *b);
int sizeContents(Item *x);
virtual int sizeOfRec(Item *o, int d);
int sizeRec(Item *x, int d);
int weighUp(Item *x);
int weightRec(Item *x, int d);
virtual int weightOf(Item *x);
void xPlace(Item *x, Item *y);
void restoreMenu();
void drawMenuStrip(uint windowNum, uint menuNum);
void lightMenuStrip(int a);
void unlightMenuStrip();
void lightMenuBox(uint hitarea);
uint menuFor_e2(Item *item);
uint menuFor_ww(Item *item, uint id);
void clearMenuStrip();
void doMenuStrip(uint menuNum);
void mouseOff();
void mouseOn();
bool loadRoomItems(uint16 item);
virtual bool loadTablesIntoMem(uint16 subrId);
bool loadXTablesIntoMem(uint16 subrId);
void loadTextIntoMem(uint16 stringId);
uint loadTextFile(const char *filename, byte *dst);
Common::SeekableReadStream *openTablesFile(const char *filename);
void closeTablesFile(Common::SeekableReadStream *in);
uint loadTextFile_simon1(const char *filename, byte *dst);
Common::SeekableReadStream *openTablesFile_simon1(const char *filename);
uint loadTextFile_gme(const char *filename, byte *dst);
Common::SeekableReadStream *openTablesFile_gme(const char *filename);
void invokeTimeEvent(TimeEvent *te);
bool kickoffTimeEvents();
void killAllTimers();
void endCutscene();
virtual void runSubroutine101();
virtual void inventoryUp(WindowBlock *window);
virtual void inventoryDown(WindowBlock *window);
WindowBlock *openWindow(uint x, uint y, uint w, uint h, uint flags, uint fillColor, uint textColor);
uint getWindowNum(WindowBlock *window);
void clearWindow(WindowBlock *window);
void changeWindow(uint a);
void closeWindow(uint a);
void setTextColor(uint color);
virtual void windowPutChar(WindowBlock *window, byte c, byte b = 0);
void waitWindow(WindowBlock *window);
HitArea *findBox(uint hitarea_id);
virtual void boxController(uint x, uint y, uint mode);
void handleVerbClicked(uint verb);
virtual void clearName();
void displayName(HitArea * ha);
void resetNameWindow();
void displayBoxStars();
void invertBox(HitArea * ha, byte a, byte b, byte c, byte d);
virtual void handleMouseWheelUp();
virtual void handleMouseWheelDown();
virtual void initMouse();
virtual void handleMouseMoved();
virtual void drawMousePointer();
void drawArrow(uint16 x, uint16 y, int8 dir);
virtual void addArrows(WindowBlock *window, uint8 num);
virtual void removeArrows(WindowBlock *window, uint num);
virtual void drawIcon(WindowBlock *window, uint icon, uint x, uint y);
virtual bool hasIcon(Item *item);
virtual uint itemGetIconNumber(Item *item);
virtual uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *itemPtr);
virtual void drawIconArray(uint i, Item *itemPtr, int line, int classMask);
void removeIconArray(uint num);
void loadIconData();
void loadIconFile();
void loadMenuFile();
virtual bool processSpecialKeys();
void hitarea_stuff_helper();
void permitInput();
uint getFeebleFontSize(byte chr);
void justifyStart();
void justifyOutPut(byte chr);
void loadZone(uint16 zoneNum, bool useError = true);
void animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, int16 x, int16 y, uint16 palette, bool vgaScript = false);
void setImage(uint16 vgaSpriteId, bool vgaScript = false);
void setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCase = false);
virtual void setWindowImageEx(uint16 mode, uint16 vgaSpriteId);
void drawEdging();
void skipSpeech();
const char *getPixelLength(const char *string, uint16 maxWidth, uint16 &pixels);
bool printNameOf(Item *item, uint x, uint y);
bool printTextOf(uint a, uint x, uint y);
void printVerbOf(uint hitarea_id);
void showActionString(const byte *string);
virtual void printScreenText(uint vgaSpriteId, uint color, const char *stringPtr, int16 x, int16 y, int16 width);
void renderStringAmiga(uint vgaSpriteId, uint color, uint width, uint height, const char *txt);
void renderString(uint vgaSpriteId, uint color, uint width, uint height, const char *txt);
void writeChar(WindowBlock *window, int x, int y, int offs, int val);
byte *allocBlock(uint32 size);
void checkNoOverWrite();
void checkRunningAnims();
void checkAnims(uint a);
void checkZonePtrs();
void setZoneBuffers();
void runVgaScript();
public:
bool getBitFlag(uint bit);
void setBitFlag(uint bit, bool value);
// Video Script Opcodes, Common
void vc1_fadeOut();
void vc2_call();
virtual void vc3_loadSprite();
void vc4_fadeIn();
void vc5_ifEqual();
void vc6_ifObjectHere();
void vc7_ifObjectNotHere();
void vc8_ifObjectIsAt();
void vc9_ifObjectStateIs();
void vc10_draw();
void vc12_delay();
void vc13_addToSpriteX();
void vc14_addToSpriteY();
void vc15_sync();
void vc16_waitSync();
void vc18_jump();
void vc19_loop();
void vc20_setRepeat();
void vc21_endRepeat();
virtual void vc22_setPalette();
void vc23_setPriority();
void vc24_setSpriteXY();
void vc25_halt_sprite();
void vc26_setSubWindow();
void vc27_resetSprite();
void vc28_playSFX();
void vc29_stopAllSounds();
void vc30_setFrameRate();
void vc31_setWindow();
void vc33_setMouseOn();
void vc34_setMouseOff();
void vc35_clearWindow();
virtual void vc36_setWindowImage();
void vc38_ifVarNotZero();
void vc39_setVar();
void vc40_scrollRight();
void vc41_scrollLeft();
void vc42_delayIfNotEQ();
// Video Script Opcodes, Personal Nightmare
void vc11_onStop();
void vc36_pause();
void vc39_volume();
void vc44_enableBox();
void vc45_disableBox();
void vc46_maxBox();
void vc48_specialEffect();
void vc50_setBox();
void vc55_scanFlag();
// Video Script Opcodes, Elvira 1
void vc17_waitEnd();
void vc32_saveScreen();
void vc37_pokePalette();
// Video Script Opcodes, Elvira 2
void vc43_ifBitSet();
void vc44_ifBitClear();
void vc45_setWindowPalette();
void vc46_setPaletteSlot1();
void vc47_setPaletteSlot2();
void vc48_setPaletteSlot3();
void vc49_setBit();
void vc50_clearBit();
void vc51_enableBox();
void vc52_playSound();
void vc53_dissolveIn();
void vc54_dissolveOut();
void vc55_moveBox();
void vc56_fullScreen();
void vc57_blackPalette();
void vc58_checkCodeWheel();
void vc58_changePriority();
void vc59_ifEGA();
// Video Script Opcodes, Waxworks
void vc60_stopAnimation();