diff options
author | Evgeny Grechnikov | 2018-10-16 01:03:55 +0300 |
---|---|---|
committer | Evgeny Grechnikov | 2018-10-16 01:03:55 +0300 |
commit | 43fb9ebb1b188578e272885a318bc57abed42de9 (patch) | |
tree | ce134a852ac2fe2440bb5136c9a66d58552f3642 /engines/lastexpress/lastexpress.cpp | |
parent | 8162309212bbc287632fc375d1740a64733019fb (diff) | |
download | scummvm-rg350-43fb9ebb1b188578e272885a318bc57abed42de9.tar.gz scummvm-rg350-43fb9ebb1b188578e272885a318bc57abed42de9.tar.bz2 scummvm-rg350-43fb9ebb1b188578e272885a318bc57abed42de9.zip |
LASTEXPRESS: drop sound thread
The backend runs its own sound thread anyway,
with the corresponding bookkeeping that we use.
We don't need yet another sound thread,
and it is always nice to not have something
that could change our structures from underneath us.
Diffstat (limited to 'engines/lastexpress/lastexpress.cpp')
-rw-r--r-- | engines/lastexpress/lastexpress.cpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/engines/lastexpress/lastexpress.cpp b/engines/lastexpress/lastexpress.cpp index 91f8a6a346..688d084614 100644 --- a/engines/lastexpress/lastexpress.cpp +++ b/engines/lastexpress/lastexpress.cpp @@ -42,7 +42,6 @@ #include "common/debug-channels.h" #include "common/error.h" #include "common/fs.h" -#include "common/timer.h" #include "engines/util.h" @@ -57,7 +56,7 @@ LastExpressEngine::LastExpressEngine(OSystem *syst, const ADGameDescription *gd) Engine(syst), _gameDescription(gd), _debugger(NULL), _random("lastexpress"), _cursor(NULL), _font(NULL), _logic(NULL), _menu(NULL), - _frameCounter(0), _lastFrameCount(0), + _lastFrameCount(0), _graphicsMan(NULL), _resMan(NULL), _sceneMan(NULL), _soundMan(NULL), _eventMouse(NULL), _eventTick(NULL), @@ -84,8 +83,6 @@ LastExpressEngine::LastExpressEngine(OSystem *syst, const ADGameDescription *gd) } LastExpressEngine::~LastExpressEngine() { - _timer->removeTimerProc(&soundTimer); - // Delete the remaining objects SAFE_DELETE(_cursor); SAFE_DELETE(_font); @@ -144,9 +141,8 @@ Common::Error LastExpressEngine::run() { // Game logic _logic = new Logic(this); - // Start sound manager and setup timer + // Sound manager _soundMan = new SoundManager(this); - _timer->installTimerProc(&soundTimer, 17000, this, "lastexpressSound"); // Menu _menu = new Menu(this); @@ -163,6 +159,11 @@ Common::Error LastExpressEngine::run() { return Common::kNoError; } +uint32 LastExpressEngine::getFrameCounter() const { + // the original game has a timer running at 60Hz incrementing a dedicated variable + return (uint64)_system->getMillis() * 60 / 1000; +} + void LastExpressEngine::pollEvents() { Common::Event ev; if (!_eventMan->pollEvent(ev)) @@ -222,10 +223,13 @@ bool LastExpressEngine::handleEvents() { getGameLogic()->getGameState()->getGameFlags()->mouseLeftClick = true; getGameLogic()->getGameState()->getGameFlags()->mouseLeftPressed = (ev.type == Common::EVENT_LBUTTONDOWN) ? true : false; - // Adjust frameInterval flag - if (_frameCounter < _lastFrameCount + 30) - getGameLogic()->getGameState()->getGameFlags()->frameInterval = true; - _lastFrameCount = _frameCounter; + { + // Adjust frameInterval flag + uint32 frameCounter = getFrameCounter(); + if (frameCounter < _lastFrameCount + 30) + getGameLogic()->getGameState()->getGameFlags()->frameInterval = true; + _lastFrameCount = frameCounter; + } if (_eventMouse && _eventMouse->isValid()) (*_eventMouse)(ev); @@ -273,21 +277,6 @@ bool LastExpressEngine::handleEvents() { } /////////////////////////////////////////////////////////////////////////////////// -/// Timer -/////////////////////////////////////////////////////////////////////////////////// -void LastExpressEngine::soundTimer(void *refCon) { - ((LastExpressEngine *)refCon)->handleSoundTimer(); -} - -void LastExpressEngine::handleSoundTimer() { - if (_frameCounter & 1) - if (_soundMan) - _soundMan->getQueue()->handleTimer(); - - _frameCounter++; -} - -/////////////////////////////////////////////////////////////////////////////////// /// Event Handling /////////////////////////////////////////////////////////////////////////////////// void LastExpressEngine::backupEventHandlers() { |