22 #ifndef MADE_RESOURCE_H 23 #define MADE_RESOURCE_H 25 #include "made/sound.h" 27 #include "common/endian.h" 28 #include "common/array.h" 29 #include "common/hashmap.h" 52 const int kMaxResourceCacheSize = 400 * 1024;
57 kResARCH =
MKTAG(
'A',
'R',
'C',
'H'),
58 kResFREE =
MKTAG(
'F',
'R',
'E',
'E'),
59 kResOMNI =
MKTAG(
'O',
'M',
'N',
'I'),
60 kResFLEX =
MKTAG(
'F',
'L',
'E',
'X'),
61 kResSNDS =
MKTAG(
'S',
'N',
'D',
'S'),
62 kResANIM =
MKTAG(
'A',
'N',
'I',
'M'),
63 kResMENU =
MKTAG(
'M',
'E',
'N',
'U'),
64 kResFONT =
MKTAG(
'F',
'O',
'N',
'T'),
65 kResXMID =
MKTAG(
'X',
'M',
'I',
'D'),
66 kResMIDI =
MKTAG(
'M',
'I',
'D',
'I')
81 void load(byte *source,
int size);
83 byte *getPalette()
const {
return _picturePalette; }
84 bool hasPalette()
const {
return _hasPalette; }
85 int getPaletteColorCount()
const {
return _paletteColorCount; }
88 byte *_picturePalette;
89 int _paletteColorCount;
91 void loadRaw(byte *source,
int size);
92 void loadChunked(byte *source,
int size);
99 void load(byte *source,
int size);
100 int getCount()
const {
return _frames.size(); }
102 if ((uint)index < _frames.size()) {
103 return _frames[index];
105 warning(
"getFrame: Tried to obtain invalid frame %i, array has %i frames", index, _frames.size());
106 return _frames[_frames.size() - 1];
109 uint16 getFlags()
const {
return _flags; }
110 int16 getWidth()
const {
return _width; }
111 int16 getHeight()
const {
return _height; }
115 int16 _width, _height;
122 virtual void load(byte *source,
int size);
125 int getSoundSize()
const {
return _soundSize; }
136 void load(byte *source,
int size)
override;
143 void load(byte *source,
int size);
144 int getCount()
const {
return _strings.size(); }
145 const char *getString(uint index)
const;
154 void load(byte *source,
int size);
155 int getHeight()
const;
156 int getCharWidth(uint c)
const;
157 int getTextWidth(
const char *text);
158 byte *getChar(uint c)
const;
162 byte *getCharData(uint c)
const;
169 void load(byte *source,
int size);
170 byte *getData()
const {
return _data; }
171 int getSize()
const {
return _size; }
182 ResourceSlot() : offs(0), size(0), res(NULL), refCount(0) {
184 ResourceSlot(uint32 roffs, uint32 rsize) : offs(roffs), size(rsize), res(NULL), refCount(0) {
193 void open(
const char *filename);
194 void openResourceBlocks();
204 void freeResource(
Resource *resource);
214 void openResourceBlock(
const char *filename,
Common::File *blockFile, uint32 resType);
220 void loadIndex(ResourceSlots *slots);
223 T *createResource(uint32 resType,
int index) {
227 T *res = (T *)getResourceFromCache(slot);
247 if (loadResource(slot, buffer, size)) {
250 res->load(buffer, size);
251 addResourceToCache(slot, res);
258 bool loadResource(
ResourceSlot *slot, byte *&buffer, uint32 &size);
259 ResourceSlot *getResourceSlot(uint32 resType, uint index);
Definition: resource.h:77
Definition: resource.h:165
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: resource.h:132
Definition: resource.h:177
Definition: resource.h:71
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: audiostream.h:50
const int kMaxResourceCacheSize
Definition: resource.h:50
Definition: resource.h:118
Definition: resource.h:188
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: resource.h:150
Definition: resource.h:95