diff options
author | Max Horn | 2010-01-29 11:03:54 +0000 |
---|---|---|
committer | Max Horn | 2010-01-29 11:03:54 +0000 |
commit | 4ffec28103972992482dbb552d7f302ea09c1a31 (patch) | |
tree | ccefa339cd087c7298274d1234d7e048def51390 /engines/sci/engine | |
parent | 52ef12547feee896c632b842f5aebbdcc9c84bd8 (diff) | |
download | scummvm-rg350-4ffec28103972992482dbb552d7f302ea09c1a31.tar.gz scummvm-rg350-4ffec28103972992482dbb552d7f302ea09c1a31.tar.bz2 scummvm-rg350-4ffec28103972992482dbb552d7f302ea09c1a31.zip |
SCI: Move selector stuff to new header; reorder k_argc & k_argp param of invoke_selector
svn-id: r47665
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.h | 48 | ||||
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kparse.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/selector.h | 88 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 1 |
12 files changed, 104 insertions, 54 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 0fc7ad4190..baff486443 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -195,54 +195,6 @@ private: Common::StringList _kernelNames; }; -/******************** Selector functionality ********************/ - -enum SelectorInvocation { - kStopOnInvalidSelector = 0, - kContinueOnInvalidSelector = 1 -}; - -/** - * Retrieves a selector from an object. - * @param segMan the segment mananger - * @param _obj_ the address of the object which the selector should be read from - * @param _slc_ the selector to read - * @return the selector value as a reg_t - * This macro halts on error. 'selector' must be a selector name registered in vm.h's - * SelectorCache and mapped in script.cpp. - */ -#define GET_SEL32(segMan, _obj_, _slc_) read_selector(segMan, _obj_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_) -#define GET_SEL32V(segMan, _obj_, _slc_) (GET_SEL32(segMan, _obj_, _slc_).offset) - -/** - * Writes a selector value to an object. - * @param segMan the segment mananger - * @param _obj_ the address of the object which the selector should be written to - * @param _slc_ the selector to read - * @param _val_ the value to write - * This macro halts on error. 'selector' must be a selector name registered in vm.h's - * SelectorCache and mapped in script.cpp. - */ -#define PUT_SEL32(segMan, _obj_, _slc_, _val_) write_selector(segMan, _obj_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, _val_) -#define PUT_SEL32V(segMan, _obj_, _slc_, _val_) PUT_SEL32(segMan, _obj_, _slc_, make_reg(0, _val_)) - - -/** - * Kludge for use with invoke_selector(). Used for compatibility with compilers - * that cannot handle vararg macros. - */ -#define INV_SEL(_object_, _selector_, _noinvalid_) \ - s, _object_, s->_kernel->_selectorCache._selector_, _noinvalid_, argv, argc - - -reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id); -void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_t value); -int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, - StackPtr k_argp, int k_argc, int argc, ...); -int invoke_selector_argv(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, - StackPtr k_argp, int k_argc, int argc, const reg_t *argv); - - /******************** Text functionality ********************/ /** * Looks up text referenced by scripts diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index d4149af50a..b4a403bedb 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -28,6 +28,7 @@ #include "sci/engine/kernel.h" #include "sci/engine/segment.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/graphics/gui.h" namespace Sci { diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 3bf30681d4..47a469dd14 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -25,6 +25,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel.h" #include "sci/console.h" #include "sci/debug.h" // for g_debug_simulated_key diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 6a764d891f..764410e2b0 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -32,6 +32,7 @@ #include "sci/resource.h" #include "sci/video/seq_decoder.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel.h" #include "sci/graphics/gui.h" #include "sci/graphics/animate.h" diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 135f153298..8901fb1286 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -24,6 +24,7 @@ */ #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel.h" namespace Sci { @@ -535,7 +536,7 @@ reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv) { write_selector(s->_segMan, curObject, slc, argv[2]); } } else { - invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, argc - 2, argv + 2); + invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argc, argv, argc - 2, argv + 2); } // Lookup node again, since the nodetable it was in may have been reallocated @@ -568,7 +569,7 @@ reg_t kListFirstTrue(EngineState *s, int argc, reg_t *argv) { // Can this happen with variable selectors? warning("kListFirstTrue: Attempted to access a variable selector"); } else { - invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, argc - 2, argv + 2); + invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argc, argv, argc - 2, argv + 2); // Check if the result is true if (!s->r_acc.isNull()) @@ -606,7 +607,7 @@ reg_t kListAllTrue(EngineState *s, int argc, reg_t *argv) { // Can this happen with variable selectors? warning("kListAllTrue: Attempted to access a variable selector"); } else { - invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, argc - 2, argv + 2); + invoke_selector_argv(s, curObject, slc, kContinueOnInvalidSelector, argc, argv, argc - 2, argv + 2); // Check if the result isn't true if (s->r_acc.isNull()) diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 1aef51a276..13e55f3625 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -26,6 +26,7 @@ #include "sci/sci.h" #include "sci/resource.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel.h" #include "sci/graphics/animate.h" diff --git a/engines/sci/engine/kparse.cpp b/engines/sci/engine/kparse.cpp index b8cecf82c9..fee6a171ee 100644 --- a/engines/sci/engine/kparse.cpp +++ b/engines/sci/engine/kparse.cpp @@ -27,6 +27,7 @@ #include "sci/resource.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/message.h" #include "sci/engine/kernel.h" diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 9bd3912aa7..acf2e2a3cc 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -25,6 +25,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel.h" #include "sci/graphics/gui.h" diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index bafeb02968..87c8eef96d 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -26,6 +26,7 @@ #include "sci/sci.h" #include "sci/resource.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/kernel_types.h" #include "sci/engine/kernel.h" diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index e3abe10dde..5e8b969edf 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -25,6 +25,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" +#include "sci/engine/selector.h" namespace Sci { @@ -54,7 +55,7 @@ void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_ } int invoke_selector_argv(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, - StackPtr k_argp, int k_argc, int argc, const reg_t *argv) { + int k_argc, StackPtr k_argp, int argc, const reg_t *argv) { int i; int framesize = 2 + 1 * argc; reg_t address; @@ -96,7 +97,7 @@ int invoke_selector_argv(EngineState *s, reg_t object, int selector_id, Selector } int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, - StackPtr k_argp, int k_argc, int argc, ...) { + int k_argc, StackPtr k_argp, int argc, ...) { va_list argp; reg_t *args = new reg_t[argc]; @@ -105,7 +106,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc args[i] = va_arg(argp, reg_t); va_end(argp); - int retval = invoke_selector_argv(s, object, selector_id, noinvalid, k_argp, k_argc, argc, args); + int retval = invoke_selector_argv(s, object, selector_id, noinvalid, k_argc, k_argp, argc, args); delete[] args; return retval; diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h new file mode 100644 index 0000000000..be777c0e72 --- /dev/null +++ b/engines/sci/engine/selector.h @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef SCI_ENGINE_SELECTOR_H +#define SCI_ENGINE_SELECTOR_H + +#include "common/scummsys.h" + +#include "sci/engine/vm_types.h" // for reg_t +#include "sci/engine/vm.h" + +namespace Sci { + + +/******************** Selector functionality ********************/ + +enum SelectorInvocation { + kStopOnInvalidSelector = 0, + kContinueOnInvalidSelector = 1 +}; + +/** + * Retrieves a selector from an object. + * @param segMan the segment mananger + * @param _obj_ the address of the object which the selector should be read from + * @param _slc_ the selector to read + * @return the selector value as a reg_t + * This macro halts on error. 'selector' must be a selector name registered in vm.h's + * SelectorCache and mapped in script.cpp. + */ +#define GET_SEL32(segMan, _obj_, _slc_) read_selector(segMan, _obj_, ((SciEngine *)g_engine)->getKernel()->_selectorCache._slc_) +#define GET_SEL32V(segMan, _obj_, _slc_) (GET_SEL32(segMan, _obj_, _slc_).offset) + +/** + * Writes a selector value to an object. + * @param segMan the segment mananger + * @param _obj_ the address of the object which the selector should be written to + * @param _slc_ the selector to read + * @param _val_ the value to write + * This macro halts on error. 'selector' must be a selector name registered in vm.h's + * SelectorCache and mapped in script.cpp. + */ +#define PUT_SEL32(segMan, _obj_, _slc_, _val_) write_selector(segMan, _obj_, ((SciEngine *)g_engine)->getKernel()->_selectorCache._slc_, _val_) +#define PUT_SEL32V(segMan, _obj_, _slc_, _val_) PUT_SEL32(segMan, _obj_, _slc_, make_reg(0, _val_)) + + +/** + * Kludge for use with invoke_selector(). Used for compatibility with compilers + * that cannot handle vararg macros. + */ +#define INV_SEL(_object_, _selector_, _noinvalid_) \ + s, _object_, s->_kernel->_selectorCache._selector_, _noinvalid_, argc, argv + + +reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id); +void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_t value); +int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, + int k_argc, StackPtr k_argp, int argc, ...); +int invoke_selector_argv(EngineState *s, reg_t object, int selector_id, SelectorInvocation noinvalid, + int k_argc, StackPtr k_argp, int argc, const reg_t *argv); + + + +} // End of namespace Sci + +#endif // SCI_ENGINE_KERNEL_H diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 7002834a9f..81d9fe9449 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -26,6 +26,7 @@ #include "sci/sci.h" // for INCLUDE_OLDGFX #include "sci/engine/state.h" +#include "sci/engine/selector.h" #include "sci/engine/vm.h" #include "sci/engine/script.h" #include "sci/engine/message.h" |