Skip to content

Commit

Permalink
DIRECTOR: Parse common STXT scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent 16a2b7e commit ddcaad4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion engines/director/score.cpp
Expand Up @@ -83,13 +83,21 @@ Score::Score(Archive &movie, Lingo &lingo, DirectorSound &soundManager) {
loadCastInfo(*_movieArchive->getResource(MKTAG('V','W','C','I'), *iterator), *iterator);
}

Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T'));
if (stxt.size() > 0) {
Common::Array<uint16>::iterator iterator;
for (iterator = stxt.begin(); iterator != stxt.end(); ++iterator) {
loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator));
}
}

DIBDecoder palette;
Common::Array<uint16> 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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions engines/director/score.h
Expand Up @@ -291,6 +291,7 @@ class Score {
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);
Expand Down

0 comments on commit ddcaad4

Please sign in to comment.