aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2011-11-04 22:38:33 +0100
committerAlyssa Milburn2011-11-04 22:38:33 +0100
commit1c1eed784a0eb029b5db75aecf4cfed1c4e80e83 (patch)
treec5da5b2a76a91848fd8fad117b19205e42befb60
parentdbbfca37a2e99ee350a1b70ce8ee9728988b0b85 (diff)
downloadscummvm-rg350-1c1eed784a0eb029b5db75aecf4cfed1c4e80e83.tar.gz
scummvm-rg350-1c1eed784a0eb029b5db75aecf4cfed1c4e80e83.tar.bz2
scummvm-rg350-1c1eed784a0eb029b5db75aecf4cfed1c4e80e83.zip
COMPOSER: Add support for V1 pipes.
-rw-r--r--engines/composer/graphics.cpp1
-rw-r--r--engines/composer/resource.cpp61
-rw-r--r--engines/composer/resource.h19
3 files changed, 79 insertions, 2 deletions
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp
index ced7073f10..6f9aa76be8 100644
--- a/engines/composer/graphics.cpp
+++ b/engines/composer/graphics.cpp
@@ -125,6 +125,7 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP
if (type != 1) {
newPipe = new Pipe(stream);
_pipes.push_front(newPipe);
+ newPipe->nextFrame();
stream = newPipe->getResource(ID_ANIM, animId, false);
}
}
diff --git a/engines/composer/resource.cpp b/engines/composer/resource.cpp
index b40bdb379b..ce2661f0d0 100644
--- a/engines/composer/resource.cpp
+++ b/engines/composer/resource.cpp
@@ -252,8 +252,10 @@ Pipe::Pipe(Common::SeekableReadStream *stream) {
_offset = 0;
_stream = stream;
_anim = NULL;
+}
- nextFrame();
+Pipe::~Pipe() {
+ delete _stream;
}
void Pipe::nextFrame() {
@@ -334,4 +336,61 @@ 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) {
+ uint32 tag = _stream->readUint32BE();
+ if (tag != ID_PIPE)
+ error("invalid tag for pipe (%08x)", tag);
+
+ _numFrames = _stream->readUint32LE();
+ uint16 scriptCount = _stream->readUint16LE();
+ _scripts.reserve(scriptCount);
+ for (uint i = 0; i < scriptCount; i++)
+ _scripts.push_back(_stream->readUint16LE());
+
+ _offset = _stream->pos();
+}
+
+void OldPipe::nextFrame() {
+ if (_currFrame >= _numFrames)
+ return;
+
+ _stream->seek(_offset, SEEK_SET);
+
+ uint32 tag = _stream->readUint32BE();
+ if (tag != ID_FRME)
+ error("invalid tag for pipe (%08x)", tag);
+
+ uint16 spriteCount = _stream->readUint16LE();
+ uint32 spriteSize = _stream->readUint32LE();
+ uint32 audioSize = _stream->readUint32LE();
+
+ Common::Array<uint16> spriteIds;
+ Common::Array<PipeResourceEntry> spriteEntries;
+ for (uint i = 0; i < spriteCount; i++) {
+ spriteIds.push_back(_stream->readUint16LE());
+ PipeResourceEntry entry;
+ entry.size = _stream->readUint32LE();
+ entry.offset = _stream->readUint32LE();
+ spriteEntries.push_back(entry);
+ }
+
+ uint32 spriteDataOffset = _stream->pos();
+ _stream->skip(spriteSize);
+
+ ResourceMap &spriteResMap = _types[ID_BMAP];
+ spriteResMap.clear();
+ for (uint i = 0; i < spriteIds.size(); i++) {
+ PipeResourceEntry &entry = spriteEntries[i];
+ entry.offset += spriteDataOffset;
+ spriteResMap[spriteIds[i]].entries.push_back(entry);
+ }
+
+ // FIXME
+ uint32 audioDataOffset = _stream->pos();
+ _stream->skip(audioSize);
+
+ _offset = _stream->pos();
+ _currFrame++;
+}
+
} // End of namespace Composer
diff --git a/engines/composer/resource.h b/engines/composer/resource.h
index 9408cdffb8..e2ce23511f 100644
--- a/engines/composer/resource.h
+++ b/engines/composer/resource.h
@@ -45,6 +45,8 @@ struct Animation;
#define ID_VARI MKTAG('V','A','R','I') // Variables
#define ID_WAVE MKTAG('W','A','V','E') // Wave
+#define ID_FRME MKTAG('F','R','M','E') // Frame
+
class Archive {
public:
Archive();
@@ -102,13 +104,16 @@ struct PipeResource {
class Pipe {
public:
Pipe(Common::SeekableReadStream *stream);
- void nextFrame();
+ virtual ~Pipe();
+ virtual void nextFrame();
Animation *_anim;
bool hasResource(uint32 tag, uint16 id) const;
Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
+ virtual const Common::Array<uint16> *getScripts() { return NULL; }
+
protected:
Common::SeekableReadStream *_stream;
@@ -119,6 +124,18 @@ protected:
uint32 _offset;
};
+class OldPipe : public Pipe {
+public:
+ OldPipe(Common::SeekableReadStream *stream);
+ void nextFrame();
+
+ const Common::Array<uint16> *getScripts() { return &_scripts; }
+
+protected:
+ uint32 _currFrame, _numFrames;
+ Common::Array<uint16> _scripts;
+};
+
} // End of namespace Composer
#endif