diff options
author | Filippos Karapetis | 2009-09-23 10:55:35 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-09-23 10:55:35 +0000 |
commit | 13ad217cdd6bf1dcb74fe9cb4f40622b58c8792a (patch) | |
tree | f0e1021c9235d3ad9c03a4a02688f9ba9111bc99 /engines/sci/engine | |
parent | 63208a20fdc466bb6ec88dc09c7f2901ef144794 (diff) | |
download | scummvm-rg350-13ad217cdd6bf1dcb74fe9cb4f40622b58c8792a.tar.gz scummvm-rg350-13ad217cdd6bf1dcb74fe9cb4f40622b58c8792a.tar.bz2 scummvm-rg350-13ad217cdd6bf1dcb74fe9cb4f40622b58c8792a.zip |
- Moved the SCI version in a global variable
- Changed all the SCI version checks to use getSciVersion()
- Also made getSciVersionDesc a global function (removes some ugly accessing of the SCI engine)
The fallback detector should work correctly now
svn-id: r44269
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/script.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/static_selectors.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 13 |
14 files changed, 49 insertions, 52 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 821ae7e4e0..6c5680f9fd 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -196,7 +196,7 @@ int _reset_graphics_input(EngineState *s) { } else { resource = s->resMan->findResource(ResourceId(kResourceTypePalette, 999), 1); if (resource) { - if (s->resMan->sciVersion() < SCI_VERSION_1_1) + if (getSciVersion() < SCI_VERSION_1_1) s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1(999, resource->data, resource->size)); else s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal11(999, resource->data, resource->size)); @@ -307,7 +307,7 @@ static void _free_graphics_input(EngineState *s) { } int game_init_sound(EngineState *s, int sound_flags) { - if (s->resMan->sciVersion() > SCI_VERSION_0_LATE) + if (getSciVersion() > SCI_VERSION_0_LATE) sound_flags |= SFX_STATE_FLAG_MULTIPLAY; s->sfx_init_flags = sound_flags; diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 696b959be2..74be751716 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -411,7 +411,7 @@ const Common::String &Kernel::getKernelName(uint number) const { } void Kernel::detectSciFeatures() { - SciVersion version = _resMan->sciVersion(); + SciVersion version = getSciVersion(); features = 0; @@ -447,12 +447,12 @@ int Kernel::findSelector(const char *selectorName) const { void Kernel::loadSelectorNames() { Resource *r = _resMan->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS), 0); - bool oldScriptHeader = (_resMan->sciVersion() == SCI_VERSION_0_EARLY); + bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); if (!r) { // No such resource? // Check if we have a table for this game // Some demos do not have a selector table - Common::StringList staticSelectorTable = checkStaticSelectorNames(_resMan->sciVersion()); + Common::StringList staticSelectorTable = checkStaticSelectorNames(); if (staticSelectorTable.empty()) error("Kernel: Could not retrieve selector names"); @@ -751,7 +751,7 @@ void Kernel::setDefaultKernelNames() { if (_selectorCache.cantBeHere != -1) _kernelNames[0x4d] = "CantBeHere"; - switch (_resMan->sciVersion()) { + switch (getSciVersion()) { case SCI_VERSION_0_EARLY: case SCI_VERSION_0_LATE: // Insert SCI0 file functions after SetCursor (0x28) @@ -791,9 +791,9 @@ bool Kernel::loadKernelNames() { _kernelNames.clear(); #ifdef ENABLE_SCI32 - if (_resMan->sciVersion() >= SCI_VERSION_2_1) + if (getSciVersion() >= SCI_VERSION_2_1) setKernelNamesSci21(); - else if (_resMan->sciVersion() == SCI_VERSION_2) + else if (getSciVersion() == SCI_VERSION_2) setKernelNamesSci2(); else #endif diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 888db2e0d9..79da7032e0 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -133,7 +133,7 @@ private: * Check for any hardcoded selector table we might have that can be used * if a game is missing the selector names. */ - Common::StringList checkStaticSelectorNames(SciVersion version); + Common::StringList checkStaticSelectorNames(); /** * Maps special selectors diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 44d49002ac..bb1a3be606 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -40,7 +40,7 @@ reg_t kGetEvent(EngineState *s, int, int argc, reg_t *argv) { reg_t obj = argv[1]; sci_event_t e; int oldx, oldy; - int modifier_mask = s->resMan->sciVersion() <= SCI_VERSION_01 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; + int modifier_mask = getSciVersion() <= SCI_VERSION_01 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; SegManager *segMan = s->segMan; // If there's a simkey pending, and the game wants a keyboard event, use the diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 7eb14055b0..a647a84cdb 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -296,7 +296,7 @@ reg_t kDoBresen(EngineState *s, int, int argc, reg_t *argv) { int completed = 0; int max_movcnt = GET_SEL32V(client, moveSpeed); - if (s->resMan->sciVersion() > SCI_VERSION_01) + if (getSciVersion() > SCI_VERSION_01) signal &= ~_K_VIEW_SIG_FLAG_HIT_OBSTACLE; if (handle_movecnt == UNINITIALIZED) @@ -383,7 +383,7 @@ reg_t kDoBresen(EngineState *s, int, int argc, reg_t *argv) { completed = 1; } - if (s->resMan->sciVersion() > SCI_VERSION_01) + if (getSciVersion() > SCI_VERSION_01) if (completed) invoke_selector(INV_SEL(mover, moveDone, kStopOnInvalidSelector), 0); diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 5bccc43f93..9f48995c36 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -167,7 +167,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their int cue; SegManager *segMan = s->segMan; - if (s->resMan->sciVersion() > SCI_VERSION_01) + if (getSciVersion() > SCI_VERSION_01) return; /* SCI1 and later explicitly poll for everything */ @@ -830,7 +830,7 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) { // effects. If the resource exists, play it using map 65535 (sound // effects map) if (s->resMan->testResource(ResourceId(kResourceTypeAudio, number)) && - s->resMan->sciVersion() >= SCI_VERSION_1_1) { + getSciVersion() >= SCI_VERSION_1_1) { // Found a relevant audio resource, play it s->_sound.stopAudio(); warning("Initializing audio resource instead of requested sound resource %d", number); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index b4ed9dad72..d1ce2885bb 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -544,7 +544,7 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename } static byte *find_unique_script_block(EngineState *s, byte *buf, int type) { - bool oldScriptHeader = (s->resMan->sciVersion() == SCI_VERSION_0_EARLY); + bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); if (oldScriptHeader) buf += 2; @@ -580,11 +580,11 @@ static void load_script(EngineState *s, Script *scr) { assert(scr->_buf); script = s->resMan->findResource(ResourceId(kResourceTypeScript, scr->_nr), 0); - if (s->resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) heap = s->resMan->findResource(ResourceId(kResourceTypeHeap, scr->_nr), 0); memcpy(scr->_buf, script->data, script->size); - if (s->resMan->sciVersion() >= SCI_VERSION_1_1) { + if (getSciVersion() >= SCI_VERSION_1_1) { scr->_heapStart = scr->_buf + scr->_scriptSize; memcpy(scr->_heapStart, heap->data, heap->size); } @@ -605,7 +605,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { // FIXME: Unify this code with script_instantiate_* load_script(s, scr); scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(s->segMan->_heap[scr->_localsSegment]); - if (s->resMan->sciVersion() >= SCI_VERSION_1_1) { + if (getSciVersion() >= SCI_VERSION_1_1) { scr->_exportTable = 0; scr->_synonyms = 0; if (READ_LE_UINT16(scr->_buf + 6) > 0) { @@ -646,7 +646,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { for (it = scr->_objects.begin(); it != end; ++it) { byte *data = scr->_buf + it->_value._pos.offset; - if (s->resMan->sciVersion() >= SCI_VERSION_1_1) { + if (getSciVersion() >= SCI_VERSION_1_1) { uint16 *funct_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 6 )); uint16 *prop_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 4 )); @@ -685,7 +685,7 @@ static void reconstruct_sounds(EngineState *s) { Song *seeker; SongIteratorType it_type; - if (s->resMan->sciVersion() > SCI_VERSION_01) + if (getSciVersion() > SCI_VERSION_01) it_type = SCI_SONG_ITERATOR_TYPE_SCI1; else it_type = SCI_SONG_ITERATOR_TYPE_SCI0; diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 247be7b7df..a19da886b2 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -96,10 +96,8 @@ void script_adjust_opcode_formats(EngineState *s) { } #ifdef ENABLE_SCI32 - SciVersion version = s->resMan->sciVersion(); - // In SCI32, some arguments are now words instead of bytes - if (version >= SCI_VERSION_2) { + if (getSciVersion() >= SCI_VERSION_2) { g_opcode_formats[op_calle][2] = Script_Word; g_opcode_formats[op_callk][1] = Script_Word; g_opcode_formats[op_super][1] = Script_Word; diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 41fecec74a..ab96d8b3fa 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -130,18 +130,18 @@ Script *SegManager::allocateScript(int script_nr, SegmentId *seg_id) { void Script::setScriptSize(int script_nr, ResourceManager *resMan) { Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); - bool oldScriptHeader = (resMan->sciVersion() == SCI_VERSION_0_EARLY); + bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); _scriptSize = script->size; _heapSize = 0; // Set later - if (!script || (resMan->sciVersion() >= SCI_VERSION_1_1 && !heap)) { + if (!script || (getSciVersion() >= SCI_VERSION_1_1 && !heap)) { error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap"); } if (oldScriptHeader) { _bufSize = script->size + READ_LE_UINT16(script->data) * 2; //locals_size = READ_LE_UINT16(script->data) * 2; - } else if (resMan->sciVersion() < SCI_VERSION_1_1) { + } else if (getSciVersion() < SCI_VERSION_1_1) { _bufSize = script->size; } else { _bufSize = script->size + heap->size; @@ -458,10 +458,10 @@ reg_t SegManager::getClassAddress(int classnr, ScriptLoadType lock, reg_t caller } } -Object *Script::scriptObjInit(reg_t obj_pos, SciVersion version) { +Object *Script::scriptObjInit(reg_t obj_pos) { Object *obj; - if (version < SCI_VERSION_1_1) + if (getSciVersion() < SCI_VERSION_1_1) obj_pos.offset += 8; // magic offset (SCRIPT_OBJECT_MAGIC_OFFSET) VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n"); @@ -474,7 +474,7 @@ Object *Script::scriptObjInit(reg_t obj_pos, SciVersion version) { uint16 *funct_area = 0; bool isClass; - if (version < SCI_VERSION_1_1) { + if (getSciVersion() < SCI_VERSION_1_1) { obj->variable_names_nr = READ_LE_UINT16(data + SCRIPT_SELECTORCTR_OFFSET); obj->base_vars = 0; funct_area = (uint16 *)(data + READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET)); @@ -494,7 +494,7 @@ Object *Script::scriptObjInit(reg_t obj_pos, SciVersion version) { VERIFY((byte *)funct_area < _buf + _bufSize, "Function area pointer references beyond end of script"); - if (version < SCI_VERSION_1_1) { + if (getSciVersion() < SCI_VERSION_1_1) { VERIFY((byte *)funct_area + obj->methods_nr * 2 // add again for classes, since those also store selectors + (isClass ? obj->methods_nr * 2 : 0) < _buf + _bufSize, "Function area extends beyond end of script"); @@ -551,7 +551,7 @@ void SegManager::scriptInitialiseLocals(reg_t location) { VERIFY(location.offset + 1 < (uint16)scr->_bufSize, "Locals beyond end of script\n"); - if (_resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) count = READ_LE_UINT16(scr->_buf + location.offset - 2); else count = (READ_LE_UINT16(scr->_buf + location.offset - 2) - 4) >> 1; @@ -618,7 +618,7 @@ void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) { reg.segment = seg; reg.offset = seeker - scr->_buf; - obj = scr->scriptObjInit(reg, _resMan->sciVersion()); + obj = scr->scriptObjInit(reg); #if 0 if (obj->_variables[5].offset != 0xffff) { diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 6980ce1570..5410d82c24 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -137,7 +137,7 @@ bool Script::init(int script_nr, ResourceManager *resMan) { _nr = script_nr; - if (resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) _heapStart = _buf + _scriptSize; else _heapStart = _buf; diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index f2f794a2ba..c912e4fc2a 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -351,7 +351,7 @@ public: * @returns A newly created Object describing the object, * stored within the relevant script */ - Object *scriptObjInit(reg_t obj_pos, SciVersion version); + Object *scriptObjInit(reg_t obj_pos); /** * Processes a relocation block witin a script diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index dc9cf3fad3..4248c68c63 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -113,7 +113,7 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, uint32 flags) successor = 0; - speedThrottler = new SpeedThrottler(res->sciVersion()); + speedThrottler = new SpeedThrottler(getSciVersion()); _setCursorType = SCI_VERSION_AUTODETECT; _doSoundType = SCI_VERSION_AUTODETECT; @@ -294,15 +294,15 @@ SciVersion EngineState::detectDoSoundType() { if (_doSoundType == SCI_VERSION_AUTODETECT) { warning("DoSound detection failed, taking an educated guess"); - if (resMan->sciVersion() >= SCI_VERSION_1_MIDDLE) + if (getSciVersion() >= SCI_VERSION_1_MIDDLE) _doSoundType = SCI_VERSION_1_LATE; - else if (resMan->sciVersion() > SCI_VERSION_01) + else if (getSciVersion() > SCI_VERSION_01) _doSoundType = SCI_VERSION_1_EARLY; else _doSoundType = SCI_VERSION_0_EARLY; } - debugC(1, kDebugLevelSound, "Detected DoSound type: %s", ((SciEngine *)g_engine)->getSciVersionDesc(_doSoundType).c_str()); + debugC(1, kDebugLevelSound, "Detected DoSound type: %s", getSciVersionDesc(_doSoundType).c_str()); } return _doSoundType; @@ -321,13 +321,13 @@ SciVersion EngineState::detectSetCursorType() { } else { warning("SetCursor detection failed, taking an educated guess"); - if (resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) _setCursorType = SCI_VERSION_1_1; else _setCursorType = SCI_VERSION_0_EARLY; } - debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", ((SciEngine *)g_engine)->getSciVersionDesc(_setCursorType).c_str()); + debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType).c_str()); } return _setCursorType; @@ -448,7 +448,7 @@ SciVersion EngineState::detectLofsType() { _lofsType = SCI_VERSION_0_EARLY; } - debugC(1, kDebugLevelVM, "Detected Lofs type: %s", ((SciEngine *)g_engine)->getSciVersionDesc(_lofsType).c_str()); + debugC(1, kDebugLevelVM, "Detected Lofs type: %s", getSciVersionDesc(_lofsType).c_str()); } return _lofsType; diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp index 76e0110249..4c68f44831 100644 --- a/engines/sci/engine/static_selectors.cpp +++ b/engines/sci/engine/static_selectors.cpp @@ -89,9 +89,9 @@ static const SelectorRemap sci11SelectorRemap[] = { { "syncTime", 279 }, { "syncCue", 280 }, { 0, 0 } }; -Common::StringList Kernel::checkStaticSelectorNames(SciVersion version) { +Common::StringList Kernel::checkStaticSelectorNames() { Common::StringList names; - const int offset = (version < SCI_VERSION_1_1) ? 3 : 0; + const int offset = (getSciVersion() < SCI_VERSION_1_1) ? 3 : 0; const int count = ARRAYSIZE(sci0Selectors) + offset; const SelectorRemap *selectorRemap = sci0SelectorRemap; int i; @@ -103,7 +103,7 @@ Common::StringList Kernel::checkStaticSelectorNames(SciVersion version) { for (i = offset; i < count; i++) names[i] = sci0Selectors[i - offset]; - if (version <= SCI_VERSION_01) { + if (getSciVersion() <= SCI_VERSION_01) { selectorRemap = sci0SelectorRemap; } else { // Several new selectors were added in SCI 1 and later. @@ -112,7 +112,7 @@ Common::StringList Kernel::checkStaticSelectorNames(SciVersion version) { for (i = count; i < count + count2; i++) names[i] = sci1Selectors[i - count]; - if (version < SCI_VERSION_1_1) { + if (getSciVersion() < SCI_VERSION_1_1) { selectorRemap = sci1SelectorRemap; } else { selectorRemap = sci11SelectorRemap; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 1ae71eeb7e..ed20c9fed6 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1412,12 +1412,12 @@ int script_instantiate_common(ResourceManager *resMan, SegManager *segMan, int s *was_new = 1; *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); - if (resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); - if (!*script || (resMan->sciVersion() >= SCI_VERSION_1_1 && !heap)) { + if (!*script || (getSciVersion() >= SCI_VERSION_1_1 && !heap)) { warning("Script 0x%x requested but not found", script_nr); - if (resMan->sciVersion() >= SCI_VERSION_1_1) { + if (getSciVersion() >= SCI_VERSION_1_1) { if (*heap) warning("Inconsistency: heap resource WAS found"); else if (*script) @@ -1467,8 +1467,7 @@ int script_instantiate_sci0(ResourceManager *resMan, SegManager *segMan, int scr int magic_pos_adder; // Usually 0; 2 for older SCI versions Resource *script; int was_new; - SciVersion version = resMan->sciVersion(); - bool oldScriptHeader = (version == SCI_VERSION_0_EARLY); + bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); const int seg_id = script_instantiate_common(resMan, segMan, script_nr, &script, NULL, &was_new); @@ -1590,7 +1589,7 @@ int script_instantiate_sci0(ResourceManager *resMan, SegManager *segMan, int scr break; case SCI_OBJ_OBJECT: case SCI_OBJ_CLASS: { // object or class? - Object *obj = scr->scriptObjInit(addr, resMan->sciVersion()); + Object *obj = scr->scriptObjInit(addr); Object *base_obj; // Instantiate the superclass, if neccessary @@ -1657,7 +1656,7 @@ int script_instantiate_sci11(ResourceManager *resMan, SegManager *segMan, int sc } int script_instantiate(ResourceManager *resMan, SegManager *segMan, int script_nr) { - if (resMan->sciVersion() >= SCI_VERSION_1_1) + if (getSciVersion() >= SCI_VERSION_1_1) return script_instantiate_sci11(resMan, segMan, script_nr); else return script_instantiate_sci0(resMan, segMan, script_nr); |