MM: Set up Xeen and MM1 as their own sub-engines

This commit is contained in:
Paul Gilbert 2023-02-12 20:22:43 -08:00
parent 4e7a5ab5ee
commit 83707bfa7f
7 changed files with 67 additions and 14 deletions

View File

@ -1,3 +1,5 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine mm "Might and Magic" yes
add_engine mm "Might and Magic" no "mm1 xeen"
add_engine mm1 "Might and Magic 1" no
add_engine xeen "Might and Magic Xeen" yes

View File

@ -26,13 +26,17 @@
#include "mm/mm.h"
static const PlainGameDescriptor MIGHT_AND_MAGIC_GAMES[] = {
#ifdef ENABLE_MM1
{ "mm1", "Might and Magic: Book One - Secret of the Inner Sanctum"},
{ "mm1_enh", "Might and Magic: Book One - Secret of the Inner Sanctum - Enhanced"},
#endif
#ifdef ENABLE_XEEN
{ "cloudsofxeen", "Might and Magic IV: Clouds of Xeen" },
{ "darksideofxeen", "Might and Magic V: Darkside of Xeen" },
{ "worldofxeen", "Might and Magic: World of Xeen" },
{ "swordsofxeen", "Might and Magic: Swords of Xeen" },
{0, 0}
#endif
{ 0, 0 }
};
static const DebugChannelDef DEBUG_FLAT_LIST[] = {

View File

@ -22,6 +22,7 @@
namespace MM {
static const MightAndMagicGameDescription GAME_DESCRIPTIONS[] = {
#ifdef ENABLE_MM1
{
// Might and Magic 1
{
@ -51,7 +52,9 @@ static const MightAndMagicGameDescription GAME_DESCRIPTIONS[] = {
GType_MightAndMagic1,
GF_ENHANCED
},
#endif
#ifdef ENABLE_XEEN
{
// World of Xeen
{
@ -320,6 +323,7 @@ static const MightAndMagicGameDescription GAME_DESCRIPTIONS[] = {
GType_Swords,
0
},
#endif
{ AD_TABLE_END_MARKER, 0, 0 }
};

View File

@ -29,11 +29,15 @@
#include "common/translation.h"
#include "mm/detection.h"
#ifdef ENABLE_MM1
#include "mm/mm1/mm1.h"
#endif
#ifdef ENABLE_XEEN
#include "mm/xeen/xeen.h"
#include "mm/xeen/metaengine.h"
#include "mm/xeen/worldofxeen/worldofxeen.h"
#include "mm/xeen/swordsofxeen/swordsofxeen.h"
#endif
class MMMetaEngine : public AdvancedMetaEngine {
private:
@ -67,9 +71,12 @@ Common::Error MMMetaEngine::createInstance(OSystem *syst, Engine **engine, const
const MM::MightAndMagicGameDescription *gd = (const MM::MightAndMagicGameDescription *)desc;
switch (gd->gameID) {
#ifdef ENABLE_MM1
case MM::GType_MightAndMagic1:
*engine = new MM::MM1::MM1Engine(syst, gd);
break;
#endif
#ifdef ENABLE_XEEN
case MM::GType_Clouds:
case MM::GType_DarkSide:
case MM::GType_WorldOfXeen:
@ -78,6 +85,7 @@ Common::Error MMMetaEngine::createInstance(OSystem *syst, Engine **engine, const
case MM::GType_Swords:
*engine = new MM::Xeen::SwordsOfXeen::SwordsOfXeenEngine(syst, gd);
break;
#endif
default:
return Common::kUnsupportedGameidError;
}
@ -86,25 +94,30 @@ Common::Error MMMetaEngine::createInstance(OSystem *syst, Engine **engine, const
}
SaveStateList MMMetaEngine::listSaves(const char *target) const {
#ifdef ENABLE_XEEN
if (isXeenGame(target))
// Fallback original code for Xeen
return MM::Xeen::XeenMetaEngine::listSaves(this, target);
#endif
return AdvancedMetaEngine::listSaves(target);
}
SaveStateDescriptor MMMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
#ifdef ENABLE_XEEN
if (isXeenGame(target))
// Fallback original code for Xeen
return MM::Xeen::XeenMetaEngine::querySaveMetaInfos(this, target, slot);
#endif
return AdvancedMetaEngine::querySaveMetaInfos(target, slot);
}
Common::KeymapArray MMMetaEngine::initKeymaps(const char *target) const {
#ifdef ENABLE_MM1
const Common::String gameId = getGameId(target);
if (gameId == "mm1" || gameId == "mm1_enh")
return MM::MM1::MetaEngine::initKeymaps();
#endif
return Common::KeymapArray();
}

View File

@ -8,6 +8,13 @@ MODULE_OBJS := \
utils/strings.o \
utils/strings_data.o \
utils/xeen_font.o \
shared/xeen/cc_archive.o \
shared/xeen/file.o \
shared/xeen/sprites.o \
shared/xeen/xsurface.o
ifdef ENABLE_MM1
MODULE_OBJS += \
mm1/console.o \
mm1/events.o \
mm1/globals.o \
@ -187,7 +194,11 @@ MODULE_OBJS := \
mm1/maps/map51.o \
mm1/maps/map52.o \
mm1/maps/map53.o \
mm1/maps/map54.o \
mm1/maps/map54.o
endif
ifdef ENABLE_XEEN
MODULE_OBJS += \
xeen/worldofxeen/clouds_cutscenes.o \
xeen/worldofxeen/darkside_cutscenes.o \
xeen/worldofxeen/worldofxeen_cutscenes.o \
@ -245,11 +256,8 @@ MODULE_OBJS := \
xeen/sprites.o \
xeen/subtitles.o \
xeen/window.o \
xeen/xeen.o \
shared/xeen/cc_archive.o \
shared/xeen/file.o \
shared/xeen/sprites.o \
shared/xeen/xsurface.o
xeen/xeen.o
endif
# This module can be built as a plugin
ifeq ($(ENABLE_MM), DYNAMIC_PLUGIN)

View File

@ -20,14 +20,15 @@
*/
#include "mm/shared/xeen/file.h"
#ifdef ENABLE_XEEN
#include "mm/xeen/files.h"
#include "mm/xeen/xeen.h"
#endif
namespace MM {
namespace Shared {
namespace Xeen {
File::File(const Common::String &filename) {
File::open(filename);
}
@ -36,11 +37,14 @@ File::File(const Common::String &filename, Common::Archive &archive) {
File::open(filename, archive);
}
#ifdef ENABLE_XEEN
File::File(const Common::String &filename, int ccMode) {
File::open(filename, ccMode);
}
#endif
bool File::open(const Common::Path &filename) {
#ifdef ENABLE_XEEN
MM::Xeen::XeenEngine *engine = dynamic_cast<MM::Xeen::XeenEngine *>(g_engine);
if (engine) {
@ -57,6 +61,10 @@ bool File::open(const Common::Path &filename) {
if (!Common::File::open(filename))
error("Could not open file - %s", filename.toString().c_str());
}
#else
if (!Common::File::open(filename))
error("Could not open file - %s", filename.toString().c_str());
#endif
return true;
}
@ -67,6 +75,7 @@ bool File::open(const Common::Path &filename, Common::Archive &archive) {
return true;
}
#ifdef ENABLE_XEEN
bool File::open(const Common::String &filename, int ccMode) {
MM::Xeen::XeenEngine *engine = dynamic_cast<MM::Xeen::XeenEngine *>(g_engine);
assert(engine);
@ -112,6 +121,7 @@ void File::setCurrentArchive(int ccMode) {
assert(fm._currentArchive);
}
#endif
Common::String File::readString() {
Common::String result;
@ -124,6 +134,7 @@ Common::String File::readString() {
}
bool File::exists(const Common::String &filename) {
#ifdef ENABLE_XEEN
MM::Xeen::XeenEngine *engine = dynamic_cast<MM::Xeen::XeenEngine *>(g_engine);
if (engine) {
@ -140,8 +151,12 @@ bool File::exists(const Common::String &filename) {
} else {
return Common::File::exists(filename);
}
#else
return Common::File::exists(filename);
#endif
}
#ifdef ENABLE_XEEN
bool File::exists(const Common::String &filename, int ccMode) {
MM::Xeen::XeenEngine *engine = dynamic_cast<MM::Xeen::XeenEngine *>(g_engine);
assert(engine);
@ -154,6 +169,7 @@ bool File::exists(const Common::String &filename, int ccMode) {
return result;
}
#endif
bool File::exists(const Common::String &filename, Common::Archive &archive) {
return archive.hasFile(filename);

View File

@ -36,10 +36,12 @@ namespace Xeen {
class File : public Common::File {
private:
public:
#ifdef ENABLE_XEEN
/**
* Sets which archive is used by default
*/
static void setCurrentArchive(int ccMode);
#endif
/**
* Synchronizes a boolean array as a bitfield set
@ -49,10 +51,11 @@ public:
File() : Common::File() {
}
File(const Common::String &filename);
File(const Common::String &filename, int ccMode);
File(const Common::String &filename, Common::Archive &archive);
~File() override {
}
#ifdef ENABLE_XEEN
File(const Common::String &filename, int ccMode);
#endif
~File() override {}
/**
* Opens the given file, throwing an error if it can't be opened
@ -63,11 +66,12 @@ public:
* Opens the given file, throwing an error if it can't be opened
*/
bool open(const Common::Path &filename, Common::Archive &archive) override;
#ifdef ENABLE_XEEN
/**
* Opens the given file, throwing an error if it can't be opened
*/
virtual bool open(const Common::String &filename, int ccMode);
#endif
/**
* Opens the given file
@ -96,6 +100,7 @@ public:
*/
static bool exists(const Common::String &filename);
#ifdef ENABLE_XEEN
/**
* Checks if a given file exists
*
@ -104,6 +109,7 @@ public:
* @return true if the file exists, false otherwise
*/
static bool exists(const Common::String &filename, int ccMode);
#endif
/**
* Checks if a given file exists