aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-03-15 16:52:55 -0400
committerWillem Jan Palenstijn2015-05-07 22:49:22 +0200
commit87a9ba5f2f5b9c3cde675c238ce718147417df03 (patch)
tree53d88c7f5f573b7cc0ebc474e0fda3319765cfb7
parent6d8134f7518a2c368a55cfc49ba0a625a9744645 (diff)
downloadscummvm-rg350-87a9ba5f2f5b9c3cde675c238ce718147417df03.tar.gz
scummvm-rg350-87a9ba5f2f5b9c3cde675c238ce718147417df03.tar.bz2
scummvm-rg350-87a9ba5f2f5b9c3cde675c238ce718147417df03.zip
SHERLOCK: Initial commit
-rw-r--r--engines/sherlock/configure.engine3
-rw-r--r--engines/sherlock/decompress.cpp82
-rw-r--r--engines/sherlock/decompress.h36
-rw-r--r--engines/sherlock/detection.cpp125
-rw-r--r--engines/sherlock/detection_tables.h47
-rw-r--r--engines/sherlock/graphics.cpp45
-rw-r--r--engines/sherlock/graphics.h43
-rw-r--r--engines/sherlock/inventory.h40
-rw-r--r--engines/sherlock/journal.cpp40
-rw-r--r--engines/sherlock/journal.h46
-rw-r--r--engines/sherlock/module.mk22
-rw-r--r--engines/sherlock/resources.cpp219
-rw-r--r--engines/sherlock/resources.h86
-rw-r--r--engines/sherlock/room.cpp32
-rw-r--r--engines/sherlock/room.h102
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp40
-rw-r--r--engines/sherlock/scalpel/scalpel.h45
-rw-r--r--engines/sherlock/sherlock.cpp81
-rw-r--r--engines/sherlock/sherlock.h91
-rw-r--r--engines/sherlock/sound.h39
-rw-r--r--engines/sherlock/sprite.cpp142
-rw-r--r--engines/sherlock/sprite.h56
-rw-r--r--engines/sherlock/talk.cpp30
-rw-r--r--engines/sherlock/talk.h49
-rw-r--r--engines/sherlock/tattoo/tattoo.cpp38
-rw-r--r--engines/sherlock/tattoo/tattoo.h45
-rw-r--r--engines/sherlock/vdaplayer.h34
27 files changed, 1658 insertions, 0 deletions
diff --git a/engines/sherlock/configure.engine b/engines/sherlock/configure.engine
new file mode 100644
index 0000000000..a56129a8f0
--- /dev/null
+++ b/engines/sherlock/configure.engine
@@ -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 sherlock "The Lost Files of Sherlock Holmes" no
diff --git a/engines/sherlock/decompress.cpp b/engines/sherlock/decompress.cpp
new file mode 100644
index 0000000000..61110be840
--- /dev/null
+++ b/engines/sherlock/decompress.cpp
@@ -0,0 +1,82 @@
+/* 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 "sherlock/decompress.h"
+
+namespace Sherlock {
+
+/**
+ * Decompresses an LZW compressed resource. If no outSize is specified, it will
+ * decompress the entire resource. If, however, an explicit size is specified,
+ * it will decompress only up to that many bytes from the stream starting at
+ * whatever position it was previously.
+ */
+Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int32 outSize) {
+ if (outSize == -1) {
+ source.seek(5);
+ outSize = source.readSint32LE();
+ }
+
+ byte lzWindow[4096];
+ uint16 lzWindowPos;
+ uint16 cmd;
+
+ byte *outBuffer = new byte[outSize];
+ byte *outBufferEnd = outBuffer + outSize;
+ Common::MemoryReadStream *outS = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES);
+
+ memset(lzWindow, 0xFF, 0xFEE);
+ lzWindowPos = 0xFEE;
+ cmd = 0;
+
+ while (1) {
+ cmd >>= 1;
+ if (!(cmd & 0x100)) {
+ cmd = source.readByte() | 0xFF00;
+ }
+ if (cmd & 1) {
+ byte literal = source.readByte();
+ *outBuffer++ = literal;
+ lzWindow[lzWindowPos] = literal;
+ lzWindowPos = (lzWindowPos + 1) & 0x0FFF;
+ } else {
+ int copyPos, copyLen;
+ copyPos = source.readByte();
+ copyLen = source.readByte();
+ copyPos = copyPos | ((copyLen & 0xF0) << 4);
+ copyLen = (copyLen & 0x0F) + 3;
+ while (copyLen--) {
+ byte literal = lzWindow[copyPos];
+ copyPos = (copyPos + 1) & 0x0FFF;
+ *outBuffer++ = literal;
+ lzWindow[lzWindowPos] = literal;
+ lzWindowPos = (lzWindowPos + 1) & 0x0FFF;
+ }
+ }
+ if (outBuffer >= outBufferEnd)
+ break;
+ }
+
+ return outS;
+}
+
+} // namespace Sherlock
diff --git a/engines/sherlock/decompress.h b/engines/sherlock/decompress.h
new file mode 100644
index 0000000000..330e018115
--- /dev/null
+++ b/engines/sherlock/decompress.h
@@ -0,0 +1,36 @@
+/* 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 SHERLOCK_DECOMPRESS_H
+#define SHERLOCK_DECOMPRESS_H
+
+#include "common/memstream.h"
+
+namespace Sherlock {
+
+#include "common/stream.h"
+
+Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int32 outSize = -1);
+
+} // namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/detection.cpp b/engines/sherlock/detection.cpp
new file mode 100644
index 0000000000..f207bb69d9
--- /dev/null
+++ b/engines/sherlock/detection.cpp
@@ -0,0 +1,125 @@
+/* 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 "sherlock/sherlock.h"
+#include "sherlock/scalpel/scalpel.h"
+#include "sherlock/tattoo/tattoo.h"
+#include "engines/advancedDetector.h"
+
+namespace Sherlock {
+
+#define MAX_SAVES 99
+
+struct SherlockGameDescription {
+ ADGameDescription desc;
+
+ int gameID;
+ uint32 features;
+};
+
+uint32 SherlockEngine::getGameID() const {
+ return _gameDescription->gameID;
+}
+
+uint32 SherlockEngine::getGameFeatures() const {
+ return _gameDescription->features;
+}
+
+Common::Platform SherlockEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
+} // End of namespace Sherlock
+
+static const PlainGameDescriptor sherlockGames[] = {
+ {"sherlock", "The Lost Files of Sherlock Holmes"},
+ { "scalpel", "The Case of the Serrated Scalpel" },
+ { "rosetattoo", "The Case of the Rose Tattoo" },
+ {0, 0}
+};
+
+#include "sherlock/detection_tables.h"
+
+class SherlockMetaEngine : public AdvancedMetaEngine {
+public:
+ SherlockMetaEngine() : AdvancedMetaEngine(Sherlock::gameDescriptions, sizeof(Sherlock::gameDescriptions), sherlockGames) {}
+
+ virtual const char *getName() const {
+ return "Sherlock Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Sherlock Engine (C) 1992-1996 Mythos Software, 1992-1996 (C) Electronic Arts";
+ }
+
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual void removeSaveState(const char *target, int slot) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+};
+
+bool SherlockMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const Sherlock::SherlockGameDescription *gd = (const Sherlock::SherlockGameDescription *)desc;
+ if (gd) {
+ switch (gd->gameID) {
+ case Sherlock::GType_SerratedScalpel:
+ *engine = new Sherlock::Scalpel::ScalpelEngine(syst, gd);
+ break;
+ case Sherlock::GType_RoseTattoo:
+ *engine = new Sherlock::Tattoo::TattooEngine(syst, gd);
+ break;
+ default:
+ error("Unknown game");
+ break;
+ }
+ }
+ return gd != 0;
+}
+
+bool SherlockMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return false;
+}
+
+SaveStateList SherlockMetaEngine::listSaves(const char *target) const {
+ SaveStateList saveList;
+ return saveList;
+}
+
+int SherlockMetaEngine::getMaximumSaveSlot() const {
+ return MAX_SAVES;
+}
+
+void SherlockMetaEngine::removeSaveState(const char *target, int slot) const {
+}
+
+SaveStateDescriptor SherlockMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ return SaveStateDescriptor();
+}
+
+
+#if PLUGIN_ENABLED_DYNAMIC(SHERLOCK)
+REGISTER_PLUGIN_DYNAMIC(SHERLOCK, PLUGIN_TYPE_ENGINE, SherlockMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(SHERLOCK, PLUGIN_TYPE_ENGINE, SherlockMetaEngine);
+#endif
diff --git a/engines/sherlock/detection_tables.h b/engines/sherlock/detection_tables.h
new file mode 100644
index 0000000000..1d7326058e
--- /dev/null
+++ b/engines/sherlock/detection_tables.h
@@ -0,0 +1,47 @@
+/* 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.
+ *
+ */
+
+namespace Sherlock {
+
+static const SherlockGameDescription gameDescriptions[] = {
+ {
+ // Case of the Serrated Scalpel - English
+ {
+ "scalpel",
+ 0,
+ {
+ { "talk.lib", 0, "ad0c4d6865edf15da4e9204c08815875", 238928 },
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOSPEECH)
+ },
+ GType_SerratedScalpel,
+ 0
+ },
+
+ { AD_TABLE_END_MARKER, 0, 0 }
+};
+
+} // End of namespace MADS
diff --git a/engines/sherlock/graphics.cpp b/engines/sherlock/graphics.cpp
new file mode 100644
index 0000000000..f4a5bf1864
--- /dev/null
+++ b/engines/sherlock/graphics.cpp
@@ -0,0 +1,45 @@
+/* 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 "sherlock/graphics.h"
+
+namespace Sherlock {
+
+Surface::Surface(uint16 width, uint16 height) {
+ create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+}
+
+Surface::~Surface() {
+ free();
+}
+
+void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) {
+ Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), color);
+}
+
+void Surface::drawSprite(int x, int y, SpriteFrame *spriteFrame, bool flipped, bool altFlag) {
+
+
+}
+
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/graphics.h b/engines/sherlock/graphics.h
new file mode 100644
index 0000000000..64518a78c6
--- /dev/null
+++ b/engines/sherlock/graphics.h
@@ -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 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 SHERLOCK_GRAPHICS_H
+#define SHERLOCK_GRAPHICS_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "sherlock/sprite.h"
+
+namespace Sherlock {
+
+class Surface : public Graphics::Surface {
+public:
+ Surface(uint16 width, uint16 height);
+ ~Surface();
+ void fillRect(int x1, int y1, int x2, int y2, byte color);
+ void drawSprite(int x, int y, SpriteFrame *spriteFrame, bool flipped = false, bool altFlag = false);
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h
new file mode 100644
index 0000000000..de4a2d7758
--- /dev/null
+++ b/engines/sherlock/inventory.h
@@ -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 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 SHERLOCK_INVENTORY_H
+#define SHERLOCK_INVENTORY_H
+
+#include "common/scummsys.h"
+
+namespace Sherlock {
+
+struct InventoryItem {
+ int stringIndex;
+ char name[12];
+ char description[41];
+ char name2[9];
+ uint16 value;
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp
new file mode 100644
index 0000000000..ad7df48943
--- /dev/null
+++ b/engines/sherlock/journal.cpp
@@ -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 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 "sherlock/journal.h"
+
+namespace Sherlock {
+
+Journal::Journal() {
+ // Allow up to 1000 statements
+ _data.resize(1000);
+
+ // Initialize fields
+ _count = 0;
+ _maxPage = 0;
+ _index = 0;
+ _sub = 0;
+ _up = _down = 0;
+ _page = 0;
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/journal.h b/engines/sherlock/journal.h
new file mode 100644
index 0000000000..64158ff123
--- /dev/null
+++ b/engines/sherlock/journal.h
@@ -0,0 +1,46 @@
+/* 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 SHERLOCK_JOURNAL_H
+#define SHERLOCK_JOURNAL_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace Sherlock {
+
+class Journal {
+public:
+ Common::Array<int> _data;
+ int _count;
+ int _maxPage;
+ int _index;
+ int _sub;
+ int _up, _down;
+ int _page;
+public:
+ Journal();
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
new file mode 100644
index 0000000000..1dfcb3a5af
--- /dev/null
+++ b/engines/sherlock/module.mk
@@ -0,0 +1,22 @@
+MODULE := engines/sherlock
+
+MODULE_OBJS = \
+ scalpel/scalpel.o \
+ tattoo/tattoo.o \
+ decompress.o \
+ detection.o \
+ graphics.o \
+ journal.o \
+ resources.o \
+ room.o \
+ sherlock.o \
+ sprite.o \
+ talk.o
+
+# This module can be built as a plugin
+ifdef BUILD_PLUGINS
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
new file mode 100644
index 0000000000..e59e65abff
--- /dev/null
+++ b/engines/sherlock/resources.cpp
@@ -0,0 +1,219 @@
+/* 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 "sherlock/resources.h"
+#include "sherlock/decompress.h"
+#include "common/debug.h"
+
+namespace Sherlock {
+
+Cache::Cache() {
+}
+
+/**
+ * Returns true if a given file is currently being cached
+ */
+bool Cache::isCached(const Common::String &filename) const {
+ return _resources.contains(filename);
+}
+
+/**
+ * Loads a file into the cache if it's not already present, and returns it.
+ * If the file is LZW compressed, automatically decompresses it and loads
+ * the uncompressed version into memory
+ */
+void Cache::load(const Common::String &filename) {
+ // First check if the entry already exists
+ if (_resources.contains(filename))
+ return;
+
+ // Allocate a new cache entry
+ _resources[filename] = CacheEntry();
+ CacheEntry &cacheEntry = _resources[filename];
+
+ // Open the file for reading
+ Common::File f;
+ if (!f.open(filename))
+ error("Could not read file - %s", filename.c_str());
+
+ // Check whether the file is compressed
+ const char LZW_HEADER[5] = { "LZV\x1a" };
+ char header[5];
+ f.read(header, 5);
+ bool isCompressed = !strncmp(header, LZW_HEADER, 5);
+ f.seek(0);
+
+ if (isCompressed) {
+ // It's compressed, so decompress the file and store it's data in the cache entry
+ Common::SeekableReadStream *decompressed = decompressLZ(f);
+ cacheEntry.resize(decompressed->size());
+ decompressed->read(&cacheEntry[0], decompressed->size());
+
+ delete decompressed;
+ } else {
+ // It's not, so read the raw data of the file into the cache entry
+ cacheEntry.resize(f.size());
+ f.read(&cacheEntry[0], f.size());
+ }
+
+ f.close();
+}
+
+Common::SeekableReadStream *Cache::get(const Common::String &filename) const {
+ // Return a memory stream that encapsulates the data
+ const CacheEntry &cacheEntry = _resources[filename];
+ return new Common::MemoryReadStream(&cacheEntry[0], cacheEntry.size());
+}
+
+/*----------------------------------------------------------------*/
+
+Resources::Resources() {
+ _resourceIndex = -1;
+
+ addToCache("vgs.lib");
+ addToCache("talk.lib");
+ addToCache("sequence.txt");
+ addToCache("journal.txt");
+ addToCache("portrait.lib");
+}
+
+
+/**
+ * Adds the specified file to the cache. If it's a library file, takes care of
+ * loading it's index for future use
+ */
+void Resources::addToCache(const Common::String &filename) {
+ _cache.load(filename);
+
+ // Check to see if the file is a library
+ Common::SeekableReadStream *stream = load(filename);
+ uint32 header = stream->readUint32BE();
+ if (header == MKTAG('L', 'I', 'B', 26))
+ loadLibraryIndex(filename, stream);
+
+ delete stream;
+}
+
+Common::SeekableReadStream *Resources::load(const Common::String &filename) {
+ // First check if the file is directly in the cache
+ if (_cache.isCached(filename))
+ return _cache.get(filename);
+
+ // Secondly, iterate through any loaded library file looking for a resource
+ // that has the same name
+ LibraryIndexes::iterator i;
+ for (i = _indexes.begin(); i != _indexes.end(); ++i) {
+ if ((*i)._value.contains(filename)) {
+ // Get a stream reference to the given library file
+ Common::SeekableReadStream *stream = load((*i)._key);
+ LibraryEntry &entry = (*i)._value[filename];
+ _resourceIndex = entry._index;
+
+ stream->seek(entry._offset);
+ Common::SeekableReadStream *resStream = stream->readStream(entry._size);
+
+ delete stream;
+ return resStream;
+ }
+ }
+
+ // At this point, fall back on a physical file with the given name
+ Common::File f;
+ if (!f.open(filename))
+ error("Could not load file - %s", filename.c_str());
+
+ Common::SeekableReadStream *stream = f.readStream(f.size());
+ f.close();
+
+ return stream;
+}
+
+/**
+ * Loads a specific resource from a given library file
+ */
+Common::SeekableReadStream *Resources::load(const Common::String &filename, const Common::String &libraryFile) {
+ // Open up the library for access
+ Common::SeekableReadStream *libStream = load(libraryFile);
+
+ // Check if the library has already had it's index read, and if not, load it
+ if (!_indexes.contains(libraryFile))
+ loadLibraryIndex(libraryFile, libStream);
+
+ // Extract the data for the specified resource and return it
+ LibraryEntry &entry = _indexes[libraryFile][filename];
+ libStream->seek(entry._offset);
+ Common::SeekableReadStream *stream = libStream->readStream(entry._size);
+
+ delete libStream;
+ return stream;
+}
+
+
+/**
+ * Reads in the index from a library file, and caches it's index for later use
+ */
+void Resources::loadLibraryIndex(const Common::String &libFilename,
+ Common::SeekableReadStream *stream) {
+ uint32 offset, nextOffset;
+
+ // Create an index entry
+ _indexes[libFilename] = LibraryIndex();
+ LibraryIndex &index = _indexes[libFilename];
+
+ // Read in the number of resources
+ stream->seek(4);
+ int count = stream->readUint16LE();
+
+ // Loop through reading in the entries
+ for (int idx = 0; idx < count; ++idx) {
+ // Read the name of the resource
+ char resName[13];
+ stream->read(resName, 13);
+ resName[12] = '\0';
+
+ // Read the offset
+ offset = stream->readUint32LE();
+
+ if (idx == (count - 1)) {
+ nextOffset = stream->size();
+ } else {
+ // Read the size by jumping forward to read the next entry's offset
+ stream->seek(13, SEEK_CUR);
+ nextOffset = stream->readUint32LE();
+ stream->seek(-17, SEEK_CUR);
+ }
+
+ // Add the entry to the index
+ index[resName] = LibraryEntry(idx, offset, nextOffset - offset);
+ }
+}
+
+/**
+ * Returns the index of the last loaded resource in it's given library file.
+ * This will be used primarily when loading talk files, so the engine can
+ * update the given conversation number in the journal
+ */
+int Resources::resouceIndex() const {
+ return _resourceIndex;
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h
new file mode 100644
index 0000000000..bfd2eb300c
--- /dev/null
+++ b/engines/sherlock/resources.h
@@ -0,0 +1,86 @@
+/* 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 SHERLOCK_RESOURCES_H
+#define SHERLOCK_RESOURCES_H
+
+#include "common/array.h"
+#include "common/file.h"
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+#include "common/str.h"
+#include "common/stream.h"
+
+namespace Sherlock {
+
+typedef Common::Array<byte> CacheEntry;
+typedef Common::HashMap<Common::String, CacheEntry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> CacheHash;
+
+struct LibraryEntry {
+ uint32 _offset, _size;
+ int _index;
+
+ LibraryEntry() : _index(0), _offset(0), _size(0) {}
+ LibraryEntry(int index, uint32 offset, uint32 size) :
+ _index(index), _offset(offset), _size(size) {}
+};
+typedef Common::HashMap<Common::String, LibraryEntry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> LibraryIndex;
+typedef Common::HashMap<Common::String, LibraryIndex, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> LibraryIndexes;
+
+class SherlockEngine;
+
+class Cache {
+private:
+ CacheHash _resources;
+public:
+ Cache();
+
+ bool isCached(const Common::String &filename) const;
+
+ void load(const Common::String &name);
+
+ Common::SeekableReadStream *get(const Common::String &filename) const;
+};
+
+class Resources {
+private:
+ Cache _cache;
+ LibraryIndexes _indexes;
+ int _resourceIndex;
+
+ void loadLibraryIndex(const Common::String &libFilename, Common::SeekableReadStream *stream);
+public:
+ Resources();
+
+ void addToCache(const Common::String &filename);
+
+ Common::SeekableReadStream *load(const Common::String &filename);
+
+ Common::SeekableReadStream *load(const Common::String &filename, const Common::String &libraryFile);
+
+ int resouceIndex() const;
+};
+
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/room.cpp b/engines/sherlock/room.cpp
new file mode 100644
index 0000000000..246a316562
--- /dev/null
+++ b/engines/sherlock/room.cpp
@@ -0,0 +1,32 @@
+/* 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 "sherlock/room.h"
+
+namespace Sherlock {
+
+Rooms::Rooms() {
+ for (int roomNum = 0; roomNum < ROOMS_COUNT; ++roomNum)
+ Common::fill(&_stats[roomNum][0], &_stats[roomNum][9], false);
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/room.h b/engines/sherlock/room.h
new file mode 100644
index 0000000000..46755c1a10
--- /dev/null
+++ b/engines/sherlock/room.h
@@ -0,0 +1,102 @@
+/* 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 SHERLOCK_ROOM_H
+#define SHERLOCK_ROOM_H
+
+#include "common/scummsys.h"
+#include "sherlock/sprite.h"
+
+namespace Sherlock {
+
+#define ROOMS_COUNT 63
+
+/*
+struct RoomBounds {
+ int x, y, width, height;
+};
+
+struct BgshapeSub {
+ uint16 value;
+};
+
+struct Bgshape {
+ char name[12];
+ char description[41];
+ char *textBufferPtr;
+ byte *seqBufPtr;
+ Sprite *sprite;
+ SpriteFrame *spriteFrame;
+ byte byte05;
+ byte seqBigCountFlag;
+ int16 seqIndex;
+ int16 canimIndex;
+ int16 x, y;
+ int16 xIncr, yIncr,
+ uint16 status;
+ int16 x2, y2;
+ int16 width2, height2;
+ uint16 word02;
+ uint16 word03;
+ byte flag;
+ byte itemValue;
+ uint16 word01;
+ uint16 word05;
+ uint16 stringIndex;
+ int16 width, height;
+ uint16 word04;
+ byte flagsAndIndex;
+ uint16 frameCount;
+ byte spriteFlags;
+ char string1[50];
+ byte byte07;
+ byte byte01;
+ byte byte02;
+ int16 boundsX, boundsY;
+ byte direction;
+ byte animIndex;
+ char string2[50];
+ byte byte06;
+ byte seqByte;
+ uint16 textBufferOfs;
+ byte byte03;
+ uint16 framesCopyCount;
+ byte byte08;
+ char string3[51];
+ uint16 word06;
+ uint16 word07;
+ uint16 word08;
+ uint16 word09;
+ BgshapeSub subItems[4];
+};
+*/
+class Rooms {
+public:
+ bool _stats[ROOMS_COUNT][9];
+ bool _savedStats[ROOMS_COUNT][9];
+public:
+ Rooms();
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
new file mode 100644
index 0000000000..11b78946f9
--- /dev/null
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -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 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 "sherlock/scalpel/scalpel.h"
+
+namespace Sherlock {
+
+namespace Scalpel {
+
+/**
+ * Initialises game flags
+ */
+void ScalpelEngine::initFlags() {
+ _flags.resize(100 * 8);
+ _flags[3] = true; // Turn on Alley
+ _flags[39] = true; // Turn on Baker Street
+}
+
+} // End of namespace Scalpel
+
+} // End of namespace Scalpel
diff --git a/engines/sherlock/scalpel/scalpel.h b/engines/sherlock/scalpel/scalpel.h
new file mode 100644
index 0000000000..e9f9aa05a2
--- /dev/null
+++ b/engines/sherlock/scalpel/scalpel.h
@@ -0,0 +1,45 @@
+/* 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 SHERLOCK_SCALPEL_H
+#define SHERLOCK_SCALPEL_H
+
+#include "sherlock/sherlock.h"
+
+namespace Sherlock {
+
+namespace Scalpel {
+
+class ScalpelEngine : public SherlockEngine {
+public:
+ ScalpelEngine(OSystem *syst, const SherlockGameDescription *gameDesc) :
+ SherlockEngine(syst, gameDesc) {}
+ virtual ~ScalpelEngine() {}
+
+ virtual void initFlags();
+};
+
+} // End of namespace Scalpel
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp
new file mode 100644
index 0000000000..a6ae6e215c
--- /dev/null
+++ b/engines/sherlock/sherlock.cpp
@@ -0,0 +1,81 @@
+/* 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 "sherlock/sherlock.h"
+#include "sherlock/graphics.h"
+#include "common/scummsys.h"
+#include "common/debug-channels.h"
+#include "engines/util.h"
+
+namespace Sherlock {
+
+SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc) :
+ Engine(syst), _gameDescription(gameDesc) {
+ _journal = nullptr;
+ _res = nullptr;
+ _rooms = nullptr;
+ _talk = nullptr;
+}
+
+
+SherlockEngine::~SherlockEngine() {
+ delete _journal;
+ delete _res;
+ delete _rooms;
+ delete _talk;
+}
+
+void SherlockEngine::initialize() {
+ initGraphics(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT, false);
+
+ DebugMan.addDebugChannel(kDebugScript, "scripts", "Script debug level");
+
+ /*
+ int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
+ bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
+
+ MidiDriver *driver = MidiDriver::createMidi(midiDriver);
+ if (native_mt32)
+ driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
+
+ _midi = new MidiPlayer(this, driver);
+ _midi->setGM(true);
+ _midi->setNativeMT32(native_mt32);
+ */
+
+ _journal = new Journal();
+ _res = new Resources();
+ _rooms = new Rooms();
+ _talk = new Talk();
+
+ initFlags();
+}
+
+Common::Error SherlockEngine::run() {
+ initialize();
+
+ // TODO: The rest of the game
+
+ return Common::kNoError;
+}
+
+} // End of namespace Comet
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
new file mode 100644
index 0000000000..a68650c0a9
--- /dev/null
+++ b/engines/sherlock/sherlock.h
@@ -0,0 +1,91 @@
+/* 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 SHERLOCK_HOLMES_H
+#define SHERLOCK_HOLMES_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/endian.h"
+#include "common/util.h"
+#include "common/savefile.h"
+#include "common/hash-str.h"
+#include "engines/engine.h"
+#include "sherlock/journal.h"
+#include "sherlock/resources.h"
+#include "sherlock/room.h"
+#include "sherlock/talk.h"
+
+namespace Sherlock {
+
+enum {
+ kFileTypeHash
+};
+
+enum {
+ kDebugScript = 1 << 0
+};
+
+enum {
+ GType_SerratedScalpel = 0,
+ GType_RoseTattoo = 1
+};
+
+#define SHERLOCK_SCREEN_WIDTH 320
+#define SHERLOCK_SCREEN_HEIGHT 200
+
+struct SherlockGameDescription;
+
+class Resource;
+
+class SherlockEngine : public Engine {
+private:
+ bool detectGame();
+
+ void initialize();
+public:
+ const SherlockGameDescription *_gameDescription;
+ Journal *_journal;
+ Resources *_res;
+ Rooms *_rooms;
+ Talk *_talk;
+ Common::Array<bool> _flags;
+public:
+ SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
+ virtual ~SherlockEngine();
+
+ virtual Common::Error run();
+
+ virtual void initFlags() = 0;
+
+ int getGameType() const;
+ uint32 getGameID() const;
+ uint32 getGameFeatures() const;
+ Common::Language getLanguage() const;
+ Common::Platform getPlatform() const;
+
+ Common::String getGameFile(int fileType);
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
new file mode 100644
index 0000000000..f3b34345ef
--- /dev/null
+++ b/engines/sherlock/sound.h
@@ -0,0 +1,39 @@
+/* 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 SHERLOCK_SOUND_H
+#define SHERLOCK_SOUND_H
+
+namespace Sherlock {
+
+class Sound {
+public
+ void playSound(const char *name);
+ void cacheSound(const char *name, int index);
+ void playCachedSound(int index);
+ void clearCache();
+
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/sprite.cpp b/engines/sherlock/sprite.cpp
new file mode 100644
index 0000000000..7aa2fdc71b
--- /dev/null
+++ b/engines/sherlock/sprite.cpp
@@ -0,0 +1,142 @@
+/* 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 "sherlock/sprite.h"
+#include "common/debug.h"
+
+namespace Sherlock {
+
+/*
+struct SpriteFrame {
+ byte *data;
+ int width, height;
+ uint16 flags;
+ int xofs, yofs;
+ byte rleMarker;
+};
+*/
+
+Sprite::Sprite(Common::SeekableReadStream &stream) {
+ load(stream);
+}
+
+Sprite::~Sprite() {
+}
+
+int Sprite::getFrameCount() {
+ return _frames.size();
+}
+
+SpriteFrame *Sprite::getFrame(int index) {
+ return _frames[index];
+}
+
+void Sprite::load(Common::SeekableReadStream &stream) {
+
+ while (!stream.eos()) {
+
+ debug("frameNum = %d\n", _frames.size());
+
+ SpriteFrame *spriteFrame = new SpriteFrame();
+
+ uint32 startOfs = stream.pos();
+
+ debug("startOfs = %08X\n", startOfs);
+
+ spriteFrame->frame = NULL;
+ spriteFrame->width = stream.readUint16LE() + 1;
+ spriteFrame->height = stream.readUint16LE() + 1;
+ spriteFrame->flags = stream.readUint16LE();
+ stream.readUint16LE();
+
+ debug("width = %d; height = %d; flags = %04X\n", spriteFrame->width, spriteFrame->height, spriteFrame->flags);
+
+ if (spriteFrame->flags & 0xFF) {
+ spriteFrame->size = (spriteFrame->width * spriteFrame->height) / 2;
+ } else if (spriteFrame->flags & 0x0100) {
+ // this size includes the header size, which we subtract
+ spriteFrame->size = stream.readUint16LE() - 11;
+ spriteFrame->rleMarker = stream.readByte();
+ } else {
+ spriteFrame->size = spriteFrame->width * spriteFrame->height;
+ }
+
+ spriteFrame->data = new byte[spriteFrame->size];
+ stream.read(spriteFrame->data, spriteFrame->size);
+
+ decompressFrame(spriteFrame);
+
+ /*
+ debug("size = %d (%08X)\n", spriteFrame->size, spriteFrame->size);
+ if (spriteFrame->frame) {
+ char fn[128];
+ sndebug(fn, 128, "%04d.spr", _frames.size());
+ FILE *x = fopen(fn, "wb");
+ fwrite(spriteFrame->frame->pixels, spriteFrame->frame->w * spriteFrame->frame->h, 1, x);
+ fclose(x);
+ }
+ */
+
+ _frames.push_back(spriteFrame);
+
+ }
+
+ // debug("Done: %08X\n", stream.pos()); fflush(stdout);
+
+}
+
+void Sprite::decompressFrame(SpriteFrame *frame) {
+
+ frame->frame = new Graphics::Surface();
+ frame->frame->create(frame->width, frame->height, Graphics::PixelFormat::createFormatCLUT8());
+
+ if (frame->flags & 0xFF) {
+ debug("Sprite::decompressFrame() 4-bits/pixel\n");
+ debug("TODO\n");
+ } else if (frame->flags & 0x0100) {
+ debug("Sprite::decompressFrame() RLE-compressed; rleMarker = %02X\n", frame->rleMarker);
+ const byte *src = frame->data;
+ byte *dst = (byte *)frame->frame->getPixels();
+ for (uint16 h = 0; h < frame->height; h++) {
+ int16 w = frame->width;
+ while (w > 0) {
+ if (*src == frame->rleMarker) {
+ byte rleColor = src[1];
+ byte rleCount = src[2];
+ src += 3;
+ w -= rleCount;
+ while (rleCount--)
+ *dst++ = rleColor;
+ } else {
+ *dst++ = *src++;
+ w--;
+ }
+ }
+ }
+ } else {
+ debug("Sprite::decompressFrame() Uncompressed\n");
+ memcpy(frame->data, frame->frame->getPixels(), frame->width * frame->height);
+ }
+
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/sprite.h b/engines/sherlock/sprite.h
new file mode 100644
index 0000000000..f56ab588bb
--- /dev/null
+++ b/engines/sherlock/sprite.h
@@ -0,0 +1,56 @@
+/* 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 SHERLOCK_SPRITE_H
+#define SHERLOCK_SPRITE_H
+
+#include "common/stream.h"
+#include "common/array.h"
+#include "graphics/surface.h"
+
+namespace Sherlock {
+
+struct SpriteFrame {
+ byte *data;
+ uint32 size;
+ uint16 width, height;
+ uint16 flags;
+ int xofs, yofs;
+ byte rleMarker;
+ Graphics::Surface *frame;
+};
+
+class Sprite {
+public:
+ Sprite(Common::SeekableReadStream &stream);
+ ~Sprite();
+ int getFrameCount();
+ SpriteFrame *getFrame(int index);
+protected:
+ Common::Array<SpriteFrame*> _frames;
+ void load(Common::SeekableReadStream &stream);
+ void decompressFrame(SpriteFrame *frame);
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
new file mode 100644
index 0000000000..3122aff95f
--- /dev/null
+++ b/engines/sherlock/talk.cpp
@@ -0,0 +1,30 @@
+/* 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 "sherlock/talk.h"
+
+namespace Sherlock {
+
+Talk::Talk() {
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
new file mode 100644
index 0000000000..6ffbcdd8d4
--- /dev/null
+++ b/engines/sherlock/talk.h
@@ -0,0 +1,49 @@
+/* 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 SHERLOCK_TALK_H
+#define SHERLOCK_TALK_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace Sherlock {
+
+struct TalkHistoryEntry {
+private:
+ int _data[2];
+public:
+ TalkHistoryEntry() { _data[0] = _data[1] = 0; }
+
+ int &operator[](int idx) { return _data[idx]; }
+};
+
+class Talk {
+public:
+ Common::Array<TalkHistoryEntry> _history;
+public:
+ Talk();
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/tattoo/tattoo.cpp b/engines/sherlock/tattoo/tattoo.cpp
new file mode 100644
index 0000000000..bed6edb3d4
--- /dev/null
+++ b/engines/sherlock/tattoo/tattoo.cpp
@@ -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 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 "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+/**
+ * Initialises game flags
+ */
+void TattooEngine::initFlags() {
+ _flags.resize(100 * 8);
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Scalpel
diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h
new file mode 100644
index 0000000000..e2977983f1
--- /dev/null
+++ b/engines/sherlock/tattoo/tattoo.h
@@ -0,0 +1,45 @@
+/* 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 SHERLOCK_TATTOO_H
+#define SHERLOCK_TATTOO_H
+
+#include "sherlock/sherlock.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+class TattooEngine : public SherlockEngine {
+public:
+ TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc) :
+ SherlockEngine(syst, gameDesc) {}
+ virtual ~TattooEngine() {}
+
+ virtual void initFlags();
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/vdaplayer.h b/engines/sherlock/vdaplayer.h
new file mode 100644
index 0000000000..9b755606d5
--- /dev/null
+++ b/engines/sherlock/vdaplayer.h
@@ -0,0 +1,34 @@
+/* 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 SHERLOCK_VDAPLAYER_H
+#define SHERLOCK_VDAPLAYER_H
+
+namespace Sherlock {
+
+class VdaPlayer {
+
+};
+
+} // End of namespace Sherlock
+
+#endif