root / hw / blizzard_template.h @ 59d94130
History | View | Annotate | Download (4.1 kB)
1 |
/*
|
---|---|
2 |
* QEMU Epson S1D13744/S1D13745 templates
|
3 |
*
|
4 |
* Copyright (C) 2008 Nokia Corporation
|
5 |
* Written by Andrzej Zaborowski <andrew@openedhand.com>
|
6 |
*
|
7 |
* This program is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU General Public License as
|
9 |
* published by the Free Software Foundation; either version 2 or
|
10 |
* (at your option) version 3 of the License.
|
11 |
*
|
12 |
* This program is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU General Public License along
|
18 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
*/
|
21 |
|
22 |
#define SKIP_PIXEL(to) to += deststep
|
23 |
#if DEPTH == 8 |
24 |
# define PIXEL_TYPE uint8_t
|
25 |
# define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
26 |
# define COPY_PIXEL1(to, from) *to ++ = from
|
27 |
#elif DEPTH == 15 || DEPTH == 16 |
28 |
# define PIXEL_TYPE uint16_t
|
29 |
# define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
30 |
# define COPY_PIXEL1(to, from) *to ++ = from
|
31 |
#elif DEPTH == 24 |
32 |
# define PIXEL_TYPE uint8_t
|
33 |
# define COPY_PIXEL(to, from) \
|
34 |
to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to) |
35 |
# define COPY_PIXEL1(to, from) \
|
36 |
*to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16 |
37 |
#elif DEPTH == 32 |
38 |
# define PIXEL_TYPE uint32_t
|
39 |
# define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
40 |
# define COPY_PIXEL1(to, from) *to ++ = from
|
41 |
#else
|
42 |
# error unknown bit depth
|
43 |
#endif
|
44 |
|
45 |
#ifdef WORDS_BIGENDIAN
|
46 |
# define SWAP_WORDS 1 |
47 |
#endif
|
48 |
|
49 |
static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, |
50 |
const uint16_t *src, unsigned int width) |
51 |
{ |
52 |
#if !defined(SWAP_WORDS) && DEPTH == 16 |
53 |
memcpy(dest, src, width); |
54 |
#else
|
55 |
uint16_t data; |
56 |
unsigned int r, g, b; |
57 |
const uint16_t *end = (const void *) src + width; |
58 |
while (src < end) {
|
59 |
data = lduw_raw(src ++); |
60 |
b = (data & 0x1f) << 3; |
61 |
data >>= 5;
|
62 |
g = (data & 0x3f) << 2; |
63 |
data >>= 6;
|
64 |
r = (data & 0x1f) << 3; |
65 |
data >>= 5;
|
66 |
COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); |
67 |
} |
68 |
#endif
|
69 |
} |
70 |
|
71 |
static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, |
72 |
const uint8_t *src, unsigned int width) |
73 |
{ |
74 |
/* TODO: check if SDL 24-bit planes are not in the same format and
|
75 |
* if so, use memcpy */
|
76 |
unsigned int r[2], g[2], b[2]; |
77 |
const uint8_t *end = src + width;
|
78 |
while (src < end) {
|
79 |
g[0] = *src ++;
|
80 |
r[0] = *src ++;
|
81 |
r[1] = *src ++;
|
82 |
b[0] = *src ++;
|
83 |
COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[0], g[0], b[0])); |
84 |
b[1] = *src ++;
|
85 |
g[1] = *src ++;
|
86 |
COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[1], g[1], b[1])); |
87 |
} |
88 |
} |
89 |
|
90 |
static void glue(blizzard_draw_line24mode2_, DEPTH)(PIXEL_TYPE *dest, |
91 |
const uint8_t *src, unsigned int width) |
92 |
{ |
93 |
unsigned int r, g, b; |
94 |
const uint8_t *end = src + width;
|
95 |
while (src < end) {
|
96 |
r = *src ++; |
97 |
src ++; |
98 |
b = *src ++; |
99 |
g = *src ++; |
100 |
COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); |
101 |
} |
102 |
} |
103 |
|
104 |
/* No rotation */
|
105 |
static blizzard_fn_t glue(blizzard_draw_fn_, DEPTH)[0x10] = { |
106 |
NULL,
|
107 |
/* RGB 5:6:5*/
|
108 |
(blizzard_fn_t) glue(blizzard_draw_line16_, DEPTH), |
109 |
/* RGB 6:6:6 mode 1 */
|
110 |
(blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH), |
111 |
/* RGB 8:8:8 mode 1 */
|
112 |
(blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH), |
113 |
NULL, NULL, |
114 |
/* RGB 6:6:6 mode 2 */
|
115 |
(blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH), |
116 |
/* RGB 8:8:8 mode 2 */
|
117 |
(blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH), |
118 |
/* YUV 4:2:2 */
|
119 |
NULL,
|
120 |
/* YUV 4:2:0 */
|
121 |
NULL,
|
122 |
NULL, NULL, NULL, NULL, NULL, NULL, |
123 |
}; |
124 |
|
125 |
/* 90deg, 180deg and 270deg rotation */
|
126 |
static blizzard_fn_t glue(blizzard_draw_fn_r_, DEPTH)[0x10] = { |
127 |
/* TODO */
|
128 |
[0 ... 0xf] = NULL, |
129 |
}; |
130 |
|
131 |
#undef DEPTH
|
132 |
#undef SKIP_PIXEL
|
133 |
#undef COPY_PIXEL
|
134 |
#undef COPY_PIXEL1
|
135 |
#undef PIXEL_TYPE
|
136 |
|
137 |
#undef SWAP_WORDS
|