Ticket #9023: draci2.patch
File draci2.patch, 17.8 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 AD_ENTRY1s("INIT.DFW", "b890a5aeebaf16af39219cba2416b0a3", 906), 44 Common::EN_ANY, 45 Common::kPlatformPC, 46 ADGF_NO_FLAGS 47 }, 48 49 { 50 "draci", 51 0, 52 AD_ENTRY1s("INIT.DFW", "9921c8f0045679a8f37eca8d41c5ec02", 906), 53 Common::CZ_CZE, 54 Common::kPlatformPC, 55 ADGF_NO_FLAGS 56 }, 57 58 { 59 "draci", 60 0, 61 AD_ENTRY1s("INIT.DFW", "76b9b78a8a8809a240acc395df4d0715", 906), 62 Common::PL_POL, 63 Common::kPlatformPC, 64 ADGF_NO_FLAGS 65 }, 66 67 AD_TABLE_END_MARKER 68 }; 69 70 } // End of namespace Draci 71 72 const ADParams detectionParams = { 73 // Pointer to ADGameDescription or its superset structure 74 (const byte *)Draci::gameDescriptions, 75 // Size of that superset structure 76 sizeof(ADGameDescription), 77 // Number of bytes to compute MD5 sum for 78 5000, 79 // List of all engine targets 80 draciGames, 81 // Structure for autoupgrading obsolete targets 82 0, 83 // Name of single gameid (optional) 84 "draci", 85 // List of files for file-based fallback detection (optional) 86 0, 87 // Flags 88 0 89 }; 90 91 class DraciMetaEngine : public AdvancedMetaEngine { 92 public: 93 DraciMetaEngine() : AdvancedMetaEngine(detectionParams) {} 94 95 virtual const char *getName() const { 96 return "Draci Historie Engine"; 97 } 98 99 virtual const char *getOriginalCopyright() const { 100 return "Copyright (C) 1995 NoSense"; 101 } 102 103 virtual bool hasFeature(MetaEngineFeature f) const; 104 virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; 105 }; 106 107 bool DraciMetaEngine::hasFeature(MetaEngineFeature f) const { 108 return false; 109 } 110 111 bool Draci::DraciEngine::hasFeature(EngineFeature f) const { 112 return false; 113 } 114 115 bool DraciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { 116 if (desc) { 117 *engine = new Draci::DraciEngine(syst, Draci::gameDescriptions); 118 } 119 return desc != 0; 120 } 121 122 #if PLUGIN_ENABLED_DYNAMIC(DRACI) 123 REGISTER_PLUGIN_DYNAMIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine); 124 #else 125 REGISTER_PLUGIN_STATIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine); 126 #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", "Draci 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 61 // Basic archive test 62 Common::String path("INIT.DFW"); 63 BArchive ar(path); 64 BAFile *f; 65 f = ar[0]; 66 debugN(0, "First 10 bytes of file %d: ", 0); 67 for(unsigned int i = 0; i < 10; ++i) { 68 debugN(0, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n'); 69 } 70 71 Common::String path2("IKONY.DFW"); 72 ar.closeArchive(); 73 ar.openArchive(path2); 74 f = ar[0]; 75 debugN(0, "First 10 bytes of file %d: ", 0); 76 for(unsigned int i = 0; i < 10; ++i) { 77 debugN(0, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n'); 78 } 79 80 return 0; 81 } 82 83 int DraciEngine::go() { 84 debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()"); 85 86 return 0; 87 } 88 89 DraciEngine::~DraciEngine() { 90 // Dispose your resources here 91 92 // Remove all of our debug levels here 93 Common::clearAllDebugChannels(); 94 } 95 96 Common::Error DraciEngine::run() { 97 init(); 98 go(); 99 return Common::kNoError; 100 } 101 102 } // 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 byte *footer; 62 uint32 footerOffset, footerSize; 63 Common::File f; 64 65 // Close previously opened archive (if any) 66 closeArchive(); 67 68 debugC(5, kDraciGeneralDebugLevel, "Loading BAR archive %s:", 69 path.c_str()); 70 71 f.open(path); 72 if (f.isOpen()) { 73 debugC(5, kDraciGeneralDebugLevel, "Success"); 74 } else { 75 debugC(5, kDraciGeneralDebugLevel, "Error"); 76 return; 77 } 78 79 // Save path for reading in files later on 80 _path = path; 81 82 // Read archive header 83 debugC(5, kDraciGeneralDebugLevel, "Checking magic number:"); 84 85 f.read(buf, 4); 86 if (memcmp(buf, _magicNumber, 4) == 0) { 87 debugC(5, kDraciGeneralDebugLevel, "Success"); 88 } else { 89 debugC(5, kDraciGeneralDebugLevel, "Error"); 90 f.close(); 91 return; 92 } 93 94 _fileCount = f.readUint16LE(); 95 footerOffset = f.readUint32LE(); 96 footerSize = f.size() - footerOffset; 97 98 debugC(5, kDraciGeneralDebugLevel, "Archive info: %d files, %d data bytes", 99 _fileCount, footerOffset - _archiveHeaderSize); 100 101 // Read in footer 102 footer = new byte[footerSize]; 103 f.seek(footerOffset); 104 f.read(footer, footerSize); 105 Common::MemoryReadStream reader(footer, footerSize); 106 107 // Read in file headers, but do not read the actual data yet 108 // The data will be read on demand to save memory 109 _files = new BAFile[_fileCount]; 110 111 for (unsigned int i = 0; i < _fileCount; i++) { 112 uint32 fileOffset; 113 114 fileOffset = reader.readUint32LE(); 115 f.seek(fileOffset); // Seek to next file in archive 116 f.readUint16LE(); // Compressed size, not used 117 _files[i]._length = f.readUint16LE(); // Original size 118 _files[i]._offset = fileOffset; 119 120 assert(f.readByte() == 0 && 121 "Compression type flag is non-zero (file is compressed)"); 122 123 _files[i]._crc = f.readByte(); // CRC checksum of the file 124 _files[i]._data = NULL; // File data will be read in on demand 125 } 126 127 // Last footer item should be equal to footerOffset 128 assert(reader.readUint32LE() == footerOffset && "Footer offset mismatch"); 129 130 f.close(); 131 } 132 133 /** 134 * @brief BArchive close method 135 * 136 * Closes the currently opened archive. It can be called explicitly to 137 * free up memory. 138 */ 139 void BArchive::closeArchive(void) { 140 if (!_files) { 141 return; 142 } 143 144 for (unsigned int i = 0; i < _fileCount; ++i) { 145 if (_files[i]._data) { 146 delete _files[i]._data; 147 } 148 } 149 150 delete[] _files; 151 152 _files = NULL; 153 _fileCount = 0; 154 } 155 156 BAFile *BArchive::operator[](unsigned int i) const { 157 Common::File f; 158 159 // Check whether requested file exists 160 if (i >= _fileCount) { 161 return NULL; 162 } 163 164 debugC(5, kDraciGeneralDebugLevel, "Accessing file %d from archive %s", 165 i, _path.c_str()); 166 167 // Check if file has already been opened and return that 168 if (_files[i]._data) { 169 return _files + i; 170 } 171 172 // Else open archive and read in requested file 173 f.open(_path); 174 if (f.isOpen()) { 175 debugC(5, kDraciGeneralDebugLevel, "Success"); 176 } else { 177 debugC(5, kDraciGeneralDebugLevel, "Error"); 178 return NULL; 179 } 180 181 // Read in the file (without the file header) 182 f.seek(_files[i]._offset + _fileHeaderSize); 183 _files[i]._data = new byte[_files[i]._length]; 184 f.read(_files[i]._data, _files[i]._length); 185 186 // Calculate CRC 187 byte tmp = 0; 188 for (unsigned int j = 0; j < _files[i]._length; j++) { 189 tmp ^= _files[i]._data[j]; 190 } 191 192 assert(tmp == _files[i]._crc && "CRC checksum mismatch"); 193 194 return _files + i; 195 } 196 197 } // End of namespace Draci 198 199 200 -
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 /** 34 * Represents individual files inside the archive 35 */ 36 37 struct BAFile { 38 uint16 _length; 39 uint32 _offset; //!< Offset of file inside archive 40 byte *_data; 41 byte _crc; 42 43 void closeFile(void) { //!< Releases the file data (for memory considerations) 44 delete _data; 45 _data = NULL; 46 } 47 }; 48 49 class BArchive { 50 public: 51 BArchive() : _files(NULL), _fileCount(0) {} 52 BArchive(Common::String &path) : _files(NULL), _fileCount(0) { openArchive(path); } 53 ~BArchive() { closeArchive(); } 54 55 void openArchive(const Common::String &path); 56 void closeArchive(void); 57 uint16 size() const { return _fileCount; } 58 59 BAFile *operator[](unsigned int i) const; 60 61 private: 62 // Archive header data 63 static const char _magicNumber[]; 64 static const unsigned int _archiveHeaderSize = 10; 65 66 // File stream header data 67 static const unsigned int _fileHeaderSize = 6; 68 69 Common::String _path; //!< Path to file 70 BAFile *_files; //!< Internal array of files 71 uint16 _fileCount; //!< Number of files in archive 72 }; 73 74 } // End of namespace Draci 75 76 #endif // BARCHIVE_H -
engines/draci/module.mk
1 MODULE := engines/draci 2 3 MODULE_OBJS := \ 4 draci.o \ 5 detection.o \ 6 barchive.o 7 8 MODULE_DIRS += \ 9 engines/draci 10 11 # This module can be built as a plugin 12 ifeq ($(ENABLE_DRACI), DYNAMIC_PLUGIN) 13 PLUGIN := 1 14 endif 15 16 # Include common rules 17 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