1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MYST3_ARCHIVE_H
#define MYST3_ARCHIVE_H
#include "common/array.h"
#include "common/file.h"
#include "math/vector3d.h"
namespace Myst3 {
class ArchiveVisitor;
class ResourceDescription;
typedef Common::Array<ResourceDescription> ResourceDescriptionArray;
class Archive {
public:
enum ResourceType {
kCubeFace = 0,
kWaterEffectMask = 1,
kLavaEffectMask = 2,
kMagneticEffectMask = 3,
kShieldEffectMask = 4,
kSpotItem = 5,
kFrame = 6,
kRawData = 7,
kMovie = 8,
kStillMovie = 10,
kText = 11,
kTextMetadata = 12,
kNumMetadata = 13,
kLocalizedSpotItem = 69,
kLocalizedFrame = 70,
kMultitrackMovie = 72,
kDialogMovie = 74
};
struct DirectorySubEntry {
uint32 offset;
uint32 size;
byte face;
ResourceType type;
Common::Array<uint32> metadata;
DirectorySubEntry() : offset(0), size(0), face(0), type(kCubeFace) {}
};
struct DirectoryEntry {
Common::String roomName;
uint32 index;
Common::Array<DirectorySubEntry> subentries;
DirectoryEntry() : index(0) {}
};
ResourceDescription getDescription(const Common::String &room, uint32 index, uint16 face,
ResourceType type);
ResourceDescriptionArray listFilesMatching(const Common::String &room, uint32 index, uint16 face,
ResourceType type);
Common::SeekableReadStream *dumpToMemory(uint32 offset, uint32 size);
uint32 copyTo(uint32 offset, uint32 size, Common::WriteStream &out);
void visit(ArchiveVisitor &visitor);
bool open(const char *fileName, const char *room);
void close();
const Common::String &getRoomName() const { return _roomName; }
uint32 getDirectorySize() const { return _directorySize; }
private:
Common::String _roomName;
Common::File _file;
uint32 _directorySize;
Common::Array<DirectoryEntry> _directory;
void decryptHeader(Common::SeekableReadStream &inStream, Common::WriteStream &outStream);
void readDirectory();
DirectorySubEntry readSubEntry(Common::ReadStream &stream);
DirectoryEntry readEntry(Common::ReadStream &stream);
const DirectoryEntry *getEntry(const Common::String &room, uint32 index) const;
};
class ResourceDescription {
public:
struct SpotItemData {
uint32 u;
uint32 v;
};
struct VideoData {
Math::Vector3d v1;
Math::Vector3d v2;
int32 u;
int32 v;
int32 width;
int32 height;
};
ResourceDescription();
ResourceDescription(Archive *archive, const Archive::DirectorySubEntry &subentry);
bool isValid() const { return _archive && _subentry; }
Common::SeekableReadStream *getData() const;
uint16 getFace() const { return _subentry->face; }
Archive::ResourceType getType() const { return _subentry->type; }
SpotItemData getSpotItemData() const;
VideoData getVideoData() const;
uint32 getMiscData(uint index) const;
Common::String getTextData(uint index) const;
private:
Archive *_archive;
const Archive::DirectorySubEntry *_subentry;
};
class ArchiveVisitor {
public:
virtual ~ArchiveVisitor();
virtual void visitArchive(Archive &archive) {}
virtual void visitDirectoryEntry(Archive::DirectoryEntry &directoryEntry) {}
virtual void visitDirectorySubEntry(Archive::DirectorySubEntry &directorySubEntry) {}
};
} // End of namespace Myst3
#endif
|