summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-03-08 07:29:42 +0000
committerJens Arnold <amiconn@rockbox.org>2006-03-08 07:29:42 +0000
commit93113f5645fa917864b3f93d9e8d34f269b80b3a (patch)
treece6e67356d93ea6264dd3ba1dc5c7c3fa50e5b2d
parent9d75acbaf706912082c967f79e9c01637ed55f54 (diff)
downloadrockbox-93113f5645fa917864b3f93d9e8d34f269b80b3a.tar.gz
rockbox-93113f5645fa917864b3f93d9e8d34f269b80b3a.zip
The LCD extension lib was split into 3 parts: Removed old file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8954 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/lib/xlcd.c477
1 files changed, 0 insertions, 477 deletions
diff --git a/apps/plugins/lib/xlcd.c b/apps/plugins/lib/xlcd.c
deleted file mode 100644
index 9b03a16b6a..0000000000
--- a/apps/plugins/lib/xlcd.c
+++ /dev/null
@@ -1,477 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Additional LCD routines not present in the core itself
11*
12* Copyright (C) 2005 Jens Arnold
13*
14* All files in this archive are subject to the GNU General Public License.
15* See the file COPYING in the source tree root for full license agreement.
16*
17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18* KIND, either express or implied.
19*
20****************************************************************************/
21
22#include "plugin.h"
23
24#ifdef HAVE_LCD_BITMAP
25
26/*** globals ***/
27
28static struct plugin_api *local_rb = NULL; /* global api struct pointer */
29
30/*** functions ***/
31
32/* library init */
33void xlcd_init(struct plugin_api* newrb)
34{
35 local_rb = newrb;
36}
37
38#if (LCD_DEPTH >= 8) || (LCD_PIXELFORMAT == HORIZONTAL_PACKING)
39/* draw a filled triangle, using horizontal lines for speed */
40void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
41{
42 int x, y;
43 long fp_x1, fp_x2, fp_dx1, fp_dx2;
44
45 /* sort vertices by increasing y value */
46 if (y1 > y3)
47 {
48 if (y2 < y3) /* y2 < y3 < y1 */
49 {
50 x = x1; x1 = x2; x2 = x3; x3 = x;
51 y = y1; y1 = y2; y2 = y3; y3 = y;
52 }
53 else if (y2 > y1) /* y3 < y1 < y2 */
54 {
55 x = x1; x1 = x3; x3 = x2; x2 = x;
56 y = y1; y1 = y3; y3 = y2; y2 = y;
57 }
58 else /* y3 <= y2 <= y1 */
59 {
60 x = x1; x1 = x3; x3 = x;
61 y = y1; y1 = y3; y3 = y;
62 }
63 }
64 else
65 {
66 if (y2 < y1) /* y2 < y1 <= y3 */
67 {
68 x = x1; x1 = x2; x2 = x;
69 y = y1; y1 = y2; y2 = y;
70 }
71 else if (y2 > y3) /* y1 <= y3 < y2 */
72 {
73 x = x2; x2 = x3; x3 = x;
74 y = y2; y2 = y3; y3 = y;
75 }
76 /* else already sorted */
77 }
78
79 if (y1 < y3) /* draw */
80 {
81 fp_dx1 = ((x3 - x1) << 16) / (y3 - y1);
82 fp_x1 = (x1 << 16) + (1<<15) + (fp_dx1 >> 1);
83
84 if (y1 < y2) /* first part */
85 {
86 fp_dx2 = ((x2 - x1) << 16) / (y2 - y1);
87 fp_x2 = (x1 << 16) + (1<<15) + (fp_dx2 >> 1);
88 for (y = y1; y < y2; y++)
89 {
90 local_rb->lcd_hline(fp_x1 >> 16, fp_x2 >> 16, y);
91 fp_x1 += fp_dx1;
92 fp_x2 += fp_dx2;
93 }
94 }
95 if (y2 < y3) /* second part */
96 {
97 fp_dx2 = ((x3 - x2) << 16) / (y3 - y2);
98 fp_x2 = (x2 << 16) + (1<<15) + (fp_dx2 >> 1);
99 for (y = y2; y < y3; y++)
100 {
101 local_rb->lcd_hline(fp_x1 >> 16, fp_x2 >> 16, y);
102 fp_x1 += fp_dx1;
103 fp_x2 += fp_dx2;
104 }
105 }
106 }
107}
108#else /* (LCD_DEPTH < 8) && (LCD_PIXELFORMAT == VERTICAL_PACKING) */
109/* draw a filled triangle, using vertical lines for speed */
110void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
111{
112 int x, y;
113 long fp_y1, fp_y2, fp_dy1, fp_dy2;
114
115 /* sort vertices by increasing x value */
116 if (x1 > x3)
117 {
118 if (x2 < x3) /* x2 < x3 < x1 */
119 {
120 x = x1; x1 = x2; x2 = x3; x3 = x;
121 y = y1; y1 = y2; y2 = y3; y3 = y;
122 }
123 else if (x2 > x1) /* x3 < x1 < x2 */
124 {
125 x = x1; x1 = x3; x3 = x2; x2 = x;
126 y = y1; y1 = y3; y3 = y2; y2 = y;
127 }
128 else /* x3 <= x2 <= x1 */
129 {
130 x = x1; x1 = x3; x3 = x;
131 y = y1; y1 = y3; y3 = y;
132 }
133 }
134 else
135 {
136 if (x2 < x1) /* x2 < x1 <= x3 */
137 {
138 x = x1; x1 = x2; x2 = x;
139 y = y1; y1 = y2; y2 = y;
140 }
141 else if (x2 > x3) /* x1 <= x3 < x2 */
142 {
143 x = x2; x2 = x3; x3 = x;
144 y = y2; y2 = y3; y3 = y;
145 }
146 /* else already sorted */
147 }
148
149 if (x1 < x3) /* draw */
150 {
151 fp_dy1 = ((y3 - y1) << 16) / (x3 - x1);
152 fp_y1 = (y1 << 16) + (1<<15) + (fp_dy1 >> 1);
153
154 if (x1 < x2) /* first part */
155 {
156 fp_dy2 = ((y2 - y1) << 16) / (x2 - x1);
157 fp_y2 = (y1 << 16) + (1<<15) + (fp_dy2 >> 1);
158 for (x = x1; x < x2; x++)
159 {
160 local_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
161 fp_y1 += fp_dy1;
162 fp_y2 += fp_dy2;
163 }
164 }
165 if (x2 < x3) /* second part */
166 {
167 fp_dy2 = ((y3 - y2) << 16) / (x3 - x2);
168 fp_y2 = (y2 << 16) + (1<<15) + (fp_dy2 >> 1);
169 for (x = x2; x < x3; x++)
170 {
171 local_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
172 fp_y1 += fp_dy1;
173 fp_y2 += fp_dy2;
174 }
175 }
176 }
177}
178#endif /* LCD_DEPTH, LCD_PIXELFORMAT */
179
180#if LCD_DEPTH >= 8
181
182#ifdef HAVE_LCD_COLOR
183static const fb_data graylut[256] = {
184#if LCD_PIXELFORMAT == RGB565
185 0x0000, 0x0000, 0x0000, 0x0020, 0x0020, 0x0821, 0x0821, 0x0841,
186 0x0841, 0x0841, 0x0841, 0x0861, 0x0861, 0x1062, 0x1062, 0x1082,
187 0x1082, 0x1082, 0x1082, 0x10a2, 0x10a2, 0x18a3, 0x18a3, 0x18c3,
188 0x18c3, 0x18c3, 0x18c3, 0x18e3, 0x18e3, 0x20e4, 0x20e4, 0x2104,
189 0x2104, 0x2104, 0x2104, 0x2124, 0x2124, 0x2124, 0x2925, 0x2945,
190 0x2945, 0x2945, 0x2945, 0x2965, 0x2965, 0x2965, 0x3166, 0x3186,
191 0x3186, 0x3186, 0x3186, 0x31a6, 0x31a6, 0x31a6, 0x39a7, 0x39c7,
192 0x39c7, 0x39c7, 0x39c7, 0x39e7, 0x39e7, 0x39e7, 0x41e8, 0x4208,
193 0x4208, 0x4208, 0x4208, 0x4228, 0x4228, 0x4228, 0x4a29, 0x4a49,
194 0x4a49, 0x4a49, 0x4a49, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x528a,
195 0x528a, 0x528a, 0x528a, 0x52aa, 0x52aa, 0x52aa, 0x52aa, 0x5aab,
196 0x5acb, 0x5acb, 0x5acb, 0x5acb, 0x5aeb, 0x5aeb, 0x5aeb, 0x62ec,
197 0x630c, 0x630c, 0x630c, 0x630c, 0x632c, 0x632c, 0x632c, 0x6b2d,
198 0x6b4d, 0x6b4d, 0x6b4d, 0x6b4d, 0x6b6d, 0x6b6d, 0x6b6d, 0x6b6d,
199 0x738e, 0x738e, 0x738e, 0x738e, 0x73ae, 0x73ae, 0x73ae, 0x73ae,
200 0x7bcf, 0x7bcf, 0x7bcf, 0x7bcf, 0x7bef, 0x7bef, 0x7bef, 0x7bef,
201 0x8410, 0x8410, 0x8410, 0x8410, 0x8430, 0x8430, 0x8430, 0x8430,
202 0x8c51, 0x8c51, 0x8c51, 0x8c51, 0x8c71, 0x8c71, 0x8c71, 0x8c71,
203 0x9492, 0x9492, 0x9492, 0x9492, 0x94b2, 0x94b2, 0x94b2, 0x94b2,
204 0x94d2, 0x9cd3, 0x9cd3, 0x9cd3, 0x9cf3, 0x9cf3, 0x9cf3, 0x9cf3,
205 0x9d13, 0xa514, 0xa514, 0xa514, 0xa534, 0xa534, 0xa534, 0xa534,
206 0xa554, 0xad55, 0xad55, 0xad55, 0xad55, 0xad75, 0xad75, 0xad75,
207 0xad75, 0xb596, 0xb596, 0xb596, 0xb596, 0xb5b6, 0xb5b6, 0xb5b6,
208 0xb5b6, 0xb5d6, 0xbdd7, 0xbdd7, 0xbdd7, 0xbdf7, 0xbdf7, 0xbdf7,
209 0xbdf7, 0xbe17, 0xc618, 0xc618, 0xc618, 0xc638, 0xc638, 0xc638,
210 0xc638, 0xc658, 0xce59, 0xce59, 0xce59, 0xce79, 0xce79, 0xce79,
211 0xce79, 0xce99, 0xd69a, 0xd69a, 0xd69a, 0xd6ba, 0xd6ba, 0xd6ba,
212 0xd6ba, 0xd6da, 0xd6da, 0xdedb, 0xdedb, 0xdefb, 0xdefb, 0xdefb,
213 0xdefb, 0xdf1b, 0xdf1b, 0xe71c, 0xe71c, 0xe73c, 0xe73c, 0xe73c,
214 0xe73c, 0xe75c, 0xe75c, 0xef5d, 0xef5d, 0xef7d, 0xef7d, 0xef7d,
215 0xef7d, 0xef9d, 0xef9d, 0xf79e, 0xf79e, 0xf7be, 0xf7be, 0xf7be,
216 0xf7be, 0xf7de, 0xf7de, 0xffdf, 0xffdf, 0xffff, 0xffff, 0xffff
217#elif LCD_PIXELFORMAT == RGB565SWAPPED
218 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2108, 0x2108, 0x4108,
219 0x4108, 0x4108, 0x4108, 0x6108, 0x6108, 0x6210, 0x6210, 0x8210,
220 0x8210, 0x8210, 0x8210, 0xa210, 0xa210, 0xa318, 0xa318, 0xc318,
221 0xc318, 0xc318, 0xc318, 0xe318, 0xe318, 0xe420, 0xe420, 0x0421,
222 0x0421, 0x0421, 0x0421, 0x2421, 0x2421, 0x2421, 0x2529, 0x4529,
223 0x4529, 0x4529, 0x4529, 0x6529, 0x6529, 0x6529, 0x6631, 0x8631,
224 0x8631, 0x8631, 0x8631, 0xa631, 0xa631, 0xa631, 0xa739, 0xc739,
225 0xc739, 0xc739, 0xc739, 0xe739, 0xe739, 0xe739, 0xe841, 0x0842,
226 0x0842, 0x0842, 0x0842, 0x2842, 0x2842, 0x2842, 0x294a, 0x494a,
227 0x494a, 0x494a, 0x494a, 0x694a, 0x694a, 0x694a, 0x694a, 0x8a52,
228 0x8a52, 0x8a52, 0x8a52, 0xaa52, 0xaa52, 0xaa52, 0xaa52, 0xab5a,
229 0xcb5a, 0xcb5a, 0xcb5a, 0xcb5a, 0xeb5a, 0xeb5a, 0xeb5a, 0xec62,
230 0x0c63, 0x0c63, 0x0c63, 0x0c63, 0x2c63, 0x2c63, 0x2c63, 0x2d6b,
231 0x4d6b, 0x4d6b, 0x4d6b, 0x4d6b, 0x6d6b, 0x6d6b, 0x6d6b, 0x6d6b,
232 0x8e73, 0x8e73, 0x8e73, 0x8e73, 0xae73, 0xae73, 0xae73, 0xae73,
233 0xcf7b, 0xcf7b, 0xcf7b, 0xcf7b, 0xef7b, 0xef7b, 0xef7b, 0xef7b,
234 0x1084, 0x1084, 0x1084, 0x1084, 0x3084, 0x3084, 0x3084, 0x3084,
235 0x518c, 0x518c, 0x518c, 0x518c, 0x718c, 0x718c, 0x718c, 0x718c,
236 0x9294, 0x9294, 0x9294, 0x9294, 0xb294, 0xb294, 0xb294, 0xb294,
237 0xd294, 0xd39c, 0xd39c, 0xd39c, 0xf39c, 0xf39c, 0xf39c, 0xf39c,
238 0x139d, 0x14a5, 0x14a5, 0x14a5, 0x34a5, 0x34a5, 0x34a5, 0x34a5,
239 0x54a5, 0x55ad, 0x55ad, 0x55ad, 0x55ad, 0x75ad, 0x75ad, 0x75ad,
240 0x75ad, 0x96b5, 0x96b5, 0x96b5, 0x96b5, 0xb6b5, 0xb6b5, 0xb6b5,
241 0xb6b5, 0xd6b5, 0xd7bd, 0xd7bd, 0xd7bd, 0xf7bd, 0xf7bd, 0xf7bd,
242 0xf7bd, 0x17be, 0x18c6, 0x18c6, 0x18c6, 0x38c6, 0x38c6, 0x38c6,
243 0x38c6, 0x58c6, 0x59ce, 0x59ce, 0x59ce, 0x79ce, 0x79ce, 0x79ce,
244 0x79ce, 0x99ce, 0x9ad6, 0x9ad6, 0x9ad6, 0xbad6, 0xbad6, 0xbad6,
245 0xbad6, 0xdad6, 0xdad6, 0xdbde, 0xdbde, 0xfbde, 0xfbde, 0xfbde,
246 0xfbde, 0x1bdf, 0x1bdf, 0x1ce7, 0x1ce7, 0x3ce7, 0x3ce7, 0x3ce7,
247 0x3ce7, 0x5ce7, 0x5ce7, 0x5def, 0x5def, 0x7def, 0x7def, 0x7def,
248 0x7def, 0x9def, 0x9def, 0x9ef7, 0x9ef7, 0xbef7, 0xbef7, 0xbef7,
249 0xbef7, 0xdef7, 0xdef7, 0xdfff, 0xdfff, 0xffff, 0xffff, 0xffff
250#endif /* LCD_PIXELFORMAT */
251};
252#endif /* HAVE_LCD_COLOR */
253
254/* Draw a partial greyscale bitmap, canonical 8 bit format */
255void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
256 int stride, int x, int y, int width, int height)
257{
258 const unsigned char *src_end;
259 fb_data *dst;
260
261 /* nothing to draw? */
262 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
263 || (x + width <= 0) || (y + height <= 0))
264 return;
265
266 /* clipping */
267 if (x < 0)
268 {
269 width += x;
270 src_x -= x;
271 x = 0;
272 }
273 if (y < 0)
274 {
275 height += y;
276 src_y -= y;
277 y = 0;
278 }
279 if (x + width > LCD_WIDTH)
280 width = LCD_WIDTH - x;
281 if (y + height > LCD_HEIGHT)
282 height = LCD_HEIGHT - y;
283
284 src += stride * src_y + src_x; /* move starting point */
285 src_end = src + stride * height;
286 dst = local_rb->lcd_framebuffer + LCD_WIDTH * y + x;
287
288 do
289 {
290 const unsigned char *src_row = src;
291 const unsigned char *row_end = src_row + width;
292 fb_data *dst_row = dst;
293
294#ifdef HAVE_LCD_COLOR
295 do
296 *dst_row++ = graylut[*src_row++];
297 while (src_row < row_end);
298#endif
299
300 src += stride;
301 dst += LCD_WIDTH;
302 }
303 while (src < src_end);
304}
305
306/* Draw a full greyscale bitmap, canonical 8 bit format */
307void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width,
308 int height)
309{
310 xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
311}
312
313#ifdef HAVE_LCD_COLOR
314/* Draw a partial colour bitmap, canonical 24 bit RGB format */
315void xlcd_color_bitmap_part(const unsigned char *src, int src_x, int src_y,
316 int stride, int x, int y, int width, int height)
317{
318 const unsigned char *src_end;
319 fb_data *dst;
320
321 /* nothing to draw? */
322 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
323 || (x + width <= 0) || (y + height <= 0))
324 return;
325
326 /* clipping */
327 if (x < 0)
328 {
329 width += x;
330 src_x -= x;
331 x = 0;
332 }
333 if (y < 0)
334 {
335 height += y;
336 src_y -= y;
337 y = 0;
338 }
339 if (x + width > LCD_WIDTH)
340 width = LCD_WIDTH - x;
341 if (y + height > LCD_HEIGHT)
342 height = LCD_HEIGHT - y;
343
344 src += 3 * (stride * src_y + src_x); /* move starting point */
345 src_end = src + 3 * stride * height;
346 dst = local_rb->lcd_framebuffer + LCD_WIDTH * y + x;
347
348 do
349 {
350 const unsigned char *src_row = src;
351 const unsigned char *row_end = src_row + 3 * width;
352 fb_data *dst_row = dst;
353
354 do
355 { /* only RGB565 and RGB565SWAPPED so far */
356 unsigned red = 31 * (*src_row++) + 127;
357 unsigned green = 63 * (*src_row++) + 127;
358 unsigned blue = 31 * (*src_row++) + 127;
359
360 red = (red + (red >> 8)) >> 8; /* approx red /= 255: */
361 green = (green + (green >> 8)) >> 8; /* approx green /= 255: */
362 blue = (blue + (blue >> 8)) >> 8; /* approx blue /= 255: */
363
364#if LCD_PIXELFORMAT == RGB565
365 *dst_row++ = (red << 11) | (green << 5) | blue;
366#elif LCD_PIXELFORMAT == RGB565SWAPPED
367 *dst_row++ = swap16((red << 11) | (green << 5) | blue);
368#endif
369 }
370 while (src_row < row_end);
371
372 src += 3 * stride;
373 dst += LCD_WIDTH;
374 }
375 while (src < src_end);
376}
377
378/* Draw a full colour bitmap, canonical 24 bit RGB format */
379void xlcd_color_bitmap(const unsigned char *src, int x, int y, int width,
380 int height)
381{
382 xlcd_color_bitmap_part(src, 0, 0, width, x, y, width, height);
383}
384#endif /* HAVE_LCD_COLOR */
385
386void xlcd_scroll_left(int count)
387{
388 fb_data *data, *data_end;
389 int length, oldmode;
390
391 if ((unsigned)count >= LCD_WIDTH)
392 return;
393
394 data = local_rb->lcd_framebuffer;
395 data_end = data + LCD_WIDTH*LCD_HEIGHT;
396 length = LCD_WIDTH - count;
397
398 do
399 {
400 local_rb->memmove(data, data + count, length * sizeof(fb_data));
401 data += LCD_WIDTH;
402 }
403 while (data < data_end);
404
405 oldmode = local_rb->lcd_get_drawmode();
406 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
407 local_rb->lcd_fillrect(length, 0, count, LCD_HEIGHT);
408 local_rb->lcd_set_drawmode(oldmode);
409}
410
411void xlcd_scroll_right(int count)
412{
413 fb_data *data, *data_end;
414 int length, oldmode;
415
416 if ((unsigned)count >= LCD_WIDTH)
417 return;
418
419 data = local_rb->lcd_framebuffer;
420 data_end = data + LCD_WIDTH*LCD_HEIGHT;
421 length = LCD_WIDTH - count;
422
423 do
424 {
425 local_rb->memmove(data + count, data, length * sizeof(fb_data));
426 data += LCD_WIDTH;
427 }
428 while (data < data_end);
429
430 oldmode = local_rb->lcd_get_drawmode();
431 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
432 local_rb->lcd_fillrect(0, 0, count, LCD_HEIGHT);
433 local_rb->lcd_set_drawmode(oldmode);
434}
435
436void xlcd_scroll_up(int count)
437{
438 long length, oldmode;
439
440 if ((unsigned)count >= LCD_HEIGHT)
441 return;
442
443 length = LCD_HEIGHT - count;
444
445 local_rb->memmove(local_rb->lcd_framebuffer,
446 local_rb->lcd_framebuffer + count * LCD_WIDTH,
447 length * LCD_WIDTH * sizeof(fb_data));
448
449 oldmode = local_rb->lcd_get_drawmode();
450 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
451 local_rb->lcd_fillrect(0, length, LCD_WIDTH, count);
452 local_rb->lcd_set_drawmode(oldmode);
453}
454
455void xlcd_scroll_down(int count)
456{
457 long length, oldmode;
458
459 if ((unsigned)count >= LCD_HEIGHT)
460 return;
461
462 length = LCD_HEIGHT - count;
463
464 local_rb->memmove(local_rb->lcd_framebuffer + count * LCD_WIDTH,
465 local_rb->lcd_framebuffer,
466 length * LCD_WIDTH * sizeof(fb_data));
467
468 oldmode = local_rb->lcd_get_drawmode();
469 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
470 local_rb->lcd_fillrect(0, 0, LCD_WIDTH, count);
471 local_rb->lcd_set_drawmode(oldmode);
472}
473
474#endif /* LCD_DEPTH >= 8 */
475
476#endif /* HAVE_LCD_BITMAP */
477