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#ifndef HOLLYWOOD_RESOURCE_H
23#define HOLLYWOOD_RESOURCE_H
24
25#include "common/array.h"
26#include "common/file.h"
27#include "common/path.h"
28#include "common/types.h"
29
30namespace Graphics {
31class ManagedSurface;
32}
33
34namespace Hollywood {
35
36// Bounded little-endian reads shared by the archive and scene-data decoders.
37uint16 readUint16LE(const Common::Array<byte> &source, uint offset);
38int16 readSint16LE(const Common::Array<byte> &source, uint offset);
39uint32 readUint32LE(const Common::Array<byte> &source, uint offset);
40
41enum {
42 kResourceChunkCount = 40,
43 kMaxResourceChunkCount = 50
44};
45
47 uint32 offsets[kMaxResourceChunkCount];
48 uint32 sizes[kMaxResourceChunkCount];
49 uint count = 0;
50
51 void clear();
52 bool load(Common::SeekableReadStream &stream, uint chunkCount = kResourceChunkCount);
53 bool isValidChunk(uint index) const;
54};
55
56Common::SeekableReadStream *createResourceChunkReadStream(const Common::Path &fileName, uint index);
57
58// Keeps a RESOURCE.* archive open and reads chunks through its parsed table.
60public:
62
63 bool open(const Common::Path &fileName, uint chunkCount = kResourceChunkCount);
64 void close();
65
66 const Common::Path &fileName() const { return _fileName; }
67 const ResourceChunkTable &chunkTable() const { return _chunkTable; }
68 bool isValidChunk(uint index) const { return _chunkTable.isValidChunk(index); }
69 uint32 chunkSize(uint index) const;
70 uint32 totalChunkSize(uint firstChunk, uint lastChunk) const;
71
72 bool readFixedChunk(uint index, Common::Array<byte> &destination, uint fixedSize,
73 const char *debugName);
74 bool readFixedChunk(uint index, Graphics::ManagedSurface &destination, uint fixedSize,
75 const char *debugName);
76 bool readFixedChunk(uint index, byte *destination, uint destinationSize,
77 uint fixedSize, const char *debugName);
78 bool readVariableChunk(uint index, Common::Array<byte> &destination);
79 bool readChunkTo(uint index, Common::Array<byte> &destination, uint32 destinationOffset);
80
81private:
82 bool chunkBounds(uint index, uint32 &offset, uint32 &size) const;
83 bool readChunkBytes(uint index, byte *destination, uint32 destinationSize);
84
85 Common::File _file;
86 Common::Path _fileName;
87 ResourceChunkTable _chunkTable;
88 bool _open;
89};
90
91} // End of namespace Hollywood
92
93#endif // HOLLYWOOD_RESOURCE_H
Definition: file.h:47
Definition: path.h:52
Definition: stream.h:745
Definition: managed_surface.h:51
Definition: resource.h:59
Definition: formatinfo.h:28
Definition: resource.h:46