ScummVM API documentation
disk.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 PARALLACTION_DISK_H
23 #define PARALLACTION_DISK_H
24 
25 #define PATH_LEN 200
26 
27 #include "common/archive.h"
28 #include "common/str.h"
29 
30 namespace Common {
31 class FSDirectory;
32 class ReadStream;
33 class SeekableReadStream;
34 }
35 
36 namespace Graphics {
37 struct Surface;
38 }
39 
40 namespace Parallaction {
41 
42 class Table;
43 class Parallaction;
44 class Gfx;
45 class Script;
46 class Font;
47 
48 struct Frames;
49 struct Cnv;
50 struct Sprites;
51 struct BackgroundInfo;
52 class GfxObj;
53 struct MaskBuffer;
54 struct PathBuffer;
55 
56 class Disk {
57 
58 public:
59  Disk() { }
60  virtual ~Disk() { }
61 
62  virtual void init() { }
63 
64  virtual Common::String selectArchive(const Common::String &name) = 0;
65  virtual void setLanguage(uint16 language) = 0;
66 
67  virtual Script* loadLocation(const char *name) = 0;
68  virtual Script* loadScript(const char* name) = 0;
69  virtual GfxObj* loadTalk(const char *name) = 0;
70  virtual GfxObj* loadObjects(const char *name, uint8 part = 0) = 0;
71  virtual Frames* loadPointer(const char *name) = 0;
72  virtual GfxObj* loadHead(const char* name) = 0;
73  virtual Font* loadFont(const char* name) = 0;
74  virtual GfxObj* loadStatic(const char* name) = 0;
75  virtual Frames* loadFrames(const char* name) = 0;
76  virtual void loadSlide(BackgroundInfo& info, const char *filename) = 0;
77  virtual void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) = 0;
78  virtual Table* loadTable(const char* name) = 0;
79  virtual Common::SeekableReadStream* loadMusic(const char* name) = 0;
80  virtual Common::SeekableReadStream* loadSound(const char* name) = 0;
81  virtual MaskBuffer *loadMask(const char *name, uint32 w, uint32 h) { return 0; }
82  virtual PathBuffer *loadPath(const char *name, uint32 w, uint32 h) { return 0; }
83 };
84 
85 class Disk_ns : public Disk {
86 
87 protected:
88  Parallaction *_vm;
89 
90  Common::SearchSet _sset;
91 
92  Common::String _resArchiveName;
93  Common::String _language;
94  Common::SeekableReadStream *openFile(const char *filename);
95  virtual Common::SeekableReadStream *tryOpenFile(const char *filename) { return 0; }
96  void errorFileNotFound(const char *filename);
97 
98  void addArchive(const Common::String& name, int priority);
99 
100  virtual void decodeCnv(byte *data, uint16 numFrames, uint16 width, uint16 height, Common::SeekableReadStream *stream) = 0;
101  Cnv *makeCnv(Common::SeekableReadStream *stream);
102 
103 public:
104  Disk_ns(Parallaction *vm);
105  ~Disk_ns() override;
106 
107  Common::String selectArchive(const Common::String &name) override;
108  void setLanguage(uint16 language) override;
109 
110  Script* loadLocation(const char *name) override;
111  Script* loadScript(const char* name) override;
112 };
113 
114 class DosDisk_ns : public Disk_ns {
115 
116 private:
117  void unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path);
118  Cnv* loadCnv(const char *filename);
119  void loadBackground(BackgroundInfo& info, const char *filename);
120  void createMaskAndPathBuffers(BackgroundInfo &info);
121  void parseDepths(BackgroundInfo &info, Common::SeekableReadStream &stream);
122  Font *createFont(const char *name, Cnv* cnv);
123 
124 protected:
125  Gfx *_gfx;
126  Common::SeekableReadStream *tryOpenFile(const char* name) override;
127  void decodeCnv(byte *data, uint16 numFrames, uint16 width, uint16 height, Common::SeekableReadStream *stream) override;
128 
129 public:
131  ~DosDisk_ns() override;
132 
133  void init() override;
134 
135  GfxObj* loadTalk(const char *name) override;
136  GfxObj* loadObjects(const char *name, uint8 part = 0) override;
137  Frames* loadPointer(const char *name) override;
138  GfxObj* loadHead(const char* name) override;
139  Font* loadFont(const char* name) override;
140  GfxObj* loadStatic(const char* name) override;
141  Frames* loadFrames(const char* name) override;
142  void loadSlide(BackgroundInfo& info, const char *filename) override;
143  void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) override;
144  Table* loadTable(const char* name) override;
145  Common::SeekableReadStream* loadMusic(const char* name) override;
146  Common::SeekableReadStream* loadSound(const char* name) override;
147 };
148 
149 class AmigaDisk_ns : public Disk_ns {
150 
151 protected:
152  void patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height);
153  void unpackFrame(byte *dst, byte *src, uint16 planeSize);
154  void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height);
155  Common::SeekableReadStream *tryOpenFile(const char* name) override;
156  Font *createFont(const char *name, Common::SeekableReadStream &stream);
157  void loadMask_internal(BackgroundInfo& info, const char *name);
158  void loadPath_internal(BackgroundInfo& info, const char *name);
159  void loadBackground(BackgroundInfo& info, const char *name);
160  void buildMask(byte* buf);
161 
162  void decodeCnv(byte *data, uint16 numFrames, uint16 width, uint16 height, Common::SeekableReadStream *stream) override;
163 
164 public:
166  ~AmigaDisk_ns() override;
167 
168  void init() override;
169 
170  GfxObj* loadTalk(const char *name) override;
171  GfxObj* loadObjects(const char *name, uint8 part = 0) override;
172  Frames* loadPointer(const char *name) override;
173  GfxObj* loadHead(const char* name) override;
174  Font* loadFont(const char* name) override;
175  GfxObj* loadStatic(const char* name) override;
176  Frames* loadFrames(const char* name) override;
177  void loadSlide(BackgroundInfo& info, const char *filename) override;
178  void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) override;
179  Table* loadTable(const char* name) override;
180  Common::SeekableReadStream* loadMusic(const char* name) override;
181  Common::SeekableReadStream* loadSound(const char* name) override;
182 };
183 
184 
185 class Disk_br : public Disk {
186 
187  Common::SeekableReadStream *openFile_internal(bool errorOnNotFound, const Common::String &name, const Common::String &ext);
188 
189 protected:
190  Parallaction *_vm;
191  Common::SearchSet _sset;
192  Common::FSDirectory *_baseDir;
193 
194  uint16 _language;
195  Common::String _currentPart;
196 
197  Common::SeekableReadStream *tryOpenFile(const Common::String &name, const Common::String &ext = Common::String());
198  Common::SeekableReadStream *openFile(const Common::String &name, const Common::String &ext = Common::String());
199  void errorFileNotFound(const Common::String &filename);
200 
201 public:
202  Disk_br(Parallaction *vm);
203  ~Disk_br() override;
204 };
205 
206 // for the moment DosDisk_br subclasses Disk. When Amiga support will
207 // be taken into consideration, it might be useful to add another level
208 // like we did for Nippon Safes.
209 class DosDisk_br : public Disk_br {
210 
211 protected:
212  Font *createFont(const char *name, Common::ReadStream &stream);
213  Sprites* createSprites(Common::ReadStream *stream);
214  void loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette);
215  GfxObj* createInventoryObjects(Common::SeekableReadStream &stream);
216 
217 public:
219 
220  void init() override;
221 
222  Common::String selectArchive(const Common::String &name) override;
223  void setLanguage(uint16 language) override;
224  Script* loadLocation(const char *name) override;
225  Script* loadScript(const char* name) override;
226  GfxObj* loadTalk(const char *name) override;
227  GfxObj* loadObjects(const char *name, uint8 part = 0) override;
228  Frames* loadPointer(const char *name) override;
229  GfxObj* loadHead(const char* name) override;
230  Font* loadFont(const char* name) override;
231  GfxObj* loadStatic(const char* name) override;
232  Frames* loadFrames(const char* name) override;
233  void loadSlide(BackgroundInfo& info, const char *filename) override;
234  void loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path) override;
235  Table* loadTable(const char* name) override;
236  Common::SeekableReadStream* loadMusic(const char* name) override;
237  Common::SeekableReadStream* loadSound(const char* name) override;
238  MaskBuffer *loadMask(const char *name, uint32 w, uint32 h) override;
239  PathBuffer *loadPath(const char *name, uint32 w, uint32 h) override;
240 };
241 
242 class DosDemoDisk_br : public DosDisk_br {
243 
244 public:
246 
247  void init() override;
248 
249  Common::String selectArchive(const Common::String& name) override;
250 };
251 
252 class AmigaDisk_br : public DosDisk_br {
253 
254 protected:
255  Sprites* createSprites(Common::ReadStream *stream);
256  Font *createFont(const char *name, Common::SeekableReadStream &stream);
257  void loadBackground(BackgroundInfo& info, const char *filename);
258  void adjustForPalette(Graphics::Surface &surf, int transparentColor = -1);
259 
260 public:
262 
263  void init() override;
264 
265  Common::String selectArchive(const Common::String& name) override;
266  GfxObj* loadTalk(const char *name) override;
267  Font* loadFont(const char* name) override;
268  GfxObj* loadStatic(const char* name) override;
269  Frames* loadFrames(const char* name) override;
270  void loadSlide(BackgroundInfo& info, const char *filename) override;
271  void loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path) override;
272  GfxObj* loadObjects(const char *name, uint8 part = 0) override;
273  Common::SeekableReadStream* loadMusic(const char* name) override;
274  Common::SeekableReadStream* loadSound(const char* name) override;
275  MaskBuffer *loadMask(const char *name, uint32 w, uint32 h) override;
276 };
277 
278 } // namespace Parallaction
279 
280 
281 
282 #endif
Definition: disk.h:252
Definition: str.h:59
Definition: surface.h:67
Definition: graphics.h:431
Definition: parser.h:35
Definition: stream.h:745
Definition: disk.h:85
Definition: disk.h:56
Definition: graphics.h:194
Definition: debug.h:8
Definition: disk.h:149
Definition: archive.h:312
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: graphics.h:352
Definition: disk.h:209
Definition: graphics.h:220
Definition: disk.h:114
Definition: graphics.h:124
Definition: stream.h:385
Definition: fs.h:341
Definition: graphics.h:53
Definition: disk.h:242
Definition: lobject.h:338
Definition: graphics.h:300
Definition: disk.h:185
Definition: graphics.h:73
Definition: objects.h:509