aboutsummaryrefslogtreecommitdiff
path: root/engines/cryomni3d
diff options
context:
space:
mode:
authorLe Philousophe2019-05-31 23:01:42 +0200
committerEugene Sandulenko2019-06-01 22:43:48 +0200
commitf25102ac76ffe7f5f2196f5fa260cfb9eb26e2c2 (patch)
treec8c9240049adbf58b6e032b7dfc0a4a2692565c9 /engines/cryomni3d
parente07844e06b56c3d299c5c7f88c5910dd0c882f3c (diff)
downloadscummvm-rg350-f25102ac76ffe7f5f2196f5fa260cfb9eb26e2c2.tar.gz
scummvm-rg350-f25102ac76ffe7f5f2196f5fa260cfb9eb26e2c2.tar.bz2
scummvm-rg350-f25102ac76ffe7f5f2196f5fa260cfb9eb26e2c2.zip
CRYOMNI3D: Put delayMillis out of pollEvents
This let's improve reaction times
Diffstat (limited to 'engines/cryomni3d')
-rw-r--r--engines/cryomni3d/cryomni3d.cpp5
-rw-r--r--engines/cryomni3d/fixed_image.cpp2
-rw-r--r--engines/cryomni3d/versailles/dialogs_manager.cpp5
-rw-r--r--engines/cryomni3d/versailles/documentation.cpp7
-rw-r--r--engines/cryomni3d/versailles/engine.cpp14
-rw-r--r--engines/cryomni3d/versailles/logic.cpp1
-rw-r--r--engines/cryomni3d/versailles/menus.cpp8
-rw-r--r--engines/cryomni3d/versailles/music.cpp3
-rw-r--r--engines/cryomni3d/versailles/toolbar.cpp11
9 files changed, 48 insertions, 8 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp
index f1ac389e71..193d1058a3 100644
--- a/engines/cryomni3d/cryomni3d.cpp
+++ b/engines/cryomni3d/cryomni3d.cpp
@@ -159,6 +159,7 @@ void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::Soun
}
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (pollEvents() && checkKeysPressed()) {
skipVideo = true;
@@ -214,6 +215,7 @@ void CryOmni3DEngine::displayHLZ(const Common::String &filename) {
}
}
g_system->updateScreen();
+ g_system->delayMillis(10);
}
delete imageDecoder;
@@ -242,7 +244,6 @@ bool CryOmni3DEngine::pollEvents() {
}
hasEvents = true;
}
- g_system->delayMillis(10);
_dragStatus = kDragStatus_NoDrag;
uint currentMouseButton = getCurrentMouseButton();
@@ -294,6 +295,8 @@ uint CryOmni3DEngine::getCurrentMouseButton() {
void CryOmni3DEngine::waitMouseRelease() {
while (g_system->getEventManager()->getButtonState() != 0 && !g_engine->shouldQuit()) {
pollEvents();
+ g_system->updateScreen();
+ g_system->delayMillis(10);
}
}
diff --git a/engines/cryomni3d/fixed_image.cpp b/engines/cryomni3d/fixed_image.cpp
index b3ea5f3f97..f00b309e11 100644
--- a/engines/cryomni3d/fixed_image.cpp
+++ b/engines/cryomni3d/fixed_image.cpp
@@ -191,6 +191,7 @@ void ZonFixedImage::manage() {
// Force poll events even when we must refresh the cursor
if (!_engine.pollEvents() && !_refreshCursor) {
g_system->updateScreen();
+ g_system->delayMillis(10);
return;
}
_refreshCursor = false;
@@ -266,6 +267,7 @@ void ZonFixedImage::manage() {
}
g_system->updateScreen();
+ g_system->delayMillis(10);
}
void ZonFixedImage::handleMouseZones(const Common::Array<Zone>::const_iterator &currentZone) {
diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp
index 27bcbb6055..2b9d38e3a1 100644
--- a/engines/cryomni3d/versailles/dialogs_manager.cpp
+++ b/engines/cryomni3d/versailles/dialogs_manager.cpp
@@ -55,6 +55,7 @@ bool Versailles_DialogsManager::play(const Common::String &sequence) {
uint end = g_system->getMillis() + 2000;
while (!g_engine->shouldQuit() && g_system->getMillis() < end && !skip) {
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents() &&
(_engine->checkKeysPressed(1, Common::KEYCODE_SPACE) ||
_engine->getCurrentMouseButton() == 1)) {
@@ -189,6 +190,8 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
bool skipWait = false;
uint end = g_system->getMillis() + duration;
while (!g_engine->shouldQuit() && g_system->getMillis() < end && !skipWait) {
+ g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents() && _engine->checkKeysPressed(1, Common::KEYCODE_SPACE)) {
skipWait = true;
}
@@ -224,6 +227,7 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
}
}
g_system->updateScreen();
+ g_system->delayMillis(10);
}
_engine->_mixer->stopHandle(audioHandle);
}
@@ -303,6 +307,7 @@ uint Versailles_DialogsManager::askPlayerQuestions(const Common::String &video,
_lastImage.h);
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
_engine->clearKeys();
diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp
index 38328f28cf..b830b0c70d 100644
--- a/engines/cryomni3d/versailles/documentation.cpp
+++ b/engines/cryomni3d/versailles/documentation.cpp
@@ -367,6 +367,7 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
if (!_engine->getCurrentMouseButton()) {
@@ -476,6 +477,7 @@ Common::String Versailles_Documentation::docAreaHandleTimeline() {
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
Common::Point mouse = _engine->getMousePos();
@@ -704,6 +706,7 @@ uint Versailles_Documentation::docAreaHandleRecord(Graphics::ManagedSurface &sur
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents() || first) {
first = false;
@@ -997,6 +1000,7 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
Common::Point mouse = _engine->getMousePos();
@@ -1233,6 +1237,7 @@ Common::String Versailles_Documentation::docAreaHandleCastleMap() {
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
Common::Point mouse = _engine->getMousePos();
@@ -1343,6 +1348,7 @@ uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surf
while (action == -1u) {
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
if (g_engine->shouldQuit()) {
@@ -1717,6 +1723,7 @@ uint Versailles_Documentation::handlePopupMenu(const Graphics::ManagedSurface
redraw = false;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (_engine->pollEvents()) {
if (g_engine->shouldQuit()) {
diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp
index d03bd958a4..7ec18a7ebe 100644
--- a/engines/cryomni3d/versailles/engine.cpp
+++ b/engines/cryomni3d/versailles/engine.cpp
@@ -1190,6 +1190,9 @@ int CryOmni3DEngine_Versailles::handleWarp() {
g_system->updateScreen();
}
}
+
+ // Slow down loop but after updating screen
+ g_system->delayMillis(10);
}
g_system->showMouse(false);
return actionId;
@@ -1346,6 +1349,9 @@ void CryOmni3DEngine_Versailles::animateWarpTransition(const Transition *transit
drawCountdown();
g_system->updateScreen();
+ // Slow down transition
+ g_system->delayMillis(10);
+
if (fabs(oldDeltaAlpha - deltaAlpha) < 0.001 && fabs(oldDeltaBeta - deltaBeta) < 0.001) {
exit = true;
}
@@ -1373,6 +1379,9 @@ void CryOmni3DEngine_Versailles::redrawWarp() {
void CryOmni3DEngine_Versailles::warpMsgBoxCB() {
pollEvents();
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
}
void CryOmni3DEngine_Versailles::animateCursor(const Object *obj) {
@@ -1385,17 +1394,17 @@ void CryOmni3DEngine_Versailles::animateCursor(const Object *obj) {
for (uint i = 4; i > 0; i--) {
// Wait 100ms
for (uint j = 10; j > 0; j--) {
- // pollEvents sleeps 10ms
pollEvents();
g_system->updateScreen();
+ g_system->delayMillis(10);
}
setCursor(obj->idSA());
g_system->updateScreen();
// Wait 100ms
for (uint j = 10; j > 0; j--) {
- // pollEvents sleeps 10ms
pollEvents();
g_system->updateScreen();
+ g_system->delayMillis(10);
}
setCursor(obj->idSl());
g_system->updateScreen();
@@ -1463,6 +1472,7 @@ void CryOmni3DEngine_Versailles::displayObject(const Common::String &imgName,
}
}
g_system->updateScreen();
+ g_system->delayMillis(10);
}
waitMouseRelease();
clearKeys();
diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp
index d39d531f64..02592ee871 100644
--- a/engines/cryomni3d/versailles/logic.cpp
+++ b/engines/cryomni3d/versailles/logic.cpp
@@ -3165,6 +3165,7 @@ FILTER_EVENT(1, 3) {
if (*event == 11301) {
while (!g_engine->shouldQuit() && _mixer->isSoundIDActive(SoundIds::kLeb001)) {
g_system->updateScreen();
+ g_system->delayMillis(10);
pollEvents();
}
clearKeys();
diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp
index dd95540602..031739d44a 100644
--- a/engines/cryomni3d/versailles/menus.cpp
+++ b/engines/cryomni3d/versailles/menus.cpp
@@ -214,6 +214,7 @@ uint CryOmni3DEngine_Versailles::displayOptions() {
drawState = 0;
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (pollEvents() || forceEvents) { // always call pollEvents
forceEvents = false;
@@ -520,6 +521,7 @@ uint CryOmni3DEngine_Versailles::displayYesNoBox(Graphics::ManagedSurface &surfa
g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, surface.w, surface.h);
}
g_system->updateScreen();
+ g_system->delayMillis(10);
if (pollEvents()) {
Common::Point mouse = getMousePos();
@@ -662,6 +664,8 @@ uint CryOmni3DEngine_Versailles::displayFilePicker(const Graphics::Surface *bgFr
}
g_system->updateScreen();
+ g_system->delayMillis(10);
+
pollEvents();
Common::KeyState key = getNextKey();
uint mousePressed = getCurrentMouseButton();
@@ -895,8 +899,6 @@ void CryOmni3DEngine_Versailles::displayMessageBox(const MsgBoxParameters &param
uint disappearTime = g_system->getMillis() + msg.size() * params.timeoutChar * 10;
bool finished = false;
while (!finished) {
- g_system->updateScreen();
-
callback();
if (g_system->getMillis() > disappearTime) {
@@ -991,6 +993,8 @@ void CryOmni3DEngine_Versailles::displayCredits() {
uint endScreenTime = g_system->getMillis() + 6000;
while (g_system->getMillis() < endScreenTime && !skipScreen) {
g_system->updateScreen();
+ g_system->delayMillis(10);
+
if (pollEvents()) {
if (getCurrentMouseButton() == 1) {
skipScreen = true;
diff --git a/engines/cryomni3d/versailles/music.cpp b/engines/cryomni3d/versailles/music.cpp
index 2fa60beadb..22d1dd8a59 100644
--- a/engines/cryomni3d/versailles/music.cpp
+++ b/engines/cryomni3d/versailles/music.cpp
@@ -26,6 +26,7 @@
#include "common/config-manager.h"
#include "common/error.h"
#include "common/file.h"
+#include "common/system.h"
#include "cryomni3d/versailles/engine.h"
@@ -110,13 +111,13 @@ void CryOmni3DEngine_Versailles::musicStop() {
int realVolume = (musicVol * channelVol) / Audio::Mixer::kMaxChannelVolume;
bool skip = false;
while (realVolume > 0 && !skip) {
- // pollEvents waits for 10ms
realVolume -= 2;
channelVol = CLIP((realVolume * Audio::Mixer::kMaxChannelVolume) / musicVol, 0, 255);
_mixer->setChannelVolume(_musicHandle, channelVol);
if (pollEvents() && checkKeysPressed(1, Common::KEYCODE_SPACE)) {
skip = true;
}
+ g_system->delayMillis(10);
}
}
_mixer->stopHandle(_musicHandle);
diff --git a/engines/cryomni3d/versailles/toolbar.cpp b/engines/cryomni3d/versailles/toolbar.cpp
index f6884bd035..23b94b8c81 100644
--- a/engines/cryomni3d/versailles/toolbar.cpp
+++ b/engines/cryomni3d/versailles/toolbar.cpp
@@ -423,7 +423,10 @@ bool Toolbar::displayToolbar(const Graphics::Surface *original) {
g_system->copyRectToScreen(_destSurface.getPixels(), _destSurface.pitch, 0,
original->h - _destSurface.h, _destSurface.w, _destSurface.h);
g_system->updateScreen();
- // pollEvents will slow down the animation because it waits 10ms
+
+ // Slow down animation
+ g_system->delayMillis(10);
+
_engine->pollEvents();
if (g_engine->shouldQuit()) {
return false;
@@ -449,7 +452,10 @@ bool Toolbar::displayToolbar(const Graphics::Surface *original) {
g_system->copyRectToScreen(_destSurface.getPixels(), _destSurface.pitch, 0,
original->h - _destSurface.h, _destSurface.w, _destSurface.h);
g_system->updateScreen();
- // pollEvents will slow down the animation because it waits 10ms
+
+ // Slow down animation
+ g_system->delayMillis(10);
+
_engine->pollEvents();
if (g_engine->shouldQuit()) {
return false;
@@ -584,6 +590,7 @@ void Toolbar::handleToolbarEvents(const Graphics::Surface *original) {
}
g_system->updateScreen();
+ g_system->delayMillis(10);
}
// Hide description when finished and selected object