aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2009-07-04 15:45:04 +0000
committerFilippos Karapetis2009-07-04 15:45:04 +0000
commitc5522b37660644666c2842045cf64f1254cc3e17 (patch)
tree6b6e12b7da9a504d4aa9cd367103e03ddd659668 /engines/sci
parentfddc5915f7f6ff8feb37d356666d32d3162a16b0 (diff)
downloadscummvm-rg350-c5522b37660644666c2842045cf64f1254cc3e17.tar.gz
scummvm-rg350-c5522b37660644666c2842045cf64f1254cc3e17.tar.bz2
scummvm-rg350-c5522b37660644666c2842045cf64f1254cc3e17.zip
- Kernel function names are no longer loaded from vocab.999, but are constructed from the hardcoded function table, depending on the SCI version used
- SCI0 games using older graphics functions are now detected by the presence of the "curAngle" selector - SCI0 games using a SCI1 table (like KQ1 demo version and full version) are detected by the presence of the "sightAngle" selector (as no SCI0 game seems to have it) svn-id: r42095
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.cpp96
-rw-r--r--engines/sci/engine/kernel.h21
-rw-r--r--engines/sci/engine/script.cpp2
-rw-r--r--engines/sci/engine/vm.h4
4 files changed, 54 insertions, 69 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index b03a073d8f..b68c42296a 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -356,35 +356,27 @@ static const char *argtype_description[] = {
Kernel::Kernel(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr) {
memset(&_selectorMap, 0, sizeof(_selectorMap)); // FIXME: Remove this once/if we C++ify selector_map_t
- loadKernelNames();
-
+ loadSelectorNames(isOldSci0);
+ mapSelectors(); // Map a few special selectors for later use
loadOpcodes();
+ loadKernelNames();
+ mapFunctions(); // Map the kernel functions
- if (!loadSelectorNames(isOldSci0)) {
- error("Kernel: Could not retrieve selector names");
- }
-
- // Map the kernel functions
- mapFunctions();
-
- // Map a few special selectors for later use
- mapSelectors();
-
- // SCI0 games using old graphics functions (before version 0.000.502) have the TimesSin
- // kernel function, whereas newer games have the SinMult kernel function in its place
- _oldGfxFunctions = !hasKernelFunction("SinMult");
+ // SCI0 games using old graphics functions (before version 0.000.502) did not have a
+ // curAngle selector
+ _oldGfxFunctions = (_selectorMap.curAngle == -1 && _resmgr->_sciVersion == SCI_VERSION_0);
}
Kernel::~Kernel() {
}
-bool Kernel::loadSelectorNames(bool isOldSci0) {
+void Kernel::loadSelectorNames(bool isOldSci0) {
int count;
Resource *r = _resmgr->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SNAMES), 0);
if (!r) // No such resource?
- return false;
+ error("Kernel: Could not retrieve selector names");
count = READ_LE_UINT16(r->data) + 1; // Counter is slightly off
@@ -400,8 +392,6 @@ bool Kernel::loadSelectorNames(bool isOldSci0) {
if (isOldSci0)
_selectorNames.push_back(tmp);
}
-
- return true;
}
bool Kernel::loadOpcodes() {
@@ -732,46 +722,34 @@ reg_t *kernel_dereference_reg_pointer(EngineState *s, reg_t pointer, int entries
return (reg_t*)_kernel_dereference_pointer(s, pointer, entries, sizeof(reg_t));
}
-void setDefaultKernelNames(Common::StringList &names) {
- names.resize(SCI_KNAMES_DEFAULT_ENTRIES_NR);
- for (int i = 0; i < SCI_KNAMES_DEFAULT_ENTRIES_NR; i++)
- names[i] = sci_default_knames[i];
-}
-
-static void vocab_get_knames0(ResourceManager *resmgr, Common::StringList &names) {
- int count, i, index = 2, empty_to_add = 1;
- Resource *r = resmgr->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES), 0);
-
- if (!r) { // No kernel name table found? Fall back to default table
- setDefaultKernelNames(names);
- return;
- }
-
- count = READ_LE_UINT16(r->data);
-
- if (count > 1023) {
- // Newer kernel name table, found in KQ1. We can use the default table here
- setDefaultKernelNames(names);
- return;
- }
-
- if (count < SCI0_KNAMES_WELL_DEFINED) {
- empty_to_add = SCI0_KNAMES_WELL_DEFINED - count;
- sciprintf("Less than %d kernel functions; adding %d\n", SCI0_KNAMES_WELL_DEFINED, empty_to_add);
- }
+void Kernel::setDefaultKernelNames() {
+ bool isSci0 = (_resmgr->_sciVersion == SCI_VERSION_0);
+ int offset = 0;
+
+ // 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 = false;
+
+ _kernelNames.resize(SCI_KNAMES_DEFAULT_ENTRIES_NR + (isSci0 ? 4 : 0));
+ for (int i = 0; i < SCI_KNAMES_DEFAULT_ENTRIES_NR; i++) {
+ // In SCI0, Platform was DoAvoider
+ if (!strcmp(sci_default_knames[i], "Platform") && isSci0) {
+ _kernelNames[i + offset] = "DoAvoider";
+ continue;
+ }
- names.resize(count + 1 + empty_to_add);
+ _kernelNames[i + offset] = sci_default_knames[i];
- for (i = 0; i < count; i++) {
- int offset = READ_LE_UINT16(r->data + index);
- int len = READ_LE_UINT16(r->data + offset);
- //fprintf(stderr,"Getting name %d of %d...\n", i, count);
- index += 2;
- names[i] = Common::String((const char *)r->data + offset + 2, len);
- }
-
- for (i = 0; i < empty_to_add; i++) {
- names[count + i] = SCRIPT_UNKNOWN_FUNCTION_STRING;
+ // SCI0 has 4 extra functions between SetCursor (0x28) and Savegame
+ if (!strcmp(sci_default_knames[i], "SetCursor") && isSci0) {
+ _kernelNames[i + 1] = "FOpen";
+ _kernelNames[i + 2] = "FPuts";
+ _kernelNames[i + 3] = "FGets";
+ _kernelNames[i + 4] = "FClose";
+ offset = 4;
+ }
}
}
@@ -810,12 +788,10 @@ bool Kernel::loadKernelNames() {
case SCI_VERSION_01:
case SCI_VERSION_01_VGA:
case SCI_VERSION_01_VGA_ODD:
- vocab_get_knames0(_resmgr, _kernelNames);
- break;
case SCI_VERSION_1_EARLY:
case SCI_VERSION_1_LATE:
case SCI_VERSION_1_1:
- setDefaultKernelNames(_kernelNames);
+ setDefaultKernelNames();
if (_resmgr->_sciVersion == SCI_VERSION_1_1) {
// KQ6CD calls unimplemented function 0x26
_kernelNames[0x26] = "Dummy";
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index e3ecddca26..ad7605753b 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -83,12 +83,13 @@ public:
*/
bool hasKernelFunction(const char *functionName) const;
- /* Applies to all versions before 0.000.502
- ** Old SCI versions used to interpret the third DrawPic() parameter inversely,
- ** with the opposite default value (obviously).
- ** Also, they used 15 priority zones from 42 to 200 instead of 14 priority
- ** zones from 42 to 190.
- */
+ /**
+ * Applies to all versions before 0.000.502
+ * Old SCI versions used to interpret the third DrawPic() parameter inversely,
+ * with the opposite default value (obviously).
+ * Also, they used 15 priority zones from 42 to 200 instead of 14 priority
+ * zones from 42 to 190.
+ */
bool usesOldGfxFunctions() const { return _oldGfxFunctions; }
// Script dissection/dumping functions
@@ -112,10 +113,14 @@ private:
bool loadKernelNames();
/**
+ * Sets the default kernel function names, based on the SCI version used
+ */
+ void setDefaultKernelNames();
+
+ /**
* Loads the kernel selector names.
- * @return True upon success, false otherwise.
*/
- bool loadSelectorNames(bool isOldSci0);
+ void loadSelectorNames(bool isOldSci0);
/**
* Maps special selectors
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 6ec4b0b43d..3260be6b36 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -203,6 +203,8 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(printLang);
FIND_SELECTOR(subtitleLang);
FIND_SELECTOR(parseLang);
+ FIND_SELECTOR(curAngle);
+ FIND_SELECTOR(sightAngle);
FIND_SELECTOR(setVol);
}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index a4c3043594..f1e89bba45 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -203,7 +203,9 @@ struct selector_map_t {
Selector printLang; /**< Used for i18n */
Selector subtitleLang;
Selector parseLang;
- Selector setVol; /**< Used to detect newer sound semantics */
+ Selector curAngle; // 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
};
// A reference to an object's variable.