ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

archive.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef MYST3_ARCHIVE_H
00024 #define MYST3_ARCHIVE_H
00025 
00026 #include "common/array.h"
00027 #include "common/file.h"
00028 
00029 #include "math/vector3d.h"
00030 
00031 namespace Myst3 {
00032 
00033 class ArchiveVisitor;
00034 class ResourceDescription;
00035 
00036 typedef Common::Array<ResourceDescription> ResourceDescriptionArray;
00037 
00038 class Archive {
00039 public:
00040     enum ResourceType {
00041         kCubeFace           =  0,
00042         kWaterEffectMask    =  1,
00043         kLavaEffectMask     =  2,
00044         kMagneticEffectMask =  3,
00045         kShieldEffectMask   =  4,
00046         kSpotItem           =  5,
00047         kFrame              =  6,
00048         kRawData            =  7,
00049         kMovie              =  8,
00050         kStillMovie         = 10,
00051         kText               = 11,
00052         kTextMetadata       = 12,
00053         kNumMetadata        = 13,
00054         kLocalizedSpotItem  = 69,
00055         kLocalizedFrame     = 70,
00056         kMultitrackMovie    = 72,
00057         kDialogMovie        = 74
00058     };
00059 
00060     struct DirectorySubEntry {
00061         uint32 offset;
00062         uint32 size;
00063         byte face;
00064         ResourceType type;
00065         Common::Array<uint32> metadata;
00066 
00067         DirectorySubEntry() : offset(0), size(0), face(0), type(kCubeFace) {}
00068     };
00069 
00070     struct DirectoryEntry {
00071         Common::String roomName;
00072         uint32 index;
00073         Common::Array<DirectorySubEntry> subentries;
00074 
00075         DirectoryEntry() : index(0) {}
00076     };
00077 
00078     ResourceDescription getDescription(const Common::String &room, uint32 index, uint16 face,
00079                                        ResourceType type);
00080     ResourceDescriptionArray listFilesMatching(const Common::String &room, uint32 index, uint16 face,
00081                                                ResourceType type);
00082 
00083     Common::SeekableReadStream *dumpToMemory(uint32 offset, uint32 size);
00084     uint32 copyTo(uint32 offset, uint32 size, Common::WriteStream &out);
00085     void visit(ArchiveVisitor &visitor);
00086 
00087     bool open(const char *fileName, const char *room);
00088     void close();
00089 
00090     const Common::String &getRoomName() const { return _roomName; }
00091     uint32 getDirectorySize() const { return _directorySize; }
00092 
00093 private:
00094     Common::String _roomName;
00095     Common::File _file;
00096     uint32 _directorySize;
00097     Common::Array<DirectoryEntry> _directory;
00098 
00099     void decryptHeader(Common::SeekableReadStream &inStream, Common::WriteStream &outStream);
00100     void readDirectory();
00101     DirectorySubEntry readSubEntry(Common::ReadStream &stream);
00102     DirectoryEntry readEntry(Common::ReadStream &stream);
00103     const DirectoryEntry *getEntry(const Common::String &room, uint32 index) const;
00104 };
00105 
00106 class ResourceDescription {
00107 public:
00108     struct SpotItemData {
00109         uint32 u;
00110         uint32 v;
00111     };
00112 
00113     struct VideoData {
00114         Math::Vector3d v1;
00115         Math::Vector3d v2;
00116         int32 u;
00117         int32 v;
00118         int32 width;
00119         int32 height;
00120     };
00121 
00122     ResourceDescription();
00123     ResourceDescription(Archive *archive, const Archive::DirectorySubEntry &subentry);
00124 
00125     bool isValid() const { return _archive && _subentry; }
00126 
00127     Common::SeekableReadStream *getData() const;
00128     uint16 getFace() const { return _subentry->face; }
00129     Archive::ResourceType getType() const { return _subentry->type; }
00130     SpotItemData getSpotItemData() const;
00131     VideoData getVideoData() const;
00132     uint32 getMiscData(uint index) const;
00133     Common::String getTextData(uint index) const;
00134 
00135 private:
00136     Archive *_archive;
00137     const Archive::DirectorySubEntry *_subentry;
00138 };
00139 
00140 class ArchiveVisitor {
00141 public:
00142     virtual ~ArchiveVisitor();
00143 
00144     virtual void visitArchive(Archive &archive) {}
00145     virtual void visitDirectoryEntry(Archive::DirectoryEntry &directoryEntry) {}
00146     virtual void visitDirectorySubEntry(Archive::DirectorySubEntry &directorySubEntry) {}
00147 };
00148 
00149 } // End of namespace Myst3
00150 
00151 #endif


Generated on Sat Jul 11 2020 05:01:05 for ResidualVM by doxygen 1.7.1
curved edge   curved edge