QDENGINE: Added engine skeleton

This commit is contained in:
Eugene Sandulenko 2022-10-23 22:29:26 +02:00
parent 7526b625da
commit 0f5c8a55f7
12 changed files with 558 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine qdengine "QD Engine" no "" "" ""

View File

@ -0,0 +1,38 @@
/* 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 "qdengine/console.h"
namespace QDEngine {
Console::Console() : GUI::Debugger() {
registerCmd("test", WRAP_METHOD(Console, Cmd_test));
}
Console::~Console() {
}
bool Console::Cmd_test(int argc, const char **argv) {
debugPrintf("Test\n");
return true;
}
} // namespace Qdengine

View File

@ -0,0 +1,40 @@
/* 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 QDENGINE_CONSOLE_H
#define QDENGINE_CONSOLE_H
#include "gui/debugger.h"
namespace QDEngine {
class Console : public GUI::Debugger {
private:
bool Cmd_test(int argc, const char **argv);
public:
Console();
~Console() override;
};
} // End of namespace QDEngine
#endif

View File

@ -0,0 +1,3 @@
begin_section("QDEngine");
add_person("Name 1", "Handle 1", "");
end_section();

View File

@ -0,0 +1,44 @@
/* 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 "base/plugins.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/md5.h"
#include "common/str-array.h"
#include "common/translation.h"
#include "common/util.h"
#include "qdengine/detection.h"
#include "qdengine/detection_tables.h"
const DebugChannelDef QDEngineMetaEngineDetection::debugFlagList[] = {
{ QDEngine::kDebugGraphics, "Graphics", "Graphics debug level" },
{ QDEngine::kDebugPath, "Path", "Pathfinding debug level" },
{ QDEngine::kDebugFilePath, "FilePath", "File path debug level" },
{ QDEngine::kDebugScan, "Scan", "Scan for unrecognised games" },
{ QDEngine::kDebugScript, "Script", "Enable debug script dump" },
DEBUG_CHANNEL_END
};
QDEngineMetaEngineDetection::QDEngineMetaEngineDetection() : AdvancedMetaEngineDetection(QDEngine::GAME_DESCRIPTIONS, QDEngine::GAME_NAMES) {
}
REGISTER_PLUGIN_STATIC(QDENGINE_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, QDEngineMetaEngineDetection);

View File

@ -0,0 +1,67 @@
/* 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 QDENGINE_DETECTION_H
#define QDENGINE_DETECTION_H
#include "engines/advancedDetector.h"
namespace QDEngine {
enum QDEngineDebugChannels {
kDebugGraphics = 1 << 0,
kDebugPath = 1 << 1,
kDebugScan = 1 << 2,
kDebugFilePath = 1 << 3,
kDebugScript = 1 << 4
};
extern const PlainGameDescriptor GAME_NAMES[];
extern const ADGameDescription GAME_DESCRIPTIONS[];
} // namespace QDEngine
class QDEngineMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
static const DebugChannelDef debugFlagList[];
public:
QDEngineMetaEngineDetection();
~QDEngineMetaEngineDetection() override {}
const char *getName() const override {
return "qdengine";
}
const char *getEngineName() const override {
return "QD Engine";
}
const char *getOriginalCopyright() const override {
return "QD Engine (C) 2003-7 K-D LAB";
}
const DebugChannelDef *getDebugChannels() const override {
return debugFlagList;
}
};
#endif

View File

@ -0,0 +1,43 @@
/* 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/>.
*
*/
namespace QDEngine {
const PlainGameDescriptor GAME_NAMES[] = {
{ "qdengine", "QDEngine game" },
{ 0, 0 }
};
const ADGameDescription GAME_DESCRIPTIONS[] = {
{
"qdengine",
nullptr,
AD_ENTRY1s("file1.bin", "00000000000000000000000000000000", 11111),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
AD_TABLE_END_MARKER
};
} // namespace Qdengine

View File

@ -0,0 +1,50 @@
/* 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 "qdengine/metaengine.h"
#include "qdengine/detection.h"
#include "qdengine/qdengine.h"
const char *QDEngineMetaEngine::getName() const {
return "qdengine";
}
Common::Error QDEngineMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
*engine = new QDEngine::QDEngineEngine(syst, desc);
return Common::kNoError;
}
bool QDEngineMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSavesUseExtendedFormat) ||
(f == kSimpleSavesNames) ||
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSupportsLoadingDuringStartup);
}
#if PLUGIN_ENABLED_DYNAMIC(QDENGINE)
REGISTER_PLUGIN_DYNAMIC(QDENGINE, PLUGIN_TYPE_ENGINE, QDEngineMetaEngine);
#else
REGISTER_PLUGIN_STATIC(QDENGINE, PLUGIN_TYPE_ENGINE, QDEngineMetaEngine);
#endif

View File

@ -0,0 +1,41 @@
/* 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 QDENGINE_METAENGINE_H
#define QDENGINE_METAENGINE_H
#include "engines/advancedDetector.h"
class QDEngineMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
public:
const char *getName() const override;
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
/**
* Determine whether the engine supports the specified MetaEngine feature.
*
* Used by e.g. the launcher to determine whether to enable the Load button.
*/
bool hasFeature(MetaEngineFeature f) const override;
};
#endif

