ScummVM API documentation
freescape.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 FREESCAPE_H
23 #define FREESCAPE_H
24 
25 #include "common/bitarray.h"
26 #include "common/events.h"
27 #include "common/file.h"
28 #include "common/memstream.h"
29 #include "engines/advancedDetector.h"
30 #include "graphics/managed_surface.h"
31 #include "graphics/surface.h"
32 
33 
34 #include "audio/decoders/wave.h"
35 #include "audio/mixer.h"
36 #include "audio/softsynth/pcspk.h"
37 #include "graphics/framelimiter.h"
38 
39 #include "freescape/area.h"
40 #include "freescape/font.h"
41 #include "freescape/gfx.h"
42 #include "freescape/objects/entrance.h"
43 #include "freescape/objects/geometricobject.h"
44 #include "freescape/objects/sensor.h"
45 #include "freescape/sound.h"
46 
47 namespace Common {
48 class RandomSource;
49 }
50 
51 namespace Freescape {
52 
53 class Renderer;
54 
55 #define FREESCAPE_DATA_BUNDLE "freescape.dat"
56 
57 enum CameraMovement {
58  kForwardMovement,
59  kBackwardMovement,
60  kLeftMovement,
61  kRightMovement
62 };
63 
64 enum FreescapeAction {
65  kActionNone,
66  kActionEscape,
67  kActionSave,
68  kActionLoad,
69  kActionToggleSound,
70  kActionMoveUp,
71  kActionMoveDown,
72  kActionMoveLeft,
73  kActionMoveRight,
74  kActionShoot,
75  kActionIncreaseAngle,
76  kActionDecreaseAngle,
77  kActionChangeStepSize,
78  kActionToggleRiseLower,
79  kActionRiseOrFlyUp,
80  kActionLowerOrFlyDown,
81  kActionChangeMode,
82  kActionSkip,
83  kActionFaceForward,
84  kActionRotateUp,
85  kActionRotateDown,
86  kActionRotateLeft,
87  kActionRotateRight,
88  kActionTurnBack,
89  kActionInfoMenu,
90  kActionIncreaseStepSize,
91  kActionDecreaseStepSize,
92  kActionToggleFlyMode,
93  kActionToggleClipMode,
94  // Driller
95  kActionDeployDrillingRig,
96  kActionCollectDrillingRig,
97  kActionRollLeft,
98  kActionRollRight,
99  // Total Eclipse
100  kActionRest,
101  // Castle
102  kActionRunMode,
103  kActionWalkMode,
104  kActionCrawlMode,
105  kActionSelectPrince,
106  kActionSelectPrincess,
107  kActionQuit,
108  // Demo actions
109  kActionUnknownKey,
110  kActionWait
111 };
112 
113 typedef Common::HashMap<uint16, Area *> AreaMap;
114 typedef Common::Array<byte *> ColorMap;
115 typedef Common::HashMap<uint16, int32> StateVars;
116 
117 enum {
118  kFreescapeDebugMove = 1,
119  kFreescapeDebugParser,
120  kFreescapeDebugCode,
121  kFreescapeDebugMedia,
122  kFreescapeDebugGroup,
123 };
124 
125 enum {
126  kFreescapeDefaultVolume = 192,
127 };
128 
129 enum GameStateControl {
130  kFreescapeGameStateStart,
131  kFreescapeGameStatePlaying,
132  kFreescapeGameStateDemo,
133  kFreescapeGameStateEnd,
134  kFreescapeGameStateRestart,
135 };
136 
138  int areaId;
139  byte *palette;
140 };
141 
142 extern Common::String shiftStr(const Common::String &str, int shift);
143 extern Common::String centerAndPadString(const Common::String &str, int size);
144 
146 public:
148  // EventManager API
149  bool pollEvent(Common::Event &event);
150  void purgeKeyboardEvents();
151  void purgeMouseEvents();
152  void pushEvent(Common::Event &event);
153  void clearExitEvents();
154  bool isActionActive(const Common::CustomEventType &action);
155 
156 private:
157  // for continuous events (keyDown)
158  enum {
159  kKeyRepeatInitialDelay = 400,
160  kKeyRepeatSustainDelay = 100
161  };
162 
163  Common::EventManager *_delegate;
164 
165  Common::KeyState _currentKeyDown;
166  Common::CustomEventType _currentActionDown;
167  uint32 _keyRepeatTime;
168 };
169 
170 class FreescapeEngine : public Engine {
171 
172 public:
173  FreescapeEngine(OSystem *syst, const ADGameDescription *gd);
174  ~FreescapeEngine();
175 
176  const ADGameDescription *_gameDescription;
177  GameStateControl _gameStateControl;
178  bool isDemo() const;
179 
180  // Game selection
181  uint32 _variant;
182  Common::Language _language;
183  bool isSpaceStationOblivion() { return _targetName.hasPrefix("spacestationoblivion"); }
184  bool isDriller() { return _targetName.hasPrefix("driller") || _targetName.hasPrefix("spacestationoblivion"); }
185  bool isDark() { return _targetName.hasPrefix("darkside"); }
186  bool isEclipse() { return _targetName.hasPrefix("totaleclipse"); } // This will match Total Eclipse 1 and 2.
187  bool isEclipse2() { return _targetName.hasPrefix("totaleclipse2"); }
188  bool isCastle() { return _targetName.hasPrefix("castle"); }
189  bool isAmiga() { return _gameDescription->platform == Common::kPlatformAmiga; }
190  bool isAtariST() { return _gameDescription->platform == Common::kPlatformAtariST; }
191  bool isDOS() { return _gameDescription->platform == Common::kPlatformDOS; }
192  bool isSpectrum() { return _gameDescription->platform == Common::kPlatformZX; }
193  bool isCPC() { return _gameDescription->platform == Common::kPlatformAmstradCPC; }
194  bool isC64() { return _gameDescription->platform == Common::kPlatformC64; }
195 
196  Common::Error run() override;
197 
198  // UI
199  Common::Rect _viewArea;
200  Common::Rect _fullscreenViewArea;
201  void centerCrossair();
202 
203  virtual void borderScreen();
204  virtual void titleScreen();
205 
206  void drawFullscreenSurface(Graphics::Surface *surface);
207  virtual void loadBorder();
208  virtual void processBorder();
209  void waitInLoop(int maxWait);
210  void drawBorder();
211  void drawTitle();
212  virtual void drawBackground();
213  void clearBackground();
214  virtual void drawUI();
215  virtual void drawInfoMenu();
216  void drawBorderScreenAndWait(Graphics::Surface *surface, int maxWait = INT_MAX);
217 
218  virtual void drawCrossair(Graphics::Surface *surface);
219  Graphics::ManagedSurface *_border;
220  Graphics::ManagedSurface *_title;
221  Graphics::ManagedSurface *_background;
222 
223  Texture *_borderTexture;
224  Texture *_titleTexture;
225  Texture *_uiTexture;
226  Texture *_skyTexture;
227 
229  Common::HashMap<uint16, Texture *> _borderCGAByArea;
230  Common::HashMap<uint16, byte *> _paletteCGAByArea;
231 
232  // Parsing assets
233  uint8 _binaryBits;
234  virtual void loadAssets();
235  virtual void loadAssetsDemo();
236  virtual void loadAssetsFullGame();
237 
238  virtual void loadAssetsAtariFullGame();
239  virtual void loadAssetsAtariDemo();
240 
241  virtual void loadAssetsAmigaFullGame();
242  virtual void loadAssetsAmigaDemo();
243 
244  virtual void loadAssetsDOSFullGame();
245  virtual void loadAssetsDOSDemo();
246 
247  virtual void loadAssetsZXFullGame();
248  virtual void loadAssetsZXDemo();
249 
250  virtual void loadAssetsCPCFullGame();
251  virtual void loadAssetsCPCDemo();
252 
253  virtual void loadAssetsC64FullGame();
254  virtual void loadAssetsC64Demo();
255 
256  virtual void drawDOSUI(Graphics::Surface *surface);
257  virtual void drawZXUI(Graphics::Surface *surface);
258  virtual void drawCPCUI(Graphics::Surface *surface);
259  virtual void drawC64UI(Graphics::Surface *surface);
260  virtual void drawAmigaAtariSTUI(Graphics::Surface *surface);
261 
262  Common::Archive *_dataBundle;
263  void loadDataBundle();
264  Graphics::Surface *loadBundledImage(const Common::String &name, bool appendRenderMode = true);
265  byte *getPaletteFromNeoImage(Common::SeekableReadStream *stream, int offset);
266  Graphics::ManagedSurface *loadAndConvertNeoImage(Common::SeekableReadStream *stream, int offset, byte *palette = nullptr);
267  Graphics::ManagedSurface *loadAndConvertScrImage(Common::SeekableReadStream *stream);
268  Graphics::ManagedSurface *loadAndConvertDoodleImage(Common::SeekableReadStream *bitmap, Common::SeekableReadStream *color1, Common::SeekableReadStream *color2, byte *palette);
269 
270  void loadPalettes(Common::SeekableReadStream *file, int offset);
271  byte *loadPalette(Common::SeekableReadStream *file);
272  void swapPalette(uint16 areaID);
273  virtual byte *findCGAPalette(uint16 levelID);
274  Common::HashMap<uint16, byte *> _paletteByArea;
275  void loadColorPalette();
276 
277  // Demo
278  Common::Array<byte> _demoData;
279  int _demoIndex;
280  int _currentDemoInputCode;
281  int _currentDemoInputRepetition;
282  Common::Array<Common::Event> _demoEvents;
283  Common::Point _currentDemoMousePosition;
284  void loadDemoData(Common::SeekableReadStream *file, int offset, int size);
285  int decodeAmigaAtariKey(int code);
286  int decodeDOSKey(int code);
287  Common::Event decodeDOSMouseEvent(int code, int repetition);
288 
289  uint16 readField(Common::SeekableReadStream *file, int nbits);
290  uint16 readPtr(Common::SeekableReadStream *file);
291  Common::Array<uint16> readArray(Common::SeekableReadStream *file, int size);
292 
293  // 8-bit
294  void load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors);
295  Area *load8bitArea(Common::SeekableReadStream *file, uint16 ncolors);
296  Object *load8bitObject(Common::SeekableReadStream *file);
297  Group *load8bitGroup(Common::SeekableReadStream *file, byte rawFlagsAndType);
298  Group *load8bitGroupV1(Common::SeekableReadStream *file, byte rawFlagsAndType);
299  Group *load8bitGroupV2(Common::SeekableReadStream *file, byte rawFlagsAndType);
300 
301  void loadGlobalObjects(Common::SeekableReadStream *file, int offset, int size);
302  void renderPixels8bitBinImage(Graphics::ManagedSurface *surface, int row, int column, int bit, int count);
303 
304  void renderPixels8bitBinCGAImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color);
305  void renderPixels8bitBinEGAImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color);
306 
307  Graphics::ManagedSurface *load8bitBinImage(Common::SeekableReadStream *file, int offset);
308  void load8bitBinImageRow(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int row);
309  void load8bitBinImageRowIteration(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int row, int bit);
310  int execute8bitBinImageCommand(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int row, int pixels, int bit);
311  int execute8bitBinImageSingleCommand(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int row, int pixels, int bit, int count);
312  int execute8bitBinImageMultiCommand(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int row, int pixels, int bit, int count);
313 
314  void parseAmigaAtariHeader(Common::SeekableReadStream *file);
315  Common::SeekableReadStream *decryptFileAmigaAtari(const Common::Path &packed, const Common::Path &unpacker, uint32 unpackArrayOffset);
316 
317  // Areas
318  uint16 _startArea;
319  uint16 _endArea;
320  AreaMap _areaMap;
321  Area *_currentArea;
322  bool _gotoExecuted;
323  Math::Vector3d _scale;
324 
325  virtual void gotoArea(uint16 areaID, int entranceID);
326  // Entrance
327  uint16 _startEntrance;
328  uint16 _endEntrance;
330 
331  // Input
332  bool _demoMode;
333  bool _disableDemoMode;
334  bool _flyMode;
335  bool _shootMode;
336  bool _noClipMode;
337  bool _invertY;
338 
339  bool _smoothMovement;
340  // Player movement state
341  bool _moveForward;
342  bool _moveBackward;
343  bool _strafeLeft;
344  bool _strafeRight;
345  bool _moveUp;
346  bool _moveDown;
347 
348  virtual void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target);
349  EventManagerWrapper *_eventManager;
350  void processInput();
351  void resetInput();
352  void stopMovement();
353  void generateDemoInput();
354  virtual void pressedKey(const int keycode);
355  virtual void releasedKey(const int keycode);
356  Common::Point getNormalizedPosition(Common::Point position);
357  virtual bool onScreenControls(Common::Point mouse);
358  void updatePlayerMovement(float deltaTime);
359  void updatePlayerMovementSmooth(float deltaTime);
360  void updatePlayerMovementClassic(float deltaTime);
361  void resolveCollisions(Math::Vector3d newPosition);
362  virtual void checkIfStillInArea();
363  void changePlayerHeight(int index);
364  void increaseStepSize();
365  void decreaseStepSize();
366  void changeStepSize();
367 
368  void changeAngle(int offset, bool wrapAround);
369  bool rise();
370  void lower();
371  bool checkFloor(Math::Vector3d currentPosition);
372  bool tryStepUp(Math::Vector3d currentPosition);
373  bool tryStepDown(Math::Vector3d currentPosition);
374  bool _hasFallen;
375  bool _isCollidingWithWall;
376  bool _isSteppingUp;
377  bool _isSteppingDown;
378  bool _isFalling;
379  int _maxFallingDistance;
380  int _maxShield;
381  int _maxEnergy;
382 
383  void rotate(float xoffset, float yoffset, float zoffset);
384  // Input state
385  float _lastFrame;
386 
387  // Interaction
388  void activate();
389  void shoot();
390  void traverseEntrance(uint16 entranceID);
391 
392  // Euler Angles
393  float _yaw;
394  float _pitch;
395  int _roll;
396  int _angleRotationIndex;
397  Common::Array<float> _angleRotations;
398 
399  Math::Vector3d directionToVector(float pitch, float heading, bool useTable);
400  void updateCamera();
401 
402  // Camera options
403  Common::Point _crossairPosition;
404  float _mouseSensitivity;
405  Math::Vector3d _upVector; // const
406  Math::Vector3d _cameraFront, _cameraRight;
407  // Spacial attributes
408  Math::Vector3d _position, _rotation, _velocity;
409  Math::Vector3d _lastPosition;
410  int _playerHeightNumber;
411  int _playerHeightMaxNumber;
412  uint16 _playerHeight;
413  uint16 _playerWidth;
414  uint16 _playerDepth;
415  uint16 _stepUpDistance;
416 
417  int _playerStepIndex;
418  Common::Array<int> _playerSteps;
419 
420  Common::Point crossairPosToMousePos(const Common::Point &crossairPos);
421  Common::Point mousePosToCrossairPos(const Common::Point &mousePos);
422  void warpMouseToCrossair(void);
423 
424  // Effects
425  Common::Array<Common::String> _conditionSources;
427 
428  bool runCollisionConditions(Math::Vector3d const lastPosition, Math::Vector3d const newPosition);
429  Math::Vector3d _objExecutingCodeSize;
430  bool _executingGlobalCode;
431  virtual void executeMovementConditions();
432  bool executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated);
433  void executeEntranceConditions(Entrance *entrance);
434  void executeLocalGlobalConditions(bool shot, bool collided, bool timer);
435  bool executeCode(FCLInstructionVector &code, bool shot, bool collided, bool timer, bool activated);
436 
437  // Instructions
438  bool checkConditional(FCLInstruction &instruction, bool shot, bool collided, bool timer, bool activated);
439  bool checkIfGreaterOrEqual(FCLInstruction &instruction);
440  bool checkIfLessOrEqual(FCLInstruction &instruction);
441  void executeExecute(FCLInstruction &instruction, bool shot, bool collided, bool activated);
442  void executeIncrementVariable(FCLInstruction &instruction);
443  void executeDecrementVariable(FCLInstruction &instruction);
444  void executeSetVariable(FCLInstruction &instruction);
445  void executeGoto(FCLInstruction &instruction);
446  void executeIfThenElse(FCLInstruction &instruction);
447  virtual void executeMakeInvisible(FCLInstruction &instruction);
448  void executeMakeVisible(FCLInstruction &instruction);
449  void executeToggleVisibility(FCLInstruction &instruction);
450  virtual void executeDestroy(FCLInstruction &instruction);
451  virtual void executeRedraw(FCLInstruction &instruction);
452  void executeSound(FCLInstruction &instruction);
453  void executeDelay(FCLInstruction &instruction);
454  bool executeEndIfNotEqual(FCLInstruction &instruction);
455  void executeSetBit(FCLInstruction &instruction);
456  void executeClearBit(FCLInstruction &instruction);
457  void executeToggleBit(FCLInstruction &instruction);
458  bool executeEndIfBitNotEqual(FCLInstruction &instruction);
459  bool executeEndIfVisibilityIsEqual(FCLInstruction &instruction);
460  void executeSwapJet(FCLInstruction &instruction);
461  virtual void executePrint(FCLInstruction &instruction);
462  void executeSPFX(FCLInstruction &instruction);
463  void executeStartAnim(FCLInstruction &instruction);
464 
465  // Sound
466  Audio::SoundHandle _soundFxHandle;
467  Audio::SoundHandle _musicHandle;
468  Audio::SoundHandle _movementSoundHandle;
469  Freescape::SizedPCSpeaker *_speaker;
470 
471  bool _syncSound;
472  bool _firstSound;
473  bool _usePrerecordedSounds;
474  void waitForSounds();
475  void stopAllSounds(Audio::SoundHandle &handle);
476  bool isPlayingSound();
477  void playSound(int index, bool sync, Audio::SoundHandle &handle);
478  void playWav(const Common::Path &filename);
479  void playMusic(const Common::Path &filename);
480  void queueSoundConst(double hzFreq, int duration);
481  void playSilence(int duration, bool sync);
482  void playSoundConst(double hzFreq, int duration, bool sync);
483  void playSoundSweepIncWL(double hzFreq1, double hzFreq2, double wlStepPerMS, int resolution, bool sync);
484  uint16 playSoundDOSSpeaker(uint16 startFrequency, soundSpeakerFx *speakerFxInfo);
485  void playSoundDOS(soundSpeakerFx *speakerFxInfo, bool sync, Audio::SoundHandle &handle);
486 
487  virtual void playSoundFx(int index, bool sync);
488  virtual void loadSoundsFx(Common::SeekableReadStream *file, int offset, int number);
490  void loadSpeakerFxDOS(Common::SeekableReadStream *file, int offsetFreq, int offsetDuration);
491  void loadSpeakerFxZX(Common::SeekableReadStream *file, int sfxTable, int sfxData);
493 
494  void playSoundZX(Common::Array<soundUnitZX> *data, Audio::SoundHandle &handle);
496  int _soundIndexShoot;
497  int _soundIndexCollide;
498  int _soundIndexFall;
499  int _soundIndexClimb;
500  int _soundIndexMenu;
501  int _soundIndexStart;
502  int _soundIndexAreaChange;
503  int _soundIndexHit;
504 
505  int _soundIndexNoShield;
506  int _soundIndexNoEnergy;
507  int _soundIndexFallen;
508  int _soundIndexTimeout;
509  int _soundIndexForceEndGame;
510  int _soundIndexCrushed;
511  int _soundIndexMissionComplete;
512 
513  // Rendering
514  int _screenW, _screenH;
515  Renderer *_gfx;
516  Graphics::FrameLimiter *_frameLimiter;
517  bool _vsyncEnabled;
518  Common::RenderMode _renderMode;
519  ColorMap _colorMap;
520  int _underFireFrames;
521  int _avoidRenderingFrames;
522  int _shootingFrames;
523  GeometricObject *_delayedShootObject;
524  void drawFrame();
525  void flashScreen(int backgroundColor);
526  uint8 _colorNumber;
527  Math::Vector3d _scaleVector;
528  float _nearClipPlane;
529  float _farClipPlane;
530 
531  // Text messages and Fonts
532  void insertTemporaryMessage(const Common::String &message, int deadline);
533  void getLatestMessages(Common::String &message, int &deadline);
534  void clearTemporalMessages();
535  Common::StringArray _temporaryMessages;
536  Common::Array<int> _temporaryMessageDeadlines;
537  Common::StringArray _messagesList;
538  Common::String _noShieldMessage;
539  Common::String _noEnergyMessage;
540  Common::String _fallenMessage;
541  Common::String _timeoutMessage;
542  Common::String _forceEndGameMessage;
543  Common::String _crushedMessage;
544  Common::String _outOfReachMessage;
545  Common::String _noEffectMessage;
546 
547  void loadMessagesFixedSize(Common::SeekableReadStream *file, int offset, int size, int number);
548  virtual void loadMessagesVariableSize(Common::SeekableReadStream *file, int offset, int number);
549  void drawFullscreenMessageAndWait(Common::String message);
550  void drawFullscreenMessage(Common::String message, uint32 front, Graphics::Surface *surface);
551 
552  // Font loading and rendering
553  void loadFonts(Common::SeekableReadStream *file, int offset);
554  void loadFonts(byte *font, int charNumber);
555  Common::Array<Graphics::ManagedSurface *> getChars(Common::SeekableReadStream *file, int offset, int charsNumber);
556  Common::Array<Graphics::ManagedSurface *> getCharsAmigaAtariInternal(int sizeX, int sizeY, int additional, int m1, int m2, Common::SeekableReadStream *file, int offset, int charsNumber);
557  Common::Array<Graphics::ManagedSurface *> getCharsAmigaAtari(Common::SeekableReadStream *file, int offset, int charsNumber);
558  Common::StringArray _currentAreaMessages;
559  Common::StringArray _currentEphymeralMessages;
560  Font _font;
561  bool _fontLoaded;
562  virtual void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
563  virtual void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
564  Graphics::Surface *drawStringsInSurface(const Common::Array<Common::String> &lines, Graphics::Surface *surface);
565 
566  // Game state
567  virtual void initGameState();
568  void setGameBit(int index);
569  void clearGameBit(int index);
570  void toggleGameBit(int index);
571  uint16 getGameBit(int index);
572 
573  StateVars _gameStateVars;
574  uint32 _gameStateBits;
575  void checkIfPlayerWasCrushed();
576  virtual bool checkIfGameEnded();
577  virtual void endGame();
578  int _endGameDelayTicks;
579  bool _endGameKeyPressed;
580  bool _endGamePlayerEndArea;
581  bool _forceEndGame;
582  bool _playerWasCrushed;
583  Common::HashMap<uint16, bool> _exploredAreas;
584  ObjectArray _sensors;
585  virtual void checkSensors();
586  virtual void drawSensorShoot(Sensor *sensor);
587  void takeDamageFromSensor();
588 
589  bool hasFeature(EngineFeature f) const override;
590  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
591  bool canSaveAutosaveCurrently() override { return false; }
592  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _gameStateControl == kFreescapeGameStatePlaying && _currentArea; }
593  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
594  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
595  virtual Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false);
596  virtual Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream);
597  Graphics::Surface *_savedScreen;
598 
599  void pauseEngineIntern(bool pause) override;
600 
601  // Timers
602  bool startCountdown(uint32 delay);
603  void removeTimers();
604  bool _timerStarted;
605  int _initialCountdown;
606  int _countdown;
607  int _ticks;
608  int _ticksFromEnd;
609  int _lastTick;
610  int _lastMinute;
611 
612  void getTimeFromCountdown(int &seconds, int &minutes, int &hours);
613  virtual void updateTimeVariables();
614 
615  // Cheats
616  bool _useExtendedTimer;
617  bool _disableSensors;
618  bool _disableFalling;
619 
620  // Random
621  Common::RandomSource *_rnd;
622 
623  // C64 specifics
624  byte *decompressC64RLE(byte *buffer, int *size, byte marker);
625  byte *_extraBuffer;
626 };
627 
628 enum GameReleaseFlags {
629  GF_AMIGA_RETAIL = (1 << 0),
630  GF_AMIGA_BUDGET = (1 << 1),
631  GF_ZX_RETAIL = (1 << 2),
632  GF_ZX_BUDGET = (1 << 3),
633  GF_ZX_DISC = (1 << 4),
634  GF_CPC_RETAIL = (1 << 5),
635  GF_CPC_RETAIL_ALT = (1 << 6),
636  GF_CPC_BUDGET = (1 << 7),
637  GF_CPC_VIRTUALWORLDS = (1 << 8),
638  GF_ATARI_RETAIL = (1 << 9),
639  GF_ATARI_BUDGET = (1 << 10),
640  GF_C64_TAPE = (1 << 11),
641  GF_C64_DISC = (1 << 12),
642 };
643 
644 extern FreescapeEngine *g_freescape;
645 
646 } // namespace Freescape
647 
648 #endif // FREESCAPE_H
Definition: geometricobject.h:34
Definition: managed_surface.h:51
Definition: group.h:40
Definition: sound.h:45
Definition: framelimiter.h:40
Definition: keymap.h:66
Definition: str.h:59
Definition: surface.h:67
EngineFeature
Definition: engine.h:260
Definition: stream.h:77
Definition: error.h:81
bool canSaveAutosaveCurrently() override
Definition: freescape.h:591
Definition: area.h:36
Definition: freescape.h:145
Definition: advancedDetector.h:164
Definition: random.h:44
RenderMode
Definition: rendermode.h:48
Definition: rect.h:524
Definition: area.h:40
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:204
Definition: stream.h:745
Definition: archive.h:141
Definition: freescape.h:170
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:592
Definition: mixer.h:49
Definition: gfx.h:60
Definition: sensor.h:34
Definition: ustr.h:57
Definition: events.h:210
Definition: algorithm.h:29
Definition: rect.h:144
Definition: entrance.h:34
Definition: font.h:32
Definition: keyboard.h:294
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:590
Definition: object.h:56
Definition: sound.h:54
Definition: system.h:163
Definition: instruction.h:36
Definition: freescape.h:137
Common::Platform platform
Definition: advancedDetector.h:199
Definition: events.h:483
Definition: engine.h:146
Definition: gfx.h:47
Language
Definition: language.h:45