From 4819a4e8572e49a14c83b41312e7f1791408b072 Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Wed, 1 Jun 2016 21:33:23 +0300 Subject: [PATCH] DIRECTOR: Load actions --- engines/director/score.cpp | 37 +++++++++++++++++++++++++++++++++++++ engines/director/score.h | 3 +++ 2 files changed, 40 insertions(+) diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 28aed23cfd9f..7a3e8864e644 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -50,6 +50,10 @@ Score::Score(Archive &movie) { if (_movieArchive->hasResource(MKTAG('V','W','L','B'), 1024)) { loadLabels(*_movieArchive->getResource(MKTAG('V','W','L','B'), 1024)); } + + if (_movieArchive->hasResource(MKTAG('V','W','A','C'), 1024)) { + loadActions(*_movieArchive->getResource(MKTAG('V','W','A','C'), 1024)); + } } void Score::loadFrames(Common::SeekableReadStream &stream) { @@ -166,6 +170,39 @@ void Score::loadLabels(Common::SeekableReadStream &stream) { } } +void Score::loadActions(Common::SeekableReadStream &stream) { + uint16 count = stream.readUint16BE() + 1; + uint16 offset = count * 4 + 2; + + byte id = stream.readByte(); + /*byte subId = */ stream.readByte(); //I couldn't find how it used in continuity (except print). Frame actionId = 1 byte. + uint16 stringPos = stream.readUint16BE() + offset; + + for (uint16 i = 0; i < count; i++) { + + uint16 nextId = stream.readByte(); + /*byte subId = */ stream.readByte(); + uint16 nextStringPos = stream.readUint16BE() + offset; + uint16 streamPos = stream.pos(); + + stream.seek(stringPos); + + for (uint16 j = stringPos; j < nextStringPos; j++) { + _actions[id] += stream.readByte(); + } + + stream.seek(streamPos); + + id = nextId; + stringPos = nextStringPos; + } + + Common::HashMap::iterator j; + for (j = _actions.begin(); j != _actions.end(); ++j) { + debug("Id %d, Script %s", j->_key, j->_value.c_str()); + } +} + BitmapCast::BitmapCast(Common::SeekableReadStream &stream) { /*byte flags = */ stream.readByte(); /*uint16 someFlaggyThing = */ stream.readUint16BE(); diff --git a/engines/director/score.h b/engines/director/score.h index fae6ea8fea37..21756be21246 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -197,10 +197,13 @@ class Score { void loadCastData(Common::SeekableReadStream &stream); void loadFrames(Common::SeekableReadStream &stream); void loadLabels(Common::SeekableReadStream &stream); + void loadActions(Common::SeekableReadStream &stream); + public: Common::Array _frames; Common::HashMap _casts; Common::HashMap _labels; + Common::HashMap _actions; private: uint16 _versionMinor;