diff options
author | upthorn | 2012-05-25 23:42:07 -0700 |
---|---|---|
committer | angstsmurf | 2016-10-18 02:08:53 +0200 |
commit | 2b58f42b8c35e002a19acd60755ef2c62d32a042 (patch) | |
tree | 8e77d921ebb168e014c11ab287b84a02c50e978d /engines/composer | |
parent | 529a82a50a299e80bca5553b66c4796c88582471 (diff) | |
download | scummvm-rg350-2b58f42b8c35e002a19acd60755ef2c62d32a042.tar.gz scummvm-rg350-2b58f42b8c35e002a19acd60755ef2c62d32a042.tar.bz2 scummvm-rg350-2b58f42b8c35e002a19acd60755ef2c62d32a042.zip |
COMPOSER: Continued work on saving/loading functionality.
Diffstat (limited to 'engines/composer')
-rw-r--r-- | engines/composer/graphics.cpp | 10 | ||||
-rw-r--r-- | engines/composer/resource.cpp | 5 | ||||
-rw-r--r-- | engines/composer/resource.h | 12 | ||||
-rw-r--r-- | engines/composer/saveload.cpp | 73 |
4 files changed, 82 insertions, 18 deletions
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp index 87694636d8..b69e09d9bf 100644 --- a/engines/composer/graphics.cpp +++ b/engines/composer/graphics.cpp @@ -44,9 +44,9 @@ bool Sprite::contains(const Common::Point &pos) const { } enum { - kAnimOpEvent = 1, - kAnimOpPlayWave = 2, - kAnimOpPlayAnim = 3, + kAnimOpEvent = 1, + kAnimOpPlayWave = 2, + kAnimOpPlayAnim = 3, kAnimOpDrawSprite = 4 }; @@ -124,7 +124,7 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP // and then fish the requested animation out of it. if (type != 1) { _pipeStreams.push_back(stream); - newPipe = new Pipe(stream); + newPipe = new Pipe(stream, animId); _pipes.push_front(newPipe); newPipe->nextFrame(); stream = newPipe->getResource(ID_ANIM, animId, false); @@ -376,7 +376,7 @@ void ComposerEngine::playPipe(uint16 id) { } Common::SeekableReadStream *stream = getResource(ID_PIPE, id); - OldPipe *pipe = new OldPipe(stream); + OldPipe *pipe = new OldPipe(stream, id); _pipes.push_front(pipe); //pipe->nextFrame(); diff --git a/engines/composer/resource.cpp b/engines/composer/resource.cpp index d867f734a9..3e787cc766 100644 --- a/engines/composer/resource.cpp +++ b/engines/composer/resource.cpp @@ -248,10 +248,11 @@ bool ComposerArchive::openStream(Common::SeekableReadStream *stream) { return true; } -Pipe::Pipe(Common::SeekableReadStream *stream) { +Pipe::Pipe(Common::SeekableReadStream *stream, uint16 pipeId) { _offset = 0; _stream = stream; _anim = NULL; + _pipeId = pipeId; } Pipe::~Pipe() { @@ -335,7 +336,7 @@ Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffer return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); } -OldPipe::OldPipe(Common::SeekableReadStream *stream) : Pipe(stream), _currFrame(0) { +OldPipe::OldPipe(Common::SeekableReadStream *stream, uint16 pipeId) : Pipe(stream, pipeId), _currFrame(0) { uint32 tag = _stream->readUint32BE(); if (tag != ID_PIPE) error("invalid tag for pipe (%08x)", tag); diff --git a/engines/composer/resource.h b/engines/composer/resource.h index b624da1776..52748bacd2 100644 --- a/engines/composer/resource.h +++ b/engines/composer/resource.h @@ -106,7 +106,7 @@ struct PipeResource { class Pipe { public: - Pipe(Common::SeekableReadStream *stream); + Pipe(Common::SeekableReadStream *stream, uint16 pipeId); virtual ~Pipe(); virtual void nextFrame(); @@ -116,6 +116,11 @@ public: Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering); virtual const Common::Array<uint16> *getScripts() { return NULL; } +#ifdef SAVING_ANYWHERE + uint16 id() const { return _pipeId; } + uint32 offset() const { return _offset; } + void setOffset(uint32 offset) { while (_offset < offset) nextFrame(); } +#endif protected: Common::SeekableReadStream *_stream; @@ -123,13 +128,16 @@ protected: typedef Common::HashMap<uint16, PipeResource> ResourceMap; typedef Common::HashMap<uint32, ResourceMap> TypeMap; TypeMap _types; +#ifdef SAVING_ANYWHERE + uint16 _pipeId; +#endif uint32 _offset; }; class OldPipe : public Pipe { public: - OldPipe(Common::SeekableReadStream *stream); + OldPipe(Common::SeekableReadStream *stream, uint16 pipeId); void nextFrame(); const Common::Array<uint16> *getScripts() { return &_scripts; } diff --git a/engines/composer/saveload.cpp b/engines/composer/saveload.cpp index 6922452ddd..c9437d230d 100644 --- a/engines/composer/saveload.cpp +++ b/engines/composer/saveload.cpp @@ -54,11 +54,6 @@ Common::Error ComposerEngine::loadGameState(int slot) { } _anims.clear(); - for (Common::List<Pipe *>::iterator i = _pipes.begin(); i != _pipes.end(); i++) { - delete *i; - } - _pipes.clear(); - ser.syncVersion(0); Common::String desc; ser.syncString(desc); @@ -85,7 +80,20 @@ Common::Error ComposerEngine::loadGameState(int slot) { ser.syncAsUint16LE(id); Sprite sprite; sprite._id = id; - initSprite(sprite); + ser.syncAsSint16LE(sprite._pos.x); + ser.syncAsSint16LE(sprite._pos.y); + ser.syncAsUint16LE(sprite._surface.w); + ser.syncAsUint16LE(sprite._surface.h); + ser.syncAsUint16LE(sprite._surface.pitch); + ser.syncAsUint16LE(sprite._zorder); + sprite._surface.pixels = malloc(sprite._surface.h * sprite._surface.pitch); + byte *dest = static_cast<byte *>(sprite._surface.pixels); + for (uint16 y = 0; y < sprite._surface.h; y++) { + for (uint16 x = 0; x < sprite._surface.w; x++) { + ser.syncAsByte(dest[x]); + } + dest += sprite._surface.pitch; + } _sprites.push_back(sprite); } @@ -141,12 +149,35 @@ Common::Error ComposerEngine::loadGameState(int slot) { ser.syncAsUint16LE(qTmp._scriptId); _queuedScripts.push_back(qTmp); } - + ser.syncAsSint16LE(_lastMousePos.x); + ser.syncAsSint16LE(_lastMousePos.y); ser.syncAsByte(_mouseEnabled); ser.syncAsByte(_mouseVisible); ser.syncAsUint16LE(_mouseSpriteId); _dirtyRects.clear(); + for (Common::List<Pipe *>::iterator i = _pipes.begin(); i != _pipes.end(); i++) { + delete *i; + } + _pipes.clear(); + for (Common::Array<Common::SeekableReadStream *>::iterator i = _pipeStreams.begin(); i != _pipeStreams.end(); i++) { + delete *i; + } + _pipeStreams.clear(); + + ser.syncAsUint32LE(tmp); + for (uint32 i = tmp; i > 0; i--) { + uint16 id; + uint32 offset; + ser.syncAsUint16LE(id); + ser.syncAsUint32LE(offset); + Common::SeekableReadStream *stream = getResource(ID_ANIM, id); + Pipe *pipe = new Pipe(stream, id); + pipe->setOffset(offset); + _pipes.push_back(pipe); + _pipeStreams.push_back(stream); + } + _dirtyRects.push_back(Common::Rect(0, 0, 640, 480)); byte palbuf[256 * 3]; ser.syncBytes(palbuf, 256 * 3); @@ -182,8 +213,21 @@ Common::Error ComposerEngine::saveGameState(int slot, const Common::String &desc tmp = _sprites.size(); ser.syncAsUint32LE(tmp); for (Common::List<Sprite>::const_iterator i = _sprites.begin(); i != _sprites.end(); i++) { - uint16 tmp = (*i)._id; - ser.syncAsUint16LE(tmp); + Sprite sprite(*i); + ser.syncAsUint16LE(sprite._id); + ser.syncAsSint16LE(sprite._pos.x); + ser.syncAsSint16LE(sprite._pos.y); + ser.syncAsUint16LE(sprite._surface.w); + ser.syncAsUint16LE(sprite._surface.h); + ser.syncAsUint16LE(sprite._surface.pitch); + ser.syncAsUint16LE(sprite._zorder); + byte *src = static_cast<byte *>((*i)._surface.pixels); + for (uint16 y = 0; y < sprite._surface.h; y++) { + for (uint x = 0; x < sprite._surface.w; x++) { + ser.syncAsByte(src[x]); + } + src += (*i)._surface.pitch; + } } tmp = _pendingPageChanges.size(); ser.syncAsUint32LE(tmp); @@ -228,10 +272,21 @@ Common::Error ComposerEngine::saveGameState(int slot, const Common::String &desc ser.syncAsUint32LE(tmp); ser.syncAsUint16LE(tmp16); } + ser.syncAsSint16LE(_lastMousePos.x); + ser.syncAsSint16LE(_lastMousePos.y); ser.syncAsByte(_mouseEnabled); ser.syncAsByte(_mouseVisible); ser.syncAsUint16LE(_mouseSpriteId); + tmp = _pipes.size(); + ser.syncAsUint32LE(tmp); + for (Common::List<Pipe *>::const_iterator i = _pipes.begin(); i != _pipes.end(); i++) { + uint16 tmp16 = (*i)->id(); + tmp = (*i)->offset(); + ser.syncAsUint16LE(tmp16); + ser.syncAsUint32LE(tmp); + } + byte palbuf[256 * 3]; _system->getPaletteManager()->grabPalette(palbuf, 0, 256); ser.syncBytes(palbuf, 256 * 3); |