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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Aug 26 01:36:20 CEST 2009


Revision: 43746
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43746&view=rev
Author:   thebluegr
Date:     2009-08-25 23:36:20 +0000 (Tue, 25 Aug 2009)

Log Message:
-----------
- Finished automatic detection of the game platform in the fallback detector
- Added detection for GK1 to the fallback detector
- Removed the rest of the executable reading code, as it's no longer used

Modified Paths:
--------------
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sci/exereader.cpp
    scummvm/trunk/engines/sci/exereader.h

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-08-25 23:24:35 UTC (rev 43745)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-08-25 23:36:20 UTC (rev 43746)
@@ -28,7 +28,6 @@
 
 #include "sci/sci.h"
 #include "sci/engine/kernel.h"
-#include "sci/exereader.h"
 #include "sci/engine/seg_manager.h"
 
 namespace Sci {
@@ -194,6 +193,8 @@
 		return "funseeker";
 	if (sierraId == "cardgames")
 		return "hoyle1";
+	if (sierraId == "gk")
+		return "gk1";
 	if (sierraId == "solitare")
 		return "hoyle2";
 	// hoyle3 is the same
@@ -259,7 +260,6 @@
 const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
 	bool foundResMap = false;
 	bool foundRes000 = false;
-	Common::Platform exePlatform = Common::kPlatformUnknown;
 
 	// Set some defaults
 	s_fallbackDesc.desc.extra = "";
@@ -318,20 +318,6 @@
 		if (filename.contains("resource.000") || filename.contains("resource.001")
 			|| filename.contains("ressci.000") || filename.contains("ressci.001"))
 			foundRes000 = true;
-
-		// Check if it's a known executable name
-		// Note: "sier" matches "sier.exe", "sierra.exe", "sierw.exe" and "sierw5.exe"
-		// TODO: Try to remove this code, and base platform detection on game resources
-		// instead of the executable itself
-		if (filename.contains("scidhuv") || filename.contains("sciduv") ||
-			filename.contains("sciv") || filename.contains("sciw") ||
-			filename.contains("prog") || filename.contains("sier")) {
-
-			// Is it really an executable file?
-			Common::SeekableReadStream *fileStream = file->createReadStream();
-			exePlatform = getGameExePlatform(fileStream);
-			delete fileStream;
-		}
 	}
 
 	// If these files aren't found, it can't be SCI
@@ -365,26 +351,30 @@
 		s_fallbackDesc.desc.extra = "EGA";
 
 	SegManager *segManager = new SegManager(resourceManager);
+	Common::Platform gamePlatform = Common::kPlatformUnknown;
 
-	if (exePlatform == Common::kPlatformUnknown) {
-		// Try to determine the platform from game resources
-		if (gameViews == kViewEga || gameViews == kViewVga ||
-			gameViews == kViewVga11) {
-			// Must be PC or Mac, set to PC for now
-			// TODO: Is there a reliable way to determine the game
-			// platform from the resources? So far, I've noticed
-			// that Mac versions have a different signature for
-			// kGetEvent and kNewWindow. I'm unsure about Atari ST
-			// versions. Could we base detection on this?
-			exePlatform = Common::kPlatformPC;
-		} else if (gameViews == kViewAmiga) {
-			exePlatform = Common::kPlatformAmiga;
-		}
-		// TODO: detection for Mac and Atari ST
+	// Try to determine the platform from game resources
+	if (gameViews == kViewEga || gameViews == kViewVga ||
+		gameViews == kViewVga11) {
+		// Must be PC or Mac, set to PC for now
+		gamePlatform = Common::kPlatformPC;
+	} else if (gameViews == kViewAmiga) {
+		gamePlatform = Common::kPlatformAmiga;
 	}
 
-	s_fallbackDesc.desc.platform = exePlatform;
+	// The existence of any of these files indicates an Amiga game
+	if (Common::File::exists("9.pat") || Common::File::exists("spal") ||
+		Common::File::exists("patch.005") || Common::File::exists("bank.001"))
+		gamePlatform = Common::kPlatformAmiga;
 
+	// The existence of 7.pat indicates a Mac game
+	if (Common::File::exists("7.pat"))
+		gamePlatform = Common::kPlatformMacintosh;
+	
+	// The data files for Atari ST versions are the same as their DOS counterparts
+
+	s_fallbackDesc.desc.platform = gamePlatform;
+
 	// Determine the game id
 	if (!script_instantiate(resourceManager, segManager, 0)) {
 		warning("fallbackDetect(): Could not instantiate script 0");

Deleted: scummvm/trunk/engines/sci/exereader.cpp
===================================================================
--- scummvm/trunk/engines/sci/exereader.cpp	2009-08-25 23:24:35 UTC (rev 43745)
+++ scummvm/trunk/engines/sci/exereader.cpp	2009-08-25 23:36:20 UTC (rev 43746)
@@ -1,119 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/endian.h"
-
-#include "sci/sci.h"
-#include "sci/exereader.h"
-
-namespace Sci {
-
-int _bitCount;
-uint16 _bits;
-
-Common::Platform getGameExePlatform(Common::SeekableReadStream *exeStream) {
-	byte magic[4];
-	// Make sure that the executable is at least 4KB big
-	if (exeStream->size() < 4096)
-		return Common::kPlatformUnknown;
-
-	// Read exe header
-	exeStream->read(magic, 4);
-
-	// Check if the header contains known magic bytes
-
-	// Information obtained from http://magicdb.org/magic.db
-	// Check if it's a DOS executable
-	if (magic[0] == 'M' && magic[1] == 'Z') {
-		return Common::kPlatformPC;
-	}
-
-	// Check if it's an Amiga executable
-	if ((magic[2] == 0x03 && magic[3] == 0xF3) ||
-		(magic[0] == 0x7F && magic[1] == 'E' && magic[2] == 'L' && magic[3] == 'F')) {
-		return Common::kPlatformAmiga;
-	}
-
-	// Check if it's an Atari executable
-	if ((magic[0] == 0x60 && magic[1] == 0x1A))
-		return Common::kPlatformAtariST;
-
-	// Check if it's a Mac exe
-
-	// Resource map offset
-	int32 offset = (int32)READ_BE_UINT32(magic);
-	offset += 28;
-	if (exeStream->size() <= offset)
-		return Common::kPlatformUnknown;
-
-	// Skip number of types in map
-	exeStream->skip(2);
-//	uint16 val = exeStream->readUint16BE() + 1;
-	exeStream->skip(2);
-
-	// Keep reading till we find the "CODE" bit
-	while (!exeStream->eos()) {
-		exeStream->skip(4);
-		if (exeStream->eos())
-			return Common::kPlatformUnknown;
-
-		exeStream->read(magic, 4);
-		if (exeStream->eos())
-			return Common::kPlatformUnknown;
-
-		if (!memcmp(magic, "CODE", 4)) {
-			return Common::kPlatformMacintosh;
-		}
-		// Skip to the next list entry
-		exeStream->skip(4);
-		if (exeStream->eos())
-			return Common::kPlatformUnknown;
-	}
-
-	// If we've reached here, the file type is unknown
-	return Common::kPlatformUnknown;
-}
-
-uint getBit(Common::SeekableReadStream *input) {
-	uint bit = _bits & 1;
-	_bitCount--;
-
-	if (_bitCount <= 0) {
-		_bits = input->readByte();
-		_bits |= input->readByte() << 8;
-
-		if (_bitCount == -1) { // special case for first bit word
-			bit = _bits & 1;
-			_bits >>= 1;
-		}
-
-		_bitCount += 16;
-	} else
-		_bits >>= 1;
-
-	return bit;
-}
-
-} // End of namespace Sci

Deleted: scummvm/trunk/engines/sci/exereader.h
===================================================================
--- scummvm/trunk/engines/sci/exereader.h	2009-08-25 23:24:35 UTC (rev 43745)
+++ scummvm/trunk/engines/sci/exereader.h	2009-08-25 23:36:20 UTC (rev 43746)
@@ -1,38 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_EXEREADER_H
-#define SCI_EXEREADER_H
-
-#include "common/stream.h"
-#include "common/util.h"
-
-namespace Sci {
-
-Common::Platform getGameExePlatform(Common::SeekableReadStream *exeStream);
-
-} // End of namespace Sci
-
-#endif // SCI_EXEREADER_H

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-08-25 23:24:35 UTC (rev 43745)
+++ scummvm/trunk/engines/sci/module.mk	2009-08-25 23:36:20 UTC (rev 43746)
@@ -4,7 +4,6 @@
 	console.o \
 	decompressor.o \
 	detection.o \
-	exereader.o \
 	resource.o \
 	sci.o \
 	tools.o \


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