ScummVM API documentation
runtime.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 VCRUISE_RUNTIME_H
23 #define VCRUISE_RUNTIME_H
24 
25 #include "graphics/pixelformat.h"
26 
27 #include "common/hashmap.h"
28 #include "common/keyboard.h"
29 #include "common/mutex.h"
30 #include "common/rect.h"
31 
32 #include "vcruise/detection.h"
33 
34 class OSystem;
35 class MidiDriver;
36 
37 namespace Common {
38 
39 class MemoryReadStream;
40 class RandomSource;
41 class ReadStream;
42 class WriteStream;
43 
44 } // End of namespace Commom
45 
46 namespace Audio {
47 
48 class AudioStream;
49 class SeekableAudioStream;
50 class LoopingAudioStream;
51 
52 } // End of namespace Audio
53 
54 namespace Graphics {
55 
56 struct PixelFormat;
57 struct WinCursorGroup;
58 class ManagedSurface;
59 class Font;
60 class Cursor;
61 
62 } // End of namespace Graphics
63 
64 namespace Video {
65 
66 class AVIDecoder;
67 
68 } // End of namespace Video
69 
70 namespace Image {
71 
72 class AniDecoder;
73 
74 } // End of namespace Image
75 
76 namespace VCruise {
77 
78 static const uint kNumDirections = 8;
79 static const uint kNumHighPrecisionDirections = 256;
80 static const uint kHighPrecisionDirectionMultiplier = kNumHighPrecisionDirections / kNumDirections;
81 static const uint kNumStartConfigs = 3;
82 
83 enum StartConfig {
84  kStartConfigCheatMenu,
85  kStartConfigInitial,
86  kStartConfigAlt,
87 };
88 
89 class AudioPlayer;
90 class CircuitPuzzle;
91 class MidiPlayer;
92 class MenuInterface;
93 class MenuPage;
94 class RuntimeMenuInterface;
95 class TextParser;
96 struct ScriptSet;
97 struct Script;
98 struct IScriptCompilerGlobalState;
99 struct Instruction;
100 struct RoomScriptSet;
101 struct SoundLoopInfo;
102 class SampleLoopAudioStream;
103 struct AD2044Graphics;
104 
105 enum GameState {
106  kGameStateBoot, // Booting the game
107  kGameStateWaitingForAnimation, // Waiting for a blocking animation with no stop frame to complete, then resuming script
108  kGameStateWaitingForAnimationToDelay, // Waiting for a blocking animation with no stop frame to complete, then going to delay
109  kGameStateWaitingForFacing, // Waiting for a blocking animation with a stop frame to complete, then resuming script
110  kGameStateWaitingForFacingToAnim, // Waiting for a blocking animation to complete, then playing _postFacingAnimDef and switching to kGameStateWaitingForAnimation
111  kGameStateQuit, // Quitting
112  kGameStateIdle, // Waiting for input events
113  kGameStateDelay, // Waiting for delay completion time
114  kGameStateScript, // Running a script
115  kGameStateScriptReset, // Resetting script interpreter into a new script
116  kGameStateGyroIdle, // Waiting for mouse movement to run a gyro
117  kGameStateGyroAnimation, // Animating a gyro
118 
119  kGameStatePanLeft,
120  kGameStatePanRight,
121 
122  kGameStateMenu,
123 };
124 
126  byte roomID;
127  byte lookupID;
128  short fwdAnimationID;
129  short revAnimationID;
130 };
131 
132 struct AnimationDef {
133  AnimationDef();
134 
135  int animNum; // May be negative if reversed
136  uint firstFrame;
137  uint lastFrame; // Inclusive
138 
139  Common::Rect constraintRect;
140 
141  Common::String animName;
142 };
143 
144 struct RoomDef {
150 
151  Common::String name;
152 };
153 
155  InteractionDef();
156 
157  Common::Rect rect;
158  uint16 interactionID;
159  uint16 objectType;
160 };
161 
163  Common::Array<InteractionDef> interactions;
164 };
165 
166 class MapLoader {
167 public:
168  virtual ~MapLoader();
169 
170  virtual void setRoomNumber(uint roomNumber) = 0;
171  virtual const MapScreenDirectionDef *getScreenDirection(uint screen, uint direction) = 0;
172  virtual void unload() = 0;
173 
174 protected:
175  static Common::SharedPtr<MapScreenDirectionDef> loadScreenDirectionDef(Common::ReadStream &stream);
176 };
177 
180 
181  uint panInteractionID;
182  uint clickInteractionID;
183  uint fpsOverride;
184  uint lastHighlightedItem;
185  uint animChangeFrameOffset;
186  uint animChangeNumFrames;
187  bool lmb;
188  bool lmbDrag;
189  bool esc;
190  bool exitToMenu;
191  bool animChangeSet;
192  bool isEntryScript;
193  bool puzzleWasSet;
194 };
195 
196 struct SfxSound {
197  Common::Array<byte> soundData;
200  Common::SharedPtr<AudioPlayer> audioPlayer;
201 };
202 
205 
206  uint frame;
208  int8 balance;
209  int32 volume;
210  bool isUpdate;
211 };
212 
213 struct SfxPlaylist {
214  SfxPlaylist();
215 
217 };
218 
219 struct SfxData {
220  SfxData();
221 
222  void reset();
223  void load(Common::SeekableReadStream &stream, Audio::Mixer *mixer);
224 
227  PlaylistMap_t playlists;
228  SoundMap_t sounds;
229 };
230 
232  SoundParams3D();
233 
234  uint minRange;
235  uint maxRange;
236 
237  // Not sure what this does. It's always shorter than the min range but after many tests, I've been
238  // unable to detect any level changes from altering this parameter.
239  uint unknownRange;
240 
241  void write(Common::WriteStream *stream) const;
242  void read(Common::ReadStream *stream);
243 };
244 
245 
246 struct SoundCache {
247  SoundCache();
248  ~SoundCache();
249 
251 
255 
256  bool isLoopActive;
257 };
258 
260  SoundInstance();
261  ~SoundInstance();
262 
263  Common::String name;
265 
266  uint id;
267 
268  int32 rampStartVolume;
269  int32 rampEndVolume;
270  int32 rampRatePerMSec;
271  uint32 rampStartTime;
272  bool rampTerminateOnCompletion;
273 
274  int32 volume;
275  int32 balance;
276 
277  uint effectiveVolume;
278  int32 effectiveBalance;
279 
280  bool is3D;
281  bool isLooping;
282  bool isSpeech;
283  bool restartWhenAudible;
284  bool tryToLoopWhenRestarted;
285  int32 x;
286  int32 y;
287 
288  SoundParams3D params3D;
289 
290  uint32 startTime;
291  uint32 endTime;
292  uint32 duration;
293 };
294 
297 
298  Common::String name;
299 
300  int32 volume;
301  int32 balance;
302 
303  uint frequency;
304  uint sceneChangesRemaining;
305 
306  void write(Common::WriteStream *stream) const;
307  void read(Common::ReadStream *stream);
308 };
309 
312 
313  bool operator==(const TriggeredOneShot &other) const;
314  bool operator!=(const TriggeredOneShot &other) const;
315 
316  uint soundID;
317  uint uniqueSlot;
318 
319  void write(Common::WriteStream *stream) const;
320  void read(Common::ReadStream *stream);
321 };
322 
324  ScoreSectionDef();
325 
326  Common::String musicFileName; // If empty, this is silent
327  Common::String nextSection;
328  int32 volumeOrDurationInSeconds;
329 };
330 
333 
334  ScoreSectionMap_t sections;
335 };
336 
338  StartConfigDef();
339 
340  uint disc;
341  uint room;
342  uint screen;
343  uint direction;
344 };
345 
348 
349  uint initialDelay;
350  uint repeatDelay;
351  bool lockInteractions;
352 
353  void write(Common::WriteStream *stream) const;
354  void read(Common::ReadStream *stream);
355 };
356 
358  StaticAnimation();
359 
360  AnimationDef animDefs[2];
361  StaticAnimParams params;
362 
363  uint32 nextStartTime;
364  uint currentAlternation;
365 };
366 
367 struct FrameData {
368  FrameData();
369 
370  uint32 frameIndex;
371  uint16 areaFrameIndex;
372  int8 roomNumber;
373  uint8 frameType; // 0x01 = Keyframe, 0x02 = Intra frame (not used in Schizm), 0x41 = Last frame
374  char areaID[4];
375 };
376 
377 struct FrameData2 {
378  FrameData2();
379 
380  int32 x;
381  int32 y;
382  int32 angle;
383  uint16 frameNumberInArea;
384  uint16 unknown; // Subarea or something?
385 };
386 
388  AnimFrameRange();
389 
390  uint animationNum;
391  uint firstFrame;
392  uint lastFrame; // Inclusive
393 };
394 
396  InventoryItem();
397 
399  uint itemID;
400  bool highlighted;
401 };
402 
403 struct Fraction {
404  Fraction();
405  Fraction(uint pNumerator, uint pDenominator);
406 
407  uint numerator;
408  uint denominator;
409 };
410 
411 enum LoadGameOutcome {
412  kLoadGameOutcomeSucceeded,
413 
414  kLoadGameOutcomeSaveDataCorrupted,
415 
416  kLoadGameOutcomeMissingVersion,
417  kLoadGameOutcomeInvalidVersion,
418  kLoadGameOutcomeSaveIsTooNew,
419  kLoadGameOutcomeSaveIsTooOld,
420 };
421 
422 // State that is swapped when switching between characters in Schizm
424  struct InventoryItem {
425  InventoryItem();
426 
427  uint itemID;
428  bool highlighted;
429 
430  void write(Common::WriteStream *stream) const;
431  void read(Common::ReadStream *stream);
432  };
433 
434  struct Sound {
435  Sound();
436 
437  Common::String name;
438  uint id;
439  int32 volume;
440  int32 balance;
441 
442  bool is3D;
443  bool isLooping;
444  bool tryToLoopWhenRestarted;
445  bool isSpeech;
446 
447  int32 x;
448  int32 y;
449 
450  SoundParams3D params3D;
451 
452  void write(Common::WriteStream *stream) const;
453  void read(Common::ReadStream *stream, uint saveGameVersion);
454  };
455 
457 
458  uint roomNumber;
459  uint screenNumber;
460  uint direction;
461  uint disc;
462  bool havePendingPostSwapScreenReset;
463 
464  uint loadedAnimation;
465  uint animDisplayingFrame;
466  bool haveIdleAnimationLoop;
467  uint idleAnimNum;
468  uint idleFirstFrame;
469  uint idleLastFrame;
470 
471  int musicTrack;
472 
473  Common::String scoreTrack;
474  Common::String scoreSection;
475  bool musicActive;
476  bool musicMuteDisabled;
477 
478  int32 musicVolume;
479  int32 animVolume;
480 
482  Common::Array<Sound> sounds;
483  Common::Array<RandomAmbientSound> randomAmbientSounds;
484 };
485 
489 
490  uint8 page;
491  uint8 slot;
492  uint8 itemID;
493 
494  void write(Common::WriteStream *stream) const;
495  void read(Common::ReadStream *stream, uint saveGameVersion);
496  };
497 
500 
501  uint32 locationID;
502  uint8 itemID;
503 
504  void write(Common::WriteStream *stream) const;
505  void read(Common::ReadStream *stream, uint saveGameVersion);
506  };
507 
509 
510  void write(Common::WriteStream *stream) const;
511  LoadGameOutcome read(Common::ReadStream *stream);
512 
513  static const uint kSaveGameIdentifier = 0x53566372;
514  static const uint kSaveGameCurrentVersion = 10;
515  static const uint kSaveGameEarliestSupportedVersion = 2;
516  static const uint kMaxStates = 2;
517 
518  static Common::String safeReadString(Common::ReadStream *stream);
519  static void writeString(Common::WriteStream *stream, const Common::String &str);
520 
521  uint hero;
522  uint swapOutRoom;
523  uint swapOutScreen;
524  uint swapOutDirection;
525  uint8 inventoryPage;
526  uint8 inventoryActiveItem;
527 
528  uint numStates;
530 
531  bool escOn;
532 
533  StaticAnimParams pendingStaticAnimParams;
534  SoundParams3D pendingSoundParams3D;
535 
536  int32 listenerX;
537  int32 listenerY;
538  int32 listenerAngle;
539 
540  Common::Array<TriggeredOneShot> triggeredOneShots;
542 
547 };
548 
549 enum OSEventType {
550  kOSEventTypeInvalid,
551 
552  kOSEventTypeMouseMove,
553  kOSEventTypeLButtonDown,
554  kOSEventTypeLButtonUp,
555 
556  kOSEventTypeKeymappedEvent,
557 };
558 
559 enum KeymappedEvent {
560  kKeymappedEventNone,
561 
562  kKeymappedEventEscape,
563  kKeymappedEventHelp,
564  kKeymappedEventSaveGame,
565  kKeymappedEventLoadGame,
566  kKeymappedEventSoundSettings,
567  kKeymappedEventQuit,
568  kKeymappedEventPause,
569  kKeymappedEventMusicToggle,
570  kKeymappedEventSoundToggle,
571  kKeymappedEventMusicVolumeDown,
572  kKeymappedEventMusicVolumeUp,
573  kKeymappedEventSoundVolumeDown,
574  kKeymappedEventSoundVolumeUp,
575 
576  kKeymappedEventSkipAnimation,
577 
578  kKeymappedEventPutItem,
579 };
580 
581 struct OSEvent {
582  OSEvent();
583 
584  OSEventType type;
585  Common::Point pos;
586  KeymappedEvent keymappedEvent;
587  uint32 timestamp;
588 };
589 
590 struct TextStyleDef {
591  Common::String fontName;
592  uint size;
593  uint unknown1;
594  uint unknown2;
595  uint unknown3; // Seems to always be 0 for English, other values for other languages
596  uint colorRGB;
597  uint shadowColorRGB;
598  uint alignment; // Modulo 10 seems to be alignment: 0 = left, 1 = center, 2 = right
599  uint unknown5; // Possibly drop shadow offset
600 };
601 
602 struct UILabelDef {
603  Common::String lineID;
604  Common::String styleDefID;
605  uint graphicLeft;
606  uint graphicTop;
607  uint graphicWidth;
608  uint graphicHeight;
609 };
610 
612  FontCacheItem();
613 
614  Common::String fname;
615  uint size;
616 
617  const Graphics::Font *font;
619 };
620 
623 
625  struct FrameDef {
626  uint imageIndex;
627  uint delay;
628  };
629 
632 
634  Common::SharedPtr<Graphics::WinCursorGroup> cursorGroupKeepAlive;
635 };
636 
637 class Runtime {
638 public:
639  friend class RuntimeMenuInterface;
640 
641  enum CharSet {
642  kCharSetLatin,
643  kCharSetGreek,
644  kCharSetCyrillic,
645  kCharSetJapanese,
646  kCharSetChineseTraditional,
647  kCharSetChineseSimplified,
648  };
649 
650  Runtime(OSystem *system, Audio::Mixer *mixer, MidiDriver *midiDrv, const Common::FSNode &rootFSNode, VCruiseGameID gameID, Common::Language defaultLanguage);
651  virtual ~Runtime();
652 
653  void initSections(const Common::Rect &gameRect, const Common::Rect &menuRect, const Common::Rect &trayRect, const Common::Rect &subtitleRect, const Common::Rect &fullscreenMenuRect, const Graphics::PixelFormat &pixFmt);
654 
655  void loadCursors(const char *exeName);
656  void setDebugMode(bool debugMode);
657  void setFastAnimationMode(bool fastAnimationMode);
658  void setPreloadSounds(bool preloadSounds);
659  void setLowQualityGraphicsMode(bool lowQualityGraphicsMode);
660 
661  bool runFrame();
662  void drawFrame();
663 
664  void onLButtonDown(int16 x, int16 y);
665  void onLButtonUp(int16 x, int16 y);
666  void onMouseMove(int16 x, int16 y);
667  void onKeymappedEvent(KeymappedEvent evt);
668 
669  bool canSave(bool onCurrentScreen) const;
670  bool canLoad() const;
671 
672  void recordSaveGameSnapshot();
673  void recordSounds(SaveGameSwappableState &state);
674  void restoreSaveGameSnapshot();
675  Common::SharedPtr<SaveGameSnapshot> generateNewGameSnapshot() const;
676 
677  void saveGame(Common::WriteStream *stream) const;
678  LoadGameOutcome loadGame(Common::ReadStream *stream);
679 
680  bool bootGame(bool newGame);
681  static void resolveCodePageForLanguage(Common::Language lang, Common::CodePage &outCodePage, CharSet &outCharSet);
682 
683  void drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect);
684  void getLabelDef(const Common::String &labelID, const Graphics::Font *&outFont, const Common::String *&outTextUTF8, uint32 &outColor, uint32 &outShadowColor, uint32 &outShadowOffset);
685 
686  void onMidiTimer();
687 
688 private:
689  enum IndexParseType {
690  kIndexParseTypeNone,
691  kIndexParseTypeRoom,
692  kIndexParseTypeRRoom, // Rectangle room (constrains animation areas)
693  kIndexParseTypeYRoom, // Yes room (variable/ID mappings)
694  kIndexParseTypeVRoom, // Value room (value/ID mappings?)
695  kIndexParseTypeTRoom, // Text
696  kIndexParseTypeCRoom, // Const
697  kIndexParseTypeSRoom, // Sound
698  kIndexParseTypeNameRoom,
699  };
700 
701  enum AnimDecoderState {
702  kAnimDecoderStateStopped,
703  kAnimDecoderStatePlaying,
704  kAnimDecoderStatePaused,
705  };
706 
707  struct IndexPrefixTypePair {
708  const char *prefix;
709  IndexParseType parseType;
710  };
711 
712  struct RenderSection {
714  Common::Rect rect;
715  Graphics::PixelFormat pixFmt;
716 
717  void init(const Common::Rect &paramRect, const Graphics::PixelFormat &fmt);
718  };
719 
720  struct Gyro {
721  static const uint kMaxPreviousStates = 3;
722 
723  int32 currentState;
724  int32 requiredState;
725  int32 previousStates[kMaxPreviousStates];
726  int32 requiredPreviousStates[kMaxPreviousStates];
727  uint numPreviousStates;
728  uint numPreviousStatesRequired;
729  bool wrapAround;
730  bool requireState;
731 
732  Gyro();
733 
734  void reset();
735  void logState();
736  };
737 
738  struct GyroState {
739  GyroState();
740 
741  void reset();
742 
743  static const uint kNumGyros = 5;
744 
745  Gyro gyros[kNumGyros];
746 
747  uint completeInteraction;
748  uint failureInteraction;
749  uint frameSeparation;
750 
751  uint activeGyro;
752  uint dragMargin;
753  uint maxValue;
754 
755  AnimationDef negAnim;
756  AnimationDef posAnim;
757  bool isVertical;
758 
759  Common::Point dragBasePoint;
760  uint dragBaseState;
761  int32 dragCurrentState;
762  bool isWaitingForAnimation;
763  };
764 
765  enum PanoramaCursorFlags {
766  kPanCursorDraggableHoriz = (1 << 0),
767  kPanCursorDraggableUp = (1 << 1),
768  kPanCursorDraggableDown = (1 << 2),
769 
770  kPanCursorDirectionUp = (0 << 3),
771  kPanCursorDirectionLeft = (1 << 3),
772  kPanCursorDirectionRight = (2 << 3),
773  kPanCursorDirectionDown = (3 << 3),
774 
775  kPanCursorMaxCount = (1 << 5),
776  };
777 
778  enum PanoramaState {
779  kPanoramaStateInactive,
780 
781  kPanoramaStatePanningUncertainDirection,
782 
783  kPanoramaStatePanningLeft,
784  kPanoramaStatePanningRight,
785  kPanoramaStatePanningUp,
786  kPanoramaStatePanningDown,
787  };
788 
789  enum InGameMenuState {
790  kInGameMenuStateInvisible,
791  kInGameMenuStateVisible,
792  kInGameMenuStateHoveringInactive,
793  kInGameMenuStateHoveringActive,
794  kInGameMenuStateClickingOver, // Mouse was pressed on a button and is holding on it
795  kInGameMenuStateClickingNotOver, // Mouse was pressed on a button and dragged off
796  kInGameMenuStateClickingInactive,
797  };
798 
799  enum SoundLoopBehavior {
800  kSoundLoopBehaviorNo,
801  kSoundLoopBehaviorYes,
802  kSoundLoopBehaviorAuto,
803  };
804 
805  static const uint kPanLeftInteraction = 1;
806  static const uint kPanDownInteraction = 2;
807  static const uint kPanRightInteraction = 3;
808  static const uint kPanUpInteraction = 4;
809 
810  static const uint kPanoramaLeftFlag = 1;
811  static const uint kPanoramaRightFlag = 2;
812  static const uint kPanoramaUpFlag = 4;
813  static const uint kPanoramaDownFlag = 8;
814  static const uint kPanoramaHorizFlags = (kPanoramaLeftFlag | kPanoramaRightFlag);
815 
816  static const uint kNumInventorySlots = 6;
817  static const uint kNumInventoryPages = 8;
818 
819  typedef int32 ScriptArg_t;
820  typedef int32 StackInt_t;
821 
822  struct StackValue {
823  enum StackValueType {
824  kNumber,
825  kString,
826  };
827 
828  union ValueUnion {
829  StackInt_t i;
830  Common::String s;
831 
832  ValueUnion();
833  explicit ValueUnion(StackInt_t iVal);
834  explicit ValueUnion(const Common::String &strVal);
835  explicit ValueUnion(Common::String &&strVal);
836  ~ValueUnion();
837  };
838 
839  StackValue();
840  StackValue(const StackValue &other);
841  StackValue(StackValue &&other);
842  explicit StackValue(StackInt_t i);
843  explicit StackValue(const Common::String &str);
844  explicit StackValue(Common::String &&str);
845  ~StackValue();
846 
847  StackValue &operator=(const StackValue &other);
848  StackValue &operator=(StackValue &&other);
849 
850  StackValueType type;
851  ValueUnion value;
852  };
853 
854  struct CallStackFrame {
855  CallStackFrame();
856 
858  uint _nextInstruction;
859  };
860 
861  struct SubtitleDef {
862  SubtitleDef();
863 
864  uint8 color[3];
865  uint unknownValue1;
866  uint durationInDeciseconds;
867  Common::String str;
868  };
869 
870  struct SubtitleQueueItem {
871  Common::U32String str;
872  uint8 color[3];
873  uint32 startTime;
874  uint32 endTime;
875  };
876 
877  bool runIdle();
878  bool runDelay();
879  bool runHorizontalPan(bool isRight);
880  bool runScript();
881  bool requireAvailableStack(uint n);
882  bool runWaitForAnimation();
883  bool runWaitForAnimationToDelay();
884  bool runWaitForFacing();
885  bool runWaitForFacingToAnim();
886  bool runGyroIdle();
887  bool runGyroAnimation();
888  void exitGyroIdle();
889  void continuePlayingAnimation(bool loop, bool useStopFrame, bool &outEndedAnimation);
890  void drawSectionToScreen(const RenderSection &section, const Common::Rect &rect);
891  void commitSectionToScreen(const RenderSection &section, const Common::Rect &rect);
892  void terminateScript();
893  void quitToMenu();
894  RoomScriptSet *getRoomScriptSetForCurrentRoom() const;
895  bool checkCompletionConditions();
896 
897  void startTerminatingHorizontalPan(bool isRight);
898 
899  bool popOSEvent(OSEvent &evt);
900  void queueOSEvent(const OSEvent &evt);
901 
902  void processUniversalKeymappedEvents(KeymappedEvent evt);
903 
904  void loadReahSchizmIndex();
905  void loadAD2044ExecutableResources();
906  void findWaves();
907  void loadConfig(const char *cfgPath);
908  void loadScore();
909  void loadDuplicateRooms();
910  void loadAllSchizmScreenNames();
911  Common::SharedPtr<SoundInstance> loadWave(const Common::String &soundName, uint soundID, const Common::ArchiveMemberPtr &archiveMemberPtr);
912  SoundCache *loadCache(SoundInstance &sound);
913  void resolveSoundByName(const Common::String &soundName, bool load, StackInt_t &outSoundID, SoundInstance *&outWave);
914  SoundInstance *resolveSoundByID(uint soundID);
915  void resolveSoundByNameOrID(const StackValue &stackValue, bool load, StackInt_t &outSoundID, SoundInstance *&outWave);
916 
917  void changeToScreen(uint roomNumber, uint screenNumber);
918  void clearIdleAnimations();
919  void changeHero();
920  void changeToExamineItem();
921  void returnFromExaminingItem();
922  bool triggerPreIdleActions();
923  void returnToIdleState();
924  void changeToCursor(const Common::SharedPtr<AnimatedCursor> &cursor);
925  void refreshCursor(uint32 currentTime);
926  bool dischargeIdleMouseMove();
927  bool dischargeIdleMouseDown();
928  bool dischargeIdleClick();
929  void loadFrameData(Common::SeekableReadStream *stream);
930  void loadFrameData2(Common::SeekableReadStream *stream);
931  void loadTabData(Common::HashMap<int, AnimFrameRange> &animIDToFrameRangeMap, uint animNumber, Common::SeekableReadStream *stream);
932 
933  void changeMusicTrack(int musicID);
934  void startScoreSection();
935  void setMusicMute(bool muted);
936 
937  void changeAnimation(const AnimationDef &animDef, bool consumeFPSOverride);
938  void changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride);
939  void changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride, const Fraction &defaultFrameRate);
940  void applyAnimationVolume();
941 
942  void setSound3DParameters(SoundInstance &sound, int32 x, int32 y, const SoundParams3D &soundParams3D);
943  void triggerSound(SoundLoopBehavior loopBehavior, SoundInstance &sound, int32 volume, int32 balance, bool is3D, bool isSpeech);
944  void triggerSoundRamp(SoundInstance &sound, uint durationMSec, int32 newVolume, bool terminateOnCompletion);
945  void stopSound(SoundInstance &sound);
946  void convertLoopingSoundToNonLooping(SoundInstance &sound);
947  void updateSounds(uint32 timestamp);
948  void updateSubtitles();
949  void update3DSounds();
950  bool computeEffectiveVolumeAndBalance(SoundInstance &snd);
951  void triggerAmbientSounds();
952  uint decibelsToLinear(int db, uint baseVolume, uint maxVolume) const;
953  int32 getSilentSoundVolume() const;
954  int32 getDefaultSoundVolume() const;
955  uint applyVolumeScale(int32 volume) const;
956  int applyBalanceScale(int32 balance) const;
957 
958  void triggerWaveSubtitles(const SoundInstance &sound, const Common::String &id);
959  void stopSubtitles();
960 
961  AnimationDef stackArgsToAnimDef(const StackInt_t *args) const;
962  void consumeAnimChangeAndAdjustAnim(AnimationDef &animDef);
963  void pushAnimDef(const AnimationDef &animDef);
964 
965  void activateScript(const Common::SharedPtr<Script> &script, bool isEntryScript, const ScriptEnvironmentVars &envVars);
966  Common::SharedPtr<ScriptSet> compileSchizmLogicSet(const uint *roomNumbers, uint numRooms) const;
967 
968  bool parseIndexDef(IndexParseType parseType, uint roomNumber, const Common::String &key, const Common::String &value);
969  void allocateRoomsUpTo(uint roomNumber);
970 
971  void drawDebugOverlay();
972 
973  Common::SharedPtr<Script> findScriptForInteraction(uint interactionID) const;
974 
975  void detectPanoramaDirections();
976  void detectPanoramaMouseMovement(uint32 timestamp);
977  void panoramaActivate();
978 
979  bool computeFaceDirectionAnimation(uint desiredDirection, const AnimationDef *&outAnimDef, uint &outInitialFrame, uint &outStopFrame);
980 
981  void inventoryAddItem(uint item);
982  void inventoryRemoveItem(uint item);
983  void clearScreen();
984  void redrawTray();
985  void clearTray();
986  void redrawSubtitleSection();
987  void clearSubtitleSection();
988  void drawSubtitleText(const Common::Array<Common::U32String> &lines, const uint8 (&color)[3]);
989  void drawInventory(uint slot);
990  void drawCompass();
991  bool isTrayVisible() const;
992  void resetInventoryHighlights();
993  void loadInventoryFromPage();
994  void copyInventoryToPage();
995  void cheatPutItem();
996  static uint32 getLocationForScreen(uint roomNumber, uint screenNumber);
997  void updatePlacedItemCache();
998  void drawPlacedItemGraphic();
999  void clearPlacedItemGraphic();
1000  void drawActiveItemGraphic();
1001  void clearActiveItemGraphic();
1002  void drawInventoryItemGraphic(uint slot);
1003  void clearInventoryItemGraphic(uint slot);
1004  void dropActiveItem();
1005  void pickupPlacedItem();
1006  void stashActiveItemToInventory(uint slot);
1007  void pickupInventoryItem(uint slot);
1008 
1009  void getFileNamesForItemGraphic(uint itemID, Common::String &outGraphicFileName, Common::String &outAlphaFileName) const;
1010  Common::SharedPtr<Graphics::Surface> loadGraphic(const Common::String &graphicName, const Common::String &alphaName, bool required);
1011  Common::SharedPtr<Graphics::Surface> loadGraphicFromPath(const Common::Path &path, bool required);
1012 
1013  bool loadSubtitles(Common::CodePage codePage, bool guessCodePage);
1014 
1015  void changeToMenuPage(MenuPage *menuPage);
1016 
1017  void checkInGameMenuHover();
1018  void dismissInGameMenu();
1019  void dischargeInGameMenuMouseUp();
1020  void drawInGameMenuButton(uint element);
1021 
1022  const Graphics::Font *resolveFont(const Common::String &textStyle, uint size);
1023 
1024  bool resolveCircuitPuzzleInteraction(const Common::Point &relMouse, Common::Point &outCoord, bool &outIsDown, Common::Rect &outHighlightRect) const;
1025  void clearCircuitPuzzle();
1026  void clearCircuitHighlightRect(const Common::Rect &rect);
1027  void drawCircuitHighlightRect(const Common::Rect &rect);
1028  static Common::Rect padCircuitInteractionRect(const Common::Rect &rect);
1029 
1030  static Common::SharedPtr<AnimatedCursor> winCursorGroupToAnimatedCursor(const Common::SharedPtr<Graphics::WinCursorGroup> &cursorGroup);
1031  static Common::SharedPtr<AnimatedCursor> aniFileToAnimatedCursor(Image::AniDecoder &aniDecoder);
1032  static Common::SharedPtr<AnimatedCursor> staticCursorToAnimatedCursor(const Common::SharedPtr<Graphics::Cursor> &cursor);
1033 
1034  // Script things
1035  void scriptOpNumber(ScriptArg_t arg);
1036  void scriptOpRotate(ScriptArg_t arg);
1037  void scriptOpAngle(ScriptArg_t arg);
1038  void scriptOpAngleGGet(ScriptArg_t arg);
1039  void scriptOpSpeed(ScriptArg_t arg);
1040  void scriptOpSAnimL(ScriptArg_t arg);
1041  void scriptOpChangeL(ScriptArg_t arg);
1042 
1043  void scriptOpAnimR(ScriptArg_t arg);
1044  void scriptOpAnimF(ScriptArg_t arg);
1045  void scriptOpAnimN(ScriptArg_t arg);
1046  void scriptOpAnimG(ScriptArg_t arg);
1047  void scriptOpAnimS(ScriptArg_t arg);
1048  void scriptOpAnim(ScriptArg_t arg);
1049 
1050  void scriptOpStatic(ScriptArg_t arg);
1051  void scriptOpVarLoad(ScriptArg_t arg);
1052  void scriptOpVarStore(ScriptArg_t arg);
1053  void scriptOpVarAddAndStore(ScriptArg_t arg);
1054  void scriptOpVarGlobalLoad(ScriptArg_t arg);
1055  void scriptOpVarGlobalStore(ScriptArg_t arg);
1056 
1057  void scriptOpItemCheck(ScriptArg_t arg);
1058  void scriptOpItemRemove(ScriptArg_t arg);
1059  void scriptOpItemHighlightSet(ScriptArg_t arg);
1060  void scriptOpItemAdd(ScriptArg_t arg);
1061  void scriptOpItemHaveSpace(ScriptArg_t arg);
1062  void scriptOpItemClear(ScriptArg_t arg);
1063 
1064  void scriptOpSetCursor(ScriptArg_t arg);
1065  void scriptOpSetRoom(ScriptArg_t arg);
1066  void scriptOpLMB(ScriptArg_t arg);
1067  void scriptOpLMB1(ScriptArg_t arg);
1068  void scriptOpSoundS1(ScriptArg_t arg);
1069  void scriptOpSoundS2(ScriptArg_t arg);
1070  void scriptOpSoundS3(ScriptArg_t arg);
1071  void scriptOpSoundL1(ScriptArg_t arg);
1072  void scriptOpSoundL2(ScriptArg_t arg);
1073  void scriptOpSoundL3(ScriptArg_t arg);
1074  void scriptOp3DSoundS2(ScriptArg_t arg);
1075  void scriptOp3DSoundL2(ScriptArg_t arg);
1076  void scriptOp3DSoundL3(ScriptArg_t arg);
1077  void scriptOpStopAL(ScriptArg_t arg);
1078  void scriptOpRange(ScriptArg_t arg);
1079  void scriptOpAddXSound(ScriptArg_t arg);
1080  void scriptOpClrXSound(ScriptArg_t arg);
1081  void scriptOpStopSndLA(ScriptArg_t arg);
1082  void scriptOpStopSndLO(ScriptArg_t arg);
1083 
1084  void scriptOpMusic(ScriptArg_t arg);
1085  void scriptOpMusicVolRamp(ScriptArg_t arg);
1086  void scriptOpParm0(ScriptArg_t arg);
1087  void scriptOpParm1(ScriptArg_t arg);
1088  void scriptOpParm2(ScriptArg_t arg);
1089  void scriptOpParm3(ScriptArg_t arg);
1090  void scriptOpParmG(ScriptArg_t arg);
1091  void scriptOpSParmX(ScriptArg_t arg);
1092  void scriptOpSAnimX(ScriptArg_t arg);
1093 
1094  void scriptOpVolumeDn2(ScriptArg_t arg);
1095  void scriptOpVolumeDn3(ScriptArg_t arg);
1096  void scriptOpVolumeDn4(ScriptArg_t arg);
1097  void scriptOpVolumeUp3(ScriptArg_t arg);
1098  void scriptOpRandom(ScriptArg_t arg);
1099  void scriptOpDrop(ScriptArg_t arg);
1100  void scriptOpDup(ScriptArg_t arg);
1101  void scriptOpSwap(ScriptArg_t arg);
1102  void scriptOpSay1(ScriptArg_t arg);
1103  void scriptOpSay2(ScriptArg_t arg);
1104  void scriptOpSay3(ScriptArg_t arg);
1105  void scriptOpSay3Get(ScriptArg_t arg);
1106  void scriptOpSetTimer(ScriptArg_t arg);
1107  void scriptOpGetTimer(ScriptArg_t arg);
1108  void scriptOpDelay(ScriptArg_t arg);
1109  void scriptOpLoSet(ScriptArg_t arg);
1110  void scriptOpLoGet(ScriptArg_t arg);
1111  void scriptOpHiSet(ScriptArg_t arg);
1112  void scriptOpHiGet(ScriptArg_t arg);
1113 
1114  void scriptOpNot(ScriptArg_t arg);
1115  void scriptOpAnd(ScriptArg_t arg);
1116  void scriptOpOr(ScriptArg_t arg);
1117  void scriptOpAdd(ScriptArg_t arg);
1118  void scriptOpSub(ScriptArg_t arg);
1119  void scriptOpNegate(ScriptArg_t arg);
1120  void scriptOpCmpEq(ScriptArg_t arg);
1121  void scriptOpCmpLt(ScriptArg_t arg);
1122  void scriptOpCmpGt(ScriptArg_t arg);
1123 
1124  void scriptOpBitLoad(ScriptArg_t arg);
1125  void scriptOpBitSet0(ScriptArg_t arg);
1126  void scriptOpBitSet1(ScriptArg_t arg);
1127 
1128  void scriptOpDisc1(ScriptArg_t arg);
1129  void scriptOpDisc2(ScriptArg_t arg);
1130  void scriptOpDisc3(ScriptArg_t arg);
1131 
1132  void scriptOpGoto(ScriptArg_t arg);
1133 
1134  void scriptOpEscOn(ScriptArg_t arg);
1135  void scriptOpEscOff(ScriptArg_t arg);
1136  void scriptOpEscGet(ScriptArg_t arg);
1137  void scriptOpBackStart(ScriptArg_t arg);
1138  void scriptOpSaveAs(ScriptArg_t arg);
1139  void scriptOpSave0(ScriptArg_t arg);
1140  void scriptOpExit(ScriptArg_t arg);
1141  void scriptOpAllowSaves(ScriptArg_t arg);
1142 
1143  void scriptOpAnimName(ScriptArg_t arg);
1144  void scriptOpValueName(ScriptArg_t arg);
1145  void scriptOpVarName(ScriptArg_t arg);
1146  void scriptOpSoundName(ScriptArg_t arg);
1147  void scriptOpCursorName(ScriptArg_t arg);
1148  void scriptOpDubbing(ScriptArg_t arg);
1149 
1150  void scriptOpCheckValue(ScriptArg_t arg);
1151  void scriptOpJump(ScriptArg_t arg);
1152 
1153  void scriptOpVerticalPanSet(bool *flags);
1154  void scriptOpVerticalPanGet();
1155 
1156  // Schizm ops
1157  void scriptOpCallFunction(ScriptArg_t arg);
1158 
1159  void scriptOpMusicStop(ScriptArg_t arg);
1160  void scriptOpMusicPlayScore(ScriptArg_t arg);
1161  void scriptOpScoreAlways(ScriptArg_t arg);
1162  void scriptOpScoreNormal(ScriptArg_t arg);
1163  void scriptOpSndPlay(ScriptArg_t arg);
1164  void scriptOpSndPlayEx(ScriptArg_t arg);
1165  void scriptOpSndPlay3D(ScriptArg_t arg);
1166  void scriptOpSndPlaying(ScriptArg_t arg);
1167  void scriptOpSndWait(ScriptArg_t arg);
1168  void scriptOpSndHalt(ScriptArg_t arg);
1169  void scriptOpSndToBack(ScriptArg_t arg);
1170  void scriptOpSndStop(ScriptArg_t arg);
1171  void scriptOpSndStopAll(ScriptArg_t arg);
1172  void scriptOpSndAddRandom(ScriptArg_t arg);
1173  void scriptOpSndClearRandom(ScriptArg_t arg);
1174  void scriptOpVolumeAdd(ScriptArg_t arg);
1175  void scriptOpVolumeChange(ScriptArg_t arg);
1176  void scriptOpAnimVolume(ScriptArg_t arg);
1177  void scriptOpAnimChange(ScriptArg_t arg);
1178  void scriptOpScreenName(ScriptArg_t arg);
1179  void scriptOpExtractByte(ScriptArg_t arg);
1180  void scriptOpInsertByte(ScriptArg_t arg);
1181  void scriptOpString(ScriptArg_t arg);
1182  void scriptOpCmpNE(ScriptArg_t arg);
1183  void scriptOpCmpLE(ScriptArg_t arg);
1184  void scriptOpCmpGE(ScriptArg_t arg);
1185  void scriptOpReturn(ScriptArg_t arg);
1186  void scriptOpSpeech(ScriptArg_t arg);
1187  void scriptOpSpeechEx(ScriptArg_t arg);
1188  void scriptOpSpeechTest(ScriptArg_t arg);
1189  void scriptOpSay(ScriptArg_t arg);
1190  void scriptOpRandomInclusive(ScriptArg_t arg);
1191  void scriptOpHeroOut(ScriptArg_t arg);
1192  void scriptOpHeroGetPos(ScriptArg_t arg);
1193  void scriptOpHeroSetPos(ScriptArg_t arg);
1194  void scriptOpHeroGet(ScriptArg_t arg);
1195  void scriptOpGarbage(ScriptArg_t arg);
1196  void scriptOpGetRoom(ScriptArg_t arg);
1197  void scriptOpBitAnd(ScriptArg_t arg);
1198  void scriptOpBitOr(ScriptArg_t arg);
1199  void scriptOpAngleGet(ScriptArg_t arg);
1200  void scriptOpIsDVDVersion(ScriptArg_t arg);
1201  void scriptOpIsCDVersion(ScriptArg_t arg);
1202  void scriptOpDisc(ScriptArg_t arg);
1203  void scriptOpHidePanel(ScriptArg_t arg);
1204  void scriptOpRotateUpdate(ScriptArg_t arg);
1205  void scriptOpMul(ScriptArg_t arg);
1206  void scriptOpDiv(ScriptArg_t arg);
1207  void scriptOpMod(ScriptArg_t arg);
1208  void scriptOpGetDigit(ScriptArg_t arg);
1209  void scriptOpPuzzleInit(ScriptArg_t arg);
1210  void scriptOpPuzzleCanPress(ScriptArg_t arg);
1211  void scriptOpPuzzleDoMove1(ScriptArg_t arg);
1212  void scriptOpPuzzleDoMove2(ScriptArg_t arg);
1213  void scriptOpPuzzleDone(ScriptArg_t arg);
1214  void scriptOpPuzzleWhoWon(ScriptArg_t arg);
1215  void scriptOpFn(ScriptArg_t arg);
1216  void scriptOpItemHighlightSetTrue(ScriptArg_t arg);
1217 
1218  // AD2044 ops
1219  void scriptOpAnimAD2044(bool isForward);
1220  void scriptOpAnimT(ScriptArg_t arg);
1221  void scriptOpAnimForward(ScriptArg_t arg);
1222  void scriptOpAnimReverse(ScriptArg_t arg);
1223  void scriptOpAnimKForward(ScriptArg_t arg);
1224  void scriptOpNoUpdate(ScriptArg_t arg);
1225  void scriptOpNoClear(ScriptArg_t arg);
1226  void scriptOpSay1_AD2044(ScriptArg_t arg);
1227  void scriptOpSay2_AD2044(ScriptArg_t arg);
1228  void scriptOpSay1Rnd(ScriptArg_t arg);
1229  void scriptOpM(ScriptArg_t arg);
1230  void scriptOpEM(ScriptArg_t arg);
1231  void scriptOpSE(ScriptArg_t arg);
1232  void scriptOpSDot(ScriptArg_t arg);
1233  void scriptOpE(ScriptArg_t arg);
1234  void scriptOpDot(ScriptArg_t arg);
1235  void scriptOpSound(ScriptArg_t arg);
1236  void scriptOpISound(ScriptArg_t arg);
1237  void scriptOpUSound(ScriptArg_t arg);
1238  void scriptOpSayCycle_AD2044(const StackInt_t *values, uint numValues);
1239  void scriptOpSay2K(ScriptArg_t arg);
1240  void scriptOpSay3K(ScriptArg_t arg);
1241  void scriptOpRGet(ScriptArg_t arg);
1242  void scriptOpRSet(ScriptArg_t arg);
1243  void scriptOpEndRSet(ScriptArg_t arg);
1244  void scriptOpStop(ScriptArg_t arg);
1245 
1246  Common::Array<Common::SharedPtr<AnimatedCursor> > _cursors; // Cursors indexed as CURSOR_CUR_##
1247  Common::Array<Common::SharedPtr<AnimatedCursor> > _cursorsShort; // Cursors indexed as CURSOR_#
1248 
1249  InventoryItem _inventory[kNumInventorySlots];
1250  InventoryItem _inventoryPages[kNumInventoryPages][kNumInventorySlots];
1251  Common::HashMap<uint32, uint8> _placedItems;
1252  uint8 _inventoryActivePage;
1253  InventoryItem _inventoryActiveItem;
1254  InventoryItem _inventoryPlacedItemCache;
1255  Common::Rect _placedItemRect;
1256 
1257  Common::SharedPtr<Graphics::Surface> _trayCompassGraphic;
1258  Common::SharedPtr<Graphics::Surface> _trayBackgroundGraphic;
1259  Common::SharedPtr<Graphics::Surface> _trayHighlightGraphic;
1260  Common::SharedPtr<Graphics::Surface> _trayCornerGraphic;
1261  Common::SharedPtr<Graphics::Surface> _backgroundGraphic;
1262 
1264 
1265  uint _panCursors[kPanCursorMaxCount];
1266 
1268  Common::HashMap<StackInt_t, uint> _scriptCursorIDToResourceIDOverride;
1269 
1270  OSystem *_system;
1271  uint _roomNumber; // Room number can be changed independently of the loaded room, the screen doesn't change until a command changes it
1272  uint _screenNumber;
1273  uint _direction;
1274  uint _hero;
1275  uint _disc;
1276 
1277  uint _swapOutRoom;
1278  uint _swapOutScreen;
1279  uint _swapOutDirection;
1280 
1281  GyroState _gyros;
1282 
1283  AnimationDef _panLeftAnimationDef;
1284  AnimationDef _panRightAnimationDef;
1285  bool _haveHorizPanAnimations;
1286  bool _havePanUpFromDirection[kNumDirections];
1287  bool _havePanDownFromDirection[kNumDirections];
1288 
1289  StaticAnimation _idleAnimations[kNumDirections];
1290  bool _haveIdleAnimations[kNumDirections];
1291  bool _haveIdleStaticAnimation;
1292  bool _keepStaticAnimationInIdle;
1293  Common::String _idleCurrentStaticAnimation;
1294  StaticAnimParams _pendingStaticAnimParams;
1295 
1296  uint32 _delayCompletionTime;
1297 
1298  AnimationDef _postFacingAnimDef;
1299 
1300  Common::SharedPtr<CircuitPuzzle> _circuitPuzzle;
1301  AnimationDef _circuitPuzzleBlockAnimation;
1302  AnimationDef _circuitPuzzleConnectAnimation;
1303 
1304  Common::HashMap<uint32, int32> _variables;
1306 
1307  uint _panoramaDirectionFlags;
1308 
1309  uint _loadedRoomNumber;
1310  uint _activeScreenNumber;
1311  bool _havePendingScreenChange;
1312  bool _forceScreenChange;
1313 
1314  // returnToIdleState executes any actions that must be executed upon returning to idle state from either
1315  // a panorama or the first script that executes upon reaching a screen.
1316  //
1317  // Unfortunately, this was done slightly prematurely since Schizm plays idle animations during pre-idle
1318  // delays and Reah never needs to do that, so _havePendingPreIdleActions exists to handle those actions
1319  // during pre-idle upon arriving at a screen.
1320  //
1321  // Pre-idle actions are executed once upon either entering Idle OR Delay state.
1322  bool _havePendingPreIdleActions;
1323  bool _havePendingReturnToIdleState;
1324  bool _havePendingPostSwapScreenReset;
1325 
1326  bool _havePendingCompletionCheck;
1327  GameState _gameState;
1328 
1329  Common::SharedPtr<MenuPage> _menuPage;
1330  Common::SharedPtr<MenuInterface> _menuInterface;
1331 
1332  bool _havePendingPlayAmbientSounds;
1333  uint32 _ambientSoundFinishTime;
1334 
1335  bool _escOn;
1336  bool _debugMode;
1337  bool _fastAnimationMode;
1338  bool _preloadSounds;
1339  bool _lowQualityGraphicsMode;
1340 
1341  VCruiseGameID _gameID;
1342 
1344  Common::Array<uint> _roomDuplicationOffsets;
1345  RoomToScreenNameToRoomMap_t _globalRoomScreenNameToScreenIDs;
1346  Common::SharedPtr<ScriptSet> _scriptSet;
1347  Common::Array<AD2044AnimationDef> _ad2044AnimationDefs;
1348 
1349  Common::Array<CallStackFrame> _scriptCallStack;
1350 
1351  Common::Array<StackValue> _scriptStack;
1352  ScriptEnvironmentVars _scriptEnv;
1353 
1355 
1356  Common::SharedPtr<AudioPlayer> _musicWavePlayer;
1357  Common::Mutex _midiPlayerMutex;
1358  Common::SharedPtr<MidiPlayer> _musicMidiPlayer;
1359  int _musicTrack;
1360  int32 _musicVolume;
1361  bool _musicActive;
1362  bool _musicMute;
1363  bool _musicMuteDisabled;
1364 
1365  Common::String _scoreTrack;
1366  Common::String _scoreSection;
1367  uint32 _scoreSectionEndTime;
1369 
1370  uint32 _musicVolumeRampStartTime;
1371  int32 _musicVolumeRampStartVolume;
1372  int32 _musicVolumeRampRatePerMSec;
1373  int32 _musicVolumeRampEnd;
1374 
1375  SfxData _sfxData;
1376 
1378  Common::SharedPtr<SfxPlaylist> _animPlaylist;
1379  AnimDecoderState _animDecoderState;
1380  bool _animTerminateAtStartOfFrame;
1381  uint _animPendingDecodeFrame;
1382  uint _animDisplayingFrame;
1383  uint _animFirstFrame;
1384  uint _animLastFrame;
1385  uint _animStopFrame;
1386  uint _animVolume;
1387  Fraction _animFrameRateLock;
1388  Common::Rect _animConstraintRect;
1389  uint32 _animStartTime;
1390  uint32 _animFramesDecoded;
1391  uint _loadedAnimation;
1392  bool _loadedAnimationHasSound;
1393  bool _animPlayWhileIdle;
1394 
1395  Common::Array<FrameData> _frameData;
1396  Common::Array<FrameData2> _frameData2;
1397  //uint32 _loadedArea;
1398 
1399  // Reah/Schizm animation map
1400  Common::Array<Common::String> _animDefNames;
1401  Common::HashMap<Common::String, uint> _animDefNameToIndex;
1402 
1403  // AD2044 animation map
1404  Common::HashMap<int, AnimFrameRange> _currentRoomAnimIDToFrameRange;
1405  Common::HashMap<int, AnimFrameRange> _examineAnimIDToFrameRange;
1406 
1407  bool _idleLockInteractions;
1408  bool _idleIsOnInteraction;
1409  bool _idleHaveClickInteraction;
1410  bool _idleHaveDragInteraction;
1411  uint _idleInteractionID;
1412 
1413  bool _idleIsOnOpenCircuitPuzzleLink;
1414  Common::Rect _idleCircuitPuzzleLinkHighlightRect;
1415 
1416  bool _idleIsCircuitPuzzleLinkDown;
1417  Common::Point _idleCircuitPuzzleCoord;
1418 
1419  bool _forceAllowSaves;
1420 
1421  InGameMenuState _inGameMenuState;
1422  uint _inGameMenuActiveElement;
1423  bool _inGameMenuButtonActive[5];
1424 
1425  Audio::Mixer *_mixer;
1426  MidiDriver *_midiDrv;
1427 
1428  Common::SharedPtr<MapLoader> _mapLoader;
1429 
1430  RenderSection _gameSection;
1431  RenderSection _gameDebugBackBuffer;
1432  RenderSection _menuSection;
1433  RenderSection _traySection;
1434  RenderSection _fullscreenMenuSection;
1435  RenderSection _subtitleSection;
1436  RenderSection _placedItemBackBufferSection;
1437 
1438  Common::Point _mousePos;
1439  Common::Point _lmbDownPos;
1440  uint32 _lmbDownTime;
1441  int _lmbDragTolerance;
1442  bool _lmbDown;
1443  bool _lmbDragging;
1444  bool _lmbReleaseWasClick; // If true, then the mouse didn't move at all since the LMB down
1445 
1446  PanoramaState _panoramaState;
1447  // The anchor point behavior is kind of weird. The way it works in Reah is that if the camera is panning left or right and the mouse is moved
1448  // back across the anchor threshold at all, then the anchor point is reset to the mouse position. This means it can drift, because the center
1449  // is moved by roughly the margin amount.
1450  // Vertical panning on the other hand resets the anchor vertical coordinate every time.
1451  Common::Point _panoramaAnchor;
1452 
1453  Common::Array<OSEvent> _pendingEvents;
1454 
1457  SoundParams3D _pendingSoundParams3D;
1458 
1459  Common::Array<TriggeredOneShot> _triggeredOneShots;
1460  Common::HashMap<uint32, uint> _sayCycles;
1461  Common::Array<RandomAmbientSound> _randomAmbientSounds;
1462 
1463  int32 _listenerX;
1464  int32 _listenerY;
1465  int32 _listenerAngle;
1466 
1467  Fraction _animSpeedRotation;
1468  Fraction _animSpeedStaticAnim;
1469  Fraction _animSpeedDefault;
1470 
1471  static const uint kAnimDefStackArgs = 8;
1472 
1473  static const uint kCursorArrow = 0;
1474  static const uint kCursorWait = 29;
1475 
1476  static const int kPanoramaPanningMarginX = 11;
1477  static const int kPanoramaPanningMarginY = 11;
1478 
1479  static const uint kSoundCacheSize = 16;
1480 
1481  static const uint kExamineItemInteractionID = 0xfffffff0u;
1482 
1483  static const uint kReturnInventorySlot0InteractionID = 0xfffffff1u;
1484  static const uint kReturnInventorySlot1InteractionID = 0xfffffff2u;
1485  static const uint kReturnInventorySlot2InteractionID = 0xfffffff3u;
1486  static const uint kReturnInventorySlot3InteractionID = 0xfffffff4u;
1487  static const uint kReturnInventorySlot4InteractionID = 0xfffffff5u;
1488  static const uint kReturnInventorySlot5InteractionID = 0xfffffff6u;
1489 
1490  static const uint kPickupInventorySlot0InteractionID = 0xfffffff7u;
1491  static const uint kPickupInventorySlot1InteractionID = 0xfffffff8u;
1492  static const uint kPickupInventorySlot2InteractionID = 0xfffffff9u;
1493  static const uint kPickupInventorySlot3InteractionID = 0xfffffffau;
1494  static const uint kPickupInventorySlot4InteractionID = 0xfffffffbu;
1495  static const uint kPickupInventorySlot5InteractionID = 0xfffffffcu;
1496 
1497  static const uint kObjectPickupInteractionID = 0xfffffffdu;
1498  static const uint kObjectDropInteractionID = 0xfffffffeu;
1499 
1500  static const uint kHeroChangeInteractionID = 0xffffffffu;
1501 
1502  Common::Pair<Common::String, Common::SharedPtr<SoundCache> > _soundCache[kSoundCacheSize];
1503  uint _soundCacheIndex;
1504 
1505  Common::SharedPtr<SaveGameSnapshot> _mostRecentValidSaveState; // Always valid
1506  Common::SharedPtr<SaveGameSnapshot> _mostRecentlyRecordedSaveState; // Might be invalid, becomes valid if the player returns to idle
1508  bool _isInGame;
1509 
1510  const Graphics::Font *_subtitleFont;
1511  Common::SharedPtr<Graphics::Font> _subtitleFontKeepalive;
1512  uint _defaultLanguageIndex;
1513  uint _languageIndex;
1514  Common::Language _language;
1515  CharSet _charSet;
1516  bool _isCDVariant;
1517  StartConfigDef _startConfigs[kNumStartConfigs];
1518 
1519  Common::Language _defaultLanguage;
1520 
1524 
1525  AnimSubtitleMap_t _animSubtitles;
1527  Common::Array<SubtitleQueueItem> _subtitleQueue;
1528  bool _isDisplayingSubtitles;
1529  bool _isSubtitleSourceAnimation;
1530 
1534 
1536 
1537  AnimatedCursor *_currentAnimatedCursor;
1538  Graphics::Cursor *_currentCursor;
1539  uint32 _cursorTimeBase;
1540  uint32 _cursorCycleLength;
1541 
1542  int32 _dbToVolume[49];
1543 
1544  // AD2044 tooltips
1545  Common::String _tooltipText;
1546  Common::String _subtitleText;
1547 
1548  Common::SharedPtr<AD2044Graphics> _ad2044Graphics;
1549  Common::Array<Common::String> _ad2044ItemNames;
1550 };
1551 
1552 } // End of namespace VCruise
1553 
1554 #endif
Definition: managed_surface.h:51
Definition: runtime.h:295
Definition: ani.h:45
Definition: runtime.h:213
Definition: util.h:213
Definition: runtime.h:346
Definition: str.h:59
Definition: font.h:83
Definition: runtime.h:611
Definition: runtime.h:357
Definition: script.h:277
Definition: stream.h:77
Definition: runtime.h:132
Definition: runtime.h:624
Definition: array.h:52
Definition: menu.h:72
Definition: pixelformat.h:138
Definition: runtime.h:590
Definition: runtime.h:423
Definition: runtime.h:377
Definition: rect.h:144
Definition: path.h:52
Definition: runtime.h:395
Definition: stream.h:745
Definition: runtime.h:231
Definition: runtime.h:486
Definition: runtime.h:196
Definition: mididrv.h:309
Definition: runtime.h:403
Definition: runtime.h:125
Definition: runtime.h:259
Definition: runtime.h:166
Definition: mixer.h:59
Definition: runtime.h:337
Definition: ad2044_items.h:27
Definition: hashmap.h:85
Definition: ustr.h:57
Definition: atari-cursor.h:38
Definition: runtime.h:178
Definition: runtime.h:203
Definition: cursor.h:42
Definition: runtime.h:637
Definition: runtime.h:246
Definition: runtime.h:625
Definition: algorithm.h:29
Definition: fs.h:69
Definition: formatinfo.h:28
Definition: runtime.h:144
Definition: mutex.h:67
Definition: rect.h:45
Definition: runtime.h:387
Definition: runtime.h:367
Definition: runtime.h:154
Definition: stream.h:385
Definition: runtime.h:331
Definition: runtime.h:219
Definition: system.h:161
Definition: ptr.h:159
Definition: avi_frames.h:36
Definition: runtime.h:581
Definition: movie_decoder.h:32
Definition: runtime.h:310
Definition: runtime.h:602
Definition: runtime.h:162
Definition: runtime.h:323
Definition: system.h:38
Language
Definition: language.h:45