aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/detection.cpp2
-rw-r--r--engines/sci/engine/game.cpp4
-rw-r--r--engines/sci/engine/kernel.cpp12
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/kevent.cpp2
-rw-r--r--engines/sci/engine/kmovement.cpp4
-rw-r--r--engines/sci/engine/ksound.cpp4
-rw-r--r--engines/sci/engine/savegame.cpp12
-rw-r--r--engines/sci/engine/script.cpp4
-rw-r--r--engines/sci/engine/seg_manager.cpp18
-rw-r--r--engines/sci/engine/segment.cpp2
-rw-r--r--engines/sci/engine/segment.h2
-rw-r--r--engines/sci/engine/state.cpp14
-rw-r--r--engines/sci/engine/static_selectors.cpp8
-rw-r--r--engines/sci/engine/vm.cpp13
-rw-r--r--engines/sci/gfx/gfx_resmgr.cpp16
-rw-r--r--engines/sci/gfx/operations.cpp2
-rw-r--r--engines/sci/gfx/operations.h3
-rw-r--r--engines/sci/resource.cpp77
-rw-r--r--engines/sci/resource.h9
-rw-r--r--engines/sci/sci.cpp41
-rw-r--r--engines/sci/sci.h38
-rw-r--r--engines/sci/sfx/softseq/adlib.cpp2
-rw-r--r--engines/sci/vocabulary.cpp2
25 files changed, 149 insertions, 146 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 0f651709b9..b8b3d2b9a5 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -367,7 +367,7 @@ const char *selector_name(EngineState *s, int selector) {
}
bool Console::cmdGetVersion(int argc, const char **argv) {
- DebugPrintf("Emulated interpreter version: %s\n", ((SciEngine *)g_engine)->getSciVersionDesc(_vm->getVersion()).c_str());
+ DebugPrintf("Emulated interpreter version: %s\n", getSciVersionDesc(getSciVersion()).c_str());
return true;
}
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index b44f494a00..819ff37974 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -285,7 +285,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
#ifndef ENABLE_SCI32
// Is SCI32 compiled in? If not, and this is a SCI32 game,
// stop here
- if (resMan->sciVersion() >= SCI_VERSION_2) {
+ if (getSciVersion() >= SCI_VERSION_2) {
SearchMan.remove("SCI_detection");
delete resMan;
return (const ADGameDescription *)&s_fallbackDesc;
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);
diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp
index b7aa00a873..f81f9e0dc1 100644
--- a/engines/sci/gfx/gfx_resmgr.cpp
+++ b/engines/sci/gfx/gfx_resmgr.cpp
@@ -58,10 +58,10 @@ GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, Resource
if (!_resMan->isVGA()) {
_staticPalette = gfx_sci0_pic_colors->getref();
- } else if (_resMan->sciVersion() == SCI_VERSION_1_1) {
+ } else if (getSciVersion() == SCI_VERSION_1_1) {
debugC(2, kDebugLevelGraphics, "Palettes are not yet supported in this SCI version\n");
#ifdef ENABLE_SCI32
- } else if (_resMan->sciVersion() >= SCI_VERSION_2) {
+ } else if (getSciVersion() >= SCI_VERSION_2) {
debugC(2, kDebugLevelGraphics, "Palettes are not yet supported in this SCI version\n");
#endif
} else {
@@ -96,7 +96,7 @@ void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pi
error("calculatePic(): pic number %d not found", nr);
if (need_unscaled) {
- if (_resMan->sciVersion() == SCI_VERSION_1_1)
+ if (getSciVersion() == SCI_VERSION_1_1)
gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _staticPalette, _portBounds);
else
gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _resMan->getViewType(), _staticPalette, _portBounds);
@@ -105,12 +105,12 @@ void GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pi
if (scaled_pic && scaled_pic->undithered_buffer)
memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size);
- if (_resMan->sciVersion() == SCI_VERSION_1_1)
+ if (getSciVersion() == SCI_VERSION_1_1)
gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _staticPalette, _portBounds);
else
gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _resMan->getViewType(), _staticPalette, _portBounds);
- if (_resMan->sciVersion() <= SCI_VERSION_1_EGA) {
+ if (getSciVersion() <= SCI_VERSION_1_EGA) {
if (need_unscaled)
gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic);
@@ -512,7 +512,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
ViewType viewType = _resMan->getViewType();
if (viewType == kViewEga) {
- int pal = (_resMan->sciVersion() <= SCI_VERSION_01) ? -1 : palette;
+ int pal = (getSciVersion() <= SCI_VERSION_01) ? -1 : palette;
view = getEGAView(resid, viewRes->data, viewRes->size, pal);
} else {
view = getVGAView(resid, viewRes->data, viewRes->size, viewType);
@@ -640,13 +640,13 @@ gfx_pixmap_t *GfxResManager::getCursor(int num) {
if (!cursorRes || !cursorRes->data)
return NULL;
- if (_resMan->sciVersion() >= SCI_VERSION_1_1) {
+ if (getSciVersion() >= SCI_VERSION_1_1) {
warning("[GFX] Attempt to retrieve cursor in SCI1.1 or later");
return NULL;
}
gfx_pixmap_t *cursor = gfxr_draw_cursor(GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, num),
- cursorRes->data, cursorRes->size, _resMan->sciVersion() > SCI_VERSION_01);
+ cursorRes->data, cursorRes->size, getSciVersion() > SCI_VERSION_01);
if (!cursor)
return NULL;
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index ba07071a8a..1f6812d633 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -384,7 +384,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) {
(*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR);
}
-void gfxop_init(int version, GfxState *state,
+void gfxop_init(GfxState *state,
gfx_options_t *options, ResourceManager *resMan,
Graphics::PixelFormat mode, int xfact, int yfact) {
//int color_depth = bpp ? bpp : 1;
diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h
index b38d70f47f..03ab882452 100644
--- a/engines/sci/gfx/operations.h
+++ b/engines/sci/gfx/operations.h
@@ -135,7 +135,6 @@ struct GfxState {
/**
* Initializes a graphics mode.
*
- * @param[in] version The interpreter version
* @param[in] state The state to initialize
* @param[in] xfact Horizontal scale factor
* @param[in] yfact Vertical scale factors
@@ -143,7 +142,7 @@ struct GfxState {
* @param[in] options Rendering options
* @param[in] resMan Resource manager to use
*/
-void gfxop_init(int version, GfxState *state,
+void gfxop_init(GfxState *state,
gfx_options_t *options, ResourceManager *resMan,
Graphics::PixelFormat mode, int xfact = 1, int yfact = 1);
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index e9f83fd29b..b637fbb615 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -315,7 +315,7 @@ void ResourceManager::loadResource(Resource *res) {
file->seek(res->file_offset, SEEK_SET);
if (res->source->source_type == kSourceAudioVolume) {
- if (_sciVersion < SCI_VERSION_1_1)
+ if (getSciVersion() < SCI_VERSION_1_1)
loadFromAudioVolumeSCI1(res, *file);
else
loadFromAudioVolumeSCI11(res, *file);
@@ -517,12 +517,9 @@ void ResourceManager::init() {
addInternalSources();
scanNewSources();
- _sciVersion = detectSciVersion();
+ detectSciVersion();
- if (_sciVersion != SCI_VERSION_AUTODETECT)
- debug("resMan: Detected %s", ((SciEngine *)g_engine)->getSciVersionDesc(_sciVersion).c_str());
- else
- warning("resMan: Couldn't determine SCI version");
+ debug("resMan: Detected %s", getSciVersionDesc(getSciVersion()).c_str());
switch (_viewType) {
case kViewEga:
@@ -1413,10 +1410,10 @@ int ResourceManager::readResourceInfo(Resource *res, Common::File *file,
compression = kCompNone;
break;
case 1:
- compression = (_sciVersion <= SCI_VERSION_01) ? kCompLZW : kCompHuffman;
+ compression = (getSciVersion() <= SCI_VERSION_01) ? kCompLZW : kCompHuffman;
break;
case 2:
- compression = (_sciVersion <= SCI_VERSION_01) ? kCompHuffman : kCompLZW1;
+ compression = (getSciVersion() <= SCI_VERSION_01) ? kCompHuffman : kCompLZW1;
break;
case 3:
compression = kCompLZW1View;
@@ -1583,7 +1580,7 @@ ViewType ResourceManager::detectViewType() {
return kViewUnknown;
}
-SciVersion ResourceManager::detectSciVersion() {
+void ResourceManager::detectSciVersion() {
// We use the view compression to set a preliminary _sciVersion for the sake of getResourceInfo
// Pretend we have a SCI0 game
_sciVersion = SCI_VERSION_0_EARLY;
@@ -1617,22 +1614,28 @@ SciVersion ResourceManager::detectSciVersion() {
// SCI1 Late resource maps have the resource types or'd with
// 0x80. We differentiate between SCI2 and SCI2.1/3 based on that.
// TODO: Differentiate between SCI2.1 and SCI3
- if (_mapVersion == kResVersionSci1Late)
- return SCI_VERSION_2;
- else
- return SCI_VERSION_2_1;
+ if (_mapVersion == kResVersionSci1Late) {
+ _sciVersion = SCI_VERSION_2;
+ return;
+ } else {
+ _sciVersion = SCI_VERSION_2_1;
+ return;
+ }
}
switch (_mapVersion) {
case kResVersionSci0Sci1Early:
if (_viewType == kViewVga) {
// VGA
- return SCI_VERSION_1_EARLY;
+ _sciVersion = SCI_VERSION_1_EARLY;
+ return;
}
// EGA
- if (hasOldScriptHeader())
- return SCI_VERSION_0_EARLY;
+ if (hasOldScriptHeader()) {
+ _sciVersion = SCI_VERSION_0_EARLY;
+ return;
+ }
if (oldDecompressors) {
// It's either SCI_VERSION_0_LATE or SCI_VERSION_01
@@ -1640,43 +1643,57 @@ SciVersion ResourceManager::detectSciVersion() {
// We first check for SCI1 vocab.999
if (testResource(ResourceId(kResourceTypeVocab, 999))) {
if (hasSci0Voc999()) {
- return SCI_VERSION_0_LATE;
+ _sciVersion = SCI_VERSION_0_LATE;
+ return;
} else {
- return SCI_VERSION_01;
+ _sciVersion = SCI_VERSION_01;
+ return;
}
}
// If vocab.999 is missing, we try vocab.900
if (testResource(ResourceId(kResourceTypeVocab, 900))) {
if (hasSci1Voc900()) {
- return SCI_VERSION_01;
+ _sciVersion = SCI_VERSION_01;
+ return;
} else {
- return SCI_VERSION_0_LATE;
+ _sciVersion = SCI_VERSION_0_LATE;
+ return;
}
}
warning("Failed to accurately determine SCI version");
// No parser, we assume SCI_VERSION_01.
- return SCI_VERSION_01;
+ _sciVersion = SCI_VERSION_01;
+ return;
}
// New decompressors. It's either SCI_VERSION_1_EGA or SCI_VERSION_1_EARLY.
- if (hasSci1Voc900())
- return SCI_VERSION_1_EGA;
+ if (hasSci1Voc900()) {
+ _sciVersion = SCI_VERSION_1_EGA;
+ return;
+ }
// SCI_VERSION_1_EARLY EGA versions seem to be lacking a valid vocab.900.
// If this turns out to be unreliable, we could do some pic resource checks instead.
- return SCI_VERSION_1_EARLY;
+ _sciVersion = SCI_VERSION_1_EARLY;
+ return;
case kResVersionSci1Middle:
- return SCI_VERSION_1_MIDDLE;
+ _sciVersion = SCI_VERSION_1_MIDDLE;
+ return;
case kResVersionSci1Late:
- if (_volVersion == kResVersionSci11)
- return SCI_VERSION_1_1;
- return SCI_VERSION_1_LATE;
+ if (_volVersion == kResVersionSci11) {
+ _sciVersion = SCI_VERSION_1_1;
+ return;
+ }
+ _sciVersion = SCI_VERSION_1_LATE;
+ return;
case kResVersionSci11:
- return SCI_VERSION_1_1;
+ _sciVersion = SCI_VERSION_1_1;
+ return;
default:
- return SCI_VERSION_AUTODETECT;
+ _sciVersion = SCI_VERSION_AUTODETECT;
+ error("detectSciVersion(): Unable to detect the game's SCI version");
}
}
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index c6ae2ed1ab..2400f2c8dd 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -228,12 +228,6 @@ public:
ViewType getViewType() const { return _viewType; }
/**
- * Returns the SCI version as detected by the resource manager
- * @return SCI version
- */
- SciVersion sciVersion() const { return _sciVersion; }
-
- /**
* Creates a new SCI resource manager.
*/
ResourceManager();
@@ -296,7 +290,6 @@ protected:
ResourceSource *_audioMapSCI1; //!< Currently loaded audio map for SCI1
ResVersion _volVersion; //!< RESOURCE.0xx version
ResVersion _mapVersion; //!< RESOURCE.MAP version
- SciVersion _sciVersion; //!< Detected SCI version */
/**
* Initializes the resource manager
@@ -431,7 +424,7 @@ protected:
ViewType detectViewType();
bool hasSci0Voc999();
bool hasSci1Voc900();
- SciVersion detectSciVersion();
+ void detectSciVersion();
};
} // End of namespace Sci
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index ebba1b08f6..d24d651905 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -43,6 +43,8 @@ namespace Sci {
class GfxDriver;
+SciVersion _sciVersion;
+
SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc)
: Engine(syst), _gameDescription(desc) {
// Put your engine in a sane state, but do nothing big yet;
@@ -177,7 +179,7 @@ Common::Error SciEngine::run() {
// Default config ends
#endif
- gfxop_init(_resMan->sciVersion(), &gfx_state, &gfx_options, _resMan, gfxmode, 1, 1);
+ gfxop_init(&gfx_state, &gfx_options, _resMan, gfxmode, 1, 1);
if (game_init_graphics(_gamestate)) { // Init interpreter graphics
warning("Game initialization failed: Error in GFX subsystem. Aborting...");
@@ -189,7 +191,7 @@ Common::Error SciEngine::run() {
return Common::kUnknownError;
}
- printf("Emulating SCI version %s\n", getSciVersionDesc(_resMan->sciVersion()).c_str());
+ printf("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()).c_str());
game_run(&_gamestate); // Run the game
@@ -227,10 +229,6 @@ const char* SciEngine::getGameID() const {
return _gameDescription->desc.gameid;
}
-SciVersion SciEngine::getVersion() const {
- return _resMan->sciVersion();
-}
-
Common::Language SciEngine::getLanguage() const {
return _gameDescription->desc.language;
}
@@ -267,35 +265,4 @@ void SciEngine::pauseEngineIntern(bool pause) {
_mixer->pauseAll(pause);
}
-Common::String SciEngine::getSciVersionDesc(SciVersion version) const {
- switch (version) {
- case SCI_VERSION_AUTODETECT:
- return "Autodetect";
- case SCI_VERSION_0_EARLY:
- return "Early SCI0";
- case SCI_VERSION_0_LATE:
- return "Late SCI0";
- case SCI_VERSION_01:
- return "SCI01";
- case SCI_VERSION_1_EGA:
- return "SCI1 EGA";
- case SCI_VERSION_1_EARLY:
- return "Early SCI1";
- case SCI_VERSION_1_MIDDLE:
- return "Middle SCI1";
- case SCI_VERSION_1_LATE:
- return "Late SCI1";
- case SCI_VERSION_1_1:
- return "SCI1.1";
- case SCI_VERSION_2:
- return "SCI2";
- case SCI_VERSION_2_1:
- return "SCI2.1";
- case SCI_VERSION_3:
- return "SCI3";
- default:
- return "Unknown";
- }
-}
-
} // End of namespace Sci
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 6f7eb90c6a..a48fc2e202 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -109,7 +109,6 @@ public:
const char* getGameID() const;
int getResourceVersion() const;
- SciVersion getVersion() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
uint32 getFlags() const;
@@ -126,8 +125,6 @@ public:
/** Remove the 'TARGET-' prefix of the given filename, if present. */
Common::String unwrapFilename(const Common::String &name) const;
- Common::String getSciVersionDesc(SciVersion version) const;
-
private:
const SciGameDescription *_gameDescription;
ResourceManager *_resMan;
@@ -137,13 +134,46 @@ private:
Console *_console;
};
+extern SciVersion _sciVersion;
+
/**
* Convenience function to obtain the active SCI version.
*/
inline static SciVersion getSciVersion() {
- return ((SciEngine*)g_engine)->getVersion();
+ assert (_sciVersion != SCI_VERSION_AUTODETECT);
+ return _sciVersion;
}
+inline static Common::String getSciVersionDesc(SciVersion version) {
+ switch (version) {
+ case SCI_VERSION_AUTODETECT:
+ return "Autodetect";
+ case SCI_VERSION_0_EARLY:
+ return "Early SCI0";
+ case SCI_VERSION_0_LATE:
+ return "Late SCI0";
+ case SCI_VERSION_01:
+ return "SCI01";
+ case SCI_VERSION_1_EGA:
+ return "SCI1 EGA";
+ case SCI_VERSION_1_EARLY:
+ return "Early SCI1";
+ case SCI_VERSION_1_MIDDLE:
+ return "Middle SCI1";
+ case SCI_VERSION_1_LATE:
+ return "Late SCI1";
+ case SCI_VERSION_1_1:
+ return "SCI1.1";
+ case SCI_VERSION_2:
+ return "SCI2";
+ case SCI_VERSION_2_1:
+ return "SCI2.1";
+ case SCI_VERSION_3:
+ return "SCI3";
+ default:
+ return "Unknown";
+ }
+}
} // End of namespace Sci
diff --git a/engines/sci/sfx/softseq/adlib.cpp b/engines/sci/sfx/softseq/adlib.cpp
index c838fca00a..d2a5cb9001 100644
--- a/engines/sci/sfx/softseq/adlib.cpp
+++ b/engines/sci/sfx/softseq/adlib.cpp
@@ -641,7 +641,7 @@ int MidiPlayer_Adlib::open(ResourceManager *resMan) {
static_cast<MidiDriver_Adlib *>(_driver)->loadResource(res);
- return static_cast<MidiDriver_Adlib *>(_driver)->open(resMan->sciVersion() <= SCI_VERSION_0_LATE);
+ return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
}
} // End of namespace Sci
diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp
index c949dfca40..783941fb11 100644
--- a/engines/sci/vocabulary.cpp
+++ b/engines/sci/vocabulary.cpp
@@ -92,7 +92,7 @@ Vocabulary::Vocabulary(ResourceManager *resMan) : _resMan(resMan) {
debug(2, "Initializing vocabulary");
- if (_resMan->sciVersion() <= SCI_VERSION_1_EGA && loadParserWords()) {
+ if (getSciVersion() <= SCI_VERSION_1_EGA && loadParserWords()) {
loadSuffixes();
if (loadBranches())
// Now build a GNF grammar out of this