aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2009-09-30 16:00:44 +0000
committerMax Horn2009-09-30 16:00:44 +0000
commit27026f65652a2afc02947303c1bde68e21724d15 (patch)
tree0ec53a51334f05db77b79866ee3d4cd9f554e705 /engines/sci
parentc76041d46d82215ff59f885d3bd089d602e493cf (diff)
downloadscummvm-rg350-27026f65652a2afc02947303c1bde68e21724d15.tar.gz
scummvm-rg350-27026f65652a2afc02947303c1bde68e21724d15.tar.bz2
scummvm-rg350-27026f65652a2afc02947303c1bde68e21724d15.zip
SCI: Replace magic '-42' by an enum
svn-id: r44492
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/vm.cpp11
-rw-r--r--engines/sci/engine/vm.h8
3 files changed, 13 insertions, 8 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 032264bcaf..1cba6077d2 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -2003,7 +2003,7 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
break;
case EXEC_STACK_TYPE_KERNEL: // Kernel function
- printf(" %x:[%x] k%s(", i, call.origin, _vm->getKernel()->getKernelName(-(call.selector) - 42).c_str());
+ printf(" %x:[%x] k%s(", i, call.origin, _vm->getKernel()->getKernelName(kMagicSelectorOffset - call.selector).c_str());
break;
case EXEC_STACK_TYPE_VARSELECTOR:
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index c9b665d881..acb89824b2 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -953,7 +953,7 @@ void run_vm(EngineState *s, int restoring) {
xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, NULL_REG,
s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
// Debugging hack to identify kernel function
- xstack->selector = -42 - opparams[0];
+ xstack->selector = kMagicSelectorOffset - opparams[0];
xstack->type = EXEC_STACK_TYPE_KERNEL;
// Call kernel function
@@ -962,14 +962,11 @@ void run_vm(EngineState *s, int restoring) {
// Remove callk stack frame again
s->_executionStack.pop_back();
} else {
- Common::String warningMsg = "Dummy function " + kfun.orig_name + "[";
- warningMsg += warningMsg.printf("0x%x", opparams[0]);
- warningMsg += "] invoked - ignoring. Params: ";
- warningMsg += warningMsg.printf("%d", argc);
- warningMsg += " (";
+ Common::String warningMsg = "Dummy function " + kfun.orig_name;
+ warningMsg += Common::String::printf("[0x%x] invoked - ignoring. Params: %d (", opparams[0], argc);
for (int i = 0; i < argc; i++) {
- warningMsg += warningMsg.printf("%04x:%04x", PRINT_REG(argv[i]));
+ warningMsg += Common::String::printf("%04x:%04x", PRINT_REG(argv[i]));
warningMsg += (i == argc - 1 ? ")" : ", ");
}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 530a293081..9247bfa350 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -102,6 +102,14 @@ enum SelectorType {
kSelectorMethod
};
+enum {
+ /**
+ * Magic offset, used to compute fake selector values for use in ExecStack
+ * when doing a callk. See the callk code in vm.cpp for details.
+ */
+ kMagicSelectorOffset = -42
+};
+
struct Class {
int script; /**< number of the script the class is in, -1 for non-existing */
reg_t reg; /**< offset; script-relative offset, segment: 0 if not instantiated */