[Scummvm-cvs-logs] CVS: scummvm/simon intern.h,1.29,1.29.2.1 simon.cpp,1.422.2.2,1.422.2.3 sound.cpp,1.64,1.64.2.1

Travis Howell kirben at users.sourceforge.net
Fri Aug 13 21:36:06 CEST 2004


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14277/simon

Modified Files:
      Tag: branch-0-6-0
	intern.h simon.cpp sound.cpp 
Log Message:

Back port Simon engine detection changes


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/intern.h,v
retrieving revision 1.29
retrieving revision 1.29.2.1
diff -u -d -r1.29 -r1.29.2.1
--- intern.h	6 Jan 2004 12:45:31 -0000	1.29
+++ intern.h	14 Aug 2004 04:35:20 -0000	1.29.2.1
@@ -163,7 +163,6 @@
 	GAME_SIMON1WIN = GF_WIN | GF_TALKIE,
 	GAME_SIMON2WIN = GF_SIMON2 | GF_WIN | GF_TALKIE,
 	GAME_SIMON1DEMO = GF_DEMO | GF_OLD_BUNDLE,
-	GAME_SIMON2MAC =  GF_SIMON2 | GF_WIN | GF_TALKIE | GF_MAC,
 	GAME_SIMON1AMIGA = GF_AMIGA | GF_OLD_BUNDLE,
 	GAME_SIMON1CD32 = GF_TALKIE | GF_AMIGA | GF_OLD_BUNDLE,
 	GAME_SIMON1ACORN = GF_TALKIE | GF_ACORN

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.422.2.2
retrieving revision 1.422.2.3
diff -u -d -r1.422.2.2 -r1.422.2.3
--- simon.cpp	12 Apr 2004 12:29:38 -0000	1.422.2.2
+++ simon.cpp	14 Aug 2004 04:35:20 -0000	1.422.2.3
@@ -28,6 +28,7 @@
 
 #include "common/config-manager.h"
 #include "common/file.h"
+#include "common/md5.h"
 
 #include "gui/about.h"
 #include "gui/message.h"
@@ -36,6 +37,7 @@
 #include "simon/intern.h"
 #include "simon/vga.h"
 #include "simon/debugger.h"
+#include "simon/simon-md5.h"
 
 #include "sound/mididrv.h"
 
@@ -65,17 +67,23 @@
 	{"simon1dos", "Simon the Sorcerer 1 (DOS)", GAME_SIMON1DOS, "GAMEPC"},
 	{"simon1amiga", "Simon the Sorcerer 1 (Amiga)", GAME_SIMON1AMIGA, "gameamiga"},
 	{"simon2dos", "Simon the Sorcerer 2 (DOS)", GAME_SIMON2DOS, "GAME32"},
-	{"simon1talkie", "Simon the Sorcerer 1 Talkie (DOS)", GAME_SIMON1TALKIE, "SIMON.GME"},
-	{"simon2talkie", "Simon the Sorcerer 2 Talkie (DOS)", GAME_SIMON2TALKIE, "GSPTR30"},
-	{"simon1win", "Simon the Sorcerer 1 Talkie (Windows)", GAME_SIMON1WIN, "SIMON.GME"},
+	{"simon1talkie", "Simon the Sorcerer 1 Talkie", GAME_SIMON1TALKIE, "GAMEPC"},
+	{"simon1win", "Simon the Sorcerer 1 Talkie (Windows)", GAME_SIMON1WIN, 0},
+	{"simon2talkie", "Simon the Sorcerer 2 Talkie", GAME_SIMON2TALKIE, "GSPTR30"},
+	{"simon2win", "Simon the Sorcerer 2 Talkie (Windows)", GAME_SIMON2WIN, 0},
+	{"simon2mac", "Simon the Sorcerer 2 Talkie (Amiga or Mac)", GAME_SIMON2WIN, 0},
 	{"simon1cd32", "Simon the Sorcerer 1 Talkie (Amiga CD32)", GAME_SIMON1CD32, "gameamiga"},
-	{"simon2win", "Simon the Sorcerer 2 Talkie (Windows)", GAME_SIMON2WIN, "GSPTR30"},
-	{"simon2mac", "Simon the Sorcerer 2 Talkie (Amiga or Mac)", GAME_SIMON2MAC, "simon2.dic"},
 	{"simon1demo", "Simon the Sorcerer 1 (DOS Demo)", GAME_SIMON1DEMO, "GDEMO"}, 
 
 	{NULL, NULL, 0, NULL}
 };
 
