diff options
author | Alyssa Milburn | 2011-07-19 16:12:18 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-19 16:12:18 +0200 |
commit | 6646be1da11e417e17e2f530a96399392916498f (patch) | |
tree | d0c5df0bfc8524ad96c93f19a13f71baeb5c92dd /engines/composer | |
parent | 6dfbf74a745246c3dd5503c7999b51d076cd574c (diff) | |
download | scummvm-rg350-6646be1da11e417e17e2f530a96399392916498f.tar.gz scummvm-rg350-6646be1da11e417e17e2f530a96399392916498f.tar.bz2 scummvm-rg350-6646be1da11e417e17e2f530a96399392916498f.zip |
COMPOSER: Implement kFuncChangeBackground.
Diffstat (limited to 'engines/composer')
-rw-r--r-- | engines/composer/composer.cpp | 2 | ||||
-rw-r--r-- | engines/composer/composer.h | 5 | ||||
-rw-r--r-- | engines/composer/graphics.cpp | 28 | ||||
-rw-r--r-- | engines/composer/scripting.cpp | 6 |
4 files changed, 30 insertions, 11 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index c63e07d9ee..e1ab6c9472 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -335,7 +335,7 @@ void ComposerEngine::loadLibrary(uint id) { // add background sprite, if it exists if (hasResource(ID_BMAP, 1000)) - addSprite(1000, 0, 0xffff, Common::Point()); + setBackground(1000); // TODO: better CTBL logic loadCTBL(1000, 100); diff --git a/engines/composer/composer.h b/engines/composer/composer.h index 95f262f1ec..55e3331faa 100644 --- a/engines/composer/composer.h +++ b/engines/composer/composer.h @@ -183,13 +183,14 @@ private: void processAnimFrame(); bool spriteVisible(uint16 id, uint16 animId); - void addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos); + Sprite *addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos); void removeSprite(uint16 id, uint16 animId); const Sprite *getSpriteAtPos(const Common::Point &pos); const Button *getButtonFor(const Sprite *sprite, const Common::Point &pos); void redraw(); - void loadCTBL(uint id, uint fadePercent); + void loadCTBL(uint16 id, uint fadePercent); + void setBackground(uint16 id); void decompressBitmap(uint16 type, Common::SeekableReadStream *stream, byte *buffer, uint32 size, uint width, uint height); bool initSprite(Sprite &sprite); Common::SeekableReadStream *getStreamForSprite(uint16 id); diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp index 65a12dd6a8..1b7c3bdfc9 100644 --- a/engines/composer/graphics.cpp +++ b/engines/composer/graphics.cpp @@ -369,7 +369,7 @@ bool ComposerEngine::spriteVisible(uint16 id, uint16 animId) { return false; } -void ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos) { +Sprite *ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos) { Sprite sprite; bool foundSprite = false; @@ -385,7 +385,7 @@ void ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Co if (i->_zorder == zorder) { i->_animId = animId; i->_pos = pos; - return; + return &(*i); } // otherwise, take a copy and remove it from the list @@ -403,7 +403,7 @@ void ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Co sprite._id = id; if (!initSprite(sprite)) { warning("ignoring addSprite on invalid sprite %d", id); - return; + return NULL; } } @@ -412,9 +412,11 @@ void ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Co continue; // insert *before* this sprite _sprites.insert(i, sprite); - return; + --i; + return &(*i); } _sprites.push_back(sprite); + return &_sprites.back(); } void ComposerEngine::removeSprite(uint16 id, uint16 animId) { @@ -453,7 +455,7 @@ void ComposerEngine::redraw() { _needsUpdate = false; } -void ComposerEngine::loadCTBL(uint id, uint fadePercent) { +void ComposerEngine::loadCTBL(uint16 id, uint fadePercent) { Common::SeekableReadStream *stream = getResource(ID_CTBL, id); uint16 numEntries = stream->readUint16LE(); @@ -472,6 +474,22 @@ void ComposerEngine::loadCTBL(uint id, uint fadePercent) { _system->getPaletteManager()->setPalette(buffer, 0, numEntries); } +void ComposerEngine::setBackground(uint16 id) { + for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) { + if (i->_id) + continue; + i->_surface.free(); + i->_id = id; + initSprite(*i); + i->_id = 0; + return; + } + + Sprite *background = addSprite(id, 0, 0xffff, Common::Point()); + if (background) + background->_id = 0; +} + static void decompressSLWM(byte *buffer, Common::SeekableReadStream *stream) { uint bitsLeft = 0; uint16 lastBits; diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp index ba1cdd7c74..f52ed3ea43 100644 --- a/engines/composer/scripting.cpp +++ b/engines/composer/scripting.cpp @@ -652,10 +652,10 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 _vars[param2] = _lastMousePos.y; return 0; case kFuncChangeBackground: - // TODO - warning("ignoring kFuncChangeBackground(%d)", param1); + debug(3, "kFuncChangeBackground(%d)", param1); // TODO: return 1 if background existed, else 0 - return 0; + setBackground(param1); + return 1; case kFuncSetBackgroundColor: // TODO warning("ignoring kFuncSetBackgroundColor(%d)", param1); |