aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-10-30 18:20:14 -0400
committerPaul Gilbert2016-10-30 18:20:14 -0400
commit5348f4f34f8187e26906fb92900f87d4b4e9b797 (patch)
tree7526c3df10c71b74a8403135ccb8ca78ca6f130f
parent31fd315c90b78cde3fe3e3e6ee7c381d7918f340 (diff)
downloadscummvm-rg350-5348f4f34f8187e26906fb92900f87d4b4e9b797.tar.gz
scummvm-rg350-5348f4f34f8187e26906fb92900f87d4b4e9b797.tar.bz2
scummvm-rg350-5348f4f34f8187e26906fb92900f87d4b4e9b797.zip
TITANIC: Support cutscene frame counting beyond end of video
The intro credits cutscene at least, uses an end frame beyond the video as a way of adding an extra delay after the video finishes
-rw-r--r--engines/titanic/support/avi_surface.cpp22
-rw-r--r--engines/titanic/support/avi_surface.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index b4d72d43ca..525c6513dd 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -41,6 +41,7 @@ AVISurface::AVISurface(const CResourceKey &key) {
_streamCount = 0;
_movieFrameSurface[0] = _movieFrameSurface[1] = nullptr;
_framePixels = nullptr;
+ _priorFrameTime = 0;
// Reset current frame. We need to keep track of frames separately from the decoder,
// since it needs to be able to go beyond the frame count or to negative to allow
@@ -287,8 +288,20 @@ void AVISurface::setFrame(int frameNumber) {
renderFrame();
}
-bool AVISurface::isNextFrame() const {
- return _decoder->getTimeToNextFrame() == 0;
+bool AVISurface::isNextFrame() {
+ if (!_decoder->endOfVideo())
+ return _decoder->getTimeToNextFrame() == 0;
+
+ // We're at the end of the video, so we need to manually
+ // keep track of frame delays. Hardcoded at the moment for 15FPS
+ const uint FRAME_TIME = 1000 / 15;
+ uint32 currTime = g_system->getMillis();
+ if (currTime >= (_priorFrameTime + FRAME_TIME)) {
+ _priorFrameTime = currTime;
+ return true;
+ }
+
+ return false;
}
bool AVISurface::renderFrame() {
@@ -376,11 +389,12 @@ void AVISurface::playCutscene(const Rect &r, uint startFrame, uint endFrame) {
_movieFrameSurface[0]->h != r.height();
startAtFrame(startFrame);
+ _currentFrame = startFrame;
+
while (_currentFrame < (int)endFrame && !g_vm->shouldQuit()) {
if (isNextFrame()) {
renderFrame();
- _currentFrame = _decoder->endOfVideo() ? _decoder->getFrameCount() :
- _decoder->getCurFrame();
+ ++_currentFrame;
if (isDifferent) {
// Clear the destination area, and use the transBlitFrom method,
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index 8d9b92df40..2a4b321f0f 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -66,6 +66,7 @@ private:
Graphics::ManagedSurface *_framePixels;
bool _isReversed;
int _currentFrame;
+ uint32 _priorFrameTime;
private:
/**
* Render a frame to the video surface
@@ -196,7 +197,7 @@ public:
/**
* Returns true if it's time for the next
*/
- bool isNextFrame() const;
+ bool isNextFrame();
/**
* Plays an interruptable cutscene