diff options
| -rw-r--r-- | engines/sci/engine/kernel.cpp | 115 | ||||
| -rw-r--r-- | engines/sci/engine/kernel.h | 5 | ||||
| -rw-r--r-- | engines/sci/engine/vm.cpp | 8 | 
3 files changed, 63 insertions, 65 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 3e30480b99..2b8daf03d1 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -1006,11 +1006,12 @@ void Kernel::mapFunctions() {  		// Reset the table entry  		_kernelFuncs[id].function = NULL;  		_kernelFuncs[id].signature = NULL; -		_kernelFuncs[id].origName = kernelName; +		_kernelFuncs[id].name = NULL;  		_kernelFuncs[id].isDummy = true;  		_kernelFuncs[id].workarounds = NULL;  		_kernelFuncs[id].subFunctions = NULL;  		_kernelFuncs[id].subFunctionCount = 0; +		_kernelFuncs[id].debugCalls = false;  		if (kernelName.empty()) {  			// No name was given -> must be an unknown opcode  			warning("Kernel function %x unknown", id); @@ -1038,70 +1039,66 @@ void Kernel::mapFunctions() {  		if (kernelMap->name) {  			// A match was found -			if (kernelMap->function) { -				_kernelFuncs[id].function = kernelMap->function; -				_kernelFuncs[id].signature = parseKernelSignature(kernelMap->name, kernelMap->signature); -				_kernelFuncs[id].workarounds = kernelMap->workarounds; -				_kernelFuncs[id].isDummy = false; -				if (kernelMap->subFunctions) { -					// Get version for subfunction identification -					SciVersion mySubVersion = (SciVersion)kernelMap->function(NULL, 0, NULL).offset; -					// Now check whats the highest subfunction-id for this version -					const SciKernelMapSubEntry *kernelSubMap = kernelMap->subFunctions; -					uint16 subFunctionCount = 0; -					while (kernelSubMap->function) { -						if ((kernelSubMap->fromVersion == SCI_VERSION_NONE) || (kernelSubMap->fromVersion <= mySubVersion)) -							if ((kernelSubMap->toVersion == SCI_VERSION_NONE) || (kernelSubMap->toVersion >= mySubVersion)) -								if (subFunctionCount <= kernelSubMap->id) -									subFunctionCount = kernelSubMap->id + 1; -						kernelSubMap++; -					} -					if (!subFunctionCount) -						error("k%s[%x]: no subfunctions found for requested version", kernelName.c_str(), id); -					// Now allocate required memory and go through it again -					_kernelFuncs[id].subFunctionCount = subFunctionCount; -					KernelSubFunction *subFunctions = new KernelSubFunction[subFunctionCount]; -					_kernelFuncs[id].subFunctions = subFunctions; -					memset(subFunctions, 0, sizeof(KernelSubFunction) * subFunctionCount); -					// And fill this info out -					kernelSubMap = kernelMap->subFunctions; -					uint kernelSubNr = 0; -					while (kernelSubMap->function) { -						if ((kernelSubMap->fromVersion == SCI_VERSION_NONE) || (kernelSubMap->fromVersion <= mySubVersion)) -							if ((kernelSubMap->toVersion == SCI_VERSION_NONE) || (kernelSubMap->toVersion >= mySubVersion)) { -								uint subId = kernelSubMap->id; -								subFunctions[subId].function = kernelSubMap->function; -								subFunctions[subId].name = kernelSubMap->name; -								subFunctions[subId].workarounds = kernelSubMap->workarounds; -								if (kernelSubMap->signature) { -									subFunctions[subId].signature = parseKernelSignature(kernelSubMap->name, kernelSubMap->signature); -								} else { -									// we go back the submap to find the previous signature for that kernel call -									const SciKernelMapSubEntry *kernelSubMapBack = kernelSubMap; -									uint kernelSubLeft = kernelSubNr; -									while (kernelSubLeft) { -										kernelSubLeft--; -										kernelSubMapBack--; -										if (kernelSubMapBack->name == kernelSubMap->name) { -											if (kernelSubMapBack->signature) { -												subFunctions[subId].signature = parseKernelSignature(kernelSubMap->name, kernelSubMapBack->signature); -												break; -											} +			_kernelFuncs[id].function = kernelMap->function; +			_kernelFuncs[id].name = kernelMap->name; +			_kernelFuncs[id].signature = parseKernelSignature(kernelMap->name, kernelMap->signature); +			_kernelFuncs[id].workarounds = kernelMap->workarounds; +			_kernelFuncs[id].isDummy = false; +			if (kernelMap->subFunctions) { +				// Get version for subfunction identification +				SciVersion mySubVersion = (SciVersion)kernelMap->function(NULL, 0, NULL).offset; +				// Now check whats the highest subfunction-id for this version +				const SciKernelMapSubEntry *kernelSubMap = kernelMap->subFunctions; +				uint16 subFunctionCount = 0; +				while (kernelSubMap->function) { +					if ((kernelSubMap->fromVersion == SCI_VERSION_NONE) || (kernelSubMap->fromVersion <= mySubVersion)) +						if ((kernelSubMap->toVersion == SCI_VERSION_NONE) || (kernelSubMap->toVersion >= mySubVersion)) +							if (subFunctionCount <= kernelSubMap->id) +								subFunctionCount = kernelSubMap->id + 1; +					kernelSubMap++; +				} +				if (!subFunctionCount) +					error("k%s[%x]: no subfunctions found for requested version", kernelName.c_str(), id); +				// Now allocate required memory and go through it again +				_kernelFuncs[id].subFunctionCount = subFunctionCount; +				KernelSubFunction *subFunctions = new KernelSubFunction[subFunctionCount]; +				_kernelFuncs[id].subFunctions = subFunctions; +				memset(subFunctions, 0, sizeof(KernelSubFunction) * subFunctionCount); +				// And fill this info out +				kernelSubMap = kernelMap->subFunctions; +				uint kernelSubNr = 0; +				while (kernelSubMap->function) { +					if ((kernelSubMap->fromVersion == SCI_VERSION_NONE) || (kernelSubMap->fromVersion <= mySubVersion)) +						if ((kernelSubMap->toVersion == SCI_VERSION_NONE) || (kernelSubMap->toVersion >= mySubVersion)) { +							uint subId = kernelSubMap->id; +							subFunctions[subId].function = kernelSubMap->function; +							subFunctions[subId].name = kernelSubMap->name; +							subFunctions[subId].workarounds = kernelSubMap->workarounds; +							if (kernelSubMap->signature) { +								subFunctions[subId].signature = parseKernelSignature(kernelSubMap->name, kernelSubMap->signature); +							} else { +								// we go back the submap to find the previous signature for that kernel call +								const SciKernelMapSubEntry *kernelSubMapBack = kernelSubMap; +								uint kernelSubLeft = kernelSubNr; +								while (kernelSubLeft) { +									kernelSubLeft--; +									kernelSubMapBack--; +									if (kernelSubMapBack->name == kernelSubMap->name) { +										if (kernelSubMapBack->signature) { +											subFunctions[subId].signature = parseKernelSignature(kernelSubMap->name, kernelSubMapBack->signature); +											break;  										}  									} -									if (!subFunctions[subId].signature) -										error("k%s: no previous signatures", kernelSubMap->name);  								} +								if (!subFunctions[subId].signature) +									error("k%s: no previous signatures", kernelSubMap->name);  							} -						kernelSubMap++; -						kernelSubNr++; -					} +						} +					kernelSubMap++; +					kernelSubNr++;  				} -				++mapped; -			} else { -				//warning("Ignoring function %s\n", s_kernelFuncMap[found].name); -				++ignored;  			} +			++mapped;  		} else {  			if (nameMatch)  				error("k%s[%x]: not found for this version/platform", kernelName.c_str(), id); diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index a5ea379ba6..b7806ce551 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -141,13 +141,14 @@ struct KernelSubFunction {  };  struct KernelFunction { -	KernelFunctionCall *function; -	Common::String origName; /**< Original name, in case we couldn't map it */  	bool isDummy; +	KernelFunctionCall *function; +	const char *name;  	uint16 *signature;  	const SciWorkaroundEntry *workarounds;  	const KernelSubFunction *subFunctions;  	uint16 subFunctionCount; +	bool debugCalls;  };  enum AutoDetectedFeatures { diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index a0f38c634c..e8a28780fb 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -798,7 +798,7 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {  		workaround = trackOriginAndFindWorkaround(0, kernelCall.workarounds, workaroundFound, &originReply);  		if (!workaroundFound) {  			kernel->signatureDebug(kernelCall.signature, argc, argv); -			error("[VM] k%s (%x) signature mismatch via method %s::%s (script %d, localCall %x)", kernel->getKernelName(kernelFuncNr).c_str(), kernelFuncNr, originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr, originReply.localCallOffset); +			error("[VM] k%s (%x) signature mismatch via method %s::%s (script %d, localCall %x)", kernelCall.name, kernelFuncNr, originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr, originReply.localCallOffset);  		}  		// FIXME: implement some real workaround type logic - ignore call, still do call etc.  		if (workaround.segment) @@ -827,7 +827,7 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {  			argc--;  			argv++;  			if (subId >= kernelCall.subFunctionCount) -				error("[VM] k%s: subfunction-id %d requested, but not available", kernelCall.origName, subId); +				error("[VM] k%s: subfunction-id %d requested, but not available", kernelCall.name, subId);  			const KernelSubFunction &kernelSubCall = kernelCall.subFunctions[subId];  			if (!kernel->signatureMatch(kernelSubCall.signature, argc, argv)) {  				// Signature mismatch @@ -857,7 +857,7 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {  		if (s->_executionStack.begin() != s->_executionStack.end())  			s->_executionStack.pop_back();  	} else { -		Common::String warningMsg = "Dummy function " + kernelCall.origName + +		Common::String warningMsg = "Dummy function " + kernel->getKernelName(kernelFuncNr) +  									Common::String::printf("[0x%x]", kernelFuncNr) +  									" invoked - ignoring. Params: " +  									Common::String::printf("%d", argc) + " ("; @@ -871,7 +871,7 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {  		// Make sure that the game doesn't call a function that is considered unused. If  		// that happens, error out. -		if (kernelCall.origName == "Dummy") +		if (kernel->getKernelName(kernelFuncNr) == "Dummy")  			error("Kernel function %d was called, which was considered to be unused", kernelFuncNr);  	}  }  | 
