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" 35 #include "audio/mixer.h" 36 #include "audio/softsynth/pcspk.h" 37 #include "graphics/framelimiter.h" 39 #include "freescape/area.h" 40 #include "freescape/font.h" 41 #include "freescape/gfx.h" 42 #include "freescape/language/8bitDetokeniser.h" 43 #include "freescape/objects/entrance.h" 44 #include "freescape/objects/geometricobject.h" 45 #include "freescape/objects/sensor.h" 46 #include "freescape/sound.h" 57 bool isEncodedCPCDirectColor(uint8 index);
58 uint8 encodeCPCDirectColor(uint8 index);
59 uint8 decodeCPCDirectColor(uint8 index);
61 #define FREESCAPE_DATA_BUNDLE "freescape.dat" 70 enum FreescapeAction {
84 kActionChangeStepSize,
85 kActionToggleRiseLower,
87 kActionLowerOrFlyDown,
97 kActionIncreaseStepSize,
98 kActionDecreaseStepSize,
100 kActionToggleClipMode,
102 kActionDeployDrillingRig,
103 kActionCollectDrillingRig,
114 kActionSelectPrincess,
116 kActionToggleFlashlight,
117 kActionToggleStereoscopic,
129 kFreescapeDebugMove = 1,
130 kFreescapeDebugParser,
132 kFreescapeDebugMedia,
133 kFreescapeDebugGroup,
137 kFreescapeDefaultVolume = 192,
140 enum GameStateControl {
141 kFreescapeGameStateStart,
142 kFreescapeGameStatePlaying,
143 kFreescapeGameStateDemo,
144 kFreescapeGameStateEnd,
145 kFreescapeGameStateRestart,
148 extern byte kEGADefaultPalette[16][3];
149 extern byte kCGAPaletteRedGreen[4][3];
150 extern byte kCGAPalettePinkBlue[4][3];
151 extern byte kCGAPalettePinkBlueBright[4][3];
152 extern byte kCGAPaletteRedGreenBright[4][3];
153 extern byte kHerculesPaletteGreen[2][3];
169 void purgeKeyboardEvents();
170 void purgeMouseEvents();
172 void clearExitEvents();
179 kKeyRepeatInitialDelay = 400,
180 kKeyRepeatSustainDelay = 100
188 uint32 _keyRepeatTime;
198 GameStateControl _gameStateControl;
204 bool isSpaceStationOblivion() {
return _targetName.hasPrefix(
"spacestationoblivion"); }
205 bool isDriller() {
return _targetName.hasPrefix(
"driller") || _targetName.hasPrefix(
"spacestationoblivion"); }
206 bool isDark() {
return _targetName.hasPrefix(
"darkside"); }
207 bool isEclipse() {
return _targetName.hasPrefix(
"totaleclipse"); }
208 bool isEclipse2() {
return _targetName.hasPrefix(
"totaleclipse2"); }
209 bool isCastle() {
return _targetName.hasPrefix(
"castle"); }
210 bool isCastleMaster2() {
return _targetName.hasPrefix(
"castlemaster2"); }
211 bool isAmiga() {
return _gameDescription->
platform == Common::kPlatformAmiga; }
212 bool isAtariST() {
return _gameDescription->
platform == Common::kPlatformAtariST; }
213 bool isDOS() {
return _gameDescription->
platform == Common::kPlatformDOS; }
214 bool isSpectrum() {
return _gameDescription->
platform == Common::kPlatformZX; }
215 bool isCPC() {
return _gameDescription->
platform == Common::kPlatformAmstradCPC; }
216 bool isC64() {
return _gameDescription->
platform == Common::kPlatformC64; }
218 virtual void beforeStarting();
224 void centerCrossair();
226 virtual void borderScreen();
227 virtual void titleScreen();
230 virtual void loadBorder();
231 virtual void processBorder();
232 void waitInLoop(
int maxWait);
235 virtual void drawBackground();
236 void clearBackground();
238 virtual void drawUI();
239 virtual void drawInfoMenu();
258 virtual void loadAssets();
259 virtual void loadAssetsDemo();
260 virtual void loadAssetsFullGame();
262 virtual void loadAssetsAtariFullGame();
263 virtual void loadAssetsAtariDemo();
265 virtual void loadAssetsAmigaFullGame();
266 virtual void loadAssetsAmigaDemo();
268 virtual void loadAssetsDOSFullGame();
269 virtual void loadAssetsDOSDemo();
271 virtual void loadAssetsZXFullGame();
272 virtual void loadAssetsZXDemo();
274 virtual void loadAssetsCPCFullGame();
275 virtual void loadAssetsCPCDemo();
277 virtual void loadAssetsC64FullGame();
278 virtual void loadAssetsC64Demo();
287 void loadDataBundle();
292 int dataOffset,
int widthWords,
int height, byte *palette);
300 void swapPalette(uint16 areaID);
301 virtual byte *findCGAPalette(uint16 levelID);
303 void loadColorPalette();
308 int _currentDemoInputCode;
309 int _currentDemoInputRepetition;
313 int decodeAmigaAtariKey(
int code);
314 int decodeDOSKey(
int code);
352 Math::Vector3d _scale;
354 virtual void gotoArea(uint16 areaID,
int entranceID);
356 uint16 _startEntrance;
362 bool _disableDemoMode;
368 bool _smoothMovement;
369 bool _useWASDControls;
370 bool _debugSimulateTouchscreen;
371 bool isTouchscreenActive()
const;
372 void setIOSGamepadControllerEnabled(
bool enabled);
373 void restoreIOSGamepadControllerSettings();
375 struct IOSGamepadControllerSetting {
379 bool _iosGamepadControllerSettingsSaved;
381 IOSGamepadControllerSetting _iosGamepadController;
382 IOSGamepadControllerSetting _iosGamepadControllerMinimalLayout;
383 IOSGamepadControllerSetting _iosGamepadControllerDirectionalInput;
398 void generateDemoInput();
399 virtual void pressedKey(
const int keycode);
400 virtual void releasedKey(
const int keycode);
403 void updatePlayerMovement(
float deltaTime);
404 void updatePlayerMovementSmooth(
float deltaTime);
405 void updatePlayerMovementClassic(
float deltaTime);
406 void resolveCollisions(Math::Vector3d newPosition);
407 virtual void checkIfStillInArea();
408 void changePlayerHeight(
int index);
409 void increaseStepSize();
410 void decreaseStepSize();
411 void changeStepSize();
413 void changeAngle(
int offset,
bool wrapAround);
416 bool checkFloor(Math::Vector3d currentPosition);
417 bool tryStepUp(Math::Vector3d currentPosition);
418 bool tryStepDown(Math::Vector3d currentPosition);
420 bool _isCollidingWithWall;
422 bool _isSteppingDown;
424 int _maxFallingDistance;
428 void rotate(
float xoffset,
float yoffset,
float zoffset);
435 void traverseEntrance(uint16 entranceID);
441 int _angleRotationIndex;
444 Math::Vector3d directionToVector(
float pitch,
float heading,
bool useTable);
446 virtual void onRotate(
float xoffset,
float yoffset,
float zoffset) {}
450 float _mouseSensitivity;
451 Math::Vector3d _upVector;
452 Math::Vector3d _cameraFront, _cameraRight;
454 Math::Vector3d _position, _rotation, _velocity;
455 Math::Vector3d _lastPosition;
456 int _playerHeightNumber;
457 int _playerHeightMaxNumber;
458 uint16 _playerHeight;
461 uint16 _stepUpDistance;
463 int _playerStepIndex;
464 int _savedPlayerStepIndex;
469 void warpMouseToCrossair(
void);
475 bool runCollisionConditions(Math::Vector3d
const lastPosition, Math::Vector3d
const newPosition);
476 Math::Vector3d _objExecutingCodeSize;
477 bool _executingGlobalCode;
478 virtual void executeMovementConditions();
479 bool executeObjectConditions(
GeometricObject *obj,
bool shot,
bool collided,
bool activated);
480 void executeEntranceConditions(
Entrance *entrance);
481 void executeLocalGlobalConditions(
bool shot,
bool collided,
bool timer);
482 bool executeCode(
FCLInstructionVector &code,
bool shot,
bool collided,
bool timer,
bool activated);
485 bool checkConditional(
FCLInstruction &instruction,
bool shot,
bool collided,
bool timer,
bool activated);
519 bool _usePrerecordedSounds;
520 void waitForSounds(Sound::Type type = Sound::kTypeNormal);
521 void stopAllSounds(Sound::Type type = Sound::kTypeNormal);
522 bool isPlayingSound(Sound::Type type = Sound::kTypeNormal);
523 void playSound(
int index,
bool sync, Sound::Type type = Sound::kTypeNormal);
527 virtual void playSoundFx(
int index,
bool sync, Sound::Type type = Sound::kTypeNormal) {}
532 Sound *loadSpeakerFxDrillerZX();
533 Sound *loadSoundsCPC(
Common::SeekableReadStream *file,
int offsetTone,
int sizeTone,
int offsetEnvelope,
int sizeEnvelope,
int offsetSoundDef,
int sizeSoundDef);
536 int _soundIndexShoot;
537 int _soundIndexCollide;
538 int _soundIndexStepDown;
539 int _soundIndexStepUp;
542 int _soundIndexStart;
543 int _soundIndexAreaChange;
546 int _soundIndexNoShield;
547 int _soundIndexNoEnergy;
548 int _soundIndexFallen;
549 int _soundIndexTimeout;
550 int _soundIndexForceEndGame;
551 int _soundIndexCrushed;
552 int _soundIndexMissionComplete;
555 int _screenW, _screenH;
561 int _underFireFrames;
562 int _avoidRenderingFrames;
566 Math::Vector3d getCameraRenderPosition();
567 void drawFrameStereo(
int farClipPlane);
571 void flashScreen(
int backgroundColor);
573 Math::Vector3d _scaleVector;
574 float _nearClipPlane;
578 void insertTemporaryMessage(
const Common::String &message,
int deadline);
580 void clearTemporalMessages();
600 void loadFonts(byte *font,
int charNumber);
609 virtual void drawStringInSurface(
const Common::String &str,
int x,
int y, uint32 fontColor, uint32 backColor,
Graphics::Surface *surface,
int offset = 0);
610 virtual void drawStringInSurface(
const Common::String &str,
int x,
int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor,
Graphics::Surface *surface,
int offset = 0);
614 virtual void initGameState();
615 void setGameBit(
int index);
616 void clearGameBit(
int index);
617 void toggleGameBit(
int index);
618 uint16 getGameBit(
int index);
620 StateVars _gameStateVars;
621 uint32 _gameStateBits;
622 void checkIfPlayerWasCrushed();
623 virtual bool triggerWinCondition();
624 virtual bool checkIfGameEnded();
625 virtual void endGame();
626 int _endGameDelayTicks;
627 bool _endGameKeyPressed;
628 bool _endGamePlayerEndArea;
630 bool _playerWasCrushed;
633 virtual void checkSensors();
634 virtual void drawSensorShoot(
Sensor *sensor);
635 void takeDamageFromSensor();
644 bool canSaveGameStateCurrently(
Common::U32String *msg =
nullptr)
override {
return _gameStateControl == kFreescapeGameStatePlaying && _currentArea && !_hasFallen && !_playerWasCrushed && _gameStateVars.getValOrDefault(k8bitVariableShield) > 0; }
651 void pauseEngineIntern(
bool pause)
override;
654 bool startCountdown(uint32 delay);
657 int _initialCountdown;
665 void getTimeFromCountdown(
int &seconds,
int &minutes,
int &hours);
666 virtual void updateTimeVariables();
669 bool _useExtendedTimer;
670 bool _disableSensors;
671 bool _disableFalling;
677 byte *decompressC64RLE(byte *buffer,
int *size, byte marker);
681 enum GameReleaseFlags {
682 GF_AMIGA_RETAIL = (1 << 0),
683 GF_AMIGA_BUDGET = (1 << 1),
684 GF_ZX_RETAIL = (1 << 2),
685 GF_ZX_BUDGET = (1 << 3),
686 GF_ZX_DISC = (1 << 4),
687 GF_CPC_RETAIL = (1 << 5),
688 GF_CPC_RETAIL_ALT = (1 << 6),
689 GF_CPC_BUDGET = (1 << 7),
690 GF_CPC_VIRTUALWORLDS = (1 << 8),
691 GF_ATARI_RETAIL = (1 << 9),
692 GF_ATARI_BUDGET = (1 << 10),
693 GF_C64_TAPE = (1 << 11),
694 GF_C64_DISC = (1 << 12),
702 #endif // FREESCAPE_H Definition: geometricobject.h:34
Definition: managed_surface.h:51
Definition: framelimiter.h:40
EngineFeature
Definition: engine.h:282
bool canSaveAutosaveCurrently() override
Definition: freescape.h:639
Definition: freescape.h:164
Definition: advancedDetector.h:164
RenderMode
Definition: rendermode.h:48
uint32 CustomEventType
Definition: events.h:212
Definition: archive.h:141
Definition: freescape.h:191
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:644
Definition: algorithm.h:29
Definition: entrance.h:34
Definition: keyboard.h:294
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:638
Definition: instruction.h:36
Definition: freescape.h:155
Common::Platform platform
Definition: advancedDetector.h:199
Definition: debugger.h:31
Language
Definition: language.h:45