aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/riven.cpp38
-rw-r--r--engines/mohawk/riven_external.cpp46
-rw-r--r--engines/mohawk/riven_scripts.cpp12
-rw-r--r--engines/mohawk/video.cpp22
-rw-r--r--engines/mohawk/video.h5
5 files changed, 64 insertions, 59 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index e6d8a16811..b431b971fb 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -615,18 +615,18 @@ static void sunnersTopStairsTimer(MohawkEngine_Riven *vm) {
// Play a random sunners video if the script one is not playing already
// and then set a new timer for when the new video should be played
- VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ VideoEntryPtr oldVideo = vm->_video->findVideoRiven(1);
uint32 timerTime = 500;
- if (!oldHandle || oldHandle->endOfVideo()) {
+ if (!oldVideo || oldVideo->endOfVideo()) {
uint32 &sunnerTime = vm->_vars["jsunnertime"];
if (sunnerTime == 0) {
timerTime = vm->_rnd->getRandomNumberRng(2, 15) * 1000;
} else if (sunnerTime < vm->getTotalPlayTime()) {
- VideoHandle handle = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(1, 3));
+ VideoEntryPtr video = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(1, 3));
- timerTime = handle->getDuration().msecs() + vm->_rnd->getRandomNumberRng(2, 15) * 1000;
+ timerTime = video->getDuration().msecs() + vm->_rnd->getRandomNumberRng(2, 15) * 1000;
}
sunnerTime = timerTime + vm->getTotalPlayTime();
@@ -645,10 +645,10 @@ static void sunnersMidStairsTimer(MohawkEngine_Riven *vm) {
// Play a random sunners video if the script one is not playing already
// and then set a new timer for when the new video should be played
- VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ VideoEntryPtr oldVideo = vm->_video->findVideoRiven(1);
uint32 timerTime = 500;
- if (!oldHandle || oldHandle->endOfVideo()) {
+ if (!oldVideo || oldVideo->endOfVideo()) {
uint32 &sunnerTime = vm->_vars["jsunnertime"];
if (sunnerTime == 0) {
@@ -662,9 +662,9 @@ static void sunnersMidStairsTimer(MohawkEngine_Riven *vm) {
else if (randValue == 5)
movie = 3;
- VideoHandle handle = vm->_video->playMovieRiven(movie);
+ VideoEntryPtr video = vm->_video->playMovieRiven(movie);
- timerTime = handle->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 10) * 1000;
+ timerTime = video->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 10) * 1000;
}
sunnerTime = timerTime + vm->getTotalPlayTime();
@@ -683,18 +683,18 @@ static void sunnersLowerStairsTimer(MohawkEngine_Riven *vm) {
// Play a random sunners video if the script one is not playing already
// and then set a new timer for when the new video should be played
- VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ VideoEntryPtr oldVideo = vm->_video->findVideoRiven(1);
uint32 timerTime = 500;
- if (!oldHandle || oldHandle->endOfVideo()) {
+ if (!oldVideo || oldVideo->endOfVideo()) {
uint32 &sunnerTime = vm->_vars["jsunnertime"];
if (sunnerTime == 0) {
timerTime = vm->_rnd->getRandomNumberRng(1, 30) * 1000;
} else if (sunnerTime < vm->getTotalPlayTime()) {
- VideoHandle handle = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(3, 5));
+ VideoEntryPtr video = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(3, 5));
- timerTime = handle->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ timerTime = video->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
}
sunnerTime = timerTime + vm->getTotalPlayTime();
@@ -713,10 +713,10 @@ static void sunnersBeachTimer(MohawkEngine_Riven *vm) {
// Play a random sunners video if the script one is not playing already
// and then set a new timer for when the new video should be played
- VideoHandle oldHandle = vm->_video->findVideoHandleRiven(3);
+ VideoEntryPtr oldvideo = vm->_video->findVideoRiven(3);
uint32 timerTime = 500;
- if (!oldHandle || oldHandle->endOfVideo()) {
+ if (!oldvideo || oldvideo->endOfVideo()) {
uint32 &sunnerTime = vm->_vars["jsunnertime"];
if (sunnerTime == 0) {
@@ -726,9 +726,9 @@ static void sunnersBeachTimer(MohawkEngine_Riven *vm) {
// activate the MLST, we have to set it manually here.
uint16 mlstID = vm->_rnd->getRandomNumberRng(3, 8);
vm->_video->activateMLST(mlstID, vm->getCard()->getId());
- VideoHandle handle = vm->_video->playMovieRiven(mlstID);
+ VideoEntryPtr video = vm->_video->playMovieRiven(mlstID);
- timerTime = handle->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ timerTime = video->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
}
sunnerTime = timerTime + vm->getTotalPlayTime();
@@ -763,7 +763,7 @@ void MohawkEngine_Riven::doVideoTimer(VideoHandle handle, bool force) {
uint16 id = _scriptMan->getStoredMovieOpcodeID();
- if (handle != _video->findVideoHandleRiven(id)) // Check if we've got a video match
+ if (handle != _video->findVideoRiven(id)) // Check if we've got a video match
return;
// Run the opcode if we can at this point
@@ -792,8 +792,8 @@ void MohawkEngine_Riven::checkSunnerAlertClick() {
return;
// If the alert video is no longer playing, we have nothing left to do
- VideoHandle handle = _video->findVideoHandleRiven(1);
- if (!handle || handle->endOfVideo())
+ VideoEntryPtr video = _video->findVideoRiven(1);
+ if (!video || video->endOfVideo())
return;
sunners = 1;
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 1a0f1e826e..525721bc99 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -229,10 +229,10 @@ void RivenExternal::runCredits(uint16 video, uint32 delay) {
_vm->_gfx->beginCredits();
uint nextCreditsFrameStart = 0;
- VideoHandle videoHandle = _vm->_video->findVideoHandleRiven(video);
+ VideoEntryPtr videoPtr = _vm->_video->findVideoRiven(video);
while (!_vm->shouldQuit() && _vm->_gfx->getCurCreditsImage() <= 320) {
- if (videoHandle->getCurFrame() >= (int32)videoHandle->getFrameCount() - 1) {
+ if (videoPtr->getCurFrame() >= (int32)videoPtr->getFrameCount() - 1) {
if (nextCreditsFrameStart == 0) {
// Set us up to start after delay ms
nextCreditsFrameStart = _vm->_system->getMillis() + delay;
@@ -267,7 +267,7 @@ void RivenExternal::runDomeButtonMovie() {
void RivenExternal::runDomeCheck() {
// Check if we clicked while the golden frame was showing
- VideoHandle video = _vm->_video->findVideoHandleRiven(1);
+ VideoEntryPtr video = _vm->_video->findVideoRiven(1);
assert(video);
int32 curFrame = video->getCurFrame();
@@ -879,12 +879,12 @@ void RivenExternal::xbupdateboiler(uint16 argc, uint16 *argv) {
_vm->_video->playMovieRiven(7);
}
} else {
- VideoHandle handle = _vm->_video->findVideoHandleRiven(7);
- if (handle)
- handle->setEnabled(false);
- handle = _vm->_video->findVideoHandleRiven(8);
- if (handle)
- handle->setEnabled(false);
+ VideoEntryPtr video = _vm->_video->findVideoRiven(7);
+ if (video)
+ video->setEnabled(false);
+ video = _vm->_video->findVideoRiven(8);
+ if (video)
+ video->setEnabled(false);
}
}
@@ -1178,7 +1178,7 @@ void RivenExternal::lowerPins() {
uint32 &upMovie = _vm->_vars["gupmoov"];
// Play the video of the pins going down
- VideoHandle handle = _vm->_video->playMovieRiven(upMovie);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(upMovie);
assert(handle);
handle->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, startTime + 550, 600));
_vm->_video->waitUntilMovieEnds(handle);
@@ -1210,7 +1210,7 @@ void RivenExternal::xgrotatepins(uint16 argc, uint16 *argv) {
_vm->_sound->playSound(12);
// Play the video of the pins rotating
- VideoHandle handle = _vm->_video->playMovieRiven(_vm->_vars["gupmoov"]);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(_vm->_vars["gupmoov"]);
assert(handle);
handle->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, startTime + 1215, 600));
_vm->_video->waitUntilMovieEnds(handle);
@@ -1296,7 +1296,7 @@ void RivenExternal::xgpincontrols(uint16 argc, uint16 *argv) {
_vm->_sound->playSound(14);
// Actually play the movie
- VideoHandle handle = _vm->_video->playMovieRiven(pinMovieCodes[imagePos - 1]);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(pinMovieCodes[imagePos - 1]);
assert(handle);
uint32 startTime = 9630 - pinPos * 600;
handle->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, startTime + 550, 600));
@@ -1376,7 +1376,7 @@ void RivenExternal::xgrviewer(uint16 argc, uint16 *argv) {
uint32 newPos = curPos + buttonPos;
// Now play the movie
- VideoHandle handle = _vm->_video->playMovieRiven(1);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(1);
assert(handle);
handle->setBounds(Audio::Timestamp(0, s_viewerTimeIntervals[curPos], 600), Audio::Timestamp(0, s_viewerTimeIntervals[newPos], 600));
_vm->_video->waitUntilMovieEnds(handle);
@@ -1447,7 +1447,7 @@ void RivenExternal::xglviewer(uint16 argc, uint16 *argv) {
uint32 newPos = curPos + buttonPos;
// Now play the movie
- VideoHandle handle = _vm->_video->playMovieRiven(1);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(1);
assert(handle);
handle->setBounds(Audio::Timestamp(0, s_viewerTimeIntervals[curPos], 600), Audio::Timestamp(0, s_viewerTimeIntervals[newPos], 600));
_vm->_video->waitUntilMovieEnds(handle);
@@ -1497,10 +1497,10 @@ static void catherineViewerIdleTimer(MohawkEngine_Riven *vm) {
// Begin playing the new movie
vm->_video->activateMLST(movie, vm->getCard()->getId());
- VideoHandle videoHandle = vm->_video->playMovieRiven(30);
+ VideoEntryPtr video = vm->_video->playMovieRiven(30);
// Reset the timer
- vm->installTimer(&catherineViewerIdleTimer, videoHandle->getDuration().msecs() + vm->_rnd->getRandomNumber(60) * 1000);
+ vm->installTimer(&catherineViewerIdleTimer, video->getDuration().msecs() + vm->_rnd->getRandomNumber(60) * 1000);
}
void RivenExternal::xglview_prisonon(uint16 argc, uint16 *argv) {
@@ -1538,9 +1538,9 @@ void RivenExternal::xglview_prisonon(uint16 argc, uint16 *argv) {
// Begin playing a movie immediately if Catherine is already in the viewer
if (cathMovie == 8 || (cathMovie >= 13 && cathMovie <= 16)) {
_vm->_video->activateMLST(cathMovie, _vm->getCard()->getId());
- VideoHandle videoHandle = _vm->_video->playMovieRiven(30);
+ VideoEntryPtr video = _vm->_video->playMovieRiven(30);
- timeUntilNextMovie = videoHandle->getDuration().msecs() + _vm->_rnd->getRandomNumber(60) * 1000;
+ timeUntilNextMovie = video->getDuration().msecs() + _vm->_rnd->getRandomNumber(60) * 1000;
} else {
// Otherwise, just redraw the imager
timeUntilNextMovie = _vm->_rnd->getRandomNumberRng(10, 20) * 1000;
@@ -2013,7 +2013,7 @@ void RivenExternal::xschool280_playwhark(uint16 argc, uint16 *argv) {
// Handle movement
// (11560/600)s is the length of each of the two movies. We divide it into 19 parts
// (one for each of the possible positions the villager can have).
- VideoHandle handle = _vm->_video->playMovieRiven(doomMLST);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(doomMLST);
Audio::Timestamp startTime = Audio::Timestamp(0, (11560 / 19) * (*posVar), 600);
*posVar += number; // Adjust to the end
Audio::Timestamp endTime = Audio::Timestamp(0, (11560 / 19) * (*posVar), 600);
@@ -2072,7 +2072,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
_vm->_system->updateScreen();
// Let's hook onto our video
- VideoHandle video = _vm->_video->findVideoHandleRiven(argv[0]);
+ VideoEntryPtr video = _vm->_video->findVideoRiven(argv[0]);
// Convert from the standard QuickTime base time to milliseconds
// The values are in terms of 1/600 of a second.
@@ -2368,7 +2368,7 @@ static void rebelPrisonWindowTimer(MohawkEngine_Riven *vm) {
// Randomize a video out in the middle of Tay
uint16 movie = vm->_rnd->getRandomNumberRng(2, 13);
vm->_video->activateMLST(movie, vm->getCard()->getId());
- VideoHandle handle = vm->_video->playMovieRiven(movie);
+ VideoEntryPtr handle = vm->_video->playMovieRiven(movie);
// Ensure the next video starts after this one ends
uint32 timeUntilNextVideo = handle->getDuration().msecs() + vm->_rnd->getRandomNumberRng(38, 58) * 1000;
@@ -2469,7 +2469,7 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) {
// Play a piece of the moving down movie
static const uint32 timeIntervals[] = { 4320, 3440, 2560, 1760, 880, 0 };
uint16 movieCode = telescopeCover ? 1 : 2;
- VideoHandle handle = _vm->_video->playMovieRiven(movieCode);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(movieCode);
handle->setBounds(Audio::Timestamp(0, timeIntervals[telescopePos], 600), Audio::Timestamp(0, timeIntervals[telescopePos - 1], 600));
_vm->_sound->playSound(14); // Play the moving sound
_vm->_video->waitUntilMovieEnds(handle);
@@ -2502,7 +2502,7 @@ void RivenExternal::xtexterior300_telescopeup(uint16 argc, uint16 *argv) {
// Play a piece of the moving up movie
static const uint32 timeIntervals[] = { 0, 800, 1680, 2560, 3440, 4320 };
uint16 movieCode = _vm->_vars["ttelecover"] ? 4 : 5;
- VideoHandle handle = _vm->_video->playMovieRiven(movieCode);
+ VideoEntryPtr handle = _vm->_video->playMovieRiven(movieCode);
handle->setBounds(Audio::Timestamp(0, timeIntervals[telescopePos - 1], 600), Audio::Timestamp(0, timeIntervals[telescopePos], 600));
_vm->_sound->playSound(14); // Play the moving sound
_vm->_video->waitUntilMovieEnds(handle);
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index c3e92380e2..1e4a1936d9 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -503,9 +503,9 @@ void RivenSimpleCommand::changeStack(uint16 op, uint16 argc, uint16 *argv) {
// Command 28: disable a movie
void RivenSimpleCommand::disableMovie(uint16 op, uint16 argc, uint16 *argv) {
- VideoHandle handle = _vm->_video->findVideoHandleRiven(argv[0]);
- if (handle)
- handle->setEnabled(false);
+ VideoEntryPtr video = _vm->_video->findVideoRiven(argv[0]);
+ if (video)
+ video->setEnabled(false);
}
// Command 29: disable all movies
@@ -515,9 +515,9 @@ void RivenSimpleCommand::disableAllMovies(uint16 op, uint16 argc, uint16 *argv)
// Command 31: enable a movie
void RivenSimpleCommand::enableMovie(uint16 op, uint16 argc, uint16 *argv) {
- VideoHandle handle = _vm->_video->findVideoHandleRiven(argv[0]);
- if (handle)
- handle->setEnabled(true);
+ VideoEntryPtr video = _vm->_video->findVideoRiven(argv[0]);
+ if (video)
+ video->setEnabled(true);
}
// Command 32: play foreground movie - blocking (movie_id)
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index eec543235e..56da654acd 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -203,6 +203,10 @@ void VideoManager::playMovieBlockingCentered(const Common::String &fileName, boo
waitUntilMovieEnds(VideoHandle(ptr));
}
+void VideoManager::waitUntilMovieEnds(const VideoEntryPtr &video) {
+ waitUntilMovieEnds(VideoHandle(video));
+}
+
void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
if (!videoHandle)
return;
@@ -448,7 +452,7 @@ void VideoManager::clearMLST() {
_mlstRecords.clear();
}
-VideoHandle VideoManager::playMovieRiven(uint16 id) {
+VideoEntryPtr VideoManager::playMovieRiven(uint16 id) {
for (uint16 i = 0; i < _mlstRecords.size(); i++) {
if (_mlstRecords[i].code == id) {
debug(1, "Play tMOV %d (non-blocking) at (%d, %d) %s, Volume = %d", _mlstRecords[i].movieID, _mlstRecords[i].left, _mlstRecords[i].top, _mlstRecords[i].loop != 0 ? "looping" : "non-looping", _mlstRecords[i].volume);
@@ -461,11 +465,11 @@ VideoHandle VideoManager::playMovieRiven(uint16 id) {
ptr->start();
}
- return VideoHandle(ptr);
+ return ptr;
}
}
- return VideoHandle();
+ return VideoEntryPtr();
}
void VideoManager::playMovieBlockingRiven(uint16 id) {
@@ -484,9 +488,9 @@ void VideoManager::playMovieBlockingRiven(uint16 id) {
void VideoManager::stopMovieRiven(uint16 id) {
debug(2, "Stopping movie %d", id);
- VideoHandle handle = findVideoHandleRiven(id);
- if (handle)
- removeEntry(handle._ptr);
+ VideoEntryPtr video = findVideoRiven(id);
+ if (video)
+ removeEntry(video);
}
void VideoManager::disableAllMovies() {
@@ -548,14 +552,14 @@ VideoEntryPtr VideoManager::open(const Common::String &fileName) {
return entry;
}
-VideoHandle VideoManager::findVideoHandleRiven(uint16 id) {
+VideoEntryPtr VideoManager::findVideoRiven(uint16 id) {
for (uint16 i = 0; i < _mlstRecords.size(); i++)
if (_mlstRecords[i].code == id)
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); it++)
if ((*it)->getID() == _mlstRecords[i].movieID)
- return VideoHandle(*it);
+ return *it;
- return VideoHandle();
+ return VideoEntryPtr();
}
VideoHandle VideoManager::findVideoHandle(uint16 id) {
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index e2b09b6afd..dba448d689 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -321,10 +321,11 @@ public:
void activateMLST(uint16 mlstId, uint16 card);
void clearMLST();
void disableAllMovies();
- VideoHandle playMovieRiven(uint16 id);
+ VideoEntryPtr playMovieRiven(uint16 id);
void playMovieBlockingRiven(uint16 id);
- VideoHandle findVideoHandleRiven(uint16 id);
+ VideoEntryPtr findVideoRiven(uint16 id);
void stopMovieRiven(uint16 id);
+ void waitUntilMovieEnds(const VideoEntryPtr &video);
// Handle functions
VideoHandle findVideoHandle(uint16 id);