35 |
|
}; |
36 |
|
static VisualFormat visualFormat; |
37 |
|
|
38 |
+ |
// This holds the pixels values of the palette colors for 8->16/32-bit expansion |
39 |
+ |
uint32 ExpandMap[256]; |
40 |
+ |
|
41 |
|
/* -------------------------------------------------------------------------- */ |
42 |
|
/* --- Raw Copy / No conversion required --- */ |
43 |
|
/* -------------------------------------------------------------------------- */ |
262 |
|
#include "video_blit.h" |
263 |
|
|
264 |
|
/* -------------------------------------------------------------------------- */ |
265 |
+ |
/* --- 8-bit indexed to 16-bit mode color expansion --- */ |
266 |
+ |
/* -------------------------------------------------------------------------- */ |
267 |
+ |
|
268 |
+ |
static void Blit_Expand_8_To_16(uint8 * dest, const uint8 * p, uint32 length) |
269 |
+ |
{ |
270 |
+ |
uint16 *q = (uint16 *)dest; |
271 |
+ |
for (int i=0; i<length; i++) |
272 |
+ |
*q++ = ExpandMap[*p++]; |
273 |
+ |
} |
274 |
+ |
|
275 |
+ |
/* -------------------------------------------------------------------------- */ |
276 |
+ |
/* --- 8-bit indexed to 32-bit mode color expansion --- */ |
277 |
+ |
/* -------------------------------------------------------------------------- */ |
278 |
+ |
|
279 |
+ |
static void Blit_Expand_8_To_32(uint8 * dest, const uint8 * p, uint32 length) |
280 |
+ |
{ |
281 |
+ |
uint32 *q = (uint32 *)dest; |
282 |
+ |
for (int i=0; i<length; i++) |
283 |
+ |
*q++ = ExpandMap[*p++]; |
284 |
+ |
} |
285 |
+ |
|
286 |
+ |
/* -------------------------------------------------------------------------- */ |
287 |
|
/* --- Blitters to the host frame buffer, or XImage buffer --- */ |
288 |
|
/* -------------------------------------------------------------------------- */ |
289 |
|
|
344 |
|
visualFormat.Rmask = visual_info->red_mask; |
345 |
|
visualFormat.Gmask = visual_info->green_mask; |
346 |
|
visualFormat.Bmask = visual_info->blue_mask; |
347 |
< |
|
347 |
> |
|
348 |
|
// Compute RGB shift values |
349 |
|
visualFormat.Rshift = 0; |
350 |
|
for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1) |
355 |
|
visualFormat.Bshift = 0; |
356 |
|
for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1) |
357 |
|
++visualFormat.Bshift; |
358 |
+ |
|
359 |
+ |
bool blitter_found = false; |
360 |
+ |
|
361 |
+ |
// 8-bit mode on 16/32-bit screen? |
362 |
+ |
if (mac_depth == VDEPTH_8BIT && visualFormat.depth > 8) { |
363 |
+ |
if (visual_info->depth <= 16) { |
364 |
+ |
Screen_blit = Blit_Expand_8_To_16; |
365 |
+ |
blitter_found = true; |
366 |
+ |
} else { |
367 |
+ |
Screen_blit = Blit_Expand_8_To_32; |
368 |
+ |
blitter_found = true; |
369 |
+ |
} |
370 |
+ |
} |
371 |
|
|
372 |
|
// Search for an adequate blit function |
335 |
– |
bool blitter_found = false; |
373 |
|
const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]); |
374 |
|
for (int i = 0; !blitter_found && (i < blitters_count); i++) { |
375 |
|
if ( (visualFormat.depth == Screen_blitters[i].depth) |