From 4ade45cb11f5929bc951d02d8077c499880c76a6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 27 May 2019 21:14:08 +0300 Subject: STARTREK: Improve game responsiveness - Add a delay after screen updates - Do not update the screen when drawing the background - this is unnecessary - Fix memory leak when drawing the background --- engines/startrek/events.cpp | 1 + engines/startrek/graphics.cpp | 7 ++++++- engines/startrek/intro.cpp | 1 + engines/startrek/menu.cpp | 3 +++ engines/startrek/startrek.cpp | 3 ++- 5 files changed, 13 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/startrek/events.cpp b/engines/startrek/events.cpp index 8e7d2c1884..d8935bd432 100644 --- a/engines/startrek/events.cpp +++ b/engines/startrek/events.cpp @@ -43,6 +43,7 @@ void StarTrekEngine::pollEvents(bool queueEvents) { // WORKAROUND: this improves the responsiveness of the mouse. _system->updateScreen(); + _system->delayMillis(10); break; case Common::EVENT_LBUTTONDOWN: diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index f92ef77594..5c6a1441b6 100644 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -131,6 +131,7 @@ void Graphics::clearScreenAndPriBuffer() { surface->fillRect(_screenRect, 0); _vm->_system->unlockScreen(); _vm->_system->updateScreen(); + _vm->_system->delayMillis(10); } void Graphics::loadPalette(const Common::String &paletteName) { @@ -200,6 +201,7 @@ void Graphics::setPaletteFadeLevel(byte *palData, int fadeLevel) { // FIXME: this isn't supposed to flush changes to graphics, only palettes. // Might not matter... _vm->_system->updateScreen(); + _vm->_system->delayMillis(10); } void Graphics::incPaletteFadeLevel() { @@ -636,6 +638,7 @@ void Graphics::updateScreen() { } _vm->_system->updateScreen(); + _vm->_system->delayMillis(10); } Sprite *Graphics::getSpriteAt(int16 x, int16 y) { @@ -759,8 +762,10 @@ void Graphics::drawBackgroundImage(const char *filename) { _vm->_system->getPaletteManager()->setPalette(palette, 0, 256); _vm->_system->copyRectToScreen(pixels, width, xoffset, yoffset, width, height); - _vm->_system->updateScreen(); + //_vm->_system->updateScreen(); + //_vm->_system->delayMillis(10); + delete[] pixels; delete[] palette; } diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp index 745b8fefc3..84a8208c34 100644 --- a/engines/startrek/intro.cpp +++ b/engines/startrek/intro.cpp @@ -50,6 +50,7 @@ void StarTrekEngine::playIntro() { _sound->playVoc("logo"); _gfx->copyBackgroundScreen(); _system->updateScreen(); + _system->delayMillis(10); _gfx->fadeinScreen(); uint32 clockTicks = _clockTicks; diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp index 72b72d94b5..fdbbf1911d 100644 --- a/engines/startrek/menu.cpp +++ b/engines/startrek/menu.cpp @@ -1027,6 +1027,7 @@ void StarTrekEngine::showRepublicMap(int16 arg0, int16 turbolift) { _gfx->setBackgroundImage(_gfx->loadBitmap("veng9b")); _gfx->copyBackgroundScreen(); _system->updateScreen(); + _system->delayMillis(10); _gfx->setPri(15); _gfx->fadeinScreen(); @@ -1077,6 +1078,7 @@ void StarTrekEngine::showRepublicMap(int16 arg0, int16 turbolift) { _gfx->setBackgroundImage(_gfx->loadBitmap("veng9")); _gfx->copyBackgroundScreen(); _system->updateScreen(); + _system->delayMillis(10); _gfx->setPri(15); Sprite someSprite; @@ -1162,6 +1164,7 @@ lclick: _gfx->setBackgroundImage(_gfx->loadBitmap(_screenName)); _gfx->copyBackgroundScreen(); _system->updateScreen(); + _system->delayMillis(10); _gfx->drawAllSprites(); diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index d347055efb..85129117ae 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -262,6 +262,7 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) { _gfx->loadPalette("palette"); _gfx->drawDirectToScreen(bgImage); _system->updateScreen(); + _system->delayMillis(10); for (int i = 0; i < (_awayMission.redshirtDead ? 3 : 4); i++) { Common::String filename = getCrewmanAnimFilename(i, name); @@ -604,7 +605,7 @@ void StarTrekEngine::playMovieMac(Common::String filename) { if (event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) continuePlaying = false; - g_system->delayMillis(10); + _system->delayMillis(10); } delete qtDecoder; -- cgit v1.2.3