ScummVM API documentation
files.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 VOYEUR_FILES_H
23#define VOYEUR_FILES_H
24
25#include "common/scummsys.h"
26#include "common/file.h"
27#include "common/rect.h"
28#include "common/str.h"
29#include "voyeur/screen.h"
30
31namespace Voyeur {
32
33class VoyeurEngine;
34class BoltFile;
35class BoltGroup;
36class BoltEntry;
37class RectResource;
38class PictureResource;
39class ViewPortResource;
40class ViewPortListResource;
41class FontResource;
42class CMapResource;
43class VInitCycleResource;
44class PtrResource;
45class ControlResource;
46class StateResource;
47class ThreadResource;
48
49#define DECOMPRESS_SIZE 0x7000
50
52public:
53 uint32 _id;
54 byte **_p;
55
56 ResolveEntry(uint32 id, byte **p) { _id = id; _p = p; }
57};
58
60public:
61 VoyeurEngine *_vm;
62 BoltFile *_curLibPtr;
63 BoltGroup *_curGroupPtr;
64 BoltEntry *_curMemberPtr;
65 int _bufferEnd;
66 int _bufferBegin;
67 int _bytesLeft;
68 int _bufSize;
69 byte *_bufStart;
70 byte *_bufPos;
71 byte _decompressBuf[DECOMPRESS_SIZE];
72 int _historyIndex;
73 byte _historyBuffer[0x200];
74 int _runLength;
75 bool _decompState;
76 int _runType;
77 int _runValue;
78 int _runOffset;
79 Common::File *_curFd;
81
82 byte *_boltPageFrame;
83public:
85
86 byte *decompress(byte *buf, int size, int mode);
87 void nextBlock();
88};
89
90class BoltFile {
91private:
93protected:
94 BoltFilesState &_state;
95
96 virtual void initResource(int resType) = 0;
97 void initDefault();
98private:
99 void resolveAll();
100 byte *getBoltMember(uint32 id);
101
102public:
103 Common::File _file;
104
105 BoltFile(const char *filename, BoltFilesState &state);
106 virtual ~BoltFile();
107
108 BoltGroup *getBoltGroup(uint16 id);
109 void freeBoltGroup(uint16 id);
110 void freeBoltMember(uint32 id);
111 byte *memberAddr(uint32 id);
112 byte *memberAddrOffset(uint32 id);
113 void resolveIt(uint32 id, byte **p);
114 void resolveFunction(uint32 id, ScreenMethodPtr *fn);
115
116 BoltEntry &boltEntry(uint16 id);
117 BoltEntry &getBoltEntryFromLong(uint32 id);
118 PictureResource *getPictureResource(uint32 id);
119 CMapResource *getCMapResource(uint32 id);
120};
121
122class BVoyBoltFile: public BoltFile {
123private:
124 // initType method table
125 void sInitRect();
126 void sInitPic();
127 void vInitCMap();
128 void vInitCycl();
129 void initViewPort();
130 void initViewPortList();
131 void initFontInfo();
132 void initFont();
133 void initSoundMap();
134protected:
135 void initResource(int resType) override;
136public:
138};
139
140class StampBoltFile: public BoltFile {
141private:
142 void initThread();
143 void initState();
144 void initPtr();
145 void initControl();
146protected:
147 void initResource(int resType) override;
148public:
150};
151
153private:
155public:
156 bool _loaded;
157 bool _processed;
158 int _count;
159 int _fileOffset;
161public:
163 virtual ~BoltGroup();
164
165 void load(uint16 groupId);
166 void unload();
167};
168
169
171private:
173public:
174 uint16 _id;
175 byte _mode;
176 byte _initMethod;
177 int _fileOffset;
178 int _size;
179 byte *_data;
180
181 // bvoy.blt resource types
182 RectResource *_rectResource;
183 PictureResource *_picResource;
184 ViewPortResource *_viewPortResource;
185 ViewPortListResource *_viewPortListResource;
186 FontResource *_fontResource;
187 FontInfoResource *_fontInfoResource;
188 CMapResource *_cMapResource;
189 VInitCycleResource *_vInitCycleResource;
190
191 // stampblt.blt resource types
192 PtrResource *_ptrResource;
193 ControlResource *_controlResource;
194 StateResource *_stateResource;
195 ThreadResource *_threadResource;
196public:
198 virtual ~BoltEntry();
199
200 void load();
201 bool hasResource() const;
202};
203
205public:
206 BoltFilesState *_boltFilesState;
207 BoltFile *_curLibPtr;
208public:
211
212 bool openBoltLib(const char *filename, BoltFile *&boltFile);
213 byte *fload(const char *filename, int *size);
214};
215
216class RectEntry: public Common::Rect {
217public:
218 int _arrIndex;
219 int _count;
220
221 RectEntry(int x1, int y1, int x2, int y2, int arrIndex, int count);
222};
223
225public:
227public:
228 RectResource(const byte *src, int size, bool isExtendedRects);
229 RectResource(int xp, int yp, int width, int height);
230 virtual ~RectResource() {}
231};
232
233/* bvoy.blt resource types */
234
235enum PictureFlag {
236 PICFLAG_2 = 2, PICFLAG_PIC_OFFSET = 8, PICFLAG_CLEAR_SCREEN = 0x10,
237 PICFLAG_20 = 0x20, PICFLAG_HFLIP = 0x40, PICFLAG_VFLIP = 0x80, PICFLAG_100 = 0x100,
238 PICFLAG_CLEAR_SCREEN00 = 0x1000
239};
240
241enum DisplayFlag {
242 DISPFLAG_1 = 1, DISPFLAG_2 = 2, DISPFLAG_4 = 4, DISPFLAG_8 = 8,
243 DISPFLAG_10 = 0x10, DISPFLAG_20 = 0x20, DISPFLAG_40 = 0x40, DISPFLAG_80 = 0x80,
244 DISPFLAG_100 = 0x100, DISPFLAG_200 = 0x200, DISPFLAG_400 = 0x400,
245 DISPFLAG_800 = 0x800, DISPFLAG_1000 = 0x1000, DISPFLAG_2000 = 0x2000,
246 DISPFLAG_4000 = 0x4000, DISPFLAG_VIEWPORT = 0x8000, DISPFLAG_CURSOR = 0x10000,
247 DISPFLAG_NONE = 0};
248
250protected:
251 VoyeurEngine *_vm;
252public:
253 uint32 _flags;
254public:
257
261 void sFillBox(int width, int height);
262
266 int drawText(const Common::String &msg);
267
271 int textWidth(const Common::String &msg);
272
277};
278
280private:
284 void flipHorizontal(const byte *data);
285
289 void flipVertical(const byte *data);
290public:
291 byte _select;
292 byte _pick;
293 byte _onOff;
294 Common::Rect _bounds;
295 uint32 _maskData;
296 uint _planeSize;
297 byte _keyColor;
298
302 byte *_imgData;
303
307 DisposeAfterUse::Flag _freeImgData;
308public:
309 PictureResource(BoltFilesState &state, const byte *src);
310 PictureResource(int flags, int select, int pick, int onOff,
311 const Common::Rect &bounds, int maskData, byte *imgData, int planeSize);
314 virtual ~PictureResource();
315};
316
317typedef void (ViewPortResource::*ViewPortMethodPtr)();
318
320private:
321 BoltFilesState &_state;
322private:
323 void setupViewPort(PictureResource *page, Common::Rect *clippingRect, ViewPortSetupPtr setupFn,
324 ViewPortAddPtr addFn, ViewPortRestorePtr restoreFn);
325public:
326 ViewPortResource *_parent;
327 ViewPortSetupPtr _setupFn;
328 int _pageCount;
329 ViewPortAddPtr _addFn;
330 int _pageIndex;
331 ViewPortRestorePtr _restoreFn;
332 int _lastPage;
333 ScreenMethodPtr _fn1;
334 Common::Rect _bounds;
335 PictureResource *_currentPic;
336 PictureResource *_activePage;
337 PictureResource *_pages[2];
338
339 // Rect lists and counts. Note that _rectListCount values of '-1' seem to have
340 // special significance, which is why I'm not making them redundant in favor
341 // of the arrays' .size() method
342 Common::Array<Common::Rect> *_rectListPtr[3];
343 int _rectListCount[3];
344
345 Common::Rect _clipRect;
346 Common::Rect _fontRect;
347public:
348 ViewPortResource(BoltFilesState &state, const byte *src);
349 virtual ~ViewPortResource();
350
351 void setupViewPort();
352 void setupViewPort(PictureResource *pic, Common::Rect *clippingRect = nullptr);
353 void addSaveRect(int pageIndex, const Common::Rect &r);
354 void fillPic(byte onOff);
355 void drawIfaceTime();
356 void drawPicPerm(PictureResource *pic, const Common::Point &pt);
357};
358
360public:
361 uint16 _rEntry, _gEntry, _bEntry;
362 uint16 _rChange, _gChange, _bChange;
363 uint16 _palIndex;
364public:
365 ViewPortPalEntry(const byte *src);
366};
367
369public:
372 int _palIndex;
373
374 ViewPortListResource(BoltFilesState &state, const byte *src);
375 virtual ~ViewPortListResource() {}
376};
377
379public:
380 int _minChar, _maxChar;
381 int _fontDepth;
382 int _padding;
383 int _fontHeight;
384 int _topPadding;
385 int *_charWidth;
386 byte *_charOffsets;
387 byte *_charImages;
388
389 FontResource(BoltFilesState &state, byte *src);
390 virtual ~FontResource();
391};
392
393enum FontJustify { ALIGN_LEFT = 0, ALIGN_CENTER = 1, ALIGN_RIGHT = 2 };
394
396public:
397 FontResource *_curFont;
398 byte _picFlags;
399 byte _picSelect;
400 byte _picPick;
401 byte _picOnOff;
402 byte _fontFlags;
403 FontJustify _justify;
404 int _fontSaveBack;
405 Common::Point _pos;
406 int _justifyWidth;
407 int _justifyHeight;
408 Common::Point _shadow;
409 int _foreColor;
410 int _backColor;
411 int _shadowColor;
412public:
413 FontInfoResource(BoltFilesState &state, const byte *src);
415 FontInfoResource(byte picFlags, byte picSelect, byte picPick, byte picOnOff, byte fontFlags,
416 FontJustify justify, int fontSaveBack, const Common::Point &pos, int justifyWidth,
417 int justifyHeight, const Common::Point &shadow, int foreColor, int backColor,
418 int shadowColor);
419};
420
422private:
423 VoyeurEngine *_vm;
424public:
425 int _steps;
426 int _fadeStatus;
427 int _start;
428 int _end;
429 byte *_entries;
430public:
431 CMapResource(BoltFilesState &state, const byte *src);
432 virtual ~CMapResource();
433
434 void startFade();
435};
436
438private:
439 BoltFilesState &_state;
440public:
441 int _type[4];
442 byte *_ptr[4];
443public:
444 VInitCycleResource(BoltFilesState &state, const byte *src);
445 virtual ~VInitCycleResource() {}
446
447 void vStartCycle();
448 void vStopCycle();
449};
450
451/* stampblt.blt resources */
452
454public:
456
457 PtrResource(BoltFilesState &state, const byte *src);
458 virtual ~PtrResource() {}
459};
460
462public:
463 int _memberIds[8];
464 byte *_entries[8];
465 int _stateId;
466 StateResource *_state;
467
468 ControlResource(BoltFilesState &state, const byte *src);
469 virtual ~ControlResource() {}
470};
471
476public:
477 int _vals[4];
478 int &_victimIndex;
479 int &_victimEvidenceIndex;
480 int &_victimMurderIndex;
481
482 StateResource(BoltFilesState &state, const byte *src);
483 virtual ~StateResource() {}
484
489};
490
492public:
493 static int _useCount[8];
494 static void initUseCount();
495 static void unloadAllStacks(VoyeurEngine *vm);
496
497 static void init();
498private:
499 VoyeurEngine *_vm;
500 Common::Point _aptPos;
501private:
502 bool getStateInfo();
503 byte *getDataOffset();
504 void getButtonsText();
505 void getButtonsFlags();
506 void performOpenCard();
507 const byte *getRecordOffset(const byte *p);
508 const byte *getNextRecord(const byte *p);
509 const byte *getSTAMPCard(int cardId);
510 int getStateFromID(uint32 id);
511 uint32 getSID(int sid);
512 void cardAction(const byte *p);
513 void doSTAMPCardAction();
514 bool goToStateID(int stackId, int id);
515 const byte *cardPerform(const byte *card);
516 bool cardPerform2(const byte *p, int cardCmdId);
517 void savePrevious();
518 void setButtonFlag(int idx, byte bits);
519 void clearButtonFlag(int idx, byte bits);
520
524 void freeTheApt();
525
529 void doAptAnim(int mode);
530
535 bool checkMansionScroll();
536public:
537 int _stateId;
538 int _stackId;
539 int _savedStateId;
540 int _savedStackId;
541 int _newStateId;
542 int _newStackId;
543 int _stateFlags;
544 int _stateCount;
545 int _parseCount;
546 uint32 _nextStateId;
547 byte *_threadInfoPtr;
548 byte _buttonFlags[64];
549 byte _buttonIds[64];
550 byte *_ctlPtr;
551 byte *_playCommandsPtr;
552
556 bool loadAStack(int stackId);
557
561 void unloadAStack(int stackId);
562
566 bool doState();
567
568public:
569 ThreadResource(BoltFilesState &state, const byte *src);
570 virtual ~ThreadResource() {}
571
575 void initThreadStruct(int idx, int id);
576
580 bool goToState(int stackId, int stateId);
581
582 bool chooseSTAMPButton(int buttonId);
583
588
593
598 void doRoom();
599
603 int doApt();
604
609
614};
615
616} // End of namespace Voyeur
617
618#endif /* VOYEUR_FILES_H */
Definition: array.h:52
Definition: file.h:47
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: files.h:122
Definition: files.h:170
Definition: files.h:90
Definition: files.h:59
Definition: files.h:152
Definition: files.h:421
Definition: files.h:461
Definition: files.h:249
void sFillBox(int width, int height)
int textWidth(const Common::String &msg)
int drawText(const Common::String &msg)
bool clipRect(Common::Rect &rect)
Definition: files.h:204
Definition: files.h:395
Definition: files.h:378
Definition: files.h:279
byte * _imgData
Definition: files.h:302
DisposeAfterUse::Flag _freeImgData
Definition: files.h:307
Definition: files.h:453
Definition: files.h:216
Definition: files.h:224
Definition: files.h:51
Definition: files.h:140
Definition: files.h:475
void synchronize(Common::Serializer &s)
Definition: files.h:491
void initThreadStruct(int idx, int id)
bool goToState(int stackId, int stateId)
void synchronize(Common::Serializer &s)
bool loadAStack(int stackId)
void unloadAStack(int stackId)
Definition: files.h:437
Definition: files.h:368
Definition: files.h:359
Definition: files.h:319
Definition: voyeur.h:78
Definition: animation.h:38
Definition: rect.h:144
int16 height() const
Definition: rect.h:218
int16 width() const
Definition: rect.h:217
Definition: rect.h:536
Definition: surface.h:67