comparison src/cs/drivers/drv_app/r2d/lcds/E_Sample/R2D_board_esample_lcd_i.c @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1
2
3 static UINT32 r2d_lcd_copy_operator(UINT32 old,UINT32 value)
4 {
5 return(value);
6 }
7
8 static UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value)
9 {
10 if ((value&0x0000FFFF)==0)
11 return(old);
12 else
13 return(value);
14 }
15 static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value)
16 {
17 return(old & value);
18 }
19 static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value)
20 {
21 return(old ^ value) ;
22 }
23 static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value)
24 {
25 return(~value);
26 }
27 static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value)
28 {
29 return(~(old | value));
30 }
31 static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value)
32 {
33 return(~(old & value));
34 }
35 static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value)
36 {
37 return(~(old ^ value)) ;
38 }
39 static UINT32 r2d_lcd_erase_operator(UINT32 old,UINT32 value)
40 {
41 if ((value&0x0FFFF)==0xFFFF)
42 return(0);
43 else
44 return(old);
45 }
46
47 // This operator is meaningless when alpha mode not supported
48 UINT32 r2d_lcd_alpha_operator(UINT32 old,UINT32 value)
49 {
50 UINT16 a,rs,gs,bs,rd,gd,bd;
51 UINT32 big_a;
52
53 big_a=value;
54 big_a=big_a>>16;
55
56 a=big_a;
57
58 if (a)
59 {
60
61 value=(~value) & 0x0FFFFFF;
62 old=(~old) & 0x0FFFFFF;
63
64 bs=(value&0x1F);
65 value=value>>5;
66 gs=(value&0x3F);
67 value=value>>6;
68 rs=(value&0x1F);
69
70
71
72 bd=(old&0x1F);
73 old=old>>5;
74 gd=(old&0x3F);
75 old=old>>6;
76 rd=(old&0x1F);
77
78
79
80
81 // Pixel value has been complemented before being
82 // saved so that the white correspond to 0 and be
83 // compatible with formulas for other modes.
84 // But alpha value is not complemented
85 // So a=0xFF correspond tranparency
86 bd=((a)*bd+(0x100 - a)*bs) >> 8;
87 gd=((a)*gd+(0x100 - a)*gs) >> 8;
88 rd=((a)*rd+(0x100 - a)*rs) >> 8;
89
90
91
92 old=(~((rd<<11)|(gd<<5)|bd)) & 0x000FFFF;
93 return(old);
94 }
95 else
96 return(value);
97 }
98
99
100 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators=
101 {
102 &r2d_lcd_copy_operator,
103 &r2d_lcd_or_operator,
104 &r2d_lcd_and_operator,
105 &r2d_lcd_xor_operator,
106 &r2d_lcd_not_copy_operator,
107 &r2d_lcd_not_or_operator,
108 &r2d_lcd_not_and_operator,
109 &r2d_lcd_not_xor_operator,
110 NULL,
111 &r2d_lcd_erase_operator
112 };
113
114
115 // Return the pixel value to write on the LCD or the offscreen
116 // pixmap
117 // (Convert Riviera color to D-Sample RGB Format with complement)
118 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color)
119 {
120 INT16 r,g,b;
121 UINT32 a;
122
123 gc->foreground_pixel_value=0;
124
125 //a=(r2d_alpha(color)) << 16;
126 //gc->foreground_pixel_value|=a;
127
128 r=(r2d_red(color)&0xF8) >> 3;
129 g=(r2d_green(color)&0xFC) >> 2;
130 b=(r2d_blue(color)&0xF8) >> 3 ;
131
132 gc->foreground_pixel_value|= (~((r<<11) | (g<<5) | b)) & 0x0FFFF;
133
134 }
135
136 // Return the pixel value to write on the LCD or the offscreen
137 // pixmap
138 // (Convert riviera color to D-Sample RGB format with complement)
139 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color)
140 {
141 INT16 r,g,b;
142 UINT32 a;
143
144 gc->background_pixel_value=0;
145
146 //a=(r2d_alpha(color)) << 16;
147 //gc->background_pixel_value|=a;
148
149 r=(r2d_red(color)&0xF8) >> 3 ;
150 g=(r2d_green(color)&0xFC) >> 2 ;
151 b=(r2d_blue(color)&0xF8) >> 3 ;
152
153 gc->background_pixel_value|= (~((r<<11) | (g<<5) | b)) & 0x0FFFF;
154 }
155
156
157
158 // Convert a LCD value (not color) to a value
159 // to be written into the 24bpp framebuffer
160 // In general, the value written is a packed
161 // representation of the ARGB color
162 // but it may be different according to the framebuffer
163 // internal format
164 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc)
165 {
166 if (lcd_value&0x0000FFFF)
167 return(TRUE);
168 else
169 return(FALSE);
170 }
171
172 // Color framebuffer to D-Sample LCD
173 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y)
174 {
175
176 INT16 red,green,blue;
177 UINT32 alpha;
178
179 //alpha=pixel_value & 0xFF000000;
180 //alpha=alpha>>8;
181
182 pixel_value=(~pixel_value) & 0x00FFFFFF;
183 red=r2d_red(pixel_value);
184 green=r2d_green(pixel_value);
185 blue=r2d_blue(pixel_value);
186
187 red=(red&0xF8)>>3;
188 green=(green&0xFC)>>2;
189 blue=(blue&0xF8)>>3;
190
191 //return(((~((red<<11) | (green << 5) | blue)) & 0x0000FFFF) | alpha);
192 return(((~((red<<11) | (green << 5) | blue)) & 0x0000FFFF) );
193 }
194
195 // D-Sample LCD to color framebuffer
196 UINT32 r2d_lcd_to_color(UINT32 color)
197 {
198
199 INT16 r,g,b;
200 UINT32 alpha;
201
202 //alpha=color & 0x00FF0000;
203 // alpha=alpha<<8;
204
205 color=~color;
206 b=(color&0x1F)<<3;
207 color=color>>5;
208 g=(color&0x3F)<<2;
209 color=color>>6;
210 r=(color&0x1F)<<3;
211
212 // return(((~((r<<16) + (g<<8)+b)) & 0x00FFFFFF) | alpha);
213 return(((~((r<<16) + (g<<8)+b)) & 0x00FFFFFF) );
214 }
215
216