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