aboutsummaryrefslogtreecommitdiff
path: root/engines/director/score.cpp
diff options
context:
space:
mode:
authorDmitry Iskrich2016-05-27 22:10:43 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit8cd7deb4763ab662c3844722e7360aea18513219 (patch)
tree0c08367e8fd93a8d17a91e84b3777fe0067e5a5e /engines/director/score.cpp
parentce2889bbf41ec56984019626657f025c1003a66a (diff)
downloadscummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.tar.gz
scummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.tar.bz2
scummvm-rg350-8cd7deb4763ab662c3844722e7360aea18513219.zip
DIRECTOR: Add support for tempo channel
Diffstat (limited to 'engines/director/score.cpp')
-rw-r--r--engines/director/score.cpp48
1 files changed, 35 insertions, 13 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;
}
}