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  kOSEventTypeKeyDown,
557 
558  kOSEventTypeKeymappedEvent,
559 };
560 
561 enum KeymappedEvent {
562  kKeymappedEventNone,
563 
564  kKeymappedEventHelp,
565  kKeymappedEventSaveGame,
566  kKeymappedEventLoadGame,
567  kKeymappedEventSoundSettings,
568  kKeymappedEventQuit,
569  kKeymappedEventPause,
570  kKeymappedEventMusicToggle,
571  kKeymappedEventSoundToggle,
572  kKeymappedEventMusicVolumeDown,
573  kKeymappedEventMusicVolumeUp,
574  kKeymappedEventSoundVolumeDown,
575  kKeymappedEventSoundVolumeUp,
576 
577  kKeymappedEventSkipAnimation,
578 
579  kKeymappedEventPutItem,
580 };
581 
582 struct OSEvent {
583  OSEvent();
584 
585  OSEventType type;
586  Common::Point pos;
587  Common::KeyCode keyCode;
588  KeymappedEvent keymappedEvent;
589  uint32 timestamp;
590 };
591 
592 struct TextStyleDef {
593  Common::String fontName;
594  uint size;
595  uint unknown1;
596  uint unknown2;
597  uint unknown3; // Seems to always be 0 for English, other values for other languages
598  uint colorRGB;
599  uint shadowColorRGB;
600  uint alignment; // Modulo 10 seems to be alignment: 0 = left, 1 = center, 2 = right
601  uint unknown5; // Possibly drop shadow offset
602 };
603 
604 struct UILabelDef {
605  Common::String lineID;
606  Common::String styleDefID;
607  uint graphicLeft;
608  uint graphicTop;
609  uint graphicWidth;
610  uint graphicHeight;
611 };
612 
614  FontCacheItem();
615 
616  Common::String fname;
617  uint size;
618 
619  const Graphics::Font *font;
621 };
622 
625 
627  struct FrameDef {
628  uint imageIndex;
629  uint delay;
630  };
631 
634 
636  Common::SharedPtr<Graphics::WinCursorGroup> cursorGroupKeepAlive;
637 };
638 
639 class Runtime {
640 public:
641  friend class RuntimeMenuInterface;
642 
643  enum CharSet {
644  kCharSetLatin,
645  kCharSetGreek,
646  kCharSetCyrillic,
647  kCharSetJapanese,
648  kCharSetChineseTraditional,
649  kCharSetChineseSimplified,
650  };
651 
652  Runtime(OSystem *system, Audio::Mixer *mixer, MidiDriver *midiDrv, const Common::FSNode &rootFSNode, VCruiseGameID gameID, Common::Language defaultLanguage);
653  virtual ~Runtime();
654 
655  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);
656 
657  void loadCursors(const char *exeName);
658  void setDebugMode(bool debugMode);
659  void setFastAnimationMode(bool fastAnimationMode);
660  void setPreloadSounds(bool preloadSounds);
661  void setLowQualityGraphicsMode(bool lowQualityGraphicsMode);
662 
663  bool runFrame();
664  void drawFrame();
665 
666  void onLButtonDown(int16 x, int16 y);
667  void onLButtonUp(int16 x, int16 y);
668  void onMouseMove(int16 x, int16 y);
669  void onKeyDown(Common::KeyCode keyCode);
670  void onKeymappedEvent(KeymappedEvent evt);
671 
672  bool canSave(bool onCurrentScreen) const;
673  bool canLoad() const;
674 
675  void recordSaveGameSnapshot();
676  void recordSounds(SaveGameSwappableState &state);
677  void restoreSaveGameSnapshot();
678  Common::SharedPtr<SaveGameSnapshot> generateNewGameSnapshot() const;
679 
680  void saveGame(Common::WriteStream *stream) const;
681  LoadGameOutcome loadGame(Common::ReadStream *stream);
682 
683  bool bootGame(bool newGame);
684  static void resolveCodePageForLanguage(Common::Language lang, Common::CodePage &outCodePage, CharSet &outCharSet);
685 
686  void drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect);
687  void getLabelDef(const Common::String &labelID, const Graphics::Font *&outFont, const Common::String *&outTextUTF8, uint32 &outColor, uint32 &outShadowColor, uint32 &outShadowOffset);
688 
689  void onMidiTimer();
690 
691 private:
692  enum IndexParseType {
693  kIndexParseTypeNone,
694  kIndexParseTypeRoom,
695  kIndexParseTypeRRoom, // Rectangle room (constrains animation areas)
696  kIndexParseTypeYRoom, // Yes room (variable/ID mappings)
697  kIndexParseTypeVRoom, // Value room (value/ID mappings?)
698  kIndexParseTypeTRoom, // Text
699  kIndexParseTypeCRoom, // Const
700  kIndexParseTypeSRoom, // Sound
701  kIndexParseTypeNameRoom,
702  };
703 
704  enum AnimDecoderState {
705  kAnimDecoderStateStopped,
706  kAnimDecoderStatePlaying,
707  kAnimDecoderStatePaused,
708  };
709 
710  struct IndexPrefixTypePair {
711  const char *prefix;
712  IndexParseType parseType;
713  };
714 
715  struct RenderSection {
717  Common::Rect rect;
718  Graphics::PixelFormat pixFmt;
719 
720  void init(const Common::Rect &paramRect, const Graphics::PixelFormat &fmt);
721  };
722 
723  struct Gyro {
724  static const uint kMaxPreviousStates = 3;
725 
726  int32 currentState;
727  int32 requiredState;
728  int32 previousStates[kMaxPreviousStates];
729  int32 requiredPreviousStates[kMaxPreviousStates];
730  uint numPreviousStates;
731  uint numPreviousStatesRequired;
732  bool wrapAround;
733  bool requireState;
734 
735  Gyro();
736 
737  void reset();
738  void logState();
739  };
740 
741  struct GyroState {
742  GyroState();
743 
744  void reset();
745 
746  static const uint kNumGyros = 5;
747 
748  Gyro gyros[kNumGyros];
749 
750  uint completeInteraction;
751  uint failureInteraction;
752  uint frameSeparation;
753 
754  uint activeGyro;
755  uint dragMargin;
756  uint maxValue;
757 
758  AnimationDef negAnim;
759  AnimationDef posAnim;
760  bool isVertical;
761 
762  Common::Point dragBasePoint;
763  uint dragBaseState;
764  int32 dragCurrentState;
765  bool isWaitingForAnimation;
766  };
767 
768  enum PanoramaCursorFlags {
769  kPanCursorDraggableHoriz = (1 << 0),
770  kPanCursorDraggableUp = (1 << 1),
771  kPanCursorDraggableDown = (1 << 2),
772 
773  kPanCursorDirectionUp = (0 << 3),
774  kPanCursorDirectionLeft = (1 << 3),
775  kPanCursorDirectionRight = (2 << 3),
776  kPanCursorDirectionDown = (3 << 3),
777 
778  kPanCursorMaxCount = (1 << 5),
779  };
780 
781  enum PanoramaState {
782  kPanoramaStateInactive,
783 
784  kPanoramaStatePanningUncertainDirection,
785 
786  kPanoramaStatePanningLeft,
787  kPanoramaStatePanningRight,
788  kPanoramaStatePanningUp,
789  kPanoramaStatePanningDown,
790  };
791 
792  enum InGameMenuState {
793  kInGameMenuStateInvisible,
794  kInGameMenuStateVisible,
795  kInGameMenuStateHoveringInactive,
796  kInGameMenuStateHoveringActive,
797  kInGameMenuStateClickingOver, // Mouse was pressed on a button and is holding on it
798  kInGameMenuStateClickingNotOver, // Mouse was pressed on a button and dragged off
799  kInGameMenuStateClickingInactive,
800  };
801 
802  enum SoundLoopBehavior {
803  kSoundLoopBehaviorNo,
804  kSoundLoopBehaviorYes,
805  kSoundLoopBehaviorAuto,
806  };
807 
808  static const uint kPanLeftInteraction = 1;
809  static const uint kPanDownInteraction = 2;
810  static const uint kPanRightInteraction = 3;
811  static const uint kPanUpInteraction = 4;
812 
813  static const uint kPanoramaLeftFlag = 1;
814  static const uint kPanoramaRightFlag = 2;
815  static const uint kPanoramaUpFlag = 4;
816  static const uint kPanoramaDownFlag = 8;
817  static const uint kPanoramaHorizFlags = (kPanoramaLeftFlag | kPanoramaRightFlag);
818 
819  static const uint kNumInventorySlots = 6;
820  static const uint kNumInventoryPages = 8;
821 
822  typedef int32 ScriptArg_t;
823  typedef int32 StackInt_t;
824 
825  struct StackValue {
826  enum StackValueType {
827  kNumber,
828  kString,
829  };
830 
831  union ValueUnion {
832  StackInt_t i;
833  Common::String s;
834 
835  ValueUnion();
836  explicit ValueUnion(StackInt_t iVal);
837  explicit ValueUnion(const Common::String &strVal);
838  explicit ValueUnion(Common::String &&strVal);
839  ~ValueUnion();
840  };
841 
842  StackValue();
843  StackValue(const StackValue &other);
844  StackValue(StackValue &&other);
845  explicit StackValue(StackInt_t i);
846  explicit StackValue(const Common::String &str);
847  explicit StackValue(Common::String &&str);
848  ~StackValue();
849 
850  StackValue &operator=(const StackValue &other);
851  StackValue &operator=(StackValue &&other);
852 
853  StackValueType type;
854  ValueUnion value;
855  };
856 
857  struct CallStackFrame {
858  CallStackFrame();
859 
861  uint _nextInstruction;
862  };
863 
864  struct SubtitleDef {
865  SubtitleDef();
866 
867  uint8 color[3];
868  uint unknownValue1;
869  uint durationInDeciseconds;
870  Common::String str;
871  };
872 
873  struct SubtitleQueueItem {
874  Common::U32String str;
875  uint8 color[3];
876  uint32 startTime;
877  uint32 endTime;
878  };
879 
880  bool runIdle();
881  bool runDelay();
882  bool runHorizontalPan(bool isRight);
883  bool runScript();
884  bool requireAvailableStack(uint n);
885  bool runWaitForAnimation();
886  bool runWaitForAnimationToDelay();
887  bool runWaitForFacing();
888  bool runWaitForFacingToAnim();
889  bool runGyroIdle();
890  bool runGyroAnimation();
891  void exitGyroIdle();
892  void continuePlayingAnimation(bool loop, bool useStopFrame, bool &outEndedAnimation);
893  void drawSectionToScreen(const RenderSection &section, const Common::Rect &rect);
894  void commitSectionToScreen(const RenderSection &section, const Common::Rect &rect);
895  void terminateScript();
896  void quitToMenu();
897  RoomScriptSet *getRoomScriptSetForCurrentRoom() const;
898  bool checkCompletionConditions();
899 
900  void startTerminatingHorizontalPan(bool isRight);
901 
902  bool popOSEvent(OSEvent &evt);
903  void queueOSEvent(const OSEvent &evt);
904 
905  void processUniversalKeymappedEvents(KeymappedEvent evt);
906 
907  void loadReahSchizmIndex();
908  void loadAD2044ExecutableResources();
909  void findWaves();
910  void loadConfig(const char *cfgPath);
911  void loadScore();
912  void loadDuplicateRooms();
913  void loadAllSchizmScreenNames();
914  Common::SharedPtr<SoundInstance> loadWave(const Common::String &soundName, uint soundID, const Common::ArchiveMemberPtr &archiveMemberPtr);
915  SoundCache *loadCache(SoundInstance &sound);
916  void resolveSoundByName(const Common::String &soundName, bool load, StackInt_t &outSoundID, SoundInstance *&outWave);
917  SoundInstance *resolveSoundByID(uint soundID);
918  void resolveSoundByNameOrID(const StackValue &stackValue, bool load, StackInt_t &outSoundID, SoundInstance *&outWave);
919 
920  void changeToScreen(uint roomNumber, uint screenNumber);
921  void clearIdleAnimations();
922  void changeHero();
923  void changeToExamineItem();
924  void returnFromExaminingItem();
925  bool triggerPreIdleActions();
926  void returnToIdleState();
927  void changeToCursor(const Common::SharedPtr<AnimatedCursor> &cursor);
928  void refreshCursor(uint32 currentTime);
929  bool dischargeIdleMouseMove();
930  bool dischargeIdleMouseDown();
931  bool dischargeIdleClick();
932  void loadFrameData(Common::SeekableReadStream *stream);
933  void loadFrameData2(Common::SeekableReadStream *stream);
934  void loadTabData(Common::HashMap<int, AnimFrameRange> &animIDToFrameRangeMap, uint animNumber, Common::SeekableReadStream *stream);
935 
936  void changeMusicTrack(int musicID);
937  void startScoreSection();
938  void setMusicMute(bool muted);
939 
940  void changeAnimation(const AnimationDef &animDef, bool consumeFPSOverride);
941  void changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride);
942  void changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride, const Fraction &defaultFrameRate);
943  void applyAnimationVolume();
944 
945  void setSound3DParameters(SoundInstance &sound, int32 x, int32 y, const SoundParams3D &soundParams3D);
946  void triggerSound(SoundLoopBehavior loopBehavior, SoundInstance &sound, int32 volume, int32 balance, bool is3D, bool isSpeech);
947  void triggerSoundRamp(SoundInstance &sound, uint durationMSec, int32 newVolume, bool terminateOnCompletion);
948  void stopSound(SoundInstance &sound);
949  void convertLoopingSoundToNonLooping(SoundInstance &sound);
950  void updateSounds(uint32 timestamp);
951  void updateSubtitles();
952  void update3DSounds();
953  bool computeEffectiveVolumeAndBalance(SoundInstance &snd);
954  void triggerAmbientSounds();
955  uint decibelsToLinear(int db, uint baseVolume, uint maxVolume) const;
956  int32 getSilentSoundVolume() const;
957  int32 getDefaultSoundVolume() const;
958  uint applyVolumeScale(int32 volume) const;
959  int applyBalanceScale(int32 balance) const;
960 
961  void triggerWaveSubtitles(const SoundInstance &sound, const Common::String &id);
962  void stopSubtitles();
963 
964  AnimationDef stackArgsToAnimDef(const StackInt_t *args) const;
965  void consumeAnimChangeAndAdjustAnim(AnimationDef &animDef);
966  void pushAnimDef(const AnimationDef &animDef);
967 
968  void activateScript(const Common::SharedPtr<Script> &script, bool isEntryScript, const ScriptEnvironmentVars &envVars);
969  Common::SharedPtr<ScriptSet> compileSchizmLogicSet(const uint *roomNumbers, uint numRooms) const;
970 
971  bool parseIndexDef(IndexParseType parseType, uint roomNumber, const Common::String &key, const Common::String &value);
972  void allocateRoomsUpTo(uint roomNumber);
973 
974  void drawDebugOverlay();
975 
976  Common::SharedPtr<Script> findScriptForInteraction(uint interactionID) const;
977 
978  void detectPanoramaDirections();
979  void detectPanoramaMouseMovement(uint32 timestamp);
980  void panoramaActivate();
981 
982  bool computeFaceDirectionAnimation(uint desiredDirection, const AnimationDef *&outAnimDef, uint &outInitialFrame, uint &outStopFrame);
983 
984  void inventoryAddItem(uint item);
985  void inventoryRemoveItem(uint item);
986  void clearScreen();
987  void redrawTray();
988  void clearTray();
989  void redrawSubtitleSection();
990  void clearSubtitleSection();
991  void drawSubtitleText(const Common::Array<Common::U32String> &lines, const uint8 (&color)[3]);
992  void drawInventory(uint slot);
993  void drawCompass();
994  bool isTrayVisible() const;
995  void resetInventoryHighlights();
996  void loadInventoryFromPage();
997  void copyInventoryToPage();
998  void cheatPutItem();
999  static uint32 getLocationForScreen(uint roomNumber, uint screenNumber);
1000  void updatePlacedItemCache();
1001  void drawPlacedItemGraphic();
1002  void clearPlacedItemGraphic();
1003  void drawActiveItemGraphic();
1004  void clearActiveItemGraphic();
1005  void drawInventoryItemGraphic(uint slot);
1006  void clearInventoryItemGraphic(uint slot);
1007  void dropActiveItem();
1008  void pickupPlacedItem();
1009  void stashActiveItemToInventory(uint slot);
1010  void pickupInventoryItem(uint slot);
1011 
1012  void getFileNamesForItemGraphic(uint itemID, Common::String &outGraphicFileName, Common::String &outAlphaFileName) const;
1013  Common::SharedPtr<Graphics::Surface> loadGraphic(const Common::String &graphicName, const Common::String &alphaName, bool required);
1014  Common::SharedPtr<Graphics::Surface> loadGraphicFromPath(const Common::Path &path, bool required);
1015 
1016  bool loadSubtitles(Common::CodePage codePage, bool guessCodePage);
1017 
1018  void changeToMenuPage(MenuPage *menuPage);
1019 
1020  void checkInGameMenuHover();
1021  void dismissInGameMenu();
1022  void dischargeInGameMenuMouseUp();
1023  void drawInGameMenuButton(uint element);
1024 
1025  const Graphics::Font *resolveFont(const Common::String &textStyle, uint size);
1026 
1027  bool resolveCircuitPuzzleInteraction(const Common::Point &relMouse, Common::Point &outCoord, bool &outIsDown, Common::Rect &outHighlightRect) const;
1028  void clearCircuitPuzzle();
1029  void clearCircuitHighlightRect(const Common::Rect &rect);
1030  void drawCircuitHighlightRect(const Common::Rect &rect);
1031  static Common::Rect padCircuitInteractionRect(const Common::Rect &rect);
1032 
1033  static Common::SharedPtr<AnimatedCursor> winCursorGroupToAnimatedCursor(const Common::SharedPtr<Graphics::WinCursorGroup> &cursorGroup);
1034  static Common::SharedPtr<AnimatedCursor> aniFileToAnimatedCursor(Image::AniDecoder &aniDecoder);
1035  static Common::SharedPtr<AnimatedCursor> staticCursorToAnimatedCursor(const Common::SharedPtr<Graphics::Cursor> &cursor);
1036 
1037  // Script things
1038  void scriptOpNumber(ScriptArg_t arg);
1039  void scriptOpRotate(ScriptArg_t arg);
1040  void scriptOpAngle(ScriptArg_t arg);
1041  void scriptOpAngleGGet(ScriptArg_t arg);
1042  void scriptOpSpeed(ScriptArg_t arg);
1043  void scriptOpSAnimL(ScriptArg_t arg);
1044  void scriptOpChangeL(ScriptArg_t arg);
1045 
1046  void scriptOpAnimR(ScriptArg_t arg);
1047  void scriptOpAnimF(ScriptArg_t arg);
1048  void scriptOpAnimN(ScriptArg_t arg);
1049  void scriptOpAnimG(ScriptArg_t arg);
1050  void scriptOpAnimS(ScriptArg_t arg);
1051  void scriptOpAnim(ScriptArg_t arg);
1052 
1053  void scriptOpStatic(ScriptArg_t arg);
1054  void scriptOpVarLoad(ScriptArg_t arg);
1055  void scriptOpVarStore(ScriptArg_t arg);
1056  void scriptOpVarAddAndStore(ScriptArg_t arg);
1057  void scriptOpVarGlobalLoad(ScriptArg_t arg);
1058  void scriptOpVarGlobalStore(ScriptArg_t arg);
1059 
1060  void scriptOpItemCheck(ScriptArg_t arg);
1061  void scriptOpItemRemove(ScriptArg_t arg);
1062  void scriptOpItemHighlightSet(ScriptArg_t arg);
1063  void scriptOpItemAdd(ScriptArg_t arg);
1064  void scriptOpItemHaveSpace(ScriptArg_t arg);
1065  void scriptOpItemClear(ScriptArg_t arg);
1066 
1067  void scriptOpSetCursor(ScriptArg_t arg);
1068  void scriptOpSetRoom(ScriptArg_t arg);
1069  void scriptOpLMB(ScriptArg_t arg);
1070  void scriptOpLMB1(ScriptArg_t arg);
1071  void scriptOpSoundS1(ScriptArg_t arg);
1072  void scriptOpSoundS2(ScriptArg_t arg);
1073  void scriptOpSoundS3(ScriptArg_t arg);
1074  void scriptOpSoundL1(ScriptArg_t arg);
1075  void scriptOpSoundL2(ScriptArg_t arg);
1076  void scriptOpSoundL3(ScriptArg_t arg);
1077  void scriptOp3DSoundS2(ScriptArg_t arg);
1078  void scriptOp3DSoundL2(ScriptArg_t arg);
1079  void scriptOp3DSoundL3(ScriptArg_t arg);
1080  void scriptOpStopAL(ScriptArg_t arg);
1081  void scriptOpRange(ScriptArg_t arg);
1082  void scriptOpAddXSound(ScriptArg_t arg);
1083  void scriptOpClrXSound(ScriptArg_t arg);
1084  void scriptOpStopSndLA(ScriptArg_t arg);
1085  void scriptOpStopSndLO(ScriptArg_t arg);
1086 
1087  void scriptOpMusic(ScriptArg_t arg);
1088  void scriptOpMusicVolRamp(ScriptArg_t arg);
1089  void scriptOpParm0(ScriptArg_t arg);
1090  void scriptOpParm1(ScriptArg_t arg);
1091  void scriptOpParm2(ScriptArg_t arg);
1092  void scriptOpParm3(ScriptArg_t arg);
1093  void scriptOpParmG(ScriptArg_t arg);
1094  void scriptOpSParmX(ScriptArg_t arg);
1095  void scriptOpSAnimX(ScriptArg_t arg);
1096 
1097  void scriptOpVolumeDn2(ScriptArg_t arg);
1098  void scriptOpVolumeDn3(ScriptArg_t arg);
1099  void scriptOpVolumeDn4(ScriptArg_t arg);
1100  void scriptOpVolumeUp3(ScriptArg_t arg);
1101  void scriptOpRandom(ScriptArg_t arg);
1102  void scriptOpDrop(ScriptArg_t arg);
1103  void scriptOpDup(ScriptArg_t arg);
1104  void scriptOpSwap(ScriptArg_t arg);
1105  void scriptOpSay1(ScriptArg_t arg);
1106  void scriptOpSay2(ScriptArg_t arg);
1107  void scriptOpSay3(ScriptArg_t arg);
1108  void scriptOpSay3Get(ScriptArg_t arg);
1109  void scriptOpSetTimer(ScriptArg_t arg);
1110  void scriptOpGetTimer(ScriptArg_t arg);
1111  void scriptOpDelay(ScriptArg_t arg);
1112  void scriptOpLoSet(ScriptArg_t arg);
1113  void scriptOpLoGet(ScriptArg_t arg);
1114  void scriptOpHiSet(ScriptArg_t arg);
1115  void scriptOpHiGet(ScriptArg_t arg);
1116 
1117  void scriptOpNot(ScriptArg_t arg);
1118  void scriptOpAnd(ScriptArg_t arg);
1119  void scriptOpOr(ScriptArg_t arg);
1120  void scriptOpAdd(ScriptArg_t arg);
1121  void scriptOpSub(ScriptArg_t arg);
1122  void scriptOpNegate(ScriptArg_t arg);
1123  void scriptOpCmpEq(ScriptArg_t arg);
1124  void scriptOpCmpLt(ScriptArg_t arg);
1125  void scriptOpCmpGt(ScriptArg_t arg);
1126 
1127  void scriptOpBitLoad(ScriptArg_t arg);
1128  void scriptOpBitSet0(ScriptArg_t arg);
1129  void scriptOpBitSet1(ScriptArg_t arg);
1130 
1131  void scriptOpDisc1(ScriptArg_t arg);
1132  void scriptOpDisc2(ScriptArg_t arg);
1133  void scriptOpDisc3(ScriptArg_t arg);
1134 
1135  void scriptOpGoto(ScriptArg_t arg);
1136 
1137  void scriptOpEscOn(ScriptArg_t arg);
1138  void scriptOpEscOff(ScriptArg_t arg);
1139  void scriptOpEscGet(ScriptArg_t arg);
1140  void scriptOpBackStart(ScriptArg_t arg);
1141  void scriptOpSaveAs(ScriptArg_t arg);
1142  void scriptOpSave0(ScriptArg_t arg);
1143  void scriptOpExit(ScriptArg_t arg);
1144  void scriptOpAllowSaves(ScriptArg_t arg);
1145 
1146  void scriptOpAnimName(ScriptArg_t arg);
1147  void scriptOpValueName(ScriptArg_t arg);
1148  void scriptOpVarName(ScriptArg_t arg);
1149  void scriptOpSoundName(ScriptArg_t arg);
1150  void scriptOpCursorName(ScriptArg_t arg);
1151  void scriptOpDubbing(ScriptArg_t arg);
1152 
1153  void scriptOpCheckValue(ScriptArg_t arg);
1154  void scriptOpJump(ScriptArg_t arg);
1155 
1156  void scriptOpVerticalPanSet(bool *flags);
1157  void scriptOpVerticalPanGet();
1158 
1159  // Schizm ops
1160  void scriptOpCallFunction(ScriptArg_t arg);
1161 
1162  void scriptOpMusicStop(ScriptArg_t arg);
1163  void scriptOpMusicPlayScore(ScriptArg_t arg);
1164  void scriptOpScoreAlways(ScriptArg_t arg);
1165  void scriptOpScoreNormal(ScriptArg_t arg);
1166  void scriptOpSndPlay(ScriptArg_t arg);
1167  void scriptOpSndPlayEx(ScriptArg_t arg);
1168  void scriptOpSndPlay3D(ScriptArg_t arg);
1169  void scriptOpSndPlaying(ScriptArg_t arg);
1170  void scriptOpSndWait(ScriptArg_t arg);
1171  void scriptOpSndHalt(ScriptArg_t arg);
1172  void scriptOpSndToBack(ScriptArg_t arg);
1173  void scriptOpSndStop(ScriptArg_t arg);
1174  void scriptOpSndStopAll(ScriptArg_t arg);
1175  void scriptOpSndAddRandom(ScriptArg_t arg);
1176  void scriptOpSndClearRandom(ScriptArg_t arg);
1177  void scriptOpVolumeAdd(ScriptArg_t arg);
1178  void scriptOpVolumeChange(ScriptArg_t arg);
1179  void scriptOpAnimVolume(ScriptArg_t arg);
1180  void scriptOpAnimChange(ScriptArg_t arg);
1181  void scriptOpScreenName(ScriptArg_t arg);
1182  void scriptOpExtractByte(ScriptArg_t arg);
1183  void scriptOpInsertByte(ScriptArg_t arg);
1184  void scriptOpString(ScriptArg_t arg);
1185  void scriptOpCmpNE(ScriptArg_t arg);
1186  void scriptOpCmpLE(ScriptArg_t arg);
1187  void scriptOpCmpGE(ScriptArg_t arg);
1188  void scriptOpReturn(ScriptArg_t arg);
1189  void scriptOpSpeech(ScriptArg_t arg);
1190  void scriptOpSpeechEx(ScriptArg_t arg);
1191  void scriptOpSpeechTest(ScriptArg_t arg);
1192  void scriptOpSay(ScriptArg_t arg);
1193  void scriptOpRandomInclusive(ScriptArg_t arg);
1194  void scriptOpHeroOut(ScriptArg_t arg);
1195  void scriptOpHeroGetPos(ScriptArg_t arg);
1196  void scriptOpHeroSetPos(ScriptArg_t arg);
1197  void scriptOpHeroGet(ScriptArg_t arg);
1198  void scriptOpGarbage(ScriptArg_t arg);
1199  void scriptOpGetRoom(ScriptArg_t arg);
1200  void scriptOpBitAnd(ScriptArg_t arg);
1201  void scriptOpBitOr(ScriptArg_t arg);
1202  void scriptOpAngleGet(ScriptArg_t arg);
1203  void scriptOpIsDVDVersion(ScriptArg_t arg);
1204  void scriptOpIsCDVersion(ScriptArg_t arg);
1205  void scriptOpDisc(ScriptArg_t arg);
1206  void scriptOpHidePanel(ScriptArg_t arg);
1207  void scriptOpRotateUpdate(ScriptArg_t arg);
1208  void scriptOpMul(ScriptArg_t arg);
1209  void scriptOpDiv(ScriptArg_t arg);
1210  void scriptOpMod(ScriptArg_t arg);
1211  void scriptOpGetDigit(ScriptArg_t arg);
1212  void scriptOpPuzzleInit(ScriptArg_t arg);
1213  void scriptOpPuzzleCanPress(ScriptArg_t arg);
1214  void scriptOpPuzzleDoMove1(ScriptArg_t arg);
1215  void scriptOpPuzzleDoMove2(ScriptArg_t arg);
1216  void scriptOpPuzzleDone(ScriptArg_t arg);
1217  void scriptOpPuzzleWhoWon(ScriptArg_t arg);
1218  void scriptOpFn(ScriptArg_t arg);
1219  void scriptOpItemHighlightSetTrue(ScriptArg_t arg);
1220 
1221  // AD2044 ops
1222  void scriptOpAnimAD2044(bool isForward);
1223  void scriptOpAnimT(ScriptArg_t arg);
1224  void scriptOpAnimForward(ScriptArg_t arg);
1225  void scriptOpAnimReverse(ScriptArg_t arg);
1226  void scriptOpAnimKForward(ScriptArg_t arg);
1227  void scriptOpNoUpdate(ScriptArg_t arg);
1228  void scriptOpNoClear(ScriptArg_t arg);
1229  void scriptOpSay1_AD2044(ScriptArg_t arg);
1230  void scriptOpSay2_AD2044(ScriptArg_t arg);
1231  void scriptOpSay1Rnd(ScriptArg_t arg);
1232  void scriptOpM(ScriptArg_t arg);
1233  void scriptOpEM(ScriptArg_t arg);
1234  void scriptOpSE(ScriptArg_t arg);
1235  void scriptOpSDot(ScriptArg_t arg);
1236  void scriptOpE(ScriptArg_t arg);
1237  void scriptOpDot(ScriptArg_t arg);
1238  void scriptOpSound(ScriptArg_t arg);
1239  void scriptOpISound(ScriptArg_t arg);
1240  void scriptOpUSound(ScriptArg_t arg);
1241  void scriptOpSayCycle_AD2044(const StackInt_t *values, uint numValues);
1242  void scriptOpSay2K(ScriptArg_t arg);
1243  void scriptOpSay3K(ScriptArg_t arg);
1244  void scriptOpRGet(ScriptArg_t arg);
1245  void scriptOpRSet(ScriptArg_t arg);
1246  void scriptOpEndRSet(ScriptArg_t arg);
1247  void scriptOpStop(ScriptArg_t arg);
1248 
1249  Common::Array<Common::SharedPtr<AnimatedCursor> > _cursors; // Cursors indexed as CURSOR_CUR_##
1250  Common::Array<Common::SharedPtr<AnimatedCursor> > _cursorsShort; // Cursors indexed as CURSOR_#
1251 
1252  InventoryItem _inventory[kNumInventorySlots];
1253  InventoryItem _inventoryPages[kNumInventoryPages][kNumInventorySlots];
1254  Common::HashMap<uint32, uint8> _placedItems;
1255  uint8 _inventoryActivePage;
1256  InventoryItem _inventoryActiveItem;
1257  InventoryItem _inventoryPlacedItemCache;
1258  Common::Rect _placedItemRect;
1259 
1260  Common::SharedPtr<Graphics::Surface> _trayCompassGraphic;
1261  Common::SharedPtr<Graphics::Surface> _trayBackgroundGraphic;
1262  Common::SharedPtr<Graphics::Surface> _trayHighlightGraphic;
1263  Common::SharedPtr<Graphics::Surface> _trayCornerGraphic;
1264  Common::SharedPtr<Graphics::Surface> _backgroundGraphic;
1265 
1267 
1268  uint _panCursors[kPanCursorMaxCount];
1269 
1271  Common::HashMap<StackInt_t, uint> _scriptCursorIDToResourceIDOverride;
1272 
1273  OSystem *_system;
1274  uint _roomNumber; // Room number can be changed independently of the loaded room, the screen doesn't change until a command changes it
1275  uint _screenNumber;
1276  uint _direction;
1277  uint _hero;
1278  uint _disc;
1279 
1280  uint _swapOutRoom;
1281  uint _swapOutScreen;
1282  uint _swapOutDirection;
1283 
1284  GyroState _gyros;
1285 
1286  AnimationDef _panLeftAnimationDef;
1287  AnimationDef _panRightAnimationDef;
1288  bool _haveHorizPanAnimations;
1289  bool _havePanUpFromDirection[kNumDirections];
1290  bool _havePanDownFromDirection[kNumDirections];
1291 
1292  StaticAnimation _idleAnimations[kNumDirections];
1293  bool _haveIdleAnimations[kNumDirections];
1294  bool _haveIdleStaticAnimation;
1295  bool _keepStaticAnimationInIdle;
1296  Common::String _idleCurrentStaticAnimation;
1297  StaticAnimParams _pendingStaticAnimParams;
1298 
1299  uint32 _delayCompletionTime;
1300 
1301  AnimationDef _postFacingAnimDef;
1302 
1303  Common::SharedPtr<CircuitPuzzle> _circuitPuzzle;
1304  AnimationDef _circuitPuzzleBlockAnimation;
1305  AnimationDef _circuitPuzzleConnectAnimation;
1306 
1307  Common::HashMap<uint32, int32> _variables;
1309 
1310  uint _panoramaDirectionFlags;
1311 
1312  uint _loadedRoomNumber;
1313  uint _activeScreenNumber;
1314  bool _havePendingScreenChange;
1315  bool _forceScreenChange;
1316 
1317  // returnToIdleState executes any actions that must be executed upon returning to idle state from either
1318  // a panorama or the first script that executes upon reaching a screen.
1319  //
1320  // Unfortunately, this was done slightly prematurely since Schizm plays idle animations during pre-idle
1321  // delays and Reah never needs to do that, so _havePendingPreIdleActions exists to handle those actions
1322  // during pre-idle upon arriving at a screen.
1323  //
1324  // Pre-idle actions are executed once upon either entering Idle OR Delay state.
1325  bool _havePendingPreIdleActions;
1326  bool _havePendingReturnToIdleState;
1327  bool _havePendingPostSwapScreenReset;
1328 
1329  bool _havePendingCompletionCheck;
1330  GameState _gameState;
1331 
1332  Common::SharedPtr<MenuPage> _menuPage;
1333  Common::SharedPtr<MenuInterface> _menuInterface;
1334 
1335  bool _havePendingPlayAmbientSounds;
1336  uint32 _ambientSoundFinishTime;
1337 
1338  bool _escOn;
1339  bool _debugMode;
1340  bool _fastAnimationMode;
1341  bool _preloadSounds;
1342  bool _lowQualityGraphicsMode;
1343 
1344  VCruiseGameID _gameID;
1345 
1347  Common::Array<uint> _roomDuplicationOffsets;
1348  RoomToScreenNameToRoomMap_t _globalRoomScreenNameToScreenIDs;
1349  Common::SharedPtr<ScriptSet> _scriptSet;
1350  Common::Array<AD2044AnimationDef> _ad2044AnimationDefs;
1351 
1352  Common::Array<CallStackFrame> _scriptCallStack;
1353 
1354  Common::Array<StackValue> _scriptStack;
1355  ScriptEnvironmentVars _scriptEnv;
1356 
1358 
1359  Common::SharedPtr<AudioPlayer> _musicWavePlayer;
1360  Common::Mutex _midiPlayerMutex;
1361  Common::SharedPtr<MidiPlayer> _musicMidiPlayer;
1362  int _musicTrack;
1363  int32 _musicVolume;
1364  bool _musicActive;
1365  bool _musicMute;
1366  bool _musicMuteDisabled;
1367 
1368  Common::String _scoreTrack;
1369  Common::String _scoreSection;
1370  uint32 _scoreSectionEndTime;
1372 
1373  uint32 _musicVolumeRampStartTime;
1374  int32 _musicVolumeRampStartVolume;
1375  int32 _musicVolumeRampRatePerMSec;
1376  int32 _musicVolumeRampEnd;
1377 
1378  SfxData _sfxData;
1379 
1381  Common::SharedPtr<SfxPlaylist> _animPlaylist;
1382  AnimDecoderState _animDecoderState;
1383  bool _animTerminateAtStartOfFrame;
1384  uint _animPendingDecodeFrame;
1385  uint _animDisplayingFrame;
1386  uint _animFirstFrame;
1387  uint _animLastFrame;
1388  uint _animStopFrame;
1389  uint _animVolume;
1390  Fraction _animFrameRateLock;
1391  Common::Rect _animConstraintRect;
1392  uint32 _animStartTime;
1393  uint32 _animFramesDecoded;
1394  uint _loadedAnimation;
1395  bool _loadedAnimationHasSound;
1396  bool _animPlayWhileIdle;
1397 
1398  Common::Array<FrameData> _frameData;
1399  Common::Array<FrameData2> _frameData2;
1400  //uint32 _loadedArea;
1401 
1402  // Reah/Schizm animation map
1403  Common::Array<Common::String> _animDefNames;
1404  Common::HashMap<Common::String, uint> _animDefNameToIndex;
1405 
1406  // AD2044 animation map
1407  Common::HashMap<int, AnimFrameRange> _currentRoomAnimIDToFrameRange;
1408  Common::HashMap<int, AnimFrameRange> _examineAnimIDToFrameRange;
1409 
1410  bool _idleLockInteractions;
1411  bool _idleIsOnInteraction;
1412  bool _idleHaveClickInteraction;
1413  bool _idleHaveDragInteraction;
1414  uint _idleInteractionID;
1415 
1416  bool _idleIsOnOpenCircuitPuzzleLink;
1417  Common::Rect _idleCircuitPuzzleLinkHighlightRect;
1418 
1419  bool _idleIsCircuitPuzzleLinkDown;
1420  Common::Point _idleCircuitPuzzleCoord;
1421 
1422  bool _forceAllowSaves;
1423 
1424  InGameMenuState _inGameMenuState;
1425  uint _inGameMenuActiveElement;
1426  bool _inGameMenuButtonActive[5];
1427 
1428  Audio::Mixer *_mixer;
1429  MidiDriver *_midiDrv;
1430 
1431  Common::SharedPtr<MapLoader> _mapLoader;
1432 
1433  RenderSection _gameSection;
1434  RenderSection _gameDebugBackBuffer;
1435  RenderSection _menuSection;
1436  RenderSection _traySection;
1437  RenderSection _fullscreenMenuSection;
1438  RenderSection _subtitleSection;
1439  RenderSection _placedItemBackBufferSection;
1440 
1441  Common::Point _mousePos;
1442  Common::Point _lmbDownPos;
1443  uint32 _lmbDownTime;
1444  int _lmbDragTolerance;
1445  bool _lmbDown;
1446  bool _lmbDragging;
1447  bool _lmbReleaseWasClick; // If true, then the mouse didn't move at all since the LMB down
1448 
1449  PanoramaState _panoramaState;
1450  // 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
1451  // 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
1452  // is moved by roughly the margin amount.
1453  // Vertical panning on the other hand resets the anchor vertical coordinate every time.
1454  Common::Point _panoramaAnchor;
1455 
1456  Common::Array<OSEvent> _pendingEvents;
1457 
1460  SoundParams3D _pendingSoundParams3D;
1461 
1462  Common::Array<TriggeredOneShot> _triggeredOneShots;
1463  Common::HashMap<uint32, uint> _sayCycles;
1464  Common::Array<RandomAmbientSound> _randomAmbientSounds;
1465 
1466  int32 _listenerX;
1467  int32 _listenerY;
1468  int32 _listenerAngle;
1469 
1470  Fraction _animSpeedRotation;
1471  Fraction _animSpeedStaticAnim;
1472  Fraction _animSpeedDefault;
1473 
1474  static const uint kAnimDefStackArgs = 8;
1475 
1476  static const uint kCursorArrow = 0;
1477  static const uint kCursorWait = 29;
1478 
1479  static const int kPanoramaPanningMarginX = 11;
1480  static const int kPanoramaPanningMarginY = 11;
1481 
1482  static const uint kSoundCacheSize = 16;
1483 
1484  static const uint kExamineItemInteractionID = 0xfffffff0u;
1485 
1486  static const uint kReturnInventorySlot0InteractionID = 0xfffffff1u;
1487  static const uint kReturnInventorySlot1InteractionID = 0xfffffff2u;
1488  static const uint kReturnInventorySlot2InteractionID = 0xfffffff3u;
1489  static const uint kReturnInventorySlot3InteractionID = 0xfffffff4u;
1490  static const uint kReturnInventorySlot4InteractionID = 0xfffffff5u;
1491  static const uint kReturnInventorySlot5InteractionID = 0xfffffff6u;
1492 
1493  static const uint kPickupInventorySlot0InteractionID = 0xfffffff7u;
1494  static const uint kPickupInventorySlot1InteractionID = 0xfffffff8u;
1495  static const uint kPickupInventorySlot2InteractionID = 0xfffffff9u;
1496  static const uint kPickupInventorySlot3InteractionID = 0xfffffffau;
1497  static const uint kPickupInventorySlot4InteractionID = 0xfffffffbu;
1498  static const uint kPickupInventorySlot5InteractionID = 0xfffffffcu;
1499 
1500  static const uint kObjectPickupInteractionID = 0xfffffffdu;
1501  static const uint kObjectDropInteractionID = 0xfffffffeu;
1502 
1503  static const uint kHeroChangeInteractionID = 0xffffffffu;
1504 
1505  Common::Pair<Common::String, Common::SharedPtr<SoundCache> > _soundCache[kSoundCacheSize];
1506  uint _soundCacheIndex;
1507 
1508  Common::SharedPtr<SaveGameSnapshot> _mostRecentValidSaveState; // Always valid
1509  Common::SharedPtr<SaveGameSnapshot> _mostRecentlyRecordedSaveState; // Might be invalid, becomes valid if the player returns to idle
1511  bool _isInGame;
1512 
1513  const Graphics::Font *_subtitleFont;
1514  Common::SharedPtr<Graphics::Font> _subtitleFontKeepalive;
1515  uint _defaultLanguageIndex;
1516  uint _languageIndex;
1517  Common::Language _language;
1518  CharSet _charSet;
1519  bool _isCDVariant;
1520  StartConfigDef _startConfigs[kNumStartConfigs];
1521 
1522  Common::Language _defaultLanguage;
1523 
1527 
1528  AnimSubtitleMap_t _animSubtitles;
1530  Common::Array<SubtitleQueueItem> _subtitleQueue;
1531  bool _isDisplayingSubtitles;
1532  bool _isSubtitleSourceAnimation;
1533 
1537 
1539 
1540  AnimatedCursor *_currentAnimatedCursor;
1541  Graphics::Cursor *_currentCursor;
1542  uint32 _cursorTimeBase;
1543  uint32 _cursorCycleLength;
1544 
1545  int32 _dbToVolume[49];
1546 
1547  // AD2044 tooltips
1548  Common::String _tooltipText;
1549  Common::String _subtitleText;
1550 
1551  Common::SharedPtr<AD2044Graphics> _ad2044Graphics;
1552  Common::Array<Common::String> _ad2044ItemNames;
1553 };
1554 
1555 } // End of namespace VCruise
1556 
1557 #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:82
Definition: runtime.h:613
Definition: runtime.h:357
Definition: script.h:277
Definition: stream.h:77
Definition: runtime.h:132
Definition: runtime.h:626
Definition: array.h:52
Definition: menu.h:72
Definition: pixelformat.h:138
Definition: runtime.h:592
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:300
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:639
Definition: runtime.h:246
Definition: runtime.h:627
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:582
Definition: movie_decoder.h:32
Definition: runtime.h:310
Definition: runtime.h:604
Definition: runtime.h:162
Definition: runtime.h:323
Definition: system.h:38
Language
Definition: language.h:45