diff options
author | Max Horn | 2009-09-17 13:21:42 +0000 |
---|---|---|
committer | Max Horn | 2009-09-17 13:21:42 +0000 |
commit | 364640cfd58a99a7b61f914a836c156d55a25c3c (patch) | |
tree | 3d49179cb5e6731cd52b2b279c781a718012e788 | |
parent | b2c386ed000bce9a34a3d392b57a5d9abe8dfa7e (diff) | |
download | scummvm-rg350-364640cfd58a99a7b61f914a836c156d55a25c3c.tar.gz scummvm-rg350-364640cfd58a99a7b61f914a836c156d55a25c3c.tar.bz2 scummvm-rg350-364640cfd58a99a7b61f914a836c156d55a25c3c.zip |
SCI: Rename selector_map_t -> SelectorCache and _selectorMap -> _selectorCache
svn-id: r44152
-rw-r--r-- | engines/sci/console.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 14 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 20 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/script.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 6 |
10 files changed, 45 insertions, 43 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 73ea0ad152..7922e30b01 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -3133,7 +3133,7 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) { int have_rects = 0; Common::Rect nsrect, nsrect_clipped, brrect; - if (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL) == kSelectorVariable) { + if (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL) == kSelectorVariable) { GETRECT(nsLeft, nsRight, nsBottom, nsTop); GETRECT(lsLeft, lsRight, lsBottom, lsTop); GETRECT(brLeft, brRight, brBottom, brTop); @@ -3147,7 +3147,7 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) { x = GET_SELECTOR(pos, x); y = GET_SELECTOR(pos, y); priority = GET_SELECTOR(pos, priority); - if (((SciEngine*)g_engine)->getKernel()->_selectorMap.z > 0) { + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.z > 0) { z = GET_SELECTOR(pos, z); printf("(%d,%d,%d)\n", x, y, z); } else @@ -3211,10 +3211,10 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array<cmd_param_t> & } - is_view = (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.x, NULL) == kSelectorVariable) && - (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.brLeft, NULL) == kSelectorVariable) && - (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.signal, NULL) == kSelectorVariable) && - (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsTop, NULL) == kSelectorVariable); + is_view = (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorCache.x, NULL) == kSelectorVariable) && + (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorCache.brLeft, NULL) == kSelectorVariable) && + (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorCache.signal, NULL) == kSelectorVariable) && + (lookup_selector(s->segMan, pos, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsTop, NULL) == kSelectorVariable); if (!is_view) { printf("Not a dynamic View object.\n"); diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 850827aa28..034c67deb6 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -380,8 +380,6 @@ static const char *argtype_description[] = { }; Kernel::Kernel(ResourceManager *resMan) : _resMan(resMan) { - memset(&_selectorMap, 0, sizeof(_selectorMap)); // FIXME: Remove this once/if we C++ify selector_map_t - loadSelectorNames(); detectSciFeatures(); @@ -404,7 +402,7 @@ void Kernel::detectSciFeatures() { if (version == SCI_VERSION_0_EARLY) { features |= kFeatureOldScriptHeader | kFeatureOldGfxFunctions; } else if (version == SCI_VERSION_0_LATE) { - if (_selectorMap.motionCue == -1) + if (_selectorCache.motionCue == -1) features |= kFeatureOldGfxFunctions; } diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index f088492b0c..58174ac9fb 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -99,7 +99,7 @@ public: void dumpScriptObject(char *data, int seeker, int objsize); void dumpScriptClass(char *data, int seeker, int objsize); - selector_map_t _selectorMap; /**< Shortcut list for important selectors */ + SelectorCache _selectorCache; /**< Shortcut list for important selectors */ Common::Array<KernelFuncWithSignature> _kernelFuncs; /**< Table of kernel functions */ private: @@ -172,32 +172,32 @@ enum SelectorInvocation { kContinueOnInvalidSelector = 1 }; -#define GET_SEL32(_o_, _slc_) read_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, __FILE__, __LINE__) +#define GET_SEL32(_o_, _slc_) read_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, __FILE__, __LINE__) #define GET_SEL32V(_o_, _slc_) (GET_SEL32(_o_, _slc_).offset) /* Retrieves a selector from an object ** Parameters: (reg_t) object: The address of the object which the selector should be read from ** (selector_name) selector: The selector to read ** Returns : (int16/uint16/reg_t) The selector value ** This macro halts on error. 'selector' must be a selector name registered in vm.h's -** selector_map_t and mapped in script.c. +** SelectorCache and mapped in script.cpp. */ -#define PUT_SEL32(_o_, _slc_, _val_) write_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, _val_, __FILE__, __LINE__) -#define PUT_SEL32V(_o_, _slc_, _val_) write_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, make_reg(0, _val_), __FILE__, __LINE__) +#define PUT_SEL32(_o_, _slc_, _val_) write_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, _val_, __FILE__, __LINE__) +#define PUT_SEL32V(_o_, _slc_, _val_) write_selector(segMan, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._slc_, make_reg(0, _val_), __FILE__, __LINE__) /* Writes a selector value to an object ** Parameters: (reg_t) object: The address of the object which the selector should be written to ** (selector_name) selector: The selector to read ** (int16) value: The value to write ** Returns : (void) ** This macro halts on error. 'selector' must be a selector name registered in vm.h's -** selector_map_t and mapped in script.c. +** SelectorCache and mapped in script.cpp. */ enum { WAS_FUNCT_NR = -1 }; #define INV_SEL(_object_, _selector_, _noinvalid_) \ - s, _object_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._selector_, _noinvalid_, WAS_FUNCT_NR, argv, argc, __FILE__, __LINE__ + s, _object_, ((SciEngine*)g_engine)->getKernel()->_selectorCache._selector_, _noinvalid_, WAS_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 9c710efb1c..07886d2fa1 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1046,7 +1046,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()->_selectorMap.z > -1) + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.z > -1) z = (int16)GET_SEL32V(object, z); else z = 0; @@ -1097,7 +1097,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()->_selectorMap.brLeft, NULL, NULL) != kSelectorVariable) + if (lookup_selector(s->segMan, object, ((SciEngine*)g_engine)->getKernel()->_selectorCache.brLeft, NULL, NULL) != kSelectorVariable) return; // non-fatal // Note: there was a check here for a very old version of SCI, which supposedly needed @@ -1175,7 +1175,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()->_selectorMap.z > -1) + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.z > -1) z = (int16)GET_SEL32V(object, z); else z = 0; @@ -1200,7 +1200,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()->_selectorMap.nsTop, NULL, NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, object, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsTop, NULL, NULL) != kSelectorVariable) { return; } // This isn't fatal @@ -1702,7 +1702,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()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable; + int has_nsrect = lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; if (has_nsrect) { int temp; @@ -1724,7 +1724,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()->_selectorMap.nsBottom, NULL, NULL)); + 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)); #endif if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN) @@ -1880,7 +1880,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()->_selectorMap.palette) + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.palette) palette = GET_SEL32V(obj, palette); else palette = 0; @@ -1901,7 +1901,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()->_selectorMap.underBits, &(under_bitsp), NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_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)); @@ -1909,7 +1909,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()->_selectorMap.signal, &(signalp), NULL) != kSelectorVariable) { + if (lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_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)); @@ -2004,7 +2004,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()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable; + int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s->segMan, obj, ((SciEngine*)g_engine)->getKernel()->_selectorCache.nsBottom, NULL, NULL) == kSelectorVariable; int oldsignal = view->signal; _k_set_now_seen(s, obj); diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index cb1f841ece..54f0f4680b 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()->_selectorMap.doit, NULL, &fptr) != kSelectorMethod) { + if (lookup_selector(s->segMan, motion_class, ((SciEngine*)g_engine)->getKernel()->_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()->_selectorMap.cantBeHere != -1) + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.cantBeHere != -1) invoke_selector(INV_SEL(client, cantBeHere, kStopOnInvalidSelector), 0); else invoke_selector(INV_SEL(client, canBeHere, kStopOnInvalidSelector), 0); diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index f40df5595e..247be7b7df 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -113,18 +113,18 @@ void script_adjust_opcode_formats(EngineState *s) { #if 1 -#define FIND_SELECTOR(_slc_) _selectorMap._slc_ = findSelector(#_slc_) -#define FIND_SELECTOR2(_slc_, _slcstr_) _selectorMap._slc_ = findSelector(_slcstr_) +#define FIND_SELECTOR(_slc_) _selectorCache._slc_ = findSelector(#_slc_) +#define FIND_SELECTOR2(_slc_, _slcstr_) _selectorCache._slc_ = findSelector(_slcstr_) #else // The defines below can be used to construct static selector tables for games which don't have // a vocab.997 resource, by dumping the selector table from other similar versions or games -#define FIND_SELECTOR(_slc_) _selectorMap._slc_ = findSelector(#_slc_); \ - printf("\t{ \"%s\", %d },\n", #_slc_, _selectorMap._slc_) +#define FIND_SELECTOR(_slc_) _selectorCache._slc_ = findSelector(#_slc_); \ + printf("\t{ \"%s\", %d },\n", #_slc_, _selectorCache._slc_) -#define FIND_SELECTOR2(_slc_, _slcstr_) _selectorMap._slc_ = findSelector(_slcstr_); \ - printf("\t{ \"%s\", %d },\n", _slcstr_, _selectorMap._slc_) +#define FIND_SELECTOR2(_slc_, _slcstr_) _selectorCache._slc_ = findSelector(_slcstr_); \ + printf("\t{ \"%s\", %d },\n", _slcstr_, _selectorCache._slc_) #endif diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index bf385d6551..aedbd92319 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -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()->_selectorMap.printLang != -1) { + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.printLang != -1) { lang = (kLanguage)GET_SEL32V(this->game_obj, printLang); if ((segMan->sciVersion() == 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()->_selectorMap.subtitleLang != -1) + if (((SciEngine*)g_engine)->getKernel()->_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()->_selectorMap.play, -6, 6); + int sum = methodChecksum(soundClass, ((SciEngine *)g_engine)->getKernel()->_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()->_selectorMap.setCursor, 0, 21); + int sum = methodChecksum(game_obj, ((SciEngine *)g_engine)->getKernel()->_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 5b2e9434c9..ba599739b0 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -330,7 +330,7 @@ PaletteEntry get_pic_color(EngineState *s, int color); // misleading. A different name (and a different place for declaring this) // would be highly welcome. static inline reg_t not_register(EngineState *s, reg_t r) { - if (((SciEngine*)g_engine)->getKernel()->_selectorMap.cantBeHere != -1) + if (((SciEngine*)g_engine)->getKernel()->_selectorCache.cantBeHere != -1) return make_reg(0, !r.offset); else return r; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 959763ee74..93cd6aa2fb 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1861,7 +1861,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()->_selectorMap.play); + _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_selectorCache.play); send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base); @@ -1880,7 +1880,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()->_selectorMap.replay); + _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_selectorCache.replay); send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base); } @@ -1899,7 +1899,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()->_selectorMap.play); // Call the play selector + _init_stack_base_with_selector(s, ((SciEngine *)g_engine)->getKernel()->_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)) { diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index cd37166d50..fa1b4f8817 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -110,7 +110,11 @@ struct Class { #define RAW_IS_OBJECT(datablock) (READ_LE_UINT16(((byte *) datablock) + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER) /** Contains selector IDs for a few selected selectors */ -struct selector_map_t { +struct SelectorCache { + SelectorCache() { + memset(this, 0, sizeof(*this)); + } + Selector init; /**< Init function */ Selector play; /**< Play function (first function to be called) */ Selector replay; /**< Replay function */ |