--- BasiliskII/src/Unix/video_blit.cpp 2004/01/12 15:29:25 1.12 +++ BasiliskII/src/Unix/video_blit.cpp 2008/01/01 09:40:33 1.19 @@ -1,7 +1,7 @@ /* * video_blit.cpp - Video/graphics emulation, blitters * - * Basilisk II (C) 1997-2004 Christian Bauer + * Basilisk II (C) 1997-2008 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,24 +20,20 @@ #include "sysdeps.h" #include "video.h" +#include "video_blit.h" #include #include -#include -#include -#ifdef ENABLE_VOSF // Format of the target visual -struct VisualFormat { - int depth; // Screen depth - uint32 Rmask, Gmask, Bmask; // RGB mask values - uint32 Rshift, Gshift, Bshift; // RGB shift values -}; static VisualFormat visualFormat; // This holds the pixels values of the palette colors for 8->16/32-bit expansion uint32 ExpandMap[256]; +// Mark video_blit.h for specialization +#define DEFINE_VIDEO_BLITTERS 1 + /* -------------------------------------------------------------------------- */ /* --- Raw Copy / No conversion required --- */ /* -------------------------------------------------------------------------- */ @@ -306,9 +302,25 @@ static void Blit_Copy_Raw(uint8 * dest, #include "video_blit.h" /* -------------------------------------------------------------------------- */ -/* --- 2/4-bit indexed to 8-bit mode conversion --- */ +/* --- 1/2/4-bit indexed to 8-bit mode conversion --- */ /* -------------------------------------------------------------------------- */ +static void Blit_Expand_1_To_8(uint8 * dest, const uint8 * p, uint32 length) +{ + uint8 *q = (uint8 *)dest; + for (uint32 i=0; i> 7; + *q++ = (c >> 6) & 1; + *q++ = (c >> 5) & 1; + *q++ = (c >> 4) & 1; + *q++ = (c >> 3) & 1; + *q++ = (c >> 2) & 1; + *q++ = (c >> 1) & 1; + *q++ = c & 1; + } +} + static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length) { uint8 *q = (uint8 *)dest; @@ -332,9 +344,25 @@ static void Blit_Expand_4_To_8(uint8 * d } /* -------------------------------------------------------------------------- */ -/* --- 2/4/8-bit indexed to 16-bit mode color expansion --- */ +/* --- 1/2/4/8-bit indexed to 16-bit mode color expansion --- */ /* -------------------------------------------------------------------------- */ +static void Blit_Expand_1_To_16(uint8 * dest, const uint8 * p, uint32 length) +{ + uint16 *q = (uint16 *)dest; + for (uint32 i=0; i> 7); + *q++ = -((c >> 6) & 1); + *q++ = -((c >> 5) & 1); + *q++ = -((c >> 4) & 1); + *q++ = -((c >> 3) & 1); + *q++ = -((c >> 2) & 1); + *q++ = -((c >> 1) & 1); + *q++ = -(c & 1); + } +} + static void Blit_Expand_2_To_16(uint8 * dest, const uint8 * p, uint32 length) { uint16 *q = (uint16 *)dest; @@ -365,9 +393,25 @@ static void Blit_Expand_8_To_16(uint8 * } /* -------------------------------------------------------------------------- */ -/* --- 2/4/8-bit indexed to 32-bit mode color expansion --- */ +/* --- 1/2/4/8-bit indexed to 32-bit mode color expansion --- */ /* -------------------------------------------------------------------------- */ +static void Blit_Expand_1_To_32(uint8 * dest, const uint8 * p, uint32 length) +{ + uint32 *q = (uint32 *)dest; + for (uint32 i=0; i> 7); + *q++ = -((c >> 6) & 1); + *q++ = -((c >> 5) & 1); + *q++ = -((c >> 4) & 1); + *q++ = -((c >> 3) & 1); + *q++ = -((c >> 2) & 1); + *q++ = -((c >> 1) & 1); + *q++ = -(c & 1); + } +} + static void Blit_Expand_2_To_32(uint8 * dest, const uint8 * p, uint32 length) { uint32 *q = (uint32 *)dest; @@ -423,6 +467,7 @@ static Screen_blit_func_info Screen_blit { 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO) { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw , Blit_RGB555_OBO }, // OK (OBO) { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT + { 16, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw , Blit_RGB555_OBO }, // OK (OBO) { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (OBO) { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK (OBO) { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT @@ -433,6 +478,7 @@ static Screen_blit_func_info Screen_blit { 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO) { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO , Blit_Copy_Raw }, // OK (NBO) { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT + { 16, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO , Blit_Copy_Raw }, // OK (NBO) { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (NBO) { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_RGB888_NBO , Blit_Copy_Raw }, // OK (NBO) { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT @@ -444,22 +490,23 @@ static Screen_blit_func_info Screen_blit // Initialize the framebuffer update function // Returns FALSE, if the function was to be reduced to a simple memcpy() // --> In that case, VOSF is not necessary -bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth) +bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth) { +#if USE_SDL_VIDEO + const bool use_sdl_video = true; +#else + const bool use_sdl_video = false; +#endif #if REAL_ADDRESSING || DIRECT_ADDRESSING - if (mac_depth == 1) { + if (mac_depth == 1 && !use_sdl_video && !visual_format.fullscreen) { - // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines + // Windowed 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines Screen_blit = Blit_Copy_Raw; } else { - visualFormat.depth = visual_info->depth; - visualFormat.Rmask = visual_info->red_mask; - visualFormat.Gmask = visual_info->green_mask; - visualFormat.Bmask = visual_info->blue_mask; - // Compute RGB shift values + visualFormat = visual_format; visualFormat.Rshift = 0; for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1) ++visualFormat.Rshift; @@ -470,40 +517,36 @@ bool Screen_blitter_init(XVisualInfo * v for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1) ++visualFormat.Bshift; - bool blitter_found = false; - - // 2/4/8-bit mode on 8/16/32-bit screen? - if (visualFormat.depth == 8) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_8; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_8; - blitter_found = true; + // 1/2/4/8-bit mode on 8/16/32-bit screen? + Screen_blit = NULL; + switch (visualFormat.depth) { + case 8: + switch (mac_depth) { + case 1: Screen_blit = Blit_Expand_1_To_8; break; + case 2: Screen_blit = Blit_Expand_2_To_8; break; + case 4: Screen_blit = Blit_Expand_4_To_8; break; } - } else if (visualFormat.depth == 15 || visualFormat.depth == 16) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_16; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_16; - blitter_found = true; - } else if (mac_depth == 8) { - Screen_blit = Blit_Expand_8_To_16; - blitter_found = true; + break; + case 15: + case 16: + switch (mac_depth) { + case 1: Screen_blit = Blit_Expand_1_To_16; break; + case 2: Screen_blit = Blit_Expand_2_To_16; break; + case 4: Screen_blit = Blit_Expand_4_To_16; break; + case 8: Screen_blit = Blit_Expand_8_To_16; break; } - } else if (visualFormat.depth == 24 || visualFormat.depth == 32) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_32; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_32; - blitter_found = true; - } else if (mac_depth == 8) { - Screen_blit = Blit_Expand_8_To_32; - blitter_found = true; + break; + case 24: + case 32: + switch (mac_depth) { + case 1: Screen_blit = Blit_Expand_1_To_32; break; + case 2: Screen_blit = Blit_Expand_2_To_32; break; + case 4: Screen_blit = Blit_Expand_4_To_32; break; + case 8: Screen_blit = Blit_Expand_8_To_32; break; } + break; } + bool blitter_found = (Screen_blit != NULL); // Search for an adequate blit function const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]); @@ -542,4 +585,3 @@ bool Screen_blitter_init(XVisualInfo * v // --> In that case, we return FALSE return (Screen_blit != Blit_Copy_Raw); } -#endif /* ENABLE_VOSF */