+static int compareMD5Table(const void *a, const void *b) {
+	const char *key = (const char *)a;
+	const MD5Table *elem = (const MD5Table *)b;
+	return strcmp(key, elem->md5);
+}
+
 GameList Engine_SIMON_gameList() {
 	const SimonGameSettings *g = simon_settings;
 	GameList games;
@@ -92,7 +100,13 @@
 	char detectName[128];
 	char detectName2[128];
 
+	typedef Common::Map<Common::String, bool> StringSet;
+	StringSet fileSet;
+
 	for (g = simon_settings; g->name; ++g) {
+		if (g->detectname == NULL)
+			continue;
+
 		strcpy(detectName, g->detectname);
 		strcpy(detectName2, g->detectname);
 		strcat(detectName2, ".");
@@ -105,10 +119,42 @@
 				(0 == scumm_stricmp(detectName2, name))) {
 				// Match found, add to list of candidates, then abort inner loop.
 				detectedGames.push_back(g->toGameSettings());
+				fileSet.addKey(file->path());
 				break;
 			}
 		}
 	}
+
+	// Now, we check the MD5 sums of the 'candidate' files. If we have an exact match,
+	// only return that.
+	bool exactMatch = false;
+	for (StringSet::const_iterator iter = fileSet.begin(); iter != fileSet.end(); ++iter) {
+		uint8 md5sum[16];
+		const char *name = iter->_key.c_str();
+		if (md5_file(name, md5sum)) {
+			char md5str[32+1];
+			for (int j = 0; j < 16; j++) {
+				sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
+			}
+
+			const MD5Table *elem;
+			elem = (const MD5Table *)bsearch(md5str, md5table, ARRAYSIZE(md5table)-1, sizeof(MD5Table), compareMD5Table);
+			if (elem) {
+				if (!exactMatch)
+					detectedGames.clear();	// Clear all the non-exact candidates
+				// Find the GameSettings for that target
+				for (g = simon_settings; g->name; ++g) {
+					if (0 == scumm_stricmp(g->name, elem->target))
+						break;
+				}
+				assert(g->name);
+				// Insert the 'enhanced' game data into the candidate list
+				detectedGames.push_back(DetectedGame(g->toGameSettings(), elem->language, elem->platform));
+				exactMatch = true;
+			}
+		}
+	}
+
 	return detectedGames;
 }
 
@@ -127,7 +173,6 @@
 static const GameSpecificSettings *simon1amiga_settings;
 static const GameSpecificSettings *simon1demo_settings;
 static const GameSpecificSettings *simon2win_settings;
-static const GameSpecificSettings *simon2mac_settings;
 static const GameSpecificSettings *simon2dos_settings;
 #else
 #define PTR(a) &a
@@ -191,18 +236,6 @@
 	"GSPTR30",                              // gamepc_filename
 };
 
-static const GameSpecificSettings simon2mac_settings = {
-	"Simon2.gme",                           // gme_filename
-	"",                                     // wav_filename
-	"",                                     // voc_filename
-	"SIMON2.MP3",                           // mp3_filename
-	"SIMON2.OGG",                           // vorbis_filename
-	"",                                     // voc_effects_filename
-	"",                                     // mp3_effects_filename
-	"",                                     // vorbis_effects_filename
-	"gsptr30",                              // gamepc_filename
-};
-
 static const GameSpecificSettings simon2dos_settings = {
 	"SIMON2.GME",                           // gme_filename
 	"",                                     // wav_filename
@@ -222,10 +255,46 @@
 	_vc_ptr = 0;
 	_game_offsets_ptr = 0;
 	
-	_game = (byte)detector->_game.features;
+	const SimonGameSettings *g = simon_settings;
+	while (g->name) {
+		if (!scumm_stricmp(detector->_game.name, g->name))
+			break;
+		g++;
+	}
+	if (!g->name)
+		error("Invalid game '%s'\n", detector->_game.name);
+
+	SimonGameSettings game = *g;
+
+	switch (Common::parsePlatform(ConfMan.get("platform"))) {
+	case Common::kPlatformAmiga:
+	case Common::kPlatformMacintosh:
+		if (game.features & GF_SIMON2)
+			game.features |= GF_WIN;
+		break;
+	case Common::kPlatformWindows:
+		game.features |= GF_WIN;
+		break;
+	default:
+		break;
+	}
+
+	_game = game.features;
+
+	// Convert older targets
+	if (g->detectname == NULL) {
+		if (!strcmp("simon1win", g->name)) {
+			ConfMan.set("gameid", "simon1talkie"); 
+			ConfMan.set("platform", "Windows"); 
+		} else if (!strcmp("simon2win", g->name) || !strcmp("simon2mac", g->name)) {
+			ConfMan.set("gameid", "simon2talkie"); 
+			ConfMan.set("platform", "Windows"); 
+		}
+		ConfMan.flushToDisk();
+	}
 
+	VGA_DELAY_BASE = 1;
 	if (_game & GF_SIMON2) {
-		VGA_DELAY_BASE = 1;
 		TABLE_INDEX_BASE = 1580 / 4;
 		TEXT_INDEX_BASE = 1500 / 4;
 		NUM_VIDEO_OP_CODES = 75;
@@ -241,7 +310,6 @@
 			MUSIC_INDEX_BASE = 1128 / 4;
 		SOUND_INDEX_BASE = 1660 / 4;
 	} else {
-		VGA_DELAY_BASE = 1;
 		TABLE_INDEX_BASE = 1576 / 4;
 		TEXT_INDEX_BASE = 1460 / 4;
 		NUM_VIDEO_OP_CODES = 64;
@@ -255,9 +323,7 @@
 		SOUND_INDEX_BASE = 0;
 	}
 
-	if (_game & GF_MAC)
-		gss = PTR(simon2mac_settings);
-	else if ((_game & GF_SIMON2) && (_game & GF_TALKIE))
+	if ((_game & GF_SIMON2) && (_game & GF_TALKIE))
 		gss = PTR(simon2win_settings);
 	else if (_game & GF_SIMON2)
 		gss = PTR(simon2dos_settings);
@@ -1180,11 +1246,11 @@
 				readSubroutineBlock(in);
 				closeTablesFile(in);
 
-				if (_game == GAME_SIMON1WIN) {
+				if (_game & GF_SIMON2) {
+					_sound->loadSfxTable(_game_file, _game_offsets_ptr[atoi(filename + 6) - 1 + SOUND_INDEX_BASE]);
+				} else if (_game & GF_WIN) {
 					memcpy(filename, "SFXXXX", 6);
 					_sound->readSfxFile(filename, _gameDataPath);
-				} else if (_game & GF_SIMON2) {
-					_sound->loadSfxTable(_game_file, _game_offsets_ptr[atoi(filename + 6) - 1 + SOUND_INDEX_BASE]);
 				}
 
 				alignTableMem();

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.cpp,v
retrieving revision 1.64
retrieving revision 1.64.2.1
diff -u -d -r1.64 -r1.64.2.1
--- sound.cpp	19 Jan 2004 17:50:38 -0000	1.64
+++ sound.cpp	14 Aug 2004 04:35:21 -0000	1.64.2.1
@@ -279,23 +279,19 @@
 #endif
 	if (!_voice) {
 		// for simon2 mac/amiga, only read index file
-		if (_game == GAME_SIMON2MAC) {
-			file->open("voices.idx", gameDataPath);
-			if (file->isOpen() == false) {
-				warning("Can't open voice index file 'voices.idx'");
-			} else {
-				file->seek(0, SEEK_END);
-				int end = file->pos();
-				file->seek(0, SEEK_SET);
-				_filenums = (uint16 *)malloc((end / 6 + 1) * 2);
-				_offsets = (uint32 *)malloc((end / 6 + 1) * 4);
+		file->open("voices.idx", gameDataPath);
+		if (file->isOpen() == true) {
+			file->seek(0, SEEK_END);
+			int end = file->pos();
+			file->seek(0, SEEK_SET);
+			_filenums = (uint16 *)malloc((end / 6 + 1) * 2);
+			_offsets = (uint32 *)malloc((end / 6 + 1) * 4);
 
-				for (int i = 1; i <= end / 6; i++) {
-					_filenums[i] = file->readUint16BE();
-					_offsets[i] = file->readUint32BE();
-				}
-				_voice_file = true;
+			for (int i = 1; i <= end / 6; i++) {
+				_filenums[i] = file->readUint16BE();
+				_offsets[i] = file->readUint32BE();
 			}
+			_voice_file = true;
 			delete file;
 		} else if (_game & GF_WIN) {
 			s = gss->wav_filename;
@@ -421,7 +417,7 @@
 }
 
 void Sound::playVoice(uint sound) {
-	if (_game == GAME_SIMON2MAC && _filenums) {
+	if (_filenums) {
 		if (_last_voice_file != _filenums[sound]) {
 			stopAll();
 





More information about the Scummvm-git-logs mailing list