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