root / hw / blizzard_template.h @ 0abaa7c1
History | View | Annotate | Download (4 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 | 8167ee88 | Blue Swirl | * with this program; if not, see <http://www.gnu.org/licenses/>.
|
19 | 7e7c5e4c | balrog | */
|
20 | 7e7c5e4c | balrog | |
21 | 7e7c5e4c | balrog | #define SKIP_PIXEL(to) to += deststep
|
22 | 7e7c5e4c | balrog | #if DEPTH == 8 |
23 | 7e7c5e4c | balrog | # define PIXEL_TYPE uint8_t
|
24 | 7e7c5e4c | balrog | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
25 | 7e7c5e4c | balrog | # define COPY_PIXEL1(to, from) *to ++ = from
|
26 | 7e7c5e4c | balrog | #elif DEPTH == 15 || DEPTH == 16 |
27 | 7e7c5e4c | balrog | # define PIXEL_TYPE uint16_t
|
28 | 7e7c5e4c | balrog | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
29 | 7e7c5e4c | balrog | # define COPY_PIXEL1(to, from) *to ++ = from
|
30 | 7e7c5e4c | balrog | #elif DEPTH == 24 |
31 | 7e7c5e4c | balrog | # define PIXEL_TYPE uint8_t
|
32 | 7e7c5e4c | balrog | # define COPY_PIXEL(to, from) \
|
33 | 7e7c5e4c | balrog | to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to) |
34 | 7e7c5e4c | balrog | # define COPY_PIXEL1(to, from) \
|
35 | 7e7c5e4c | balrog | *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16 |
36 | 7e7c5e4c | balrog | #elif DEPTH == 32 |
37 | 7e7c5e4c | balrog | # define PIXEL_TYPE uint32_t
|
38 | 7e7c5e4c | balrog | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
39 | 7e7c5e4c | balrog | # define COPY_PIXEL1(to, from) *to ++ = from
|
40 | 7e7c5e4c | balrog | #else
|
41 | 7e7c5e4c | balrog | # error unknown bit depth
|
42 | 7e7c5e4c | balrog | #endif
|
43 | 7e7c5e4c | balrog | |
44 | e2542fe2 | Juan Quintela | #ifdef HOST_WORDS_BIGENDIAN
|
45 | 7e7c5e4c | balrog | # define SWAP_WORDS 1 |
46 | 7e7c5e4c | balrog | #endif
|
47 | 7e7c5e4c | balrog | |
48 | 7e7c5e4c | balrog | static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, |
49 | 7e7c5e4c | balrog | const uint16_t *src, unsigned int width) |
50 | 7e7c5e4c | balrog | { |
51 | 7e7c5e4c | balrog | #if !defined(SWAP_WORDS) && DEPTH == 16 |
52 | b21e9863 | balrog | memcpy(dest, src, width); |
53 | 7e7c5e4c | balrog | #else
|
54 | 7e7c5e4c | balrog | uint16_t data; |
55 | 7e7c5e4c | balrog | unsigned int r, g, b; |
56 | b21e9863 | balrog | const uint16_t *end = (const void *) src + width; |
57 | 7e7c5e4c | balrog | while (src < end) {
|
58 | 7e7c5e4c | balrog | data = lduw_raw(src ++); |
59 | 7e7c5e4c | balrog | b = (data & 0x1f) << 3; |
60 | 7e7c5e4c | balrog | data >>= 5;
|
61 | 7e7c5e4c | balrog | g = (data & 0x3f) << 2; |
62 | 7e7c5e4c | balrog | data >>= 6;
|
63 | 7e7c5e4c | balrog | r = (data & 0x1f) << 3; |
64 | 7e7c5e4c | balrog | data >>= 5;
|
65 | 7e7c5e4c | balrog | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); |
66 | 7e7c5e4c | balrog | } |
67 | 7e7c5e4c | balrog | #endif
|
68 | 7e7c5e4c | balrog | } |
69 | 7e7c5e4c | balrog | |
70 | 7e7c5e4c | balrog | static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, |
71 | 7e7c5e4c | balrog | const uint8_t *src, unsigned int width) |
72 | 7e7c5e4c | balrog | { |
73 | 7e7c5e4c | balrog | /* TODO: check if SDL 24-bit planes are not in the same format and
|
74 | 7e7c5e4c | balrog | * if so, use memcpy */
|
75 | 7e7c5e4c | balrog | unsigned int r[2], g[2], b[2]; |
76 | 7e7c5e4c | balrog | const uint8_t *end = src + width;
|
77 | 7e7c5e4c | balrog | while (src < end) {
|
78 | 7e7c5e4c | balrog | g[0] = *src ++;
|
79 | 7e7c5e4c | balrog | r[0] = *src ++;
|
80 | 7e7c5e4c | balrog | r[1] = *src ++;
|
81 | 7e7c5e4c | balrog | b[0] = *src ++;
|
82 | 7e7c5e4c | balrog | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[0], g[0], b[0])); |
83 | 7e7c5e4c | balrog | b[1] = *src ++;
|
84 | 7e7c5e4c | balrog | g[1] = *src ++;
|
85 | 7e7c5e4c | balrog | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[1], g[1], b[1])); |
86 | 7e7c5e4c | balrog | } |
87 | 7e7c5e4c | balrog | } |
88 | 7e7c5e4c | balrog | |
89 | 7e7c5e4c | balrog | static void glue(blizzard_draw_line24mode2_, DEPTH)(PIXEL_TYPE *dest, |
90 | 7e7c5e4c | balrog | const uint8_t *src, unsigned int width) |
91 | 7e7c5e4c | balrog | { |
92 | 7e7c5e4c | balrog | unsigned int r, g, b; |
93 | 7e7c5e4c | balrog | const uint8_t *end = src + width;
|
94 | 7e7c5e4c | balrog | while (src < end) {
|
95 | 7e7c5e4c | balrog | r = *src ++; |
96 | 7e7c5e4c | balrog | src ++; |
97 | 7e7c5e4c | balrog | b = *src ++; |
98 | 7e7c5e4c | balrog | g = *src ++; |
99 | 7e7c5e4c | balrog | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); |
100 | 7e7c5e4c | balrog | } |
101 | 7e7c5e4c | balrog | } |
102 | 7e7c5e4c | balrog | |
103 | 7e7c5e4c | balrog | /* No rotation */
|
104 | 7e7c5e4c | balrog | static blizzard_fn_t glue(blizzard_draw_fn_, DEPTH)[0x10] = { |
105 | 7e7c5e4c | balrog | NULL,
|
106 | 7e7c5e4c | balrog | /* RGB 5:6:5*/
|
107 | 7e7c5e4c | balrog | (blizzard_fn_t) glue(blizzard_draw_line16_, DEPTH), |
108 | 7e7c5e4c | balrog | /* RGB 6:6:6 mode 1 */
|
109 | 7e7c5e4c | balrog | (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH), |
110 | 7e7c5e4c | balrog | /* RGB 8:8:8 mode 1 */
|
111 | 7e7c5e4c | balrog | (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH), |
112 | 7e7c5e4c | balrog | NULL, NULL, |
113 | 7e7c5e4c | balrog | /* RGB 6:6:6 mode 2 */
|
114 | 7e7c5e4c | balrog | (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH), |
115 | 7e7c5e4c | balrog | /* RGB 8:8:8 mode 2 */
|
116 | 7e7c5e4c | balrog | (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH), |
117 | 7e7c5e4c | balrog | /* YUV 4:2:2 */
|
118 | 7e7c5e4c | balrog | NULL,
|
119 | 7e7c5e4c | balrog | /* YUV 4:2:0 */
|
120 | 7e7c5e4c | balrog | NULL,
|
121 | 7e7c5e4c | balrog | NULL, NULL, NULL, NULL, NULL, NULL, |
122 | 7e7c5e4c | balrog | }; |
123 | 7e7c5e4c | balrog | |
124 | 7e7c5e4c | balrog | /* 90deg, 180deg and 270deg rotation */
|
125 | 7e7c5e4c | balrog | static blizzard_fn_t glue(blizzard_draw_fn_r_, DEPTH)[0x10] = { |
126 | 7e7c5e4c | balrog | /* TODO */
|
127 | 7e7c5e4c | balrog | [0 ... 0xf] = NULL, |
128 | 7e7c5e4c | balrog | }; |
129 | 7e7c5e4c | balrog | |
130 | 7e7c5e4c | balrog | #undef DEPTH
|
131 | 7e7c5e4c | balrog | #undef SKIP_PIXEL
|
132 | 7e7c5e4c | balrog | #undef COPY_PIXEL
|
133 | 7e7c5e4c | balrog | #undef COPY_PIXEL1
|
134 | 7e7c5e4c | balrog | #undef PIXEL_TYPE
|
135 | 7e7c5e4c | balrog | |
136 | 7e7c5e4c | balrog | #undef SWAP_WORDS |