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 SNATCHER_RESOURCE_H
23#define SNATCHER_RESOURCE_H
24
25#include "common/fs.h"
26#include "common/scummsys.h"
27#include "snatcher/state.h"
28
29namespace Common {
30class SeekableReadStream;
31class SeekableReadStreamEndian;
32} // End of namespace Common
33
34namespace Snatcher {
35
36class SnatcherEngine;
37class SceneModule;
38class FanTranslationHandler;
39class FIO;
40
42public:
43 SceneHandler(SnatcherEngine *vm, SceneModule *scn, FIO *fio) : _vm(vm), _module(scn), _fio(fio) {}
44 virtual ~SceneHandler() {}
45 virtual void operator()(GameState &state) = 0;
46protected:
47 SnatcherEngine *_vm;
48 SceneModule *_module;
49 FIO *_fio;
50};
51
53public:
55 explicit ResourcePointer(const uint8 *data, uint32 dataSize, uint32 offs, uint32 loc, bool assignBufferOwnership = false);
56 explicit ResourcePointer(uint8 *data, uint32 dataSize, uint32 offs, uint32 loc, bool assignBufferOwnership = false);
58 ResourcePointer(ResourcePointer &&ptr) noexcept;
60
61 const uint8 *operator()() const;
62 const uint8 *operator++(int);
63 const uint8 *operator++();
64 uint16 readUINT16() const;
65 uint16 readSINT16() const;
66 uint32 readUINT32() const;
67 uint32 readSINT32() const;
68 uint16 readIncrUINT16();
69 uint16 readIncrSINT16();
70 uint32 readIncrUINT32();
71 uint32 readIncrSINT32();
72 void writeUINT16(uint16 value);
73 void writeUINT32(uint32 value);
74 ResourcePointer operator+(int inc) const;
75 bool operator<(const ResourcePointer &ptr) const;
76 bool operator>(const ResourcePointer &ptr) const;
77 bool operator==(const ResourcePointer &ptr) const;
78 void operator+=(int inc);
79 void operator=(const uint8 *ptr);
80 void operator=(const ResourcePointer &ptr);
81 void operator=(ResourcePointer &&ptr) noexcept;
82 uint8 operator[](int index) const;
83 ResourcePointer getDataFromTable(int tableEntry) const;
84 ResourcePointer makePtr(uint32 offs) const;
85private:
86 void checkOffset(int extraBytes, const char *caller) const;
87
88 const uint8 *_dataStart;
89 uint32 _dataSize;
90 uint8 *_writeableDataStart;
91 uint32 _offset;
92 uint32 _moduleLocation;
93 bool _ownBuffer;
94};
95
97 friend class FIO;
98public:
100
101 ResourcePointer getPtr(int offset) const;
102 ResourcePointer getGfxData() const;
103
104 void run(GameState &state);
105
106private:
107 SceneModule(SnatcherEngine *vm, FIO *fio, const char *resFile, int index);
108
109 const uint8 *_data;
110 uint32 _dataSize;
111 SnatcherEngine *_vm;
112 FIO *_fio;
113 const int _resIndex;
114 Common::Path _resFile;
115 SceneHandler *_updateHandler;
116
117 typedef SceneHandler*(SHFactory)(SnatcherEngine*, SceneModule*, FIO*);
118 static SHFactory *const _shList[97];
119};
120
121class FIO {
122public:
123 FIO(SnatcherEngine *vm);
124 ~FIO();
125
126 SceneModule *loadModule(int index);
127 uint8 *fileData(int index, uint32 *fileSize);
128 uint8 *fileData(const Common::Path &file, uint32 *fileSize);
129 bool loadingCompleted();
130 Common::SeekableReadStream *readStream(int index);
131 Common::SeekableReadStream *readStream(const Common::Path &file);
132
133private:
134 Common::SearchSet _files;
135 SnatcherEngine *_vm;
136 uint32 _loadingTimer;
137
138private:
139 static const char *_resFileList[97];
140 static const int _resFileListSize;
141};
142
143} // End of namespace Snatcher
144
145#endif // SNATCHER_RESOURCE_H
Definition: path.h:52
Definition: archive.h:330
Definition: stream.h:745
Definition: resource.h:121
Definition: resource.h:52
Definition: resource.h:41
Definition: resource.h:96
Definition: snatcher.h:50
Definition: algorithm.h:29
Definition: state.h:94