diff options
author | Iskrich | 2016-05-26 21:05:34 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 5718268106a463a2f58af92856f1ceb72ad4f3cb (patch) | |
tree | dfaebba3ca4669f62b4b8237cf46b023b0f91250 /engines/director | |
parent | 60348aa02a95154f6a0b36b9a9097b4255c85888 (diff) | |
download | scummvm-rg350-5718268106a463a2f58af92856f1ceb72ad4f3cb.tar.gz scummvm-rg350-5718268106a463a2f58af92856f1ceb72ad4f3cb.tar.bz2 scummvm-rg350-5718268106a463a2f58af92856f1ceb72ad4f3cb.zip |
DIRECTOR: Load cast data and movie config
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/director.cpp | 7 | ||||
-rw-r--r-- | engines/director/score.cpp | 134 | ||||
-rw-r--r-- | engines/director/score.h | 62 |
3 files changed, 198 insertions, 5 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 5c2c7adc6d..ff294a7db5 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -72,6 +72,13 @@ Common::Error DirectorEngine::run() { Common::SeekableReadStream *scr = _mainArchive->getResource(MKTAG('V','W','S','C'), 1024); Score score(*scr); + + Common::SeekableReadStream *conf = _mainArchive->getResource(MKTAG('V','W','C','F'), 1024); + score.loadConfig(*conf); + + Common::SeekableReadStream *records = _mainArchive->getResource(MKTAG('V','W','C','R'), 1024); + score.loadCastData(*records); + score.play(); if (getPlatform() == Common::kPlatformWindows) diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 733e96a2f9..c83ff5a168 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -61,12 +61,146 @@ Score::Score(Common::SeekableReadStream &stream) { _frames.remove_at(0); } +void Score::loadConfig(Common::SeekableReadStream &stream) { + /*uint16 unk1 = */ stream.readUint16BE(); + /*ver1 = */ stream.readUint16BE(); + _movieRect.top = stream.readUint16BE(); + _movieRect.left = stream.readUint16BE(); + _movieRect.bottom = stream.readUint16BE(); + _movieRect.right = stream.readUint16BE(); + + _castArrayStart = stream.readUint16BE(); + _castArrayEnd = stream.readUint16BE(); + _initialFrameRate = stream.readByte(); + stream.skip(9); + /*uint16 stageColor = */ stream.readUint16BE(); +} + void Score::readVersion(uint32 rid) { _versionMinor = rid & 0xffff; _versionMajor = rid >> 16; debug("%d.%d", _versionMajor, _versionMinor); } +void Score::loadCastData(Common::SeekableReadStream &stream) { + for (uint16 id = _castArrayStart; id < _castArrayEnd; id++) { + byte size = stream.readByte(); + if (size > 0) { + debug("%d", stream.pos()); + uint8 castType = stream.readByte(); + switch (castType) { + case kCastBitmap: + _casts[id] = getBitmapCast(stream); + _casts[id]->type = kCastBitmap; + break; + case kCastText: + _casts[id] = getTextCast(stream); + _casts[id]->type = kCastText; + break; + case kCastShape: + _casts[id] = getShapeCast(stream); + _casts[id]->type = kCastShape; + break; + case kCastButton: + _casts[id] = getButtonCast(stream); + _casts[id]->type = kCastButton; + break; + default: + warning("Unhandled cast type: %d", castType); + stream.skip(size - 1); + break; + } + } + } +} + +BitmapCast *Score::getBitmapCast(Common::SeekableReadStream &stream) { + BitmapCast *cast = new BitmapCast(); + /*byte flags = */ stream.readByte(); + /*uint16 someFlaggyThing = */ stream.readUint16BE(); + + cast->initialRect.top = stream.readUint16BE(); + cast->initialRect.left = stream.readUint16BE(); + cast->initialRect.bottom = stream.readUint16BE(); + cast->initialRect.right = stream.readUint16BE(); + + cast->boundingRect.top = stream.readUint16BE(); + cast->boundingRect.left = stream.readUint16BE(); + cast->boundingRect.bottom = stream.readUint16BE(); + cast->boundingRect.right = stream.readUint16BE(); + + cast->regX = stream.readUint16BE(); + cast->regY = stream.readUint16BE(); + /*uint16 unk1 =*/ stream.readUint16BE(); + /*uint16 unk2 =*/ stream.readUint16BE(); + return cast; +} + +TextCast *Score::getTextCast(Common::SeekableReadStream &stream) { + TextCast *cast = new TextCast(); + /*byte flags =*/ stream.readByte(); + cast->borderSize = stream.readByte(); + cast->gutterSize = stream.readByte(); + cast->boxShadow = stream.readByte(); + cast->textType = stream.readByte(); + cast->textAlign = stream.readUint16BE(); + stream.skip(6); //palinfo + /*uint32 unk1 = */ stream.readUint32BE(); + + cast->initialRect.top = stream.readUint16BE(); + cast->initialRect.left = stream.readUint16BE(); + cast->initialRect.bottom = stream.readUint16BE(); + cast->initialRect.right = stream.readUint16BE(); + + cast->textShadow = stream.readByte(); + cast->textFlags = stream.readByte(); + /*uint16 unk2 =*/ stream.readUint16BE(); + return cast; +} + +ShapeCast *Score::getShapeCast(Common::SeekableReadStream &stream) { + ShapeCast *cast = new ShapeCast(); + /*byte flags = */ stream.readByte(); + /*unk1 = */ stream.readByte(); + cast->shapeType = stream.readByte(); + + cast->initialRect.top = stream.readUint16BE(); + cast->initialRect.left = stream.readUint16BE(); + cast->initialRect.bottom = stream.readUint16BE(); + cast->initialRect.right = stream.readUint16BE(); + + cast->pattern = stream.readUint16BE(); + cast->fgCol = stream.readByte(); + cast->bgCol = stream.readByte(); + cast->fillType = stream.readByte(); + cast->lineThickness = stream.readByte(); + cast->lineDirection = stream.readByte(); + return cast; +} + +ButtonCast *Score::getButtonCast(Common::SeekableReadStream &stream) { + ButtonCast *cast = new ButtonCast(); + /*byte flags =*/ stream.readByte(); + cast->borderSize = stream.readByte(); + cast->gutterSize = stream.readByte(); + cast->boxShadow = stream.readByte(); + cast->textType = stream.readByte(); + cast->textAlign = stream.readUint16BE(); + stream.skip(6); //palinfo + /*uint32 unk1 = */ stream.readUint32BE(); + + cast->initialRect.top = stream.readUint16BE(); + cast->initialRect.left = stream.readUint16BE(); + cast->initialRect.bottom = stream.readUint16BE(); + cast->initialRect.right = stream.readUint16BE(); + + cast->textShadow = stream.readByte(); + cast->textFlags = stream.readByte(); + /*uint16 unk2 =*/ stream.readUint16BE(); + cast->buttonType = stream.readUint16BE(); + return cast; +} + void Score::play() { initGraphics(800, 800, true); uint32 frameId = 0; diff --git a/engines/director/score.h b/engines/director/score.h index fe09b1c504..e35b7425d4 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -70,6 +70,45 @@ enum mainChannelsPosition { kPaletePosition = 15 }; +struct Cast { + castType type; + Common::Rect initialRect; +}; + +struct BitmapCast : Cast { + Common::Rect boundingRect; + uint16 regX; + uint16 regY; + uint8 flags; +}; + +struct ShapeCast : Cast { + byte shapeType; + uint16 pattern; + byte fgCol; + byte bgCol; + byte fillType; + byte lineThickness; + byte lineDirection; +}; + +struct TextCast : Cast { + byte borderSize; + byte gutterSize; + byte boxShadow; + + byte textType; + byte textAlign; + byte textShadow; + byte textFlags; +}; + +struct ButtonCast : TextCast { + //TODO types? + uint16 buttonType; +}; + + class Sprite { public: Sprite(); @@ -115,16 +154,29 @@ public: class Score { public: + Score(Common::SeekableReadStream &stream); + void readVersion(uint32 rid); + void loadConfig(Common::SeekableReadStream &stream); + void loadCastData(Common::SeekableReadStream &stream); + void play(); + +private: + BitmapCast *getBitmapCast(Common::SeekableReadStream &stream); + TextCast *getTextCast(Common::SeekableReadStream &stream); + ButtonCast *getButtonCast(Common::SeekableReadStream &stream); + ShapeCast *getShapeCast(Common::SeekableReadStream &stream); + +public: Common::Array<Frame *> _frames; + Common::HashMap<int, Cast *> _casts; private: uint16 _versionMinor; uint16 _versionMajor; - -public: - Score(Common::SeekableReadStream &stream); - void readVersion(uint32 rid); - void play(); + byte _initialFrameRate; + uint16 _castArrayStart; + uint16 _castArrayEnd; + Common::Rect _movieRect; }; } //End of namespace Director |