mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-20 16:59:06 +00:00
SCI: Move selector stuff to new header; reorder k_argc & k_argp param of invoke_selector
svn-id: r47665
This commit is contained in:
parent
52ef12547f
commit
4ffec28103
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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())
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
|
88
engines/sci/engine/selector.h
Normal file
88
engines/sci/engine/selector.h
Normal file
@ -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
|
@ -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"
|
||||
|
@ -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--;
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user