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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue May 18 13:23:13 CEST 2010


Revision: 49075
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49075&view=rev
Author:   thebluegr
Date:     2010-05-18 11:23:13 +0000 (Tue, 18 May 2010)

Log Message:
-----------
- Moved determine_reg_type() and kernel_matches_signature() inside the Kernel class, where they belong
- Moved the kernel signature defines inside kernel.h
- Removed some unused references to EngineState

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kernel32.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/sci.cpp

Removed Paths:
-------------
    scummvm/trunk/engines/sci/engine/kernel_types.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/console.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -33,7 +33,6 @@
 #include "sci/engine/state.h"
 #include "sci/engine/selector.h"
 #include "sci/engine/savegame.h"
-#include "sci/engine/kernel_types.h"	// for determine_reg_type
 #include "sci/engine/gc.h"
 #include "sci/engine/features.h"
 #ifdef USE_OLD_MUSIC_FUNCTIONS
@@ -1835,7 +1834,7 @@
 		return true;
 	}
 
-	int t = determine_reg_type(_engine->_gamestate->_segMan, val);
+	int t = g_sci->getKernel()->findRegType(_engine->_gamestate->_segMan, val);
 
 	switch (t) {
 	case KSIG_LIST:
@@ -1904,7 +1903,7 @@
 		}
 	}
 
-	int type_mask = determine_reg_type(_engine->_gamestate->_segMan, reg);
+	int type_mask = g_sci->getKernel()->findRegType(_engine->_gamestate->_segMan, reg);
 	int filter;
 	int found = 0;
 

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -33,7 +33,6 @@
 #include "sci/engine/features.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
-#include "sci/engine/kernel_types.h"
 #include "sci/engine/message.h"
 #include "sci/graphics/gui.h"
 #include "sci/graphics/menu.h"

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -28,7 +28,6 @@
 #include "sci/event.h"
 #include "sci/resource.h"
 #include "sci/engine/state.h"
-#include "sci/engine/kernel_types.h"
 
 #include "common/system.h"
 
@@ -643,7 +642,7 @@
 	return;
 }
 
-int determine_reg_type(SegManager *segMan, reg_t reg) {
+int Kernel::findRegType(SegManager *segMan, reg_t reg) {
 	// No segment? Must be arithmetic
 	if (!reg.segment)
 		return reg.offset ? KSIG_ARITHMETIC : KSIG_ARITHMETIC | KSIG_NULL;
@@ -685,14 +684,14 @@
 	}
 }
 