View File

@ -0,0 +1,17 @@
MODULE := engines/qdengine
MODULE_OBJS = \
qdengine.o \
console.o \
metaengine.o
# This module can be built as a plugin
ifeq ($(ENABLE_QDENGINE), DYNAMIC_PLUGIN)
PLUGIN := 1
endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection.o

View File

@ -0,0 +1,107 @@
/* 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 "qdengine/qdengine.h"
#include "qdengine/detection.h"
#include "qdengine/console.h"
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
#include "common/system.h"
#include "engines/util.h"
#include "graphics/paletteman.h"
namespace QDEngine {
QDEngineEngine *g_engine;
QDEngineEngine::QDEngineEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
_gameDescription(gameDesc), _randomSource("QDEngine") {
g_engine = this;
}
QDEngineEngine::~QDEngineEngine() {
delete _screen;
}
uint32 QDEngineEngine::getFeatures() const {
return _gameDescription->flags;
}
Common::String QDEngineEngine::getGameId() const {
return _gameDescription->gameId;
}
Common::Error QDEngineEngine::run() {
// Initialize 320x200 paletted graphics mode
initGraphics(320, 200);
_screen = new Graphics::Screen();
// Set the engine's debugger console
setDebugger(new Console());
// If a savegame was selected from the launcher, load it
int saveSlot = ConfMan.getInt("save_slot");
if (saveSlot != -1)
(void)loadGameState(saveSlot);
// Draw a series of boxes on screen as a sample
for (int i = 0; i < 100; ++i)
_screen->frameRect(Common::Rect(i, i, 320 - i, 200 - i), i);
_screen->update();
// Simple event handling loop
byte pal[256 * 3] = { 0 };
Common::Event e;
int offset = 0;
while (!shouldQuit()) {
while (g_system->getEventManager()->pollEvent(e)) {
}
// Cycle through a simple palette
++offset;
for (int i = 0; i < 256; ++i)
pal[i * 3 + 1] = (i + offset) % 256;
g_system->getPaletteManager()->setPalette(pal, 0, 256);
_screen->update();
// Delay for a bit. All events loops should have a delay
// to prevent the system being unduly loaded
g_system->delayMillis(10);
}
return Common::kNoError;
}
Common::Error QDEngineEngine::syncGame(Common::Serializer &s) {
// The Serializer has methods isLoading() and isSaving()
// if you need to specific steps; for example setting
// an array size after reading it's length, whereas
// for saving it would write the existing array's length
int dummy = 0;
s.syncAsUint32LE(dummy);
return Common::kNoError;
}
} // namespace QDEngine

105
engines/qdengine/qdengine.h Normal file
View File

@ -0,0 +1,105 @@
/* 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 QDENGINE_QDENGINE_H
#define QDENGINE_QDENGINE_H
#include "common/scummsys.h"
#include "common/system.h"
#include "common/error.h"
#include "common/fs.h"
#include "common/hash-str.h"
#include "common/random.h"
#include "common/serializer.h"
#include "common/util.h"
#include "engines/engine.h"
#include "engines/savestate.h"
#include "graphics/screen.h"
#include "qdengine/detection.h"
namespace QDEngine {
struct QDEngineGameDescription;
class QDEngineEngine : public Engine {
private:
const ADGameDescription *_gameDescription;
Common::RandomSource _randomSource;
protected:
// Engine APIs
Common::Error run() override;
public:
Graphics::Screen *_screen = nullptr;
public:
QDEngineEngine(OSystem *syst, const ADGameDescription *gameDesc);
~QDEngineEngine() override;
uint32 getFeatures() const;
/**
* Returns the game Id
*/
Common::String getGameId() const;
/**
* Gets a random number
*/
uint32 getRandomNumber(uint maxNum) {
return _randomSource.getRandomNumber(maxNum);
}
bool hasFeature(EngineFeature f) const override {
return
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime) ||
(f == kSupportsReturnToLauncher);
};
bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
return true;
}
bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
return true;
}
/**
* Uses a serializer to allow implementing savegame
* loading and saving using a single method
*/
Common::Error syncGame(Common::Serializer &s);
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
Common::Serializer s(nullptr, stream);
return syncGame(s);
}
Common::Error loadGameStream(Common::SeekableReadStream *stream) override {
Common::Serializer s(stream, nullptr);
return syncGame(s);
}
};
extern QDEngineEngine *g_engine;
#define SHOULD_QUIT ::QDEngine::g_engine->shouldQuit()
} // namespace QDEngine
#endif