[Scummvm-git-logs] scummvm master -> a38011e101af25e68cf9e3c0979794ad904f92c0
djsrv
dservilla at gmail.com
Wed Jun 24 21:02:39 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e9d214f058 DIRECTOR: LINGO: Make script types match Lscr
a38011e101 DIRECTOR: LINGO: Load cast scripts from Lscr
Commit: e9d214f0580187b7c01701b88e7bb69bc21dff9c
https://github.com/scummvm/scummvm/commit/e9d214f0580187b7c01701b88e7bb69bc21dff9c
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-24T16:59:51-04:00
Commit Message:
DIRECTOR: LINGO: Make script types match Lscr
Changed paths:
engines/director/score-loading.cpp
engines/director/types.h
diff --git a/engines/director/score-loading.cpp b/engines/director/score-loading.cpp
index 121d61cda7..20be62bd14 100644
--- a/engines/director/score-loading.cpp
+++ b/engines/director/score-loading.cpp
@@ -43,10 +43,10 @@
namespace Director {
const char *scriptTypes[] = {
- "MovieScript",
+ "ScoreScript",
"CastScript",
- "GlobalScript",
- "ScoreScript"
+ "MovieScript",
+ "GlobalScript"
};
const char *scriptType2str(ScriptType scr) {
diff --git a/engines/director/types.h b/engines/director/types.h
index d9f999e6be..3fe846e847 100644
--- a/engines/director/types.h
+++ b/engines/director/types.h
@@ -43,11 +43,11 @@ enum CastType {
enum ScriptType {
kNoneScript = -1,
- kMovieScript = 0,
- kCastScript = 1,
- kGlobalScript = 2,
- kScoreScript = 3,
- kMaxScriptType = 3 // Sync with score.cpp:45, array scriptTypes[]
+ kScoreScript = 0,
+ kCastScript = 1, // not a canonical ID - change if it's actually used by Director
+ kMovieScript = 2,
+ kGlobalScript = 3, // not a canonical ID
+ kMaxScriptType = 3 // Sync with score-loading.cpp:45, array scriptTypes[]
};
enum ShapeType {
Commit: a38011e101af25e68cf9e3c0979794ad904f92c0
https://github.com/scummvm/scummvm/commit/a38011e101af25e68cf9e3c0979794ad904f92c0
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-24T16:59:51-04:00
Commit Message:
DIRECTOR: LINGO: Load cast scripts from Lscr
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
engines/director/lingo/lingo.h
engines/director/score-loading.cpp
engines/director/score.h
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 80fa99a80b..f6b57dfc23 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -25,6 +25,7 @@
#include "common/substream.h"
#include "director/director.h"
+#include "director/cast.h"
#include "director/score.h"
#include "director/util.h"
#include "director/lingo/lingo.h"
@@ -776,20 +777,7 @@ void LC::cb_zeropush() {
g_lingo->push(d);
}
-void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, const Common::String &scriptName, Common::String &archName) {
- debugC(1, kDebugCompile, "Add V4 bytecode for type %s with id %d", scriptType2str(type), id);
-
- if (getScriptContext(archiveIndex, type, id)) {
- // We can't undefine context data because it could be used in e.g. symbols.
- // Abort on double definitions.
- error("Script already defined for type %d, id %d", id, type);
- return;
- }
-
- _assemblyArchive = archiveIndex;
- _assemblyContext = new ScriptContext(type, !scriptName.empty() ? scriptName : Common::String::format("%d", id));
- _archives[_assemblyArchive].scriptContexts[type][id] = _assemblyContext;
-
+void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, const Common::String &archName) {
if (stream.size() < 0x5c) {
warning("Lscr header too small");
return;
@@ -816,19 +804,21 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
/* uint32 length = */ stream.readUint32();
/* uint32 length2 = */ stream.readUint32();
uint16 codeStoreOffset = stream.readUint16();
- /* uint16 scriptNumber = */ stream.readUint16();
+ /* uint16 lctxIndex = */ stream.readUint16();
// unk2
for (uint32 i = 0; i < 0x10; i++) {
stream.readByte();
}
// offset 36
- /* uint16 scriptNumber2 = */ stream.readUint16();
- /* uint32 scriptType = */ stream.readUint32();
- // unk3
- for (uint32 i = 0; i < 0x8; i++) {
+ /* uint16 unk3 = */ stream.readUint16();
+ uint32 scriptTypeId = stream.readUint32();
+ // unk4
+ for (uint32 i = 0; i < 0x4; i++) {
stream.readByte();
}
+ uint16 castId = stream.readUint16();
+ /* uint16 unk5 = */ stream.readUint16();
// offset 50 - contents map
// TODO: I believe the handler vectors map handlers to some sort of identifier
@@ -846,6 +836,35 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
/* uint16 constsStoreCount = */ stream.readUint32();
uint32 constsStoreOffset = stream.readUint32();
+ // initialise the script
+ ScriptType scriptType = kCastScript;
+ Common::String castName;
+ Cast *member = g_director->getCastMember(castId);
+ if (member) {
+ if (member->_type == kCastLingoScript) {
+ if (scriptTypeId == kScoreScript || scriptTypeId == kMovieScript)
+ scriptType = (ScriptType)scriptTypeId;
+ else
+ warning("Unknown script type: %d", scriptTypeId);
+ }
+ CastInfo *info = member->_score->_castsInfo[castId];
+ if (info)
+ castName = info->name;
+ }
+
+ debugC(1, kDebugCompile, "Add V4 bytecode for type %s with id %d", scriptType2str(scriptType), castId);
+
+ if (getScriptContext(archiveIndex, scriptType, castId)) {
+ // We can't undefine context data because it could be used in e.g. symbols.
+ // Abort on double definitions.
+ error("Script already defined for type %d, id %d", castId, scriptType);
+ return;
+ }
+
+ _assemblyArchive = archiveIndex;
+ _assemblyContext = new ScriptContext(scriptType, !castName.empty() ? castName : Common::String::format("%d", castId));
+ _archives[_assemblyArchive].scriptContexts[scriptType][castId] = _assemblyContext;
+
// initialise each property
if ((uint32)stream.size() < propertiesOffset + propertiesCount * 2) {
warning("Lscr properties store missing");
@@ -1007,7 +1026,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
}
break;
default:
- warning("Unknown constant type %d", type);
+ warning("Unknown constant type %d", constType);
break;
}
@@ -1033,7 +1052,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
bool skipdump = false;
if (ConfMan.getBool("dump_scripts")) {
- Common::String buf = dumpScriptName(archName.c_str(), type, id, "lscr");
+ Common::String buf = dumpScriptName(archName.c_str(), scriptType, castId, "lscr");
if (!out.open(buf)) {
warning("Lingo::addCodeV4(): Can not open dump file %s", buf.c_str());
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 1f0b8e44d7..a2d0781abd 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -371,7 +371,7 @@ public:
void addCode(const char *code, int archiveIndex, ScriptType type, uint16 id, const char *scriptName = nullptr);
ScriptContext *compileAnonymous(const char *code);
- void addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, const Common::String &scriptName, Common::String &archName);
+ void addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, const Common::String &archName);
void addNamesV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex);
void executeHandler(const Common::String &name);
void executeScript(ScriptType type, uint16 id);
diff --git a/engines/director/score-loading.cpp b/engines/director/score-loading.cpp
index 20be62bd14..afc01d5680 100644
--- a/engines/director/score-loading.cpp
+++ b/engines/director/score-loading.cpp
@@ -173,34 +173,6 @@ bool Score::loadArchive(bool isSharedCast) {
debug("STUB: Unhandled 'STR ' resource");
}
- // Try to load script context
- if (_vm->getVersion() >= 4) {
- Common::Array<uint16> lctx = _movieArchive->getResourceIDList(MKTAG('L','c','t','x'));
- if (lctx.size() > 0) {
- debugC(2, kDebugLoading, "****** Loading %d Lctx resources", lctx.size());
-
- for (Common::Array<uint16>::iterator iterator = lctx.begin(); iterator != lctx.end(); ++iterator) {
- loadLingoContext(*(r = _movieArchive->getResource(MKTAG('L','c','t','x'), *iterator)));
- delete r;
- }
- }
- }
-
- // Try to load script name lists
- if (_vm->getVersion() >= 4) {
- Common::Array<uint16> lnam = _movieArchive->getResourceIDList(MKTAG('L','n','a','m'));
- if (lnam.size() > 0) {
-
- int maxLnam = -1;
- for (Common::Array<uint16>::iterator iterator = lnam.begin(); iterator != lnam.end(); ++iterator) {
- maxLnam = MAX(maxLnam, (int)*iterator);
- }
- debugC(2, kDebugLoading, "****** Loading Lnam resource with highest ID (%d)", maxLnam);
- loadLingoNames(*(r = _movieArchive->getResource(MKTAG('L','n','a','m'), maxLnam)));
- delete r;
- }
- }
-
Common::Array<uint16> vwci = _movieArchive->getResourceIDList(MKTAG('V', 'W', 'C', 'I'));
if (vwci.size() > 0) {
debugC(2, kDebugLoading, "****** Loading %d CastInfos VWCI", vwci.size());
@@ -226,6 +198,34 @@ bool Score::loadArchive(bool isSharedCast) {
}
}
+ // Try to load script name lists
+ if (_vm->getVersion() >= 4) {
+ Common::Array<uint16> lnam = _movieArchive->getResourceIDList(MKTAG('L','n','a','m'));
+ if (lnam.size() > 0) {
+
+ int maxLnam = -1;
+ for (Common::Array<uint16>::iterator iterator = lnam.begin(); iterator != lnam.end(); ++iterator) {
+ maxLnam = MAX(maxLnam, (int)*iterator);
+ }
+ debugC(2, kDebugLoading, "****** Loading Lnam resource with highest ID (%d)", maxLnam);
+ loadLingoNames(*(r = _movieArchive->getResource(MKTAG('L','n','a','m'), maxLnam)));
+ delete r;
+ }
+ }
+
+ // Try to load script context
+ if (_vm->getVersion() >= 4) {
+ Common::Array<uint16> lctx = _movieArchive->getResourceIDList(MKTAG('L','c','t','x'));
+ if (lctx.size() > 0) {
+ debugC(2, kDebugLoading, "****** Loading %d Lctx resources", lctx.size());
+
+ for (Common::Array<uint16>::iterator iterator = lctx.begin(); iterator != lctx.end(); ++iterator) {
+ loadLingoContext(*(r = _movieArchive->getResource(MKTAG('L','c','t','x'), *iterator)));
+ delete r;
+ }
+ }
+ }
+
// PICT resources
if (_movieArchive->hasResource(MKTAG('P', 'I', 'C', 'T'), -1)) {
debug("STUB: Unhandled 'PICT' resource");
@@ -879,18 +879,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
Cast *member = _loadedCast->getVal(id);
// FIXME. Bytecode disabled by default, requires --debugflags=bytecode for now
- if (_vm->getVersion() >= 4 && castType == kCastLingoScript && debugChannelSet(-1, kDebugBytecode)) {
- // Try and load the compiled Lingo script associated with this cast
- uint scriptId = ((ScriptCast *)member)->_id - 1;
- if (scriptId < _castScriptIds.size()) {
- int resourceId = _castScriptIds[scriptId];
- Common::SeekableSubReadStreamEndian *r;
- _lingo->addCodeV4(*(r = _movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), resourceId)), _lingoArchive, ((ScriptCast *)member)->_scriptType, id, ci->name, _macName);
- delete r;
- } else {
- warning("Score::loadCastData(): Lingo context missing a resource entry for script %d referenced in cast %d", scriptId, id);
- }
- } else {
+ if (_vm->getVersion() < 4 || !debugChannelSet(-1, kDebugBytecode)) {
if (!ci->script.empty()) {
ScriptType scriptType = kCastScript;
// the script type here could be wrong!
@@ -1050,8 +1039,6 @@ void Score::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
stream.hexdump(0x2a);
}
- _castScriptIds.clear();
-
stream.readUint16();
stream.readUint16();
stream.readUint16();
@@ -1076,7 +1063,12 @@ void Score::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
stream.readUint16();
stream.readUint16();
- _castScriptIds.push_back(index);
+ // FIXME. Bytecode disabled by default, requires --debugflags=bytecode for now
+ if (_vm->getVersion() >= 4 && debugChannelSet(-1, kDebugBytecode)) {
+ Common::SeekableSubReadStreamEndian *r;
+ _lingo->addCodeV4(*(r = _movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), index)), _lingoArchive, _macName);
+ delete r;
+ }
}
} else {
error("Score::loadLingoContext: unsuported Director version (%d)", _vm->getVersion());
diff --git a/engines/director/score.h b/engines/director/score.h
index d67b9200f8..f665f3b3a4 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -195,7 +195,6 @@ public:
Common::HashMap<uint16, Common::String> _actions;
Common::HashMap<uint16, bool> _immediateActions;
Common::HashMap<uint16, Common::String> _fontMap;
- Common::Array<uint16> _castScriptIds;
Graphics::ManagedSurface *_surface;
Graphics::ManagedSurface *_maskSurface;
Graphics::ManagedSurface *_backSurface;
More information about the Scummvm-git-logs
mailing list