GLK: COMPREHEND: Skeleton engine

This commit is contained in:
Paul Gilbert 2020-05-26 20:02:45 -07:00
parent 41e38d700d
commit 5d8838005b
10 changed files with 345 additions and 0 deletions

View File

@ -0,0 +1,51 @@
/* 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.
*
*/
#include "glk/comprehend/comprehend.h"
#include "glk/quetzal.h"
#include "common/config-manager.h"
#include "common/translation.h"
namespace Glk {
namespace Comprehend {
Comprehend::Comprehend(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
_saveSlot(-1) {
}
void Comprehend::runGame() {
initialize();
#ifdef TODO
_bottomWindow = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
if (_bottomWindow == nullptr) {
glk_exit();
return;
}
glk_set_window(_bottomWindow);
#endif
}
void Comprehend::initialize() {
}
} // End of namespace Comprehend
} // End of namespace Glk

View File

@ -0,0 +1,78 @@
/* 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.
*
*/
#ifndef GLK_COMPREHEND_COMPREHEND_H
#define GLK_COMPREHEND_COMPREHEND_H
#include "common/scummsys.h"
#include "glk/glk_api.h"
namespace Glk {
namespace Comprehend {
/**
* Scott Adams game interpreter
*/
class Comprehend : public GlkAPI {
private:
int _saveSlot; ///< Save slot when loading savegame from launcher
private:
/**
* Initialization code
*/
void initialize();
public:
/**
* Constructor
*/
Comprehend(OSystem *syst, const GlkGameDescription &gameDesc);
/**
* Returns the running interpreter type
*/
InterpreterType getInterpreterType() const override { return INTERPRETER_SCOTT; }
/**
* Execute the game
*/
void runGame() override;
/**
* Load a savegame from the passed Quetzal file chunk stream
*/
Common::Error readSaveData(Common::SeekableReadStream *rs) override {
return Common::kReadingFailed;
}
/**
* Save the game. The passed write stream represents access to the UMem chunk
* in the Quetzal save file that will be created
*/
Common::Error writeGameData(Common::WriteStream *ws) override {
return Common::kWritingFailed;
}
};
} // End of namespace Comprehend
} // End of namespace Glk
#endif

View File

@ -0,0 +1,92 @@
/* 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.
*
*/
#include "glk/comprehend/detection.h"
#include "glk/comprehend/detection_tables.h"
#include "glk/blorb.h"
#include "common/file.h"
#include "common/md5.h"
#include "engines/game.h"
namespace Glk {
namespace Comprehend {
void ComprehendMetaEngine::getSupportedGames(PlainGameList &games) {
for (const PlainGameDescriptor *pd = COMPREHEND_GAME_LIST; pd->gameId; ++pd)
games.push_back(*pd);
}
GameDescriptor ComprehendMetaEngine::findGame(const char *gameId) {
for (const PlainGameDescriptor *pd = COMPREHEND_GAME_LIST; pd->gameId; ++pd) {
if (!strcmp(gameId, pd->gameId))
return *pd;
}
return GameDescriptor::empty();
}
bool ComprehendMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
// Check for a recognised filename
if (file->isDirectory())
continue;
Common::String filename = file->getName();
bool hasExt = filename.hasSuffixIgnoreCase(".gda");
if (!hasExt)
continue;
// Get the file's MD5
Common::File gameFile;
if (!gameFile.open(*file))
continue;
Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
gameFile.close();
// Iterate through the known games
const ComprehendDetectionEntry *p = COMPREHEND_GAMES;
for (; p->_gameId; ++p) {
if (filename.equalsIgnoreCase(p->_filename)) {
// Check for an md5 match
if (p->_md5 == md5) {
// Found a match
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}
}
}
}
return !gameList.empty();
}
void ComprehendMetaEngine::detectClashes(Common::StringMap &map) {
for (const PlainGameDescriptor *pd = COMPREHEND_GAME_LIST; pd->gameId; ++pd) {
if (map.contains(pd->gameId))
error("Duplicate game Id found - %s", pd->gameId);
map[pd->gameId] = "";
}
}
} // End of namespace Comprehend
} // End of namespace Glk

View File

@ -0,0 +1,60 @@
/* 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.
*
*/
#ifndef GLK_COMPREHEND_DETECTION
#define GLK_COMPREHEND_DETECTION
#include "common/fs.h"
#include "common/hash-str.h"
#include "engines/game.h"
#include "glk/detection.h"
namespace Glk {
namespace Comprehend {
class ComprehendMetaEngine {
public:
/**
* Get a list of supported games
*/
static void getSupportedGames(PlainGameList &games);
/**
* Returns a game description for the given game Id, if it's supported
*/
static GameDescriptor findGame(const char *gameId);
/**
* Detect supported games
*/
static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
/**
* Check for game Id clashes with other sub-engines
*/
static void detectClashes(Common::StringMap &map);
};
} // End of namespace Comprehend
} // End of namespace Glk
#endif

View File

