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