[Scummvm-git-logs] scummvm master -> 3141414e3a7870575e9eaf4751dc1733ea1ac496
mduggan
noreply at scummvm.org
Sat Oct 26 05:09:12 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
81ca1d6296 DGDS: Fix dialog drawing on scene change
3141414e3a DGDS: Fix Dragon arcade sequences a bit
Commit: 81ca1d629674c54c405d0a102bc9c0bc19e45930
https://github.com/scummvm/scummvm/commit/81ca1d629674c54c405d0a102bc9c0bc19e45930
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-26T16:05:00+11:00
Commit Message:
DGDS: Fix dialog drawing on scene change
Changed paths:
engines/dgds/scene.cpp
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index f7c475338e0..862c60512b1 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -1553,8 +1553,19 @@ bool SDSScene::checkDialogActive() {
if (action || dlg._action.empty()) {
dlg.setFlag(kDlgFlagHiFinished);
if (action) {
- debug("Dialog closing: run action (%d ops)", action->sceneOpList.size());
+ // Take a copy of the dialog because the actions might change the scene
+ Dialog dlgCopy = dlg;
+ debug("Dialog %d closing: run action (%d ops)", dlg._num, action->sceneOpList.size());
if (!runOps(action->sceneOpList)) {
+ // HACK: the scene changed, but we haven't yet drawn the foreground for the
+ // dialog, this is our last chance so do it now. The game does it in a
+ // different way that relies on delayed disposal of the dialog data.
+ if (dlgCopy.hasFlag(kDlgFlagVisible) && !dlgCopy.hasFlag(kDlgFlagOpening)) {
+ DgdsEngine *engine = DgdsEngine::getInstance();
+ dlgCopy.draw(&engine->_compositionBuffer, kDlgDrawFindSelectionPointXY);
+ dlgCopy.draw(&engine->_compositionBuffer, kDlgDrawFindSelectionTxtOffset);
+ dlgCopy.draw(&engine->_compositionBuffer, kDlgDrawStageForeground);
+ }
_dlgWithFlagLo8IsClosing = false;
return true;
}
Commit: 3141414e3a7870575e9eaf4751dc1733ea1ac496
https://github.com/scummvm/scummvm/commit/3141414e3a7870575e9eaf4751dc1733ea1ac496
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-26T16:05:48+11:00
Commit Message:
DGDS: Fix Dragon arcade sequences a bit
Dragon arcade sequences should run at 15 FPS, the rest of the game runs at 30.
This also fixes a potential issue with stale data after load/save, and
correclty starts the music.
Changed paths:
engines/dgds/dgds.cpp
engines/dgds/dgds.h
engines/dgds/dialog.cpp
engines/dgds/dragon_arcade.cpp
diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 105b6f08831..eacc557a212 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -85,7 +85,7 @@ DgdsEngine::DgdsEngine(OSystem *syst, const ADGameDescription *gameDesc)
_detailLevel(kDgdsDetailHigh), _textSpeed(1), _justChangedScene1(false), _justChangedScene2(false),
_random("dgds"), _currentCursor(-1), _menuToTrigger(kMenuNone), _isLoading(true), _flipMode(false),
_rstFileName(nullptr), _difficulty(1), _menu(nullptr), _adsInterp(nullptr), _isDemo(false),
- _dragonArcade(nullptr) {
+ _dragonArcade(nullptr), _skipNextFrame(false) {
syncSoundSettings();
_platform = gameDesc->platform;
@@ -323,6 +323,10 @@ void DgdsEngine::init(bool restarting) {
delete _menu;
delete _adsInterp;
delete _inventory;
+ if (_dragonArcade)
+ delete _dragonArcade;
+ if (_shellGame)
+ delete _shellGame;
}
_gamePals = new GamePalettes(_resource, _decompressor);
@@ -483,6 +487,9 @@ Common::Error DgdsEngine::run() {
_isLoading = false;
+ uint32 startMillis = g_system->getMillis();
+ uint32 frameCount = 0;
+
while (!shouldQuit()) {
Common::EventType mouseEvent = Common::EVENT_INVALID;
while (eventMan->pollEvent(ev)) {
@@ -584,107 +591,123 @@ Common::Error DgdsEngine::run() {
default:
break;
}
- g_system->updateScreen();
- g_system->delayMillis(10);
_clock.update(false);
- continue;
- }
-
- _scene->checkForClearedDialogs();
-
- _gdsScene->runPreTickOps();
- _scene->runPreTickOps();
+ } else {
- _compositionBuffer.blitFrom(_backgroundBuffer);
+ _scene->checkForClearedDialogs();
- if (_inventory->isOpen() && _scene->getNum() == 2) {
- int invCount = _gdsScene->countItemsInScene2();
- _inventory->draw(_compositionBuffer, invCount);
- }
+ _gdsScene->runPreTickOps();
+ _scene->runPreTickOps();
- _compositionBuffer.transBlitFrom(_storedAreaBuffer);
+ _compositionBuffer.blitFrom(_backgroundBuffer);
- _scene->drawActiveDialogBgs(&_compositionBuffer);
-
- if (_scene->getNum() != 2 || _inventory->isZoomVisible())
- _adsInterp->run();
+ if (_inventory->isOpen() && _scene->getNum() == 2) {
+ int invCount = _gdsScene->countItemsInScene2();
+ _inventory->draw(_compositionBuffer, invCount);
+ }
- if (mouseEvent != Common::EVENT_INVALID) {
- if (_inventory->isOpen()) {
- switch (mouseEvent) {
- case Common::EVENT_MOUSEMOVE:
- _inventory->mouseMoved(_lastMouse);
- break;
- case Common::EVENT_LBUTTONDOWN:
- _inventory->mouseLDown(_lastMouse);
- break;
- case Common::EVENT_LBUTTONUP:
- _inventory->mouseLUp(_lastMouse);
- break;
- case Common::EVENT_RBUTTONUP:
- _inventory->mouseRUp(_lastMouse);
- break;
- default:
- break;
- }
- } else {
- switch (mouseEvent) {
- case Common::EVENT_MOUSEMOVE:
- _scene->mouseMoved(_lastMouse);
- break;
- case Common::EVENT_LBUTTONDOWN:
- _scene->mouseLDown(_lastMouse);
- break;
- case Common::EVENT_LBUTTONUP:
- _scene->mouseLUp(_lastMouse);
- break;
- case Common::EVENT_RBUTTONDOWN:
- _scene->mouseRDown(_lastMouse);
- break;
- case Common::EVENT_RBUTTONUP:
- _scene->mouseRUp(_lastMouse);
- break;
- default:
- break;
+ _compositionBuffer.transBlitFrom(_storedAreaBuffer);
+
+ _scene->drawActiveDialogBgs(&_compositionBuffer);
+
+ if (_scene->getNum() != 2 || _inventory->isZoomVisible())
+ _adsInterp->run();
+
+ if (mouseEvent != Common::EVENT_INVALID) {
+ if (_inventory->isOpen()) {
+ switch (mouseEvent) {
+ case Common::EVENT_MOUSEMOVE:
+ _inventory->mouseMoved(_lastMouse);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ _inventory->mouseLDown(_lastMouse);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _inventory->mouseLUp(_lastMouse);
+ break;
+ case Common::EVENT_RBUTTONUP:
+ _inventory->mouseRUp(_lastMouse);
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (mouseEvent) {
+ case Common::EVENT_MOUSEMOVE:
+ _scene->mouseMoved(_lastMouse);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ _scene->mouseLDown(_lastMouse);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _scene->mouseLUp(_lastMouse);
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ _scene->mouseRDown(_lastMouse);
+ break;
+ case Common::EVENT_RBUTTONUP:
+ _scene->mouseRUp(_lastMouse);
+ break;
+ default:
+ break;
+ }
}
}
- }
- // TODO: Hard-coded logic to match Rise of the Dragon, check others
- if (getGameId() != GID_DRAGON || _scene->getNum() != 55)
- _gdsScene->runPostTickOps();
+ // TODO: Hard-coded logic to match Rise of the Dragon, check others
+ if (getGameId() != GID_DRAGON || _scene->getNum() != 55)
+ _gdsScene->runPostTickOps();
- _scene->runPostTickOps();
- _scene->checkTriggers();
+ _scene->runPostTickOps();
+ _scene->checkTriggers();
- _dumpFrame(_backgroundBuffer, "back");
- _dumpFrame(_storedAreaBuffer, "stor");
- _dumpFrame(_compositionBuffer, "comp");
+ _dumpFrame(_backgroundBuffer, "back");
+ _dumpFrame(_storedAreaBuffer, "stor");
+ _dumpFrame(_compositionBuffer, "comp");
- if (!_inventory->isOpen()) {
- _gdsScene->drawItems(_compositionBuffer);
- checkDrawInventoryButton();
- }
+ if (!_inventory->isOpen()) {
+ _gdsScene->drawItems(_compositionBuffer);
+ checkDrawInventoryButton();
+ }
- if (getGameId() == GID_DRAGON)
- _clock.draw(_compositionBuffer);
+ if (getGameId() == GID_DRAGON)
+ _clock.draw(_compositionBuffer);
- bool haveActiveDialog = _scene->checkDialogActive();
+ bool haveActiveDialog = _scene->checkDialogActive();
- _scene->drawAndUpdateDialogs(&_compositionBuffer);
- _scene->drawVisibleHeads(&_compositionBuffer);
+ _scene->drawAndUpdateDialogs(&_compositionBuffer);
+ _scene->drawVisibleHeads(&_compositionBuffer);
- _dumpFrame(_compositionBuffer, "comp-with-dlg");
+ _dumpFrame(_compositionBuffer, "comp-with-dlg");
- bool gameRunning = (!haveActiveDialog && _gameGlobals->getGlobal(0x57) /* TODO: && _dragItem == nullptr*/);
- _clock.update(gameRunning);
+ bool gameRunning = (!haveActiveDialog && _gameGlobals->getGlobal(0x57) /* TODO: && _dragItem == nullptr*/);
+ _clock.update(gameRunning);
+
+ g_system->copyRectToScreen(_compositionBuffer.getPixels(), SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ _justChangedScene1 = false;
+ _justChangedScene2 = false;
+ }
- g_system->copyRectToScreen(_compositionBuffer.getPixels(), SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
g_system->updateScreen();
- g_system->delayMillis(10);
- _justChangedScene1 = false;
- _justChangedScene2 = false;
+ // Limit to 30 FPS
+ const uint32 thisFrameMillis = g_system->getMillis();
+ frameCount++;
+ if (_skipNextFrame) {
+ frameCount++;
+ _skipNextFrame = false;
+ }
+ const uint32 elapsedMillis = thisFrameMillis - startMillis;
+ const uint32 targetMillis = (frameCount * 1000 / 30);
+ if (targetMillis > elapsedMillis) {
+ // too fast, delay
+ g_system->delayMillis(targetMillis - elapsedMillis);
+ } else if (targetMillis < elapsedMillis) {
+ // too slow.. adjust expectations? :)
+ startMillis = g_system->getMillis();
+ frameCount = 0;
+ }
+
}
return Common::kNoError;
}
@@ -759,6 +782,13 @@ Common::Error DgdsEngine::syncGame(Common::Serializer &s) {
_soundPlayer->stopAllSfx();
_scene->unload();
_adsInterp->unload();
+
+ // Clear arcade state completely.
+ if (getGameId() == GID_DRAGON) {
+ delete _dragonArcade;
+ _dragonArcade = new DragonArcade();
+ }
+
_scene->load(sceneFile, _resource, _decompressor);
}
diff --git a/engines/dgds/dgds.h b/engines/dgds/dgds.h
index 2216c3e4e26..cfcef2f1cce 100644
--- a/engines/dgds/dgds.h
+++ b/engines/dgds/dgds.h
@@ -168,6 +168,7 @@ private:
bool _isDemo;
bool _flipMode;
+ bool _skipNextFrame;
public:
DgdsEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -242,6 +243,7 @@ public:
bool isInvButtonVisible() const;
ShellGame *getShellGame() { return _shellGame; }
DragonArcade *getDragonArcade() { return _dragonArcade; }
+ void setSkipNextFrame() { _skipNextFrame = true; }
static DgdsEngine *getInstance() { return static_cast<DgdsEngine *>(g_engine); }
void setFlipMode(bool mode) { _flipMode = mode; }
diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index d9dbb306235..8e6fc91d4cb 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -614,7 +614,7 @@ void Dialog::updateSelectedAction(int delta) {
}
if (_action.size() > 1 || !delta) {
- debug("Dialog: update mouse to %d, %d (mouseloc %d, selnum %d)", mouseX, mouseY, _state->_strMouseLoc, _lastSelectedDialogItemNum);
+ debug("Dialog %d: update mouse to %d, %d (mouseloc %d, selnum %d)", _num, mouseX, mouseY, _state->_strMouseLoc, _lastSelectedDialogItemNum);
g_system->warpMouse(mouseX, mouseY);
}
}
diff --git a/engines/dgds/dragon_arcade.cpp b/engines/dgds/dragon_arcade.cpp
index f40c5526065..2b16d88c304 100644
--- a/engines/dgds/dragon_arcade.cpp
+++ b/engines/dgds/dragon_arcade.cpp
@@ -76,7 +76,7 @@ void DragonArcade::finish() {
engine->enableKeymapper();
_initFinished = false;
- warning("TODO: DragonArcade::finish: copy/clear some vid buffers here?");
+ //warning("TODO: DragonArcade::finish: copy/clear some vid buffers here?");
}
bool DragonArcade::doTickUpdate() {
@@ -136,8 +136,10 @@ bool DragonArcade::doTickUpdate() {
break;
}
drawHealthBars();
- //do { } while (_arcadeTickDelay != 0);
- //_arcadeTickDelay = 4;
+
+ // Original has delay here to reduce the arcade speed to 15 FPS.
+ DgdsEngine::getInstance()->setSkipNextFrame();
+
_nTickUpdates++;
return true;
@@ -1665,6 +1667,7 @@ void DragonArcade::initIfNeeded() {
_arrowImg->loadBitmap("arcade.bmp");
engine->_soundPlayer->loadMusic(songName);
+ engine->_soundPlayer->playMusic(0);
// set font to 0?
// set text draw to 0xe?
drawBackgroundAndWeapons();
More information about the Scummvm-git-logs
mailing list