diff options
author | Eugene Sandulenko | 2016-11-08 23:41:43 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-11-08 23:41:43 +0100 |
commit | 3291a9761cf43e67fe0d085ac63fd89b46367765 (patch) | |
tree | 533cc27c8d2b67aa2d9dc62b91145f2fdb89dec6 /engines | |
parent | 25a233339439ed2cdf6b52f82c57f1adaa59e0bc (diff) | |
download | scummvm-rg350-3291a9761cf43e67fe0d085ac63fd89b46367765.tar.gz scummvm-rg350-3291a9761cf43e67fe0d085ac63fd89b46367765.tar.bz2 scummvm-rg350-3291a9761cf43e67fe0d085ac63fd89b46367765.zip |
DIRECTOR: Implement D4 CASt member parsing stub
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/cast.cpp | 133 | ||||
-rw-r--r-- | engines/director/cast.h | 16 | ||||
-rw-r--r-- | engines/director/resource.cpp | 2 | ||||
-rw-r--r-- | engines/director/score.cpp | 70 | ||||
-rw-r--r-- | engines/director/score.h | 4 |
5 files changed, 139 insertions, 86 deletions
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index e0d0603ca0..2e4e2c9c3f 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -28,66 +28,103 @@ namespace Director { -BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) { - flags = stream.readByte(); - someFlaggyThing = stream.readUint16(); - initialRect = Score::readRect(stream); - boundingRect = Score::readRect(stream); - regY = stream.readUint16(); - regX = stream.readUint16(); - unk1 = unk2 = 0; +BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint16 version) { + if (version < 4) { + flags = stream.readByte(); + someFlaggyThing = stream.readUint16(); + initialRect = Score::readRect(stream); + boundingRect = Score::readRect(stream); + regY = stream.readUint16(); + regX = stream.readUint16(); + unk1 = unk2 = 0; - if (someFlaggyThing & 0x8000) { - unk1 = stream.readUint16(); - unk2 = stream.readUint16(); + if (someFlaggyThing & 0x8000) { + unk1 = stream.readUint16(); + unk2 = stream.readUint16(); + } + } else { + initialRect = Score::readRect(stream); + boundingRect = Score::readRect(stream); + regX = 0; // FIXME: HACK + regY = 0; // FIXME: HACK } modified = 0; } -TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) { - flags1 = stream.readByte(); - borderSize = static_cast<SizeType>(stream.readByte()); - gutterSize = static_cast<SizeType>(stream.readByte()); - boxShadow = static_cast<SizeType>(stream.readByte()); - textType = static_cast<TextType>(stream.readByte()); - textAlign = static_cast<TextAlignType>(stream.readUint16()); - palinfo1 = stream.readUint16(); - palinfo2 = stream.readUint16(); - palinfo3 = stream.readUint16(); +TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { + if (version < 4) { + flags1 = stream.readByte(); + borderSize = static_cast<SizeType>(stream.readByte()); + gutterSize = static_cast<SizeType>(stream.readByte()); + boxShadow = static_cast<SizeType>(stream.readByte()); + textType = static_cast<TextType>(stream.readByte()); + textAlign = static_cast<TextAlignType>(stream.readUint16()); + palinfo1 = stream.readUint16(); + palinfo2 = stream.readUint16(); + palinfo3 = stream.readUint16(); - int t = stream.readUint32(); - assert(t == 0); // So far we saw only 0 here + int t = stream.readUint32(); + assert(t == 0); // So far we saw only 0 here - initialRect = Score::readRect(stream); - textShadow = static_cast<SizeType>(stream.readByte()); - byte flags = stream.readByte(); - if (flags & 0x1) - textFlags.push_back(kTextFlagEditable); - if (flags & 0x2) - textFlags.push_back(kTextFlagAutoTab); - if (flags & 0x4) - textFlags.push_back(kTextFlagDoNotWrap); - if (flags & 0xf8) - warning("Unproxessed text cast flags: %x", flags & 0xf8); + initialRect = Score::readRect(stream); + textShadow = static_cast<SizeType>(stream.readByte()); + byte flags = stream.readByte(); + if (flags & 0x1) + textFlags.push_back(kTextFlagEditable); + if (flags & 0x2) + textFlags.push_back(kTextFlagAutoTab); + if (flags & 0x4) + textFlags.push_back(kTextFlagDoNotWrap); + if (flags & 0xf8) + warning("Unproxessed text cast flags: %x", flags & 0xf8); - // TODO: FIXME: guesswork - fontId = stream.readByte(); - fontSize = stream.readByte(); + // TODO: FIXME: guesswork + fontId = stream.readByte(); + fontSize = stream.readByte(); + } else { + initialRect = Score::readRect(stream); + //boundingRect = Score::readRect(stream); + } + + modified = 0; +} + +ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) { + if (version < 4) { + /*byte flags = */ stream.readByte(); + /*unk1 = */ stream.readByte(); + shapeType = static_cast<ShapeType>(stream.readByte()); + initialRect = Score::readRect(stream); + pattern = stream.readUint16BE(); + fgCol = stream.readByte(); + bgCol = stream.readByte(); + fillType = stream.readByte(); + lineThickness = stream.readByte(); + lineDirection = stream.readByte(); + } else { + initialRect = Score::readRect(stream); + //boundingRect = Score::readRect(stream); + } + modified = 0; +} +ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextCast(stream, version) { + if (version < 4) { + buttonType = static_cast<ButtonType>(stream.readUint16BE()); + } else { + initialRect = Score::readRect(stream); + //boundingRect = Score::readRect(stream); + } modified = 0; } -ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) { - /*byte flags = */ stream.readByte(); - /*unk1 = */ stream.readByte(); - shapeType = static_cast<ShapeType>(stream.readByte()); - initialRect = Score::readRect(stream); - pattern = stream.readUint16BE(); - fgCol = stream.readByte(); - bgCol = stream.readByte(); - fillType = stream.readByte(); - lineThickness = stream.readByte(); - lineDirection = stream.readByte(); +ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) { + if (version < 4) { + error("Unhandled Script cast"); + } else { + initialRect = Score::readRect(stream); + //boundingRect = Score::readRect(stream); + } modified = 0; } diff --git a/engines/director/cast.h b/engines/director/cast.h index 96ad87947f..82651a757f 100644 --- a/engines/director/cast.h +++ b/engines/director/cast.h @@ -49,7 +49,7 @@ struct Cast { }; struct BitmapCast : Cast { - BitmapCast(Common::SeekableSubReadStreamEndian &stream); + BitmapCast(Common::ReadStreamEndian &stream, uint16 version = 2); Common::Rect boundingRect; uint16 regX; @@ -67,7 +67,7 @@ enum ShapeType { }; struct ShapeCast : Cast { - ShapeCast(Common::SeekableSubReadStreamEndian &stream); + ShapeCast(Common::ReadStreamEndian &stream, uint16 version = 2); ShapeType shapeType; uint16 pattern; @@ -106,7 +106,7 @@ enum SizeType { }; struct TextCast : Cast { - TextCast(Common::SeekableSubReadStreamEndian &stream); + TextCast(Common::ReadStreamEndian &stream, uint16 version = 2); SizeType borderSize; SizeType gutterSize; @@ -129,13 +129,17 @@ enum ButtonType { }; struct ButtonCast : TextCast { - ButtonCast(Common::SeekableSubReadStreamEndian &stream) : TextCast(stream) { - buttonType = static_cast<ButtonType>(stream.readUint16BE()); - } + ButtonCast(Common::ReadStreamEndian &stream, uint16 version = 2); ButtonType buttonType; }; +struct ScriptCast : Cast { + ScriptCast(Common::ReadStreamEndian &stream, uint16 version = 2); +}; + + + struct CastInfo { Common::String script; Common::String name; diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp index bcf5db61bc..54ab2198e1 100644 --- a/engines/director/resource.cpp +++ b/engines/director/resource.cpp @@ -212,7 +212,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { castScore->loadConfig(*shardcst->getResource(MKTAG('V','W','C','F'), 1024)); if (getVersion() < 4) - castScore->loadCastDataD2(*shardcst->getResource(MKTAG('V','W','C','R'), 1024)); + castScore->loadCastDataVWCR(*shardcst->getResource(MKTAG('V','W','C','R'), 1024)); Common::Array<uint16> cast = shardcst->getResourceIDList(MKTAG('C','A','S','t')); if (cast.size() > 0) { diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 407a671a45..f2cd673480 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -193,7 +193,7 @@ void Score::loadArchive() { if (_vm->getVersion() < 4) { assert(_movieArchive->hasResource(MKTAG('V','W','C','R'), 1024)); - loadCastDataD2(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024)); + loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024)); } if (_movieArchive->hasResource(MKTAG('V','W','A','C'), 1024)) { @@ -348,8 +348,8 @@ void Score::readVersion(uint32 rid) { debug("Version: %d.%d", _versionMajor, _versionMinor); } -void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) { - debugC(1, kDebugLoading, "Score::loadCastData(). start: %d, end: %d", _castArrayStart, _castArrayEnd); +void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { + debugC(1, kDebugLoading, "Score::loadCastDataVWCR(). start: %d, end: %d", _castArrayStart, _castArrayEnd); for (uint16 id = _castArrayStart; id <= _castArrayEnd; id++) { byte size = stream.readByte(); @@ -376,7 +376,7 @@ void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) { _casts[id]->type = kCastButton; break; default: - warning("Unhandled cast type: %d", castType); + warning("Score::loadCastDataVWCR(): Unhandled cast type: %d", castType); stream.skip(size - 1); break; } @@ -393,17 +393,17 @@ void Score::loadCastDataD2(Common::SeekableSubReadStreamEndian &stream) { } } -void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 castId) { +void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id) { // d4+ variant if (stream.size() == 0) return; if (stream.size() < 26) { - warning("CAST data id %d is too small", castId); + warning("CAST data id %d is too small", id); return; } - debugC(3, kDebugLoading, "CASt: id: %d", castId); + debugC(3, kDebugLoading, "CASt: id: %d", id); if (debugChannelSet(5, kDebugLoading)) stream.hexdump(stream.size()); @@ -428,43 +428,52 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 cas blob[0] = blob[1] = blob[2] = 0; } - debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d", castId, castType, size1, size2, size2, size3); + debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d", id, castType, size1, size2, size2, size3); + + byte *data = (byte *)malloc(size1 + 16); + stream.read(data, size1 + 16); + + Common::MemoryReadStreamEndian castStream(data, size1 + 16, stream.isBE()); -#if 0 switch (castType) { case kCastBitmap: - _casts[id] = new BitmapCast(stream); + warning("CASt: Bitmap"); + Common::hexdump(data, size1 + 16); + _casts[id] = new BitmapCast(castStream, _vm->getVersion()); _casts[id]->type = kCastBitmap; break; case kCastText: - _casts[id] = new TextCast(stream); + warning("CASt: Text"); + Common::hexdump(data, size1 + 16); + _casts[id] = new TextCast(castStream, _vm->getVersion()); _casts[id]->type = kCastText; break; case kCastShape: - _casts[id] = new ShapeCast(stream); + warning("CASt: Shape"); + Common::hexdump(data, size1 + 16); + + _casts[id] = new ShapeCast(castStream, _vm->getVersion()); _casts[id]->type = kCastShape; break; case kCastButton: - _casts[id] = new ButtonCast(stream); + warning("CASt: Button"); + Common::hexdump(data, size1 + 16); + + _casts[id] = new ButtonCast(castStream, _vm->getVersion()); _casts[id]->type = kCastButton; break; + case kCastScript: + warning("CASt: Script"); + Common::hexdump(data, size1 + 16); + + _casts[id] = new ScriptCast(castStream, _vm->getVersion()); + _casts[id]->type = kCastScript; + break; default: - warning("Unhandled cast type: %d", castType); - stream.skip(size - 1); + warning("Score::loadCastData(): Unhandled cast type: %d", castType); break; } -#endif - - Score::readRect(stream); - Score::readRect(stream); - - //member.initialRect = readRect(data) - //member.boundingRect = readRect(data) - //member.regX = 0 // FIXME: HACK - //member.regY = 0 // FIXME: HACK - byte *data = (byte *)malloc(size1); - stream.read(data, size1); free(data); if (size2) { @@ -488,7 +497,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 cas ci->fileName = castStrings[3]; ci->type = castStrings[4]; - _castsInfo[castId] = ci; + _castsInfo[id] = ci; } if (size3) @@ -794,7 +803,10 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn Common::String entryString; for (uint j = entries[i]; j < entries[i + 1]; j++) - entryString += data[j]; + if (data[j] == '\r') + entryString += '\n'; + else + entryString += data[j]; strings.push_back(entryString); } @@ -830,7 +842,7 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) { } } -Common::Rect Score::readRect(Common::SeekableSubReadStreamEndian &stream) { +Common::Rect Score::readRect(Common::ReadStreamEndian &stream) { Common::Rect *rect = new Common::Rect(); rect->top = stream.readUint16(); rect->left = stream.readUint16(); diff --git a/engines/director/score.h b/engines/director/score.h index ca148aff85..9f6088307b 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -55,7 +55,7 @@ public: Score(DirectorEngine *vm, Archive *); ~Score(); - static Common::Rect readRect(Common::SeekableSubReadStreamEndian &stream); + static Common::Rect readRect(Common::ReadStreamEndian &stream); static int compareLabels(const void *a, const void *b); void loadArchive(); void setStartToLabel(Common::String label); @@ -66,7 +66,7 @@ public: void processEvents(); Archive *getArchive() const { return _movieArchive; }; void loadConfig(Common::SeekableSubReadStreamEndian &stream); - void loadCastDataD2(Common::SeekableSubReadStreamEndian &stream); + void loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream); void loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id); void setCurrentFrame(uint16 frameId) { _currentFrame = frameId; } int getCurrentFrame() { return _currentFrame; } |