diff options
author | Martin Kiewitz | 2010-07-29 17:22:38 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-07-29 17:22:38 +0000 |
commit | 41ed8b438944025628b2e5a002ea3815b694fd22 (patch) | |
tree | 95c09d4ccc11f004ae54f59717d59eb7889728c6 | |
parent | 148c830d769aaf4fd4e08e46284d419ff0c93f18 (diff) | |
download | scummvm-rg350-41ed8b438944025628b2e5a002ea3815b694fd22.tar.gz scummvm-rg350-41ed8b438944025628b2e5a002ea3815b694fd22.tar.bz2 scummvm-rg350-41ed8b438944025628b2e5a002ea3815b694fd22.zip |
SCI: some subfunction support for logkernel
svn-id: r51475
-rw-r--r-- | engines/sci/engine/kernel.cpp | 29 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 3 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 19 |
3 files changed, 42 insertions, 9 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 58ac35462e..a7e5ab208a 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -654,9 +654,15 @@ bool Kernel::debugSetFunctionLogging(const char *kernelName, bool logging) { if (strcmp(kernelName, "*")) { for (uint id = 0; id < _kernelFuncs.size(); id++) { if (_kernelFuncs[id].name) { - if (strcmp(kernelName, _kernelFuncs[id].name) == 0) { - _kernelFuncs[id].debugLogging = logging; - return true; + if (!_kernelFuncs[id].subFunctions) { + // No sub-functions, enable actual kernel function + if (strcmp(kernelName, _kernelFuncs[id].name) == 0) { + _kernelFuncs[id].debugLogging = logging; + return true; + } + } else { + // Sub-Functions available + // TODO: do this } } } @@ -664,8 +670,21 @@ bool Kernel::debugSetFunctionLogging(const char *kernelName, bool logging) { } // Set debugLogging for all calls for (uint id = 0; id < _kernelFuncs.size(); id++) { - if (_kernelFuncs[id].name) - _kernelFuncs[id].debugLogging = logging; + if (_kernelFuncs[id].name) { + if (!_kernelFuncs[id].subFunctions) { + // No sub-functions, enable actual kernel function + _kernelFuncs[id].debugLogging = logging; + } else { + // Sub-Functions available, enable those too + KernelSubFunction *kernelSubCall = _kernelFuncs[id].subFunctions; + uint kernelSubCallCount = _kernelFuncs[id].subFunctionCount; + for (uint subId = 0; subId < kernelSubCallCount; subId++) { + if (kernelSubCall->function) + kernelSubCall->debugLogging = logging; + kernelSubCall++; + } + } + } } return true; } diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 227eb19c01..285e746349 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -126,6 +126,7 @@ struct KernelSubFunction { const char *name; uint16 *signature; const SciWorkaroundEntry *workarounds; + bool debugLogging; }; struct KernelFunction { @@ -133,7 +134,7 @@ struct KernelFunction { const char *name; uint16 *signature; const SciWorkaroundEntry *workarounds; - const KernelSubFunction *subFunctions; + KernelSubFunction *subFunctions; uint16 subFunctionCount; bool debugLogging; }; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 6625387b56..b7f6896a48 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -647,9 +647,19 @@ static void addKernelCallToExecStack(EngineState *s, int kernelCallNr, int argc, xstack->type = EXEC_STACK_TYPE_KERNEL; } -static void logKernelCall(const KernelFunction *kernelCall, EngineState *s, int argc, reg_t *argv, reg_t result) { +static void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunction *kernelSubCall, EngineState *s, int argc, reg_t *argv, reg_t result) { Kernel *kernel = g_sci->getKernel(); - printf("k%s: ", kernelCall->name); + if (!kernelSubCall) { + printf("k%s: ", kernelCall->name); + } else { + int callNameLen = strlen(kernelCall->name); + if (strncmp(kernelCall->name, kernelSubCall->name, callNameLen) == 0) { + const char *subCallName = kernelSubCall->name + callNameLen; + printf("k%s(%s): ", kernelCall->name, subCallName); + } else { + printf("k%s(%s): ", kernelCall->name, kernelSubCall->name); + } + } for (int parmNr = 0; parmNr < argc; parmNr++) { if (parmNr) printf(", "); @@ -732,7 +742,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { s->r_acc = kernelCall.function(s, argc, argv); if (kernelCall.debugLogging) - logKernelCall(&kernelCall, s, argc, argv, s->r_acc); + logKernelCall(&kernelCall, NULL, s, argc, argv, s->r_acc); } else { // Sub-functions available, check signature and call that one directly if (argc < 1) @@ -780,6 +790,9 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { error("[VM] k%s: subfunction-id %d requested, but not available", kernelCall.name, subId); addKernelCallToExecStack(s, kernelCallNr, argc, argv); s->r_acc = kernelSubCall.function(s, argc, argv); + + if (kernelSubCall.debugLogging) + logKernelCall(&kernelCall, &kernelSubCall, s, argc, argv, s->r_acc); } // Remove callk stack frame again, if there's still an execution stack |