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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu May 14 11:12:28 CEST 2009


Revision: 40552
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40552&view=rev
Author:   thebluegr
Date:     2009-05-14 09:12:27 +0000 (Thu, 14 May 2009)

Log Message:
-----------
Started using game-specific flags and removed/replaced some SCI version checks with flags.
- The SCI0 new script header and the angles check have been replaced by the GF_SCI0_OLD flag
- The SCI0 new drawpic parameter and the new priority check have been replaced by the GF_SCI0_OLDGFXFUNCS flag
- Removed the code which retries to use the newer script header in SCI0 games if the detected one is wrong, as that case should be covered by the GF_SCI0_OLD flag
- Removed the leftover min_version and max_version variables from gamestate
- Cleaned up kGetTime() a bit

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/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h
    scummvm/trunk/engines/sci/scicore/resource.h
    scummvm/trunk/engines/sci/scicore/versions.h
    scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
    scummvm/trunk/engines/sci/scicore/vocabulary.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/console.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -109,7 +109,7 @@
 bool Console::cmdSelectors(int argc, const char **argv) {
 	Common::StringList selectorNames;
 
-	if (!vocabulary_get_snames(_vm->getResMgr(), _vm->getVersion(), selectorNames)) {
+	if (!vocabulary_get_snames(_vm->getResMgr(), (_vm->getFlags() & GF_SCI0_OLD), selectorNames)) {
 		DebugPrintf("No selector name table found!\n");
 		return true;
 	}

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -121,7 +121,7 @@
 		{"resource.map", 0, "f3d1be7752d30ba60614533d531e2e98", 474},
 		{"resource.001", 0, "6fd05926c2199af0af6f72f90d0d7260", 126895},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 453)
 	},
@@ -196,7 +196,7 @@
 		{"resource.map", 0, "39485580d34a72997f3d5b3aba4d24f1", 426},
 		{"resource.001", 0, "11391434f41c834090d7a1e9488ce936", 129739},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLD | GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.395 and 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 0, 294)
 	},
@@ -876,7 +876,7 @@
 		{"resource.006", 0, "851a62d00972dc4002f472cc0d84e71d", 333777},
 		{"resource.007", 0, "851a62d00972dc4002f472cc0d84e71d", 341038},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLD | GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.395 and 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 274)
 	},
@@ -892,7 +892,7 @@
 		{"resource.006", 0, "0c8566848a76eea19a6d6220914030a7", 337288},
 		{"resource.007", 0, "0c8566848a76eea19a6d6220914030a7", 343882},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLD | GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.395 and 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 253)
 	},
@@ -1374,7 +1374,7 @@
 		{"resource.map", 0, "03dba704bb77da55a91ad27b5a3cac09", 528},
 		{"resource.001", 0, "9f5520f0297206928df0b0b36493cd33", 127532},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO},
-		0,
+		GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 409) // FIXME: no version number in executable (x.yyy.zzz)
 	},
@@ -1389,7 +1389,7 @@
 		{"resource.005", 0, "4a24443a25e2b1492462a52809605dc2", 277732},
 		{"resource.006", 0, "4a24443a25e2b1492462a52809605dc2", 345683},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 409)
 	},
@@ -1404,7 +1404,7 @@
 		{"resource.005", 0, "96033f57accfca903750413fd09193c8", 274953},
 		{"resource.006", 0, "96033f57accfca903750413fd09193c8", 345818},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLD | GF_SCI0_OLDGFXFUNCS,		// version is older than 0.000.395 and 0.000.502
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 343)
 	},
@@ -2554,7 +2554,7 @@
 		{"resource.map", 0, "ec66ac2b1ce58b2575ba00b65058de1a", 612},
 		{"resource.001", 0, "ceeda7202b96e5c85ecaa88a40a540fc", 180245},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO},
-		0,
+		GF_SCI0_OLD,		// version is older than 0.000.395
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 453)
 	},
@@ -2566,7 +2566,7 @@
 		{"resource.002", 0, "ceeda7202b96e5c85ecaa88a40a540fc", 720244},
 		{"resource.003", 0, "ceeda7202b96e5c85ecaa88a40a540fc", 688367},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0},
-		0,
+		GF_SCI0_OLD,		// version is older than 0.000.395
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION(0, 000, 453)
 	},

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -56,7 +56,7 @@
 
 	s->opcodes = vocabulary_get_opcodes(s->resmgr);
 
