diff options
author | Filippos Karapetis | 2010-05-18 11:23:13 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-18 11:23:13 +0000 |
commit | 75f4791a4a97889cd01663e9cc882682e58b6177 (patch) | |
tree | 24c1f4b16d9351e18435d125b139608efe82f5ae /engines/sci/engine | |
parent | 15986b81c2f30a52d2b7ebc90ce0eff9fe173443 (diff) | |
download | scummvm-rg350-75f4791a4a97889cd01663e9cc882682e58b6177.tar.gz scummvm-rg350-75f4791a4a97889cd01663e9cc882682e58b6177.tar.bz2 scummvm-rg350-75f4791a4a97889cd01663e9cc882682e58b6177.zip |
- 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
svn-id: r49075
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 11 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 64 | ||||
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel_types.h | 96 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 3 |
7 files changed, 67 insertions, 111 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index f92c67505c..d46ca65fbe 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -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" diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 122af1c36b..7cf186453a 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -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 @@ void Kernel::mapFunctions() { 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 @@ int determine_reg_type(SegManager *segMan, reg_t reg) { } } -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 @@ void Kernel::setDefaultKernelNames(Common::String gameId) { } } -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 diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index a8915f4860..cbfd575e18 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -78,13 +78,13 @@ struct List; // from segment.h * * 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 @@ struct List; // from segment.h //#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 @@ public: * 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 @@ public: 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 @@ private: /** * Sets the default kernel function names to the SCI2.1 kernel functions */ - void setKernelNamesSci21(EngineState *s); + void setKernelNamesSci21(); #endif /** diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index f63e2e3e77..465e0e92df 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -378,7 +378,7 @@ void Kernel::setKernelNamesSci2() { _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(). diff --git a/engines/sci/engine/kernel_types.h b/engines/sci/engine/kernel_types.h deleted file mode 100644 index a8da4fead1..0000000000 --- a/engines/sci/engine/kernel_types.h +++ /dev/null @@ -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 diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index fdcd8d977b..9fa819e779 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -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 { diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 40e2d760de..ca582e9349 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -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 @@ static void callKernelFunc(EngineState *s, int kernelFuncNum, int argc) { 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); } |