@ -0,0 +1,51 @@
/* 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.
*
*/
#include "common/gui_options.h"
#include "common/language.h"
#include "engines/game.h"
namespace Glk {
namespace Comprehend {
const PlainGameDescriptor COMPREHEND_GAME_LIST[] = {
{"crimsoncrown", "Crimson Crown"},
{"transylvania", "Transylvania"},
{nullptr, nullptr}};
struct ComprehendDetectionEntry {
const char *const _gameId;
const char *const _filename;
const char *const _md5;
};
const ComprehendDetectionEntry COMPREHEND_GAMES[] = {
// DOS games
{"crimsoncrown", "cc1.gda", "f2abf019675ac5c9bcfd81032bc7787b"},
{"transylvania", "tr.gda", "22e08633eea02ceee49b909dfd982d22"},
{nullptr, nullptr, nullptr}
};
} // End of namespace Comprehend
} // End of namespace Glk

View File

@ -35,6 +35,8 @@
#include "glk/alan3/alan3.h"
#include "glk/archetype/archetype.h"
#include "glk/archetype/detection.h"
#include "glk/comprehend/comprehend.h"
#include "glk/comprehend/detection.h"
#include "glk/frotz/detection.h"
#include "glk/frotz/frotz.h"
#include "glk/glulxe/detection.h"
@ -172,6 +174,7 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
else if ((*engine = create<Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Glulxe::GlulxeMetaEngine, Glk::Glulxe::Glulxe>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc)) != nullptr) {}
@ -222,6 +225,7 @@ PlainGameList GlkMetaEngine::getSupportedGames() const {
Glk::Alan2::Alan2MetaEngine::getSupportedGames(list);
Glk::Alan3::Alan3MetaEngine::getSupportedGames(list);
Glk::Archetype::ArchetypeMetaEngine::getSupportedGames(list);
Glk::Comprehend::ComprehendMetaEngine::getSupportedGames(list);
Glk::Frotz::FrotzMetaEngine::getSupportedGames(list);
Glk::Glulxe::GlulxeMetaEngine::getSupportedGames(list);
Glk::Hugo::HugoMetaEngine::getSupportedGames(list);
@ -246,6 +250,7 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
FIND_GAME(AGT);
FIND_GAME(Alan3);
FIND_GAME(Archetype);
FIND_GAME(Comprehend);
FIND_GAME(Frotz);
FIND_GAME(Glulxe);
FIND_GAME(Hugo);
@ -272,6 +277,7 @@ DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const {
Glk::Alan2::Alan2MetaEngine::detectGames(fslist, detectedGames);
Glk::Alan3::Alan3MetaEngine::detectGames(fslist, detectedGames);
Glk::Archetype::ArchetypeMetaEngine::detectGames(fslist, detectedGames);
Glk::Comprehend::ComprehendMetaEngine::detectGames(fslist, detectedGames);
Glk::Frotz::FrotzMetaEngine::detectGames(fslist, detectedGames);
Glk::Glulxe::GlulxeMetaEngine::detectGames(fslist, detectedGames);
Glk::Hugo::HugoMetaEngine::detectGames(fslist, detectedGames);
@ -293,6 +299,7 @@ void GlkMetaEngine::detectClashes() const {
Glk::Alan2::Alan2MetaEngine::detectClashes(map);
Glk::Alan3::Alan3MetaEngine::detectClashes(map);
Glk::Archetype::ArchetypeMetaEngine::detectClashes(map);
Glk::Comprehend::ComprehendMetaEngine::detectClashes(map);
Glk::Frotz::FrotzMetaEngine::detectClashes(map);
Glk::Glulxe::GlulxeMetaEngine::detectClashes(map);
Glk::Hugo::HugoMetaEngine::detectClashes(map);

View File

@ -129,6 +129,7 @@ struct GlkDetectionEntry {
const char *const _md5;
size_t _filesize;
Common::Language _language;
const char *const _filename;
};
#define DT_ENTRY0(ID, MD5, FILESIZE) { ID, "", MD5, FILESIZE, Common::EN_ANY }

View File

@ -43,6 +43,7 @@ enum InterpreterType {
INTERPRETER_ALAN3,
INTERPRETER_ARCHETYPE,
INTERPRETER_BOCFEL,
INTERPRETER_COMPREHEND,
INTERPRETER_FROTZ,
INTERPRETER_GEAS,
INTERPRETER_GLULXE,

View File

@ -166,6 +166,8 @@ MODULE_OBJS := \
archetype/sys_object.o \
archetype/timestamp.o \
archetype/token.o \
comprehend/comprehend.o \
comprehend/detection.o \
frotz/bitmap_font.o \
frotz/config.o \
frotz/detection.o \

View File

@ -48,6 +48,8 @@ uint32 QuetzalBase::getInterpreterTag(InterpreterType interpType) {
return MKTAG('A', 'L', 'N', '3');
case INTERPRETER_ARCHETYPE:
return MKTAG('A', 'R', 'C', 'H');
case INTERPRETER_COMPREHEND:
return MKTAG('C', 'O', 'M', 'P');
case INTERPRETER_FROTZ:
return MKTAG('Z', 'C', 'O', 'D');
case INTERPRETER_GEAS: