diff options
author | Dmitry Iskrich | 2016-05-27 22:10:43 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 8cd7deb4763ab662c3844722e7360aea18513219 (patch) | |
tree | 0c08367e8fd93a8d17a91e84b3777fe0067e5a5e | |
parent | ce2889bbf41ec56984019626657f025c1003a66a (diff) | |
download | scummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.tar.gz scummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.tar.bz2 scummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.zip |
DIRECTOR: Add support for tempo channel
-rw-r--r-- | engines/director/score.cpp | 48 | ||||
-rw-r--r-- | engines/director/score.h | 7 |
2 files changed, 41 insertions, 14 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 6dfd16b592..aef9c86e78 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -68,7 +68,7 @@ void Score::loadConfig(Common::SeekableReadStream &stream) { _castArrayStart = stream.readUint16BE(); _castArrayEnd = stream.readUint16BE(); - _initialFrameRate = stream.readByte(); + _currentFrameRate = stream.readByte(); stream.skip(9); /*uint16 stageColor = */ stream.readUint16BE(); } @@ -193,21 +193,43 @@ Common::Rect Score::readRect(Common::SeekableReadStream &stream) { void Score::play() { initGraphics(800, 800, true); - uint32 frameId = 0; - bool stop = false; - - while (frameId != _frames.size() && !stop) { - Common::Event event; + _currentFrame = 1; + _stopPlay = false; + _nextFrameTime = g_system->getMillis() + (float)_currentFrameRate / 60 * 1000; + while (!_stopPlay) { + display(); + processEvents(); + g_system->delayMillis(10); + } +} - while (g_system->getEventManager()->pollEvent(event)) { - if (event.type == Common::EVENT_QUIT) - stop = true; +void Score::display() { + if (g_system->getMillis() < _nextFrameTime) + return; + + _frames[_currentFrame]->display(); + g_system->updateScreen(); + _currentFrame++; + byte tempo = _frames[_currentFrame]->_tempo; + if (tempo) { + if (tempo > 161) { + //Delay + _nextFrameTime = g_system->getMillis() + (256 - tempo) * 1000; + } else { + //FPS + _nextFrameTime = g_system->getMillis() + (float)tempo / 60 * 1000; + _currentFrameRate = tempo; } - _frames[frameId]->display(); - frameId++; - g_system->updateScreen(); - g_system->delayMillis(50); + } + _nextFrameTime = g_system->getMillis() + (float)_currentFrameRate / 60 * 1000; +} + +void Score::processEvents() { + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { + if (event.type == Common::EVENT_QUIT) + _stopPlay = true; } } diff --git a/engines/director/score.h b/engines/director/score.h index 7696089546..9e729c2570 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -167,6 +167,8 @@ private: ButtonCast *getButtonCast(Common::SeekableReadStream &stream); ShapeCast *getShapeCast(Common::SeekableReadStream &stream); Common::Rect readRect(Common::SeekableReadStream &stream); + void processEvents(); + void display(); public: Common::Array<Frame *> _frames; @@ -175,8 +177,11 @@ public: private: uint16 _versionMinor; uint16 _versionMajor; - byte _initialFrameRate; + byte _currentFrameRate; uint16 _castArrayStart; + uint16 _currentFrame; + uint32 _nextFrameTime; + bool _stopPlay; uint16 _castArrayEnd; Common::Rect _movieRect; }; |