COMPOSER: Add support for V1 pipes.
This commit is contained in:
parent
dbbfca37a2
commit
1c1eed784a
3 changed files with 79 additions and 2 deletions
|
@ -125,6 +125,7 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP
|
||||||
if (type != 1) {
|
if (type != 1) {
|
||||||
newPipe = new Pipe(stream);
|
newPipe = new Pipe(stream);
|
||||||
_pipes.push_front(newPipe);
|
_pipes.push_front(newPipe);
|
||||||
|
newPipe->nextFrame();
|
||||||
stream = newPipe->getResource(ID_ANIM, animId, false);
|
stream = newPipe->getResource(ID_ANIM, animId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,8 +252,10 @@ Pipe::Pipe(Common::SeekableReadStream *stream) {
|
||||||
_offset = 0;
|
_offset = 0;
|
||||||
_stream = stream;
|
_stream = stream;
|
||||||
_anim = NULL;
|
_anim = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
nextFrame();
|
Pipe::~Pipe() {
|
||||||
|
delete _stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pipe::nextFrame() {
|
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);
|
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
|
} // End of namespace Composer
|
||||||
|
|
|
@ -45,6 +45,8 @@ struct Animation;
|
||||||
#define ID_VARI MKTAG('V','A','R','I') // Variables
|
#define ID_VARI MKTAG('V','A','R','I') // Variables
|
||||||
#define ID_WAVE MKTAG('W','A','V','E') // Wave
|
#define ID_WAVE MKTAG('W','A','V','E') // Wave
|
||||||
|
|
||||||
|
#define ID_FRME MKTAG('F','R','M','E') // Frame
|
||||||
|
|
||||||
class Archive {
|
class Archive {
|
||||||
public:
|
public:
|
||||||
Archive();
|
Archive();
|
||||||
|
@ -102,13 +104,16 @@ struct PipeResource {
|
||||||
class Pipe {
|
class Pipe {
|
||||||
public:
|
public:
|
||||||
Pipe(Common::SeekableReadStream *stream);
|
Pipe(Common::SeekableReadStream *stream);
|
||||||
void nextFrame();
|
virtual ~Pipe();
|
||||||
|
virtual void nextFrame();
|
||||||
|
|
||||||
Animation *_anim;
|
Animation *_anim;
|
||||||
|
|
||||||
bool hasResource(uint32 tag, uint16 id) const;
|
bool hasResource(uint32 tag, uint16 id) const;
|
||||||
Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
|
Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
|
||||||
|
|
||||||
|
virtual const Common::Array<uint16> *getScripts() { return NULL; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Common::SeekableReadStream *_stream;
|
Common::SeekableReadStream *_stream;
|
||||||
|
|
||||||
|
@ -119,6 +124,18 @@ protected:
|
||||||
uint32 _offset;
|
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
|
} // End of namespace Composer
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue