aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-07-07 11:14:18 +0000
committerFilippos Karapetis2009-07-07 11:14:18 +0000
commita9aaf56b3e81d46776a6fba574ab9833a8f21be1 (patch)
treebbf78615a1e9418f98bd4cc48b86d6cd888b543d /engines/sci/engine
parentd55f7e72d0af649c472ccc8bb34a408ead3ae7f4 (diff)
downloadscummvm-rg350-a9aaf56b3e81d46776a6fba574ab9833a8f21be1.tar.gz
scummvm-rg350-a9aaf56b3e81d46776a6fba574ab9833a8f21be1.tar.bz2
scummvm-rg350-a9aaf56b3e81d46776a6fba574ab9833a8f21be1.zip
Cleanup: added an enum for the auto-detected features, removed the selectors which are only used for auto-detection from the convenience selector map and placed feature auto-detection in a separate function. Also, now the automatically detected graphics resources are shown in the console.
svn-id: r42212
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kernel.cpp118
-rw-r--r--engines/sci/engine/kernel.h38
-rw-r--r--engines/sci/engine/ksound.cpp4
-rw-r--r--engines/sci/engine/script.cpp4
-rw-r--r--engines/sci/engine/vm.h4
5 files changed, 90 insertions, 78 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index ddcaf53df9..dd2d0dc61a 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -370,67 +370,31 @@ static const char *argtype_description[] = {
Kernel::Kernel(ResourceManager *resmgr) : _resmgr(resmgr) {
memset(&_selectorMap, 0, sizeof(_selectorMap)); // FIXME: Remove this once/if we C++ify selector_map_t
- detectOldScriptHeader(); // must be called before loadSelectorNames()
+ detectSciFeatures(); // must be called before loadSelectorNames()
loadSelectorNames();
- mapSelectors(); // Map a few special selectors for later use
+ mapSelectors(); // Map a few special selectors for later use
loadOpcodes();
loadKernelNames();
- mapFunctions(); // Map the kernel functions
-
- // SCI0 games using old graphics functions (before version 0.000.502) did not have a
- // motionCue selector
- _oldGfxFunctions = (_selectorMap.motionCue == -1 && _resmgr->_sciVersion == SCI_VERSION_0);
-
- // SCI1 games which use absolute lofs have the egoMoveSpeed selector
- _hasLofsAbsolute = (_selectorMap.egoMoveSpeed != -1 && _resmgr->_sciVersion < SCI_VERSION_1_1);
-
- printAutoDetectedFeatures();
+ mapFunctions(); // Map the kernel functions
}
Kernel::~Kernel() {
}
-void Kernel::printAutoDetectedFeatures() {
- if (_oldScriptHeader)
- printf("Kernel auto-detection: game found to have old headers for script blocks\n");
- else
- printf("Kernel auto-detection: game found to have newer headers for script blocks\n");
-
- if (_oldGfxFunctions)
- printf("Kernel auto-detection: game found to be using old graphics functions\n");
- else
- printf("Kernel auto-detection: game found to be using newer graphics functions\n");
-
- if (_hasLofsAbsolute)
- printf("Kernel auto-detection: game found to be using absolute parameters for lofs\n");
- else
- printf("Kernel auto-detection: game found to be using relative parameters for lofs\n");
-
- if (_selectorMap.setVol != -1)
- printf("Kernel auto-detection: using SCI1 sound functions\n");
- else if (_selectorMap.nodePtr != -1)
- printf("Kernel auto-detection: using SCI01 sound functions\n");
- else
- printf("Kernel auto-detection: using SCI0 sound functions\n");
-
- if (_resmgr->_sciVersion == SCI_VERSION_0 && _selectorMap.sightAngle != -1)
- printf("Kernel auto-detection: found SCI0 game using a SCI1 kernel table\n");
-}
-
-void Kernel::detectOldScriptHeader() {
- if (_resmgr->_sciVersion != SCI_VERSION_0) {
- _oldScriptHeader = false;
- return;
- }
-
+void Kernel::detectSciFeatures() {
Resource *r = _resmgr->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SNAMES), 0);
if (!r) // No such resource?
error("Kernel: Could not retrieve selector names");
int count = READ_LE_UINT16(r->data) + 1; // Counter is slightly off
+ features = 0;
- _oldScriptHeader = true;
+ // Initialize features based on SCI version
+ if (_resmgr->_sciVersion == SCI_VERSION_0) {
+ features |= kFeatureOldScriptHeader;
+ features |= kFeatureOldGfxFunctions;
+ }
for (int i = 0; i < count; i++) {
int offset = READ_LE_UINT16(r->data + 2 + i * 2);
@@ -438,14 +402,58 @@ void Kernel::detectOldScriptHeader() {
Common::String tmp((const char *)r->data + offset + 2, len);
- // We determine if the game has old script headers by the existence of the
- // "setTarget" selector. The "motionInited" selector can also be used for the
- // same purpose
- if (tmp == "setTarget") {
- _oldScriptHeader = false;
- break;
- }
+ if (tmp == "setTarget") // "motionInited" can also be used
+ features &= ~kFeatureOldScriptHeader;
+
+ if (tmp == "motionCue")
+ features &= ~kFeatureOldGfxFunctions;
+
+ if (tmp == "egoMoveSpeed" && _resmgr->_sciVersion < SCI_VERSION_1_1)
+ features |= kFeatureLofsAbsolute;
+
+ if (tmp == "sightAngle" && _resmgr->_sciVersion == SCI_VERSION_0)
+ features |= kFeatureSci0Sci1Table;
+
+ if (tmp == "setVol")
+ features |= kFeatureSci1Sound;
+
+ if (tmp == "nodePtr")
+ features |= kFeatureSci01Sound;
}
+
+ if (features & kFeatureSci1Sound)
+ features &= ~kFeatureSci01Sound;
+
+ printf("Kernel auto-detected features:\n");
+
+ printf("Script block headers: ");
+ if (features & kFeatureOldScriptHeader)
+ printf("old\n");
+ else
+ printf("new\n");
+
+ printf("Graphics functions: ");
+ if (features & kFeatureOldGfxFunctions)
+ printf("old\n");
+ else
+ printf("new\n");
+
+ printf("lofs parameters: ");
+ if (features & kFeatureLofsAbsolute)
+ printf("absolute\n");
+ else
+ printf("relative\n");
+
+ printf("Sound functions: ");
+ if (features & kFeatureSci1Sound)
+ printf("SCI1\n");
+ else if (features & kFeatureSci01Sound)
+ printf("SCI01\n");
+ else
+ printf("SCI0\n");
+
+ if (features & kFeatureSci0Sci1Table)
+ printf("Found SCI0 game using a SCI1 kernel table\n");
}
void Kernel::loadSelectorNames() {
@@ -466,7 +474,7 @@ void Kernel::loadSelectorNames() {
// Early SCI versions used the LSB in the selector ID as a read/write
// toggle. To compensate for that, we add every selector name twice.
- if (_oldScriptHeader)
+ if (features & kFeatureOldScriptHeader)
_selectorNames.push_back(tmp);
}
}
@@ -806,7 +814,7 @@ void Kernel::setDefaultKernelNames() {
// Check if we have a SCI01 game which uses a SCI1 kernel table (e.g. the KQ1 demo
// and full version). We do this by checking if the sightAngle selector exists, as no
// SCI0 game seems to have it
- if (_selectorMap.sightAngle != -1 && isSci0)
+ if (features & kFeatureSci0Sci1Table)
isSci0 = false;
_kernelNames.resize(SCI_KNAMES_DEFAULT_ENTRIES_NR + (isSci0 ? 4 : 0));
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index e73914a7e7..4814bd0317 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -55,6 +55,15 @@ struct KernelFuncWithSignature {
Common::String orig_name; /**< Original name, in case we couldn't map it */
};
+enum AutoDetectedFeatures {
+ kFeatureOldScriptHeader = 1 << 0,
+ kFeatureOldGfxFunctions = 1 << 1,
+ kFeatureLofsAbsolute = 1 << 2,
+ kFeatureSci01Sound = 1 << 3,
+ kFeatureSci1Sound = 1 << 4,
+ kFeatureSci0Sci1Table = 1 << 5
+};
+
class Kernel {
public:
Kernel(ResourceManager *resmgr);
@@ -91,7 +100,7 @@ public:
* Also, old SCI versions assign 120 degrees to left & right, and 60 to up
* and down. Later versions use an even 90 degree distribution.
*/
- bool hasOldScriptHeader() const { return _oldScriptHeader; }
+ bool hasOldScriptHeader() const { return (features & kFeatureOldScriptHeader); }
/**
* Applies to all versions before 0.000.502
@@ -100,14 +109,24 @@ public:
* Also, they used 15 priority zones from 42 to 200 instead of 14 priority
* zones from 42 to 190.
*/
- bool usesOldGfxFunctions() const { return _oldGfxFunctions; }
+ bool usesOldGfxFunctions() const { return (features & kFeatureOldGfxFunctions); }
/**
* Applies to all SCI1 versions after 1.000.200
* In late SCI1 versions, the argument of lofs[as] instructions
* is absolute rather than relative.
*/
- bool hasLofsAbsolute() const { return _hasLofsAbsolute; }
+ bool hasLofsAbsolute() const { return (features & kFeatureLofsAbsolute); }
+
+ /**
+ * Determines if the game is using SCI01 sound functions
+ */
+ bool usesSci01SoundFunctions() const { return (features & kFeatureSci01Sound); }
+
+ /**
+ * Determines if the game is using SCI1 sound functions
+ */
+ bool usesSci1SoundFunctions() const { return (features & kFeatureSci1Sound); }
// Script dissection/dumping functions
void dissectScript(int scriptNumber, Vocabulary *vocab);
@@ -145,14 +164,9 @@ private:
void mapSelectors();
/**
- * Prints auto-detected features from selectors
- */
- void printAutoDetectedFeatures();
-
- /**
- * Detects if the game is using older script headers
+ * Detects SCI features based on the existence of certain selectors
*/
- void detectOldScriptHeader();
+ void detectSciFeatures();
/**
* Maps kernel functions
@@ -166,9 +180,7 @@ private:
bool loadOpcodes();
ResourceManager *_resmgr;
- bool _oldScriptHeader;
- bool _oldGfxFunctions;
- bool _hasLofsAbsolute;
+ uint32 features;
// Kernel-related lists
/**
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index f1584bf975..ba70bf9f73 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -982,9 +982,9 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
* Used for synthesized music playback
*/
reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- if (s->_kernel->_selectorMap.setVol != -1)
+ if (s->_kernel->usesSci1SoundFunctions())
return kDoSound_SCI1(s, funct_nr, argc, argv);
- else if (s->_kernel->_selectorMap.nodePtr != -1)
+ else if (s->_kernel->usesSci01SoundFunctions())
return kDoSound_SCI01(s, funct_nr, argc, argv);
else
return kDoSound_SCI0(s, funct_nr, argc, argv);
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 991955cd67..b7529c33bd 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -199,10 +199,6 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(printLang);
FIND_SELECTOR(subtitleLang);
FIND_SELECTOR(parseLang);
- FIND_SELECTOR(motionCue);
- FIND_SELECTOR(sightAngle);
- FIND_SELECTOR(setVol);
- FIND_SELECTOR(egoMoveSpeed);
}
void Kernel::dumpScriptObject(char *data, int seeker, int objsize) {
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 0536ec32ab..a3fabbe44b 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -203,10 +203,6 @@ struct selector_map_t {
Selector printLang; /**< Used for i18n */
Selector subtitleLang;
Selector parseLang;
- Selector motionCue; // Used to detect newer graphics functions semantics
- Selector sightAngle; // Used to detect some SCI0/SCI01 games which need a SCI1 table
- Selector setVol; // Used to detect newer sound semantics
- Selector egoMoveSpeed; // Used to detect SCI1 games which use absolute values in lofs
};
// A reference to an object's variable.