Commit 688ea2eb9b251c73c78a8b60c8d5800730927be2
1 parent
749ecd99
Fix 24 bit mode
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4937 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
19 additions
and
4 deletions
hw/tcx.c
@@ -124,19 +124,34 @@ static void tcx_draw_line8(TCXState *s1, uint8_t *d, | @@ -124,19 +124,34 @@ static void tcx_draw_line8(TCXState *s1, uint8_t *d, | ||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | +/* | ||
128 | + XXX Could be much more optimal: | ||
129 | + * detect if line/page/whole screen is in 24 bit mode | ||
130 | + * if destination is also BGR, use memcpy | ||
131 | + */ | ||
127 | static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, | 132 | static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, |
128 | const uint8_t *s, int width, | 133 | const uint8_t *s, int width, |
129 | const uint32_t *cplane, | 134 | const uint32_t *cplane, |
130 | const uint32_t *s24) | 135 | const uint32_t *s24) |
131 | { | 136 | { |
132 | - int x; | ||
133 | - uint8_t val; | 137 | + int x, bgr, r, g, b; |
138 | + uint8_t val, *p8; | ||
134 | uint32_t *p = (uint32_t *)d; | 139 | uint32_t *p = (uint32_t *)d; |
135 | uint32_t dval; | 140 | uint32_t dval; |
136 | 141 | ||
142 | + bgr = s1->ds->bgr; | ||
137 | for(x = 0; x < width; x++, s++, s24++) { | 143 | for(x = 0; x < width; x++, s++, s24++) { |
138 | - if ((bswap32(*cplane++) & 0xff000000) == 0x03000000) { // 24-bit direct | ||
139 | - dval = bswap32(*s24) & 0x00ffffff; | 144 | + if ((be32_to_cpu(*cplane++) & 0xff000000) == 0x03000000) { |
145 | + // 24-bit direct, BGR order | ||
146 | + p8 = (uint8_t *)s24; | ||
147 | + p8++; | ||
148 | + b = *p8++; | ||
149 | + g = *p8++; | ||
150 | + r = *p8++; | ||
151 | + if (bgr) | ||
152 | + dval = rgb_to_pixel32bgr(r, g, b); | ||
153 | + else | ||
154 | + dval = rgb_to_pixel32(r, g, b); | ||
140 | } else { | 155 | } else { |
141 | val = *s; | 156 | val = *s; |
142 | dval = s1->palette[val]; | 157 | dval = s1->palette[val]; |