diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 32 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 3 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 14 |
11 files changed, 38 insertions, 39 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 4da3814e30..218b6bad4d 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -219,7 +219,7 @@ int _reset_graphics_input(EngineState *s) { s->priority_first = 42; // Priority zone 0 ends here - if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions()) + if (s->_kernel->usesOldGfxFunctions()) s->priority_last = 200; else s->priority_last = 190; diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 0010e3cd64..93f8de4157 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -193,7 +193,7 @@ enum { }; #define INV_SEL(_object_, _selector_, _noinvalid_) \ - s, _object_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._selector_, _noinvalid_, FAKE_FUNCT_NR, argv, argc, __FILE__, __LINE__ + s, _object_, s->_kernel->_selectorCache._selector_, _noinvalid_, FAKE_FUNCT_NR, argv, argc, __FILE__, __LINE__ /* Kludge for use with invoke_selector(). Used for compatibility with compilers that can't ** handle vararg macros. */ diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 80db212703..e483b3b9ad 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -145,7 +145,7 @@ int _find_view_priority(EngineState *s, int y) { return j; return 14; // Maximum } else { - if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions()) + if (!s->_kernel->usesOldGfxFunctions()) return SCI0_VIEW_PRIORITY_14_ZONES(y); else return SCI0_VIEW_PRIORITY(y) == 15 ? 14 : SCI0_VIEW_PRIORITY(y); @@ -153,7 +153,7 @@ int _find_view_priority(EngineState *s, int y) { } int _find_priority_band(EngineState *s, int nr) { - if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions() && (nr < 0 || nr > 14)) { + if (!s->_kernel->usesOldGfxFunctions() && (nr < 0 || nr > 14)) { if (nr == 15) return 0xffff; else { @@ -162,7 +162,7 @@ int _find_priority_band(EngineState *s, int nr) { return 0; } - if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions() && (nr < 0 || nr > 15)) { + if (s->_kernel->usesOldGfxFunctions() && (nr < 0 || nr > 15)) { warning("Attempt to get priority band %d", nr); return 0; } @@ -172,7 +172,7 @@ int _find_priority_band(EngineState *s, int nr) { else { int retval; - if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions()) + if (!s->_kernel->usesOldGfxFunctions()) retval = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr); else retval = SCI0_PRIORITY_BAND_FIRST(nr); @@ -979,7 +979,7 @@ reg_t kDrawPic(EngineState *s, int, int argc, reg_t *argv) { gfx_color_t transparent = s->wm_port->_bgcolor; int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY; - if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions()) + if (s->_kernel->usesOldGfxFunctions()) add_to_pic = (argc > 2) ? argv[2].toSint16() : false; dp.nr = argv[0].toSint16(); @@ -1030,7 +1030,7 @@ reg_t kDrawPic(EngineState *s, int, int argc, reg_t *argv) { s->priority_first = 42; - if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions()) + if (s->_kernel->usesOldGfxFunctions()) s->priority_last = 200; else s->priority_last = 190; @@ -1054,7 +1054,7 @@ Common::Rect set_base(EngineState *s, reg_t object) { x = (int16)GET_SEL32V(object, x); original_y = y = (int16)GET_SEL32V(object, y); - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.z > -1) + if (s->_kernel->_selectorCache.z > -1) z = (int16)GET_SEL32V(object, z); else z = 0; @@ -1105,7 +1105,7 @@ void _k_base_setter(EngineState *s, reg_t object) { SegManager *segMan = s->segMan; Common::Rect absrect = set_base(s, object); - if (lookup_selector(s->segMan, object, ((SciEngine*)g_engine)->getKernel()->_selectorCache.brLeft, NULL, NULL) != kSelectorVariable) + if (lookup_selector(s->segMan, object, s->_kernel->_selectorCache.brLeft, NULL, NULL) != kSelectorVariable) return; // non-fatal // Note: there was a check here for a very old version of SCI, which supposedly needed @@ -1183,7 +1183,7 @@ Common::Rect get_nsrect(EngineState *s, reg_t object, byte clip) { x = (int16)GET_SEL32V(object, x); y = (int16)GET_SEL32V(object, y); - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.z > -1) + if (s->_kernel->_selectorCache.z > -1) z = (int16)GET_SEL32V(object, z); else z = 0; @@ -1208,7 +1208,7 @@ static void _k_set_now_seen(EngineState *s, reg_t object) { SegManager *segMan = s->segMan; Common::Rect absrect = get_nsrect(s, object, 0); - if (lookup_selector(s->segMan, object, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsTop, NULL, NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, object, s->_kernel->_selectorCache.nsTop, NULL, NULL) != kSelectorVariable) { return; } // This isn't fatal @@ -1710,7 +1710,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) { * if ((widget->signal & (_K_VIEW_SIG_FLAG_PRIVATE | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == _K_VIEW_SIG_FLAG_PRIVATE) { */ if ((widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == 0) { - int has_nsrect = lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; + int has_nsrect = lookup_selector(s->segMan, obj, s->_kernel->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; if (has_nsrect) { int temp; @@ -1732,7 +1732,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) { } #ifdef DEBUG_LSRECT else - fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL, NULL)); + fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s->segMan, obj, s->_kernel->_selectorCache.nsBottom, NULL, NULL)); #endif if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN) @@ -1888,7 +1888,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i loop = oldloop = sign_extend_byte(GET_SEL32V(obj, loop)); cel = oldcel = sign_extend_byte(GET_SEL32V(obj, cel)); - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.palette) + if (s->_kernel->_selectorCache.palette) palette = GET_SEL32V(obj, palette); else palette = 0; @@ -1909,7 +1909,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i } ObjVarRef under_bitsp; - if (lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.underBits, &(under_bitsp), NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, obj, s->_kernel->_selectorCache.underBits, &(under_bitsp), NULL) != kSelectorVariable) { under_bitsp.obj = NULL_REG; under_bits = NULL_REG; debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no underBits\n", PRINT_REG(obj)); @@ -1917,7 +1917,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i under_bits = *under_bitsp.getPointer(s->segMan); ObjVarRef signalp; - if (lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.signal, &(signalp), NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, obj, s->_kernel->_selectorCache.signal, &(signalp), NULL) != kSelectorVariable) { signalp.obj = NULL_REG; signal = 0; debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no signal selector\n", PRINT_REG(obj)); @@ -2012,7 +2012,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) { while (view) { reg_t obj = make_reg(view->_ID, view->_subID); int priority, _priority; - int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; + int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s->segMan, obj, s->_kernel->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; int oldsignal = view->signal; _k_set_now_seen(s, obj); diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index e045e75b5c..550fd789a2 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -260,7 +260,7 @@ reg_t kUnknown(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) { char tmpbuf[256]; snprintf(tmpbuf, sizeof(tmpbuf), "Unimplemented kernel function: 0x%02x (%s) (", - funct_nr, ((SciEngine*)g_engine)->getKernel()->getKernelName(funct_nr).c_str()); + funct_nr, s->_kernel->getKernelName(funct_nr).c_str()); for (int i = 0; i < argc; i++) { char tmpbuf2[20]; diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index b9381b1383..7eb14055b0 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -269,7 +269,7 @@ static void bresenham_autodetect(EngineState *s) { return; } - if (lookup_selector(s->segMan, motion_class, ((SciEngine*)g_engine)->getKernel()->_selectorCache.doit, NULL, &fptr) != kSelectorMethod) { + if (lookup_selector(s->segMan, motion_class, s->_kernel->_selectorCache.doit, NULL, &fptr) != kSelectorMethod) { warning("bresenham_autodetect failed"); handle_movecnt = INCREMENT_MOVECNT; // Most games do this, so best guess return; @@ -365,7 +365,7 @@ reg_t kDoBresen(EngineState *s, int, int argc, reg_t *argv) { debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d\n", x, y, bdi); - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.cantBeHere != -1) { + if (s->_kernel->_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 8713805fec..7ca50b25ca 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -705,7 +705,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } // FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch. - retval = new EngineState(s->resMan, s->_flags); + retval = new EngineState(s->resMan, s->_kernel, s->_flags); // Copy some old data retval->gfx_state = s->gfx_state; diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 099976343a..7ddec73f19 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -108,7 +108,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod uint opcode; int bytecount = 1; int i = 0; - Kernel *kernel = ((SciEngine*)g_engine)->getKernel(); + Kernel *kernel = s->_kernel; 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 2886bd0c77..93d84dc5e1 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -69,7 +69,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc if (slc_type == kSelectorNone) { warning("Selector '%s' of object at %04x:%04x could not be invoked (%s L%d)", - ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line); + s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line); if (noinvalid == kStopOnInvalidSelector) error("[Kernel] Not recoverable: VM was halted"); return 1; diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index fbc64d8075..dc9cf3fad3 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -30,8 +30,8 @@ namespace Sci { -EngineState::EngineState(ResourceManager *res, uint32 flags) -: resMan(res), _flags(flags), _dirseeker(this) { +EngineState::EngineState(ResourceManager *res, Kernel *kernel, uint32 flags) +: resMan(res), _kernel(kernel), _flags(flags), _dirseeker(this) { game_version = 0; @@ -180,7 +180,7 @@ Common::String EngineState::getLanguageString(const char *str, kLanguage lang) c kLanguage EngineState::getLanguage() { kLanguage lang = K_LANG_ENGLISH; - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.printLang != -1) { + if (_kernel->_selectorCache.printLang != -1) { lang = (kLanguage)GET_SEL32V(this->game_obj, printLang); if ((getSciVersion() == SCI_VERSION_1_1) || (lang == K_LANG_NONE)) { @@ -227,7 +227,7 @@ Common::String EngineState::strSplit(const char *str, const char *sep) { kLanguage lang = getLanguage(); kLanguage subLang = K_LANG_NONE; - if (((SciEngine*)g_engine)->getKernel()->_selectorCache.subtitleLang != -1) + if (_kernel->_selectorCache.subtitleLang != -1) subLang = (kLanguage)GET_SEL32V(this->game_obj, subtitleLang); Common::String retval = getLanguageString(str, lang); @@ -273,7 +273,7 @@ SciVersion EngineState::detectDoSoundType() { reg_t soundClass; if (!parse_reg_t(this, "?Sound", &soundClass)) { - int sum = methodChecksum(soundClass, ((SciEngine *)g_engine)->getKernel()->_selectorCache.play, -6, 6); + int sum = methodChecksum(soundClass, _kernel->_selectorCache.play, -6, 6); switch(sum) { case 0x1B2: // SCI0 @@ -310,7 +310,7 @@ SciVersion EngineState::detectDoSoundType() { SciVersion EngineState::detectSetCursorType() { if (_setCursorType == SCI_VERSION_AUTODETECT) { - int sum = methodChecksum(game_obj, ((SciEngine *)g_engine)->getKernel()->_selectorCache.setCursor, 0, 21); + int sum = methodChecksum(game_obj, _kernel->_selectorCache.setCursor, 0, 21); if ((sum == 0x4D5) || (sum == 0x552)) { // Standard setCursor diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 46ec34f2ba..10957737c3 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -158,7 +158,7 @@ private: struct EngineState : public Common::Serializable { public: - EngineState(ResourceManager *res, uint32 flags); + EngineState(ResourceManager *res, Kernel *kernel, uint32 flags); virtual ~EngineState(); virtual void saveLoadWithSerializer(Common::Serializer &ser); @@ -166,6 +166,7 @@ public: kLanguage getLanguage(); public: ResourceManager *resMan; /**< The resource manager */ + Kernel *_kernel; const uint32 _flags; /**< Specific game flags */ diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 0b757eff20..c1425977c4 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -301,7 +301,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt Breakpoint *bp; char method_name [256]; - sprintf(method_name, "%s::%s", s->segMan->getObjectName(send_obj), ((SciEngine *)g_engine)->getKernel()->getSelectorName(selector).c_str()); + sprintf(method_name, "%s::%s", s->segMan->getObjectName(send_obj), s->_kernel->getSelectorName(selector).c_str()); bp = s->bp_list; while (bp) { @@ -936,12 +936,10 @@ void run_vm(EngineState *s, int restoring) { s->restAdjust = 0; // We just used up the scriptState.restAdjust, remember? } - Kernel *kernel = ((SciEngine *)g_engine)->getKernel(); - - if (opparams[0] >= (int)kernel->_kernelFuncs.size()) { + if (opparams[0] >= (int)s->_kernel->_kernelFuncs.size()) { error("Invalid kernel function 0x%x requested", opparams[0]); } else { - const KernelFuncWithSignature &kfun = kernel->_kernelFuncs[opparams[0]]; + const KernelFuncWithSignature &kfun = s->_kernel->_kernelFuncs[opparams[0]]; int argc = ASSERT_ARITHMETIC(scriptState.xs->sp[0]); if (!oldScriptHeader) @@ -1768,7 +1766,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) { script_init_engine(s); game_init(s); sfx_reset_player(); - _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_selectorCache.play); + _init_stack_base_with_selector(s, s->_kernel->_selectorCache.play); send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base); @@ -1787,7 +1785,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) { debugC(2, kDebugLevelVM, "Restarting with replay()\n"); s->_executionStack.clear(); // Restart with replay - _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_selectorCache.replay); + _init_stack_base_with_selector(s, s->_kernel->_selectorCache.replay); send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base); } @@ -1806,7 +1804,7 @@ int game_run(EngineState **_s) { EngineState *s = *_s; debugC(2, kDebugLevelVM, "Calling %s::play()\n", s->_gameName.c_str()); - _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_selectorCache.play); // Call the play selector + _init_stack_base_with_selector(s, s->_kernel->_selectorCache.play); // Call the play selector // Now: Register the first element on the execution stack- if (!send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base)) { |