diff options
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/movie.cpp | 59 | ||||
-rw-r--r-- | engines/titanic/support/movie.h | 25 | ||||
-rw-r--r-- | engines/titanic/support/video_surface.h | 1 |
3 files changed, 74 insertions, 11 deletions
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp index 846dc09d5c..4fccc571ee 100644 --- a/engines/titanic/support/movie.cpp +++ b/engines/titanic/support/movie.cpp @@ -27,11 +27,11 @@ namespace Titanic { -CMovie::CMovie() : ListItem(), _state(0), _field10(0) { +CMovie::CMovie() : ListItem(), _state(MOVIE_STOPPED), _field10(0) { } bool CMovie::isActive() const { - return g_vm->_movieList.contains(this); + return g_vm->_activeMovies.contains(this); } bool CMovie::get10() { @@ -52,6 +52,7 @@ OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) : _videoSurfa } OSMovie::~OSMovie() { + g_vm->_activeMovies.remove(this); delete _video; } @@ -61,6 +62,10 @@ void OSMovie::proc8(int v1, CVideoSurface *surface) { void OSMovie::proc9(int v1, int v2, int v3, bool v4) { warning("TODO: OSMovie::proc9"); + //setFrame(v1); ? + _video->start(); + g_vm->_activeMovies.push_back(this); + _state = MOVIE_NONE; } void OSMovie::proc10() { @@ -85,11 +90,7 @@ void OSMovie::proc14() { void OSMovie::setFrame(uint frameNumber) { _video->seekToFrame(frameNumber); - const Graphics::Surface *s = _video->decodeNextFrame(); - Graphics::Surface *surf = s->convertTo(g_system->getScreenFormat()); - - _videoSurface->blitFrom(Common::Point(0, 0), surf); - delete surf; + decodeFrame(); } void OSMovie::proc16() { @@ -118,4 +119,48 @@ void *OSMovie::proc21() { return nullptr; } +MovieState OSMovie::getState() { + if (!_video) + _state = MOVIE_STOPPED; + return _state; +} + +void OSMovie::update() { + if (_state != MOVIE_STOPPED) { + if (_video->isPlaying()) { + if (_video->needsUpdate()) { + decodeFrame(); + _state = MOVIE_FRAME; + } else { + _state = MOVIE_NONE; + } + } else { + _state = MOVIE_STOPPED; + } + } +} + +void OSMovie::decodeFrame() { + const Graphics::Surface *frame = _video->decodeNextFrame(); + OSVideoSurface *videoSurface = static_cast<OSVideoSurface *>(_videoSurface); + assert(videoSurface); + + videoSurface->lock(); + assert(videoSurface->_rawSurface); + + if (frame->format == videoSurface->_rawSurface->format) { + // Matching format, so we can copy straight from the video frame + videoSurface->_rawSurface->blitFrom(*frame); + } else { + // Different formats so we have to convert it first + Graphics::Surface *s = frame->convertTo(videoSurface->_rawSurface->format); + videoSurface->_rawSurface->blitFrom(*s); + + s->free(); + delete s; + } + + videoSurface->unlock(); +} + } // End of namespace Titanic diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h index b5ae70de13..dfb0ca108a 100644 --- a/engines/titanic/support/movie.h +++ b/engines/titanic/support/movie.h @@ -29,11 +29,20 @@ namespace Titanic { +enum MovieState { + MOVIE_STOPPED = -1, MOVIE_NONE = 0, MOVIE_FINISHED = 1, MOVIE_FRAME = 2 +}; + class CVideoSurface; +class CMovie; + +class CMovieList : public List<CMovie> { +public: +}; class CMovie : public ListItem { protected: - int _state; + MovieState _state; int _field10; public: CMovie(); @@ -57,12 +66,20 @@ public: bool isActive() const; bool get10(); + + virtual MovieState getState() = 0; + virtual void update() = 0; }; class OSMovie : public CMovie { private: Video::VideoDecoder *_video; CVideoSurface *_videoSurface; + + /** + * Decodes the next frame + */ + void decodeFrame(); public: OSMovie(const CResourceKey &name, CVideoSurface *surface); virtual ~OSMovie(); @@ -86,10 +103,10 @@ public: virtual int proc19(); virtual void proc20(); virtual void *proc21(); -}; -class CGlobalMovies : public List<CMovie> { -public: + + virtual MovieState getState(); + virtual void update(); }; } // End of namespace Titanic diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h index 767306cae6..d39dea627b 100644 --- a/engines/titanic/support/video_surface.h +++ b/engines/titanic/support/video_surface.h @@ -208,6 +208,7 @@ public: }; class OSVideoSurface : public CVideoSurface { + friend class OSMovie; private: static byte _map[0x400]; |