ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.h
Revision: 1.4
Committed: 2001-01-28T14:05:19Z (23 years, 9 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: snapshot-17022001, snapshot-29052001, release-0_9-1
Changes since 1.3: +35 -42 lines
Log Message:
Mainly changes to the VOSF code:
- improved blitters selection
- improved blitters performance if UNALIGNED_PROFITABLE is set
- cleaned up 8 bpp blitters

File Contents

# Content
1 /*
2 * video_blit.h - Video/graphics emulation, blitters
3 *
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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef FB_DEPTH
22 # error "Undefined screen depth"
23 #endif
24
25 #if !defined(FB_BLIT_1) && (FB_DEPTH <= 16)
26 # error "Undefined 16-bit word blit function"
27 #endif
28
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 #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 (((unsigned long) source) & 1) {
42 *dest++ = *source++;
43 length -= 1;
44 }
45 #endif
46
47 #if FB_DEPTH <= 16
48 // Align source and dest to 32-bit word boundaries
49 if (((unsigned long) source) & 2) {
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 source += remainder * 4;
61 dest += remainder * 4;
62
63 int n = ((length / 4) + 7) / 8;
64 switch (remainder) {
65 case 0: do {
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 could be one word left to blit
81 if (length & 2) {
82 FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
83 #if FB_DEPTH <= 8
84 dest += 2;
85 source += 2;
86 #endif
87 }
88 #endif
89
90 #if FB_DEPTH <= 8
91 // There could be one byte left to blit
92 if (length & 1)
93 *dest = *source;
94 #endif
95
96 #undef DEREF_LONG_PTR
97 #undef DEREF_WORD_PTR
98 }
99
100 #undef FB_FUNC_NAME
101
102 #ifdef FB_BLIT_1
103 #undef FB_BLIT_1
104 #endif
105
106 #ifdef FB_BLIT_2
107 #undef FB_BLIT_2
108 #endif
109
110 #ifdef FB_DEPTH
111 #undef FB_DEPTH
112 #endif