From ddcaad4a11b8b9d542a01d2544283416a03ea80a Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Wed, 15 Jun 2016 19:34:00 +0300 Subject: [PATCH] DIRECTOR: Parse common STXT scripts --- engines/director/score.cpp | 26 +++++++++++++++++++++++++- engines/director/score.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 4cbc4f2cf0f..16f85fc02fd 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -83,13 +83,21 @@ Score::Score(Archive &movie, Lingo &lingo, DirectorSound &soundManager) { loadCastInfo(*_movieArchive->getResource(MKTAG('V','W','C','I'), *iterator), *iterator); } + Common::Array stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); + if (stxt.size() > 0) { + Common::Array::iterator iterator; + for (iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { + loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator)); + } + } + DIBDecoder palette; Common::Array clutList = _movieArchive->getResourceIDList(MKTAG('C','L','U','T')); if (clutList.size() > 1) error("More than one palette was found"); if (clutList.size() == 0) - warning("CLUT not found"); + error("CLUT not found"); Common::SeekableReadStream *pal = _movieArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[0]); palette.loadPalette(*pal); @@ -263,6 +271,22 @@ void Score::loadActions(Common::SeekableReadStream &stream) { } } +void Score::loadScriptText(Common::SeekableReadStream &stream) { + /*uint32 unk1 = */ stream.readUint32BE(); + uint32 strLen = stream.readUint32BE(); + /*uin32 dataLen = */ stream.readUint32BE(); + Common::String script; + for (uint32 i = 0; i < strLen; i++) { + byte ch = stream.readByte(); + if (ch == 0x0d){ + //in old Mac systems \r was the code for end-of-line instead. + ch = '\n'; + } + script += ch; + } + _lingo->addCode(script, kMovieScript, 0); +} + void Score::dumpScript(uint16 id, ScriptType type, Common::String script) { Common::DumpFile out; Common::String typeName; diff --git a/engines/director/score.h b/engines/director/score.h index a05c6bb060e..6156194df43 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -291,6 +291,7 @@ private: void loadLabels(Common::SeekableReadStream &stream); void loadActions(Common::SeekableReadStream &stream); void loadCastInfo(Common::SeekableReadStream &stream, uint16 id); + void loadScriptText(Common::SeekableReadStream &stream); void loadFileInfo(Common::SeekableReadStream &stream); void loadFontMap(Common::SeekableReadStream &stream); void dumpScript(uint16 id, ScriptType type, Common::String script);