aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/glk/advsys/advsys.cpp27
-rw-r--r--engines/glk/advsys/advsys.h15
-rw-r--r--engines/glk/advsys/detection.cpp17
-rw-r--r--engines/glk/advsys/detection_tables.h15
-rw-r--r--engines/glk/advsys/game.cpp76
-rw-r--r--engines/glk/advsys/game.h92
-rw-r--r--engines/glk/module.mk1
7 files changed, 242 insertions, 1 deletions
diff --git a/engines/glk/advsys/advsys.cpp b/engines/glk/advsys/advsys.cpp
index 47c3da1d43..0c62524db1 100644
--- a/engines/glk/advsys/advsys.cpp
+++ b/engines/glk/advsys/advsys.cpp
@@ -21,12 +21,37 @@
*/
#include "glk/advsys/advsys.h"
+#include "common/translation.h"
namespace Glk {
namespace AdvSys {
void AdvSys::runGame() {
- // TODO
+ if (!initialize()) {
+ GUIErrorMessage(_("Could not start AdvSys game"));
+ return;
+ }
+
+ // TODO: play game
+ print("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n");
+
+
+ deinitialize();
+}
+
+bool AdvSys::initialize() {
+ _window = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
+ if (_window)
+ return false;
+
+ return true;
+}
+
+void AdvSys::deinitialize() {
+}
+
+void AdvSys::print(const char *msg) {
+ glk_put_string_stream(glk_window_get_stream(_window), msg);
}
Common::Error AdvSys::loadGameData(strid_t save) {
diff --git a/engines/glk/advsys/advsys.h b/engines/glk/advsys/advsys.h
index ceb2df3260..0aeb14ed3e 100644
--- a/engines/glk/advsys/advsys.h
+++ b/engines/glk/advsys/advsys.h
@@ -34,7 +34,22 @@ namespace AdvSys {
*/
class AdvSys : public GlkAPI {
private:
+ winid_t _window;
+private:
+ /**
+ * Engine initialization
+ */
+ bool initialize();
+
+ /**
+ * Engine cleanup
+ */
+ void deinitialize();
+ /**
+ * Print a string to the window
+ */
+ void print(const char *msg);
public:
/**
* Constructor
diff --git a/engines/glk/advsys/detection.cpp b/engines/glk/advsys/detection.cpp
index 4cedecfbc0..d3b376f0b6 100644
--- a/engines/glk/advsys/detection.cpp
+++ b/engines/glk/advsys/detection.cpp
@@ -22,6 +22,8 @@
#include "glk/advsys/detection.h"
#include "glk/advsys/detection_tables.h"
+#include "glk/advsys/game.h"
+#include "common/debug.h"
#include "common/file.h"
#include "common/md5.h"
#include "engines/game.h"
@@ -62,6 +64,12 @@ bool AdvSysMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &
Common::File gameFile;
if (!gameFile.open(*file))
continue;
+
+ Header hdr(&gameFile);
+ if (!hdr._valid)
+ continue;
+
+ gameFile.seek(0);
Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
int32 filesize = gameFile.size();
@@ -77,6 +85,15 @@ bool AdvSysMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &
gd.addExtraEntry("filename", file->getName());
gameList.push_back(gd);
+ } else {
+ if (gDebugLevel > 0) {
+ // Print an entry suitable for putting into the detection_tables.h
+ debug("ENTRY0(\"%s\", \"%s\", %u),", filename.c_str(), md5.c_str(), (uint)filesize);
+ }
+
+ const PlainGameDescriptor &desc = ADVSYS_GAME_LIST[0];
+ DetectedGame gd(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
+ gameList.push_back(gd);
}
}
diff --git a/engines/glk/advsys/detection_tables.h b/engines/glk/advsys/detection_tables.h
index de36a34062..e109f53369 100644
--- a/engines/glk/advsys/detection_tables.h
+++ b/engines/glk/advsys/detection_tables.h
@@ -37,10 +37,25 @@ struct AdvSysGame {
};
const PlainGameDescriptor ADVSYS_GAME_LIST[] = {
+ { "advsys", "AdvSys Game" },
+
+ { "bustedadvsys", "Busted!" },
+ { "starshipcolumbus", "Starship Columbus" },
+ { "elves87", "Elves '87" },
+ { "keytotime", "The Key to Time" },
+ { "onehand", "The Sound of One Hand Clapping" },
+ { "pirating", "Pirating" },
+
{ nullptr, nullptr }
};
const AdvSysGame ADVSYS_GAMES[] = {
+ { "2246a2686a07c714868680eaf980ece9", "bustedadvsys", 79091 },
+ { "120d7041dfa000c9a313a8b0ae9cef33", "starshipcolumbus", 76032 },
+ { "746963e82552f95b5e743fe24ecd1ec3", "elves87", 77947 },
+ { "892217ab8d902a732e82c55efd22931d", "keytotime", 24941 },
+ { "3a2a3cc24709ff3272f3a15d09b5e63e", "onehand", 95762 },
+ { "e55fff2ac51a8a16b979541e8d3210d8", "pirating", 29529 },
{ nullptr, nullptr, 0 }
};
diff --git a/engines/glk/advsys/game.cpp b/engines/glk/advsys/game.cpp
new file mode 100644
index 0000000000..ce1da29456
--- /dev/null
+++ b/engines/glk/advsys/game.cpp
@@ -0,0 +1,76 @@
+/* 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/advsys/game.h"
+#include "common/memstream.h"
+
+namespace Glk {
+namespace AdvSys {
+
+#define HEADER_SIZE 62
+
+void Header::load(Common::ReadStream *s) {
+ _valid = false;
+ byte data[HEADER_SIZE];
+
+ // Read in the data
+ if (s->read(data, HEADER_SIZE) != HEADER_SIZE)
+ return;
+ Compression::decompress(data, HEADER_SIZE);
+ Common::MemoryReadStream ms(data, HEADER_SIZE, DisposeAfterUse::NO);
+
+ // Validate the header
+ _valid = !strncmp((const char*)data + 2, "ADVSYS", 6);
+ if (!_valid)
+ return;
+
+ _size = ms.readUint16LE();
+ ms.skip(6);
+ _headerVersion = ms.readUint16LE();
+ _name = Common::String((const char*)data + 10, (const char*)data + 28);
+ ms.skip(18);
+ _version = ms.readUint16LE();
+ _wordTable = ms.readUint16LE();
+ _wordTypeTable = ms.readUint16LE();
+ _objectTable = ms.readUint16LE();
+ _actionTable = ms.readUint16LE();
+ _variableTable = ms.readUint16LE();
+ _dataSpace = ms.readUint16LE();
+ _codeSpace = ms.readUint16LE();
+ _dataBlock = ms.readUint16LE();
+ _messageBlock = ms.readUint16LE();
+ _initCode = ms.readUint16LE();
+ _updateCode = ms.readUint16LE();
+ _before = ms.readUint16LE();
+ _after = ms.readUint16LE();
+ _errorHandler = ms.readUint16LE();
+ _saveArea = ms.readUint16LE();
+ _saveSize = ms.readUint16LE();
+}
+
+void Compression::decompress(byte *data, size_t size) {
+ for (; --size; ++data)
+ *data = ~(*data + 30);
+}
+
+} // End of namespace AdvSys
+} // End of namespace Glk
diff --git a/engines/glk/advsys/game.h b/engines/glk/advsys/game.h
new file mode 100644
index 0000000000..9e2a6f759f
--- /dev/null
+++ b/engines/glk/advsys/game.h
@@ -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.
+ *
+ */
+
+#ifndef GLK_ADVSYS_GAME
+#define GLK_ADVSYS_GAME
+
+#include "common/stream.h"
+
+namespace Glk {
+namespace AdvSys {
+
+/**
+ * Decompressor
+ */
+struct Compression {
+ /**
+ * Decompress a data block
+ */
+ static void decompress(byte* data, size_t size);
+};
+
+/**
+ * AdvSys game header
+ */
+struct Header {
+ bool _valid; ///< Signals whether header is valid
+ size_t _size; ///< Header size in bytes
+ uint _headerVersion; ///< Header structure version
+ Common::String _name; ///< Adventure name
+ uint _version; ///< Adventure version
+ uint _wordTable; ///< Word table offset
+ uint _wordTypeTable; ///< Word type table offset
+ uint _objectTable; ///< Object table offset
+ uint _actionTable; ///< Action table offset
+ uint _variableTable; ///< Variable table offset
+ uint _dataSpace; ///< Data space offset
+ uint _codeSpace; ///< Code space offset
+ uint _dataBlock; ///< First data block offset
+ uint _messageBlock; ///< First message block offset
+ uint _initCode; ///< Initialization code offset
+ uint _updateCode; ///< Update code offset
+ uint _before; ///< Code offset before verb handler
+ uint _after; ///< Code offset after verb handler
+ uint _errorHandler; ///< Error handler code offset
+ uint _saveArea; ///< Save area offset
+ uint _saveSize; ///< Save area size
+
+ /**
+ * Constructor
+ */
+ Header() : _valid(false), _size(0), _headerVersion(0), _version(0), _wordTable(0),
+ _wordTypeTable(0), _objectTable(0), _actionTable(0), _variableTable(0),
+ _dataSpace(0), _codeSpace(0), _dataBlock(0), _messageBlock(0), _initCode(0),
+ _updateCode(0), _before(0), _after(0), _errorHandler(0), _saveArea(0), _saveSize(0) {
+ }
+
+ /**
+ * Constructor
+ */
+ Header(Common::ReadStream* s) {
+ load(s);
+ }
+
+ /**
+ * Load the header
+ */
+ void load(Common::ReadStream *s);
+};
+
+} // End of namespace AdvSys
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 3894969ae1..827b5e4d78 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -27,6 +27,7 @@ MODULE_OBJS := \
window_text_grid.o \
advsys/advsys.o \
advsys/detection.o \
+ advsys/game.o \
alan2/alan2.o \
alan2/decode.o \
alan2/detection.o \