aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2010-01-29 11:03:54 +0000
committerMax Horn2010-01-29 11:03:54 +0000
commit4ffec28103972992482dbb552d7f302ea09c1a31 (patch)
treeccefa339cd087c7298274d1234d7e048def51390 /engines
parent52ef12547feee896c632b842f5aebbdcc9c84bd8 (diff)
downloadscummvm-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')
-rw-r--r--engines/sci/console.cpp1
-rw-r--r--engines/sci/engine/kernel.h48
-rw-r--r--engines/sci/engine/kernel32.cpp1
-rw-r--r--engines/sci/engine/kevent.cpp1
-rw-r--r--engines/sci/engine/kgraphics.cpp1
-rw-r--r--engines/sci/engine/klists.cpp7
-rw-r--r--engines/sci/engine/kmovement.cpp1
-rw-r--r--engines/sci/engine/kparse.cpp1
-rw-r--r--engines/sci/engine/kpathing.cpp1
-rw-r--r--engines/sci/engine/kscripts.cpp1
-rw-r--r--engines/sci/engine/selector.cpp7
-rw-r--r--engines/sci/engine/selector.h88
-rw-r--r--engines/sci/engine/state.cpp1
-rw-r--r--engines/sci/graphics/animate.cpp5
-rw-r--r--engines/sci/graphics/controls.cpp1
-rw-r--r--engines/sci/graphics/gfx.cpp1
-rw-r--r--engines/sci/graphics/gui.cpp1
-rw-r--r--engines/sci/graphics/menu.cpp1
-rw-r--r--engines/sci/sound/audio.cpp1
-rw-r--r--engines/sci/sound/soundcmd.cpp2
20 files changed, 115 insertions, 56 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index edf36d52a5..48702de6d6 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -32,6 +32,7 @@
#include "sci/resource.h"
#include "sci/engine/savegame.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/engine/gc.h"
#include "sci/engine/kernel_types.h" // for determine_reg_type
#ifdef USE_OLD_MUSIC_FUNCTIONS
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"
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index 439240a43f..8718fa4f97 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -29,6 +29,7 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/engine/vm.h"
#include "sci/graphics/gfx.h"
#include "sci/graphics/view.h"
@@ -91,7 +92,7 @@ bool SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) {
signal = GET_SEL32V(_s->_segMan, curObject, signal);
if (!(signal & kSignalFrozen)) {
// Call .doit method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argv, argc, 0);
+ invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argc, argv, 0);
// Lookup node again, since the nodetable it was in may have been reallocated
curNode = _s->_segMan->lookupNode(curAddress);
}
@@ -486,7 +487,7 @@ void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) {
if (signal & kSignalDisposeMe) {
// Call .delete_ method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argv, argc, 0);
+ invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argc, argv, 0);
}
listIterator--;
}
diff --git a/engines/sci/graphics/controls.cpp b/engines/sci/graphics/controls.cpp
index a3c729d84d..24336b47da 100644
--- a/engines/sci/graphics/controls.cpp
+++ b/engines/sci/graphics/controls.cpp
@@ -30,6 +30,7 @@
#include "sci/sci.h"
#include "sci/event.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/graphics/gfx.h"
#include "sci/graphics/font.h"
#include "sci/graphics/text.h"
diff --git a/engines/sci/graphics/gfx.cpp b/engines/sci/graphics/gfx.cpp
index 018ec1fad9..b3219d98e9 100644
--- a/engines/sci/graphics/gfx.cpp
+++ b/engines/sci/graphics/gfx.cpp
@@ -29,6 +29,7 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/graphics/gfx.h"
#include "sci/graphics/animate.h"
#include "sci/graphics/font.h"
diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp
index d82e16bbf9..f0185c01ae 100644
--- a/engines/sci/graphics/gui.cpp
+++ b/engines/sci/graphics/gui.cpp
@@ -30,6 +30,7 @@
#include "sci/debug.h" // for g_debug_sleeptime_factor
#include "sci/event.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/graphics/gui.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/palette.h"
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index 4202f2b3fb..a3b55608d4 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -30,6 +30,7 @@
#include "sci/sci.h"
#include "sci/event.h"
#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
#include "sci/graphics/helpers.h"
#include "sci/graphics/gfx.h"
#include "sci/graphics/animate.h"
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 9c8ddacd90..7d2b67a111 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -24,6 +24,7 @@
*/
#include "sci/resource.h"
+#include "sci/engine/selector.h"
#include "sci/engine/kernel.h"
#include "sci/engine/seg_manager.h"
#include "sci/sound/audio.h"
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index b9609014e7..5b30734045 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -33,6 +33,8 @@
#include "sci/sound/music.h"
#include "sci/sound/soundcmd.h"
+#include "sci/engine/selector.h"
+
namespace Sci {
#define SCI1_SOUND_FLAG_MAY_PAUSE 1 /* Only here for completeness; The interpreter doesn't touch this bit */