[Scummvm-git-logs] scummvm master -> 870603d226b23b2300fecd1a100254d91156c1dc
sev-
noreply at scummvm.org
Tue Nov 29 00:14:51 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
870603d226 QUEEN: Reduce the amount of code that is included in the detection plugin
Commit: 870603d226b23b2300fecd1a100254d91156c1dc
https://github.com/scummvm/scummvm/commit/870603d226b23b2300fecd1a100254d91156c1dc
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-29T01:14:48+01:00
Commit Message:
QUEEN: Reduce the amount of code that is included in the detection plugin
Changed paths:
A engines/queen/version.cpp
A engines/queen/version.h
engines/queen/defs.h
engines/queen/detection.cpp
engines/queen/module.mk
engines/queen/resource.cpp
engines/queen/resource.h
diff --git a/engines/queen/defs.h b/engines/queen/defs.h
index 350a627ab2c..85ea4ed6774 100644
--- a/engines/queen/defs.h
+++ b/engines/queen/defs.h
@@ -26,6 +26,14 @@ namespace Queen {
#define SAVEGAME_SIZE 24622
+enum GameFeatures {
+ GF_DEMO = 1 << 0, // demo
+ GF_TALKIE = 1 << 1, // equivalent to cdrom version check
+ GF_FLOPPY = 1 << 2, // floppy, ie. non-talkie version
+ GF_INTERVIEW = 1 << 3, // interview demo
+ GF_REBUILT = 1 << 4 // version rebuilt with the 'compression_queen' tool
+};
+
enum {
COMPRESSION_NONE = 0,
COMPRESSION_MP3 = 1,
@@ -33,6 +41,28 @@ enum {
COMPRESSION_FLAC = 3
};
+enum Version {
+ VER_ENG_FLOPPY = 0,
+ VER_ENG_TALKIE = 1,
+ VER_FRE_FLOPPY = 2,
+ VER_FRE_TALKIE = 3,
+ VER_GER_FLOPPY = 4,
+ VER_GER_TALKIE = 5,
+ VER_ITA_FLOPPY = 6,
+ VER_ITA_TALKIE = 7,
+ VER_SPA_TALKIE = 8,
+ VER_HEB_TALKIE = 9,
+ VER_DEMO_PCGAMES = 10,
+ VER_DEMO = 11,
+ VER_INTERVIEW = 12,
+ VER_AMI_ENG_FLOPPY = 13,
+ VER_AMI_DEMO = 14,
+ VER_AMI_INTERVIEW = 15,
+ VER_AMI_GER_FLOPPY = 16,
+
+ VER_COUNT = 17
+};
+
enum {
GAME_SCREEN_WIDTH = 320,
GAME_SCREEN_HEIGHT = 200,
diff --git a/engines/queen/detection.cpp b/engines/queen/detection.cpp
index 396e8394f19..9fe30dd5765 100644
--- a/engines/queen/detection.cpp
+++ b/engines/queen/detection.cpp
@@ -26,8 +26,9 @@
#include "common/gui_options.h"
#include "common/file.h"
+#include "queen/defs.h"
#include "queen/detection.h"
-#include "queen/resource.h"
+#include "queen/version.h"
static const PlainGameDescriptor queenGames[] = {
{"queen", "Flight of the Amazon Queen"},
@@ -495,7 +496,7 @@ ADDetectedGame QueenMetaEngineDetection::fallbackDetect(const FileMap &allFiles,
continue;
}
Queen::DetectedGameVersion version;
- if (Queen::Resource::detectVersion(&version, &dataFile)) {
+ if (Queen::detectVersion(&version, &dataFile)) {
desc.gameId = "queen";
desc.language = version.language;
desc.platform = version.platform;
diff --git a/engines/queen/module.mk b/engines/queen/module.mk
index 5eb011c7773..de6ea49a4fc 100644
--- a/engines/queen/module.mk
+++ b/engines/queen/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
sound.o \
state.o \
talk.o \
+ version.o \
walk.o
# This module can be built as a plugin
@@ -39,6 +40,5 @@ DETECT_OBJS += $(MODULE)/detection.o
# module is enabled, because it already has the contents.
ifneq ($(ENABLE_QUEEN), STATIC_PLUGIN)
# External dependencies for detection.
-DETECT_OBJS += $(MODULE)/resource.o
-DETECT_OBJS += $(MODULE)/restables.o
+DETECT_OBJS += $(MODULE)/version.o
endif
diff --git a/engines/queen/resource.cpp b/engines/queen/resource.cpp
index 54bbf31baf2..c159d63b98b 100644
--- a/engines/queen/resource.cpp
+++ b/engines/queen/resource.cpp
@@ -31,26 +31,6 @@ namespace Queen {
const char *const Resource::_tableFilename = "queen.tbl";
-const RetailGameVersion Resource::_gameVersions[] = {
- { "PEM10", 1, 0x00000008, 22677657 },
- { "CEM10", 1, 0x0000584E, 190787021 },
- { "PFM10", 1, 0x0002CD93, 22157304 },
- { "CFM10", 1, 0x00032585, 186689095 },
- { "PGM10", 1, 0x00059ACA, 22240013 },
- { "CGM10", 1, 0x0005F2A7, 217648975 },
- { "PIM10", 1, 0x000866B1, 22461366 },
- { "CIM10", 1, 0x0008BEE2, 190795582 },
- { "CSM10", 1, 0x000B343C, 190730602 },
- { "CHM10", 1, 0x000DA981, 190705558 },
- { "PE100", 1, 0x00101EC6, 3724538 },
- { "PE100", 1, 0x00102B7F, 3732177 },
- { "PEint", 1, 0x00103838, 1915913 },
- { "aEM10", 2, 0x00103F1E, 351775 },
- { "CE101", 2, 0x00107D8D, 563335 },
- { "PE100", 2, 0x001086D4, 597032 },
- { "aGM10", 3, 0x00108C6A, 344575 }
-};
-
static int compareResourceEntry(const void *a, const void *b) {
const char *filename = (const char *)a;
const ResourceEntry *entry = (const ResourceEntry *)b;
@@ -127,105 +107,6 @@ void Resource::loadTextFile(const char *filename, Common::StringArray &stringLis
}
}
-bool Resource::detectVersion(DetectedGameVersion *ver, Common::File *f) {
- memset(ver, 0, sizeof(DetectedGameVersion));
-
- if (f->readUint32BE() == MKTAG('Q','T','B','L')) {
- f->read(ver->str, 6);
- f->skip(2);
- ver->compression = f->readByte();
- ver->features = GF_REBUILT;
- ver->queenTblVersion = 0;
- ver->queenTblOffset = 0;
- } else {
- const RetailGameVersion *gameVersion = detectGameVersionFromSize(f->size());
- if (gameVersion == nullptr) {
- warning("Unknown/unsupported FOTAQ version");
- return false;
- }
- Common::strcpy_s(ver->str, gameVersion->str);
- ver->compression = COMPRESSION_NONE;
- ver->features = 0;
- ver->queenTblVersion = gameVersion->queenTblVersion;
- ver->queenTblOffset = gameVersion->queenTblOffset;
-
- // Handle game versions for which versionStr information is irrevelant
- if (gameVersion == &_gameVersions[VER_AMI_DEMO]) { // CE101
- ver->language = Common::EN_ANY;
- ver->features |= GF_FLOPPY | GF_DEMO;
- ver->platform = Common::kPlatformAmiga;
- return true;
- }
- if (gameVersion == &_gameVersions[VER_AMI_INTERVIEW]) { // PE100
- ver->language = Common::EN_ANY;
- ver->features |= GF_FLOPPY | GF_INTERVIEW;
- ver->platform = Common::kPlatformAmiga;
- return true;
- }
- }
-
- switch (ver->str[1]) {
- case 'E':
- if (Common::parseLanguage(ConfMan.get("language")) == Common::RU_RUS) {
- ver->language = Common::RU_RUS;
- } else if (Common::parseLanguage(ConfMan.get("language")) == Common::EL_GRC) {
- ver->language = Common::EL_GRC;
- } else {
- ver->language = Common::EN_ANY;
- }
- break;
- case 'F':
- ver->language = Common::FR_FRA;
- break;
- case 'G':
- ver->language = Common::DE_DEU;
- break;
- case 'H':
- ver->language = Common::HE_ISR;
- break;
- case 'I':
- ver->language = Common::IT_ITA;
- break;
- case 'S':
- ver->language = Common::ES_ESP;
- break;
- case 'g':
- ver->language = Common::EL_GRC;
- break;
- case 'R':
- ver->language = Common::RU_RUS;
- break;
- default:
- error("Invalid language id '%c'", ver->str[1]);
- break;
- }
-
- switch (ver->str[0]) {
- case 'P':
- ver->features |= GF_FLOPPY;
- ver->platform = Common::kPlatformDOS;
- break;
- case 'C':
- ver->features |= GF_TALKIE;
- ver->platform = Common::kPlatformDOS;
- break;
- case 'a':
- ver->features |= GF_FLOPPY;
- ver->platform = Common::kPlatformAmiga;
- break;
- default:
- error("Invalid platform id '%c'", ver->str[0]);
- break;
- }
-
- if (strcmp(ver->str + 2, "100") == 0 || strcmp(ver->str + 2, "101") == 0) {
- ver->features |= GF_DEMO;
- } else if (strcmp(ver->str + 2, "int") == 0) {
- ver->features |= GF_INTERVIEW;
- }
- return true;
-}
-
void Resource::checkJASVersion() {
if (_version.platform == Common::kPlatformAmiga) {
// don't bother verifying the JAS version string with these versions,
@@ -276,7 +157,7 @@ void Resource::readTableFile(uint8 version, uint32 offset) {
readTableEntries(&tableFile);
} else {
// check if it is the english floppy version, for which we have a hardcoded version of the table
- if (strcmp(_version.str, _gameVersions[VER_ENG_FLOPPY].str) == 0) {
+ if (strcmp(_version.str, "PEM10") == 0) {
_resourceEntries = 1076;
_resourceTable = _resourceTablePEM10;
} else {
@@ -298,15 +179,6 @@ void Resource::readTableEntries(Common::File *file) {
}
}
-const RetailGameVersion *Resource::detectGameVersionFromSize(uint32 size) {
- for (int i = 0; i < VER_COUNT; ++i) {
- if (_gameVersions[i].dataFileSize == size) {
- return &_gameVersions[i];
- }
- }
- return nullptr;
-}
-
Common::File *Resource::findSound(const char *filename, uint32 *size) {
assert(strstr(filename, ".SB") != nullptr || strstr(filename, ".AMR") != nullptr || strstr(filename, ".INS") != nullptr);
ResourceEntry *re = resourceEntry(filename);
diff --git a/engines/queen/resource.h b/engines/queen/resource.h
index cec2040d6a3..7281d5018a8 100644
--- a/engines/queen/resource.h
+++ b/engines/queen/resource.h
@@ -27,34 +27,10 @@
#include "common/language.h"
#include "common/platform.h"
#include "queen/defs.h"
+#include "queen/version.h"
namespace Queen {
-enum GameFeatures {
- GF_DEMO = 1 << 0, // demo
- GF_TALKIE = 1 << 1, // equivalent to cdrom version check
- GF_FLOPPY = 1 << 2, // floppy, ie. non-talkie version
- GF_INTERVIEW = 1 << 3, // interview demo
- GF_REBUILT = 1 << 4 // version rebuilt with the 'compression_queen' tool
-};
-
-struct RetailGameVersion {
- char str[6];
- uint8 queenTblVersion;
- uint32 queenTblOffset;
- uint32 dataFileSize;
-};
-
-struct DetectedGameVersion {
- Common::Platform platform;
- Common::Language language;
- uint8 features;
- uint8 compression;
- char str[6];
- uint8 queenTblVersion;
- uint32 queenTblOffset;
-};
-
struct ResourceEntry {
char filename[13];
uint8 bundle;
@@ -96,31 +72,6 @@ public:
Common::Platform getPlatform() const { return _version.platform; }
- //! detect game version
- static bool detectVersion(DetectedGameVersion *ver, Common::File *f);
-
- enum Version {
- VER_ENG_FLOPPY = 0,
- VER_ENG_TALKIE = 1,
- VER_FRE_FLOPPY = 2,
- VER_FRE_TALKIE = 3,
- VER_GER_FLOPPY = 4,
- VER_GER_TALKIE = 5,
- VER_ITA_FLOPPY = 6,
- VER_ITA_TALKIE = 7,
- VER_SPA_TALKIE = 8,
- VER_HEB_TALKIE = 9,
- VER_DEMO_PCGAMES = 10,
- VER_DEMO = 11,
- VER_INTERVIEW = 12,
- VER_AMI_ENG_FLOPPY = 13,
- VER_AMI_DEMO = 14,
- VER_AMI_INTERVIEW = 15,
- VER_AMI_GER_FLOPPY = 16,
-
- VER_COUNT = 17
- };
-
enum {
JAS_VERSION_OFFSET_DEMO = 0x119A8,
JAS_VERSION_OFFSET_INTV = 0xCF8,
@@ -155,15 +106,9 @@ protected:
//! read the resource table from the specified file
void readTableEntries(Common::File *file);
- //! detect game version based on queen.1 datafile size
- static const RetailGameVersion *detectGameVersionFromSize(uint32 size);
-
//! resource table filename (queen.tbl)
static const char *const _tableFilename;
- //! known FOTAQ versions
- static const RetailGameVersion _gameVersions[];
-
//! resource table for english floppy version
static ResourceEntry _resourceTablePEM10[];
};
diff --git a/engines/queen/version.cpp b/engines/queen/version.cpp
new file mode 100644
index 00000000000..03f7ccf578f
--- /dev/null
+++ b/engines/queen/version.cpp
@@ -0,0 +1,159 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "queen/version.h"
+#include "queen/defs.h"
+
+#include "common/config-manager.h"
+#include "common/file.h"
+
+namespace Queen {
+
+//! known FOTAQ versions
+static const RetailGameVersion gameVersions[] = {
+ { "PEM10", 1, 0x00000008, 22677657 },
+ { "CEM10", 1, 0x0000584E, 190787021 },
+ { "PFM10", 1, 0x0002CD93, 22157304 },
+ { "CFM10", 1, 0x00032585, 186689095 },
+ { "PGM10", 1, 0x00059ACA, 22240013 },
+ { "CGM10", 1, 0x0005F2A7, 217648975 },
+ { "PIM10", 1, 0x000866B1, 22461366 },
+ { "CIM10", 1, 0x0008BEE2, 190795582 },
+ { "CSM10", 1, 0x000B343C, 190730602 },
+ { "CHM10", 1, 0x000DA981, 190705558 },
+ { "PE100", 1, 0x00101EC6, 3724538 },
+ { "PE100", 1, 0x00102B7F, 3732177 },
+ { "PEint", 1, 0x00103838, 1915913 },
+ { "aEM10", 2, 0x00103F1E, 351775 },
+ { "CE101", 2, 0x00107D8D, 563335 },
+ { "PE100", 2, 0x001086D4, 597032 },
+ { "aGM10", 3, 0x00108C6A, 344575 }
+};
+
+bool detectVersion(DetectedGameVersion *ver, Common::File *f) {
+ memset(ver, 0, sizeof(DetectedGameVersion));
+
+ if (f->readUint32BE() == MKTAG('Q','T','B','L')) {
+ f->read(ver->str, 6);
+ f->skip(2);
+ ver->compression = f->readByte();
+ ver->features = GF_REBUILT;
+ ver->queenTblVersion = 0;
+ ver->queenTblOffset = 0;
+ } else {
+ const RetailGameVersion *gameVersion = detectGameVersionFromSize(f->size());
+ if (gameVersion == nullptr) {
+ warning("Unknown/unsupported FOTAQ version");
+ return false;
+ }
+ Common::strcpy_s(ver->str, gameVersion->str);
+ ver->compression = COMPRESSION_NONE;
+ ver->features = 0;
+ ver->queenTblVersion = gameVersion->queenTblVersion;
+ ver->queenTblOffset = gameVersion->queenTblOffset;
+
+ // Handle game versions for which versionStr information is irrevelant
+ if (gameVersion == &gameVersions[VER_AMI_DEMO]) { // CE101
+ ver->language = Common::EN_ANY;
+ ver->features |= GF_FLOPPY | GF_DEMO;
+ ver->platform = Common::kPlatformAmiga;
+ return true;
+ }
+ if (gameVersion == &gameVersions[VER_AMI_INTERVIEW]) { // PE100
+ ver->language = Common::EN_ANY;
+ ver->features |= GF_FLOPPY | GF_INTERVIEW;
+ ver->platform = Common::kPlatformAmiga;
+ return true;
+ }
+ }
+
+ switch (ver->str[1]) {
+ case 'E':
+ if (Common::parseLanguage(ConfMan.get("language")) == Common::RU_RUS) {
+ ver->language = Common::RU_RUS;
+ } else if (Common::parseLanguage(ConfMan.get("language")) == Common::EL_GRC) {
+ ver->language = Common::EL_GRC;
+ } else {
+ ver->language = Common::EN_ANY;
+ }
+ break;
+ case 'F':
+ ver->language = Common::FR_FRA;
+ break;
+ case 'G':
+ ver->language = Common::DE_DEU;
+ break;
+ case 'H':
+ ver->language = Common::HE_ISR;
+ break;
+ case 'I':
+ ver->language = Common::IT_ITA;
+ break;
+ case 'S':
+ ver->language = Common::ES_ESP;
+ break;
+ case 'g':
+ ver->language = Common::EL_GRC;
+ break;
+ case 'R':
+ ver->language = Common::RU_RUS;
+ break;
+ default:
+ error("Invalid language id '%c'", ver->str[1]);
+ break;
+ }
+
+ switch (ver->str[0]) {
+ case 'P':
+ ver->features |= GF_FLOPPY;
+ ver->platform = Common::kPlatformDOS;
+ break;
+ case 'C':
+ ver->features |= GF_TALKIE;
+ ver->platform = Common::kPlatformDOS;
+ break;
+ case 'a':
+ ver->features |= GF_FLOPPY;
+ ver->platform = Common::kPlatformAmiga;
+ break;
+ default:
+ error("Invalid platform id '%c'", ver->str[0]);
+ break;
+ }
+
+ if (strcmp(ver->str + 2, "100") == 0 || strcmp(ver->str + 2, "101") == 0) {
+ ver->features |= GF_DEMO;
+ } else if (strcmp(ver->str + 2, "int") == 0) {
+ ver->features |= GF_INTERVIEW;
+ }
+ return true;
+}
+
+const RetailGameVersion *detectGameVersionFromSize(uint32 size) {
+ for (int i = 0; i < VER_COUNT; ++i) {
+ if (gameVersions[i].dataFileSize == size) {
+ return &gameVersions[i];
+ }
+ }
+ return nullptr;
+}
+
+} // End of namespace Queen
diff --git a/engines/queen/version.h b/engines/queen/version.h
new file mode 100644
index 00000000000..815e9f16af1
--- /dev/null
+++ b/engines/queen/version.h
@@ -0,0 +1,59 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef QUEEN_VERSION_H
+#define QUEEN_VERSION_H
+
+#include "common/language.h"
+#include "common/platform.h"
+
+namespace Common {
+class File;
+}
+
+namespace Queen {
+
+struct DetectedGameVersion {
+ Common::Platform platform;
+ Common::Language language;
+ uint8 features;
+ uint8 compression;
+ char str[6];
+ uint8 queenTblVersion;
+ uint32 queenTblOffset;
+};
+
+struct RetailGameVersion {
+ char str[6];
+ uint8 queenTblVersion;
+ uint32 queenTblOffset;
+ uint32 dataFileSize;
+};
+
+//! detect game version
+bool detectVersion(DetectedGameVersion *ver, Common::File *f);
+
+//! detect game version based on queen.1 datafile size
+const RetailGameVersion *detectGameVersionFromSize(uint32 size);
+
+} // End of namespace Queen
+
+#endif
More information about the Scummvm-git-logs
mailing list