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 */ 22 23 #include "common/scummsys.h" 24 #include "common/endian.h" 25 #include "common/hashmap.h" 26 #include "common/file.h" 27 #include "common/str.h" 28 29 #ifndef MOHAWK_RESOURCE_H 30 #define MOHAWK_RESOURCE_H 31 32 namespace Mohawk { 33 34 // Main FourCC's 35 #define ID_MHWK MKTAG('M','H','W','K') // Main FourCC 36 #define ID_RSRC MKTAG('R','S','R','C') // Resource Directory Tag 37 38 // Myst Resource FourCC's 39 #define ID_CLRC MKTAG('C','L','R','C') // Cursor Hotspots 40 #define ID_EXIT MKTAG('E','X','I','T') // Card Exit Scripts 41 #define ID_HINT MKTAG('H','I','N','T') // Cursor Hints 42 #define ID_INIT MKTAG('I','N','I','T') // Card Entrance Scripts 43 #define ID_MSND MKTAG('M','S','N','D') // Standard Mohawk Sound 44 #define ID_RLST MKTAG('R','L','S','T') // Resource List, Specifies HotSpots 45 #define ID_RSFL MKTAG('R','S','F','L') // ??? (system.dat only) 46 #define ID_VIEW MKTAG('V','I','E','W') // Card Details 47 #define ID_WDIB MKTAG('W','D','I','B') // LZ-Compressed Windows Bitmap 48 49 // Myst Masterpiece Edition Resource FourCC's (In addition to Myst FourCC's) 50 #define ID_HELP MKTAG('H','E','L','P') // Help Chunk 51 #define ID_MJMP MKTAG('M','J','M','P') // MSND Jumps (To reduce MSND duplication) 52 #define ID_PICT MKTAG('P','I','C','T') // JPEG/PICT/WDIB Image 53 54 // Riven Resource FourCC's 55 #define ID_BLST MKTAG('B','L','S','T') // Card Hotspot Enabling Lists 56 #define ID_CARD MKTAG('C','A','R','D') // Card Scripts 57 #define ID_FLST MKTAG('F','L','S','T') // Card SFXE Lists 58 #define ID_HSPT MKTAG('H','S','P','T') // Card Hotspots 59 #define ID_MLST MKTAG('M','L','S','T') // Card Movie Lists 60 #define ID_NAME MKTAG('N','A','M','E') // Object Names 61 #define ID_PLST MKTAG('P','L','S','T') // Card Picture Lists 62 #define ID_RMAP MKTAG('R','M','A','P') // Card Codes 63 #define ID_SFXE MKTAG('S','F','X','E') // Water Effect Animations 64 #define ID_SLST MKTAG('S','L','S','T') // Card Ambient Sound Lists 65 #define ID_TMOV MKTAG('t','M','O','V') // QuickTime Movie 66 67 // Riven Saved Game FourCC's 68 #define ID_VARS MKTAG('V','A','R','S') // Variable Values 69 #define ID_VERS MKTAG('V','E','R','S') // Version Info 70 #define ID_ZIPS MKTAG('Z','I','P','S') // Zip Mode Status 71 #define ID_META MKTAG('M','E','T','A') // ScummVM save metadata 72 #define ID_THMB MKTAG('T','H','M','B') // ScummVM save thumbnail 73 74 // Zoombini Resource FourCC's 75 #define ID_SND MKTAG( 0 ,'S','N','D') // Standard Mohawk Sound 76 #define ID_CURS MKTAG('C','U','R','S') // Cursor 77 #define ID_SCRB MKTAG('S','C','R','B') // Feature Script 78 #define ID_SCRS MKTAG('S','C','R','S') // Snoid Script 79 #define ID_NODE MKTAG('N','O','D','E') // Walk Node 80 #define ID_PATH MKTAG('P','A','T','H') // Walk Path 81 #define ID_SHPL MKTAG('S','H','P','L') // Shape List 82 83 // Living Books Resource FourCC's 84 #define ID_TCUR MKTAG('t','C','U','R') // Cursor 85 #define ID_BITL MKTAG('B','I','T','L') // Book Item List 86 #define ID_CTBL MKTAG('C','T','B','L') // Color Table 87 #define ID_SCRP MKTAG('S','C','R','P') // Script 88 #define ID_SPR MKTAG('S','P','R','#') // Sprite? 89 #define ID_VRSN MKTAG('V','R','S','N') // Version 90 #define ID_ANI MKTAG('A','N','I',' ') // Animation 91 #define ID_SHP MKTAG('S','H','P','#') // Shape 92 #define ID_WAV MKTAG('W','A','V',' ') // Old Sound Resource 93 #define ID_BMAP MKTAG('B','M','A','P') // Old Mohawk Bitmap 94 #define ID_BCOD MKTAG('B','C','O','D') // Book Code 95 96 // CSTime Resource FourCC's 97 #define ID_CINF MKTAG('C','I','N','F') // Case Info 98 #define ID_CONV MKTAG('C','O','N','V') // Conversation 99 #define ID_HOTS MKTAG('H','O','T','S') // Hotspot 100 #define ID_INVO MKTAG('I','N','V','O') // Inventory Object 101 #define ID_QARS MKTAG('Q','A','R','S') // Question and Responses 102 #define ID_SCEN MKTAG('S','C','E','N') // Scene 103 #define ID_STRI MKTAG('S','T','R','I') // String Entry? 104 105 // Mohawk Wave Tags 106 #define ID_WAVE MKTAG('W','A','V','E') // Game Sound (Third Tag) 107 #define ID_ADPC MKTAG('A','D','P','C') // Game Sound Chunk 108 #define ID_DATA MKTAG('D','a','t','a') // Game Sound Chunk 109 #define ID_CUE MKTAG('C','u','e','#') // Game Sound Chunk 110 111 // Common Resource FourCC's 112 #define ID_TBMP MKTAG('t','B','M','P') // Standard Mohawk Bitmap 113 #define ID_TWAV MKTAG('t','W','A','V') // Standard Mohawk Sound 114 #define ID_TPAL MKTAG('t','P','A','L') // Standard Mohawk Palette 115 #define ID_TCNT MKTAG('t','C','N','T') // Shape Count (CSWorld, CSAmtrak, JamesMath) 116 #define ID_TSCR MKTAG('t','S','C','R') // Script (CSWorld, CSAmtrak, Treehouse) 117 #define ID_STRL MKTAG('S','T','R','L') // String List (Zoombini, CSWorld, CSAmtrak) 118 #define ID_TBMH MKTAG('t','B','M','H') // Standard Mohawk Bitmap 119 #define ID_TMID MKTAG('t','M','I','D') // Standard Mohawk MIDI 120 #define ID_REGS MKTAG('R','E','G','S') // Registration Data - Shape Offsets (Zoombini, Treehouse) 121 #define ID_BYTS MKTAG('B','Y','T','S') // Byte Array? (Used as Database Entry in CSWorld, CSAmtrak) 122 #define ID_INTS MKTAG('I','N','T','S') // uint16 Array? (CSWorld, CSAmtrak) 123 #define ID_BBOX MKTAG('B','B','O','X') // Boxes? (CSWorld, CSAmtrak) 124 #define ID_SYSX MKTAG('S','Y','S','X') // MIDI Sysex 125 126 127 class Archive { 128 public: 129 Archive(); 130 virtual ~Archive(); 131 132 bool openFile(const Common::String &fileName); 133 virtual bool openStream(Common::SeekableReadStream *stream) = 0; 134 void close(); 135 isOpen()136 bool isOpen() const { return _stream != 0; } 137 138 bool hasResource(uint32 tag, uint16 id) const; 139 bool hasResource(uint32 tag, const Common::String &resName) const; 140 Common::SeekableReadStream *getResource(uint32 tag, uint16 id); 141 uint32 getOffset(uint32 tag, uint16 id) const; 142 uint16 findResourceID(uint32 tag, const Common::String &resName) const; 143 Common::String getName(uint32 tag, uint16 id) const; 144 145 Common::Array<uint32> getResourceTypeList() const; 146 Common::Array<uint16> getResourceIDList(uint32 type) const; 147 148 /** Offset the resource ids for a resource type by the specified amount */ 149 void offsetResourceIDs(uint32 type, uint16 startId, int16 increment); 150 protected: 151 Common::SeekableReadStream *_stream; 152 153 struct Resource { 154 uint32 offset; 155 uint32 size; 156 Common::String name; 157 }; 158 159 typedef Common::HashMap<uint16, Resource> ResourceMap; 160 typedef Common::HashMap<uint32, ResourceMap> TypeMap; 161 TypeMap _types; 162 }; 163 164 class MohawkArchive : public Archive { 165 public: MohawkArchive()166 MohawkArchive() : Archive() {} ~MohawkArchive()167 ~MohawkArchive() override {} 168 169 bool openStream(Common::SeekableReadStream *stream) override; 170 }; 171 172 class LivingBooksArchive_v1 : public Archive { 173 public: LivingBooksArchive_v1()174 LivingBooksArchive_v1() : Archive() {} ~LivingBooksArchive_v1()175 ~LivingBooksArchive_v1() override {} 176 177 bool openStream(Common::SeekableReadStream *stream) override; 178 }; 179 180 class DOSArchive_v2 : public Archive { 181 public: DOSArchive_v2()182 DOSArchive_v2() : Archive() {} ~DOSArchive_v2()183 ~DOSArchive_v2() override {} 184 185 bool openStream(Common::SeekableReadStream *stream) override; 186 }; 187 188 } // End of namespace Mohawk 189 190 #endif 191