diff options
-rw-r--r-- | engines/mohawk/riven.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/riven_card.cpp | 58 | ||||
-rw-r--r-- | engines/mohawk/riven_card.h | 6 | ||||
-rw-r--r-- | engines/mohawk/riven_external.cpp | 66 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/video.cpp | 46 | ||||
-rw-r--r-- | engines/mohawk/video.h | 2 |
7 files changed, 109 insertions, 77 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index b431b971fb..2536b0246f 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -591,7 +591,7 @@ static void catherineIdleTimer(MohawkEngine_Riven *vm) { cathState = 1; // Play the movie, blocking - vm->_video->activateMLST(movie, vm->getCard()->getId()); + vm->_video->activateMLST(vm->getCard()->getMovie(movie)); vm->_cursor->hideCursor(); vm->_video->playMovieBlockingRiven(movie); vm->_cursor->showCursor(); @@ -725,7 +725,7 @@ static void sunnersBeachTimer(MohawkEngine_Riven *vm) { // Unlike the other cards' scripts which automatically // activate the MLST, we have to set it manually here. uint16 mlstID = vm->_rnd->getRandomNumberRng(3, 8); - vm->_video->activateMLST(mlstID, vm->getCard()->getId()); + vm->_video->activateMLST(vm->getCard()->getMovie(mlstID)); VideoEntryPtr video = vm->_video->playMovieRiven(mlstID); timerTime = video->getDuration().msecs() + vm->_rnd->getRandomNumberRng(1, 30) * 1000; diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index 212557b15d..4b6feae5ae 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -40,6 +40,7 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) : loadHotspots(id); loadCardPictureList(id); loadCardSoundList(id); + loadCardMovieList(id); loadCardHotspotEnableList(id); loadCardWaterEffectList(id); } @@ -510,6 +511,63 @@ void RivenCard::dump() const { } debugN("\n"); } + + for (uint i = 0; i < _movieList.size(); i++) { + debug("== Movie %d ==", _movieList[i].index); + debug("movieID: %d", _movieList[i].movieID); + debug("code: %d", _movieList[i].code); + debug("left: %d", _movieList[i].left); + debug("top: %d", _movieList[i].top); + debug("u0[0]: %d", _movieList[i].u0[0]); + debug("u0[1]: %d", _movieList[i].u0[1]); + debug("u0[2]: %d", _movieList[i].u0[2]); + debug("loop: %d", _movieList[i].loop); + debug("volume: %d", _movieList[i].volume); + debug("u1: %d", _movieList[i].u1); + debugN("\n"); + } +} + +void RivenCard::loadCardMovieList(uint16 id) { + Common::SeekableReadStream *mlstStream = _vm->getResource(ID_MLST, id); + + uint16 recordCount = mlstStream->readUint16BE(); + _movieList.resize(recordCount); + + for (uint16 i = 0; i < recordCount; i++) { + MLSTRecord &mlstRecord = _movieList[i]; + mlstRecord.index = mlstStream->readUint16BE(); + mlstRecord.movieID = mlstStream->readUint16BE(); + mlstRecord.code = mlstStream->readUint16BE(); + mlstRecord.left = mlstStream->readUint16BE(); + mlstRecord.top = mlstStream->readUint16BE(); + + for (byte j = 0; j < 2; j++) + if (mlstStream->readUint16BE() != 0) + warning("u0[%d] in MLST non-zero", j); + + if (mlstStream->readUint16BE() != 0xFFFF) + warning("u0[2] in MLST not 0xFFFF"); + + mlstRecord.loop = mlstStream->readUint16BE(); + mlstRecord.volume = mlstStream->readUint16BE(); + mlstRecord.u1 = mlstStream->readUint16BE(); + + if (mlstRecord.u1 != 1) + warning("mlstRecord.u1 not 1"); + } + + delete mlstStream; +} + +MLSTRecord RivenCard::getMovie(uint16 index) const { + for (uint16 i = 0; i < _movieList.size(); i++) { + if (_movieList[i].index == index) { + return _movieList[i]; + } + } + + error("Could not find movie %d in card %d", index, _id); } RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) : diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h index 626c427444..b02f5f7753 100644 --- a/engines/mohawk/riven_card.h +++ b/engines/mohawk/riven_card.h @@ -25,6 +25,7 @@ #include "mohawk/riven_scripts.h" #include "mohawk/riven_sound.h" +#include "mohawk/video.h" #include "common/rect.h" #include "common/system.h" @@ -79,6 +80,9 @@ public: /** Get the card's sound description with the specified index */ SLSTRecord getSound(uint16 index) const; + /** Get the card's movie description with the specified index */ + MLSTRecord getMovie(uint16 index) const; + /** Draw borders for all the hotspots in the card */ void drawHotspotRects(); @@ -128,6 +132,7 @@ private: void loadHotspots(uint16 id); void loadCardPictureList(uint16 id); void loadCardSoundList(uint16 id); + void loadCardMovieList(uint16 id); void loadCardHotspotEnableList(uint16 id); void loadCardWaterEffectList(uint16 id); void setCurrentCardVariable(); @@ -164,6 +169,7 @@ private: // Resource lists Common::Array<Picture> _pictureList; Common::Array<SLSTRecord> _soundList; + Common::Array<MLSTRecord> _movieList; Common::Array<HotspotEnableRecord> _hotspotEnableList; Common::Array<WaterEffectRecord> _waterEffectList; }; diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 525721bc99..c5426dccf7 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -810,53 +810,53 @@ void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) { // Water is filling/draining from the boiler if (water == 0) { if (platform == 1) - _vm->_video->activateMLST(12, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(12)); else - _vm->_video->activateMLST(10, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(10)); } else if (heat == 1) { if (platform == 1) - _vm->_video->activateMLST(22, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(22)); else - _vm->_video->activateMLST(19, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(19)); } else { if (platform == 1) - _vm->_video->activateMLST(16, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(16)); else - _vm->_video->activateMLST(13, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(13)); } } else if (argv[0] == 2 && water != 0) { if (heat == 1) { // Turning on the heat if (platform == 1) - _vm->_video->activateMLST(23, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(23)); else - _vm->_video->activateMLST(20, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(20)); } else { // Turning off the heat if (platform == 1) - _vm->_video->activateMLST(18, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(18)); else - _vm->_video->activateMLST(15, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(15)); } } else if (argv[0] == 3) { if (platform == 1) { // Lowering the platform if (water == 1) { if (heat == 1) - _vm->_video->activateMLST(24, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(24)); else - _vm->_video->activateMLST(17, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(17)); } else - _vm->_video->activateMLST(11, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(11)); } else { // Raising the platform if (water == 1) { if (heat == 1) - _vm->_video->activateMLST(21, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(21)); else - _vm->_video->activateMLST(14, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(14)); } else - _vm->_video->activateMLST(9, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(9)); } } @@ -872,10 +872,10 @@ void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) { void RivenExternal::xbupdateboiler(uint16 argc, uint16 *argv) { if (_vm->_vars["bheat"] != 0) { if (_vm->_vars["bblrgrt"] == 0) { - _vm->_video->activateMLST(8, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(8)); _vm->_video->playMovieRiven(8); } else { - _vm->_video->activateMLST(7, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(7)); _vm->_video->playMovieRiven(7); } } else { @@ -996,11 +996,11 @@ void RivenExternal::xbfreeytram(uint16 argc, uint16 *argv) { } // Activate the MLST and play the video - _vm->_video->activateMLST(mlstId, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(mlstId)); _vm->_video->playMovieBlockingRiven(11); // Now play the second movie - _vm->_video->activateMLST(mlstId + 5, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(mlstId + 5)); _vm->_video->playMovieBlockingRiven(12); } @@ -1410,19 +1410,19 @@ void RivenExternal::xgplaywhark(uint16 argc, uint16 *argv) { // Activate the correct video based on the amount of times we've been visited switch (wharkVisits) { case 1: - _vm->_video->activateMLST(3, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(3)); break; case 2: // One of two random videos - _vm->_video->activateMLST(4 + _vm->_rnd->getRandomBit(), _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(4 + _vm->_rnd->getRandomBit())); break; case 3: // One of two random videos - _vm->_video->activateMLST(6 + _vm->_rnd->getRandomBit(), _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(6 + _vm->_rnd->getRandomBit())); break; case 4: // Red alert! Shields online! Brace yourself for impact! - _vm->_video->activateMLST(8, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(8)); break; } @@ -1496,7 +1496,7 @@ static void catherineViewerIdleTimer(MohawkEngine_Riven *vm) { cathState = 3; // Begin playing the new movie - vm->_video->activateMLST(movie, vm->getCard()->getId()); + vm->_video->activateMLST(vm->getCard()->getMovie(movie)); VideoEntryPtr video = vm->_video->playMovieRiven(30); // Reset the timer @@ -1537,7 +1537,7 @@ 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()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(cathMovie)); VideoEntryPtr video = _vm->_video->playMovieRiven(30); timeUntilNextMovie = video->getDuration().msecs() + _vm->_rnd->getRandomNumber(60) * 1000; @@ -2138,7 +2138,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) { _vm->_cursor->setCursor(kRivenHideCursor); // Hide the cursor _vm->getCard()->drawPicture(3); // Black out the screen _vm->_sound->playSound(0); // Play the link sound - _vm->_video->activateMLST(7, _vm->getCard()->getId()); // Activate Gehn Link Video + _vm->_video->activateMLST(_vm->getCard()->getMovie(7)); // Activate Gehn Link Video _vm->_video->playMovieBlockingRiven(1); // Play Gehn Link Video _vm->_vars["agehn"] = 4; // Set Gehn to the trapped state _vm->_vars["atrapbook"] = 1; // We've got the trap book again @@ -2283,7 +2283,7 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) { } // Now play the video for the watch - _vm->_video->activateMLST(1, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(1)); _vm->_video->playMovieBlockingRiven(1); // And, finally, refresh @@ -2367,7 +2367,7 @@ void RivenExternal::xrhideinventory(uint16 argc, uint16 *argv) { 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()); + vm->_video->activateMLST(vm->getCard()->getMovie(movie)); VideoEntryPtr handle = vm->_video->playMovieRiven(movie); // Ensure the next video starts after this one ends @@ -2435,25 +2435,25 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) { if (_vm->_vars["pcage"] == 2) { // The best ending: Catherine is free, Gehn is trapped, Atrus comes to rescue you. // And now we fall back to Earth... all the way... - _vm->_video->activateMLST(8, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(8)); runEndGame(8, 5000); } else if (_vm->_vars["agehn"] == 4) { // The ok ending: Catherine is still trapped, Gehn is trapped, Atrus comes to rescue you. // Nice going! Catherine and the islanders are all dead now! Just go back to your home... - _vm->_video->activateMLST(9, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(9)); runEndGame(9, 5000); } else if (_vm->_vars["atrapbook"] == 1) { // The bad ending: Catherine is trapped, Gehn is free, Atrus gets shot by Gehn, // And then you get shot by Cho. Nice going! Catherine and the islanders are dead // and you have just set Gehn free from Riven, not to mention you're dead. - _vm->_video->activateMLST(10, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(10)); runEndGame(10, 5000); } else { // The impossible ending: You don't have Catherine's journal and yet you were somehow // able to open the hatch on the telescope. The game provides an ending for those who // cheat, load a saved game with the combo, or just guess the telescope combo. Atrus // doesn't come and you just fall into the fissure. - _vm->_video->activateMLST(11, _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(11)); runEndGame(11, 5000); } } else { diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 1e4a1936d9..2985f155d5 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -610,7 +610,7 @@ void RivenSimpleCommand::activateSLST(uint16 op, uint16 argc, uint16 *argv) { // Command 41: activate MLST record and play void RivenSimpleCommand::activateMLSTAndPlay(uint16 op, uint16 argc, uint16 *argv) { - _vm->_video->activateMLST(argv[0], _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(argv[0])); _vm->_video->playMovieRiven(argv[0]); } @@ -643,7 +643,7 @@ void RivenSimpleCommand::zipMode(uint16 op, uint16 argc, uint16 *argv) { // Command 46: activate MLST record (movie lists) void RivenSimpleCommand::activateMLST(uint16 op, uint16 argc, uint16 *argv) { - _vm->_video->activateMLST(argv[0], _vm->getCard()->getId()); + _vm->_video->activateMLST(_vm->getCard()->getMovie(argv[0])); } void RivenSimpleCommand::dump(byte tabs) { diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index 56da654acd..cfc60153cb 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -405,47 +405,15 @@ bool VideoManager::drawNextFrame(VideoEntryPtr videoEntry) { return true; } -void VideoManager::activateMLST(uint16 mlstId, uint16 card) { - Common::SeekableReadStream *mlstStream = _vm->getResource(ID_MLST, card); - uint16 recordCount = mlstStream->readUint16BE(); - - for (uint16 i = 0; i < recordCount; i++) { - MLSTRecord mlstRecord; - mlstRecord.index = mlstStream->readUint16BE(); - mlstRecord.movieID = mlstStream->readUint16BE(); - mlstRecord.code = mlstStream->readUint16BE(); - mlstRecord.left = mlstStream->readUint16BE(); - mlstRecord.top = mlstStream->readUint16BE(); - - for (byte j = 0; j < 2; j++) - if (mlstStream->readUint16BE() != 0) - warning("u0[%d] in MLST non-zero", j); - - if (mlstStream->readUint16BE() != 0xFFFF) - warning("u0[2] in MLST not 0xFFFF"); - - mlstRecord.loop = mlstStream->readUint16BE(); - mlstRecord.volume = mlstStream->readUint16BE(); - mlstRecord.u1 = mlstStream->readUint16BE(); - - if (mlstRecord.u1 != 1) - warning("mlstRecord.u1 not 1"); - - // We've found a match, add it - if (mlstRecord.index == mlstId) { - // Make sure we don't have any duplicates - for (uint32 j = 0; j < _mlstRecords.size(); j++) - if (_mlstRecords[j].index == mlstRecord.index || _mlstRecords[j].code == mlstRecord.code) { - _mlstRecords.remove_at(j); - j--; - } - - _mlstRecords.push_back(mlstRecord); - break; +void VideoManager::activateMLST(const MLSTRecord &mlst) { + // Make sure we don't have any duplicates + for (uint32 j = 0; j < _mlstRecords.size(); j++) + if (_mlstRecords[j].index == mlst.index || _mlstRecords[j].code == mlst.code) { + _mlstRecords.remove_at(j); + j--; } - } - delete mlstStream; + _mlstRecords.push_back(mlst); } void VideoManager::clearMLST() { diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h index dba448d689..c3d04ea58c 100644 --- a/engines/mohawk/video.h +++ b/engines/mohawk/video.h @@ -318,7 +318,7 @@ public: bool isVideoPlaying(); // Riven-related functions - void activateMLST(uint16 mlstId, uint16 card); + void activateMLST(const MLSTRecord &mlst); void clearMLST(); void disableAllMovies(); VideoEntryPtr playMovieRiven(uint16 id); |