diff options
author | Alyssa Milburn | 2011-11-04 22:39:27 +0100 |
---|---|---|
committer | Alyssa Milburn | 2011-11-04 22:39:27 +0100 |
commit | 4da2f24866fc1094f46cf9ec5eeba4d939822824 (patch) | |
tree | ef0d0b757619d3c57345d175099401540e21883d | |
parent | 1c1eed784a0eb029b5db75aecf4cfed1c4e80e83 (diff) | |
download | scummvm-rg350-4da2f24866fc1094f46cf9ec5eeba4d939822824.tar.gz scummvm-rg350-4da2f24866fc1094f46cf9ec5eeba4d939822824.tar.bz2 scummvm-rg350-4da2f24866fc1094f46cf9ec5eeba4d939822824.zip |
COMPOSER: Handle V1 pipes properly.
-rw-r--r-- | engines/composer/composer.cpp | 8 | ||||
-rw-r--r-- | engines/composer/composer.h | 4 | ||||
-rw-r--r-- | engines/composer/graphics.cpp | 42 | ||||
-rw-r--r-- | engines/composer/scripting.cpp | 29 |
4 files changed, 71 insertions, 12 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 1fa21a5494..5c66d9f0bf 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -53,8 +53,11 @@ ComposerEngine::ComposerEngine(OSystem *syst, const ComposerGameDescription *gam ComposerEngine::~ComposerEngine() { DebugMan.clearAllDebugChannels(); + stopPipes(); for (Common::List<OldScript *>::iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++) delete *i; + for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) + delete *i; for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) delete i->_archive; for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) @@ -421,10 +424,7 @@ void ComposerEngine::unloadLibrary(uint id) { delete *j; } _anims.clear(); - for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) { - delete *j; - } - _pipes.clear(); + stopPipes(); for (Common::List<Sprite>::iterator j = _sprites.begin(); j != _sprites.end(); j++) { j->_surface.free(); diff --git a/engines/composer/composer.h b/engines/composer/composer.h index ff85ed50a3..0d11817b9f 100644 --- a/engines/composer/composer.h +++ b/engines/composer/composer.h @@ -204,6 +204,7 @@ private: void runScript(uint16 id); int16 scriptFuncCall(uint16 id, int16 param1, int16 param2, int16 param3); void runOldScript(uint16 id, uint16 wait); + void stopOldScript(uint16 id); void tickOldScripts(); bool tickOldScript(OldScript *script); @@ -212,6 +213,9 @@ private: void playWaveForAnim(uint16 id, uint16 priority, bool bufferingOnly); void processAnimFrame(); + void playPipe(uint16 id); + void stopPipes(); + bool spriteVisible(uint16 id, uint16 animId); Sprite *addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos); void removeSprite(uint16 id, uint16 animId); diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp index 6f9aa76be8..dc0c99a5ff 100644 --- a/engines/composer/graphics.cpp +++ b/engines/composer/graphics.cpp @@ -355,6 +355,38 @@ void ComposerEngine::processAnimFrame() { } } +void ComposerEngine::playPipe(uint16 id) { + stopPipes(); + + if (!hasResource(ID_PIPE, id)) { + error("couldn't find pipe %d", id); + } + + Common::SeekableReadStream *stream = getResource(ID_PIPE, id); + OldPipe *pipe = new OldPipe(stream); + _pipes.push_front(pipe); + //pipe->nextFrame(); + + const Common::Array<uint16> *scripts = pipe->getScripts(); + if (scripts && !scripts->empty()) + runScript((*scripts)[0], 1, 0, 0); +} + +void ComposerEngine::stopPipes() { + for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) { + const Common::Array<uint16> *scripts = (*j)->getScripts(); + if (scripts) { + for (uint i = 0; i < scripts->size(); i++) { + removeSprite((*scripts)[i], 0); + stopOldScript((*scripts)[i]); + } + } + delete *j; + } + + _pipes.clear(); +} + bool ComposerEngine::spriteVisible(uint16 id, uint16 animId) { for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) { if (i->_id != id) @@ -376,7 +408,10 @@ Sprite *ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) { if (i->_id != id) continue; - if (i->_animId && animId && (i->_animId != animId)) + if (getGameType() == GType_ComposerV1) { + if (i->_animId != animId) + continue; + } else if (i->_animId && animId && (i->_animId != animId)) continue; dirtySprite(*i); @@ -426,7 +461,10 @@ void ComposerEngine::removeSprite(uint16 id, uint16 animId) { for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) { if (!i->_id || (id && i->_id != id)) continue; - if (i->_animId && animId && (i->_animId != animId)) + if (getGameType() == GType_ComposerV1) { + if (i->_animId != animId) + continue; + } else if (i->_animId && animId && (i->_animId != animId)) continue; dirtySprite(*i); i->_surface.free(); diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp index bf02924cbb..e9e8b7570f 100644 --- a/engines/composer/scripting.cpp +++ b/engines/composer/scripting.cpp @@ -733,7 +733,7 @@ OldScript::~OldScript() { } void ComposerEngine::runOldScript(uint16 id, uint16 wait) { - // FIXME: kill any old script + stopOldScript(id); Common::SeekableReadStream *stream = getResource(ID_SCRP, id); OldScript *script = new OldScript(id, stream); @@ -741,6 +741,17 @@ void ComposerEngine::runOldScript(uint16 id, uint16 wait) { _oldScripts.push_back(script); } +void ComposerEngine::stopOldScript(uint16 id) { + // FIXME: this could potentially (in the case of buggy script) be called on an in-use script + + for (Common::List<OldScript *>::iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++) { + if ((*i)->_id == id) { + delete *i; + i = _oldScripts.reverse_erase(i); + } + } +} + void ComposerEngine::tickOldScripts() { for (Common::List<OldScript *>::iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++) { if (!tickOldScript(*i)) { @@ -780,7 +791,8 @@ bool ComposerEngine::tickOldScript(OldScript *script) { } bool running = true; - while (running && script->_stream->pos() + 1 < (int)script->_size) { + bool erasedOldSprite = false; + while (running && script->_stream->pos() < (int)script->_size) { uint16 spriteId, scriptId, buttonId, pipeId; Common::Point spritePos; @@ -792,7 +804,10 @@ bool ComposerEngine::tickOldScript(OldScript *script) { running = false; break; case kOldOpReplaceSprite: - removeSprite(0, script->_id); + if (!erasedOldSprite) { + removeSprite(0, script->_id); + erasedOldSprite = true; + } spriteId = script->_stream->readUint16LE(); spritePos.x = script->_stream->readSint16LE(); @@ -820,7 +835,8 @@ bool ComposerEngine::tickOldScript(OldScript *script) { case kOldOpStopScript: scriptId = script->_stream->readUint16LE(); debug(3, "kOldOpStopScript(%d)", scriptId); - warning("kOldOpStopScript not yet implemented"); // FIXME + removeSprite(0, scriptId); + stopOldScript(scriptId); break; case kOldOpActivateButton: buttonId = script->_stream->readUint16LE(); @@ -882,12 +898,13 @@ bool ComposerEngine::tickOldScript(OldScript *script) { case kOldOpPlayPipe: pipeId = script->_stream->readUint16LE(); debug(3, "kOldOpPlayPipe(%d)", pipeId); - warning("V1 pipes not yet implemented"); // FIXME + playPipe(pipeId); break; case kOldOpStopPipe: pipeId = script->_stream->readUint16LE(); debug(3, "kOldOpStopPipe(%d)", pipeId); - warning("V1 pipes not yet implemented"); // FIXME + // yes, pipeId is ignored here.. + stopPipes(); break; case kOldOpNewScreen: uint16 newScreenId; |