-	if (!vocabulary_get_snames(s->resmgr, s->version, s->_selectorNames)) {
+	if (!vocabulary_get_snames(s->resmgr, (s->flags & GF_SCI0_OLD), s->_selectorNames)) {
 		sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)!\n");
 		return 1;
 	}
@@ -127,7 +127,7 @@
 
 	s->priority_first = 42; // Priority zone 0 ends here
 
-	if (s->version < SCI_VERSION_FTU_PRIORITY_14_ZONES)
+	if (s->flags & GF_SCI0_OLDGFXFUNCS)
 		s->priority_last = 200;
 	else
 		s->priority_last = 190;
@@ -323,7 +323,7 @@
 		Resource *script = s->resmgr->findResource(kResourceTypeScript, scriptnr, 0);
 
 		if (script) {
-			if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
+			if (s->flags & GF_SCI0_OLD)
 				magic_offset = seeker = 2;
 			else
 				magic_offset = seeker = 0;
@@ -336,9 +336,8 @@
 						break;
 					seeker += (int16)READ_LE_UINT16(script->data + seeker + 2);
 					if (seeker <= lastseeker) {
-						warning("Script version is invalid");
 						s->_classtable.clear();
-						return SCI_ERROR_INVALID_SCRIPT_VERSION;
+						error("Script version is invalid");
 					}
 				}
 
