[Scummvm-cvs-logs] SF.net SVN: scummvm:[42212] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Jul 7 13:14:18 CEST 2009
Revision: 42212
http://scummvm.svn.sourceforge.net/scummvm/?rev=42212&view=rev
Author: thebluegr
Date: 2009-07-07 11:14:18 +0000 (Tue, 07 Jul 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kernel.cpp
scummvm/trunk/engines/sci/engine/kernel.h
scummvm/trunk/engines/sci/engine/ksound.cpp
scummvm/trunk/engines/sci/engine/script.cpp
scummvm/trunk/engines/sci/engine/vm.h
scummvm/trunk/engines/sci/resource.cpp
Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp 2009-07-07 11:14:18 UTC (rev 42212)
@@ -370,67 +370,31 @@
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 @@
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 @@
// 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 @@
// 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));
Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/engine/kernel.h 2009-07-07 11:14:18 UTC (rev 42212)
@@ -55,6 +55,15 @@
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 @@
* 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,15 +109,25 @@
* 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);
void dumpScriptObject(char *data, int seeker, int objsize);
@@ -145,16 +164,11 @@
void mapSelectors();
/**
- * Prints auto-detected features from selectors
+ * Detects SCI features based on the existence of certain selectors
*/
- void printAutoDetectedFeatures();
+ void detectSciFeatures();
/**
- * Detects if the game is using older script headers
- */
- void detectOldScriptHeader();
-
- /**
* Maps kernel functions
*/
void mapFunctions();
@@ -166,9 +180,7 @@
bool loadOpcodes();
ResourceManager *_resmgr;
- bool _oldScriptHeader;
- bool _oldGfxFunctions;
- bool _hasLofsAbsolute;
+ uint32 features;
// Kernel-related lists
/**
Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp 2009-07-07 11:14:18 UTC (rev 42212)
@@ -982,9 +982,9 @@
* 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);
Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/engine/script.cpp 2009-07-07 11:14:18 UTC (rev 42212)
@@ -199,10 +199,6 @@
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) {
Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/engine/vm.h 2009-07-07 11:14:18 UTC (rev 42212)
@@ -203,10 +203,6 @@
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.
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2009-07-07 10:28:05 UTC (rev 42211)
+++ scummvm/trunk/engines/sci/resource.cpp 2009-07-07 11:14:18 UTC (rev 42212)
@@ -568,6 +568,11 @@
debug("Resmgr: Couldn't determine SCI version");
break;
}
+
+ if (_isVGA)
+ debug("Resmgr: Detected VGA graphic resources");
+ else
+ debug("Resmgr: Detected non-VGA/EGA graphic resources");
}
ResourceManager::~ResourceManager() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list