diff --git a/engines/myst3/movie.cpp b/engines/myst3/movie.cpp index 0ef1bb4b350..b2b3484969a 100644 --- a/engines/myst3/movie.cpp +++ b/engines/myst3/movie.cpp @@ -24,15 +24,15 @@ namespace Myst3 { -Movie::Movie(Archive &archive, uint16 id) { +Movie::Movie(Archive *archive, uint16 id) { static const float scale = 50.0f; - const DirectorySubEntry *binkDesc = archive.getDescription(id, 0, DirectorySubEntry::kMovie); + const DirectorySubEntry *binkDesc = archive->getDescription(id, 0, DirectorySubEntry::kMovie); if (!binkDesc) return; - Common::MemoryReadStream *binkStream = archive.getData(binkDesc); + Common::MemoryReadStream *binkStream = archive->getData(binkDesc); const VideoData &videoData = binkDesc->getVideoData(); Math::Vector3d planeDirection = videoData.v1; diff --git a/engines/myst3/movie.h b/engines/myst3/movie.h index 2949ddd3f90..e0ff39d7305 100644 --- a/engines/myst3/movie.h +++ b/engines/myst3/movie.h @@ -32,9 +32,10 @@ namespace Myst3 { class Movie { public: - Movie(Archive &archive, uint16 id); + Movie(Archive *archive, uint16 id); virtual ~Movie(); void draw(); + void setCondition(uint16 condition) { _condition = condition; } private: static const int _movieTextureSize = 1024; @@ -45,6 +46,8 @@ private: Math::Vector3d _pTopRight; Video::BinkDecoder _bink; GLuint _texture; + + uint16 _condition; }; } /* namespace Myst3 */ diff --git a/engines/myst3/myst3.cpp b/engines/myst3/myst3.cpp index d8ca4fdd879..d2e8b94d97f 100644 --- a/engines/myst3/myst3.cpp +++ b/engines/myst3/myst3.cpp @@ -153,10 +153,19 @@ Common::Error Myst3Engine::run() { } _node->draw(); + for (uint i = 0; i < _movies.size(); i++) { + _movies[i]->draw(); + } + _system->updateScreen(); _system->delayMillis(10); } + for (uint i = 0; i < _movies.size(); i++) { + delete _movies[i]; + } + _movies.clear(); + _node->unload(); delete _node; @@ -167,6 +176,10 @@ Common::Error Myst3Engine::run() { void Myst3Engine::goToNode(uint16 nodeID, uint8 roomID) { if (_node) { + for (uint i = 0; i < _movies.size(); i++) { + delete _movies[i]; + } + _movies.clear(); _node->unload(); delete _node; _node = 0; @@ -250,4 +263,10 @@ void Myst3Engine::runScriptsFromNode(uint16 nodeID, uint8 roomID, uint32 ageID) } } +void Myst3Engine::loadMovie(uint16 id, bool preload, uint16 condition) { + Movie *movie = new Movie(_archive, id); + movie->setCondition(condition); + _movies.push_back(movie); +} + } // end of namespace Myst3 diff --git a/engines/myst3/myst3.h b/engines/myst3/myst3.h index c5046217210..2b03318d2ca 100644 --- a/engines/myst3/myst3.h +++ b/engines/myst3/myst3.h @@ -30,6 +30,7 @@ #include "engines/myst3/archive.h" #include "engines/myst3/console.h" #include "engines/myst3/database.h" +#include "engines/myst3/movie.h" #include "engines/myst3/node.h" #include "engines/myst3/scene.h" #include "engines/myst3/script.h" @@ -72,6 +73,7 @@ public: void runScriptsFromNode(uint16 nodeID, uint8 roomID = 0, uint32 ageID = 0); void runNodeInitScripts(); + void loadMovie(uint16 id, bool preload, uint16 condition); private: OSystem *_system; Console *_console; @@ -82,6 +84,8 @@ private: Script *_scriptEngine; Database *_db; + Common::Array _movies; + ViewType _viewType; uint16 _currentNode; uint8 _currentRoom; diff --git a/engines/myst3/nodecube.cpp b/engines/myst3/nodecube.cpp index 2982e9f5bb5..71cc398f316 100644 --- a/engines/myst3/nodecube.cpp +++ b/engines/myst3/nodecube.cpp @@ -47,16 +47,6 @@ void NodeCube::load(Archive &archive, uint16 index) { delete jpegStream; } } - - // HACK: To load some of the movies of a frame - loadMovie(archive, index + 10000); - loadMovie(archive, index + 11000); - loadMovie(archive, index + 20000); -} - -void NodeCube::loadMovie(Archive &archive, uint16 id) { - Movie *movie = new Movie(archive, id); - _movies.push_back(movie); } void NodeCube::draw() { @@ -117,17 +107,9 @@ void NodeCube::draw() { glEnd(); glDepthMask(GL_TRUE); - - for (uint i = 0; i < _movies.size(); i++) { - _movies[i]->draw(); - } } void NodeCube::unload() { - for (uint i = 0; i < _movies.size(); i++) { - delete _movies[i]; - } - Node::unload(); } diff --git a/engines/myst3/nodecube.h b/engines/myst3/nodecube.h index 6998e38f620..5320b5b199f 100644 --- a/engines/myst3/nodecube.h +++ b/engines/myst3/nodecube.h @@ -24,7 +24,6 @@ #define NODECUBE_H_ #include "engines/myst3/node.h" -#include "engines/myst3/movie.h" namespace Myst3 { @@ -36,11 +35,6 @@ public: void load(Archive &archive, uint16 id); void unload(); void draw(); - - void loadMovie(Archive &archive, uint16 id); - -private: - Common::Array _movies; }; } /* namespace Myst3 */ diff --git a/engines/myst3/script.cpp b/engines/myst3/script.cpp index b9f667f56cb..728fc1a76da 100644 --- a/engines/myst3/script.cpp +++ b/engines/myst3/script.cpp @@ -37,6 +37,8 @@ Script::Script(Myst3Engine *vm): OPCODE(8, nodeFrameInitCond); OPCODE(9, nodeFrameInitIndex); OPCODE(11, stopWholeScript); + OPCODE(19, movieInitCond); + OPCODE(22, movieInitCondPreload); OPCODE(35, sunspotAdd); OPCODE(49, varSetZero); OPCODE(50, varSetOne); @@ -221,6 +223,17 @@ void Script::stopWholeScript(Context &c, const Opcode &cmd) { c.endScript = true; } +void Script::movieInitCond(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Init movie %d with condition %d", cmd.op, cmd.args[0], cmd.args[1]); + + _vm->loadMovie(cmd.args[0], false, cmd.args[1]); +} +void Script::movieInitCondPreload(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Preload movie %d with condition %d", cmd.op, cmd.args[0], cmd.args[1]); + + _vm->loadMovie(cmd.args[0], true, cmd.args[1]); +} + void Script::sunspotAdd(Context &c, const Opcode &cmd) { debugC(kDebugScript, "Opcode %d: Add sunspot: pitch %d heading %d", cmd.op, cmd.args[0], cmd.args[1]); diff --git a/engines/myst3/script.h b/engines/myst3/script.h index bc97c2586c3..053234bcfcb 100644 --- a/engines/myst3/script.h +++ b/engines/myst3/script.h @@ -71,6 +71,8 @@ private: DECLARE_OPCODE(nodeFrameInitCond); DECLARE_OPCODE(nodeFrameInitIndex); DECLARE_OPCODE(stopWholeScript); + DECLARE_OPCODE(movieInitCond); + DECLARE_OPCODE(movieInitCondPreload); DECLARE_OPCODE(sunspotAdd); DECLARE_OPCODE(varSetZero); DECLARE_OPCODE(varSetOne);