1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __PALETTE_HPP_
|
---|
10 | #define __PALETTE_HPP_
|
---|
11 |
|
---|
12 | #include "arch.hh"
|
---|
13 | #include "isllist.hh"
|
---|
14 | #include "init/init.hh"
|
---|
15 |
|
---|
16 | enum i4_pixel_depth
|
---|
17 | {
|
---|
18 | I4_32BIT=0, // 16.7 mil & alpha
|
---|
19 | I4_16BIT=1, // 64K color
|
---|
20 | I4_8BIT=2, // 256 color
|
---|
21 | I4_4BIT=3, // 16 color
|
---|
22 | I4_2BIT=4 // 2 color
|
---|
23 | } ;
|
---|
24 |
|
---|
25 | class i4_file_class;
|
---|
26 | struct i4_pixel_format
|
---|
27 | {
|
---|
28 | // these not valid for 2,4, and 8 bit pixel depths
|
---|
29 | w32 red_mask, red_shift, red_bits;
|
---|
30 | w32 green_mask, green_shift, green_bits;
|
---|
31 | w32 blue_mask, blue_shift, blue_bits;
|
---|
32 | w32 alpha_mask, alpha_shift, alpha_bits;
|
---|
33 |
|
---|
34 | // lookup is not valid for 16 & 32 bit pixel depths
|
---|
35 | w32 *lookup;
|
---|
36 |
|
---|
37 | i4_pixel_depth pixel_depth;
|
---|
38 |
|
---|
39 | void calc_shift();
|
---|
40 |
|
---|
41 | void default_format();
|
---|
42 | w32 write(i4_file_class *f);
|
---|
43 | void read(i4_file_class *f);
|
---|
44 | };
|
---|
45 |
|
---|
46 | class i4_pal
|
---|
47 | {
|
---|
48 | public:
|
---|
49 | i4_pal *next;
|
---|
50 |
|
---|
51 | i4_pixel_format source;
|
---|
52 |
|
---|
53 | virtual i4_bool can_convert(const i4_pixel_format *source_fmt,
|
---|
54 | const i4_pixel_format *dest_fmt) const = 0;
|
---|
55 |
|
---|
56 | virtual i4_color convert(const i4_color source_pixel,
|
---|
57 | const i4_pixel_format *dest_fmt) const = 0;
|
---|
58 |
|
---|
59 | virtual ~i4_pal() { ; }
|
---|
60 | };
|
---|
61 |
|
---|
62 | class i4_lookup_pal : public i4_pal
|
---|
63 | {
|
---|
64 | public:
|
---|
65 | virtual i4_bool can_convert(const i4_pixel_format *source,
|
---|
66 | const i4_pixel_format *dest) const;
|
---|
67 |
|
---|
68 | virtual i4_color convert(const i4_color source,
|
---|
69 | const i4_pixel_format *dest) const;
|
---|
70 |
|
---|
71 | i4_lookup_pal(i4_pixel_format *source);
|
---|
72 | virtual ~i4_lookup_pal();
|
---|
73 |
|
---|
74 | };
|
---|
75 |
|
---|
76 | class i4_rgb_pal : public i4_pal
|
---|
77 | {
|
---|
78 | public:
|
---|
79 | i4_rgb_pal(i4_pixel_format *source);
|
---|
80 |
|
---|
81 | virtual i4_bool can_convert(const i4_pixel_format *source,
|
---|
82 | const i4_pixel_format *dest) const;
|
---|
83 |
|
---|
84 | virtual i4_color convert(const i4_color source,
|
---|
85 | const i4_pixel_format *dest) const;
|
---|
86 |
|
---|
87 |
|
---|
88 | };
|
---|
89 |
|
---|
90 |
|
---|
91 | class i4_pal_manager_class : public i4_init_class
|
---|
92 | {
|
---|
93 | i4_isl_list<i4_pal> pal_list;
|
---|
94 |
|
---|
95 | i4_pal *def32, *def_na_32, *def8;
|
---|
96 |
|
---|
97 | public:
|
---|
98 | void init();
|
---|
99 | void uninit();
|
---|
100 |
|
---|
101 | i4_pal *register_pal(i4_pixel_format *format);
|
---|
102 |
|
---|
103 | // c will be converted from 32bit color to dest_format
|
---|
104 | i4_color convert_32_to(i4_color c, const i4_pixel_format *dest_format) const;
|
---|
105 |
|
---|
106 | // c will be converted from source_format to 32bit color
|
---|
107 | i4_color convert_to_32(i4_color c, const i4_pal *source_format) const;
|
---|
108 |
|
---|
109 | const i4_pal *default_no_alpha_32() { return def_na_32; }
|
---|
110 | const i4_pal *default_32() { return def32; }
|
---|
111 | const i4_pal *default_8() { return def8; }
|
---|
112 | } ;
|
---|
113 |
|
---|
114 | extern i4_pal_manager_class i4_pal_man;
|
---|
115 |
|
---|
116 | w32 g1_light_color(w32 color_32bit, float intensity);
|
---|
117 |
|
---|
118 | #endif
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|