[Scummvm-git-logs] scummvm master -> d659bb05bf0566b918921a86856e2e2255427a96
neuromancer
noreply at scummvm.org
Tue Feb 13 13:57:58 UTC 2024
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7cb83f4b3f FREESCAPE: refactoring of initGameState and add _gameStateControl variable
c946163d94 FREESCAPE: refactoring of checkIfGameEnded and endGame for driller, dark and eclipse
8ed649dea8 FREESCAPE: end game fixes for dark and eclipse
3f82028ddf FREESCAPE: falling handling fixes for eclipse
3e75742477 FREESCAPE: removed old message list and add info menu in eclipse
5bf0d2cfdd FREESCAPE: purge keyboard events before calling save/load dialogs
a14165eeaa FREESCAPE: implemented rest key in eclipse
d659bb05bf FREESCAPE: implemented eng game sequence in eclipse
Commit: 7cb83f4b3fcb3aa155a9ee90d13b427342a9957b
https://github.com/scummvm/scummvm/commit/7cb83f4b3fcb3aa155a9ee90d13b427342a9957b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: refactoring of initGameState and add _gameStateControl variable
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/castle.cpp
engines/freescape/games/dark/dark.cpp
engines/freescape/games/driller/driller.cpp
engines/freescape/games/eclipse/eclipse.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 1f977efc7f5..9e7ab9d021d 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -81,6 +81,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
if (!Common::parseBool(ConfMan.get("invert_y"), _invertY))
error("Failed to parse bool from disable_falling option");
+ _gameStateControl = kFreescapeGameStateStart;
_startArea = 0;
_startEntrance = 0;
_currentArea = nullptr;
@@ -716,10 +717,32 @@ uint16 FreescapeEngine::getGameBit(int index) {
}
void FreescapeEngine::initGameState() {
+ _gameStateControl = kFreescapeGameStatePlaying;
+
for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
_gameStateVars[i] = 0;
+ for (auto &it : _areaMap)
+ it._value->resetArea();
+
_gameStateBits = 0;
+
+ _flyMode = false;
+ _noClipMode = false;
+ _playerWasCrushed = false;
+ _shootingFrames = 0;
+ _underFireFrames = 0;
+ _yaw = 0;
+ _pitch = 0;
+
+ _demoIndex = 0;
+ _demoEvents.clear();
+
+ removeTimers();
+ startCountdown(_initialCountdown - 1);
+ int seconds, minutes, hours;
+ getTimeFromCountdown(seconds, minutes, hours);
+ _lastMinute = minutes;
}
void FreescapeEngine::rotate(float xoffset, float yoffset) {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 2753e6caeb4..adee3b66828 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -68,6 +68,13 @@ enum {
kFreescapeDebugMedia = 1 << 4,
};
+enum GameStateControl {
+ kFreescapeGameStateStart,
+ kFreescapeGameStatePlaying,
+ kFreescapeGameStateDemo,
+ kFreescapeGameStateEnd,
+};
+
struct CGAPaletteEntry {
int areaId;
byte *palette;
@@ -103,6 +110,7 @@ public:
~FreescapeEngine();
const ADGameDescription *_gameDescription;
+ GameStateControl _gameStateControl;
bool isDemo() const;
// Game selection
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index 4140ee4c6cc..b50485c54e4 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -331,31 +331,9 @@ void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
}
void CastleEngine::initGameState() {
- _flyMode = false;
- _noClipMode = false;
- _shootingFrames = 0;
- _underFireFrames = 0;
- _yaw = 0;
- _pitch = 0;
-
- for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
- _gameStateVars[i] = 0;
-
- for (auto &it : _areaMap)
- it._value->resetArea();
-
- _gameStateBits = 0;
-
- //_gameStateVars[k8bitVariableEnergy] = _initialFuel;
- //_gameStateVars[k8bitVariableShield] = _initialShield;
-
+ FreescapeEngine::initGameState();
_playerHeightNumber = 1;
_playerHeight = _playerHeights[_playerHeightNumber];
- removeTimers();
- startCountdown(_initialCountdown);
- _lastMinute = 0;
- _demoIndex = 0;
- _demoEvents.clear();
}
void CastleEngine::executePrint(FCLInstruction &instruction) {
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 17d708b62a0..b0c818086da 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -172,34 +172,13 @@ void DarkEngine::initKeymaps(Common::Keymap *engineKeyMap, const char *target) {
}
void DarkEngine::initGameState() {
- _flyMode = false;
- _hasFallen = false;
- _noClipMode = false;
- _playerWasCrushed = false;
- _shootingFrames = 0;
- _underFireFrames = 0;
- _yaw = 0;
- _pitch = 0;
-
- for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
- _gameStateVars[i] = 0;
-
- for (auto &it : _areaMap)
- it._value->resetArea();
-
- _gameStateBits = 0;
-
+ FreescapeEngine::initGameState();
_gameStateVars[k8bitVariableEnergy] = _initialEnergy;
_gameStateVars[k8bitVariableShield] = _initialShield;
_gameStateVars[kVariableActiveECDs] = 100;
_playerHeightNumber = 1;
_playerHeight = _playerHeights[_playerHeightNumber];
- removeTimers();
- startCountdown(_initialCountdown);
- _lastMinute = 0;
- _demoIndex = 0;
- _demoEvents.clear();
_exploredAreas.clear();
_exploredAreas[_startArea] = true;
}
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index 81a1720ed95..f68bac698e1 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -718,19 +718,9 @@ void DrillerEngine::removeDrill(Area *area) {
}
void DrillerEngine::initGameState() {
- _flyMode = false;
- _noClipMode = false;
- _playerWasCrushed = false;
- _shootingFrames = 0;
- _underFireFrames = 0;
- _yaw = 0;
- _pitch = 0;
-
- for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
- _gameStateVars[i] = 0;
+ FreescapeEngine::initGameState();
for (auto &it : _areaMap) {
- it._value->resetArea();
if (_drillStatusByArea[it._key] != kDrillerNoRig)
removeDrill(it._value);
_drillStatusByArea[it._key] = kDrillerNoRig;
@@ -740,7 +730,6 @@ void DrillerEngine::initGameState() {
}
_drillSuccessByArea[it._key] = 0;
}
- _gameStateBits = 0;
_gameStateVars[k8bitVariableEnergy] = _initialTankEnergy;
_gameStateVars[k8bitVariableShield] = _initialTankShield;
@@ -753,12 +742,6 @@ void DrillerEngine::initGameState() {
_playerHeightNumber = 1;
_playerHeight = _playerHeights[_playerHeightNumber];
- removeTimers();
- startCountdown(_initialCountdown - 1);
-
- int seconds, minutes, hours;
- getTimeFromCountdown(seconds, minutes, hours);
- _lastMinute = minutes;
_demoIndex = 0;
_demoEvents.clear();
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 3ace851c627..25ee8dbd68c 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -95,30 +95,10 @@ EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : Frees
}
void EclipseEngine::initGameState() {
- _flyMode = false;
- _hasFallen = false;
- _noClipMode = false;
- _playerWasCrushed = false;
- _shootingFrames = 0;
- _underFireFrames = 0;
- _yaw = 0;
- _pitch = 0;
-
- for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
- _gameStateVars[i] = 0;
-
- for (auto &it : _areaMap)
- it._value->resetArea();
-
- _gameStateBits = 0;
+ FreescapeEngine::initGameState();
_playerHeightNumber = 1;
_playerHeight = _playerHeights[_playerHeightNumber];
- removeTimers();
- startCountdown(_initialCountdown);
- _lastMinute = 0;
- _demoIndex = 0;
- _demoEvents.clear();
_gameStateVars[k8bitVariableEnergy] = _initialEnergy;
_gameStateVars[k8bitVariableShield] = _initialShield;
Commit: c946163d946e45aa8c4e52662a4acde888dd0dc7
https://github.com/scummvm/scummvm/commit/c946163d946e45aa8c4e52662a4acde888dd0dc7
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: refactoring of checkIfGameEnded and endGame for driller, dark and eclipse
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/dark/dark.cpp
engines/freescape/games/dark/dark.h
engines/freescape/games/driller/driller.cpp
engines/freescape/games/driller/driller.h
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/games/eclipse/eclipse.h
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 9e7ab9d021d..9a04e22c104 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -84,6 +84,8 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_gameStateControl = kFreescapeGameStateStart;
_startArea = 0;
_startEntrance = 0;
+ _endArea = 0;
+ _endEntrance = 0;
_currentArea = nullptr;
_gotoExecuted = false;
_rotation = Math::Vector3d(0, 0, 0);
@@ -389,9 +391,14 @@ void FreescapeEngine::processInput() {
}
while (_eventManager->pollEvent(event)) {
- if (_demoMode) {
+ if (_gameStateControl != kFreescapeGameStatePlaying) {
if (event.type == Common::EVENT_SCREEN_CHANGED)
; // Allow event
+ else if (_gameStateControl == kFreescapeGameStateEnd && event.type == Common::EVENT_KEYDOWN) {
+ _endGameKeyPressed = true;
+ continue;
+ } else if (event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ ; // Allow event
else if (event.customType != 0xde00)
continue;
}
@@ -623,7 +630,6 @@ Common::Error FreescapeEngine::run() {
gotoArea(_startArea, _startEntrance);
debugC(1, kFreescapeDebugMove, "Starting area %d", _currentArea->getAreaID());
- bool endGame = false;
// Draw first frame
g_system->showMouse(false);
@@ -636,11 +642,12 @@ Common::Error FreescapeEngine::run() {
while (!shouldQuit()) {
updateTimeVariables();
- if (endGame) {
+ if (_gameStateControl == kFreescapeGameStateRestart) {
initGameState();
gotoArea(_startArea, _startEntrance);
- endGame = false;
- }
+ } else if (_gameStateControl == kFreescapeGameStateEnd)
+ endGame();
+
processInput();
if (_demoMode)
generateDemoInput();
@@ -654,13 +661,20 @@ Common::Error FreescapeEngine::run() {
_frameLimiter->startFrame();
if (_vsyncEnabled) // if vsync is enabled, the framelimiter will not work
g_system->delayMillis(15); // try to target ~60 FPS
- endGame = checkIfGameEnded();
+
+ checkIfGameEnded();
}
_eventManager->clearExitEvents();
return Common::kNoError;
}
+void FreescapeEngine::endGame() {
+ if (_endGameKeyPressed) {
+ _gameStateControl = kFreescapeGameStateRestart;
+ }
+}
+
void FreescapeEngine::loadBorder() {
if (_border) {
Graphics::Surface *border = _gfx->convertImageFormatIfNecessary(_border);
@@ -697,6 +711,42 @@ void FreescapeEngine::processBorder() {
}
bool FreescapeEngine::checkIfGameEnded() {
+ if (_gameStateControl != kFreescapeGameStatePlaying)
+ return false;
+
+ if (_gameStateVars[k8bitVariableShield] == 0) {
+ if (!_noShieldMessage.empty())
+ insertTemporaryMessage(_noShieldMessage, _countdown - 2);
+ _gameStateControl = kFreescapeGameStateEnd;
+ } else if (_gameStateVars[k8bitVariableEnergy] == 0) {
+ if (!_noEnergyMessage.empty())
+ insertTemporaryMessage(_noEnergyMessage, _countdown - 2);
+ _gameStateControl = kFreescapeGameStateEnd;
+ } else if (_hasFallen) {
+ _hasFallen = false;
+ playSound(14, false);
+ if (!_fallenMessage.empty())
+ insertTemporaryMessage(_fallenMessage, _countdown - 4);
+ _gameStateControl = kFreescapeGameStateEnd;
+ } else if (_countdown <= 0) {
+ if (!_timeoutMessage.empty())
+ insertTemporaryMessage(_timeoutMessage, _countdown - 4);
+ _gameStateControl = kFreescapeGameStateEnd;
+ } else if (_playerWasCrushed) {
+ _playerWasCrushed = false;
+ if (!_crushedMessage.empty())
+ insertTemporaryMessage(_crushedMessage, _countdown - 4);
+ _gameStateControl = kFreescapeGameStateEnd;
+ } else if (_forceEndGame) {
+ _forceEndGame = false;
+ if (!_forceEndGameMessage.empty())
+ insertTemporaryMessage(_forceEndGameMessage, _countdown - 4);
+ _gameStateControl = kFreescapeGameStateEnd;
+ }
+
+ if (_gameStateControl == kFreescapeGameStateEnd)
+ gotoArea(_endArea, _endEntrance);
+
return false; // TODO
}
@@ -734,6 +784,7 @@ void FreescapeEngine::initGameState() {
_underFireFrames = 0;
_yaw = 0;
_pitch = 0;
+ _endGameKeyPressed = false;
_demoIndex = 0;
_demoEvents.clear();
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index adee3b66828..a0fb2e46a4e 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -73,6 +73,7 @@ enum GameStateControl {
kFreescapeGameStatePlaying,
kFreescapeGameStateDemo,
kFreescapeGameStateEnd,
+ kFreescapeGameStateRestart,
};
struct CGAPaletteEntry {
@@ -161,7 +162,7 @@ public:
// Parsing assets
uint8 _binaryBits;
- void loadAssets();
+ virtual void loadAssets();
virtual void loadAssetsDemo();
virtual void loadAssetsFullGame();
@@ -241,6 +242,7 @@ public:
// Areas
uint16 _startArea;
+ uint16 _endArea;
AreaMap _areaMap;
Area *_currentArea;
bool _gotoExecuted;
@@ -249,6 +251,7 @@ public:
virtual void gotoArea(uint16 areaID, int entranceID);
// Entrance
uint16 _startEntrance;
+ uint16 _endEntrance;
Common::HashMap<int, const struct entrancesTableEntry *> _entranceTable;
// Input
@@ -404,6 +407,12 @@ public:
Common::StringArray _temporaryMessages;
Common::Array<int> _temporaryMessageDeadlines;
Common::StringArray _messagesList;
+ Common::String _noShieldMessage;
+ Common::String _noEnergyMessage;
+ Common::String _fallenMessage;
+ Common::String _timeoutMessage;
+ Common::String _forceEndGameMessage;
+ Common::String _crushedMessage;
void loadMessagesFixedSize(Common::SeekableReadStream *file, int offset, int size, int number);
virtual void loadMessagesVariableSize(Common::SeekableReadStream *file, int offset, int number);
@@ -429,6 +438,8 @@ public:
StateVars _gameStateVars;
uint32 _gameStateBits;
virtual bool checkIfGameEnded();
+ virtual void endGame();
+ bool _endGameKeyPressed;
bool _forceEndGame;
bool _playerWasCrushed;
ObjectArray _sensors;
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index b0c818086da..82e6fca835b 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -181,6 +181,19 @@ void DarkEngine::initGameState() {
_playerHeight = _playerHeights[_playerHeightNumber];
_exploredAreas.clear();
_exploredAreas[_startArea] = true;
+
+ _endArea = 1;
+ _endEntrance = 26;
+}
+
+void DarkEngine::loadAssets() {
+ FreescapeEngine::loadAssets();
+
+ _timeoutMessage = _messagesList[14];
+ _noShieldMessage = _messagesList[15];
+ _noEnergyMessage = _messagesList[16];
+ _fallenMessage = _messagesList[17];
+ _crushedMessage = _messagesList[10];
}
bool DarkEngine::tryDestroyECDFullGame(int index) {
@@ -353,6 +366,15 @@ void DarkEngine::addSkanner(Area *area) {
}
bool DarkEngine::checkIfGameEnded() {
+ if (_gameStateControl == kFreescapeGameStatePlaying) {
+ FreescapeEngine::checkIfGameEnded();
+
+ // If the game state changed to game over, then the player failed
+ if (_gameStateControl == kFreescapeGameStateEnd) {
+ _gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
+ }
+ }
+
if (_gameStateVars[kVariableDarkECD] > 0) {
int index = _gameStateVars[kVariableDarkECD] - 1;
bool destroyed = tryDestroyECD(index);
@@ -367,59 +389,24 @@ bool DarkEngine::checkIfGameEnded() {
}
_gameStateVars[kVariableDarkECD] = 0;
}
+ return false;
+}
- if (_hasFallen) {
- _gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
- playSound(14, false);
- insertTemporaryMessage(_messagesList[17], _countdown - 4);
- drawBackground();
- drawBorder();
- drawUI();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(1000);
- gotoArea(1, 26);
- } else if (_playerWasCrushed) {
- insertTemporaryMessage(_messagesList[10], _countdown - 2);
- _gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- _playerWasCrushed = false;
- gotoArea(1, 26);
- } else if (_gameStateVars[k8bitVariableShield] == 0) {
- insertTemporaryMessage(_messagesList[15], _countdown - 2);
- _gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(1, 26);
- } else if (_forceEndGame) {
- _forceEndGame = false;
- insertTemporaryMessage(_messagesList[18], _countdown - 2);
- _gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(1, 26);
+void DarkEngine::endGame() {
+ if (_gameStateControl == kFreescapeGameStateEnd) {
+ if (true /*_countdown <= 0*/) {
+ if (_gameStateVars[kVariableDarkEnding]) {
+ executeLocalGlobalConditions(false, true, false);
+ _gameStateVars[kVariableDarkEnding] = 0;
+ insertTemporaryMessage(_messagesList[22], INT_MIN);
+ }
+ }
}
- if (_currentArea->getAreaID() == 1) {
- rotate(0, 10);
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(20);
- executeLocalGlobalConditions(false, true, false);
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(200);
- return true;
+ if (_endGameKeyPressed && _gameStateVars[kVariableDarkEnding] == 0) {
+ //_gameStateControl = kFreescapeGameStateRestart;
}
- return false;
+ _endGameKeyPressed = false;
}
void DarkEngine::gotoArea(uint16 areaID, int entranceID) {
@@ -509,6 +496,8 @@ void DarkEngine::gotoArea(uint16 areaID, int entranceID) {
_yaw = 90;
_pitch = 0;
playSound(9, true);
+ } else if (areaID == _endArea && entranceID == _endEntrance) {
+ _pitch = 10;
} else
playSound(5, false);
@@ -552,6 +541,8 @@ void DarkEngine::pressedKey(const int keycode) {
}
void DarkEngine::updateTimeVariables() {
+ if (_gameStateControl != kFreescapeGameStatePlaying)
+ return;
// This function only executes "on collision" room/global conditions
int seconds, minutes, hours;
getTimeFromCountdown(seconds, minutes, hours);
diff --git a/engines/freescape/games/dark/dark.h b/engines/freescape/games/dark/dark.h
index 109141e6200..8ccf168d091 100644
--- a/engines/freescape/games/dark/dark.h
+++ b/engines/freescape/games/dark/dark.h
@@ -50,6 +50,7 @@ public:
void initGameState() override;
void borderScreen() override;
bool checkIfGameEnded() override;
+ void endGame() override;
void gotoArea(uint16 areaID, int entranceID) override;
void pressedKey(const int keycode) override;
@@ -60,6 +61,7 @@ public:
void initZX();
void initCPC();
+ void loadAssets() override;
void loadAssetsDOSFullGame() override;
void loadAssetsDOSDemo() override;
void loadAssetsAmigaFullGame() override;
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index f68bac698e1..e264040da5d 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -93,6 +93,9 @@ DrillerEngine::DrillerEngine(OSystem *syst, const ADGameDescription *gd) : Frees
_demoMode = !_disableDemoMode; // Most of the driller demos are non-interactive
_angleRotationIndex = 0;
}
+
+ _endArea = 127;
+ _endEntrance = 0;
}
DrillerEngine::~DrillerEngine() {
@@ -195,30 +198,39 @@ void DrillerEngine::gotoArea(uint16 areaID, int entranceID) {
resetInput();
}
-void DrillerEngine::loadAssetsFullGame() {
- FreescapeEngine::loadAssetsFullGame();
- /*
- We are going to inject a small script in the
- last area to force the game to end:
- IF COLLIDED? THEN
- IF VAR!=? (v32, 18) THEN END ENDIF
- GOTO (127, 0)
- */
-
- FCLInstructionVector instructions;
- Common::Array<uint16> conditionArray;
-
- conditionArray.push_back(0xb);
- conditionArray.push_back(0x20);
- conditionArray.push_back(0x12);
- conditionArray.push_back(0x12);
- conditionArray.push_back(0x7f);
- conditionArray.push_back(0x0);
-
- Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, false);
- debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
- _areaMap[18]->_conditions.push_back(instructions);
- _areaMap[18]->_conditionSources.push_back(conditionSource);
+void DrillerEngine::loadAssets() {
+ FreescapeEngine::loadAssets();
+ if (_areaMap.contains(18)) {
+ /*
+ We are going to inject a small script in the
+ last area to force the game to end:
+ IF COLLIDED? THEN
+ IF VAR!=? (v32, 18) THEN END ENDIF
+ GOTO (127, 0)
+ */
+
+ FCLInstructionVector instructions;
+ Common::Array<uint16> conditionArray;
+
+ conditionArray.push_back(0xb);
+ conditionArray.push_back(0x20);
+ conditionArray.push_back(0x12);
+ conditionArray.push_back(0x12);
+ conditionArray.push_back(0x7f);
+ conditionArray.push_back(0x0);
+
+ Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, false);
+ debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
+ _areaMap[18]->_conditions.push_back(instructions);
+ _areaMap[18]->_conditionSources.push_back(conditionSource);
+ }
+
+ _timeoutMessage = _messagesList[14];
+ _noShieldMessage = _messagesList[15];
+ _noEnergyMessage = _messagesList[16];
+ _fallenMessage = _messagesList[17];
+ // Small extra feature: allow player to be crushed in Driller
+ _crushedMessage = "CRUSHED!";
}
void DrillerEngine::drawInfoMenu() {
@@ -754,78 +766,16 @@ bool DrillerEngine::checkIfGameEnded() {
if (_demoData[_demoIndex + 1] == 0x5f)
return true;
- if (_countdown <= 0) {
- insertTemporaryMessage(_messagesList[14], _countdown - 2);
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(127, 0);
- }
-
- if (_gameStateVars[k8bitVariableShield] == 0) {
- insertTemporaryMessage(_messagesList[15], _countdown - 2);
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(127, 0);
- }
-
- if (_gameStateVars[k8bitVariableEnergy] == 0) {
- insertTemporaryMessage(_messagesList[16], _countdown - 2);
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(127, 0);
- }
-
- if (_hasFallen) {
- _hasFallen = false;
- playSound(14, false);
- insertTemporaryMessage(_messagesList[17], _countdown - 4);
- drawBackground();
- drawBorder();
- drawUI();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(1000);
- gotoArea(127, 0);
- }
-
- if (_forceEndGame) {
- _forceEndGame = false;
- if (isDemo())
- return true;
- else {
- insertTemporaryMessage(_messagesList[18], _countdown - 2);
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(2000);
- gotoArea(127, 0);
- }
- }
-
- if (_currentArea->getAreaID() == 127) {
- if (_gameStateVars[32] == 18) { // All areas are complete
- insertTemporaryMessage(_messagesList[19], _countdown - 2);
- _gameStateVars[32] = 0; // Avoid repeating the message
- }
-
- // Draw a few frames
- for (int i = 0; i < 10; i++) {
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(10);
- }
+ FreescapeEngine::checkIfGameEnded();
+ return false;
+}
- g_system->delayMillis(5000);
- return true;
+void DrillerEngine::endGame() {
+ FreescapeEngine::endGame();
+ if (_gameStateVars[32] == 18) { // All areas are complete
+ insertTemporaryMessage(_messagesList[19], _countdown - 2);
+ _gameStateVars[32] = 0; // Avoid repeating the message
}
- return false;
}
bool DrillerEngine::onScreenControls(Common::Point mouse) {
diff --git a/engines/freescape/games/driller/driller.h b/engines/freescape/games/driller/driller.h
index 1bd1d412b9c..0aca5f9f4b6 100644
--- a/engines/freescape/games/driller/driller.h
+++ b/engines/freescape/games/driller/driller.h
@@ -41,6 +41,7 @@ public:
void initKeymaps(Common::Keymap *engineKeyMap, const char *target) override;
void initGameState() override;
bool checkIfGameEnded() override;
+ void endGame() override;
void gotoArea(uint16 areaID, int entranceID) override;
@@ -60,7 +61,7 @@ private:
void removeDrill(Area *area);
void addSkanner(Area *area);
- void loadAssetsFullGame() override;
+ void loadAssets() override;
void loadAssetsAtariFullGame() override;
void loadAssetsAtariDemo() override;
void loadAssetsAmigaFullGame() override;
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 25ee8dbd68c..4e635103b90 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -92,6 +92,9 @@ EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : Frees
_initialEnergy = 16;
_initialShield = 10; // TODO
+
+ _endArea = 1;
+ _endEntrance = 33;
}
void EclipseEngine::initGameState() {
@@ -104,32 +107,18 @@ void EclipseEngine::initGameState() {
_gameStateVars[k8bitVariableShield] = _initialShield;
}
-bool EclipseEngine::checkIfGameEnded() {
- if (_hasFallen) {
- _hasFallen = false;
- playSound(14, false);
- insertTemporaryMessage(_messagesList[3], _countdown - 4);
- drawBackground();
- drawBorder();
- drawUI();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(1000);
- gotoArea(1, 33);
- }
+void EclipseEngine::loadAssets() {
+ FreescapeEngine::loadAssets();
- if (_currentArea->getAreaID() == 1 && _flyMode) {
- // Draw a few frames
- for (int i = 0; i < 10; i++) {
- drawFrame();
- _gfx->flipBuffer();
- g_system->updateScreen();
- g_system->delayMillis(10);
- }
+ _timeoutMessage = _messagesList[1];
+ _noShieldMessage = _messagesList[0];
+ //_noEnergyMessage = _messagesList[16];
+ _fallenMessage = _messagesList[3];
+ _crushedMessage = _messagesList[2];
+}
- g_system->delayMillis(5000);
- return true;
- }
+bool EclipseEngine::checkIfGameEnded() {
+ FreescapeEngine::checkIfGameEnded();
return false;
}
@@ -153,7 +142,7 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
if (areaID == _startArea && entranceID == _startEntrance)
playSound(9, true);
- if (areaID == _startArea && entranceID == 33)
+ if (areaID == _endArea && entranceID == _endEntrance)
_flyMode = true;
else
playSound(5, false);
diff --git a/engines/freescape/games/eclipse/eclipse.h b/engines/freescape/games/eclipse/eclipse.h
index ffa9567942f..ceaf0e7ea2a 100644
--- a/engines/freescape/games/eclipse/eclipse.h
+++ b/engines/freescape/games/eclipse/eclipse.h
@@ -39,6 +39,7 @@ public:
void borderScreen() override;
void titleScreen() override;
+ void loadAssets() override;
void loadAssetsDOSFullGame() override;
uint32 _initialEnergy;
Commit: 8ed649dea87f5f9ef4aec80a1e07fbbbf8dcf1cc
https://github.com/scummvm/scummvm/commit/8ed649dea87f5f9ef4aec80a1e07fbbbf8dcf1cc
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: end game fixes for dark and eclipse
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/dark/dark.cpp
engines/freescape/games/eclipse/eclipse.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 9a04e22c104..6e6987650d9 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -155,6 +155,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_initialCountdown = 0;
_countdown = 0;
_ticks = 0;
+ _ticksFromEnd = 0;
_lastTick = -1;
_lastMinute = -1;
_frameLimiter = nullptr;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index a0fb2e46a4e..bb5986ddb57 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -466,6 +466,7 @@ public:
int _initialCountdown;
int _countdown;
int _ticks;
+ int _ticksFromEnd;
int _lastTick;
int _lastMinute;
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 82e6fca835b..37f73902bfa 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -394,17 +394,21 @@ bool DarkEngine::checkIfGameEnded() {
void DarkEngine::endGame() {
if (_gameStateControl == kFreescapeGameStateEnd) {
- if (true /*_countdown <= 0*/) {
+ if (!_ticksFromEnd)
+ _ticksFromEnd = _ticks;
+ else if ((_ticks - _ticksFromEnd) / 15 >= 15) {
if (_gameStateVars[kVariableDarkEnding]) {
executeLocalGlobalConditions(false, true, false);
_gameStateVars[kVariableDarkEnding] = 0;
insertTemporaryMessage(_messagesList[22], INT_MIN);
+ _currentArea->_colorRemaps.clear();
+ _gfx->setColorRemaps(&_currentArea->_colorRemaps);
}
}
}
if (_endGameKeyPressed && _gameStateVars[kVariableDarkEnding] == 0) {
- //_gameStateControl = kFreescapeGameStateRestart;
+ _gameStateControl = kFreescapeGameStateRestart;
}
_endGameKeyPressed = false;
}
@@ -597,6 +601,17 @@ void DarkEngine::executePrint(FCLInstruction &instruction) {
void DarkEngine::drawBinaryClock(Graphics::Surface *surface, int xPosition, int yPosition, uint32 front, uint32 back) {
int number = _ticks / 2;
+
+ if (_gameStateControl == kFreescapeGameStatePlaying)
+ number = _ticks / 2;
+ else if (_gameStateControl == kFreescapeGameStateEnd)
+ number = 1 << (_ticks - _ticksFromEnd) / 15;
+ else
+ return;
+
+ if (number >= 1 << 15)
+ number = (1 << 15) - 1;
+
int bits = 0;
while (bits <= 15) {
int y = yPosition - (7 * bits);
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 4e635103b90..2b70a8a53a5 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -142,9 +142,10 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
if (areaID == _startArea && entranceID == _startEntrance)
playSound(9, true);
- if (areaID == _endArea && entranceID == _endEntrance)
+ if (areaID == _endArea && entranceID == _endEntrance) {
_flyMode = true;
- else
+ _pitch = 20;
+ } else
playSound(5, false);
if (_currentArea->_skyColor > 0 && _currentArea->_skyColor != 255) {
Commit: 3f82028ddf44a02d705aa54cb2739c518b637162
https://github.com/scummvm/scummvm/commit/3f82028ddf44a02d705aa54cb2739c518b637162
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: falling handling fixes for eclipse
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/eclipse/dos.cpp
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/language/instruction.cpp
engines/freescape/movement.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 6e6987650d9..7cde785ee73 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -92,6 +92,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_position = Math::Vector3d(0, 0, 0);
_lastPosition = Math::Vector3d(0, 0, 0);
_hasFallen = false;
+ _maxFallingDistance = 64;
_velocity = Math::Vector3d(0, 0, 0);
_cameraFront = Math::Vector3d(0, 0, 0);
_cameraRight = Math::Vector3d(0, 0, 0);
@@ -334,8 +335,10 @@ void FreescapeEngine::drawFrame() {
}
drawBackground();
- if (!_playerWasCrushed) // Avoid rendering inside objects
+ if (_avoidRenderingFrames == 0) // Avoid rendering inside objects
_currentArea->draw(_gfx, _ticks / 10);
+ else
+ _avoidRenderingFrames--;
if (_underFireFrames > 0) {
for (auto &it : _sensors) {
@@ -406,7 +409,7 @@ void FreescapeEngine::processInput() {
switch (event.type) {
case Common::EVENT_JOYBUTTON_DOWN:
- if (_hasFallen)
+ if (_hasFallen || _playerWasCrushed)
break;
switch (event.joystick.button) {
case Common::JOYSTICK_BUTTON_B:
@@ -715,6 +718,9 @@ bool FreescapeEngine::checkIfGameEnded() {
if (_gameStateControl != kFreescapeGameStatePlaying)
return false;
+ if (_avoidRenderingFrames > 0)
+ return false;
+
if (_gameStateVars[k8bitVariableShield] == 0) {
if (!_noShieldMessage.empty())
insertTemporaryMessage(_noShieldMessage, _countdown - 2);
@@ -783,6 +789,7 @@ void FreescapeEngine::initGameState() {
_playerWasCrushed = false;
_shootingFrames = 0;
_underFireFrames = 0;
+ _avoidRenderingFrames = 0;
_yaw = 0;
_pitch = 0;
_endGameKeyPressed = false;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index bb5986ddb57..de6bf78f91f 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -280,6 +280,7 @@ public:
bool tryStepUp(Math::Vector3d currentPosition);
bool tryStepDown(Math::Vector3d currentPosition);
bool _hasFallen;
+ int _maxFallingDistance;
int _maxShield;
int _maxEnergy;
@@ -392,6 +393,7 @@ public:
Common::RenderMode _renderMode;
ColorMap _colorMap;
int _underFireFrames;
+ int _avoidRenderingFrames;
int _shootingFrames;
void drawFrame();
void flashScreen(int backgroundColor);
diff --git a/engines/freescape/games/eclipse/dos.cpp b/engines/freescape/games/eclipse/dos.cpp
index c743cc3808c..d602831a3e6 100644
--- a/engines/freescape/games/eclipse/dos.cpp
+++ b/engines/freescape/games/eclipse/dos.cpp
@@ -54,7 +54,7 @@ void EclipseEngine::loadAssetsDOSFullGame() {
if (!file.isOpen())
error("Failed to open TOTEE.EXE");
- loadSoundsFx(&file, 0xecb4, 1);
+ loadSoundsFx(&file, 0xd670, 1);
loadSpeakerFx(&file, 0x7396 + 0x200, 0x72a1 + 0x200);
loadFonts(&file, 0xd403);
load8bitBinary(&file, 0x3ce0, 16);
@@ -158,12 +158,13 @@ soundFx *EclipseEngine::load1bPCM(Common::SeekableReadStream *file, int offset)
}
void EclipseEngine::loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) {
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 5; i++) {
_soundsFx[i] = load1bPCM(file, offset);
offset += (_soundsFx[i]->size / 8) + 4;
}
}
+
void EclipseEngine::playSoundFx(int index, bool sync) {
if (_soundsFx.size() == 0) {
debugC(1, kFreescapeDebugMedia, "WARNING: Sounds are not loaded");
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 2b70a8a53a5..fa08a5816b3 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -118,6 +118,19 @@ void EclipseEngine::loadAssets() {
}
bool EclipseEngine::checkIfGameEnded() {
+ if (_hasFallen && _avoidRenderingFrames == 0) {
+ _hasFallen = false;
+ playSoundFx(4, false);
+
+ if (_gameStateVars[k8bitVariableShield] > 4) {
+ _gameStateVars[k8bitVariableShield] -= 4;
+ return false; // Game can continue
+ }
+ if (!_fallenMessage.empty())
+ insertTemporaryMessage(_fallenMessage, _countdown - 4);
+ _gameStateControl = kFreescapeGameStateEnd;
+ }
+
FreescapeEngine::checkIfGameEnded();
return false;
}
@@ -169,7 +182,7 @@ void EclipseEngine::drawBackground() {
void EclipseEngine::titleScreen() {
if (isDOS())
- playSoundFx(0, true);
+ playSoundFx(2, true);
FreescapeEngine::titleScreen();
}
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index a58b4098077..5cba30f4295 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -528,6 +528,9 @@ void FreescapeEngine::executeMakeVisible(FCLInstruction &instruction) {
Math::AABB boundingBox = createPlayerAABB(_position, _playerHeight);
if (obj->_boundingBox.collides(boundingBox)) {
_playerWasCrushed = true;
+ _avoidRenderingFrames = 60 * 3;
+ if (isEclipse())
+ playSoundFx(2, true);
_shootingFrames = 0;
}
}
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index 1ea6bd03086..ca3f7ba5ed2 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -387,8 +387,12 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
newPosition = _currentArea->resolveCollisions(lastPosition, newPosition, _playerHeight);
int fallen = lastPosition.y() - newPosition.y();
- if (fallen > 64)
+ if (fallen > _maxFallingDistance) {
_hasFallen = !_disableFalling;
+ _avoidRenderingFrames = 60 * 3;
+ if (isEclipse())
+ playSoundFx(0, true);
+ }
if (!_hasFallen && fallen > 0) {
playSound(3, false);
Commit: 3e757424776a622cbac702367920939d6b493fd4
https://github.com/scummvm/scummvm/commit/3e757424776a622cbac702367920939d6b493fd4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: removed old message list and add info menu in eclipse
Changed paths:
engines/freescape/games/eclipse/dos.cpp
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/games/eclipse/eclipse.h
diff --git a/engines/freescape/games/eclipse/dos.cpp b/engines/freescape/games/eclipse/dos.cpp
index d602831a3e6..2bba2112cd7 100644
--- a/engines/freescape/games/eclipse/dos.cpp
+++ b/engines/freescape/games/eclipse/dos.cpp
@@ -54,6 +54,7 @@ void EclipseEngine::loadAssetsDOSFullGame() {
if (!file.isOpen())
error("Failed to open TOTEE.EXE");
+ loadMessagesFixedSize(&file, 0x710f, 16, 17);
loadSoundsFx(&file, 0xd670, 1);
loadSpeakerFx(&file, 0x7396 + 0x200, 0x72a1 + 0x200);
loadFonts(&file, 0xd403);
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index fa08a5816b3..c8d40474cd2 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -27,27 +27,6 @@
namespace Freescape {
-static const char *rawMessagesTable[] = {
- "HEART FAILURE",
- "SUN ECLIPSED",
- "CRUSHED TO DEATH",
- "FATAL FALL",
- "CURSE OVERCOME",
- "TOTAL ECLIPSE",
- "TOO HOT TO REST!",
- "RESTING...",
- " ANKH FOUND ",
- "WAY BLOCKED",
- "5 ANKHS REQUIRED",
- "$2M REWARD",
- "MAKE THE MATCH",
- "TOUCH TO COLLECT",
- "NO ENTRY",
- "REMOVE LID",
- "POISON AIR",
- "MATCH MADE",
- NULL};
-
EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEngine(syst, gd) {
if (isDOS())
initDOS();
@@ -65,17 +44,6 @@ EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : Frees
_playerDepth = 8;
_stepUpDistance = 32;
- const char **messagePtr = rawMessagesTable;
- if (isDOS()) {
- debugC(1, kFreescapeDebugParser, "String table:");
- while (*messagePtr) {
- Common::String message(*messagePtr);
- _messagesList.push_back(message);
- debugC(1, kFreescapeDebugParser, "%s", message.c_str());
- messagePtr++;
- }
- }
-
_playerStepIndex = 2;
_playerSteps.clear();
_playerSteps.push_back(1);
@@ -208,6 +176,94 @@ void EclipseEngine::borderScreen() {
}
}
+void EclipseEngine::drawInfoMenu() {
+ PauseToken pauseToken = pauseEngine();
+ _savedScreen = _gfx->getScreenshot();
+ uint32 color = 0;
+ switch (_renderMode) {
+ case Common::kRenderCGA:
+ color = 1;
+ break;
+ case Common::kRenderZX:
+ color = 6;
+ break;
+ default:
+ color = 14;
+ }
+ uint8 r, g, b;
+ _gfx->readFromPalette(color, r, g, b);
+ uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+ uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
+
+ Graphics::Surface *surface = new Graphics::Surface();
+ surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
+
+ surface->fillRect(Common::Rect(88, 48, 231, 103), black);
+ surface->frameRect(Common::Rect(88, 48, 231, 103), front);
+
+ surface->frameRect(Common::Rect(90, 50, 229, 101), front);
+
+ drawStringInSurface("L-LOAD S-SAVE", 105, 56, front, black, surface);
+ if (isSpectrum())
+ drawStringInSurface("1-TERMINATE", 105, 64, front, black, surface);
+ else
+ drawStringInSurface("ESC-TERMINATE", 105, 64, front, black, surface);
+
+ drawStringInSurface("T-TOGGLE", 128, 81, front, black, surface);
+ drawStringInSurface("SOUND ON/OFF", 113, 88, front, black, surface);
+
+ Common::Event event;
+ bool cont = true;
+ while (!shouldQuit() && cont) {
+ while (_eventManager->pollEvent(event)) {
+
+ // Events
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_l) {
+ _gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
+ loadGameDialog();
+ _gfx->setViewport(_viewArea);
+ } else if (event.kbd.keycode == Common::KEYCODE_s) {
+ _gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
+ saveGameDialog();
+ _gfx->setViewport(_viewArea);
+ } else if (isDOS() && event.kbd.keycode == Common::KEYCODE_t) {
+ playSound(6, true);
+ } else if ((isDOS() || isCPC()) && event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ _forceEndGame = true;
+ cont = false;
+ } else if (isSpectrum() && event.kbd.keycode == Common::KEYCODE_1) {
+ _forceEndGame = true;
+ cont = false;
+ } else
+ cont = false;
+ break;
+ case Common::EVENT_SCREEN_CHANGED:
+ _gfx->computeScreenViewport();
+ break;
+
+ default:
+ break;
+ }
+ }
+ drawFrame();
+ drawFullscreenSurface(surface);
+
+ _gfx->flipBuffer();
+ g_system->updateScreen();
+ g_system->delayMillis(15); // try to target ~60 FPS
+ }
+
+ _savedScreen->free();
+ delete _savedScreen;
+ surface->free();
+ delete surface;
+ pauseToken.clear();
+}
+
void EclipseEngine::drawAnalogClock(Graphics::Surface *surface, int x, int y, uint32 colorHand1, uint32 colorHand2, uint32 colorBack) {
// These calls will cover the pixels of the hardcoded clock image
drawAnalogClockHand(surface, x, y, 6 * 6 - 90, 12, colorBack);
diff --git a/engines/freescape/games/eclipse/eclipse.h b/engines/freescape/games/eclipse/eclipse.h
index ceaf0e7ea2a..a82ba59bef0 100644
--- a/engines/freescape/games/eclipse/eclipse.h
+++ b/engines/freescape/games/eclipse/eclipse.h
@@ -38,6 +38,7 @@ public:
void borderScreen() override;
void titleScreen() override;
+ void drawInfoMenu() override;
void loadAssets() override;
void loadAssetsDOSFullGame() override;
Commit: 5bf0d2cfdd84c88488f2c49d4d934dd8c3f32df9
https://github.com/scummvm/scummvm/commit/5bf0d2cfdd84c88488f2c49d4d934dd8c3f32df9
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: purge keyboard events before calling save/load dialogs
Changed paths:
engines/freescape/games/dark/dark.cpp
engines/freescape/games/driller/driller.cpp
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 37f73902bfa..17663fa075c 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -697,10 +697,12 @@ void DarkEngine::drawInfoMenu() {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_l) {
_gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
loadGameDialog();
_gfx->setViewport(_viewArea);
} else if (event.kbd.keycode == Common::KEYCODE_s) {
_gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
saveGameDialog();
_gfx->setViewport(_viewArea);
} else if (isDOS() && event.kbd.keycode == Common::KEYCODE_t) {
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index e264040da5d..10e7831fb28 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -335,10 +335,12 @@ void DrillerEngine::drawInfoMenu() {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_l) {
_gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
loadGameDialog();
_gfx->setViewport(_viewArea);
} else if (event.kbd.keycode == Common::KEYCODE_s) {
_gfx->setViewport(_fullscreenViewArea);
+ _eventManager->purgeKeyboardEvents();
saveGameDialog();
_gfx->setViewport(_viewArea);
} else if (isDOS() && event.kbd.keycode == Common::KEYCODE_t) {
Commit: a14165eeaa3602d9e9ee1589a9565ae5bcd84609
https://github.com/scummvm/scummvm/commit/a14165eeaa3602d9e9ee1589a9565ae5bcd84609
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: implemented rest key in eclipse
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/games/eclipse/eclipse.h
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 7cde785ee73..9bfe38f0790 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -472,7 +472,10 @@ void FreescapeEngine::processInput() {
decreaseStepSize();
break;
case Common::KEYCODE_r:
- rise();
+ if (isEclipse())
+ pressedKey(Common::KEYCODE_r);
+ else
+ rise();
break;
case Common::KEYCODE_f:
lower();
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index c8d40474cd2..5cdf7d3df6f 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -264,6 +264,20 @@ void EclipseEngine::drawInfoMenu() {
pauseToken.clear();
}
+void EclipseEngine::pressedKey(const int keycode) {
+ if (keycode == Common::KEYCODE_r) {
+ if (_currentArea->getAreaID() == 1) {
+ playSoundFx(3, false);
+ if (_temporaryMessages.empty())
+ insertTemporaryMessage(_messagesList[6], _countdown - 2);
+ } else {
+ if (_temporaryMessages.empty())
+ insertTemporaryMessage(_messagesList[7], _countdown - 2);
+ _countdown = _countdown - 5;
+ }
+ }
+}
+
void EclipseEngine::drawAnalogClock(Graphics::Surface *surface, int x, int y, uint32 colorHand1, uint32 colorHand2, uint32 colorBack) {
// These calls will cover the pixels of the hardcoded clock image
drawAnalogClockHand(surface, x, y, 6 * 6 - 90, 12, colorBack);
diff --git a/engines/freescape/games/eclipse/eclipse.h b/engines/freescape/games/eclipse/eclipse.h
index a82ba59bef0..04d46a6550f 100644
--- a/engines/freescape/games/eclipse/eclipse.h
+++ b/engines/freescape/games/eclipse/eclipse.h
@@ -42,6 +42,7 @@ public:
void loadAssets() override;
void loadAssetsDOSFullGame() override;
+ void pressedKey(const int keycode);
uint32 _initialEnergy;
uint32 _initialShield;
Commit: d659bb05bf0566b918921a86856e2e2255427a96
https://github.com/scummvm/scummvm/commit/d659bb05bf0566b918921a86856e2e2255427a96
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-02-13T14:53:16+01:00
Commit Message:
FREESCAPE: implemented eng game sequence in eclipse
Changed paths:
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/games/eclipse/eclipse.h
engines/freescape/gfx.h
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl.h
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 5cdf7d3df6f..4dd07e5cf3b 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -103,6 +103,21 @@ bool EclipseEngine::checkIfGameEnded() {
return false;
}
+void EclipseEngine::endGame() {
+ if (_gameStateControl == kFreescapeGameStateEnd) {
+ removeTimers();
+ if (_countdown > 0)
+ _countdown -= 10;
+ else
+ _countdown = 0;
+ }
+
+ if (_endGameKeyPressed && _countdown == 0) {
+ _gameStateControl = kFreescapeGameStateRestart;
+ }
+ _endGameKeyPressed = false;
+}
+
void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
debugC(1, kFreescapeDebugMove, "Jumping to area: %d, entrance: %d", areaID, entranceID);
@@ -144,7 +159,16 @@ void EclipseEngine::drawBackground() {
clearBackground();
_gfx->drawBackground(_currentArea->_skyColor);
if (_currentArea && _currentArea->getAreaID() == 1) {
- _gfx->drawEclipse(15, 10);
+ if (_countdown <= 15 * 60) // Last 15 minutes
+ _gfx->drawBackground(5);
+ if (_countdown <= 10) // Last 10 seconds
+ _gfx->drawBackground(1);
+
+ float progress = 0;
+ if (_countdown >= 0)
+ progress = float(_countdown) / _initialCountdown;
+
+ _gfx->drawEclipse(15, 10, progress);
}
}
diff --git a/engines/freescape/games/eclipse/eclipse.h b/engines/freescape/games/eclipse/eclipse.h
index 04d46a6550f..ae5f8603a06 100644
--- a/engines/freescape/games/eclipse/eclipse.h
+++ b/engines/freescape/games/eclipse/eclipse.h
@@ -66,6 +66,7 @@ public:
soundFx *load1bPCM(Common::SeekableReadStream *file, int offset);
bool checkIfGameEnded() override;
+ void endGame() override;
void loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) override;
void playSoundFx(int index, bool sync) override;
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 3e84e863186..83c23ea55f6 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -98,7 +98,7 @@ public:
virtual void clear(uint8 r, uint8 g, uint8 b, bool ignoreViewport = false) = 0;
virtual void drawFloor(uint8 color) = 0;
virtual void drawBackground(uint8 color);
- virtual void drawEclipse(uint8 color1, uint8 color2) {};
+ virtual void drawEclipse(uint8 color1, uint8 color2, float difference) {};
Common::Rect viewport() const;
virtual Common::Point nativeResolution() { return Common::Point(_screenW, _screenH); }
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 6a1caa0237b..8dd06b77ce2 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -326,12 +326,11 @@ void OpenGLRenderer::drawCelestialBody(Math::Vector3d position, float radius, by
glPopMatrix();
}
-void OpenGLRenderer::drawEclipse(byte color1, byte color2) {
+void OpenGLRenderer::drawEclipse(byte color1, byte color2, float progress) {
Math::Vector3d sunPosition(-5000, 2000, 500);
float radius = 500.0;
drawCelestialBody(sunPosition, radius, color1);
-
- Math::Vector3d moonPosition(-5000, 2000, 1000);
+ Math::Vector3d moonPosition(-5000, 2000, 500 + 500 * progress);
drawCelestialBody(moonPosition, radius, color2);
}
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index e932af50f21..ef4b3ac612a 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -107,7 +107,7 @@ public:
virtual void flipBuffer() override;
virtual void drawFloor(uint8 color) override;
- virtual void drawEclipse(uint8 color1, uint8 color2) override;
+ virtual void drawEclipse(uint8 color1, uint8 color2, float difference) override;
void drawCelestialBody(Math::Vector3d position, float radius, uint8 color);
virtual Graphics::Surface *getScreenshot() override;
More information about the Scummvm-git-logs
mailing list