diff options
-rw-r--r-- | engines/titanic/game_manager.cpp | 13 | ||||
-rw-r--r-- | engines/titanic/game_manager.h | 2 | ||||
-rw-r--r-- | engines/titanic/game_state.cpp | 2 | ||||
-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 | ||||
-rw-r--r-- | engines/titanic/titanic.h | 2 |
7 files changed, 87 insertions, 17 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index b6eac3eb82..3e15bb0e2c 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -149,7 +149,7 @@ void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *new } void CGameManager::update() { - handleMovies(); + updateMovies(); frameMessage(getRoom()); _list.update(g_vm->_events->getTicksCount()); _trueTalkManager.update1(); @@ -191,8 +191,15 @@ void CGameManager::update() { } } -void CGameManager::handleMovies() { - warning("TODO: CGameManager::handleMovies"); +void CGameManager::updateMovies() { + // TODO: Make this more like the original, if I can figuring out + // what's it doing with temporary lists and the OSMovie methods + for (CMovieList::iterator i = g_vm->_activeMovies.begin(); + i != g_vm->_activeMovies.end(); ++i) { + + } + + } void CGameManager::updateDiskTicksCount() { diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h index b8f5d02463..5004c777fe 100644 --- a/engines/titanic/game_manager.h +++ b/engines/titanic/game_manager.h @@ -103,7 +103,7 @@ private: /** * Handles any ongoing movie playback */ - void handleMovies(); + void updateMovies(); public: CProjectItem *_project; CGameView *_gameView; diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index 92a0e3dea6..fab7d1165b 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -32,7 +32,7 @@ bool CGameStateMovieList::clear() { CMovieListItem *listItem = *i; ++i; - if (!g_vm->_movieList.contains(listItem->_item)) { + if (!g_vm->_activeMovies.contains(listItem->_item)) { remove(listItem); delete listItem; } 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]; diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h index a5549e463b..e83d7d9bdc 100644 --- a/engines/titanic/titanic.h +++ b/engines/titanic/titanic.h @@ -110,7 +110,7 @@ public: OSScreenManager *_screenManager; CMainGameWindow *_window; Common::RandomSource _randomSource; - CGlobalMovies _movieList; + CMovieList _activeMovies; CString _itemNames[TOTAL_ITEMS]; CString _itemDescriptions[TOTAL_ITEMS]; CString _itemObjects[TOTAL_ITEMS]; |