2011-07-14 18:08:06 +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.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2011-07-14 18:08:06 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2011-07-14 18:08:06 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-07-14 18:08:06 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/endian.h"
|
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
|
|
|
|
#ifndef COMPOSER_RESOURCE_H
|
|
|
|
#define COMPOSER_RESOURCE_H
|
|
|
|
|
|
|
|
namespace Composer {
|
|
|
|
|
2011-07-27 13:34:55 +00:00
|
|
|
struct Animation;
|
2011-07-18 19:52:55 +00:00
|
|
|
|
2011-07-14 18:08:06 +00:00
|
|
|
#define ID_LBRC MKTAG('L','B','R','C') // Main FourCC
|
|
|
|
|
2011-11-05 10:19:22 +00:00
|
|
|
#define ID_ACEL MKTAG('A','C','E','L') // Keyboard Accelerator (v1)
|
2011-11-05 09:47:24 +00:00
|
|
|
#define ID_AMBI MKTAG('A','M','B','I') // Ambient (v1 sprite button)
|
2011-07-14 18:08:06 +00:00
|
|
|
#define ID_ANIM MKTAG('A','N','I','M') // Animation
|
|
|
|
#define ID_BMAP MKTAG('B','M','A','P') // Bitmap
|
|
|
|
#define ID_BUTN MKTAG('B','U','T','N') // Button
|
|
|
|
#define ID_CTBL MKTAG('C','T','B','L') // Color Table
|
|
|
|
#define ID_EVNT MKTAG('E','V','N','T') // Event
|
|
|
|
#define ID_PIPE MKTAG('P','I','P','E') // Pipe
|
2011-11-05 15:00:02 +00:00
|
|
|
#define ID_RAND MKTAG('R','A','N','D') // Random Object
|
2011-07-14 18:08:06 +00:00
|
|
|
#define ID_SCRP MKTAG('S','C','R','P') // Script
|
|
|
|
#define ID_VARI MKTAG('V','A','R','I') // Variables
|
|
|
|
#define ID_WAVE MKTAG('W','A','V','E') // Wave
|
|
|
|
|
2011-11-04 21:38:33 +00:00
|
|
|
#define ID_FRME MKTAG('F','R','M','E') // Frame
|
|
|
|
|
2011-07-14 18:08:06 +00:00
|
|
|
class Archive {
|
|
|
|
public:
|
|
|
|
Archive();
|
|
|
|
virtual ~Archive();
|
|
|
|
|
|
|
|
bool openFile(const Common::String &fileName);
|
|
|
|
virtual bool openStream(Common::SeekableReadStream *stream) = 0;
|
|
|
|
void close();
|
|
|
|
|
|
|
|
bool isOpen() const { return _stream != 0; }
|
|
|
|
|
|
|
|
bool hasResource(uint32 tag, uint16 id) const;
|
|
|
|
bool hasResource(uint32 tag, const Common::String &resName) const;
|
|
|
|
Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
|
|
|
|
uint32 getResourceFlags(uint32 tag, uint16 id) const;
|
|
|
|
uint32 getOffset(uint32 tag, uint16 id) const;
|
|
|
|
uint16 findResourceID(uint32 tag, const Common::String &resName) const;
|
|
|
|
Common::String getName(uint32 tag, uint16 id) const;
|
|
|
|
|
|
|
|
Common::Array<uint32> getResourceTypeList() const;
|
|
|
|
Common::Array<uint16> getResourceIDList(uint32 type) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
|
|
|
|
struct Resource {
|
|
|
|
uint32 offset;
|
|
|
|
uint32 size;
|
|
|
|
Common::String name;
|
|
|
|
uint32 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<uint16, Resource> ResourceMap;
|
|
|
|
typedef Common::HashMap<uint32, ResourceMap> TypeMap;
|
|
|
|
TypeMap _types;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ComposerArchive : public Archive {
|
|
|
|
public:
|
|
|
|
ComposerArchive() : Archive() {}
|
2020-02-09 11:05:27 +00:00
|
|
|
~ComposerArchive() override {}
|
2011-07-14 18:08:06 +00:00
|
|
|
|
2020-02-09 11:05:27 +00:00
|
|
|
bool openStream(Common::SeekableReadStream *stream) override;
|
2011-07-14 18:08:06 +00:00
|
|
|
};
|
|
|
|
|
2011-07-18 19:52:55 +00:00
|
|
|
struct PipeResourceEntry {
|
|
|
|
uint32 size;
|
|
|
|
uint32 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PipeResource {
|
|
|
|
Common::Array<PipeResourceEntry> entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Pipe {
|
|
|
|
public:
|
2012-05-28 19:40:07 +00:00
|
|
|
Pipe(Common::SeekableReadStream *stream, uint16 id);
|
2011-11-04 21:38:33 +00:00
|
|
|
virtual ~Pipe();
|
|
|
|
virtual void nextFrame();
|
2011-07-18 19:52:55 +00:00
|
|
|
|
|
|
|
Animation *_anim;
|
|
|
|
|
2011-07-20 07:54:11 +00:00
|
|
|
bool hasResource(uint32 tag, uint16 id) const;
|
2011-07-18 19:52:55 +00:00
|
|
|
Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
|
|
|
|
|
2011-11-04 21:38:33 +00:00
|
|
|
virtual const Common::Array<uint16> *getScripts() { return NULL; }
|
2012-05-28 20:00:07 +00:00
|
|
|
uint16 getPipeId() const { return _pipeId; }
|
2012-05-29 19:49:03 +00:00
|
|
|
virtual uint32 getOffset() const { return _offset; }
|
|
|
|
virtual void setOffset(uint32 offset) { while (_offset < offset) nextFrame(); }
|
2012-05-28 20:00:07 +00:00
|
|
|
typedef Common::HashMap<uint32, Common::List<uint16> > DelMap;
|
2012-05-29 19:49:03 +00:00
|
|
|
DelMap _bufferedResources;
|
2011-11-04 21:38:33 +00:00
|
|
|
|
2011-07-18 19:52:55 +00:00
|
|
|
protected:
|
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
|
|
|
|
typedef Common::HashMap<uint16, PipeResource> ResourceMap;
|
|
|
|
typedef Common::HashMap<uint32, ResourceMap> TypeMap;
|
|
|
|
TypeMap _types;
|
2012-05-26 06:42:07 +00:00
|
|
|
uint16 _pipeId;
|
2011-07-18 19:52:55 +00:00
|
|
|
|
|
|
|
uint32 _offset;
|
|
|
|
};
|
|
|
|
|
2011-11-04 21:38:33 +00:00
|
|
|
class OldPipe : public Pipe {
|
|
|
|
public:
|
2012-05-26 06:42:07 +00:00
|
|
|
OldPipe(Common::SeekableReadStream *stream, uint16 pipeId);
|
2020-02-09 11:05:27 +00:00
|
|
|
void nextFrame() override;
|
2011-11-04 21:38:33 +00:00
|
|
|
|
2020-02-09 11:05:27 +00:00
|
|
|
const Common::Array<uint16> *getScripts() override { return &_scripts; }
|
|
|
|
uint32 getOffset() const override { return _currFrame; }
|
|
|
|
void setOffset(uint32 offset) override { while (_currFrame < offset) nextFrame(); }
|
2011-11-04 21:38:33 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32 _currFrame, _numFrames;
|
|
|
|
Common::Array<uint16> _scripts;
|
|
|
|
};
|
|
|
|
|
2011-07-14 18:08:06 +00:00
|
|
|
} // End of namespace Composer
|
|
|
|
|
|
|
|
#endif
|