2 * QEMU Epson S1D13744/S1D13745 templates
4 * Copyright (C) 2008 Nokia Corporation
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
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.
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.
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.
22 #define SKIP_PIXEL(to) to += deststep
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
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
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
42 # error unknown bit depth
45 #ifdef WORDS_BIGENDIAN
49 static void glue(blizzard_draw_line16_
, DEPTH
)(PIXEL_TYPE
*dest
,
50 const uint16_t *src
, unsigned int width
)
52 #if !defined(SWAP_WORDS) && DEPTH == 16
53 memcpy(dest
, src
, width
);
57 const uint16_t *end
= (const void *) src
+ width
;
59 data
= lduw_raw(src
++);
60 b
= (data
& 0x1f) << 3;
62 g
= (data
& 0x3f) << 2;
64 r
= (data
& 0x1f) << 3;
66 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
71 static void glue(blizzard_draw_line24mode1_
, DEPTH
)(PIXEL_TYPE
*dest
,
72 const uint8_t *src
, unsigned int width
)
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
;
83 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[0], g
[0], b
[0]));
86 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[1], g
[1], b
[1]));
90 static void glue(blizzard_draw_line24mode2_
, DEPTH
)(PIXEL_TYPE
*dest
,
91 const uint8_t *src
, unsigned int width
)
94 const uint8_t *end
= src
+ width
;
100 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
105 static blizzard_fn_t
glue(blizzard_draw_fn_
, DEPTH
)[0x10] = {
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
),
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
),
122 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
125 /* 90deg, 180deg and 270deg rotation */
126 static blizzard_fn_t
glue(blizzard_draw_fn_r_
, DEPTH
)[0x10] = {