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.7 by cebix, 2001-07-06T22:00:39Z vs.
Revision 1.12 by cebix, 2004-01-12T15:29:25Z

# Line 1 | Line 1
1   /*
2   *  video_blit.cpp - Video/graphics emulation, blitters
3   *
4 < *  Basilisk II (C) 1997-2001 Christian Bauer
4 > *  Basilisk II (C) 1997-2004 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 64 | Line 64 | static void Blit_Copy_Raw(uint8 * dest,
64   #define FB_BLIT_2(dst, src) \
65          (dst = (((src) >> 8) & 0x00ff00ff) | (((src) & 0x00ff00ff) << 8))
66  
67 + #define FB_BLIT_4(dst, src) \
68 +        (dst =  (((src) >> 8) & UVAL64(0x00ff00ff00ff00ff)) | \
69 +                        (((src) & UVAL64(0x00ff00ff00ff00ff)) << 8))
70 +
71   #define FB_DEPTH 15
72   #include "video_blit.h"
73  
# Line 81 | Line 85 | static void Blit_Copy_Raw(uint8 * dest,
85   #define FB_BLIT_2(dst, src) \
86          (dst = (((src) >> 10) & 0x001f001f) | ((src) & 0x03e003e0) | (((src) << 10) & 0x7c007c00))
87  
88 + #define FB_BLIT_4(dst, src) \
89 +        (dst =  (((src) >> 10) & UVAL64(0x001f001f001f001f)) | \
90 +                        ( (src)        & UVAL64(0x03e003e003e003e0)) | \
91 +                        (((src) << 10) & UVAL64(0x7c007c007c007c00)))
92 +
93   #define FB_DEPTH 15
94   #define FB_FUNC_NAME Blit_BGR555_NBO
95   #include "video_blit.h"
# Line 93 | Line 102 | static void Blit_Copy_Raw(uint8 * dest,
102   #define FB_BLIT_2(dst, src) \
103          (dst = (((src) >> 2) & 0x1f001f00) | (((src) >> 8) & 0x30003) | (((src) << 8) & 0xe000e000) | (((src) << 2) & 0x7c007c))
104  
105 + #define FB_BLIT_4(dst, src) \
106 +        (dst =  (((src) >> 2) & UVAL64(0x1f001f001f001f00)) | \
107 +                        (((src) >> 8) & UVAL64(0x0003000300030003)) | \
108 +                        (((src) << 8) & UVAL64(0xe000e000e000e000)) | \
109 +                        (((src) << 2) & UVAL64(0x007c007c007c007c)))
110 +
111   #define FB_DEPTH 15
112   #define FB_FUNC_NAME Blit_BGR555_OBO
113   #include "video_blit.h"
# Line 107 | Line 122 | static void Blit_Copy_Raw(uint8 * dest,
122   #define FB_BLIT_2(dst, src) \
123          (dst = (((src) >> 2) & 0x1f001f) | (((src) >> 8) & 0xe000e0) | (((src) << 8) & 0x03000300) | (((src) << 2) & 0x7c007c00))
124  
125 + #define FB_BLIT_4(dst, src) \
126 +        (dst =  (((src) >> 2) & UVAL64(0x001f001f001f001f)) | \
127 +                        (((src) >> 8) & UVAL64(0x00e000e000e000e0)) | \
128 +                        (((src) << 8) & UVAL64(0x0300030003000300)) | \
129 +                        (((src) << 2) & UVAL64(0x7c007c007c007c00)))
130 +
131   #define FB_DEPTH 15
132   #define FB_FUNC_NAME Blit_BGR555_NBO
133   #include "video_blit.h"
# Line 119 | Line 140 | static void Blit_Copy_Raw(uint8 * dest,
140   #define FB_BLIT_2(dst, src) \
141          (dst = (((src) << 6) & 0x1f001f00) | ((src) & 0xe003e003) | (((src) >> 6) & 0x7c007c))
142  
143 + #define FB_BLIT_4(dst, src) \
144 +        (dst =  (((src) << 6) & UVAL64(0x1f001f001f001f00)) | \
145 +                        ( (src)       & UVAL64(0xe003e003e003e003)) | \
146 +                        (((src) >> 6) & UVAL64(0x007c007c007c007c)))
147 +
148   #define FB_DEPTH 15
149   #define FB_FUNC_NAME Blit_BGR555_OBO
150   #include "video_blit.h"
# Line 139 | Line 165 | static void Blit_Copy_Raw(uint8 * dest,
165   #define FB_BLIT_2(dst, src) \
166          (dst = (((src) & 0x001f001f) | (((src) << 1) & 0xffc0ffc0)))
167  
168 + #define FB_BLIT_4(dst, src) \
169 +        (dst =  (((src)       & UVAL64(0x001f001f001f001f)) | \
170 +                        (((src) << 1) & UVAL64(0xffc0ffc0ffc0ffc0))))
171 +
172   #define FB_DEPTH 16
173   #define FB_FUNC_NAME Blit_RGB565_NBO
174   #include "video_blit.h"
# Line 151 | Line 181 | static void Blit_Copy_Raw(uint8 * dest,
181   #define FB_BLIT_2(dst, src) \
182          (dst = ((((src) >> 7) & 0x00ff00ff) | (((src) << 9) & 0xc000c000) | (((src) << 8) & 0x1f001f00)))
183  
184 + #define FB_BLIT_4(dst, src) \
185 +        (dst =  (((src) >> 7) & UVAL64(0x00ff00ff00ff00ff)) | \
186 +                        (((src) << 9) & UVAL64(0xc000c000c000c000)) | \
187 +                        (((src) << 8) & UVAL64(0x1f001f001f001f00)))
188 +
189   #define FB_DEPTH 16
190   #define FB_FUNC_NAME Blit_RGB565_OBO
191   #include "video_blit.h"
# Line 162 | Line 197 | static void Blit_Copy_Raw(uint8 * dest,
197   #define FB_BLIT_1(dst, src) \
198          (dst = (((src) >> 8) & 0x001f) | (((src) << 9) & 0xfe00) | (((src) >> 7) & 0x01c0))
199          
165 // gb-- Disabled because I don't see any improvement
166 #if 0 && defined(__i386__) && defined(X86_ASSEMBLY)
167
168 #define FB_BLIT_2(dst, src) \
169        __asm__ (       "movl %0,%%ebx\n\t" \
170                                "movl %0,%%ebp\n\t" \
171                                "andl $0x1f001f00,%%ebx\n\t" \
172                                "andl $0x007f007f,%0\n\t" \
173                                "andl $0xe000e000,%%ebp\n\t" \
174                                "shrl $8,%%ebx\n\t" \
175                                "shrl $7,%%ebp\n\t" \
176                                "shll $9,%0\n\t" \
177                                "orl %%ebx,%%ebp\n\t" \
178                                "orl %%ebp,%0\n\t" \
179                        : "=r" (dst) : "0" (src) : "ebx", "ebp", "cc" )
180
181 #else
182
200   #define FB_BLIT_2(dst, src) \
201          (dst = (((src) >> 8) & 0x001f001f) | (((src) << 9) & 0xfe00fe00) | (((src) >> 7) & 0x01c001c0))
202  
203 < #endif
203 > #define FB_BLIT_4(dst, src) \
204 >        (dst =  (((src) >> 8) & UVAL64(0x001f001f001f001f)) | \
205 >                        (((src) << 9) & UVAL64(0xfe00fe00fe00fe00)) | \
206 >                        (((src) >> 7) & UVAL64(0x01c001c001c001c0)))
207  
208   #define FB_DEPTH 16
209   #define FB_FUNC_NAME Blit_RGB565_NBO
# Line 197 | Line 217 | static void Blit_Copy_Raw(uint8 * dest,
217   #define FB_BLIT_2(dst, src) \
218          (dst = (((src) & 0x1f001f00) | (((src) << 1) & 0xe0fee0fe) | (((src) >> 15) & 0x10001)))
219  
220 + #define FB_BLIT_4(dst, src) \
221 +        (dst =  (((src)        & UVAL64(0x1f001f001f001f00)) | \
222 +                        (((src) <<  1) & UVAL64(0xe0fee0fee0fee0fe)) | \
223 +                        (((src) >> 15) & UVAL64(0x0001000100010001))))
224 +
225   #define FB_DEPTH 16
226   #define FB_FUNC_NAME Blit_RGB565_OBO
227   #include "video_blit.h"
# Line 216 | Line 241 | static void Blit_Copy_Raw(uint8 * dest,
241   #define FB_BLIT_2(dst, src) \
242          (dst = (((src) >> 24) & 0xff) | (((src) >> 8) & 0xff00) | (((src) & 0xff00) << 8) | (((src) & 0xff) << 24))
243  
244 + #define FB_BLIT_4(dst, src) \
245 +        (dst =  (((src) >> 24) & UVAL64(0x000000ff000000ff)) | \
246 +                        (((src) >>  8) & UVAL64(0x0000ff000000ff00)) | \
247 +                        (((src) & UVAL64(0x0000ff000000ff00)) <<  8) | \
248 +                        (((src) & UVAL64(0x000000ff000000ff)) << 24))
249 +
250   #define FB_DEPTH 24
251   #include "video_blit.h"
252  
# Line 230 | Line 261 | static void Blit_Copy_Raw(uint8 * dest,
261   #define FB_BLIT_2(dst, src) \
262          (dst = (((src) >> 16) & 0xff) | ((src) & 0xff00) | (((src) & 0xff) << 16))
263  
264 + #define FB_BLIT_4(dst, src) \
265 +        (dst =  (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \
266 +                        ( (src)        & UVAL64(0x0000ff000000ff00)) | \
267 +                        (((src) & UVAL64(0x000000ff000000ff)) << 16))
268 +
269   #define FB_FUNC_NAME Blit_BGR888_NBO
270   #define FB_DEPTH 24
271   #include "video_blit.h"
# Line 241 | Line 277 | static void Blit_Copy_Raw(uint8 * dest,
277   #define FB_BLIT_2(dst, src) \
278          (dst = (((src) >> 16) & 0xff) | ((src) & 0xff0000) | (((src) & 0xff) << 16))
279  
280 + #define FB_BLIT_4(dst, src) \
281 +        (dst =  (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \
282 +                        ( (src)        & UVAL64(0x00ff000000ff0000)) | \
283 +                        (((src) & UVAL64(0x000000ff000000ff)) << 16))
284 +
285   #define FB_FUNC_NAME Blit_BGR888_OBO
286   #define FB_DEPTH 24
287   #include "video_blit.h"
# Line 258 | Line 299 | static void Blit_Copy_Raw(uint8 * dest,
299   #define FB_BLIT_2(dst, src) \
300          (dst = ((src) & 0xff00ff) | (((src) & 0xff00) << 16))
301  
302 + #define FB_BLIT_4(dst, src) \
303 +        (dst = ((src) & UVAL64(0x00ff00ff00ff00ff)) | (((src) & UVAL64(0x0000ff000000ff00)) << 16))
304 +
305   #define FB_DEPTH 24
306   #include "video_blit.h"
307  
# Line 268 | Line 312 | static void Blit_Copy_Raw(uint8 * dest,
312   static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length)
313   {
314          uint8 *q = (uint8 *)dest;
315 <        for (int i=0; i<length; i++) {
315 >        for (uint32 i=0; i<length; i++) {
316                  uint8 c = *p++;
317                  *q++ = c >> 6;
318                  *q++ = (c >> 4) & 3;
# Line 280 | Line 324 | static void Blit_Expand_2_To_8(uint8 * d
324   static void Blit_Expand_4_To_8(uint8 * dest, const uint8 * p, uint32 length)
325   {
326          uint8 *q = (uint8 *)dest;
327 <        for (int i=0; i<length; i++) {
327 >        for (uint32 i=0; i<length; i++) {
328                  uint8 c = *p++;
329                  *q++ = c >> 4;
330                  *q++ = c & 0x0f;
# Line 294 | Line 338 | static void Blit_Expand_4_To_8(uint8 * d
338   static void Blit_Expand_2_To_16(uint8 * dest, const uint8 * p, uint32 length)
339   {
340          uint16 *q = (uint16 *)dest;
341 <        for (int i=0; i<length; i++) {
341 >        for (uint32 i=0; i<length; i++) {
342                  uint8 c = *p++;
343                  *q++ = ExpandMap[c >> 6];
344                  *q++ = ExpandMap[c >> 4];
# Line 306 | Line 350 | static void Blit_Expand_2_To_16(uint8 *
350   static void Blit_Expand_4_To_16(uint8 * dest, const uint8 * p, uint32 length)
351   {
352          uint16 *q = (uint16 *)dest;
353 <        for (int i=0; i<length; i++) {
353 >        for (uint32 i=0; i<length; i++) {
354                  uint8 c = *p++;
355                  *q++ = ExpandMap[c >> 4];
356                  *q++ = ExpandMap[c];
# Line 316 | Line 360 | static void Blit_Expand_4_To_16(uint8 *
360   static void Blit_Expand_8_To_16(uint8 * dest, const uint8 * p, uint32 length)
361   {
362          uint16 *q = (uint16 *)dest;
363 <        for (int i=0; i<length; i++)
363 >        for (uint32 i=0; i<length; i++)
364                  *q++ = ExpandMap[*p++];
365   }
366  
# Line 327 | Line 371 | static void Blit_Expand_8_To_16(uint8 *
371   static void Blit_Expand_2_To_32(uint8 * dest, const uint8 * p, uint32 length)
372   {
373          uint32 *q = (uint32 *)dest;
374 <        for (int i=0; i<length; i++) {
374 >        for (uint32 i=0; i<length; i++) {
375                  uint8 c = *p++;
376                  *q++ = ExpandMap[c >> 6];
377                  *q++ = ExpandMap[c >> 4];
# Line 339 | Line 383 | static void Blit_Expand_2_To_32(uint8 *
383   static void Blit_Expand_4_To_32(uint8 * dest, const uint8 * p, uint32 length)
384   {
385          uint32 *q = (uint32 *)dest;
386 <        for (int i=0; i<length; i++) {
386 >        for (uint32 i=0; i<length; i++) {
387                  uint8 c = *p++;
388                  *q++ = ExpandMap[c >> 4];
389                  *q++ = ExpandMap[c];
# Line 349 | Line 393 | static void Blit_Expand_4_To_32(uint8 *
393   static void Blit_Expand_8_To_32(uint8 * dest, const uint8 * p, uint32 length)
394   {
395          uint32 *q = (uint32 *)dest;
396 <        for (int i=0; i<length; i++)
396 >        for (uint32 i=0; i<length; i++)
397                  *q++ = ExpandMap[*p++];
398   }
399  
# Line 400 | Line 444 | static Screen_blit_func_info Screen_blit
444   // Initialize the framebuffer update function
445   // Returns FALSE, if the function was to be reduced to a simple memcpy()
446   // --> In that case, VOSF is not necessary
447 < bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, video_depth mac_depth)
447 > bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth)
448   {
449   #if REAL_ADDRESSING || DIRECT_ADDRESSING
450 <        if (mac_depth == VDEPTH_1BIT) {
450 >        if (mac_depth == 1) {
451  
452                  // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines
453                  Screen_blit = Blit_Copy_Raw;
# Line 430 | Line 474 | bool Screen_blitter_init(XVisualInfo * v
474          
475                  // 2/4/8-bit mode on 8/16/32-bit screen?
476                  if (visualFormat.depth == 8) {
477 <                        if (mac_depth == VDEPTH_2BIT) {
477 >                        if (mac_depth == 2) {
478                                  Screen_blit = Blit_Expand_2_To_8;
479                                  blitter_found = true;
480 <                        } else if (mac_depth == VDEPTH_4BIT) {
480 >                        } else if (mac_depth == 4) {
481                                  Screen_blit = Blit_Expand_4_To_8;
482                                  blitter_found = true;
483                          }
484                  } else if (visualFormat.depth == 15 || visualFormat.depth == 16) {
485 <                        if (mac_depth == VDEPTH_2BIT) {
485 >                        if (mac_depth == 2) {
486                                  Screen_blit = Blit_Expand_2_To_16;
487                                  blitter_found = true;
488 <                        } else if (mac_depth == VDEPTH_4BIT) {
488 >                        } else if (mac_depth == 4) {
489                                  Screen_blit = Blit_Expand_4_To_16;
490                                  blitter_found = true;
491 <                        } else if (mac_depth == VDEPTH_8BIT) {
491 >                        } else if (mac_depth == 8) {
492                                  Screen_blit = Blit_Expand_8_To_16;
493                                  blitter_found = true;
494                          }
495                  } else if (visualFormat.depth == 24 || visualFormat.depth == 32) {
496 <                        if (mac_depth == VDEPTH_2BIT) {
496 >                        if (mac_depth == 2) {
497                                  Screen_blit = Blit_Expand_2_To_32;
498                                  blitter_found = true;
499 <                        } else if (mac_depth == VDEPTH_4BIT) {
499 >                        } else if (mac_depth == 4) {
500                                  Screen_blit = Blit_Expand_4_To_32;
501                                  blitter_found = true;
502 <                        } else if (mac_depth == VDEPTH_8BIT) {
502 >                        } else if (mac_depth == 8) {
503                                  Screen_blit = Blit_Expand_8_To_32;
504                                  blitter_found = true;
505                          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines