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, see <http://www.gnu.org/licenses/>.
21 #define SKIP_PIXEL(to) to += deststep
23 # define PIXEL_TYPE uint8_t
24 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
25 # define COPY_PIXEL1(to, from) *to ++ = from
26 #elif DEPTH == 15 || DEPTH == 16
27 # define PIXEL_TYPE uint16_t
28 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
29 # define COPY_PIXEL1(to, from) *to ++ = from
31 # define PIXEL_TYPE uint8_t
32 # define COPY_PIXEL(to, from) \
33 to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to)
34 # define COPY_PIXEL1(to, from) \
35 *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16
37 # define PIXEL_TYPE uint32_t
38 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
39 # define COPY_PIXEL1(to, from) *to ++ = from
41 # error unknown bit depth
44 #ifdef HOST_WORDS_BIGENDIAN
48 static void glue(blizzard_draw_line16_
, DEPTH
)(PIXEL_TYPE
*dest
,
49 const uint16_t *src
, unsigned int width
)
51 #if !defined(SWAP_WORDS) && DEPTH == 16
52 memcpy(dest
, src
, width
);
56 const uint16_t *end
= (const void *) src
+ width
;
58 data
= lduw_raw(src
++);
59 b
= (data
& 0x1f) << 3;
61 g
= (data
& 0x3f) << 2;
63 r
= (data
& 0x1f) << 3;
65 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
70 static void glue(blizzard_draw_line24mode1_
, DEPTH
)(PIXEL_TYPE
*dest
,
71 const uint8_t *src
, unsigned int width
)
73 /* TODO: check if SDL 24-bit planes are not in the same format and
74 * if so, use memcpy */
75 unsigned int r
[2], g
[2], b
[2];
76 const uint8_t *end
= src
+ width
;
82 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[0], g
[0], b
[0]));
85 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[1], g
[1], b
[1]));
89 static void glue(blizzard_draw_line24mode2_
, DEPTH
)(PIXEL_TYPE
*dest
,
90 const uint8_t *src
, unsigned int width
)
93 const uint8_t *end
= src
+ width
;
99 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
104 static blizzard_fn_t
glue(blizzard_draw_fn_
, DEPTH
)[0x10] = {
107 (blizzard_fn_t
) glue(blizzard_draw_line16_
, DEPTH
),
108 /* RGB 6:6:6 mode 1 */
109 (blizzard_fn_t
) glue(blizzard_draw_line24mode1_
, DEPTH
),
110 /* RGB 8:8:8 mode 1 */
111 (blizzard_fn_t
) glue(blizzard_draw_line24mode1_
, DEPTH
),
113 /* RGB 6:6:6 mode 2 */
114 (blizzard_fn_t
) glue(blizzard_draw_line24mode2_
, DEPTH
),
115 /* RGB 8:8:8 mode 2 */
116 (blizzard_fn_t
) glue(blizzard_draw_line24mode2_
, DEPTH
),
121 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
124 /* 90deg, 180deg and 270deg rotation */
125 static blizzard_fn_t
glue(blizzard_draw_fn_r_
, DEPTH
)[0x10] = {