2016-09-17 19:34:47 +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 CHEWY_RESOURCE_H
|
|
|
|
#define CHEWY_RESOURCE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
|
|
|
#include "common/random.h"
|
2016-09-24 08:49:54 +00:00
|
|
|
#include "common/stream.h"
|
2016-09-26 23:34:20 +00:00
|
|
|
#include "graphics/surface.h"
|
2016-09-17 19:34:47 +00:00
|
|
|
|
|
|
|
namespace Chewy {
|
|
|
|
|
2016-09-20 07:50:59 +00:00
|
|
|
enum ResourceType {
|
|
|
|
kResourcePCX = 0, // unused
|
2016-09-20 09:10:59 +00:00
|
|
|
kResourceTBF = 1, // background art, contained in TGPs
|
2016-09-20 07:50:59 +00:00
|
|
|
kResourceTAF = 2,
|
|
|
|
kResourceTFF = 3,
|
2016-09-20 09:10:59 +00:00
|
|
|
kResourceVOC = 4, // speech and SFX, contained in TVPs
|
2016-09-20 07:50:59 +00:00
|
|
|
kResourceTPF = 5, // unused
|
2016-09-20 09:10:59 +00:00
|
|
|
kResourceTMF = 6, // music, similar to a MOD file, contained in details.tap
|
2016-09-20 07:50:59 +00:00
|
|
|
kResourceMOD = 7, // unused
|
|
|
|
kResourceRAW = 8, // unused
|
|
|
|
kResourceLBM = 9, // unused
|
|
|
|
kResourceRDI = 10,
|
|
|
|
kResourceTXT = 11,
|
|
|
|
kResourceIIB = 12,
|
|
|
|
kResourceSIB = 13,
|
|
|
|
kResourceEIB = 14,
|
|
|
|
kResourceATS = 15, // unused
|
|
|
|
kResourceSAA = 16, // unused
|
|
|
|
kResourceFLC = 17, // unused
|
|
|
|
kResourceAAD = 18, // unused
|
|
|
|
kResourceADS = 19, // unused
|
|
|
|
kResourceADH = 20, // used in txt/diah.adh
|
2016-09-20 09:10:59 +00:00
|
|
|
kResourceTGP = 21, // container for background art, used in back/comic.tgp, back/episode1.tgp and back/gbook.tgp
|
|
|
|
kResourceTVP = 22, // container for speech, used in sound/speech.tvp
|
2016-09-20 07:50:59 +00:00
|
|
|
kResourceTTP = 23, // unused
|
2016-09-20 09:10:59 +00:00
|
|
|
kResourceTAP = 24, // container for sound effects, music and cutscenes, used in sound/details.tap and cut/cut.tap
|
2016-09-20 07:50:59 +00:00
|
|
|
kResourceCFO = 25, // unused
|
|
|
|
kResourceTCF = 26 // error messages, used in err/err_e.tcf (English) and err/err_d.tcf (German)
|
|
|
|
};
|
|
|
|
|
2016-09-20 09:10:59 +00:00
|
|
|
// Generic chunk header
|
2016-09-20 07:50:59 +00:00
|
|
|
struct Chunk {
|
|
|
|
uint32 size;
|
2016-09-20 10:00:19 +00:00
|
|
|
uint16 num; // same as the type below, used in chunks where the type is substituted with count
|
2016-09-20 07:50:59 +00:00
|
|
|
ResourceType type;
|
|
|
|
uint32 pos; // position of the actual data
|
|
|
|
};
|
2016-09-17 19:34:47 +00:00
|
|
|
|
2016-09-20 09:10:59 +00:00
|
|
|
// TBF (background) chunk header
|
2016-09-20 07:50:59 +00:00
|
|
|
struct TBFChunk {
|
2016-09-17 19:34:47 +00:00
|
|
|
// TBF chunk header
|
|
|
|
// ID (TBF, followed by a zero)
|
|
|
|
uint16 screenMode;
|
|
|
|
uint16 compressionFlag;
|
2016-09-20 09:10:59 +00:00
|
|
|
uint32 size;
|
2016-09-17 19:34:47 +00:00
|
|
|
uint16 width;
|
|
|
|
uint16 height;
|
2016-09-19 06:37:04 +00:00
|
|
|
byte palette[3 * 256];
|
2016-09-20 09:10:59 +00:00
|
|
|
byte *data;
|
|
|
|
};
|
|
|
|
|
2016-09-26 10:19:37 +00:00
|
|
|
// TAF (sprite) image data chunk header - 15 bytes
|
|
|
|
struct TAFChunk {
|
|
|
|
uint16 compressionFlag;
|
|
|
|
uint16 width;
|
|
|
|
uint16 height;
|
|
|
|
// 4 bytes next sprite offset
|
|
|
|
// 4 bytes sprite image offset
|
|
|
|
// 1 byte padding
|
|
|
|
byte *data;
|
|
|
|
};
|
|
|
|
|
2016-09-20 09:10:59 +00:00
|
|
|
// Sound chunk header
|
|
|
|
struct SoundChunk {
|
|
|
|
uint32 size;
|
|
|
|
byte *data;
|
2016-09-17 19:34:47 +00:00
|
|
|
};
|
|
|
|
|
2016-09-20 21:50:53 +00:00
|
|
|
// Video chunk header
|
|
|
|
struct VideoChunk {
|
|
|
|
// ID (CFA, followed by a zero)
|
|
|
|
uint32 size;
|
|
|
|
uint16 frameCount;
|
|
|
|
uint16 width;
|
|
|
|
uint16 height;
|
|
|
|
uint32 frameDelay; // in ms
|
|
|
|
uint32 firstFrameOffset;
|
|
|
|
};
|
|
|
|
|
2016-09-24 08:49:54 +00:00
|
|
|
enum VideoFrameType {
|
|
|
|
kVideoFrameNormal = 0xF1FA,
|
|
|
|
kVideoFrameCustom = 0xFAF1
|
|
|
|
};
|
|
|
|
|
2016-09-20 07:50:59 +00:00
|
|
|
typedef Common::Array<Chunk> ChunkList;
|
2016-09-17 19:34:47 +00:00
|
|
|
typedef Common::Array<TBFChunk> TBFChunkList;
|
|
|
|
|
|
|
|
class Resource {
|
|
|
|
public:
|
|
|
|
Resource(Common::String filename);
|
2016-09-20 09:10:59 +00:00
|
|
|
virtual ~Resource();
|
2016-09-17 19:34:47 +00:00
|
|
|
|
2016-09-20 07:50:59 +00:00
|
|
|
ResourceType getType() const { return _resType; }
|
|
|
|
uint32 getChunkCount() const;
|
2016-09-20 10:00:19 +00:00
|
|
|
Chunk *getChunk(uint num);
|
|
|
|
virtual byte *getChunkData(uint num);
|
2016-09-17 19:34:47 +00:00
|
|
|
|
2016-09-20 07:50:59 +00:00
|
|
|
protected:
|
2016-09-26 10:19:37 +00:00
|
|
|
void initSprite(Common::String filename);
|
|
|
|
void unpackRLE(byte *buffer, uint32 compressedSize, uint32 uncompressedSize);
|
2016-10-03 02:29:58 +00:00
|
|
|
void decrypt(byte *data, uint32 size);
|
2016-09-26 10:19:37 +00:00
|
|
|
|
2016-09-17 19:34:47 +00:00
|
|
|
Common::File _stream;
|
|
|
|
uint16 _chunkCount;
|
2016-09-20 07:50:59 +00:00
|
|
|
ResourceType _resType;
|
2016-09-20 21:50:53 +00:00
|
|
|
bool _encrypted;
|
2016-09-20 07:50:59 +00:00
|
|
|
|
|
|
|
ChunkList _chunkList;
|
2016-09-20 09:10:59 +00:00
|
|
|
};
|
|
|
|
|
2016-09-26 10:19:37 +00:00
|
|
|
class SpriteResource : public Resource {
|
|
|
|
public:
|
|
|
|
SpriteResource(Common::String filename) : Resource(filename) {}
|
2016-09-26 20:26:28 +00:00
|
|
|
virtual ~SpriteResource() {}
|
2016-09-26 10:19:37 +00:00
|
|
|
|
|
|
|
TAFChunk *getSprite(uint num);
|
|
|
|
};
|
|
|
|
|
2016-09-20 09:10:59 +00:00
|
|
|
class BackgroundResource : public Resource {
|
|
|
|
public:
|
|
|
|
BackgroundResource(Common::String filename) : Resource(filename) {}
|
2016-09-26 20:26:28 +00:00
|
|
|
virtual ~BackgroundResource() {}
|
2016-09-20 09:10:59 +00:00
|
|
|
|
2016-09-20 10:00:19 +00:00
|
|
|
TBFChunk *getImage(uint num);
|
2016-09-20 09:10:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SoundResource : public Resource {
|
|
|
|
public:
|
|
|
|
SoundResource(Common::String filename) : Resource(filename) {}
|
2016-09-26 20:26:28 +00:00
|
|
|
virtual ~SoundResource() {}
|
2016-09-20 09:10:59 +00:00
|
|
|
|
2016-09-20 10:00:19 +00:00
|
|
|
SoundChunk *getSound(uint num);
|
|
|
|
};
|
|
|
|
|
2016-09-20 21:50:53 +00:00
|
|
|
class VideoResource : public Resource {
|
|
|
|
public:
|
|
|
|
VideoResource(Common::String filename) : Resource(filename) {}
|
2016-09-26 20:26:28 +00:00
|
|
|
virtual ~VideoResource() {}
|
2016-09-20 21:50:53 +00:00
|
|
|
|
|
|
|
VideoChunk *getVideoHeader(uint num);
|
2016-09-24 08:49:54 +00:00
|
|
|
Common::SeekableReadStream *getVideoStream(uint num);
|
2016-09-20 21:50:53 +00:00
|
|
|
};
|
|
|
|
|
2016-09-17 19:34:47 +00:00
|
|
|
} // End of namespace Chewy
|
|
|
|
|
|
|
|
#endif
|