diff options
| author | Filippos Karapetis | 2009-05-14 09:12:27 +0000 | 
|---|---|---|
| committer | Filippos Karapetis | 2009-05-14 09:12:27 +0000 | 
| commit | 999d46b241a4aade493f76b4f3623a39c4fed930 (patch) | |
| tree | 56a1c2079395ab22ccae8a003691230f073635e3 | |
| parent | 2ca7605050c25eff88931fe523c2b005856803f1 (diff) | |
| download | scummvm-rg350-999d46b241a4aade493f76b4f3623a39c4fed930.tar.gz scummvm-rg350-999d46b241a4aade493f76b4f3623a39c4fed930.tar.bz2 scummvm-rg350-999d46b241a4aade493f76b4f3623a39c4fed930.zip | |
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
svn-id: r40552
| -rw-r--r-- | engines/sci/console.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/detection.cpp | 18 | ||||
| -rw-r--r-- | engines/sci/engine/game.cpp | 11 | ||||
| -rw-r--r-- | engines/sci/engine/kernel.cpp | 69 | ||||
| -rw-r--r-- | engines/sci/engine/kgraphics.cpp | 14 | ||||
| -rw-r--r-- | engines/sci/engine/savegame.cpp | 6 | ||||
| -rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/engine/seg_manager.cpp | 3 | ||||
| -rw-r--r-- | engines/sci/engine/state.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/engine/state.h | 2 | ||||
| -rw-r--r-- | engines/sci/engine/vm.cpp | 15 | ||||
| -rw-r--r-- | engines/sci/sci.cpp | 48 | ||||
| -rw-r--r-- | engines/sci/sci.h | 20 | ||||
| -rw-r--r-- | engines/sci/scicore/resource.h | 1 | ||||
| -rw-r--r-- | engines/sci/scicore/versions.h | 24 | ||||
| -rw-r--r-- | engines/sci/scicore/vocab_debug.cpp | 10 | ||||
| -rw-r--r-- | engines/sci/scicore/vocabulary.h | 2 | 
17 files changed, 81 insertions, 168 deletions
| diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 6cce0fcedd..2a2092d861 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -109,7 +109,7 @@ bool Console::cmdGetVersion(int argc, const char **argv) {  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;  	} diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 66bd3a0dc0..9633046fa2 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -121,7 +121,7 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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 @@ static const struct SciGameDescription SciGameDescriptions[] = {  		{"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)  	}, diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 0066ebf239..c7909b76c1 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -56,7 +56,7 @@ static int _init_vocabulary(EngineState *s) { // initialize vocabulary and relat  	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 @@ int _reset_graphics_input(EngineState *s) {  	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 @@ static int create_class_table_sci0(EngineState *s) {  		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 @@ static int create_class_table_sci0(EngineState *s) {  						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 @@ static int create_class_table_sci0(EngineState *s) {  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; diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index b7ec82265d..8c4fc596ce 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -359,46 +359,35 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) {  	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 - -		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; -		} -		} +	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); +	} + +	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); diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index ab9bbcf354..c7e0102d18 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -160,7 +160,7 @@ int _find_view_priority(EngineState *s, int y) {  				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_view_priority(EngineState *s, int y) {  }  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 @@ int _find_priority_band(EngineState *s, int nr) {  		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 @@ int _find_priority_band(EngineState *s, int nr) {  	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 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int funct_nr, int argc,  	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 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {  	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 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {  	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; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 363cf48392..a88deff5a1 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -513,9 +513,9 @@ static SegmentId find_unique_seg_by_type(SegManager *self, int type) {  }  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 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {  	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 diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 9e962a6449..5727062bbc 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1379,7 +1379,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod  			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: ("); diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 62976dc548..df0561a5e1 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -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 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) {  		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)) { diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 4661abeeda..948e10ff71 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -100,8 +100,6 @@ EngineState::EngineState() : _dirseeker(this) {  	version_lock_flag = 0;  	version = 0; -	max_version = 0; -	min_version = 0;  	_fileHandles.resize(5); diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index e361601444..8e7b92f5a1 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -196,7 +196,7 @@ public:  	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 */ diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 7b27decbda..46944eb020 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -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 @@ void run_vm(EngineState *s, int restoring) {  			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 @@ void run_vm(EngineState *s, int restoring) {  			} 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 @@ void run_vm(EngineState *s, int restoring) {  				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 @@ SelectorType lookup_selector(EngineState *s, reg_t obj_location, Selector select  	// 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 @@ int script_instantiate_sci0(EngineState *s, int script_nr) {  	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 @@ int script_instantiate(EngineState *s, int script_nr) {  }  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_sci0(EngineState *s, int script_nr, SegmentId seg) {  }  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); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 3359ed9898..6c6dd7356c 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -81,50 +81,7 @@ static void init_console() {  }  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 @@ Common::Error SciEngine::run() {  	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 @@ Common::Platform SciEngine::getPlatform() const {  }  uint32 SciEngine::getFlags() const { -	return _gameDescription->desc.flags; +	return _gameDescription->flags;  }  Common::String SciEngine::getSavegameName(int nr) const { diff --git a/engines/sci/sci.h b/engines/sci/sci.h index ac2d7288c8..35d2f8d8f1 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -81,18 +81,14 @@ enum SciGameFlags {  	** 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), - -	/* 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), +	GF_SCI0_OLD			= (1 << 0),  	/* Applies to all versions before 0.000.502  	** Old SCI versions used to interpret the third DrawPic() parameter inversely, @@ -100,12 +96,12 @@ enum SciGameFlags {  	** 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 @@ enum SciGameFlags {      ** 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 { diff --git a/engines/sci/scicore/resource.h b/engines/sci/scicore/resource.h index 82344da3b2..3bf5c97d05 100644 --- a/engines/sci/scicore/resource.h +++ b/engines/sci/scicore/resource.h @@ -66,7 +66,6 @@ enum ResourceStatus {  #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 */ diff --git a/engines/sci/scicore/versions.h b/engines/sci/scicore/versions.h index bae643066d..4739b7a3fb 100644 --- a/engines/sci/scicore/versions.h +++ b/engines/sci/scicore/versions.h @@ -46,30 +46,6 @@ namespace Sci {  ** - "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() */ diff --git a/engines/sci/scicore/vocab_debug.cpp b/engines/sci/scicore/vocab_debug.cpp index 579f61a8de..bb157135ab 100644 --- a/engines/sci/scicore/vocab_debug.cpp +++ b/engines/sci/scicore/vocab_debug.cpp @@ -308,7 +308,7 @@ int vocabulary_get_class_count(ResourceManager *resmgr) {  }  #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 @@ bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Commo  		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; diff --git a/engines/sci/scicore/vocabulary.h b/engines/sci/scicore/vocabulary.h index 504931b5be..2124ed36d8 100644 --- a/engines/sci/scicore/vocabulary.h +++ b/engines/sci/scicore/vocabulary.h @@ -195,7 +195,7 @@ int vocabulary_get_class_count(ResourceManager *resmgr);   * 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); | 
