diff options
author | Max Horn | 2009-09-17 16:53:58 +0000 |
---|---|---|
committer | Max Horn | 2009-09-17 16:53:58 +0000 |
commit | f2d2276c4ac02a84dadabbdf8863d09ec946d3c7 (patch) | |
tree | 15805a20c9f8d9e9dd79afd5aadd3ac2d73c06d3 /engines/sci/engine/kscripts.cpp | |
parent | eb77efda785dd7df31a90fb3fd57ea17bf49a606 (diff) | |
download | scummvm-rg350-f2d2276c4ac02a84dadabbdf8863d09ec946d3c7.tar.gz scummvm-rg350-f2d2276c4ac02a84dadabbdf8863d09ec946d3c7.tar.bz2 scummvm-rg350-f2d2276c4ac02a84dadabbdf8863d09ec946d3c7.zip |
SCI: Move some selector related function into a new file selector.cpp
svn-id: r44171
Diffstat (limited to 'engines/sci/engine/kscripts.cpp')
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index ce7656f47e..2978a2a2e2 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -31,82 +31,6 @@ namespace Sci { -reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id, const char *file, int line) { - ObjVarRef address; - - if (lookup_selector(segMan, object, selector_id, &address, NULL) != kSelectorVariable) - return NULL_REG; - else - return *address.getPointer(segMan); -} - -void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_t value, const char *fname, int line) { - ObjVarRef address; - - if ((selector_id < 0) || (selector_id > (int)((SciEngine*)g_engine)->getKernel()->getSelectorNamesSize())) { - warning("Attempt to write to invalid selector %d of" - " object at %04x:%04x (%s L%d).", selector_id, PRINT_REG(object), fname, line); - return; - } - - if (lookup_selector(segMan, object, selector_id, &address, NULL) != kSelectorVariable) - warning("Selector '%s' of object at %04x:%04x could not be" - " written to (%s L%d)", ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line); - else - *address.getPointer(segMan) = value; -} - -int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, int kfunct, - StackPtr k_argp, int k_argc, const char *fname, int line, int argc, ...) { - va_list argp; - int i; - int framesize = 2 + 1 * argc; - reg_t address; - int slc_type; - StackPtr stackframe = k_argp + k_argc; - - stackframe[0] = make_reg(0, selector_id); // The selector we want to call - stackframe[1] = make_reg(0, argc); // Argument count - - slc_type = lookup_selector(s->segMan, object, selector_id, NULL, &address); - - if (slc_type == kSelectorNone) { - warning("Selector '%s' of object at %04x:%04x could not be invoked (%s L%d)", - ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line); - if (noinvalid == kStopOnInvalidSelector) - error("[Kernel] Not recoverable: VM was halted"); - return 1; - } - if (slc_type == kSelectorVariable) // Swallow silently - return 0; - - va_start(argp, argc); - for (i = 0; i < argc; i++) { - reg_t arg = va_arg(argp, reg_t); - stackframe[2 + i] = arg; // Write each argument - } - va_end(argp); - - // Write "kernel" call to the stack, for debugging: - ExecStack *xstack; - xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, k_argc, k_argp - 1, 0, NULL_REG, - s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS); - xstack->selector = -42 - kfunct; // Evil debugging hack to identify kernel function - xstack->type = EXEC_STACK_TYPE_KERNEL; - - // Now commit the actual function: - xstack = send_selector(s, object, object, stackframe, framesize, stackframe); - - xstack->sp += argc + 2; - xstack->fp += argc + 2; - - run_vm(s, 0); // Start a new vm - - s->_executionStack.pop_back(); // Get rid of the extra stack entry - - return 0; -} - // Loads arbitrary resources of type 'restype' with resource numbers 'resnrs' // This implementation ignores all resource numbers except the first one. reg_t kLoad(EngineState *s, int, int argc, reg_t *argv) { |