[Scummvm-cvs-logs] SF.net SVN: scummvm:[44269] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Sep 23 12:55:35 CEST 2009


Revision: 44269
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44269&view=rev
Author:   thebluegr
Date:     2009-09-23 10:55:35 +0000 (Wed, 23 Sep 2009)

Log Message:
-----------
- 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

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/kmovement.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/segment.cpp
    scummvm/trunk/engines/sci/engine/segment.h
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/static_selectors.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h
    scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
    scummvm/trunk/engines/sci/vocabulary.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/console.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -367,7 +367,7 @@
 }
 
 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;
 }

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -285,7 +285,7 @@
 #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;

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -196,7 +196,7 @@
 		} 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 @@
 }
 
 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;

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -411,7 +411,7 @@
 }
 
 void Kernel::detectSciFeatures() {
-	SciVersion version = _resMan->sciVersion();
+	SciVersion version = getSciVersion();
 
 	features = 0;
 
@@ -447,12 +447,12 @@
 
 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 @@
 	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 @@
 	_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

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-09-23 10:55:35 UTC (rev 44269)
@@ -133,7 +133,7 @@
 	 * 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

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -40,7 +40,7 @@
 	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

Modified: scummvm/trunk/engines/sci/engine/kmovement.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmovement.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/kmovement.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -296,7 +296,7 @@
 	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 @@
 		completed = 1;
 	}
 
-	if (s->resMan->sciVersion() > SCI_VERSION_01)
+	if (getSciVersion() > SCI_VERSION_01)
 		if (completed)
 			invoke_selector(INV_SEL(mover, moveDone, kStopOnInvalidSelector), 0);
 

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -167,7 +167,7 @@
 	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 @@
 			// 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);

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -544,7 +544,7 @@
 }
 
 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 @@
 	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 @@
 				// 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 @@
 				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 @@
 	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;

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -96,10 +96,8 @@
 	}
 
 #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;

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -130,18 +130,18 @@
 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 @@
 	}
 }
 
-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 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 
 		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) {

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -137,7 +137,7 @@
 
 	_nr = script_nr;
 
-	if (resMan->sciVersion() >= SCI_VERSION_1_1)
+	if (getSciVersion() >= SCI_VERSION_1_1)
 		_heapStart = _buf + _scriptSize;
 	else
 		_heapStart = _buf;

Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/segment.h	2009-09-23 10:55:35 UTC (rev 44269)
@@ -351,7 +351,7 @@
 	 * @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

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -113,7 +113,7 @@
 
 	successor = 0;
 
-	speedThrottler = new SpeedThrottler(res->sciVersion());
+	speedThrottler = new SpeedThrottler(getSciVersion());
 
 	_setCursorType = SCI_VERSION_AUTODETECT;
 	_doSoundType = SCI_VERSION_AUTODETECT;
@@ -294,15 +294,15 @@
 		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 @@
 		} 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 @@
 			_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;

Modified: scummvm/trunk/engines/sci/engine/static_selectors.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/static_selectors.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/static_selectors.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -89,9 +89,9 @@
 	{     "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 @@
 	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 @@
 		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;

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -1412,12 +1412,12 @@
 	*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 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 @@
 			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(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);

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -58,10 +58,10 @@
 
 	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 @@
 		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 @@
 	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 @@
 		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 @@
 		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;

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -384,7 +384,7 @@
 	(*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;

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-09-23 10:55:35 UTC (rev 44269)
@@ -135,7 +135,6 @@
 /**
  * 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 @@
  * @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);
 

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -315,7 +315,7 @@
 	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 @@
 	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 @@
 		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 @@
 	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 @@
 		// 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 @@
 			// 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");
 	}
 }
 

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/resource.h	2009-09-23 10:55:35 UTC (rev 44269)
@@ -228,12 +228,6 @@
 	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 @@
 	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 @@
 	ViewType detectViewType();
 	bool hasSci0Voc999();
 	bool hasSci1Voc900();
-	SciVersion detectSciVersion();
+	void detectSciVersion();
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -43,6 +43,8 @@
 
 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 @@
 	// 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 @@
 		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 @@
 	return _gameDescription->desc.gameid;
 }
 
-SciVersion SciEngine::getVersion() const {
-	return _resMan->sciVersion();
-}
-
 Common::Language SciEngine::getLanguage() const {
 	return _gameDescription->desc.language;
 }
@@ -267,35 +265,4 @@
 	_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

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/sci.h	2009-09-23 10:55:35 UTC (rev 44269)
@@ -109,7 +109,6 @@
 
 	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 @@
 	/** 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 @@
 	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
 

Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -641,7 +641,7 @@
 
 	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

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-09-23 10:49:18 UTC (rev 44268)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-09-23 10:55:35 UTC (rev 44269)
@@ -92,7 +92,7 @@
 
 	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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list