[Scummvm-cvs-logs] SF.net SVN: scummvm:[42095] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Jul 4 17:45:04 CEST 2009


Revision: 42095
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42095&view=rev
Author:   thebluegr
Date:     2009-07-04 15:45:04 +0000 (Sat, 04 Jul 2009)

Log Message:
-----------
- 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)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/engine/vm.h

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-04 15:39:31 UTC (rev 42094)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-04 15:45:04 UTC (rev 42095)
@@ -356,35 +356,27 @@
 Kernel::Kernel(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr) {
 	memset(&_selectorMap, 0, sizeof(_selectorMap));	// FIXME: Remove this once/if we C++ify selector_map_t
 
+	loadSelectorNames(isOldSci0);
+	mapSelectors();     // Map a few special selectors for later use
+	loadOpcodes();
 	loadKernelNames();
+	mapFunctions();     // Map the kernel functions
 
-	loadOpcodes();
-
-	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 @@
 		if (isOldSci0)
 			_selectorNames.push_back(tmp);
 	}
-
-	return true;
 }
 
 bool Kernel::loadOpcodes() {
@@ -732,47 +722,35 @@
 	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];
-}
+void Kernel::setDefaultKernelNames() {
+	bool isSci0 = (_resmgr->_sciVersion == SCI_VERSION_0);
+	int offset = 0;
 
-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);
+	// 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;
 
-	if (!r) { // No kernel name table found? Fall back to default table
-		setDefaultKernelNames(names);
-		return;
-	}
+	_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;
+		}
 
-	count = READ_LE_UINT16(r->data);
+		_kernelNames[i + offset] = sci_default_knames[i];
 
-	if (count > 1023) {
-		// Newer kernel name table, found in KQ1. We can use the default table here
-		setDefaultKernelNames(names);
-		return;
+		// 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;
+		}
 	}
-
-	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);
-	}
-
-	names.resize(count + 1 + empty_to_add);
-
-	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;
-	}
 }
 
 #ifdef ENABLE_SCI32
@@ -810,12 +788,10 @@
 	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";

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-07-04 15:39:31 UTC (rev 42094)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-07-04 15:45:04 UTC (rev 42095)
@@ -83,12 +83,13 @@
 	*/
 	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 @@
 	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

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2009-07-04 15:39:31 UTC (rev 42094)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2009-07-04 15:45:04 UTC (rev 42095)
@@ -203,6 +203,8 @@
 	FIND_SELECTOR(printLang);
 	FIND_SELECTOR(subtitleLang);
 	FIND_SELECTOR(parseLang);
+	FIND_SELECTOR(curAngle);
+	FIND_SELECTOR(sightAngle);
 	FIND_SELECTOR(setVol);
 }
 

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-07-04 15:39:31 UTC (rev 42094)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-07-04 15:45:04 UTC (rev 42095)
@@ -203,7 +203,9 @@
 	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.


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