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