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.12 by cebix, 2004-01-12T15:29:25Z vs.
Revision 1.16 by gbeauche, 2005-01-30T21:42:14Z

# Line 1 | Line 1
1   /*
2   *  video_blit.cpp - Video/graphics emulation, blitters
3   *
4 < *  Basilisk II (C) 1997-2004 Christian Bauer
4 > *  Basilisk II (C) 1997-2005 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 20 | Line 20
20  
21   #include "sysdeps.h"
22   #include "video.h"
23 + #include "video_blit.h"
24  
25   #include <stdio.h>
26   #include <stdlib.h>
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
27  
29 #ifdef ENABLE_VOSF
28   // Format of the target visual
31 struct VisualFormat {
32        int             depth;                                  // Screen depth
33        uint32  Rmask, Gmask, Bmask;    // RGB mask values
34        uint32  Rshift, Gshift, Bshift; // RGB shift values
35 };
29   static VisualFormat visualFormat;
30  
31   // This holds the pixels values of the palette colors for 8->16/32-bit expansion
32   uint32 ExpandMap[256];
33  
34 + // Mark video_blit.h for specialization
35 + #define DEFINE_VIDEO_BLITTERS 1
36 +
37   /* -------------------------------------------------------------------------- */
38   /* --- Raw Copy / No conversion required                                  --- */
39   /* -------------------------------------------------------------------------- */
# Line 306 | Line 302 | static void Blit_Copy_Raw(uint8 * dest,
302   #include "video_blit.h"
303  
304   /* -------------------------------------------------------------------------- */
305 < /* --- 2/4-bit indexed to 8-bit mode conversion                           --- */
305 > /* --- 1/2/4-bit indexed to 8-bit mode conversion                           --- */
306   /* -------------------------------------------------------------------------- */
307  
308 + static void Blit_Expand_1_To_8(uint8 * dest, const uint8 * p, uint32 length)
309 + {
310 +        uint8 *q = (uint8 *)dest;
311 +        for (uint32 i=0; i<length; i++) {
312 +                uint8 c = *p++;
313 +                *q++ = c >> 7;
314 +                *q++ = (c >> 6) & 1;
315 +                *q++ = (c >> 5) & 1;
316 +                *q++ = (c >> 4) & 1;
317 +                *q++ = (c >> 3) & 1;
318 +                *q++ = (c >> 2) & 1;
319 +                *q++ = (c >> 1) & 1;
320 +                *q++ = c & 1;
321 +        }
322 + }
323 +
324   static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length)
325   {
326          uint8 *q = (uint8 *)dest;
# Line 423 | Line 435 | static Screen_blit_func_info Screen_blit
435          {  8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw       , Blit_Copy_Raw         },      // OK (NBO)
436          { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw       , Blit_RGB555_OBO       },      // OK (OBO)
437          { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO     , Blit_BGR555_OBO       },      // NT
438 +        { 16, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw       , Blit_RGB555_OBO       },      // OK (OBO)
439          { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO     , Blit_RGB565_OBO       },      // OK (OBO)
440          { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw       , Blit_RGB888_OBO       },      // OK (OBO)
441          { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO     , Blit_BGR888_OBO       },      // NT
# Line 433 | Line 446 | static Screen_blit_func_info Screen_blit
446          {  8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw       , Blit_Copy_Raw         },      // OK (NBO)
447          { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO     , Blit_Copy_Raw         },      // OK (NBO)
448          { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO     , Blit_BGR555_OBO       },      // NT
449 +        { 16, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO     , Blit_Copy_Raw         },      // OK (NBO)
450          { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO     , Blit_RGB565_OBO       },      // OK (NBO)
451          { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_RGB888_NBO     , Blit_Copy_Raw         },      // OK (NBO)
452          { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO     , Blit_BGR888_OBO       },      // NT
# Line 444 | Line 458 | static Screen_blit_func_info Screen_blit
458   // Initialize the framebuffer update function
459   // Returns FALSE, if the function was to be reduced to a simple memcpy()
460   // --> In that case, VOSF is not necessary
461 < bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth)
461 > bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth)
462   {
463 + #if USE_SDL_VIDEO
464 +        const bool use_sdl_video = true;
465 + #else
466 +        const bool use_sdl_video = false;
467 + #endif
468   #if REAL_ADDRESSING || DIRECT_ADDRESSING
469 <        if (mac_depth == 1) {
469 >        if (!use_sdl_video && mac_depth == 1) {
470  
471                  // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines
472                  Screen_blit = Blit_Copy_Raw;
473  
474          } else {
475  
457                visualFormat.depth = visual_info->depth;
458                visualFormat.Rmask = visual_info->red_mask;
459                visualFormat.Gmask = visual_info->green_mask;
460                visualFormat.Bmask = visual_info->blue_mask;
461
476                  // Compute RGB shift values
477 +                visualFormat = visual_format;
478                  visualFormat.Rshift = 0;
479                  for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1)
480                          ++visualFormat.Rshift;
# Line 470 | Line 485 | bool Screen_blitter_init(XVisualInfo * v
485                  for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1)
486                          ++visualFormat.Bshift;
487  
488 <                bool blitter_found = false;
489 <        
490 <                // 2/4/8-bit mode on 8/16/32-bit screen?
491 <                if (visualFormat.depth == 8) {
492 <                        if (mac_depth == 2) {
493 <                                Screen_blit = Blit_Expand_2_To_8;
494 <                                blitter_found = true;
495 <                        } else if (mac_depth == 4) {
481 <                                Screen_blit = Blit_Expand_4_To_8;
482 <                                blitter_found = true;
488 >                // 1/2/4/8-bit mode on 8/16/32-bit screen?
489 >                Screen_blit = NULL;
490 >                switch (visualFormat.depth) {
491 >                case 8:
492 >                        switch (mac_depth) {
493 >                        case 1: Screen_blit = Blit_Expand_1_To_8; break;
494 >                        case 2: Screen_blit = Blit_Expand_2_To_8; break;
495 >                        case 4: Screen_blit = Blit_Expand_4_To_8; break;
496                          }
497 <                } else if (visualFormat.depth == 15 || visualFormat.depth == 16) {
498 <                        if (mac_depth == 2) {
499 <                                Screen_blit = Blit_Expand_2_To_16;
500 <                                blitter_found = true;
501 <                        } else if (mac_depth == 4) {
502 <                                Screen_blit = Blit_Expand_4_To_16;
503 <                                blitter_found = true;
491 <                        } else if (mac_depth == 8) {
492 <                                Screen_blit = Blit_Expand_8_To_16;
493 <                                blitter_found = true;
497 >                        break;
498 >                case 15:
499 >                case 16:
500 >                        switch (mac_depth) {
501 >                        case 2: Screen_blit = Blit_Expand_2_To_16; break;
502 >                        case 4: Screen_blit = Blit_Expand_4_To_16; break;
503 >                        case 8: Screen_blit = Blit_Expand_8_To_16; break;
504                          }
505 <                } else if (visualFormat.depth == 24 || visualFormat.depth == 32) {
506 <                        if (mac_depth == 2) {
507 <                                Screen_blit = Blit_Expand_2_To_32;
508 <                                blitter_found = true;
509 <                        } else if (mac_depth == 4) {
510 <                                Screen_blit = Blit_Expand_4_To_32;
511 <                                blitter_found = true;
502 <                        } else if (mac_depth == 8) {
503 <                                Screen_blit = Blit_Expand_8_To_32;
504 <                                blitter_found = true;
505 >                        break;
506 >                case 24:
507 >                case 32:
508 >                        switch (mac_depth) {
509 >                        case 2: Screen_blit = Blit_Expand_2_To_32; break;
510 >                        case 4: Screen_blit = Blit_Expand_4_To_32; break;
511 >                        case 8: Screen_blit = Blit_Expand_8_To_32; break;
512                          }
513 +                        break;
514                  }
515 +                bool blitter_found = (Screen_blit != NULL);
516          
517                  // Search for an adequate blit function
518                  const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]);
# Line 542 | Line 551 | bool Screen_blitter_init(XVisualInfo * v
551          // --> In that case, we return FALSE
552          return (Screen_blit != Blit_Copy_Raw);
553   }
545 #endif /* ENABLE_VOSF */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines