aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-08-25 23:36:20 +0000
committerFilippos Karapetis2009-08-25 23:36:20 +0000
commitc3db0d3f2a8aaaca2b86bd8fe20cd216fc308bcf (patch)
tree7da908d74516335c95053a72b9dab786188dc407
parentf7acc7f669537210b513559474799e52a04bd528 (diff)
downloadscummvm-rg350-c3db0d3f2a8aaaca2b86bd8fe20cd216fc308bcf.tar.gz
scummvm-rg350-c3db0d3f2a8aaaca2b86bd8fe20cd216fc308bcf.tar.bz2
scummvm-rg350-c3db0d3f2a8aaaca2b86bd8fe20cd216fc308bcf.zip
- 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 svn-id: r43746
-rw-r--r--engines/sci/detection.cpp56
-rw-r--r--engines/sci/exereader.cpp119
-rw-r--r--engines/sci/exereader.h38
-rw-r--r--engines/sci/module.mk1
4 files changed, 23 insertions, 191 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 95870e8f77..8e665fb622 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -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 @@ Common::String convertSierraGameId(Common::String sierraId) {
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 @@ Common::String convertSierraGameId(Common::String sierraId) {
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 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
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,25 +351,29 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
s_fallbackDesc.desc.extra = "EGA";
SegManager *segManager = new SegManager(resourceManager);
-
- 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
+ Common::Platform gamePlatform = 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
+ 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)) {
diff --git a/engines/sci/exereader.cpp b/engines/sci/exereader.cpp
deleted file mode 100644
index fbeda66b45..0000000000
--- a/engines/sci/exereader.cpp
+++ /dev/null
@@ -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
diff --git a/engines/sci/exereader.h b/engines/sci/exereader.h
deleted file mode 100644
index e114c0a3a4..0000000000
--- a/engines/sci/exereader.h
+++ /dev/null
@@ -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
diff --git a/engines/sci/module.mk b/engines/sci/module.mk
index 54e7ed3589..a49108ba37 100644
--- a/engines/sci/module.mk
+++ b/engines/sci/module.mk
@@ -4,7 +4,6 @@ MODULE_OBJS = \
console.o \
decompressor.o \
detection.o \
- exereader.o \
resource.o \
sci.o \
tools.o \