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;
385 void generateDemoInput();
386 virtual void pressedKey(
const int keycode);
387 virtual void releasedKey(
const int keycode);
390 void updatePlayerMovement(
float deltaTime);
391 void updatePlayerMovementSmooth(
float deltaTime);
392 void updatePlayerMovementClassic(
float deltaTime);
393 void resolveCollisions(Math::Vector3d newPosition);
394 virtual void checkIfStillInArea();
395 void changePlayerHeight(
int index);
396 void increaseStepSize();
397 void decreaseStepSize();
398 void changeStepSize();
400 void changeAngle(
int offset,
bool wrapAround);
403 bool checkFloor(Math::Vector3d currentPosition);
404 bool tryStepUp(Math::Vector3d currentPosition);
405 bool tryStepDown(Math::Vector3d currentPosition);
407 bool _isCollidingWithWall;
409 bool _isSteppingDown;
411 int _maxFallingDistance;
415 void rotate(
float xoffset,
float yoffset,
float zoffset);
422 void traverseEntrance(uint16 entranceID);
428 int _angleRotationIndex;
431 Math::Vector3d directionToVector(
float pitch,
float heading,
bool useTable);
433 virtual void onRotate(
float xoffset,
float yoffset,
float zoffset) {}
437 float _mouseSensitivity;
438 Math::Vector3d _upVector;
439 Math::Vector3d _cameraFront, _cameraRight;
441 Math::Vector3d _position, _rotation, _velocity;
442 Math::Vector3d _lastPosition;
443 int _playerHeightNumber;
444 int _playerHeightMaxNumber;
445 uint16 _playerHeight;
448 uint16 _stepUpDistance;
450 int _playerStepIndex;
451 int _savedPlayerStepIndex;
456 void warpMouseToCrossair(
void);
462 bool runCollisionConditions(Math::Vector3d
const lastPosition, Math::Vector3d
const newPosition);
463 Math::Vector3d _objExecutingCodeSize;
464 bool _executingGlobalCode;
465 virtual void executeMovementConditions();
466 bool executeObjectConditions(
GeometricObject *obj,
bool shot,
bool collided,
bool activated);
467 void executeEntranceConditions(
Entrance *entrance);
468 void executeLocalGlobalConditions(
bool shot,
bool collided,
bool timer);
469 bool executeCode(
FCLInstructionVector &code,
bool shot,
bool collided,
bool timer,
bool activated);
472 bool checkConditional(
FCLInstruction &instruction,
bool shot,
bool collided,
bool timer,
bool activated);
507 bool _usePrerecordedSounds;
508 void waitForSounds();
510 bool isPlayingSound();
514 void queueSoundConst(
double hzFreq,
int duration);
515 void playSilence(
int duration,
bool sync);
516 void playSoundConst(
double hzFreq,
int duration,
bool sync);
517 void playSoundSweepIncWL(
double hzFreq1,
double hzFreq2,
double wlStepPerMS,
int resolution,
bool sync);
518 uint16 playSoundDOSSpeaker(uint16 startFrequency,
soundSpeakerFx *speakerFxInfo);
522 virtual void playSoundC64(
int index);
523 virtual void playSoundFx(
int index,
bool sync);
534 void loadSoundsCPC(
Common::SeekableReadStream *file,
int offsetTone,
int sizeTone,
int offsetEnvelope,
int sizeEnvelope,
int offsetSoundDef,
int sizeSoundDef);
544 int _soundIndexShoot;
545 int _soundIndexCollide;
546 int _soundIndexStepDown;
547 int _soundIndexStepUp;
550 int _soundIndexStart;
551 int _soundIndexAreaChange;
554 int _soundIndexNoShield;
555 int _soundIndexNoEnergy;
556 int _soundIndexFallen;
557 int _soundIndexTimeout;
558 int _soundIndexForceEndGame;
559 int _soundIndexCrushed;
560 int _soundIndexMissionComplete;
563 int _screenW, _screenH;
569 int _underFireFrames;
570 int _avoidRenderingFrames;
574 void drawFrameStereo(
int farClipPlane);
578 void flashScreen(
int backgroundColor);
580 Math::Vector3d _scaleVector;
581 float _nearClipPlane;
585 void insertTemporaryMessage(
const Common::String &message,
int deadline);
587 void clearTemporalMessages();
607 void loadFonts(byte *font,
int charNumber);
616 virtual void drawStringInSurface(
const Common::String &str,
int x,
int y, uint32 fontColor, uint32 backColor,
Graphics::Surface *surface,
int offset = 0);
617 virtual void drawStringInSurface(
const Common::String &str,
int x,
int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor,
Graphics::Surface *surface,
int offset = 0);
621 virtual void initGameState();
622 void setGameBit(
int index);
623 void clearGameBit(
int index);
624 void toggleGameBit(
int index);
625 uint16 getGameBit(
int index);
627 StateVars _gameStateVars;
628 uint32 _gameStateBits;
629 void checkIfPlayerWasCrushed();
630 virtual bool triggerWinCondition();
631 virtual bool checkIfGameEnded();
632 virtual void endGame();
633 int _endGameDelayTicks;
634 bool _endGameKeyPressed;
635 bool _endGamePlayerEndArea;
637 bool _playerWasCrushed;
640 virtual void checkSensors();
641 virtual void drawSensorShoot(
Sensor *sensor);
642 void takeDamageFromSensor();
651 bool canSaveGameStateCurrently(
Common::U32String *msg =
nullptr)
override {
return _gameStateControl == kFreescapeGameStatePlaying && _currentArea && !_hasFallen && !_playerWasCrushed && _gameStateVars.getValOrDefault(k8bitVariableShield) > 0; }
658 void pauseEngineIntern(
bool pause)
override;
661 bool startCountdown(uint32 delay);
664 int _initialCountdown;
672 void getTimeFromCountdown(
int &seconds,
int &minutes,
int &hours);
673 virtual void updateTimeVariables();
676 bool _useExtendedTimer;
677 bool _disableSensors;
678 bool _disableFalling;
684 byte *decompressC64RLE(byte *buffer,
int *size, byte marker);
688 enum GameReleaseFlags {
689 GF_AMIGA_RETAIL = (1 << 0),
690 GF_AMIGA_BUDGET = (1 << 1),
691 GF_ZX_RETAIL = (1 << 2),
692 GF_ZX_BUDGET = (1 << 3),
693 GF_ZX_DISC = (1 << 4),
694 GF_CPC_RETAIL = (1 << 5),
695 GF_CPC_RETAIL_ALT = (1 << 6),
696 GF_CPC_BUDGET = (1 << 7),
697 GF_CPC_VIRTUALWORLDS = (1 << 8),
698 GF_ATARI_RETAIL = (1 << 9),
699 GF_ATARI_BUDGET = (1 << 10),
700 GF_C64_TAPE = (1 << 11),
701 GF_C64_DISC = (1 << 12),
709 #endif // FREESCAPE_H Definition: geometricobject.h:34
Definition: managed_surface.h:51
Definition: framelimiter.h:40
EngineFeature
Definition: engine.h:258
bool canSaveAutosaveCurrently() override
Definition: freescape.h:646
Definition: freescape.h:164
Definition: advancedDetector.h:164
RenderMode
Definition: rendermode.h:48
uint32 CustomEventType
Definition: events.h:204
Definition: archive.h:141
Definition: freescape.h:191
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:651
Definition: algorithm.h:29
Definition: entrance.h:34
Definition: keyboard.h:294
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: freescape.h:645
Definition: instruction.h:36
Definition: freescape.h:155
Common::Platform platform
Definition: advancedDetector.h:199
Definition: debugger.h:31
Language
Definition: language.h:45