aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/myst_areas.cpp5
-rw-r--r--engines/mohawk/myst_stacks/dni.cpp15
-rw-r--r--engines/mohawk/myst_stacks/intro.cpp19
-rw-r--r--engines/mohawk/video.cpp50
-rw-r--r--engines/mohawk/video.h6
5 files changed, 57 insertions, 38 deletions
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 311d553d04..9cbf79ddaf 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -219,9 +219,8 @@ void MystResourceType6::handleCardChange() {
bool MystResourceType6::isPlaying() {
if (_videoRunning) {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle != NULL_VID_HANDLE)
- return !_vm->_video->endOfVideo(handle);
+ VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+ return handle != NULL_VID_HANDLE && !_vm->_video->endOfVideo(handle);
}
return false;
diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp
index 417fa90aa3..eb5d2a63c6 100644
--- a/engines/mohawk/myst_stacks/dni.cpp
+++ b/engines/mohawk/myst_stacks/dni.cpp
@@ -107,14 +107,13 @@ void MystScriptParser_Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16
void MystScriptParser_Dni::atrus_run() {
if (_globals.ending == 2) {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle)) {
+ if (!_vm->_video->isVideoPlaying()) {
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrus2", kDniStack), 215, 77);
_globals.ending = 4;
_globals.bluePagesInBook = 63;
_globals.redPagesInBook = 63;
}
- // TODO: Complete / fix
+ // TODO: Complete/fix
} else if (_globals.ending == 1) {
// TODO: Complete, loop atr1page end
} else if (_globals.ending != 3 && _globals.ending != 4) {
@@ -122,17 +121,15 @@ void MystScriptParser_Dni::atrus_run() {
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1page", kDniStack), 215, 77);
_globals.ending = 1;
- // TODO: Complete, movie control / looping
+ // TODO: Complete, movie control/looping
} else {
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1nopg", kDniStack), 215, 77);
_globals.ending = 3;
- // TODO: Complete, movie control / looping
+ // TODO: Complete, movie control/looping
}
- } else {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
- _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true);
+ } else if (!_vm->_video->isVideoPlaying()) {
+ _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true);
}
}
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index 139a4c6b38..505b311761 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -107,16 +107,14 @@ void MystScriptParser_Intro::introMovies_run() {
} else
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("broder", kIntroStack));
} else if (_introStep == 1) {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+ if (!_vm->_video->isVideoPlaying())
_introStep = 2;
} else if (_introStep == 2) {
_introStep = 3;
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack));
} else if (_introStep == 3) {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+ if (!_vm->_video->isVideoPlaying())
_introStep = 4;
} else if (_introStep == 4) {
_introStep = 5;
@@ -129,15 +127,13 @@ void MystScriptParser_Intro::introMovies_run() {
_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("intro", kIntroStack));
}
} else if (_introStep == 5) {
- VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
- if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+ if (!_vm->_video->isVideoPlaying())
_introStep = 6;
} else {
- if (_vm->getFeatures() & GF_DEMO) {
+ if (_vm->getFeatures() & GF_DEMO)
_vm->changeToCard(2001, true);
- } else {
+ else
_vm->changeToCard(2, true);
- }
}
}
@@ -155,9 +151,8 @@ void MystScriptParser_Intro::mystLinkBook_run() {
_vm->_gfx->copyImageToBackBuffer(4, Common::Rect(544, 333));
_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
}
- } else {
- if (!_linkBookMovie->isPlaying())
- _vm->changeToCard(5, true);
+ } else if (!_linkBookMovie->isPlaying()) {
+ _vm->changeToCard(5, true);
}
}
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 6e076315c1..31fd3d08d7 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -124,14 +124,14 @@ void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
delete _videoStreams[videoHandle].video;
_videoStreams[videoHandle].video = 0;
- _videoStreams[videoHandle].id = 0xffff;
+ _videoStreams[videoHandle].id = 0;
_videoStreams[videoHandle].filename.clear();
}
-void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x, int16 y, bool loop) {
+VideoHandle VideoManager::playBackgroundMovie(const Common::String &filename, int16 x, int16 y, bool loop) {
VideoHandle videoHandle = createVideoHandle(filename, x, y, loop);
if (videoHandle == NULL_VID_HANDLE)
- return;
+ return NULL_VID_HANDLE;
// Center x if requested
if (x < 0)
@@ -140,12 +140,14 @@ void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x,
// Center y if requested
if (y < 0)
_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+
+ return videoHandle;
}
-void VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
+VideoHandle VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
VideoHandle videoHandle = createVideoHandle(id, x, y, loop);
if (videoHandle == NULL_VID_HANDLE)
- return;
+ return NULL_VID_HANDLE;
// Center x if requested
if (x < 0)
@@ -154,6 +156,8 @@ void VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
// Center y if requested
if (y < 0)
_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+
+ return videoHandle;
}
bool VideoManager::updateBackgroundMovies() {
@@ -171,7 +175,7 @@ bool VideoManager::updateBackgroundMovies() {
} else {
delete _videoStreams[i].video;
_videoStreams[i].video = 0;
- _videoStreams[i].id = 0xffff;
+ _videoStreams[i].id = 0;
_videoStreams[i].filename.clear();
continue;
}
@@ -304,7 +308,7 @@ void VideoManager::stopMovie(uint16 id) {
if (_mlstRecords[i].movieID == _videoStreams[j].id) {
delete _videoStreams[j].video;
_videoStreams[j].video = 0;
- _videoStreams[j].id = 0xffff;
+ _videoStreams[j].id = 0;
_videoStreams[j].filename.clear();
return;
}
@@ -380,7 +384,7 @@ VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint
entry.x = x;
entry.y = y;
entry.filename = filename;
- entry.id = 0xffff;
+ entry.id = 0;
entry.loop = loop;
entry.enabled = true;
@@ -407,7 +411,7 @@ VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint
VideoHandle VideoManager::findVideoHandleRiven(uint16 id) {
for (uint16 i = 0; i < _mlstRecords.size(); i++)
if (_mlstRecords[i].code == id)
- for (uint16 j = 0; j < _videoStreams.size(); j++)
+ for (uint32 j = 0; j < _videoStreams.size(); j++)
if (_videoStreams[j].video && _mlstRecords[i].movieID == _videoStreams[j].id)
return j;
@@ -415,9 +419,23 @@ VideoHandle VideoManager::findVideoHandleRiven(uint16 id) {
}
VideoHandle VideoManager::findVideoHandle(uint16 id) {
- for (uint16 j = 0; j < _videoStreams.size(); j++)
- if (_videoStreams[j].video && _videoStreams[j].id == id)
- return j;
+ if (!id)
+ return NULL_VID_HANDLE;
+
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && _videoStreams[i].id == id)
+ return i;
+
+ return NULL_VID_HANDLE;
+}
+
+VideoHandle VideoManager::findVideoHandle(const Common::String &filename) {
+ if (filename.empty())
+ return NULL_VID_HANDLE;
+
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && _videoStreams[i].filename.equalsIgnoreCase(filename))
+ return i;
return NULL_VID_HANDLE;
}
@@ -442,4 +460,12 @@ bool VideoManager::endOfVideo(const VideoHandle &handle) {
return _videoStreams[handle]->endOfVideo();
}
+bool VideoManager::isVideoPlaying() {
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && !_videoStreams[i]->endOfVideo())
+ return true;
+
+ return false;
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index d144ac66c2..f1ff690754 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -75,12 +75,13 @@ public:
// Generic movie functions
void playMovie(const Common::String &filename, uint16 x = 0, uint16 y = 0, bool clearScreen = false);
void playMovieCentered(const Common::String &filename, bool clearScreen = true);
- void playBackgroundMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false);
- void playBackgroundMovie(uint16 id, int16 x = -1, int16 y = -1, bool loop = false);
+ VideoHandle playBackgroundMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false);
+ VideoHandle playBackgroundMovie(uint16 id, int16 x = -1, int16 y = -1, bool loop = false);
bool updateBackgroundMovies();
void pauseVideos();
void resumeVideos();
void stopVideos();
+ bool isVideoPlaying();
// Riven-related functions
void activateMLST(uint16 mlstId, uint16 card);
@@ -95,6 +96,7 @@ public:
// Handle functions
VideoHandle findVideoHandle(uint16 id);
+ VideoHandle findVideoHandle(const Common::String &filename);
int32 getCurFrame(const VideoHandle &handle);
uint32 getFrameCount(const VideoHandle &handle);
uint32 getElapsedTime(const VideoHandle &handle);