1 #ifndef _bmpnames_hpp_
2 #define _bmpnames_hpp_
3 
4 #include "chunk.hpp"
5 
6 // for assert
7 #define UseLocalAssert No
8 #include "ourasert.h"
9 #define assert(x) GLOBALASSERT(x)
10 
11 enum BMPN_Flags
12 {
13 	ChunkBMPFlag_Null                 = 0x00000000, // all flags reset
14 	ChunkBMPFlag_NotInShape           = 0x00000001, // not a texture map, maybe a sprite or hud graphic
15 	ChunkBMPFlag_UsesTransparency     = 0x00000002, // transparency_colour defines invisible pixels
16 	ChunkBMPFlag_RequireGameMipMaps   = 0x00000004, // mip maps are required for the game
17 	ChunkBMPFlag_RequireToolsMipMaps  = 0x00000008, // mip maps are required for the interface engine
18 	ChunkBMPFlag_MipMapsExist         = 0x00000010, // internal mip maps are up to date
19 	ChunkBMPFlag_NotLit               = 0x00000020, // not light sourced (eg. hud, iflag_nolight), so do not put darker colours into palette
20 	ChunkBMPFlag_FixedPalette         = 0x00000040, // will be quantized once only to a fixed sub-palette of each main palette
21 	ChunkBMPFlag_Quantized            = 0x00000080, // .PG0 exists which corresponds to the palette
22 	// See below                        0x00000100
23 	ChunkBMPFlag_MipMapsQuantized     = 0x00000200, // .PG1-.PG6 exist which correspond to the palette and are mip maps
24 	ChunkBMPFlag_PP0Exists            = 0x00000400, // internal .PP0 exists
25 	ChunkBMPFlag_NotInPC              = 0x00000800, // for reduced memory, reduced features on some platforms
26 	ChunkBMPFlag_NotInSaturn          = 0x00001000, // for reduced memory, reduced features on some platforms
27 	ChunkBMPFlag_NotInPlaystation     = 0x00002000, // for reduced memory, reduced features on some platforms
28 	ChunkBMPFlag_BM0Exists            = 0x00004000, // 256 colour palettized texture for hw accelerators exists
29 	ChunkBMPFlag_BMnsExist            = 0x00008000, // mip mapped versions of 256 colour palettized texture exist
30 	ChunkBMP_Dither                   = 0x00070000, //
31 	ChunkBMP_DitherFloyd              = 0x00010000, //
32 	ChunkBMP_DitherFloydDamp1         = 0x00020000, //
33 	ChunkBMP_DitherFloydDamp2         = 0x00030000, // 3 bits to control the type of error diffusion (if any)
34 	ChunkBMP_DitherJarvis             = 0x00040000, //
35 	ChunkBMP_DitherJarvisDamp1        = 0x00050000, //
36 	ChunkBMP_DitherJarvisDamp2        = 0x00060000, //
37 	ChunkBMPFlag_RqQuantLUV           = 0x00080000, // Remap in LUV colour space
38 	ChunkBMPFlag_HistogramExists      = 0x00100000, // used by cencon in palette generation - help by outputting .HST files
39 	ChunkBMPFlag_HistogramV2Exists    = 0x00200000, // used by cencon in palette generation - help by outputting .HS2 files (non-lit histograms for lit bitmaps with conceptual tlt palette)
40 	ChunkBMPFlag_CopiedGenMipMaps     = 0x00400000, // mip map HW generic textures have been copied to final dest
41 	ChunkBMPFlag_CopiedGenBaseTex     = 0x00800000, // base (non-mip) HW generic textures have been copied to final dest
42 
43 	ChunkBMPFlag_IFF                  = 0x01000000, // a very important flag indeed:
44 		// when this flag is set, the file is an IFF file and the filename stores a
45 		// full relative path from the 'textures-root' directory for the project
46 		// all other flags are complete bollocks when this flag is set
47 		// (except for the NotIn.... flags)
48 		// all this data will be in the file itself (transparency data anyway,,,)
49 		// the file can be updated without the use of cencon, so for this reason
50 		// I'll store the widths and heights where the transparent colour used
51 		// to be. I'll also provide member-access functions to access this data
52 		// which will check the flag is correct
53 
54 // This flag will be set on newer RIF files, because older ones will have priorities of 0 which is not ideal!
55 // When a chunk with these flag not set is detected, default values are filled in and the old values are not used.
56 	ChunkBMPFlag_PriorityAndTransparencyAreValid = 0x00000100
57 
58 };
59 
60 //I have removed transparency from the default flags at the request of the artists
61 
62 // default flags for new bitmaps
63 #define DEFAULT_BMPN_FLAGS ((BMPN_Flags) ( \
64         ChunkBMPFlag_PriorityAndTransparencyAreValid | \
65         ChunkBMPFlag_RequireToolsMipMaps | /* test */ \
66         ChunkBMPFlag_RequireGameMipMaps ))
67 
68 // user flags that should correspond for corresponding bitmaps
69 #define COPY_BMPN_FLAGS ((BMPN_Flags) ( \
70         ChunkBMPFlag_NotInShape | \
71         ChunkBMPFlag_UsesTransparency | \
72         ChunkBMPFlag_RequireToolsMipMaps | \
73         ChunkBMPFlag_RequireGameMipMaps | \
74         ChunkBMPFlag_MipMapsExist | \
75         ChunkBMPFlag_BMnsExist | \
76         ChunkBMPFlag_BM0Exists | \
77         ChunkBMPFlag_PP0Exists | \
78         ChunkBMPFlag_NotLit | \
79         ChunkBMPFlag_FixedPalette | \
80         ChunkBMPFlag_NotInPC | \
81         ChunkBMPFlag_NotInSaturn | \
82         ChunkBMPFlag_NotInPlaystation | \
83         ChunkBMP_Dither | \
84         ChunkBMPFlag_RqQuantLUV | \
85         ChunkBMPFlag_IFF))
86 
87 // flags that when changed require requantizing
88 #define CHECKMODIFY_BMPN_FLAGS ((BMPN_Flags) ( \
89         ChunkBMPFlag_UsesTransparency | \
90         ChunkBMPFlag_FixedPalette /* not sure */ | \
91         ChunkBMP_Dither | \
92         ChunkBMPFlag_RqQuantLUV ))
93 
94 // flags to reset if a bitmap needs requantizing
95 #define QUANTIZED_BMPN_FLAGS ((BMPN_Flags) ( \
96         ChunkBMPFlag_Quantized | \
97         ChunkBMPFlag_MipMapsQuantized ))
98 
99 #define COMPLETED_BMPN_FLAGS ((BMPN_Flags) ( \
100 		ChunkBMPFlag_CopiedGenBaseTex | \
101 		ChunkBMPFlag_CopiedGenMipMaps | \
102 		QUANTIZED_BMPN_FLAGS ))
103 
104 #define DEFAULT_BMPN_PRIORITY 6
105 
106 
107 extern void Palette_Outdated(Chunk_With_Children * parent); // decalred here, defined in chunkpal to avoid extra compiler dependencies
108 extern void FixedPalette_Outdated(Chunk_With_Children * parent); // decalred here, defined in chunkpal to avoid extra compiler dependencies
109 extern BOOL IsFixedPalette(Chunk_With_Children * parent);
110 
111 
112 class BMP_Name
113 {
114 public:
115 
116 	BMP_Name(const char * fname, int const gbnc_version);
117 	~BMP_Name();
118 
119 	BMP_Name(const BMP_Name &);
120 	const BMP_Name & operator=(const BMP_Name &);
121 
122 	char * filename;
123 
124 	BMPN_Flags flags;
125 	int index;
126 	int version_num;
127 	int enum_id;
128 	#define BMPNAME_PARENT_VER_SHIFT 8
129 	// version num contains bmp version num (incremental on update)
130 	// and Global_BMP_Name_Chunk version (at the time of creation) num shifted up
131 	// This is so that if a bitmap is removed and then added, its
132 	// version num will still be greater than that of the removed version
133 	#define BMPNAME_VERSION_NUM_MASK 0x000fffff
134 	#define BMPNAME_ENUMID_SHIFT 20
135 	// the top 12 bits of the previously spare data item (data1)
136 	// contain an enumeration constant (max 4095)
137 	// and the bottom 20 bits are available for version numbers
138 	// a bit cramped and not ideal, but we are running out of storage space
139 	// there are still two bytes free(0) in the priority data
140 
141 	#define MAX_PC_PRIORITY 0xff
142 	#define MAX_PSX_PRIORITY 0xff
get_pc_priority(void) const143 	inline int get_pc_priority(void) const { return priority & 0xff; }
get_psx_priority(void) const144 	inline int get_psx_priority(void) const { return priority >> 8 & 0xff; }
set_pc_priority(int const p)145 	inline void set_pc_priority(int const p) { priority &= ~0xff; priority |= p & 0xff; }
set_psx_priority(int const p)146 	inline void set_psx_priority(int const p) { priority &= ~0xff00; priority |= (p & 0xff) << 8; }
147 
148 	friend BOOL operator==(const BMP_Name &o1, const BMP_Name &o2);
149 	friend BOOL operator!=(const BMP_Name &o1, const BMP_Name &o2);
150 
BMP_Name()151 	BMP_Name()
152 	: filename(0), flags((BMPN_Flags)DEFAULT_BMPN_FLAGS), index(0), version_num (0), priority (DEFAULT_BMPN_PRIORITY), transparency_colour_union(0) {}
153 
154 	void Validate(void);
155 
156 	unsigned GetTranspRedVal() const;
157 	unsigned GetTranspGreenVal() const;
158 	unsigned GetTranspBlueVal() const;
159 	unsigned GetWidth() const;
160 	unsigned GetHeight() const;
161 
162 	void SetTranspRedVal(unsigned);
163 	void SetTranspGreenVal(unsigned);
164 	void SetTranspBlueVal(unsigned);
165 	void SetWidth(unsigned);
166 	void SetHeight(unsigned);
167 
168 	// copy all data
169 	void CopyUnionDataFrom(BMP_Name const & rBmp);
170 	bool DifferentTransparencyColour(BMP_Name const & rBmp) const;
171 
172 	enum
173 	{
174 		MAXVAL_RGB = 0xff,
175 		MAXVAL_WH = 0xffff
176 	};
177 
178 private:
179 
180 	int priority; // contains pc palettized mode palette generating priority as well as 16/256 colour priority for attahced palettes
181 
182 	enum
183 	{
184 		SHIFT_R = 22,
185 		SHIFT_G = 12,
186 		SHIFT_B = 2,
187 
188 		SHIFT_W = 0,
189 		SHIFT_H = 16
190 	};
191 
192 	unsigned transparency_colour_union; // == r<<22 + g<<12 + b << 2 ; r,g,b <- [0..255], but don't assume this'll always be the case
193 		// or H<<16 + W
194 
195 	BMP_Name(const char * fname);
196 	// initial part of constructor from buffer.
197 	// GBNC and BLSC loaders find the rest of the data
198 	// and put it into the BMP_Name object constructed with this constructor
199 
200 	friend class Chunk_With_BMPs;
201 	friend class BMP_Flags;
202 };
203 
204 // functions to access the union transparency_colour_union which isn't a real C/C++ union
205 // they will check that you're performing valid accesses (ie. using the right part of the union)
206 // if you're a friend class, please ensure you use these access functions or know what you're doing
GetTranspRedVal() const207 inline unsigned BMP_Name::GetTranspRedVal() const
208 {
209 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
210 	return transparency_colour_union >> SHIFT_R & MAXVAL_RGB;
211 }
212 
GetTranspGreenVal() const213 inline unsigned BMP_Name::GetTranspGreenVal() const
214 {
215 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
216 	return transparency_colour_union >> SHIFT_G & MAXVAL_RGB;
217 }
218 
GetTranspBlueVal() const219 inline unsigned BMP_Name::GetTranspBlueVal() const
220 {
221 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
222 	return transparency_colour_union >> SHIFT_B & MAXVAL_RGB;
223 }
224 
GetWidth() const225 inline unsigned BMP_Name::GetWidth() const
226 {
227 	assert(flags & ChunkBMPFlag_IFF); // only available for IFF files - required since they can be modified externally
228 	return transparency_colour_union >> SHIFT_W & MAXVAL_WH;
229 }
230 
GetHeight() const231 inline unsigned BMP_Name::GetHeight() const
232 {
233 	assert(flags & ChunkBMPFlag_IFF); // only available for IFF files - required since they can be modified externally
234 	return transparency_colour_union >> SHIFT_H & MAXVAL_WH;
235 }
236 
SetTranspRedVal(unsigned v)237 inline void BMP_Name::SetTranspRedVal(unsigned v)
238 {
239 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
240 	assert(v<=MAXVAL_RGB); // sensible value
241 
242 	transparency_colour_union &= ~(MAXVAL_RGB << SHIFT_R);
243 	transparency_colour_union |= v << SHIFT_R;
244 }
245 
SetTranspGreenVal(unsigned v)246 inline void BMP_Name::SetTranspGreenVal(unsigned v)
247 {
248 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
249 	assert(v<=MAXVAL_RGB); // sensible value
250 
251 	transparency_colour_union &= ~(MAXVAL_RGB << SHIFT_G);
252 	transparency_colour_union |= v << SHIFT_G;
253 }
254 
SetTranspBlueVal(unsigned v)255 inline void BMP_Name::SetTranspBlueVal(unsigned v)
256 {
257 	assert(!(flags & ChunkBMPFlag_IFF)); // not available for IFF files - it's in the file
258 	assert(v<=MAXVAL_RGB); // sensible value
259 
260 	transparency_colour_union &= ~(MAXVAL_RGB << SHIFT_B);
261 	transparency_colour_union |= v << SHIFT_B;
262 }
263 
SetWidth(unsigned v)264 inline void BMP_Name::SetWidth(unsigned v)
265 {
266 	assert(flags & ChunkBMPFlag_IFF); // only available for IFF files - required since they can be modified externally
267 	assert(v<=MAXVAL_WH); // sensible value
268 
269 	transparency_colour_union &= ~(MAXVAL_WH << SHIFT_W);
270 	transparency_colour_union |= v << SHIFT_W;
271 }
272 
SetHeight(unsigned v)273 inline void BMP_Name::SetHeight(unsigned v)
274 {
275 	assert(flags & ChunkBMPFlag_IFF); // only available for IFF files - required since they can be modified externally
276 	assert(v<=MAXVAL_WH); // sensible value
277 
278 	transparency_colour_union &= ~(MAXVAL_WH << SHIFT_H);
279 	transparency_colour_union |= v << SHIFT_H;
280 }
281 
CopyUnionDataFrom(BMP_Name const & rBmp)282 inline void BMP_Name::CopyUnionDataFrom(BMP_Name const & rBmp)
283 {
284 	assert((flags & ChunkBMPFlag_IFF)==(rBmp.flags & ChunkBMPFlag_IFF));
285 
286 	transparency_colour_union = rBmp.transparency_colour_union;
287 }
288 
DifferentTransparencyColour(BMP_Name const & rBmp) const289 inline bool BMP_Name::DifferentTransparencyColour(BMP_Name const & rBmp) const
290 {
291 	assert(!(flags & ChunkBMPFlag_IFF) && !(rBmp.flags & ChunkBMPFlag_IFF));
292 
293 	return transparency_colour_union != rBmp.transparency_colour_union;
294 }
295 
296 
297 ///////////////////////////////////////////////
298 
299 class BMP_Names_ExtraData;
300 class Bitmap_MD5_Chunk;
301 
302 class Chunk_With_BMPs : public Chunk
303 {
304 public:
305 
306 	int max_index;
307 
308 	List<BMP_Name> bmps;
309 
310 	virtual int get_version_num(void);
311 	virtual void set_version_num(int);
312 	virtual void inc_version_num(void);
313 	virtual BMP_Names_ExtraData * GetExtendedData(void);
314 
315 	virtual int const * GetMD5Val(BMP_Name const & rcbmp);
316 	virtual void SetMD5Val(BMP_Name const & rcbmp, int const * md5id);
317 	virtual void RemoveMD5Val(char const * bname);
318 
319 	//friend class BMP_Group; // for cencon
320 	//friend class BMP_Info; // for cencon
321 
322 protected:
323 	virtual Bitmap_MD5_Chunk * GetMD5Chunk(char const * bname) = 0;
324 	virtual void CreateMD5Chunk(BMP_Name const & rcbmp, int const * md5id) = 0;
325 
326 	virtual size_t size_chunk ();
327 	virtual void fill_data_block (char * data_start);
328 
Chunk_With_BMPs(Chunk_With_Children * parent,const char * const ident)329 	Chunk_With_BMPs (Chunk_With_Children * parent, const char * const ident) : Chunk(parent,ident), max_index(0) {}
330 	Chunk_With_BMPs (Chunk_With_Children * parent, const char * const ident, const char * sdata, size_t ssize);
331 
332 };
333 
334 
335 class Global_BMP_Name_Chunk : public Chunk_With_BMPs
336 {
337 public:
338 
Global_BMP_Name_Chunk(Chunk_With_Children * parent)339 	Global_BMP_Name_Chunk (Chunk_With_Children * parent)
340 	: Chunk_With_BMPs (parent, "BMPNAMES")
341 	{}
342 	// constructor from buffer
Global_BMP_Name_Chunk(Chunk_With_Children * parent,const char * sdata,size_t ssize)343 	Global_BMP_Name_Chunk (Chunk_With_Children * parent, const char * sdata, size_t ssize)
344 	: Chunk_With_BMPs (parent, "BMPNAMES", sdata, ssize) {}
345 private:
346 	virtual Bitmap_MD5_Chunk * GetMD5Chunk(char const * bname);
347 	virtual void CreateMD5Chunk(BMP_Name const & rcbmp, int const * md5id);
348 
349 	friend class Environment_Data_Chunk;
350 
351 
352 
353 
354 };
355 
356 
357 class Bitmap_List_Store_Chunk : public Chunk_With_BMPs
358 {
359 public:
360 
Bitmap_List_Store_Chunk(Chunk_With_Children * parent)361 	Bitmap_List_Store_Chunk (Chunk_With_Children * parent)
362 	: Chunk_With_BMPs (parent, "BMPLSTST")
363 	{}
364 
365 	// constructor from buffer
366 	// not private, so that it is easy to get to
Bitmap_List_Store_Chunk(Chunk_With_Children * parent,const char * sdata,size_t ssize)367 	Bitmap_List_Store_Chunk (Chunk_With_Children * parent, const char * sdata, size_t ssize)
368 	: Chunk_With_BMPs (parent, "BMPLSTST", sdata, ssize) {}
369 
370 private:
371 	virtual Bitmap_MD5_Chunk * GetMD5Chunk(char const * bname);
372 	virtual void CreateMD5Chunk(BMP_Name const & rcbmp, int const * md5id);
373 
374 	friend class Shape_External_File_Chunk;
375 
376 };
377 
378 
379 
380 class BMP_Names_Version_Chunk : public Chunk
381 {
382 public:
383 
BMP_Names_Version_Chunk(Chunk_With_Children * parent)384 	BMP_Names_Version_Chunk (Chunk_With_Children * parent)
385 	: Chunk (parent, "BMNAMVER"), version_num (0)
386 	{}
387 	// constructor from buffer
BMP_Names_Version_Chunk(Chunk_With_Children * parent,const char * sdata,size_t)388 	BMP_Names_Version_Chunk (Chunk_With_Children * parent, const char * sdata, size_t /*ssize*/)
389 	: Chunk (parent, "BMNAMVER"), version_num(*(int *)sdata)
390 	{}
391 
392 	virtual size_t size_chunk ();
393 
394 	virtual void fill_data_block (char * data_start);
395 
396 private:
397 
398 	int version_num;
399 
400 	friend class Environment_Data_Chunk;
401 	friend class Chunk_With_BMPs;
402 	friend class Shape_External_File_Chunk;
403 	friend class Sprite_Header_Chunk;
404 
405 
406 };
407 
408 enum GlobalBMPFlags
409 {
410 	GBF_FIXEDPALETTE      = 0x00000001,
411 	GBF_SPRITE            = 0x00000002,
412 	GBF_HISTOGRAMEXISTS   = 0x00000004,
413 	GBF_HISTOGRAMV2EXISTS = 0x00000008,
414 
415 	GBF_NONE = 0,
416 
417 	// IMPORTANT
418 	// since enums are not guaranteed to assume any particular
419 	// storage class, code compiled on different compilers or
420 	// with different settings may result in enums to be written
421 	// to the data block as a char and read back in as an int,
422 	// with the three most significant bytes containing junk.
423 	// THIS MASK MUST BE KEPT UP TO DATE AS THE ENUM IS EXTENDED;
424 	// ALSO ENSURE THAT NEW FILES LOADED INTO OLD SOFTWARE WILL
425 	// NOT HAVE THEIR ENUM VALUE OVER-MASKED; THE MASK IS ONLY
426 	// HERE TO ATTEMPT TO REMOVE PROBLEMS FROM FILES MADE
427 	// PRIOR TO ITS INTRODUCTION
428 	GBF_MASK = 0x000000ff
429 };
430 
431 class BMP_Names_ExtraData
432 {
433 public:
434 	GlobalBMPFlags flags;
435 protected:
436 	int reserved[12];
437 };
438 
439 
440 class BMP_Names_ExtraData_Chunk : public Chunk, public BMP_Names_ExtraData
441 {
442 public:
443 
BMP_Names_ExtraData_Chunk(Chunk_With_Children * parent)444 	BMP_Names_ExtraData_Chunk (Chunk_With_Children * parent)
445 	: Chunk (parent, "BMNAMEXT")
446 	{
447 		for (int i=0; i<12; ++i) reserved[i] = 0;
448 		flags = GBF_NONE;
449 	}
450 
451 	// constructor from buffer
BMP_Names_ExtraData_Chunk(Chunk_With_Children * parent,const char * sdata,size_t)452 	BMP_Names_ExtraData_Chunk (Chunk_With_Children * parent, const char * sdata, size_t /*ssize*/)
453 	: Chunk (parent, "BMNAMEXT")
454 	{
455 		flags = (GlobalBMPFlags)(*(int *)sdata & GBF_MASK);
456 		sdata += 4;
457 		for (int i=0; i<12; ++i, sdata+=4) reserved[i] = *(int *)sdata;
458 	}
459 
460 private:
461 
462 	virtual size_t size_chunk ();
463 
464 	virtual void fill_data_block (char * data_start);
465 
466 	friend class Environment_Data_Chunk;
467 	friend class Shape_External_File_Chunk;
468 	friend class Sprite_Header_Chunk;
469 
470 
471 };
472 
473 
474 class External_Shape_BMPs_Store_Chunk : public Chunk_With_BMPs, protected BMP_Names_ExtraData
475 {
476 public:
477 	char * rifname; // to match one in RIF_Child_Chunk
478 	char * shapename; // matches rif name of original shape
479 
480 	External_Shape_BMPs_Store_Chunk (Chunk_With_Children * parent, char const * rifn, char const * shapen);
481 	External_Shape_BMPs_Store_Chunk (Chunk_With_Children * parent, const char * sdata, size_t ssize);
482 	~External_Shape_BMPs_Store_Chunk();
483 
get_version_num(void)484 	virtual int get_version_num(void) { return version_num; }
set_version_num(int v)485 	virtual void set_version_num(int v) { version_num = v; }
inc_version_num(void)486 	virtual void inc_version_num(void) { ++version_num; }
GetExtendedData(void)487 	virtual BMP_Names_ExtraData * GetExtendedData(void) { return this; }
488 
489 private:
490 	virtual Bitmap_MD5_Chunk * GetMD5Chunk(char const * bname);
491 	virtual void CreateMD5Chunk(BMP_Name const & rcbmp, int const * md5id);
492 
493 	int version_num;
494 
size_chunk()495 	virtual size_t size_chunk()
496 	{
497 		return chunk_size = Chunk_With_BMPs::size_chunk() + ((rifname ? strlen(rifname) : 0) + (shapename ? strlen(shapename) : 0)+2 +3&~3) + 56;
498 	}
499 
500 	virtual void fill_data_block(char * data_start);
501 
502 
503 
504 	friend class Environment_Game_Mode_Chunk;
505 };
506 
507 
508 // for dealing with matching images
509 
510 enum IDscFlags
511 {
512 	IDSCF_SPRITE       = 0x00000001, // image is in a sprite
513 	IDSCF_INCLUDED     = 0x00000002, // image is from another rif file
514 	IDSCF_FIXEDPALETTE = 0x00000004, // image has pgms for fixed palette
515 	IDSCF_SUBSHAPE     = 0x00000008, // image for shape included from another file
516 
517 	IDSCF_0 = 0,
518 
519 	// IMPORTANT
520 	// since enums are not guaranteed to assume any particular
521 	// storage class, code compiled on different compilers or
522 	// with different settings may result in enums to be written
523 	// to the data block as a char and read back in as an int,
524 	// with the three most significant bytes containing junk.
525 	// THIS MASK MUST BE KEPT UP TO DATE AS THE ENUM IS EXTENDED;
526 	// ALSO ENSURE THAT NEW FILES LOADED INTO OLD SOFTWARE WILL
527 	// NOT HAVE THEIR ENUM VALUE OVER-MASKED; THE MASK IS ONLY
528 	// HERE TO ATTEMPT TO REMOVE PROBLEMS FROM FILES MADE
529 	// PRIOR TO ITS INTRODUCTION
530 	IDSCF_MASK = 0x000000ff
531 };
532 
533 class ImageDescriptor
534 {
535 public:
536 	// constructos;
537 	ImageDescriptor();
538 	ImageDescriptor(ImageDescriptor const &);
539 	ImageDescriptor(IDscFlags, char const * fname, char const * rname = 0, char const * xname = 0);
540 	~ImageDescriptor();
541 	ImageDescriptor & operator = (ImageDescriptor const &);
542 
543 	// operators
544 	BOOL operator == (ImageDescriptor const &) const;
operator !=(ImageDescriptor const & id2) const545 	inline BOOL operator != (ImageDescriptor const & id2) const
546 		{ return ! operator == (id2); }
547 
548 	// members
549 	IDscFlags flags;
550 
551 	char * filename; // name.bmp
552 	char * rifname; // only if IDSCF_INCLUDED is set
553 	char * fixrifname; // only if IDSCF_FIXEDPALETTE is set
554 
555 private:
556 	// I/O
557 	ImageDescriptor(char const * datablock);
558 	size_t Size() const;
559 	void WriteData(char * datablock) const;
560 
561 	friend class MatchingImages;
562 
563 	int spares[3];
564 };
565 
566 class MatchingImages
567 {
568 public:
569 	// constructos;
MatchingImages()570 	MatchingImages() {}
571 	MatchingImages(ImageDescriptor const & _load, ImageDescriptor const & _insteadof);
572 
573 	// operators
operator ==(MatchingImages const & m2)574 	inline BOOL operator == (MatchingImages const & m2)
575 		{ return load == m2.load && insteadof == m2.insteadof; }
operator !=(MatchingImages const & m2)576 	inline BOOL operator != (MatchingImages const & m2)
577 		{ return load != m2.load || insteadof != m2.insteadof; }
578 
579 	// members
580 	ImageDescriptor load;
581 	ImageDescriptor insteadof;
582 
583 private:
584 
585 	// I/O
586 	MatchingImages(char const * datablock);
587 	size_t Size() const;
588 	void WriteData(char * datablock) const;
589 
590 	friend class Matching_Images_Chunk;
591 
592 	int spares[3];
593 
594 };
595 
596 enum MICFlags
597 {
598 	MICF_0 = 0,
599 
600 	MICF_FIXEDPALETTE = 0x00000001,
601 
602 	// IMPORTANT
603 	// since enums are not guaranteed to assume any particular
604 	// storage class, code compiled on different compilers or
605 	// with different settings may result in enums to be written
606 	// to the data block as a char and read back in as an int,
607 	// with the three most significant bytes containing junk.
608 	// THIS MASK MUST BE KEPT UP TO DATE AS THE ENUM IS EXTENDED;
609 	// ALSO ENSURE THAT NEW FILES LOADED INTO OLD SOFTWARE WILL
610 	// NOT HAVE THEIR ENUM VALUE OVER-MASKED; THE MASK IS ONLY
611 	// HERE TO ATTEMPT TO REMOVE PROBLEMS FROM FILES MADE
612 	// PRIOR TO ITS INTRODUCTION
613 	MICF_MASK = 0x000000ff
614 };
615 
616 class Matching_Images_Chunk : public Chunk
617 {
618 public:
619 	// constructors
Matching_Images_Chunk(Chunk_With_Children * parent)620 	Matching_Images_Chunk(Chunk_With_Children * parent)	: Chunk(parent,"MATCHIMG"), flags(MICF_0)
621 		{ spares[0]=0; spares[1]=0; } // empty list
622 	// I/O
623 	Matching_Images_Chunk(Chunk_With_Children * parent, char const * datablock, size_t);
624 	// members
625 	List<MatchingImages> mlist;
626 
627 	MICFlags flags;
628 
629 	// methods
630 	ImageDescriptor const & GetLoadImage(ImageDescriptor const &);
631 
632 private:
633 	int spares[2];
634 
635 
636 	virtual size_t size_chunk();
637 	virtual void fill_data_block(char * data_start);
638 
639 	friend class Environment_Data_Chunk;
640 	friend class Environment_Game_Mode_Chunk;
641 };
642 
643 enum BMPMD5_Flags
644 {
645 	BMD5F_0 = 0,
646 
647 	BMD5F_SPRITE = 0x00000001,
648 
649 	// IMPORTANT
650 	// since enums are not guaranteed to assume any particular
651 	// storage class, code compiled on different compilers or
652 	// with different settings may result in enums to be written
653 	// to the data block as a char and read back in as an int,
654 	// with the three most significant bytes containing junk.
655 	// THIS MASK MUST BE KEPT UP TO DATE AS THE ENUM IS EXTENDED;
656 	// ALSO ENSURE THAT NEW FILES LOADED INTO OLD SOFTWARE WILL
657 	// NOT HAVE THEIR ENUM VALUE OVER-MASKED; THE MASK IS ONLY
658 	// HERE TO ATTEMPT TO REMOVE PROBLEMS FROM FILES MADE
659 	// PRIOR TO ITS INTRODUCTION
660 	BMD5F_MASK = 0x000000ff
661 };
662 
663 class Bitmap_MD5_Chunk : public Chunk
664 {
665 public :
666 	Bitmap_MD5_Chunk(Chunk_With_Children * parent, char const * datablock, size_t);
667 private:
668 	Bitmap_MD5_Chunk(Chunk_With_Children * parent, int const * md5id, BMP_Name const & rcbmp, char const * rname = 0, char const * sname = 0);
669 	~Bitmap_MD5_Chunk();
670 	int md5_val[4];
671 	char * bmpname;
672 	char * rifname;
673 	char * shapename;
674 	BMPMD5_Flags flags;
675 	int version_num;
676 
677 	int spare;
678 
679 	virtual size_t size_chunk();
680 	virtual void fill_data_block(char * data_start);
681 
682 	// your parents are your friends
683 	friend class Environment_Data_Chunk;
684 	friend class Environment_Game_Mode_Chunk;
685 	friend class Shape_External_File_Chunk;
686 	friend class Sprite_Header_Chunk;
687 	// some of your siblings are friends as well
688 	friend class Chunk_With_BMPs;
689 	friend class Global_BMP_Name_Chunk;
690 	friend class Bitmap_List_Store_Chunk;
691 	friend class External_Shape_BMPs_Store_Chunk;
692 	friend class RIF_Child_Chunk;
693 };
694 
695 
696 
697 #endif
698