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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #define SKIP_PIXEL(to) to += deststep
25 # define PIXEL_TYPE uint8_t
26 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
27 # define COPY_PIXEL1(to, from) *to ++ = from
28 #elif DEPTH == 15 || DEPTH == 16
29 # define PIXEL_TYPE uint16_t
30 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
31 # define COPY_PIXEL1(to, from) *to ++ = from
33 # define PIXEL_TYPE uint8_t
34 # define COPY_PIXEL(to, from) \
35 to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to)
36 # define COPY_PIXEL1(to, from) \
37 *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16
39 # define PIXEL_TYPE uint32_t
40 # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
41 # define COPY_PIXEL1(to, from) *to ++ = from
43 # error unknown bit depth
46 #ifdef WORDS_BIGENDIAN
50 static void glue(blizzard_draw_line16_
, DEPTH
)(PIXEL_TYPE
*dest
,
51 const uint16_t *src
, unsigned int width
)
53 #if !defined(SWAP_WORDS) && DEPTH == 16
54 memcpy(dest
, src
, width
);
58 const uint16_t *end
= (const void *) src
+ width
;
60 data
= lduw_raw(src
++);
61 b
= (data
& 0x1f) << 3;
63 g
= (data
& 0x3f) << 2;
65 r
= (data
& 0x1f) << 3;
67 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
72 static void glue(blizzard_draw_line24mode1_
, DEPTH
)(PIXEL_TYPE
*dest
,
73 const uint8_t *src
, unsigned int width
)
75 /* TODO: check if SDL 24-bit planes are not in the same format and
76 * if so, use memcpy */
77 unsigned int r
[2], g
[2], b
[2];
78 const uint8_t *end
= src
+ width
;
84 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[0], g
[0], b
[0]));
87 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
[1], g
[1], b
[1]));
91 static void glue(blizzard_draw_line24mode2_
, DEPTH
)(PIXEL_TYPE
*dest
,
92 const uint8_t *src
, unsigned int width
)
95 const uint8_t *end
= src
+ width
;
101 COPY_PIXEL1(dest
, glue(rgb_to_pixel
, DEPTH
)(r
, g
, b
));
106 static blizzard_fn_t
glue(blizzard_draw_fn_
, DEPTH
)[0x10] = {
109 (blizzard_fn_t
) glue(blizzard_draw_line16_
, DEPTH
),
110 /* RGB 6:6:6 mode 1 */
111 (blizzard_fn_t
) glue(blizzard_draw_line24mode1_
, DEPTH
),
112 /* RGB 8:8:8 mode 1 */
113 (blizzard_fn_t
) glue(blizzard_draw_line24mode1_
, DEPTH
),
115 /* RGB 6:6:6 mode 2 */
116 (blizzard_fn_t
) glue(blizzard_draw_line24mode2_
, DEPTH
),
117 /* RGB 8:8:8 mode 2 */
118 (blizzard_fn_t
) glue(blizzard_draw_line24mode2_
, DEPTH
),
123 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
126 /* 90deg, 180deg and 270deg rotation */
127 static blizzard_fn_t
glue(blizzard_draw_fn_r_
, DEPTH
)[0x10] = {