-bool kernel_matches_signature(SegManager *segMan, const char *sig, int argc, const reg_t *argv) {
+bool Kernel::signatureMatch(SegManager *segMan, const char *sig, int argc, const reg_t *argv) {
 	// Always "match" if no signature is given
 	if (!sig)
 		return true;
 
 	while (*sig && argc) {
 		if ((*sig & KSIG_ANY) != KSIG_ANY) {
-			int type = determine_reg_type(segMan, *argv);
+			int type = findRegType(segMan, *argv);
 
 			if (!type) {
 				warning("[KERN] Could not determine type of ref %04x:%04x; failing signature check", PRINT_REG(*argv));
@@ -777,12 +776,12 @@
 	}
 }
 
-bool Kernel::loadKernelNames(Common::String gameId, EngineState *s) {
+bool Kernel::loadKernelNames(Common::String gameId) {
 	_kernelNames.clear();
 
 #ifdef ENABLE_SCI32
 	if (getSciVersion() >= SCI_VERSION_2_1)
-		setKernelNamesSci21(s);
+		setKernelNamesSci21();
 	else if (getSciVersion() == SCI_VERSION_2)
 		setKernelNamesSci2();
 	else

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2010-05-18 11:23:13 UTC (rev 49075)
@@ -78,13 +78,13 @@
  *
  * SCI0 parser vocabularies:
  * - vocab.901 / 901.voc - suffix vocabulary
- * - vocab.900 / 900.vo1 - parse tree branches
+ * - vocab.900 / 900.voc - parse tree branches
  * - vocab.0 / 0.voc - main vocabulary, containing words and their attributes
  *                     (e.g. "onto" - "position")
  *
  * SCI01 parser vocabularies:
  * - vocab.902 / 902.voc - suffix vocabulary
- * - vocab.901 / 901.vo1 - parse tree branches
+ * - vocab.901 / 901.voc - parse tree branches
  * - vocab.900 / 900.voc - main vocabulary, containing words and their attributes
  *                        (e.g. "onto" - "position")
  *
@@ -94,6 +94,39 @@
 //#define DEBUG_PARSER	// enable for parser debugging
 //#define DISABLE_VALIDATIONS	// enable to stop validation checks
 
+// ---- Kernel signatures -----------------------------------------------------
+#define KSIG_TERMINATOR 0
+
+// Uncompiled signatures
+#define KSIG_SPEC_ARITMETIC 'i'
+#define KSIG_SPEC_LIST 'l'
+#define KSIG_SPEC_NODE 'n'
+#define KSIG_SPEC_OBJECT 'o'
+#define KSIG_SPEC_REF 'r' // Said Specs and strings
+#define KSIG_SPEC_ARITHMETIC 'i'
+#define KSIG_SPEC_NULL 'z'
+#define KSIG_SPEC_ANY '.'
+#define KSIG_SPEC_ELLIPSIS '*' // Arbitrarily more TYPED arguments
+
+#define KSIG_SPEC_SUM_DONE ('a' - 'A') // Use small letters to indicate end of sum type
+/* Use capital letters for sum types, e.g.
+** "LNoLr" for a function which takes two arguments:
+** (1) list, node or object
+** (2) list or ref
+*/
+
+// Compiled signatures
+#define KSIG_LIST	0x01
+#define KSIG_NODE	0x02
+#define KSIG_OBJECT	0x04
+#define KSIG_REF	0x08
+#define KSIG_ARITHMETIC 0x10
+
+#define KSIG_NULL	0x40
+#define KSIG_ANY	0x5f
+#define KSIG_ELLIPSIS	0x80
+// ----------------------------------------------------------------------------
+
 /* Generic description: */
 typedef reg_t KernelFunc(EngineState *s, int argc, reg_t *argv);
 
@@ -131,7 +164,7 @@
 	 * name table of the resource (the format changed between version 0 and 1).
 	 * @return true on success, false on failure
 	 */
-	bool loadKernelNames(Common::String gameId, EngineState *s);
+	bool loadKernelNames(Common::String gameId);
 
 	/**
 	 * Determines the selector ID of a selector by its name
@@ -149,6 +182,29 @@
 	typedef Common::Array<KernelFuncWithSignature> KernelFuncsContainer;
 	KernelFuncsContainer _kernelFuncs; /**< Table of kernel functions */
 
+	/**
+	 * Determines whether a list of registers matches a given signature.
+	 * If no signature is given (i.e., if sig is NULL), this is always
+	 * treated as a match.
+	 *
+	 * @param segMan pointer to the segment manager
+	 * @param sig	 signature to test against
+	 * @param argc	 number of arguments to test
+	 * @param argv	 argument list
+	 * @return true if the signature was matched, false otherwise
+	 */
+	bool signatureMatch(SegManager *segMan, const char *sig, int argc, const reg_t *argv);
+
+	/**
+	 * Determines the type of the object indicated by reg.
+	 * @param segMan			the Segment manager
+	 * @param reg				register to check
+	 * @return one of KSIG_* below KSIG_NULL.
+	 *	       KSIG_INVALID set if the type of reg can be determined, but is invalid.
+	 *	       0 on error.
+	 */
+	int findRegType(SegManager *segMan, reg_t reg);
+
 private:
 	/**
 	 * Sets the default kernel function names, based on the SCI version used
@@ -164,7 +220,7 @@
 	/**
 	 * Sets the default kernel function names to the SCI2.1 kernel functions
 	 */
-	void setKernelNamesSci21(EngineState *s);
+	void setKernelNamesSci21();
 #endif
 
 	/**

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -378,7 +378,7 @@
 	_kernelNames = Common::StringArray(sci2_default_knames, kKernelEntriesSci2);
 }
 
-void Kernel::setKernelNamesSci21(EngineState *s) {
+void Kernel::setKernelNamesSci21() {
 	// Some SCI games use a modified SCI2 kernel table instead of the SCI2.1/SCI3 kernel table.
 	// The GK2 demo does this as well as at least one version of KQ7. We detect which version
 	// to use based on where kDoSound is called from Sound::play().

Deleted: scummvm/trunk/engines/sci/engine/kernel_types.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_types.h	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/kernel_types.h	2010-05-18 11:23:13 UTC (rev 49075)
@@ -1,96 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_ENGINE_KERNEL_TYPES_H
-#define SCI_ENGINE_KERNEL_TYPES_H
-
-#include "sci/engine/vm_types.h"
-
-namespace Sci {
-
-#define KSIG_TERMINATOR 0
-
-// Uncompiled signatures
-#define KSIG_SPEC_ARITMETIC 'i'
-#define KSIG_SPEC_LIST 'l'
-#define KSIG_SPEC_NODE 'n'
-#define KSIG_SPEC_OBJECT 'o'
-#define KSIG_SPEC_REF 'r' // Said Specs and strings
-#define KSIG_SPEC_ARITHMETIC 'i'
-#define KSIG_SPEC_NULL 'z'
-#define KSIG_SPEC_ANY '.'
-#define KSIG_SPEC_ELLIPSIS '*' // Arbitrarily more TYPED arguments
-
-#define KSIG_SPEC_SUM_DONE ('a' - 'A') // Use small letters to indicate end of sum type
-/* Use capital letters for sum types, e.g.
-** "LNoLr" for a function which takes two arguments:
-** (1) list, node or object
-** (2) list or ref
-*/
-
-// Compiled signatures
-#define KSIG_LIST	0x01
-#define KSIG_NODE	0x02
-#define KSIG_OBJECT	0x04
-#define KSIG_REF	0x08
-#define KSIG_ARITHMETIC 0x10
-
-#define KSIG_NULL	0x40
-#define KSIG_ANY	0x5f
-#define KSIG_ELLIPSIS	0x80
-
-/**
- * Determines whether a list of registers matches a given signature.
- * If no signature is given (i.e., if sig is NULL), this is always
- * treated as a match.
- *
- * @param s		state to operate on
- * @param sig	signature to test against
- * @param argc	number of arguments to test
- * @param argv	argument list
- * @return true if the signature was matched, false otherwise
- */
-bool kernel_matches_signature(SegManager *segMan, const char *sig, int argc, const reg_t *argv);
-
-/**
- * Determines the type of the object indicated by reg.
- * @param segMan			the Segment manager
- * @param reg				register to check
-  * @return one of KSIG_* below KSIG_NULL.
- *	       KSIG_INVALID set if the type of reg can be determined, but is invalid.
- *	       0 on error.
- */
-int determine_reg_type(SegManager *segMan, reg_t reg);
-
-/**
- * Returns a textual description of the type of an object.
- * @param type		type value to describe
- * @return pointer to a (static) descriptive string
- */
-const char *kernel_argtype_description(int type);
-
-} // End of namespace Sci
-
-#endif // SCI_ENGIENE_KERNEL_TYPES_H

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -27,7 +27,6 @@
 #include "sci/resource.h"
 #include "sci/engine/state.h"
 #include "sci/engine/selector.h"
-#include "sci/engine/kernel_types.h"
 #include "sci/engine/kernel.h"
 
 namespace Sci {

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -35,7 +35,6 @@
 #include "sci/engine/features.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
-#include "sci/engine/kernel_types.h"
 #include "sci/engine/seg_manager.h"
 #include "sci/engine/script.h"
 #include "sci/engine/gc.h"
@@ -564,7 +563,7 @@
 	const KernelFuncWithSignature &kernelFunc = g_sci->getKernel()->_kernelFuncs[kernelFuncNum];
 
 	if (kernelFunc.signature
-			&& !kernel_matches_signature(s->_segMan, kernelFunc.signature, argc, scriptState.xs->sp + 1)) {
+			&& !g_sci->getKernel()->signatureMatch(s->_segMan, kernelFunc.signature, argc, scriptState.xs->sp + 1)) {
 		error("[VM] Invalid arguments to kernel call %x", kernelFuncNum);
 	}
 

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-05-18 10:39:08 UTC (rev 49074)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-05-18 11:23:13 UTC (rev 49075)
@@ -225,7 +225,7 @@
 	_resMan->addNewGMPatch(_gamestate->_gameId);
 
 	script_adjust_opcode_formats(_gamestate);
-	_kernel->loadKernelNames(getGameID(), _gamestate);
+	_kernel->loadKernelNames(getGameID());
 
 	// Set the savegame dir (actually, we set it to a fake value,
 	// since we cannot let the game control where saves are stored)


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