aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-02-13 17:45:40 +0000
committerMax Horn2010-02-13 17:45:40 +0000
commite45f0f309acd2448dc042bd89584791f932388a3 (patch)
tree89440faa87e843d4460cd3a1221915e18dffbdb1
parent9575cc08a2d54af57ada390f0f736d64857a49d1 (diff)
downloadscummvm-rg350-e45f0f309acd2448dc042bd89584791f932388a3.tar.gz
scummvm-rg350-e45f0f309acd2448dc042bd89584791f932388a3.tar.bz2
scummvm-rg350-e45f0f309acd2448dc042bd89584791f932388a3.zip
SCI: Remove EngineState::_kernel, use SciEngine::_kernel instead
svn-id: r48050
-rw-r--r--engines/sci/console.cpp4
-rw-r--r--engines/sci/engine/kgraphics.cpp4
-rw-r--r--engines/sci/engine/kmovement.cpp2
-rw-r--r--engines/sci/engine/savegame.cpp2
-rw-r--r--engines/sci/engine/scriptdebug.cpp2
-rw-r--r--engines/sci/engine/selector.cpp4
-rw-r--r--engines/sci/engine/selector.h2
-rw-r--r--engines/sci/engine/state.cpp8
-rw-r--r--engines/sci/engine/state.h3
-rw-r--r--engines/sci/engine/vm.cpp16
-rw-r--r--engines/sci/graphics/animate.cpp4
-rw-r--r--engines/sci/graphics/gui.cpp4
-rw-r--r--engines/sci/graphics/gui32.cpp4
-rw-r--r--engines/sci/sci.cpp2
-rw-r--r--engines/sci/sci.h8
15 files changed, 34 insertions, 35 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index d6c3b07f75..3b42a36bb9 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -402,8 +402,8 @@ ResourceType parseResourceType(const char *resid) {
}
const char *selector_name(EngineState *s, int selector) {
- if (selector >= 0 && selector < (int)s->_kernel->getSelectorNamesSize())
- return s->_kernel->getSelectorName(selector).c_str();
+ if (selector >= 0 && selector < (int)g_sci->getKernel()->getSelectorNamesSize())
+ return g_sci->getKernel()->getSelectorName(selector).c_str();
else
return "--INVALID--";
}
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 8eb2401b3a..592d1d4fd0 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -826,12 +826,12 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
maxChars = GET_SEL32V(s->_segMan, controlObject, SELECTOR(x)); // max chars per entry
cursorOffset = GET_SEL32V(s->_segMan, controlObject, SELECTOR(cursor));
- if (s->_kernel->_selectorCache.topString != -1) {
+ if (g_sci->getKernel()->_selectorCache.topString != -1) {
// Games from early SCI1 onwards use topString
upperOffset = GET_SEL32V(s->_segMan, controlObject, SELECTOR(topString));
} else {
// Earlier games use lsTop or brTop
- if (lookup_selector(s->_segMan, controlObject, s->_kernel->_selectorCache.brTop, NULL, NULL) == kSelectorVariable)
+ if (lookup_selector(s->_segMan, controlObject, g_sci->getKernel()->_selectorCache.brTop, NULL, NULL) == kSelectorVariable)
upperOffset = GET_SEL32V(s->_segMan, controlObject, SELECTOR(brTop));
else
upperOffset = GET_SEL32V(s->_segMan, controlObject, SELECTOR(lsTop));
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index b91ccadce6..1dd3227aef 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -315,7 +315,7 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) {
debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d", x, y, bdi);
- if (s->_kernel->_selectorCache.cantBeHere != -1) {
+ if (g_sci->getKernel()->_selectorCache.cantBeHere != -1) {
invoke_selector(INV_SEL(client, cantBeHere, kStopOnInvalidSelector), 0);
s->r_acc = make_reg(0, !s->r_acc.offset);
} else {
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index cef8525200..22405b8b99 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -944,7 +944,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
}
// Create a new EngineState object
- retval = new EngineState(s->_kernel, s->_voc, s->_segMan, s->_audio);
+ retval = new EngineState(s->_voc, s->_segMan, s->_audio);
retval->_event = new SciEvent();
// Copy some old data
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index cbf8379273..57c9f47f24 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -107,7 +107,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
reg_t retval = make_reg(pos.segment, pos.offset + 1);
uint16 param_value;
int i = 0;
- Kernel *kernel = s->_kernel;
+ Kernel *kernel = g_sci->getKernel();
if (!mobj) {
warning("Disassembly failed: Segment %04x non-existant or not a script", pos.segment);
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 8a859b1431..20a10a180e 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -215,14 +215,14 @@ int invoke_selector_argv(EngineState *s, reg_t object, int selector_id, Selector
if (slc_type == kSelectorNone) {
warning("Selector '%s' of object at %04x:%04x could not be invoked",
- s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object));
+ g_sci->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object));
if (noinvalid == kStopOnInvalidSelector)
error("[Kernel] Not recoverable: VM was halted");
return 1;
}
if (slc_type == kSelectorVariable) {
warning("Attempting to invoke variable selector %s of object %04x:%04x",
- s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object));
+ g_sci->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object));
return 0;
}
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index 427af7430a..e824d8713d 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -79,7 +79,7 @@ enum SelectorInvocation {
* that cannot handle vararg macros.
*/
#define INV_SEL(_object_, _selector_, _noinvalid_) \
- s, _object_, s->_kernel->_selectorCache._selector_, _noinvalid_, argc, argv
+ s, _object_, g_sci->getKernel()->_selectorCache._selector_, _noinvalid_, argc, argv
reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id);
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index d61bc7ede8..4559ebd763 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -33,8 +33,8 @@
namespace Sci {
-EngineState::EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, AudioPlayer *audio)
-: _kernel(kernel), _voc(voc), _segMan(segMan), _audio(audio), _dirseeker() {
+EngineState::EngineState(Vocabulary *voc, SegManager *segMan, AudioPlayer *audio)
+: _voc(voc), _segMan(segMan), _audio(audio), _dirseeker() {
#ifdef USE_OLD_MUSIC_FUNCTIONS
sfx_init_flags = 0;
@@ -145,7 +145,7 @@ kLanguage EngineState::getLanguage() {
lang = K_LANG_ENGLISH;
- if (_kernel->_selectorCache.printLang != -1) {
+ if (g_sci->getKernel()->_selectorCache.printLang != -1) {
lang = (kLanguage)GET_SEL32V(_segMan, _gameObj, SELECTOR(printLang));
if ((getSciVersion() >= SCI_VERSION_1_1) || (lang == K_LANG_NONE)) {
@@ -192,7 +192,7 @@ Common::String EngineState::strSplit(const char *str, const char *sep) {
kLanguage lang = getLanguage();
kLanguage subLang = K_LANG_NONE;
- if (_kernel->_selectorCache.subtitleLang != -1) {
+ if (g_sci->getKernel()->_selectorCache.subtitleLang != -1) {
subLang = (kLanguage)GET_SEL32V(_segMan, _gameObj, SELECTOR(subtitleLang));
}
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index eca061027c..f7011a1a2c 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -108,14 +108,13 @@ public:
struct EngineState : public Common::Serializable {
public:
- EngineState(Kernel *kernel, Vocabulary *voc, SegManager *segMan, AudioPlayer *audio);
+ EngineState(Vocabulary *voc, SegManager *segMan, AudioPlayer *audio);
virtual ~EngineState();
virtual void saveLoadWithSerializer(Common::Serializer &ser);
public:
SegManager *_segMan; /**< The segment manager */
- Kernel *_kernel;
Vocabulary *_voc;
Common::String _gameId; /**< Designation of the primary object (which inherits from Game) */
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 9c1e203c5f..cb106950e9 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -240,7 +240,7 @@ static void validate_write_var(reg_t *r, reg_t *stack_base, int type, int max, i
#endif
#define READ_VAR(type, index, def) validate_read_var(scriptState.variables[type], s->stack_base, type, scriptState.variables_max[type], index, __LINE__, def)
-#define WRITE_VAR(type, index, value) validate_write_var(scriptState.variables[type], s->stack_base, type, scriptState.variables_max[type], index, __LINE__, value, s->_segMan, s->_kernel)
+#define WRITE_VAR(type, index, value) validate_write_var(scriptState.variables[type], s->stack_base, type, scriptState.variables_max[type], index, __LINE__, value, s->_segMan, g_sci->getKernel())
#define WRITE_VAR16(type, index, value) WRITE_VAR(type, index, make_reg(0, value));
#define ACC_ARITHMETIC_L(op) make_reg(0, (op validate_arithmetic(s->r_acc)))
@@ -360,7 +360,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
if (s->_activeBreakpointTypes & BREAK_SELECTOR) {
char method_name[256];
- sprintf(method_name, "%s::%s", s->_segMan->getObjectName(send_obj), s->_kernel->getSelectorName(selector).c_str());
+ sprintf(method_name, "%s::%s", s->_segMan->getObjectName(send_obj), g_sci->getKernel()->getSelectorName(selector).c_str());
Common::List<Breakpoint>::const_iterator bp;
for (bp = s->_breakpoints.begin(); bp != s->_breakpoints.end(); ++bp) {
@@ -561,10 +561,10 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
static void callKernelFunc(EngineState *s, int kernelFuncNum, int argc) {
- if (kernelFuncNum >= (int)s->_kernel->_kernelFuncs.size())
+ if (kernelFuncNum >= (int)g_sci->getKernel()->_kernelFuncs.size())
error("Invalid kernel function 0x%x requested", kernelFuncNum);
- const KernelFuncWithSignature &kernelFunc = s->_kernel->_kernelFuncs[kernelFuncNum];
+ const KernelFuncWithSignature &kernelFunc = g_sci->getKernel()->_kernelFuncs[kernelFuncNum];
if (kernelFunc.signature
&& !kernel_matches_signature(s->_segMan, kernelFunc.signature, argc, scriptState.xs->sp + 1)) {
@@ -1358,7 +1358,7 @@ void run_vm(EngineState *s, bool restoring) {
var_container = s->_segMan->getObject(obj->getSuperClassSelector());
uint16 varSelector = var_container->getVarSelector(opparams[0] >> 1);
// printf("%X\n", varSelector);
-// printf("%s\n", s->_kernel->getSelectorName(varSelector).c_str());
+// printf("%s\n", g_sci->getKernel()->getSelectorName(varSelector).c_str());
if ((varSelector == 0x84) || (varSelector == 0x92))) {
// selectors cycles, cycleCnt from lsl5 hardcoded
uint32 curTime = g_system->getMillis();
@@ -1698,7 +1698,7 @@ static EngineState *_game_run(EngineState *&s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
s->_sound.sfx_reset_player();
#endif
- _init_stack_base_with_selector(s, s->_kernel->_selectorCache.play);
+ _init_stack_base_with_selector(s, g_sci->getKernel()->_selectorCache.play);
send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base);
@@ -1716,7 +1716,7 @@ static EngineState *_game_run(EngineState *&s) {
debugC(2, kDebugLevelVM, "Restarting with replay()");
s->_executionStack.clear(); // Restart with replay
- _init_stack_base_with_selector(s, s->_kernel->_selectorCache.replay);
+ _init_stack_base_with_selector(s, g_sci->getKernel()->_selectorCache.replay);
send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base);
}
@@ -1735,7 +1735,7 @@ int game_run(EngineState **_s) {
EngineState *s = *_s;
debugC(2, kDebugLevelVM, "Calling %s::play()", s->_gameId.c_str());
- _init_stack_base_with_selector(s, s->_kernel->_selectorCache.play); // Call the play selector
+ _init_stack_base_with_selector(s, g_sci->getKernel()->_selectorCache.play); // Call the play selector
// Now: Register the first element on the execution stack-
if (!send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base)) {
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index b42a794399..67c41ee9ba 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -95,7 +95,7 @@ bool GfxAnimate::invoke(List *list, int argc, reg_t *argv) {
signal = GET_SEL32V(_s->_segMan, curObject, SELECTOR(signal));
if (!(signal & kSignalFrozen)) {
// Call .doit method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argc, argv, 0);
+ invoke_selector(_s, curObject, g_sci->getKernel()->_selectorCache.doit, kContinueOnInvalidSelector, argc, argv, 0);
// Lookup node again, since the nodetable it was in may have been reallocated
curNode = _s->_segMan->lookupNode(curAddress);
}
@@ -490,7 +490,7 @@ void GfxAnimate::restoreAndDelete(int argc, reg_t *argv) {
if (signal & kSignalDisposeMe) {
// Call .delete_ method of that object
- invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argc, argv, 0);
+ invoke_selector(_s, curObject, g_sci->getKernel()->_selectorCache.delete_, kContinueOnInvalidSelector, argc, argv, 0);
}
listIterator--;
}
diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp
index 5f3fa32ff8..c5ce6672a1 100644
--- a/engines/sci/graphics/gui.cpp
+++ b/engines/sci/graphics/gui.cpp
@@ -60,10 +60,10 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
_coordAdjuster = new GfxCoordAdjuster16(_ports);
g_sci->_gfxCoordAdjuster = _coordAdjuster;
_cursor->init(_coordAdjuster, _s->_event);
- _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster);
+ _compare = new GfxCompare(_s->_segMan, g_sci->getKernel(), _cache, _screen, _coordAdjuster);
g_sci->_gfxCompare = _compare;
_transitions = new GfxTransitions(this, _screen, _palette, g_sci->getResMan()->isVGA());
- _paint16 = new GfxPaint16(g_sci->getResMan(), _s->_segMan, _s->_kernel, this, _cache, _ports, _coordAdjuster, _screen, _palette, _transitions);
+ _paint16 = new GfxPaint16(g_sci->getResMan(), _s->_segMan, g_sci->getKernel(), this, _cache, _ports, _coordAdjuster, _screen, _palette, _transitions);
g_sci->_gfxPaint = _paint16;
g_sci->_gfxPaint16 = _paint16;
_animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions);
diff --git a/engines/sci/graphics/gui32.cpp b/engines/sci/graphics/gui32.cpp
index 80454378d5..9e0b7f68e0 100644
--- a/engines/sci/graphics/gui32.cpp
+++ b/engines/sci/graphics/gui32.cpp
@@ -52,9 +52,9 @@ SciGui32::SciGui32(EngineState *state, GfxScreen *screen, GfxPalette *palette, G
_coordAdjuster = new GfxCoordAdjuster32(_s->_segMan);
g_sci->_gfxCoordAdjuster = _coordAdjuster;
_cursor->init(_coordAdjuster, _s->_event);
- _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster);
+ _compare = new GfxCompare(_s->_segMan, g_sci->getKernel(), _cache, _screen, _coordAdjuster);
g_sci->_gfxCompare = _compare;
- _paint32 = new GfxPaint32(g_sci->getResMan(), _s->_segMan, _s->_kernel, _coordAdjuster, _cache, _screen, _palette);
+ _paint32 = new GfxPaint32(g_sci->getResMan(), _s->_segMan, g_sci->getKernel(), _coordAdjuster, _cache, _screen, _palette);
g_sci->_gfxPaint = _paint32;
_frameout = new GfxFrameout(_s->_segMan, g_sci->getResMan(), _coordAdjuster, _cache, _screen, _palette, _paint32);
g_sci->_gfxFrameout = _frameout;
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index fc6fc218f6..e1cfacc8b4 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -181,7 +181,7 @@ Common::Error SciEngine::run() {
_features = new GameFeatures(segMan, _kernel);
// We'll set the GUI below
- _gamestate = new EngineState(_kernel, _vocabulary, segMan, _audio);
+ _gamestate = new EngineState(_vocabulary, segMan, _audio);
_gamestate->_event = new SciEvent();
if (script_init_engine(_gamestate))
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index c411f48bc9..2138b131cd 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -149,10 +149,10 @@ public:
uint32 getFlags() const;
bool isDemo() const;
- ResourceManager *getResMan() const { return _resMan; }
- Kernel *getKernel() const { return _kernel; }
- EngineState *getEngineState() const { return _gamestate; }
- Vocabulary *getVocabulary() const { return _vocabulary; }
+ inline ResourceManager *getResMan() const { return _resMan; }
+ inline Kernel *getKernel() const { return _kernel; }
+ inline EngineState *getEngineState() const { return _gamestate; }
+ inline Vocabulary *getVocabulary() const { return _vocabulary; }
Common::String getSavegameName(int nr) const;
Common::String getSavegamePattern() const;