ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/video_blit.cpp (file contents):
Revision 1.4 by cebix, 2001-07-01T14:38:03Z vs.
Revision 1.7 by cebix, 2001-07-06T22:00:39Z

# Line 35 | Line 35 | struct VisualFormat {
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   /* -------------------------------------------------------------------------- */
# Line 259 | Line 262 | static void Blit_Copy_Raw(uint8 * dest,
262   #include "video_blit.h"
263  
264   /* -------------------------------------------------------------------------- */
265 + /* --- 2/4-bit indexed to 8-bit mode conversion                           --- */
266 + /* -------------------------------------------------------------------------- */
267 +
268 + static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length)
269 + {
270 +        uint8 *q = (uint8 *)dest;
271 +        for (int i=0; i<length; i++) {
272 +                uint8 c = *p++;
273 +                *q++ = c >> 6;
274 +                *q++ = (c >> 4) & 3;
275 +                *q++ = (c >> 2) & 3;
276 +                *q++ = c & 3;
277 +        }
278 + }
279 +
280 + static void Blit_Expand_4_To_8(uint8 * dest, const uint8 * p, uint32 length)
281 + {
282 +        uint8 *q = (uint8 *)dest;
283 +        for (int i=0; i<length; i++) {
284 +                uint8 c = *p++;
285 +                *q++ = c >> 4;
286 +                *q++ = c & 0x0f;
287 +        }
288 + }
289 +
290 + /* -------------------------------------------------------------------------- */
291 + /* --- 2/4/8-bit indexed to 16-bit mode color expansion                   --- */
292 + /* -------------------------------------------------------------------------- */
293 +
294 + static void Blit_Expand_2_To_16(uint8 * dest, const uint8 * p, uint32 length)
295 + {
296 +        uint16 *q = (uint16 *)dest;
297 +        for (int i=0; i<length; i++) {
298 +                uint8 c = *p++;
299 +                *q++ = ExpandMap[c >> 6];
300 +                *q++ = ExpandMap[c >> 4];
301 +                *q++ = ExpandMap[c >> 2];
302 +                *q++ = ExpandMap[c];
303 +        }
304 + }
305 +
306 + static void Blit_Expand_4_To_16(uint8 * dest, const uint8 * p, uint32 length)
307 + {
308 +        uint16 *q = (uint16 *)dest;
309 +        for (int i=0; i<length; i++) {
310 +                uint8 c = *p++;
311 +                *q++ = ExpandMap[c >> 4];
312 +                *q++ = ExpandMap[c];
313 +        }
314 + }
315 +
316 + static void Blit_Expand_8_To_16(uint8 * dest, const uint8 * p, uint32 length)
317 + {
318 +        uint16 *q = (uint16 *)dest;
319 +        for (int i=0; i<length; i++)
320 +                *q++ = ExpandMap[*p++];
321 + }
322 +
323 + /* -------------------------------------------------------------------------- */
324 + /* --- 2/4/8-bit indexed to 32-bit mode color expansion                   --- */
325 + /* -------------------------------------------------------------------------- */
326 +
327 + static void Blit_Expand_2_To_32(uint8 * dest, const uint8 * p, uint32 length)
328 + {
329 +        uint32 *q = (uint32 *)dest;
330 +        for (int i=0; i<length; i++) {
331 +                uint8 c = *p++;
332 +                *q++ = ExpandMap[c >> 6];
333 +                *q++ = ExpandMap[c >> 4];
334 +                *q++ = ExpandMap[c >> 2];
335 +                *q++ = ExpandMap[c];
336 +        }
337 + }
338 +
339 + static void Blit_Expand_4_To_32(uint8 * dest, const uint8 * p, uint32 length)
340 + {
341 +        uint32 *q = (uint32 *)dest;
342 +        for (int i=0; i<length; i++) {
343 +                uint8 c = *p++;
344 +                *q++ = ExpandMap[c >> 4];
345 +                *q++ = ExpandMap[c];
346 +        }
347 + }
348 +
349 + static void Blit_Expand_8_To_32(uint8 * dest, const uint8 * p, uint32 length)
350 + {
351 +        uint32 *q = (uint32 *)dest;
352 +        for (int i=0; i<length; i++)
353 +                *q++ = ExpandMap[*p++];
354 + }
355 +
356 + /* -------------------------------------------------------------------------- */
357   /* --- Blitters to the host frame buffer, or XImage buffer                --- */
358   /* -------------------------------------------------------------------------- */
359  
# Line 319 | Line 414 | bool Screen_blitter_init(XVisualInfo * v
414                  visualFormat.Rmask = visual_info->red_mask;
415                  visualFormat.Gmask = visual_info->green_mask;
416                  visualFormat.Bmask = visual_info->blue_mask;
417 <        
417 >
418                  // Compute RGB shift values
419                  visualFormat.Rshift = 0;
420                  for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1)
# Line 330 | Line 425 | bool Screen_blitter_init(XVisualInfo * v
425                  visualFormat.Bshift = 0;
426                  for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1)
427                          ++visualFormat.Bshift;
428 +
429 +                bool blitter_found = false;
430 +        
431 +                // 2/4/8-bit mode on 8/16/32-bit screen?
432 +                if (visualFormat.depth == 8) {
433 +                        if (mac_depth == VDEPTH_2BIT) {
434 +                                Screen_blit = Blit_Expand_2_To_8;
435 +                                blitter_found = true;
436 +                        } else if (mac_depth == VDEPTH_4BIT) {
437 +                                Screen_blit = Blit_Expand_4_To_8;
438 +                                blitter_found = true;
439 +                        }
440 +                } else if (visualFormat.depth == 15 || visualFormat.depth == 16) {
441 +                        if (mac_depth == VDEPTH_2BIT) {
442 +                                Screen_blit = Blit_Expand_2_To_16;
443 +                                blitter_found = true;
444 +                        } else if (mac_depth == VDEPTH_4BIT) {
445 +                                Screen_blit = Blit_Expand_4_To_16;
446 +                                blitter_found = true;
447 +                        } else if (mac_depth == VDEPTH_8BIT) {
448 +                                Screen_blit = Blit_Expand_8_To_16;
449 +                                blitter_found = true;
450 +                        }
451 +                } else if (visualFormat.depth == 24 || visualFormat.depth == 32) {
452 +                        if (mac_depth == VDEPTH_2BIT) {
453 +                                Screen_blit = Blit_Expand_2_To_32;
454 +                                blitter_found = true;
455 +                        } else if (mac_depth == VDEPTH_4BIT) {
456 +                                Screen_blit = Blit_Expand_4_To_32;
457 +                                blitter_found = true;
458 +                        } else if (mac_depth == VDEPTH_8BIT) {
459 +                                Screen_blit = Blit_Expand_8_To_32;
460 +                                blitter_found = true;
461 +                        }
462 +                }
463          
464                  // Search for an adequate blit function
335                bool blitter_found = false;
465                  const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]);
466                  for (int i = 0; !blitter_found && (i < blitters_count); i++) {
467                          if      (       (visualFormat.depth == Screen_blitters[i].depth)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines