diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/chewy/chewy.cpp | 36 | ||||
-rw-r--r-- | engines/chewy/module.mk | 3 | ||||
-rw-r--r-- | engines/chewy/resource.cpp | 82 | ||||
-rw-r--r-- | engines/chewy/resource.h | 73 |
4 files changed, 193 insertions, 1 deletions
diff --git a/engines/chewy/chewy.cpp b/engines/chewy/chewy.cpp index a26a944674..130e31b64c 100644 --- a/engines/chewy/chewy.cpp +++ b/engines/chewy/chewy.cpp @@ -20,12 +20,16 @@ * */ +#include "common/config-manager.h" #include "common/error.h" +#include "common/events.h" +#include "common/system.h" #include "engines/engine.h" #include "engines/util.h" #include "chewy/chewy.h" +#include "chewy/resource.h" namespace Chewy { @@ -33,6 +37,16 @@ ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _rnd("chewy") { + + const Common::FSNode gameDataDir(ConfMan.get("path")); + + SearchMan.addSubDirectoryMatching(gameDataDir, "back"); + SearchMan.addSubDirectoryMatching(gameDataDir, "cut"); + SearchMan.addSubDirectoryMatching(gameDataDir, "err"); + SearchMan.addSubDirectoryMatching(gameDataDir, "misc"); + SearchMan.addSubDirectoryMatching(gameDataDir, "room"); + SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); + SearchMan.addSubDirectoryMatching(gameDataDir, "txt"); } ChewyEngine::~ChewyEngine() { @@ -44,6 +58,28 @@ Common::Error ChewyEngine::run() { initialize(); + Resource *res = new Resource("comic.tgp"); + TBFChunk *cur = res->getChunk(1); + + debug("Chunk 1: packed %d, type %d, pos %d, mode %d, comp %d, unpacked %d, width %d, height %d", + cur->packedSize, cur->type, cur->pos, cur->screenMode, cur->compressionFlag, cur->unpackedSize, + cur->width, cur->height + ); + + delete res; + + // Run a dummy loop + Common::Event event; + + while (!shouldQuit()) { + while (g_system->getEventManager()->pollEvent(event)) { + if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) + g_engine->quitGame(); + } + + g_system->delayMillis(10); + } + return Common::kNoError; } diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk index 497c101212..c9621c6273 100644 --- a/engines/chewy/module.mk +++ b/engines/chewy/module.mk @@ -2,7 +2,8 @@ MODULE := engines/chewy MODULE_OBJS = \ chewy.o \ - detection.o + detection.o \ + resource.o # This module can be built as a plugin diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp new file mode 100644 index 0000000000..1d8764a979 --- /dev/null +++ b/engines/chewy/resource.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 "common/stream.h" +#include "common/debug.h" +#include "common/textconsole.h" + +#include "chewy/chewy.h" +#include "chewy/resource.h" + +namespace Chewy { + +Resource::Resource(Common::String filename) { + _stream.open(filename); + uint32 magicBytes = MKTAG('N', 'G', 'S', '\0'); + if (_stream.readUint32BE() != magicBytes) + error("Invalid resource - %s", filename.c_str()); + _stream.skip(2); // type + _chunkCount = _stream.readUint16LE(); + + uint32 tbfID = MKTAG('T', 'B', 'F', '\0'); + + for (uint i = 0; i < _chunkCount; i++) { + TBFChunk cur; + cur.packedSize = _stream.readUint32LE(); + cur.type = _stream.readUint16LE(); + cur.pos = _stream.pos(); + if (_stream.readUint32BE() != tbfID) + error("Corrupt resource %s", filename.c_str()); + + cur.screenMode = _stream.readUint16LE(); + cur.compressionFlag = _stream.readUint16LE(); + cur.unpackedSize = _stream.readUint32LE(); + cur.width = _stream.readUint16LE(); + cur.height = _stream.readUint16LE(); + _stream.read(cur.palette, 3 * 256); + _stream.skip(cur.packedSize - TBF_CHUNK_HEADER_SIZE); + + _tbfChunkList.push_back(cur); + + /*debug("Chunk %d: packed %d, type %d, pos %d, mode %d, comp %d, unpacked %d, width %d, height %d", + i, cur.packedSize, cur.type, cur.pos, cur.screenMode, cur.compressionFlag, cur.unpackedSize, + cur.width, cur.height + );*/ + } + +} + +Resource::~Resource() { + _tbfChunkList.clear(); + _stream.close(); +} + +TBFChunk *Resource::getChunk(int num) { + return &_tbfChunkList[num]; +} + +Common::SeekableReadStream *Resource::getChunkData(int num) { + // TODO + return nullptr; +} + +} // End of namespace Chewy diff --git a/engines/chewy/resource.h b/engines/chewy/resource.h new file mode 100644 index 0000000000..5432e3c160 --- /dev/null +++ b/engines/chewy/resource.h @@ -0,0 +1,73 @@ +/* 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 CHEWY_RESOURCE_H +#define CHEWY_RESOURCE_H + + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/util.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/random.h" + +namespace Chewy { + +// 4 + 2 + 2 + 4 + 2 + 2 + 768 = 784 bytes +#define TBF_CHUNK_HEADER_SIZE 784 + +struct TBFChunk { + uint32 packedSize; // includes header + uint16 type; + uint32 pos; // extra field + + // TBF chunk header + // ID (TBF, followed by a zero) + uint16 screenMode; + uint16 compressionFlag; + uint32 unpackedSize; + uint16 width; + uint16 height; + char palette[3 * 256]; +}; + +typedef Common::Array<TBFChunk> TBFChunkList; + +class Resource { +public: + Resource(Common::String filename); + ~Resource(); + + TBFChunk *getChunk(int num); + Common::SeekableReadStream *getChunkData(int num); + +private: + Common::File _stream; + uint16 _chunkCount; + TBFChunkList _tbfChunkList; +}; + +} // End of namespace Chewy + +#endif |