aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/support
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-20 07:38:13 -0400
committerPaul Gilbert2016-07-20 07:38:13 -0400
commitd5bf17e73ff9533d2f54588622048ab755f4151b (patch)
treefebbe55f9d000d7822487e797472b73d60c53df2 /engines/titanic/support
parent53c7517dfbae96fe99b7a8e7a32298526e46baa1 (diff)
downloadscummvm-rg350-d5bf17e73ff9533d2f54588622048ab755f4151b.tar.gz
scummvm-rg350-d5bf17e73ff9533d2f54588622048ab755f4151b.tar.bz2
scummvm-rg350-d5bf17e73ff9533d2f54588622048ab755f4151b.zip
TITANIC: Add movie _handled flag, simplify frame timinig code
Diffstat (limited to 'engines/titanic/support')
-rw-r--r--engines/titanic/support/avi_surface.cpp7
-rw-r--r--engines/titanic/support/avi_surface.h5
-rw-r--r--engines/titanic/support/movie.cpp30
-rw-r--r--engines/titanic/support/movie.h9
4 files changed, 17 insertions, 34 deletions
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 7779baf2ff..38bccafa89 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -260,10 +260,13 @@ int AVISurface::getFrame() const {
return _decoders[0]->getCurFrame();
}
+bool AVISurface::isFrameReady() const {
+ return _decoders[0]->needsUpdate() && (!_decoders[1] || _decoders[1]->needsUpdate());
+}
+
bool AVISurface::renderFrame() {
// Check there's a frame ready for display
- assert(_videoSurface);
- if (!_decoders[0]->needsUpdate() || (_decoders[1] && !_decoders[1]->needsUpdate()))
+ if (!isFrameReady())
return false;
// Decode each decoder's video stream into the appropriate surface
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index 32db925d7a..dfd4c59267 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -162,6 +162,11 @@ public:
* Duplicates the secondary frame, if the movie has a second video track
*/
Graphics::ManagedSurface *duplicateSecondaryFrame() const;
+
+ /**
+ * Returns true if a frame is ready to be rendered
+ */
+ bool isFrameReady() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index b98a5b57a1..2943ee1a84 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -36,7 +36,7 @@ namespace Titanic {
CMovieList *CMovie::_playingMovies;
CVideoSurface *CMovie::_movieSurface;
-CMovie::CMovie() : ListItem(), _state(MSTATE_0), _field10(0),
+CMovie::CMovie() : ListItem(), _handled(false), _field10(0),
_field14(0) {
}
@@ -84,9 +84,6 @@ OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) :
_field24 = 0;
_field28 = 0;
_field2C = 0;
- _ticksStart = 0;
- _frameTime1 = 0;
- _frameTime2 = 17066;
surface->resize(_aviSurface.getWidth(), _aviSurface.getHeight());
_aviSurface.setVideoSurface(surface);
@@ -165,25 +162,13 @@ void OSMovie::setFrame(uint frameNumber) {
bool OSMovie::handleEvents(CMovieEventList &events) {
if (!_aviSurface._isPlaying)
return false;
-
- int time = (g_vm->_events->getTicksCount() + ((_ticksStart << 24) - _ticksStart)) << 8;
- if (time < _frameTime1)
+ if (!_aviSurface.isFrameReady())
return _aviSurface._isPlaying;
- if (!_field14 && (time - _frameTime1) > (_frameTime2 * 2))
- _frameTime1 = time;
-
- _frameTime1 += _frameTime2;
- _aviSurface.handleEvents(events);
- _videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface());
-
- if (_field14) {
- while (_frameTime1 >= time && events.empty()) {
- _aviSurface.handleEvents(events);
- _videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface());
-
- _frameTime1 += _frameTime2;
- }
+ // Handle updating the frame
+ while (_aviSurface.isFrameReady()) {
+ _aviSurface.handleEvents(events);
+ _videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface());
}
return _aviSurface._isPlaying;
@@ -202,9 +187,6 @@ int OSMovie::getFrame() const {
}
void OSMovie::movieStarted() {
- _frameTime1 = _frameTime2 = 256000.0 / _aviSurface._frameRate;
- _ticksStart = g_vm->_events->getTicksCount();
-
if (_aviSurface._hasAudio)
_aviSurface._soundManager->movieStarted();
diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h
index b6c2a09667..feb320f0b2 100644
--- a/engines/titanic/support/movie.h
+++ b/engines/titanic/support/movie.h
@@ -32,10 +32,6 @@
namespace Titanic {
-enum MovieState {
- MSTATE_0 = 0, MSTATE_1 = 1
-};
-
class CGameObject;
class CMovie;
class CSoundManager;
@@ -52,7 +48,7 @@ protected:
*/
void addToPlayingMovies();
public:
- MovieState _state;
+ bool _handled;
int _field10;
int _field14;
public:
@@ -158,9 +154,6 @@ private:
int _field24;
int _field28;
int _field2C;
- int _ticksStart;
- int _frameTime1;
- int _frameTime2;
private:
/**
* Called when a movie is started playing