[Scummvm-git-logs] scummvm master -> 7a2ef8ba20488082602a86c3a5e543a3c7d49e0e
neuromancer
noreply at scummvm.org
Sat Oct 4 13:21:44 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
3261129f7b FREESCAPE: restored original animation for castle for dos and refactored some code to allow executing code before starti
b50f3062a7 FREESCAPE: make wait for sound more responsive using wait in loop
7a2ef8ba20 FREESCAPE: avoid getting stuck in movement when a script is executed
Commit: 3261129f7bd5000d11bf5cc0f8d132de842eae60
https://github.com/scummvm/scummvm/commit/3261129f7bd5000d11bf5cc0f8d132de842eae60
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-04T10:20:46-03:00
Commit Message:
FREESCAPE: restored original animation for castle for dos and refactored some code to allow executing code before starting
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/castle/castle.cpp
engines/freescape/games/castle/castle.h
engines/freescape/games/castle/dos.cpp
engines/freescape/games/castle/zx.cpp
engines/freescape/sound.cpp
engines/freescape/ui.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 62033fd352a..d1b39f1e3ae 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -781,6 +781,8 @@ void FreescapeEngine::executeMovementConditions() {
void FreescapeEngine::updateTimeVariables() {}
+void FreescapeEngine::beforeStarting() {}
+
Common::Error FreescapeEngine::run() {
_vsyncEnabled = g_system->getFeatureState(OSystem::kFeatureVSync);
_frameLimiter = new Graphics::FrameLimiter(g_system, ConfMan.getInt("engine_speed"));
@@ -803,7 +805,6 @@ Common::Error FreescapeEngine::run() {
// Load game data and init game state
loadDataBundle();
loadAssets();
- initGameState();
loadColorPalette();
if (g_system->getFeatureState(OSystem::kFeatureTouchscreen)) {
@@ -824,33 +825,30 @@ Common::Error FreescapeEngine::run() {
processBorder(); // Border is processed to use during the game
if (saveSlot >= 0) { // load the savegame
+ initGameState();
loadGameState(saveSlot);
- } else
- gotoArea(_startArea, _startEntrance);
-
- debugC(1, kFreescapeDebugMove, "Starting area %d", _currentArea->getAreaID());
- // Draw first frame
+ }
g_system->showMouse(false);
g_system->lockMouse(true);
resetInput();
- _gfx->computeScreenViewport();
- _gfx->clear(0, 0, 0, true);
- _gfx->flipBuffer();
- g_system->updateScreen();
while (!shouldQuit()) {
float currentFrame = g_system->getMillis();
float deltaTime = (currentFrame - _lastFrame) / 1000.0f;
_lastFrame = currentFrame;
- updateTimeVariables();
- if (_gameStateControl == kFreescapeGameStateRestart) {
+ if (_gameStateControl == kFreescapeGameStateRestart || _gameStateControl == kFreescapeGameStateStart) {
initGameState();
gotoArea(_startArea, _startEntrance);
+ g_system->updateScreen();
+ debugC(1, kFreescapeDebugMove, "Starting area %d", _currentArea->getAreaID());
+ beforeStarting();
+ _gameStateControl = kFreescapeGameStatePlaying;
} else if (_gameStateControl == kFreescapeGameStateEnd)
endGame();
+ updateTimeVariables();
processInput();
updatePlayerMovement(deltaTime);
if (_demoMode)
@@ -1017,7 +1015,6 @@ uint16 FreescapeEngine::getGameBit(int index) {
}
void FreescapeEngine::initGameState() {
- _gameStateControl = kFreescapeGameStatePlaying;
_endGameDelayTicks = int(2 * 60); // 2.5 seconds at 60 frames per second
for (int i = 0; i < k8bitMaxVariable; i++) // TODO: check maximum variable
@@ -1148,6 +1145,7 @@ Common::Error FreescapeEngine::loadGameStream(Common::SeekableReadStream *stream
gotoArea(areaID, -1); // Do not change position nor rotation
_playerHeight = 32 * (_playerHeightNumber + 1) - 16 / float(_currentArea->_scale);
+ _gameStateControl = kFreescapeGameStatePlaying;
return loadGameStreamExtended(stream);
}
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 91ff3c3751d..6217d2b0512 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -193,6 +193,7 @@ public:
bool isCPC() { return _gameDescription->platform == Common::kPlatformAmstradCPC; }
bool isC64() { return _gameDescription->platform == Common::kPlatformC64; }
+ virtual void beforeStarting();
Common::Error run() override;
// UI
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 524fec7a75e..6ade2160b6e 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -39,7 +39,7 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
if (!Common::parseBool(ConfMan.get("rock_travel"), _useRockTravel))
error("Failed to parse bool from rock_travel option");
- _soundIndexStart = 9;
+ _soundIndexStart = 11;
_soundIndexAreaChange = 24;
_soundIndexCollide = 4;
_soundIndexStepUp = 5;
@@ -303,6 +303,13 @@ void CastleEngine::initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *inf
engineKeyMap->addAction(act);
}
+void CastleEngine::beforeStarting() {
+ if (isDOS())
+ waitInLoop(250);
+ else if (isSpectrum())
+ waitInLoop(100);
+}
+
void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
debugC(1, kFreescapeDebugMove, "Jumping to area: %d, entrance: %d", areaID, entranceID);
@@ -1516,6 +1523,45 @@ void CastleEngine::selectCharacterScreen() {
}
+void CastleEngine::drawLiftingGate(Graphics::Surface *surface) {
+ uint32 keyColor = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x24, 0xA5);
+ int duration = 0;
+
+ if (isDOS())
+ duration = 250;
+ else if (isSpectrum())
+ duration = 100;
+
+ if ((_gameStateControl == kFreescapeGameStateStart || _gameStateControl == kFreescapeGameStateRestart) && _ticks <= duration) { // Draw the _gameOverBackgroundFrame gate lifting up slowly
+ int gate_w = _gameOverBackgroundFrame->w;
+ int gate_h = _gameOverBackgroundFrame->h;
+
+ // The gate should move up by the height of the view area to disappear.
+ int y_offset = _ticks * _viewArea.height() / duration;
+
+ // Initial position is with the gate bottom at the view area bottom.
+ int dx = _viewArea.left + (_viewArea.width() - gate_w) / 2;
+ int dy = (_viewArea.bottom - gate_h) - y_offset;
+
+ // Define destination rect for the full gate
+ Common::Rect destRect(dx, dy, dx + gate_w, dy + gate_h);
+
+ // Find intersection with view area to clip
+ Common::Rect clippedDest = destRect.findIntersectingRect(_viewArea);
+
+ // If there is something to draw
+ if (clippedDest.isValidRect() && clippedDest.width() > 0 && clippedDest.height() > 0) {
+ // Adjust source rect based on clipping
+ int src_x = clippedDest.left - destRect.left;
+ int src_y = clippedDest.top - destRect.top;
+ Common::Rect clippedSrc(src_x, src_y, src_x + clippedDest.width(), src_y + clippedDest.height());
+
+ // Draw the clipped part
+ surface->copyRectToSurfaceWithKey(*_gameOverBackgroundFrame, clippedDest.left, clippedDest.top, clippedSrc, keyColor);
+ }
+ }
+}
+
Common::Error CastleEngine::saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave) {
stream->writeUint32LE(_keysCollected.size());
for (auto &it : _keysCollected) {
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index dfa06722485..40f7320a43e 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -49,6 +49,7 @@ public:
Graphics::ManagedSurface *_menuFxOffIndicator;
Graphics::ManagedSurface *_menu;
+ void beforeStarting() override;
void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
void initGameState() override;
void endGame() override;
@@ -73,6 +74,7 @@ public:
void drawCPCUI(Graphics::Surface *surface) override;
void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
void drawEnergyMeter(Graphics::Surface *surface, Common::Point origin);
+ void drawLiftingGate(Graphics::Surface *surface);
void pressedKey(const int keycode) override;
void checkSensors() override;
void updateTimeVariables() override;
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index ae51c7be435..719622ec5a7 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -428,6 +428,7 @@ void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
uint32 color = 10;
uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
uint8 r, g, b;
+ drawLiftingGate(surface);
_gfx->readFromPalette(color, r, g, b);
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
@@ -448,7 +449,7 @@ void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
_temporaryMessages.push_back(message);
_temporaryMessageDeadlines.push_back(deadline);
} else {
- if (_gameStateControl == kFreescapeGameStatePlaying) {
+ if (_gameStateControl != kFreescapeGameStateEnd) {
if (ghostInArea())
drawStringInSurface(_messagesList[116], 97, 182, front, back, surface);
else
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index b22c384db58..63a81cbcc3c 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -36,7 +36,7 @@ void CastleEngine::initZX() {
_soundIndexStepDown = -1;
_soundIndexMenu = -1;
_soundIndexStart = 6;
- _soundIndexAreaChange = 7;
+ _soundIndexAreaChange = 6;
}
Graphics::ManagedSurface *CastleEngine::loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back) {
@@ -247,6 +247,8 @@ void CastleEngine::drawZXUI(Graphics::Surface *surface) {
uint32 color = 5;
uint8 r, g, b;
+ drawLiftingGate(surface);
+
_gfx->readFromPalette(color, r, g, b);
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
@@ -266,7 +268,7 @@ void CastleEngine::drawZXUI(Graphics::Surface *surface) {
_temporaryMessages.push_back(message);
_temporaryMessageDeadlines.push_back(deadline);
} else {
- if (_gameStateControl == kFreescapeGameStatePlaying) {
+ if (_gameStateControl != kFreescapeGameStateEnd) {
drawStringInSurface(_currentArea->_name, 120, 179, front, black, surface);
}
}
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index a5ffd8150a4..227edce8261 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -444,6 +444,7 @@ void FreescapeEngine::playSoundFx(int index, bool sync) {
}
void FreescapeEngine::stopAllSounds(Audio::SoundHandle &handle) {
+ debugC(1, kFreescapeDebugMedia, "Stopping sound");
_mixer->stopHandle(handle);
}
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index 3353b20e894..cf1ce465e2a 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -24,7 +24,8 @@
namespace Freescape {
void FreescapeEngine::waitInLoop(int maxWait) {
- for (int i = 0; i < maxWait; i++) {
+ long int startTick = _ticks;
+ while (_ticks <= startTick + maxWait) {
Common::Event event;
while (_eventManager->pollEvent(event)) {
Common::Point mousePos;
Commit: b50f3062a7b0482e544e70370f7346a28f3c9e5f
https://github.com/scummvm/scummvm/commit/b50f3062a7b0482e544e70370f7346a28f3c9e5f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-04T10:20:46-03:00
Commit Message:
FREESCAPE: make wait for sound more responsive using wait in loop
Changed paths:
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/sound.cpp
engines/freescape/ui.cpp
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 02f0320f52b..9193db013e0 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -307,7 +307,7 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
if (areaID == _startArea && entranceID == _startEntrance) {
if (_pitch >= 180)
_pitch = 360 - _pitch;
- playSound(_soundIndexStart, true, _soundFxHandle);
+ playSound(_soundIndexStart, false, _soundFxHandle);
if (isEclipse2()) {
_gameStateControl = kFreescapeGameStateStart;
_pitch = -10;
@@ -448,7 +448,7 @@ void EclipseEngine::drawInfoMenu() {
saveGameDialog();
_gfx->setViewport(_viewArea);
} else if (isDOS() && event.customType == kActionToggleSound) {
- playSound(_soundIndexMenu, true, _soundFxHandle);
+ playSound(_soundIndexMenu, false, _soundFxHandle);
} else if ((isDOS() || isCPC() || isSpectrum()) && event.customType == kActionEscape) {
_forceEndGame = true;
cont = false;
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index 227edce8261..875e7fdb7ff 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -451,10 +451,10 @@ void FreescapeEngine::stopAllSounds(Audio::SoundHandle &handle) {
void FreescapeEngine::waitForSounds() {
if (_usePrerecordedSounds || isAmiga() || isAtariST())
while (_mixer->isSoundHandleActive(_soundFxHandle))
- g_system->delayMillis(10);
+ waitInLoop(10);
else {
while (!_speaker->endOfStream())
- g_system->delayMillis(10);
+ waitInLoop(10);
}
}
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index cf1ce465e2a..b907bc0755e 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -28,6 +28,9 @@ void FreescapeEngine::waitInLoop(int maxWait) {
while (_ticks <= startTick + maxWait) {
Common::Event event;
while (_eventManager->pollEvent(event)) {
+ if (_ticks > startTick + maxWait)
+ break;
+
Common::Point mousePos;
switch (event.type) {
case Common::EVENT_QUIT:
@@ -91,6 +94,8 @@ void FreescapeEngine::waitInLoop(int maxWait) {
g_system->delayMillis(15); // try to target ~60 FPS
}
_gfx->clear(0, 0, 0, true);
+ _eventManager->purgeMouseEvents();
+ _eventManager->purgeKeyboardEvents();
}
void FreescapeEngine::titleScreen() {
Commit: 7a2ef8ba20488082602a86c3a5e543a3c7d49e0e
https://github.com/scummvm/scummvm/commit/7a2ef8ba20488082602a86c3a5e543a3c7d49e0e
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-04T10:20:46-03:00
Commit Message:
FREESCAPE: avoid getting stuck in movement when a script is executed
Changed paths:
engines/freescape/events.cpp
engines/freescape/freescape.h
engines/freescape/movement.cpp
diff --git a/engines/freescape/events.cpp b/engines/freescape/events.cpp
index 1257b8448aa..db5f0039d51 100644
--- a/engines/freescape/events.cpp
+++ b/engines/freescape/events.cpp
@@ -123,4 +123,8 @@ bool EventManagerWrapper::isActionActive(const Common::CustomEventType &action)
return _currentActionDown == action;
}
+bool EventManagerWrapper::isKeyPressed() {
+ return _currentKeyDown.keycode != Common::KEYCODE_INVALID;
+}
+
} // namespace Freescape
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 6217d2b0512..8787af858bb 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -152,6 +152,7 @@ public:
void pushEvent(Common::Event &event);
void clearExitEvents();
bool isActionActive(const Common::CustomEventType &action);
+ bool isKeyPressed();
private:
// for continuous events (keyDown)
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index 6f197932c45..a19b4781e61 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -425,6 +425,18 @@ void FreescapeEngine::updatePlayerMovementClassic(float deltaTime) {
}
void FreescapeEngine::updatePlayerMovementSmooth(float deltaTime) {
+ if (_moveForward && !_eventManager->isActionActive(kActionMoveUp))
+ _moveForward = false;
+
+ if (_moveBackward && !_eventManager->isActionActive(kActionMoveDown))
+ _moveBackward = false;
+
+ if (_strafeLeft && !_eventManager->isActionActive(kActionMoveLeft))
+ _strafeLeft = false;
+
+ if (_strafeRight && !_eventManager->isActionActive(kActionMoveRight))
+ _strafeRight = false;
+
if (!_moveForward && !_moveBackward && !_strafeLeft && !_strafeRight)
return;
@@ -471,8 +483,6 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
_gotoExecuted = false;
bool executed = runCollisionConditions(lastPosition, newPosition);
- if (executed)
- stopMovement();
if (_gotoExecuted) {
_gotoExecuted = false;
@@ -543,8 +553,7 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
if (!_hasFallen && fallen > 0) {
isSteppingDown = true;
// Position in Y was changed, let's re-run effects
- if (runCollisionConditions(_lastPosition, newPosition))
- stopMovement();
+ runCollisionConditions(_lastPosition, newPosition);
}
if (isSteppingUp && (newPosition - _lastPosition).length() <= 1) {
@@ -592,8 +601,7 @@ bool FreescapeEngine::runCollisionConditions(Math::Vector3d const lastPosition,
Object *collided = nullptr;
_gotoExecuted = false;
- if (!_smoothMovement)
- _speaker->stop();
+ _speaker->stop();
Math::Ray ray(newPosition, -_upVector);
collided = _currentArea->checkCollisionRay(ray, _playerHeight + 3);
More information about the Scummvm-git-logs
mailing list