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

Comparing BasiliskII/src/Unix/video_blit.h (file contents):
Revision 1.3 by gbeauche, 2000-09-23T08:39:55Z vs.
Revision 1.4 by gbeauche, 2001-01-28T14:05:19Z

# Line 1 | Line 1
1   /*
2   *  video_blit.h - Video/graphics emulation, blitters
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 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 18 | Line 18
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  
21 < #ifndef FB_BLIT_1
22 < # error "Undefined 16-bit word blit function"
21 > #ifndef FB_DEPTH
22 > # error "Undefined screen depth"
23   #endif
24  
25 < #ifndef FB_BLIT_2
26 < # error "Undefined 32-bit word blit function"
25 > #if !defined(FB_BLIT_1) && (FB_DEPTH <= 16)
26 > # error "Undefined 16-bit word blit function"
27   #endif
28  
29 < #ifndef FB_DEPTH
30 < # error "Undefined screen depth"
29 > #if !defined(FB_BLIT_2)
30 > # error "Undefined 32-bit word blit function"
31   #endif
32  
33   static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length)
34   {
35 <        union {
36 <        uint8 *  bp;
37 <        uint16 * wp;
38 <        uint32 * lp;
39 <        } s, d;
40 <        
41 <        s.bp = (uint8 *)source;
42 <        d.bp = dest;
35 > #define DEREF_LONG_PTR(ptr, ofs) (((uint32 *)(ptr))[(ofs)])
36 > #define DEREF_WORD_PTR(ptr, ofs) (((uint16 *)(ptr))[(ofs)])
37          
38 + #ifndef UNALIGNED_PROFITABLE
39   #if FB_DEPTH <= 8
40          // Align source and dest to 16-bit word boundaries
41 <        if (FB_DEPTH <= 8 && ((unsigned long) source) & 1) {
42 <                *d.bp++ = *s.bp++;
41 >        if (((unsigned long) source) & 1) {
42 >                *dest++ = *source++;
43                  length -= 1;
44          }
45   #endif
46          
52 #if FB_DEPTH <= 8
53        if (length >= 2) {
54 #endif
55        
47   #if FB_DEPTH <= 16
48          // Align source and dest to 32-bit word boundaries
49          if (((unsigned long) source) & 2) {
50 <                const uint16 val = *s.wp++;
51 <                FB_BLIT_1(*d.wp++, val);
50 >                FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
51 >                dest += 2; source += 2;
52                  length -= 2;
53          }
54   #endif
55 + #endif
56          
57          // Blit 4-byte words
58          if (length >= 4) {
59                  const int remainder = (length / 4) % 8;
60 <                s.lp += remainder;
61 <                d.lp += remainder;
60 >                source += remainder * 4;
61 >                dest += remainder * 4;
62                  
63                  int n = ((length / 4) + 7) / 8;
64                  switch (remainder) {
65                  case 0: do {
66 <                                s.lp += 8; d.lp += 8;
67 <                                FB_BLIT_2(d.lp[-8], s.lp[-8]);
68 <                case 7: FB_BLIT_2(d.lp[-7], s.lp[-7]);
69 <                case 6: FB_BLIT_2(d.lp[-6], s.lp[-6]);
70 <                case 5: FB_BLIT_2(d.lp[-5], s.lp[-5]);
71 <                case 4: FB_BLIT_2(d.lp[-4], s.lp[-4]);
72 <                case 3: FB_BLIT_2(d.lp[-3], s.lp[-3]);
73 <                case 2: FB_BLIT_2(d.lp[-2], s.lp[-2]);
74 <                case 1: FB_BLIT_2(d.lp[-1], s.lp[-1]);
66 >                                dest += 32; source += 32;
67 >                                FB_BLIT_2(DEREF_LONG_PTR(dest, -8), DEREF_LONG_PTR(source, -8));
68 >                case 7: FB_BLIT_2(DEREF_LONG_PTR(dest, -7), DEREF_LONG_PTR(source, -7));
69 >                case 6: FB_BLIT_2(DEREF_LONG_PTR(dest, -6), DEREF_LONG_PTR(source, -6));
70 >                case 5: FB_BLIT_2(DEREF_LONG_PTR(dest, -5), DEREF_LONG_PTR(source, -5));
71 >                case 4: FB_BLIT_2(DEREF_LONG_PTR(dest, -4), DEREF_LONG_PTR(source, -4));
72 >                case 3: FB_BLIT_2(DEREF_LONG_PTR(dest, -3), DEREF_LONG_PTR(source, -3));
73 >                case 2: FB_BLIT_2(DEREF_LONG_PTR(dest, -2), DEREF_LONG_PTR(source, -2));
74 >                case 1: FB_BLIT_2(DEREF_LONG_PTR(dest, -1), DEREF_LONG_PTR(source, -1));
75                                  } while (--n > 0);
76                  }
77          }
78          
79   #if FB_DEPTH <= 16
80 <        // There might remain at least one word to blit
80 >        // There could be one word left to blit
81          if (length & 2) {
82 <                FB_BLIT_1(*d.wp, *s.wp);
82 >                FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
83   #if FB_DEPTH <= 8
84 <                d.wp++;
85 <                s.wp++;
84 >                dest += 2;
85 >                source += 2;
86   #endif
87          }
88   #endif
89          
90   #if FB_DEPTH <= 8
91 <        }
100 <        
101 <        // There might remain one byte to blit
91 >        // There could be one byte left to blit
92          if (length & 1)
93 <                *d.bp = *s.bp;
93 >                *dest = *source;
94   #endif
95 +        
96 + #undef DEREF_LONG_PTR
97 + #undef DEREF_WORD_PTR
98   }
99  
100   #undef FB_FUNC_NAME

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines