Ticket #9023: draci.patch
File draci.patch, 16.3 KB (added by , 15 years ago) |
---|
-
configure
96 96 add_engine tinsel "Tinsel" no 97 97 add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes 98 98 add_engine tucker "Bud Tucker in Double Trouble" yes 99 add_engine draci "Dragon History" no 99 100 100 101 101 102 # -
engines/draci/detection.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #include "draci/draci.h" 27 28 #include "base/plugins.h" 29 #include "engines/metaengine.h" 30 31 static const PlainGameDescriptor draciGames[] = { 32 { "draci", "Draci Historie" }, 33 { 0, 0 } 34 }; 35 36 namespace Draci { 37 38 const ADGameDescription gameDescriptions[] = { 39 40 { 41 "draci", 42 0, 43 { 44 {"INIT.DFW", 0, "b890a5aeebaf16af39219cba2416b0a3", -1}, 45 {NULL, 0, NULL, 0} 46 }, 47 Common::EN_ANY, 48 Common::kPlatformPC, 49 ADGF_NO_FLAGS 50 }, 51 52 { 53 "draci", 54 0, 55 { 56 {"INIT.DFW", 0, "9921c8f0045679a8f37eca8d41c5ec02", -1}, 57 {NULL, 0, NULL, 0} 58 }, 59 Common::CZ_CZE, 60 Common::kPlatformPC, 61 ADGF_NO_FLAGS 62 }, 63 64 { 65 "draci", 66 0, 67 { 68 {"INIT.DFW", 0, "76b9b78a8a8809a240acc395df4d0715", -1}, 69 {NULL, 0, NULL, 0} 70 }, 71 Common::PL_POL, 72 Common::kPlatformPC, 73 ADGF_NO_FLAGS 74 }, 75 76 AD_TABLE_END_MARKER 77 }; 78 79 } // End of namespace Draci 80 81 const ADParams detectionParams = { 82 // Pointer to ADGameDescription or its superset structure 83 (const byte *)Draci::gameDescriptions, 84 // Size of that superset structure 85 sizeof(ADGameDescription), 86 // Number of bytes to compute MD5 sum for 87 5000, 88 // List of all engine targets 89 draciGames, 90 // Structure for autoupgrading obsolete targets 91 0, 92 // Name of single gameid (optional) 93 "draci", 94 // List of files for file-based fallback detection (optional) 95 0, 96 // Flags 97 0 98 }; 99 100 class DraciMetaEngine : public AdvancedMetaEngine { 101 public: 102 DraciMetaEngine() : AdvancedMetaEngine(detectionParams) {} 103 104 virtual const char *getName() const { 105 return "Draci Historie Engine"; 106 } 107 108 virtual const char *getOriginalCopyright() const { 109 return "Copyright (C) 1995 NoSense"; 110 } 111 112 virtual bool hasFeature(MetaEngineFeature f) const; 113 virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; 114 }; 115 116 bool DraciMetaEngine::hasFeature(MetaEngineFeature f) const { 117 return false; 118 } 119 120 bool Draci::DraciEngine::hasFeature(EngineFeature f) const { 121 return false; 122 } 123 124 bool DraciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { 125 if (desc) { 126 *engine = new Draci::DraciEngine(syst, Draci::gameDescriptions); 127 } 128 return desc != 0; 129 } 130 131 #if PLUGIN_ENABLED_DYNAMIC(DRACI) 132 REGISTER_PLUGIN_DYNAMIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine); 133 #else 134 REGISTER_PLUGIN_STATIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine); 135 #endif -
engines/draci/draci.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 27 #include "common/scummsys.h" 28 29 #include "common/config-manager.h" 30 #include "common/events.h" 31 #include "common/file.h" 32 33 #include "draci/draci.h" 34 35 #include "draci/barchive.h" 36 37 namespace Draci { 38 39 DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) 40 : Engine(syst) { 41 // Put your engine in a sane state, but do nothing big yet; 42 // in particular, do not load data from files; rather, if you 43 // need to do such things, do them from init(). 44 45 // Do not initialize graphics here 46 47 // However this is the place to specify all default directories 48 //Common::File::addDefaultDirectory(_gameDataPath + "sound/"); 49 50 // Here is the right place to set up the engine specific debug levels 51 Common::addDebugChannel(kDraciGeneralDebugLevel, "general", "General debug level"); 52 53 // Don't forget to register your random source 54 syst->getEventManager()->registerRandomSource(_rnd, "draci"); 55 } 56 57 int DraciEngine::init() { 58 // Initialize graphics using following: 59 initGraphics(320, 200, false); 60 Common::String path("INIT.DFW"); 61 BArchive ar(path); 62 printf("INIT.DFW %d files\n", ar.size()); 63 64 return 0; 65 } 66 67 int DraciEngine::go() { 68 debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()"); 69 70 return 0; 71 } 72 73 DraciEngine::~DraciEngine() { 74 // Dispose your resources here 75 76 // Remove all of our debug levels here 77 Common::clearAllDebugChannels(); 78 } 79 80 Common::Error DraciEngine::run() { 81 init(); 82 go(); 83 return Common::kNoError; 84 } 85 86 } // End of namespace Draci -
engines/draci/barchive.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #include "common/debug.h" 27 #include "common/file.h" 28 #include "common/str.h" 29 #include "common/stream.h" 30 31 #include "draci/barchive.h" 32 #include "draci/draci.h" 33 34 namespace Draci { 35 36 const char BArchive::_magicNumber[] = "BAR!"; 37 38 /** 39 * @brief BArchive open method 40 * @param path Path to input file 41 * 42 * Opens a BAR (Bob's Archiver) archive, which is the game's archiving format. 43 * BAR archives have a .DFW file extension, due to an unused historical interface. 44 * 45 * archive format: header, 46 * file0, file1, ... 47 * footer 48 * header format: [4 bytes] magic number "BAR!" 49 * [uint16LE] file count (number of archived streams), 50 * [uint32LE] footer offset from start of file 51 * file<N> format: [2 bytes] compressed length 52 * [2 bytes] original length 53 * [1 byte] compression type 54 * [1 byte] CRC 55 * footer format: [array of uint32LE] offsets of individual files from start of archive 56 * (last entry is footer offset again) 57 */ 58 59 void BArchive::openArchive(const Common::String &path) { 60 byte buf[4]; 61 unsigned int footerOffset, dataLength; 62 Common::File f; 63 64 // Close previously opened archive (if any) 65 closeArchive(); 66 67 debugC(5, kDraciGeneralDebugLevel, "Opening file %s as a BAR archive:", 68 path.c_str()); 69 f.open(path); 70 if (f.isOpen()) { 71 debugC(5, kDraciGeneralDebugLevel, "Success"); 72 } else { 73 debugC(5, kDraciGeneralDebugLevel, "Error"); 74 return; 75 } 76 77 // Read archive header 78 debugC(5, kDraciGeneralDebugLevel, "Checking magic number:"); 79 f.read(buf, 4); 80 if (memcmp(buf, _magicNumber, 4) == 0) { 81 debugC(5, kDraciGeneralDebugLevel, "Success"); 82 } else { 83 debugC(5, kDraciGeneralDebugLevel, "Error"); 84 f.close(); 85 return; 86 } 87 88 _fileCount = f.readUint16LE(); 89 footerOffset = f.readUint32LE(); 90 dataLength = footerOffset - _archiveHeaderSize; 91 debugC(5, kDraciGeneralDebugLevel, "Archive info: %d files, %d data bytes", 92 _fileCount, dataLength); 93 94 // Read files from archive 95 _rawData = new byte[dataLength]; 96 _files = new BAFile[_fileCount]; 97 98 f.read(_rawData, dataLength); 99 Common::MemoryReadStream reader(_rawData, dataLength); 100 101 for (unsigned int i = 0; i < _fileCount; i++) { 102 unsigned int fileOffset; 103 104 fileOffset = f.readUint32LE() - _archiveHeaderSize; 105 reader.seek(fileOffset); 106 reader.readUint16LE(); // Compressed size, not used 107 _files[i]._length = reader.readUint16LE(); 108 assert(reader.readByte() == 0 && 109 "Compression type flag is non-zero (file is compressed)"); 110 _files[i]._crc = reader.readByte(); // CRC checksum of the file 111 _files[i]._data = _rawData + fileOffset + _fileHeaderSize; 112 113 // Calculate CRC 114 byte tmp = 0; 115 for (unsigned int j = 0; j < _files[i]._length; j++) { 116 tmp ^= _files[i]._data[j]; 117 } 118 119 assert(tmp == _files[i]._crc && "CRC checksum mismatch"); 120 } 121 122 // Last footer item should be equal to footerOffset 123 assert(f.readUint32LE() == footerOffset && "Footer offset mismatch"); 124 } 125 126 /** 127 * @brief BArchive close method 128 * 129 * Closes the currently opened archive. It can be called explicitly to 130 * free up memory. 131 */ 132 void BArchive::closeArchive(void) { 133 if (!_rawData) { 134 return; 135 } 136 137 delete[] _rawData; 138 delete[] _files; 139 140 _rawData = NULL; 141 _files = NULL; 142 _fileCount = 0; 143 } 144 145 } // End of namespace Draci 146 147 148 -
engines/draci/draci.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #ifndef DRACI_H 27 #define DRACI_H 28 29 #include "common/system.h" 30 #include "engines/engine.h" 31 #include "engines/advancedDetector.h" 32 33 namespace Draci { 34 35 class DraciEngine : public Engine { 36 public: 37 DraciEngine(OSystem *syst, const ADGameDescription *gameDesc); 38 ~DraciEngine(); 39 40 int init(); 41 int go(); 42 Common::Error run(); 43 44 bool hasFeature(Engine::EngineFeature f) const; 45 46 private: 47 Common::RandomSource _rnd; 48 }; 49 50 enum { 51 kDraciGeneralDebugLevel = 1 << 0 52 }; 53 54 } // End of namespace Draci 55 56 #endif // DRACI_H 57 -
engines/draci/barchive.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #ifndef BARCHIVE_H 27 #define BARCHIVE_H 28 29 #include "common/str.h" 30 31 namespace Draci { 32 33 class BArchive { 34 public: 35 36 /** 37 * Represents individual files inside the archive 38 */ 39 40 struct BAFile { 41 unsigned int _length; 42 const byte *_data; 43 byte _crc; 44 }; 45 46 BArchive() : _rawData(NULL), _files(NULL), _fileCount(0) {} 47 BArchive(Common::String &path) : _rawData(NULL), _files(NULL), _fileCount(0) { openArchive(path); } 48 ~BArchive() { closeArchive(); } 49 50 void openArchive(const Common::String &path); 51 void closeArchive(void); 52 unsigned int size() const { return _fileCount; } 53 54 const BAFile *operator[](unsigned int i) const { 55 return (i < _fileCount) ? _files + i : NULL; 56 } 57 58 private: 59 // Archive header data 60 static const char _magicNumber[]; 61 static const unsigned int _archiveHeaderSize = 10; 62 63 // File stream header data 64 static const unsigned int _fileHeaderSize = 6; 65 66 BAFile *_files; //!< Internal array of files 67 unsigned int _fileCount; //!< Number of files in archive 68 unsigned char *_rawData; //!< Raw data read from file, NULL if no archive opened 69 }; 70 71 } // End of namespace Draci 72 73 #endif /* BARCHIVE_H */ -
engines/draci/module.mk
1 MODULE := engines/draci 2 3 MODULE_OBJS := \ 4 draci.o detection.o barchive.o 5 6 MODULE_DIRS += \ 7 engines/draci 8 9 # This module can be built as a plugin 10 ifeq ($(ENABLE_DRACI), DYNAMIC_PLUGIN) 11 PLUGIN := 1 12 endif 13 14 # Include common rules 15 include $(srcdir)/rules.mk -
engines/engines.mk
36 36 MODULES += engines/cruise 37 37 endif 38 38 39 ifdef ENABLE_DRACI 40 DEFINES += -DENABLE_DRACI=$(ENABLE_DRACI) 41 MODULES += engines/draci 42 endif 43 39 44 ifdef ENABLE_DRASCULA 40 45 DEFINES += -DENABLE_DRASCULA=$(ENABLE_DRASCULA) 41 46 MODULES += engines/drascula -
base/plugins.cpp
157 157 #if PLUGIN_ENABLED_STATIC(TUCKER) 158 158 LINK_PLUGIN(TUCKER) 159 159 #endif 160 #if PLUGIN_ENABLED_STATIC(DRACI) 161 LINK_PLUGIN(DRACI) 162 #endif 160 163 161 164 // Music plugins 162 165 // TODO: Use defines to disable or enable each MIDI driver as a