@@ -387,8 +386,6 @@
 int script_init_engine(EngineState *s, sci_version_t version) {
 	int result;
 
-	s->max_version = SCI_VERSION(9, 999, 999);
-	s->min_version = 0; //Set no real limits
 	s->version = 0;
 	s->kernel_opt_flags = 0;
 

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -359,46 +359,35 @@
 	g_system->getTimeAndDate(loc_time);
 	start_time = g_system->getMillis() - s->game_start_time;
 
-	if (s->version < SCI_VERSION_FTU_NEW_GETTIME) { // Use old semantics
-		if (argc) { // Get seconds since last am/pm switch
-			retval = loc_time.tm_sec + loc_time.tm_min * 60 + (loc_time.tm_hour % 12) * 3600;
-			debugC(2, kDebugLevelTime, "GetTime(timeofday) returns %d", retval);
-		} else { // Get time since game started
-			retval = start_time * 60 / 1000;
-			debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
-		}
-	} else {
-		int mode = UKPV_OR_ALT(0, 0);
-		// The same strange method is still used for distinguishing
-		// mode 0 and the others. We assume that this is safe, though
+	if (argc && s->version < SCI_VERSION_FTU_NEW_GETTIME) { // Use old semantics
+		retval = loc_time.tm_sec + loc_time.tm_min * 60 + (loc_time.tm_hour % 12) * 3600;
+		debugC(2, kDebugLevelTime, "GetTime(timeofday) returns %d", retval);
+		return make_reg(0, retval);
+	}
 
-		switch (mode) {
-		case _K_NEW_GETTIME_TICKS : {
-			retval = start_time * 60 / 1000;
-			debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
-			break;
-		}
-		case _K_NEW_GETTIME_TIME_12HOUR : {
-			loc_time.tm_hour %= 12;
-			retval = (loc_time.tm_min << 6) | (loc_time.tm_hour << 12) | (loc_time.tm_sec);
-			debugC(2, kDebugLevelTime, "GetTime(12h) returns %d", retval);
-			break;
-		}
-		case _K_NEW_GETTIME_TIME_24HOUR : {
-			retval = (loc_time.tm_min << 5) | (loc_time.tm_sec >> 1) | (loc_time.tm_hour << 11);
-			debugC(2, kDebugLevelTime, "GetTime(24h) returns %d", retval);
-			break;
-		}
-		case _K_NEW_GETTIME_DATE : {
-			retval = ((loc_time.tm_mon + 1) << 5) | loc_time.tm_mday | (((loc_time.tm_year + 1900) & 0x7f) << 9);
-			debugC(2, kDebugLevelTime, "GetTime(date) returns %d", retval);
-			break;
-		}
-		default: {
-			warning("Attempt to use unknown GetTime mode %d", mode);
-			break;
-		}
-		}
+	int mode = UKPV_OR_ALT(0, 0);
+
+	switch (mode) {
+	case _K_NEW_GETTIME_TICKS :
+		retval = start_time * 60 / 1000;
+		debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
+		break;
+	case _K_NEW_GETTIME_TIME_12HOUR :
+		loc_time.tm_hour %= 12;
+		retval = (loc_time.tm_min << 6) | (loc_time.tm_hour << 12) | (loc_time.tm_sec);
+		debugC(2, kDebugLevelTime, "GetTime(12h) returns %d", retval);
+		break;
+	case _K_NEW_GETTIME_TIME_24HOUR :
+		retval = (loc_time.tm_min << 5) | (loc_time.tm_sec >> 1) | (loc_time.tm_hour << 11);
+		debugC(2, kDebugLevelTime, "GetTime(24h) returns %d", retval);
+		break;
+	case _K_NEW_GETTIME_DATE :
+		retval = ((loc_time.tm_mon + 1) << 5) | loc_time.tm_mday | (((loc_time.tm_year + 1900) & 0x7f) << 9);
+		debugC(2, kDebugLevelTime, "GetTime(date) returns %d", retval);
+		break;
+	default:
+		warning("Attempt to use unknown GetTime mode %d", mode);
+		break;
 	}
 
 	return make_reg(0, retval);

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -160,7 +160,7 @@
 				return j;
 		return 14; // Maximum
 	} else {
-		if (s->version >= SCI_VERSION_FTU_PRIORITY_14_ZONES)
+		if (!(s->flags & GF_SCI0_OLDGFXFUNCS))
 			return SCI0_VIEW_PRIORITY_14_ZONES(y);
 		else
 			return SCI0_VIEW_PRIORITY(y) == 15 ? 14 : SCI0_VIEW_PRIORITY(y);
@@ -168,7 +168,7 @@
 }
 
 int _find_priority_band(EngineState *s, int nr) {
-	if (s->version >= SCI_VERSION_FTU_PRIORITY_14_ZONES && (nr < 0 || nr > 14)) {
+	if (!(s->flags & GF_SCI0_OLDGFXFUNCS) && (nr < 0 || nr > 14)) {
 		if (nr == 15)
 			return 0xffff;
 		else {
@@ -177,7 +177,7 @@
 		return 0;
 	}
 
-	if (s->version < SCI_VERSION_FTU_PRIORITY_14_ZONES && (nr < 0 || nr > 15)) {
+	if ((s->flags & GF_SCI0_OLDGFXFUNCS) && (nr < 0 || nr > 15)) {
 		warning("Attempt to get priority band %d", nr);
 		return 0;
 	}
@@ -187,7 +187,7 @@
 	else {
 		int retval;
 
-		if (s->version >= SCI_VERSION_FTU_PRIORITY_14_ZONES)
+		if (!(s->flags & GF_SCI0_OLDGFXFUNCS))
 			retval = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr);
 		else
 			retval = SCI0_PRIORITY_BAND_FIRST(nr);
@@ -675,7 +675,7 @@
 
 	angle %= 360;
 
-	if (s->version >= SCI_VERSION_FTU_2ND_ANGLES) {
+	if (!(s->flags & GF_SCI0_OLD)) {
 		if (angle < 45)
 			loop = 3;
 		else if (angle < 136)
@@ -985,7 +985,7 @@
 	dp.nr = SKPV(0);
 	dp.palette = SKPV_OR_ALT(3, 0);
 
-	if (s->version < SCI_VERSION_FTU_NEWER_DRAWPIC_PARAMETERS) {
+	if (s->flags & GF_SCI0_OLDGFXFUNCS) {
 		if (!SKPV_OR_ALT(2, 0))
 			add_to_pic = 0;
 	} else {
@@ -1050,7 +1050,7 @@
 
 	s->priority_first = 42;
 
-	if (s->version < SCI_VERSION_FTU_PRIORITY_14_ZONES)
+	if (s->flags & GF_SCI0_OLDGFXFUNCS)
 		s->priority_last = 200;
 	else
 		s->priority_last = 190;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -513,9 +513,9 @@
 }
 
 static byte *find_unique_script_block(EngineState *s, byte *buf, int type) {
-	int magic_pos_adder = s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER ? 0 : 2;
+	if (s->flags & GF_SCI0_OLD)
+		buf += 2;
 
-	buf += magic_pos_adder;
 	do {
 		int seeker_type = READ_LE_UINT16(buf);
 		int seeker_size;
@@ -857,8 +857,6 @@
 
 	memcpy(&(retval->selector_map), &(s->selector_map), sizeof(selector_map_t));
 
-	retval->max_version = retval->version;
-	retval->min_version = retval->version;
 	retval->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE);
 
 	// Copy breakpoint information from current game instance

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -1379,7 +1379,7 @@
 			int stackframe = (scr[pos.offset + 2] >> 1) + (*p_restadjust);
 			int argc = ((*p_sp)[- stackframe - 1]).offset;
 
-			if (s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
+			if (!(s->flags & GF_SCI0_OLD))
 				argc += (*p_restadjust);
 
 			sciprintf(" Kernel params: (");

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "sci/sci.h"
 #include "sci/engine/seg_manager.h"
 #include "sci/engine/state.h"
 #include "sci/engine/intmap.h"
@@ -146,7 +147,7 @@
 		sciprintf("%s: failed to load %s\n", __FUNCTION__, !script ? "script" : "heap");
 		return;
 	}
-	if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) {
+	if (s->flags & GF_SCI0_OLD) {
 		scr.buf_size = script->size + READ_LE_UINT16(script->data) * 2;
 		//locals_size = READ_LE_UINT16(script->data) * 2;
 	} else if (s->version < SCI_VERSION(1, 001, 000)) {

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -100,8 +100,6 @@
 
 	version_lock_flag = 0;
 	version = 0;
-	max_version = 0;
-	min_version = 0;
 
 	_fileHandles.resize(5);
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-05-14 09:12:27 UTC (rev 40552)
@@ -196,7 +196,7 @@
 
 	byte version_lock_flag; /**< Set to 1 to disable any autodetection mechanisms */
 	sci_version_t version; /**< The approximated patchlevel of the version to emulate */
-	sci_version_t max_version, min_version; /* Used for autodetect sanity checks */
+	uint32 flags;			/* Specific game flags */
 
 	unsigned int kernel_opt_flags; /**< Kernel optimization flags- used for performance tweaking */
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -26,6 +26,7 @@
 #include "common/debug.h"
 #include "common/stack.h"
 
+#include "sci/sci.h"
 #include "sci/scicore/resource.h"
 #include "sci/engine/state.h"
 #include "sci/scicore/versions.h"
@@ -1005,7 +1006,7 @@
 			gc_countdown(s);
 
 			xs->sp -= (opparams[1] >> 1) + 1;
-			if (s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER) {
+			if (!(s->flags & GF_SCI0_OLD)) {
 				xs->sp -= restadjust;
 				s->r_amp_rest = 0; // We just used up the restadjust, remember?
 			}
@@ -1016,7 +1017,7 @@
 			} else {
 				int argc = ASSERT_ARITHMETIC(xs->sp[0]);
 
-				if (s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
+				if (!(s->flags & GF_SCI0_OLD))
 					argc += restadjust;
 
 				if (s->_kfuncTable[opparams[0]].signature
@@ -1034,7 +1035,7 @@
 				xs_new = &(s->_executionStack[s->execution_stack_pos]);
 				s->_executionStackPosChanged = true;
 
-				if (s->version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
+				if (!(s->flags & GF_SCI0_OLD))
 					restadjust = s->r_amp_rest;
 
 			}
@@ -1549,7 +1550,7 @@
 
 	// Early SCI versions used the LSB in the selector ID as a read/write
 	// toggle, meaning that we must remove it for selector lookup.
-	if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
+	if (s->flags & GF_SCI0_OLD)
 		selector_id &= ~1;
 
 	if (!obj) {
@@ -1722,7 +1723,7 @@
 	reg.segment = seg_id;
 	reg.offset = 0;
 
-	if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) {
+	if (s->flags & GF_SCI0_OLD) {
 		//
 		int locals_nr = READ_LE_UINT16(script->data);
 
@@ -1899,7 +1900,7 @@
 }
 
 void script_uninstantiate_sci0(EngineState *s, int script_nr, SegmentId seg) {
-	reg_t reg = make_reg(seg, (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) ? 2 : 0);
+	reg_t reg = make_reg(seg, (s->flags & GF_SCI0_OLD) ? 2 : 0);
 	int objtype, objlength;
 
 	// Make a pass over the object in order uninstantiate all superclasses
@@ -1941,7 +1942,7 @@
 }
 
 void script_uninstantiate(EngineState *s, int script_nr) {
-	reg_t reg = make_reg(0, (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) ? 2 : 0);
+	reg_t reg = make_reg(0, (s->flags & GF_SCI0_OLD) ? 2 : 0);
 
 	reg.segment = s->seg_manager->segGet(script_nr);
 

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -81,50 +81,7 @@
 }
 
 static int init_gamestate(EngineState *gamestate, sci_version_t version) {
-	int errc;
-
-	if ((errc = script_init_engine(gamestate, version))) { // Initialize game state
-		int recovered = 0;
-
-		if (errc == SCI_ERROR_INVALID_SCRIPT_VERSION) {
-			int tversion = SCI_VERSION_FTU_NEW_SCRIPT_HEADER - ((version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) ? 0 : 1);
-
-			while (!recovered && tversion) {
-				printf("Trying version %d.%03x.%03d instead\n", SCI_VERSION_MAJOR(tversion),
-				       SCI_VERSION_MINOR(tversion), SCI_VERSION_PATCHLEVEL(tversion));
-
-				errc = script_init_engine(gamestate, tversion);
-
-				if ((recovered = !errc))
-					version = tversion;
-
-				if (errc != SCI_ERROR_INVALID_SCRIPT_VERSION)
-					break;
-
-				switch (tversion) {
-
-				case SCI_VERSION_FTU_NEW_SCRIPT_HEADER - 1:
-					if (version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
-						tversion = 0;
-					else
-						tversion = SCI_VERSION_FTU_NEW_SCRIPT_HEADER;
-					break;
-
-				case SCI_VERSION_FTU_NEW_SCRIPT_HEADER:
-					tversion = 0;
-					break;
-				}
-			}
-			if (recovered)
-				printf("Success.\n");
-		}
-
-		if (!recovered) {
-			fprintf(stderr, "Script initialization failed. Aborting...\n");
-			return 1;
-		}
-	}
-	return 0;
+	return script_init_engine(gamestate, version);
 }
 
 SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc)
@@ -222,6 +179,7 @@
 	EngineState *gamestate = new EngineState();
 	gamestate->resmgr = _resmgr;
 	gamestate->gfx_state = NULL;
+	gamestate->flags = getFlags();
 
 	if (init_gamestate(gamestate, version))
 		return Common::kUnknownError;
@@ -328,7 +286,7 @@
 }
 
 uint32 SciEngine::getFlags() const {
-	return _gameDescription->desc.flags;
+	return _gameDescription->flags;
 }
 
 Common::String SciEngine::getSavegameName(int nr) const {

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/sci.h	2009-05-14 09:12:27 UTC (rev 40552)
@@ -81,31 +81,27 @@
 	** SCI0 flags
 	*/
 
-	/* Applies to all versions before 0.000.395
+	/* Applies to all versions before 0.000.395 (i.e. KQ4 old, XMAS 1988 and LSL2)
 	** Old SCI versions used two word header for script blocks (first word equal
 	** to 0x82, meaning of the second one unknown). New SCI versions used one
 	** word header.
+	** Also, old SCI versions assign 120 degrees to left & right, and 60 to up
+	** and down. Later versions use an even 90 degree distribution.
 	*/
-	GF_OLDSCRIPTHEADER	= (1 << 0),
+	GF_SCI0_OLD			= (1 << 0),
 
-	/* Applies to all versions before 0.000.395
-	** Earlier versions assign 120 degrees to left & right , and 60 to up and down.
-	** Later versions use an even 90 degree distribution.
-	*/
-	GF_OLDANGLES		= (1 << 1),
-
 	/* Applies to all versions before 0.000.502
 	** Old SCI versions used to interpret the third DrawPic() parameter inversely,
 	** with the opposite default value (obviously).
 	** Also, they used 15 priority zones from 42 to 200 instead of 14 priority
 	** zones from 42 to 190.
 	*/
-	GF_OLDGFXFUNCTIONS	= (1 << 2),
+	GF_SCI0_OLDGFXFUNCS	= (1 << 1),
 
 	/* Applies to all versions before 0.000.629
 	** Older SCI versions had simpler code for GetTime()
 	*/
-	GF_OLDGETTIME		= (1 << 3),
+	GF_SCI0_OLDGETTIME	= (1 << 2),
 
 	// ----------------------------------------------------------------------------
 
@@ -117,12 +113,12 @@
     ** In later SCI1 versions, the argument of lofs[as]
 	** instructions is absolute rather than relative.
 	*/
-	GF_LOFSABSOLUTE		= (1 << 4),
+	GF_LOFSABSOLUTE		= (1 << 3),
 
 	/* Applies to all versions from 1.000.510 onwards
 	** kDoSound() is different than in earlier SCI1 versions.
 	*/
-	GF_NEWDOSOUND		= (1 << 5)
+	GF_NEWDOSOUND		= (1 << 4)
 };
 
 class SciEngine : public Engine {

Modified: scummvm/trunk/engines/sci/scicore/resource.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.h	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/scicore/resource.h	2009-05-14 09:12:27 UTC (rev 40552)
@@ -66,7 +66,6 @@
 #define SCI_ERROR_RESOURCE_TOO_BIG 9
 /* Resource size exceeds SCI_MAX_RESOURCE_SIZE */
 #define SCI_ERROR_UNSUPPORTED_VERSION 10
-#define SCI_ERROR_INVALID_SCRIPT_VERSION 11
 
 #define SCI_ERROR_CRITICAL SCI_ERROR_NO_RESOURCE_FILES_FOUND
 /* the first critical error number */

Modified: scummvm/trunk/engines/sci/scicore/versions.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/versions.h	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/scicore/versions.h	2009-05-14 09:12:27 UTC (rev 40552)
@@ -46,30 +46,6 @@
 ** - "FTU" means "First To Use"
 */
 
-#define SCI_VERSION_FTU_NEW_SCRIPT_HEADER SCI_VERSION(0,000,395)
-/* Last version known not to do this: 0.000.343
-** Old SCI versions used two word header for script blocks (first word equal
-** to 0x82, meaning of the second one unknown). New SCI versions used one
-** word header.
-*/
-
-#define SCI_VERSION_FTU_2ND_ANGLES SCI_VERSION(0,000,395)
-/* Last version known not to use this: ?
-** Earlier versions assign 120 degrees to left & right , and 60 to up and down.
-** Later versions use an even 90 degree distribution.
-*/
-
-#define SCI_VERSION_FTU_NEWER_DRAWPIC_PARAMETERS SCI_VERSION(0,000,502)
-/* Last version known not to do this: 0.000.435
-** Old SCI versions used to interpret the third DrawPic() parameter inversely,
-** with the opposite default value (obviously)
-*/
-
-#define SCI_VERSION_FTU_PRIORITY_14_ZONES SCI_VERSION(0,000,502)
-/* Last version known to do this: 0.000.490
- * Uses 14 zones from 42 to 190 instead of 15 zones from 42 to 200.
-*/
-
 #define SCI_VERSION_FTU_NEW_GETTIME SCI_VERSION(0,000,629)
 /* These versions of SCI has a different set of subfunctions in GetTime() */
 

Modified: scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-05-14 09:12:27 UTC (rev 40552)
@@ -308,7 +308,7 @@
 }
 #endif
 
-bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Common::StringList &selectorNames) {
+bool vocabulary_get_snames(ResourceManager *resmgr, bool isOldSci0, Common::StringList &selectorNames) {
 	int count;
 
 	Resource *r = resmgr->findResource(kResourceTypeVocab, 997, 0);
@@ -324,11 +324,11 @@
 		
 		Common::String tmp((const char *)r->data + offset + 2, len);
 		selectorNames.push_back(tmp);
-		if ((version != 0) && (version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)) {
-			// Early SCI versions used the LSB in the selector ID as a read/write
-			// toggle. To compensate for that, we add every selector name twice.
+
+		// Early SCI versions used the LSB in the selector ID as a read/write
+		// toggle. To compensate for that, we add every selector name twice.
+		if (isOldSci0)
 			selectorNames.push_back(tmp);
-		}
 	}
 
 	return true;

Modified: scummvm/trunk/engines/sci/scicore/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocabulary.h	2009-05-14 07:28:06 UTC (rev 40551)
+++ scummvm/trunk/engines/sci/scicore/vocabulary.h	2009-05-14 09:12:27 UTC (rev 40552)
@@ -195,7 +195,7 @@
  * Fills the given StringList with selector names.
  * Returns true upon success, false oterwise.
  */
-bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Common::StringList &selectorNames);
+bool vocabulary_get_snames(ResourceManager *resmgr, bool isOldSci0, Common::StringList &selectorNames);
 
 /* Look up a selector name in an array, return the index */
 int vocabulary_lookup_sname(const Common::StringList &selectorNames, const char *sname);


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