ScummVM API documentation
datarchive.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 GNAP_DATARCHIVE_H
23 #define GNAP_DATARCHIVE_H
24 
25 #include "common/array.h"
26 #include "common/events.h"
27 #include "common/file.h"
28 #include "common/memstream.h"
29 #include "common/random.h"
30 #include "common/str.h"
31 #include "common/substream.h"
32 #include "common/system.h"
33 #include "engines/engine.h"
34 
35 namespace Gnap {
36 
37 struct DatEntry {
38  uint32 _ofs;
39  uint32 _outSize1;
40  uint32 _type;
41  uint32 _outSize2;
42 };
43 
44 class DatArchive {
45 public:
46  DatArchive(const char *filename);
47  ~DatArchive();
48  byte *load(int index);
49  int getCount() const { return _entriesCount; }
50  uint32 getEntryType(int index) { return _entries[index]._type; }
51  uint32 getEntrySize(int index) { return _entries[index]._outSize1; }
52 protected:
53  Common::File *_fd;
54  int _entriesCount;
55  DatEntry *_entries;
56 };
57 
58 const int kMaxDatArchives = 2;
59 
60 class DatManager {
61 public:
62  DatManager();
63  ~DatManager();
64  void open(int index, const char *filename);
65  void close(int index);
66  byte *loadResource(int resourceId);
67  uint32 getResourceType(int resourceId);
68  uint32 getResourceSize(int resourceId);
69 protected:
70  DatArchive *_datArchives[kMaxDatArchives];
71 };
72 
73 int ridToDatIndex(int resourceId);
74 int ridToEntryIndex(int resourceId);
75 int makeRid(int datIndex, int entryIndex);
76 
77 } // End of namespace Gnap
78 
79 #endif // GNAP_DATARCHIVE_H
Definition: datarchive.h:37
Definition: datarchive.h:60
Definition: file.h:47
Definition: datarchive.h:44
Definition: character.h:25