2013-05-20 02:45:54 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VOYEUR_FILES_H
|
|
|
|
#define VOYEUR_FILES_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/file.h"
|
2013-05-25 19:36:57 +00:00
|
|
|
#include "common/rect.h"
|
2013-05-20 02:45:54 +00:00
|
|
|
#include "common/str.h"
|
2013-05-30 03:21:07 +00:00
|
|
|
#include "voyeur/graphics.h"
|
2013-05-20 02:45:54 +00:00
|
|
|
|
|
|
|
namespace Voyeur {
|
|
|
|
|
|
|
|
class VoyeurEngine;
|
2013-05-25 13:58:03 +00:00
|
|
|
class BoltFile;
|
2013-05-20 02:45:54 +00:00
|
|
|
class BoltGroup;
|
|
|
|
class BoltEntry;
|
2013-05-25 19:36:57 +00:00
|
|
|
class PictureResource;
|
2013-05-26 03:30:48 +00:00
|
|
|
class ViewPortResource;
|
2013-05-27 02:18:54 +00:00
|
|
|
class ViewPortListResource;
|
2013-05-28 03:01:15 +00:00
|
|
|
class FontResource;
|
|
|
|
class CMapResource;
|
|
|
|
class VInitCyclResource;
|
2013-05-26 03:30:48 +00:00
|
|
|
|
2013-05-22 03:15:43 +00:00
|
|
|
#define DECOMPRESS_SIZE 0x7000
|
2013-05-20 02:45:54 +00:00
|
|
|
|
2013-05-25 13:58:03 +00:00
|
|
|
typedef void (BoltFile::*BoltMethodPtr)();
|
|
|
|
|
2013-05-26 03:30:48 +00:00
|
|
|
class ResolveEntry {
|
|
|
|
public:
|
|
|
|
uint32 _id;
|
|
|
|
byte **_p;
|
|
|
|
|
|
|
|
ResolveEntry(uint32 id, byte **p) { _id = id; _p = p; }
|
|
|
|
};
|
|
|
|
|
2013-05-25 19:36:57 +00:00
|
|
|
class BoltFilesState {
|
|
|
|
public:
|
2013-05-26 00:51:53 +00:00
|
|
|
VoyeurEngine *_vm;
|
2013-05-25 19:36:57 +00:00
|
|
|
BoltFile *_curLibPtr;
|
|
|
|
BoltGroup *_curGroupPtr;
|
|
|
|
BoltEntry *_curMemberPtr;
|
|
|
|
byte *_curMemInfoPtr;
|
|
|
|
int _fromGroupFlag;
|
|
|
|
byte _xorMask;
|
|
|
|
bool _encrypt;
|
|
|
|
int _curFilePosition;
|
|
|
|
int _bufferEnd;
|
|
|
|
int _bufferBegin;
|
|
|
|
int _bytesLeft;
|
|
|
|
int _bufSize;
|
|
|
|
byte *_bufStart;
|
|
|
|
byte *_bufPos;
|
|
|
|
byte _decompressBuf[DECOMPRESS_SIZE];
|
|
|
|
int _historyIndex;
|
|
|
|
byte _historyBuffer[0x200];
|
|
|
|
int _runLength;
|
|
|
|
int _decompState;
|
|
|
|
int _runType;
|
|
|
|
int _runValue;
|
|
|
|
int _runOffset;
|
2013-05-26 00:51:53 +00:00
|
|
|
Common::File *_curFd;
|
2013-05-26 03:30:48 +00:00
|
|
|
Common::Array<ResolveEntry> _resolves;
|
2013-05-26 00:51:53 +00:00
|
|
|
|
|
|
|
byte *_boltPageFrame;
|
|
|
|
int _sImageShift;
|
|
|
|
bool _SVGAReset;
|
2013-05-25 19:36:57 +00:00
|
|
|
public:
|
|
|
|
BoltFilesState();
|
|
|
|
|
|
|
|
byte *decompress(byte *buf, int size, int mode);
|
|
|
|
void nextBlock();
|
2013-05-26 00:51:53 +00:00
|
|
|
|
|
|
|
void EMSGetFrameAddr(byte **pageFrame) {} // TODO: Maybe?
|
|
|
|
bool EMSAllocatePages(uint *planeSize) { return false; } // TODO: Maybe?
|
|
|
|
void EMSMapPageHandle(int planeSize, int idx1, int idx2) {} // TODO: Maybe?
|
2013-05-25 19:36:57 +00:00
|
|
|
};
|
|
|
|
|
2013-05-20 02:45:54 +00:00
|
|
|
class BoltFile {
|
|
|
|
private:
|
2013-05-25 13:58:03 +00:00
|
|
|
static const BoltMethodPtr _fnInitType[25];
|
2013-05-20 02:45:54 +00:00
|
|
|
private:
|
2013-05-25 19:36:57 +00:00
|
|
|
BoltFilesState &_state;
|
2013-05-20 02:45:54 +00:00
|
|
|
Common::Array<BoltGroup> _groups;
|
2013-05-26 00:51:53 +00:00
|
|
|
Common::File _file;
|
2013-05-22 02:07:17 +00:00
|
|
|
|
2013-05-25 13:58:03 +00:00
|
|
|
// initType method table
|
|
|
|
void initDefault();
|
|
|
|
void sInitPic();
|
|
|
|
void vInitCMap();
|
|
|
|
void vInitCycl();
|
|
|
|
void initViewPort();
|
|
|
|
void initViewPortList();
|
|
|
|
void initFontInfo();
|
2013-06-15 15:39:28 +00:00
|
|
|
void initFont();
|
2013-05-25 13:58:03 +00:00
|
|
|
void initSoundMap();
|
2013-05-20 02:45:54 +00:00
|
|
|
private:
|
2013-05-26 03:30:48 +00:00
|
|
|
void resolveAll();
|
2013-05-21 01:18:40 +00:00
|
|
|
byte *getBoltMember(uint32 id);
|
2013-05-20 02:45:54 +00:00
|
|
|
|
2013-05-26 03:30:48 +00:00
|
|
|
void termType() {} // TODO
|
|
|
|
void initMem(int id) {} // TODO
|
|
|
|
void termMem() {} // TODO
|
|
|
|
void initGro() {} // TODO
|
|
|
|
void termGro() {} // TODO
|
2013-05-21 01:18:40 +00:00
|
|
|
public:
|
2013-05-25 19:36:57 +00:00
|
|
|
BoltFile(BoltFilesState &state);
|
2013-05-21 01:18:40 +00:00
|
|
|
~BoltFile();
|
|
|
|
|
|
|
|
bool getBoltGroup(uint32 id);
|
2013-06-06 01:28:51 +00:00
|
|
|
void freeBoltGroup(uint32 id);
|
2013-05-21 01:18:40 +00:00
|
|
|
byte *memberAddr(uint32 id);
|
2013-05-26 03:30:48 +00:00
|
|
|
byte *memberAddrOffset(uint32 id);
|
|
|
|
void resolveIt(uint32 id, byte **p);
|
2013-05-30 03:21:07 +00:00
|
|
|
void resolveFunction(uint32 id, GraphicMethodPtr *fn);
|
2013-05-29 03:57:16 +00:00
|
|
|
|
2013-06-15 15:39:28 +00:00
|
|
|
BoltEntry &boltEntry(uint16 id);
|
|
|
|
BoltEntry &getBoltEntryFromLong(uint32 id);
|
2013-06-13 02:13:52 +00:00
|
|
|
PictureResource *getPictureResource(uint32 id);
|
2013-06-06 01:28:51 +00:00
|
|
|
CMapResource *getCMapResource(uint32 id);
|
2013-05-20 02:45:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BoltGroup {
|
|
|
|
private:
|
|
|
|
Common::SeekableReadStream *_file;
|
|
|
|
public:
|
2013-05-22 02:07:17 +00:00
|
|
|
byte _loaded;
|
|
|
|
bool _processed;
|
2013-05-20 02:45:54 +00:00
|
|
|
bool _callInitGro;
|
2013-06-06 01:28:51 +00:00
|
|
|
int _termGroIndex;
|
2013-05-20 02:45:54 +00:00
|
|
|
int _count;
|
|
|
|
int _fileOffset;
|
|
|
|
Common::Array<BoltEntry> _entries;
|
|
|
|
public:
|
|
|
|
BoltGroup(Common::SeekableReadStream *f);
|
2013-06-08 19:49:44 +00:00
|
|
|
virtual ~BoltGroup();
|
2013-05-20 02:45:54 +00:00
|
|
|
|
|
|
|
void load();
|
2013-06-08 19:49:44 +00:00
|
|
|
void unload();
|
2013-05-20 02:45:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BoltEntry {
|
|
|
|
private:
|
|
|
|
Common::SeekableReadStream *_file;
|
|
|
|
public:
|
2013-05-21 01:18:40 +00:00
|
|
|
byte _mode;
|
|
|
|
byte _field1;
|
2013-05-25 13:58:03 +00:00
|
|
|
byte _initMethod;
|
2013-05-20 02:45:54 +00:00
|
|
|
int _fileOffset;
|
2013-05-21 01:18:40 +00:00
|
|
|
byte _xorMask;
|
|
|
|
int _size;
|
|
|
|
byte *_data;
|
2013-05-25 19:36:57 +00:00
|
|
|
|
|
|
|
PictureResource *_picResource;
|
2013-05-26 03:30:48 +00:00
|
|
|
ViewPortResource *_viewPortResource;
|
2013-05-27 02:18:54 +00:00
|
|
|
ViewPortListResource *_viewPortListResource;
|
2013-05-28 03:01:15 +00:00
|
|
|
FontResource *_fontResource;
|
2013-06-15 15:39:28 +00:00
|
|
|
FontInfoResource *_fontInfoResource;
|
2013-05-28 03:01:15 +00:00
|
|
|
CMapResource *_cMapResource;
|
|
|
|
VInitCyclResource *_vInitCyclResource;
|
2013-05-20 02:45:54 +00:00
|
|
|
public:
|
|
|
|
BoltEntry(Common::SeekableReadStream *f);
|
2013-05-21 01:18:40 +00:00
|
|
|
virtual ~BoltEntry();
|
2013-05-20 02:45:54 +00:00
|
|
|
|
|
|
|
void load();
|
2013-05-29 02:39:32 +00:00
|
|
|
bool hasResource() const;
|
2013-05-20 02:45:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FilesManager {
|
|
|
|
private:
|
|
|
|
int _decompressSize;
|
|
|
|
public:
|
2013-05-25 19:36:57 +00:00
|
|
|
BoltFilesState _boltFilesState;
|
2013-05-20 02:45:54 +00:00
|
|
|
BoltFile *_curLibPtr;
|
|
|
|
public:
|
|
|
|
FilesManager();
|
2013-05-26 00:51:53 +00:00
|
|
|
void setVm(VoyeurEngine *vm) { _boltFilesState._vm = vm; }
|
2013-05-20 02:45:54 +00:00
|
|
|
|
2013-05-21 01:18:40 +00:00
|
|
|
bool openBoltLib(const Common::String &filename, BoltFile *&boltFile);
|
2013-06-11 01:29:12 +00:00
|
|
|
byte *fload(const Common::String &filename, int *size = NULL);
|
2013-05-20 02:45:54 +00:00
|
|
|
};
|
|
|
|
|
2013-06-01 01:03:16 +00:00
|
|
|
class DisplayResource {
|
2013-05-30 03:21:07 +00:00
|
|
|
public:
|
2013-05-25 19:36:57 +00:00
|
|
|
uint16 _flags;
|
2013-06-01 01:03:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PictureResource: public DisplayResource {
|
|
|
|
public:
|
2013-05-25 19:36:57 +00:00
|
|
|
byte _select;
|
|
|
|
byte _pick;
|
|
|
|
byte _onOff;
|
|
|
|
byte _depth;
|
2013-05-30 03:21:07 +00:00
|
|
|
Common::Rect _bounds;
|
2013-05-25 19:36:57 +00:00
|
|
|
uint32 _maskData;
|
2013-05-26 00:51:53 +00:00
|
|
|
uint _planeSize;
|
2013-05-25 19:36:57 +00:00
|
|
|
|
|
|
|
byte *_imgData;
|
|
|
|
public:
|
|
|
|
PictureResource(BoltFilesState &state, const byte *src);
|
2013-06-16 13:03:03 +00:00
|
|
|
PictureResource(int flags, int select, int pick, int onOff, int depth,
|
|
|
|
const Common::Rect &bounds, int maskData, byte *imgData, int planeSize);
|
2013-06-08 21:51:41 +00:00
|
|
|
PictureResource();
|
2013-05-25 19:36:57 +00:00
|
|
|
virtual ~PictureResource();
|
|
|
|
};
|
|
|
|
|
2013-05-29 02:39:32 +00:00
|
|
|
typedef void (ViewPortResource::*ViewPortMethodPtr)();
|
|
|
|
|
2013-06-01 01:03:16 +00:00
|
|
|
class ViewPortResource: public DisplayResource {
|
2013-05-29 02:39:32 +00:00
|
|
|
private:
|
|
|
|
BoltFilesState &_state;
|
|
|
|
private:
|
2013-05-30 03:21:07 +00:00
|
|
|
void setupViewPort(PictureResource *page, Common::Rect *clipRect, ViewPortSetupPtr setupFn,
|
|
|
|
ViewPortAddPtr addFn, ViewPortRestorePtr restoreFn);
|
2013-05-26 03:30:48 +00:00
|
|
|
public:
|
2013-06-17 01:20:42 +00:00
|
|
|
ViewPortResource *_parent;
|
2013-06-01 01:31:33 +00:00
|
|
|
int _pageCount;
|
|
|
|
int _pageIndex;
|
|
|
|
int _lastPage;
|
2013-05-30 03:21:07 +00:00
|
|
|
Common::Rect _bounds;
|
2013-05-29 02:39:32 +00:00
|
|
|
int _field18;
|
2013-06-01 01:31:33 +00:00
|
|
|
PictureResource *_currentPic;
|
2013-05-30 03:21:07 +00:00
|
|
|
PictureResource *_activePage;
|
2013-06-01 01:31:33 +00:00
|
|
|
PictureResource *_pages[2];
|
2013-05-26 03:30:48 +00:00
|
|
|
byte *_field30;
|
2013-06-01 17:01:09 +00:00
|
|
|
|
|
|
|
// Rect lists and counts. Note that _rectListCount values of '-1' seem to have
|
|
|
|
// special significance, which is why I'm not making them redundant in favour
|
|
|
|
// of the arrays' .size() method
|
2013-06-01 16:35:50 +00:00
|
|
|
Common::Array<Common::Rect> *_rectListPtr[3];
|
|
|
|
int _rectListCount[3];
|
2013-06-01 17:01:09 +00:00
|
|
|
|
2013-05-30 03:21:07 +00:00
|
|
|
Common::Rect _clipRect;
|
2013-05-26 03:30:48 +00:00
|
|
|
byte *_field7A;
|
2013-05-30 03:21:07 +00:00
|
|
|
GraphicMethodPtr _fn1;
|
|
|
|
ViewPortSetupPtr _setupFn;
|
|
|
|
ViewPortAddPtr _addFn;
|
|
|
|
ViewPortRestorePtr _restoreFn;
|
2013-06-15 02:01:59 +00:00
|
|
|
PictureResource _fontChar;
|
|
|
|
Common::Rect _fontRect;
|
2013-05-26 03:30:48 +00:00
|
|
|
public:
|
|
|
|
ViewPortResource(BoltFilesState &state, const byte *src);
|
2013-06-01 16:35:50 +00:00
|
|
|
virtual ~ViewPortResource();
|
2013-05-29 02:39:32 +00:00
|
|
|
|
|
|
|
void setupViewPort();
|
2013-06-15 02:01:59 +00:00
|
|
|
int drawText(const Common::String &msg);
|
|
|
|
int textWidth(const Common::String &msg);
|
|
|
|
void addSaveRect(int pageIndex, const Common::Rect &r);
|
|
|
|
void sFillBox(int width);
|
2013-05-26 03:30:48 +00:00
|
|
|
};
|
|
|
|
|
2013-06-08 02:07:57 +00:00
|
|
|
class ViewPortPalEntry {
|
|
|
|
public:
|
|
|
|
uint16 _rEntry, _gEntry, _bEntry;
|
2013-06-08 14:31:37 +00:00
|
|
|
uint16 _rChange, _gChange, _bChange;
|
|
|
|
uint16 _palIndex;
|
2013-06-08 02:07:57 +00:00
|
|
|
public:
|
|
|
|
ViewPortPalEntry(const byte *src);
|
|
|
|
};
|
|
|
|
|
2013-05-27 02:18:54 +00:00
|
|
|
class ViewPortListResource {
|
|
|
|
public:
|
2013-06-08 02:07:57 +00:00
|
|
|
Common::Array<ViewPortPalEntry> _palette;
|
2013-05-29 02:39:32 +00:00
|
|
|
Common::Array<ViewPortResource *> _entries;
|
2013-06-11 01:46:19 +00:00
|
|
|
int _palIndex;
|
2013-05-27 02:18:54 +00:00
|
|
|
|
|
|
|
ViewPortListResource(BoltFilesState &state, const byte *src);
|
|
|
|
virtual ~ViewPortListResource() {}
|
|
|
|
};
|
|
|
|
|
2013-05-28 03:01:15 +00:00
|
|
|
class FontResource {
|
|
|
|
public:
|
2013-06-15 02:01:59 +00:00
|
|
|
int _minChar, _maxChar;
|
|
|
|
int field2;
|
|
|
|
int _padding;
|
|
|
|
int _fontHeight;
|
|
|
|
int field6;
|
|
|
|
int *_charWidth;
|
|
|
|
byte *_data1;
|
|
|
|
byte *_data2;
|
|
|
|
|
|
|
|
FontResource(BoltFilesState &state, byte *src);
|
|
|
|
virtual ~FontResource();
|
2013-05-28 03:01:15 +00:00
|
|
|
};
|
|
|
|
|
2013-06-15 15:39:28 +00:00
|
|
|
enum FontJustify { ALIGN_LEFT = 0, ALIGN_CENTRE = 1, ALIGN_RIGHT = 2 };
|
|
|
|
|
|
|
|
class FontInfoResource {
|
|
|
|
public:
|
|
|
|
FontResource *_curFont;
|
|
|
|
byte _picFlags;
|
|
|
|
byte _picSelect;
|
|
|
|
byte _picPick;
|
|
|
|
byte _picOnOff;
|
|
|
|
byte _fontFlags;
|
|
|
|
FontJustify _justify;
|
|
|
|
int _fontSaveBack;
|
|
|
|
Common::Point _pos;
|
|
|
|
int _justifyWidth;
|
|
|
|
int _justifyHeight;
|
|
|
|
Common::Point _shadow;
|
|
|
|
int _foreColor;
|
|
|
|
int _backColor;
|
|
|
|
int _shadowColor;
|
|
|
|
public:
|
|
|
|
FontInfoResource(BoltFilesState &state, const byte *src);
|
|
|
|
FontInfoResource();
|
|
|
|
FontInfoResource(byte picFlags, byte picSelect, byte picPick, byte picOnOff, byte fontFlags,
|
|
|
|
FontJustify justify, int fontSaveBack, const Common::Point &pos, int justifyWidth,
|
|
|
|
int justifyHeight, const Common::Point &shadow, int foreColor, int backColor,
|
|
|
|
int shadowColor);
|
|
|
|
};
|
|
|
|
|
2013-05-28 03:01:15 +00:00
|
|
|
class CMapResource {
|
2013-06-06 01:28:51 +00:00
|
|
|
private:
|
|
|
|
VoyeurEngine *_vm;
|
2013-05-28 03:01:15 +00:00
|
|
|
public:
|
2013-06-06 01:28:51 +00:00
|
|
|
int _steps;
|
|
|
|
int _fadeStatus;
|
2013-05-28 03:01:15 +00:00
|
|
|
int _start;
|
|
|
|
int _end;
|
2013-06-06 01:28:51 +00:00
|
|
|
byte *_entries;
|
2013-05-28 03:01:15 +00:00
|
|
|
public:
|
|
|
|
CMapResource(BoltFilesState &state, const byte *src);
|
|
|
|
virtual ~CMapResource();
|
2013-06-06 01:28:51 +00:00
|
|
|
|
|
|
|
void startFade();
|
2013-05-28 03:01:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class VInitCyclResource {
|
|
|
|
public:
|
|
|
|
byte *_ptr[4];
|
|
|
|
public:
|
|
|
|
VInitCyclResource(BoltFilesState &state, const byte *src);
|
|
|
|
virtual ~VInitCyclResource() {}
|
|
|
|
};
|
|
|
|
|
2013-05-20 02:45:54 +00:00
|
|
|
} // End of namespace Voyeur
|
|
|
|
|
2013-05-23 13:13:28 +00:00
|
|
|
#endif /* VOYEUR_FILES_H */
|