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.2 by gbeauche, 2001-01-31T21:28:58Z vs.
Revision 1.5 by cebix, 2001-07-01T19:57:55Z

# Line 19 | Line 19
19   */
20  
21   #include "sysdeps.h"
22 + #include "video.h"
23  
24   #include <stdio.h>
25   #include <stdlib.h>
# Line 34 | 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 258 | Line 262 | static void Blit_Copy_Raw(uint8 * dest,
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  
# Line 304 | Line 330 | static Screen_blit_func_info Screen_blit
330   // Initialize the framebuffer update function
331   // Returns FALSE, if the function was to be reduced to a simple memcpy()
332   // --> In that case, VOSF is not necessary
333 < bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order)
333 > bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, video_depth mac_depth)
334   {
335 <        visualFormat.depth = visual_info->depth;
336 <        visualFormat.Rmask = visual_info->red_mask;
337 <        visualFormat.Gmask = visual_info->green_mask;
338 <        visualFormat.Bmask = visual_info->blue_mask;
335 > #if REAL_ADDRESSING || DIRECT_ADDRESSING
336 >        if (mac_depth == VDEPTH_1BIT) {
337 >
338 >                // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines
339 >                Screen_blit = Blit_Copy_Raw;
340 >
341 >        } else {
342 >
343 >                visualFormat.depth = visual_info->depth;
344 >                visualFormat.Rmask = visual_info->red_mask;
345 >                visualFormat.Gmask = visual_info->green_mask;
346 >                visualFormat.Bmask = visual_info->blue_mask;
347 >
348 >                // Compute RGB shift values
349 >                visualFormat.Rshift = 0;
350 >                for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1)
351 >                        ++visualFormat.Rshift;
352 >                visualFormat.Gshift = 0;
353 >                for (uint32 Gmask = visualFormat.Gmask; Gmask && ((Gmask & 1) != 1); Gmask >>= 1)
354 >                        ++visualFormat.Gshift;
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 <        // Compute RGB shift values
362 <        visualFormat.Rshift = 0;
363 <        for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1)
364 <                ++visualFormat.Rshift;
365 <        visualFormat.Gshift = 0;
366 <        for (uint32 Gmask = visualFormat.Gmask; Gmask && ((Gmask & 1) != 1); Gmask >>= 1)
367 <                ++visualFormat.Gshift;
368 <        visualFormat.Bshift = 0;
369 <        for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1)
370 <                ++visualFormat.Bshift;
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
373 <        bool blitter_found = false;
374 <        const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]);
375 <        for (int i = 0; !blitter_found && (i < blitters_count); i++) {
376 <                if      (       (visualFormat.depth == Screen_blitters[i].depth)
377 <                        &&      (visualFormat.Rmask == Screen_blitters[i].Rmask)
378 <                        &&      (visualFormat.Gmask == Screen_blitters[i].Gmask)
379 <                        &&      (visualFormat.Bmask == Screen_blitters[i].Bmask)
380 <                        )
381 <                {
382 <                        blitter_found = true;
383 <                        Screen_blit = native_byte_order
384 <                                                ? Screen_blitters[i].handler_nbo
385 <                                                : Screen_blitters[i].handler_obo
386 <                                                ;
372 >                // Search for an adequate blit function
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)
376 >                                &&      (visualFormat.Rmask == Screen_blitters[i].Rmask)
377 >                                &&      (visualFormat.Gmask == Screen_blitters[i].Gmask)
378 >                                &&      (visualFormat.Bmask == Screen_blitters[i].Bmask)
379 >                                )
380 >                        {
381 >                                blitter_found = true;
382 >                                Screen_blit = native_byte_order
383 >                                                        ? Screen_blitters[i].handler_nbo
384 >                                                        : Screen_blitters[i].handler_obo
385 >                                                        ;
386 >                        }
387                  }
341        }
388          
389 <        // No appropriate blitter found, dump RGB mask values and abort()
390 <        if (!blitter_found) {
391 <                fprintf(stderr, "### No appropriate blitter found\n");
392 <                fprintf(stderr, "\tR/G/B mask values  : 0x%06x, 0x%06x, 0x%06x (depth = %d)\n",
393 <                        visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask, visualFormat.depth);
394 <                fprintf(stderr, "\tR/G/B shift values : %d/%d/%d\n",
395 <                        visualFormat.Rshift, visualFormat.Gshift, visualFormat.Bshift);
396 <                abort();
389 >                // No appropriate blitter found, dump RGB mask values and abort()
390 >                if (!blitter_found) {
391 >                        fprintf(stderr, "### No appropriate blitter found\n");
392 >                        fprintf(stderr, "\tR/G/B mask values  : 0x%06x, 0x%06x, 0x%06x (depth = %d)\n",
393 >                                visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask, visualFormat.depth);
394 >                        fprintf(stderr, "\tR/G/B shift values : %d/%d/%d\n",
395 >                                visualFormat.Rshift, visualFormat.Gshift, visualFormat.Bshift);
396 >                        abort();
397 >                }
398          }
399 + #else
400 +        // The UAE memory handlers will blit correctly
401 +        // --> no need for specialised blitters here
402 +        Screen_blit = Blit_Copy_Raw;
403 + #endif
404          
405          // If the blitter simply reduces to a copy, we don't need VOSF in DGA mode
406          // --> In that case, we return FALSE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines