diff options
author | Willem Jan Palenstijn | 2016-04-01 23:54:00 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2016-07-02 21:25:53 +0200 |
commit | d643cb651f5661a80c7d7ea493ff397cf0bef3fd (patch) | |
tree | 07cd0ef81e904d9c4c8c79910a4e3f3a265c3103 /engines | |
parent | 7f12638763e9732bc75aab4823c43ebdf8a8c2be (diff) | |
download | scummvm-rg350-d643cb651f5661a80c7d7ea493ff397cf0bef3fd.tar.gz scummvm-rg350-d643cb651f5661a80c7d7ea493ff397cf0bef3fd.tar.bz2 scummvm-rg350-d643cb651f5661a80c7d7ea493ff397cf0bef3fd.zip |
SCI: Remove unexpected side effect from ExecStack constructor
The ExecStack constructor set argp[0] to argc before. This is now moved
to the caller, to make this action more explicit.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/vm.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 273492ccc6..3e12084ed6 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -239,6 +239,7 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP // Check if a breakpoint is set on this method g_sci->checkExportBreakpoint(script, pubfunct); + assert(argp[0].toUint16() == argc); // The first argument is argc ExecStack xstack(calling_obj, calling_obj, sp, argc, argp, seg, make_reg32(seg, exportAddr), -1, -1, -1, pubfunct, -1, s->_executionStack.size() - 1, EXEC_STACK_TYPE_CALL); @@ -312,6 +313,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt if (activeBreakpointTypes || DebugMan.isDebugChannelEnabled(kDebugLevelScripts)) debugSelectorCall(send_obj, selector, argc, argp, varp, funcp, s->_segMan, selectorType); + assert(argp[0].toUint16() == argc); // The first argument is argc ExecStack xstack(work_obj, send_obj, curSP, argc, argp, 0xFFFF, curFP, selector, -1, -1, -1, -1, origin, stackType); @@ -386,6 +388,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { // Call kernel function if (!kernelCall.subFunctionCount) { + argv[-1] = make_reg(0, argc); // The first argument is argc addKernelCallToExecStack(s, kernelCallNr, -1, argc, argv); s->r_acc = kernelCall.function(s, argc, argv); @@ -444,6 +447,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { } if (!kernelSubCall.function) error("[VM] k%s: subfunction ID %d requested, but not available", kernelCall.name, subId); + argv[-1] = make_reg(0, argc); // The first argument is argc addKernelCallToExecStack(s, kernelCallNr, subId, argc, argv); s->r_acc = kernelSubCall.function(s, argc, argv); @@ -837,8 +841,10 @@ void run_vm(EngineState *s) { uint32 localCallOffset = s->xs->addr.pc.getOffset() + opparams[0]; + int final_argc = (call_base->requireUint16()) + s->r_rest; + call_base[0] = make_reg(0, final_argc); // The first argument is argc ExecStack xstack(s->xs->objp, s->xs->objp, s->xs->sp, - (call_base->requireUint16()) + s->r_rest, call_base, + final_argc, call_base, s->xs->local_segment, make_reg32(s->xs->addr.pc.getSegment(), localCallOffset), NULL_SELECTOR, -1, -1, -1, localCallOffset, s->_executionStack.size() - 1, EXEC_STACK_TYPE_CALL); diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index dc789b6201..c41060dc32 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -115,7 +115,6 @@ struct ExecStack { fp = sp = sp_; argc = argc_; variables_argp = argp_; - *variables_argp = make_reg(0, argc); // The first argument is argc if (localsSegment_ != 0xFFFF) local_segment = localsSegment_; else |