2 * QEMU model of the Milkymist VGA framebuffer.
4 * Copyright (c) 2010 Michael Walle <michael@walle.cc>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 #define COPY_PIXEL(to, r, g, b) \
24 *to = rgb_to_pixel8(r, g, b); \
28 #define COPY_PIXEL(to, r, g, b) \
30 *(uint16_t *)to = rgb_to_pixel15(r, g, b); \
34 #define COPY_PIXEL(to, r, g, b) \
36 *(uint16_t *)to = rgb_to_pixel16(r, g, b); \
40 #define COPY_PIXEL(to, r, g, b) \
42 uint32_t tmp = rgb_to_pixel24(r, g, b); \
43 *(to++) = tmp & 0xff; \
44 *(to++) = (tmp >> 8) & 0xff; \
45 *(to++) = (tmp >> 16) & 0xff; \
48 #define COPY_PIXEL(to, r, g, b) \
50 *(uint32_t *)to = rgb_to_pixel32(r, g, b); \
54 #error unknown bit depth
57 static void glue(draw_line_
, BITS
)(void *opaque
, uint8_t *d
, const uint8_t *s
,
58 int width
, int deststep
)
64 rgb565
= lduw_be_p(s
);
65 r
= ((rgb565
>> 11) & 0x1f) << 3;
66 g
= ((rgb565
>> 5) & 0x3f) << 2;
67 b
= ((rgb565
>> 0) & 0x1f) << 3;
68 COPY_PIXEL(d
, r
, g
, b
);