diff options
-rw-r--r-- | engines/titanic/support/avi_surface.cpp | 34 | ||||
-rw-r--r-- | engines/titanic/support/avi_surface.h | 5 | ||||
-rw-r--r-- | engines/titanic/support/movie.cpp | 18 |
3 files changed, 38 insertions, 19 deletions
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index c37bd83616..e43127ccb9 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -20,12 +20,13 @@ * */ -#include "titanic/support/avi_surface.h" -#include "titanic/support/screen_manager.h" -#include "titanic/support/video_surface.h" #include "common/system.h" #include "graphics/pixelformat.h" #include "video/avi_decoder.h" +#include "titanic/support/avi_surface.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/video_surface.h" +#include "titanic/titanic.h" namespace Titanic { @@ -358,4 +359,31 @@ Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const { } } +void AVISurface::playCutscene(const Rect &r, uint startFrame, uint endFrame) { + bool isDifferent = _movieFrameSurface[0]->w != r.width() || + _movieFrameSurface[0]->h != r.height(); + + startAtFrame(startFrame); + while (getFrame() <= (int)endFrame) { + if (isNextFrame()) { + renderFrame(); + _currentFrame = _decoders[0]->getCurFrame(); + + if (isDifferent) { + // Clear the destination area, and use the transBlitFrom method, + // which supports arbitrary scaling, to reduce to the desired size + g_vm->_screen->fillRect(r, 0); + g_vm->_screen->transBlitFrom(*_movieFrameSurface[0], + Common::Rect(0, 0, _movieFrameSurface[0]->w, _movieFrameSurface[0]->h), r); + } else { + g_vm->_screen->blitFrom(*_movieFrameSurface[0], Common::Point(r.left, r.top)); + } + } + + // Brief wait, and check at the same time for clicks to abort the clip + if (g_vm->_events->waitForPress(10)) + break; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h index d21182bca9..54b0155bdd 100644 --- a/engines/titanic/support/avi_surface.h +++ b/engines/titanic/support/avi_surface.h @@ -176,6 +176,11 @@ public: * Returns true if it's time for the next */ bool isNextFrame() const; + + /** + * Plays an interruptable cutscene + */ + void playCutscene(const Rect &r, uint startFrame, uint endFrame); }; } // End of namespace Titanic diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp index 50a55c8218..cfdcecbf42 100644 --- a/engines/titanic/support/movie.cpp +++ b/engines/titanic/support/movie.cpp @@ -133,22 +133,8 @@ void OSMovie::playCutscene(const Rect &drawRect, uint startFrame, uint endFrame) drawRect.top + (heightLess ? CLIP_HEIGHT_REDUCED : CLIP_HEIGHT) ); - uint timePerFrame = (uint)(1000.0 / _aviSurface._frameRate); - - for (; startFrame < endFrame; ++startFrame) { - // Set the frame - _aviSurface.setFrame(startFrame); - - // TODO: See if we need to do anything further here. The original had a bunch - // of calls and using of the _movieSurface; perhaps to allow scaling down - // videos to half-size - if (widthLess || heightLess) - warning("Not properly reducing clip size: %d %d", r.width(), r.height()); - - // Wait for the next frame, unless the user interrupts the clip - if (g_vm->_events->waitForPress(timePerFrame)) - break; - } + _aviSurface.setFrame(startFrame); + _aviSurface.playCutscene(r, startFrame, endFrame); } void OSMovie::stop() { |