ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.h
Revision: 1.3
Committed: 2000-09-23T08:39:55Z (23 years, 9 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
Changes since 1.2: +33 -22 lines
Log Message:
- cleaned up and fixed 8bpp copy

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * video_blit.h - Video/graphics emulation, blitters
3     *
4     * Basilisk II (C) 1997-2000 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_BLIT_1
22     # error "Undefined 16-bit word blit function"
23     #endif
24    
25     #ifndef FB_BLIT_2
26     # error "Undefined 32-bit word blit function"
27     #endif
28    
29     #ifndef FB_DEPTH
30     # error "Undefined screen depth"
31     #endif
32    
33     static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length)
34     {
35 gbeauche 1.3 union {
36     uint8 * bp;
37     uint16 * wp;
38     uint32 * lp;
39     } s, d;
40    
41     s.bp = (uint8 *)source;
42     d.bp = dest;
43    
44 gbeauche 1.1 #if FB_DEPTH <= 8
45     // Align source and dest to 16-bit word boundaries
46     if (FB_DEPTH <= 8 && ((unsigned long) source) & 1) {
47 gbeauche 1.3 *d.bp++ = *s.bp++;
48 gbeauche 1.1 length -= 1;
49     }
50     #endif
51    
52 gbeauche 1.2 #if FB_DEPTH <= 8
53     if (length >= 2) {
54     #endif
55 gbeauche 1.1
56     #if FB_DEPTH <= 16
57     // Align source and dest to 32-bit word boundaries
58     if (((unsigned long) source) & 2) {
59 gbeauche 1.3 const uint16 val = *s.wp++;
60     FB_BLIT_1(*d.wp++, val);
61 gbeauche 1.1 length -= 2;
62     }
63     #endif
64    
65     // Blit 4-byte words
66     if (length >= 4) {
67     const int remainder = (length / 4) % 8;
68 gbeauche 1.3 s.lp += remainder;
69     d.lp += remainder;
70 gbeauche 1.1
71     int n = ((length / 4) + 7) / 8;
72     switch (remainder) {
73     case 0: do {
74 gbeauche 1.3 s.lp += 8; d.lp += 8;
75     FB_BLIT_2(d.lp[-8], s.lp[-8]);
76     case 7: FB_BLIT_2(d.lp[-7], s.lp[-7]);
77     case 6: FB_BLIT_2(d.lp[-6], s.lp[-6]);
78     case 5: FB_BLIT_2(d.lp[-5], s.lp[-5]);
79     case 4: FB_BLIT_2(d.lp[-4], s.lp[-4]);
80     case 3: FB_BLIT_2(d.lp[-3], s.lp[-3]);
81     case 2: FB_BLIT_2(d.lp[-2], s.lp[-2]);
82     case 1: FB_BLIT_2(d.lp[-1], s.lp[-1]);
83 gbeauche 1.1 } while (--n > 0);
84     }
85     }
86    
87     #if FB_DEPTH <= 16
88 gbeauche 1.3 // There might remain at least one word to blit
89 gbeauche 1.1 if (length & 2) {
90 gbeauche 1.3 FB_BLIT_1(*d.wp, *s.wp);
91     #if FB_DEPTH <= 8
92     d.wp++;
93     s.wp++;
94     #endif
95 gbeauche 1.2 }
96     #endif
97    
98     #if FB_DEPTH <= 8
99 gbeauche 1.1 }
100 gbeauche 1.3
101     // There might remain one byte to blit
102     if (length & 1)
103     *d.bp = *s.bp;
104 gbeauche 1.1 #endif
105     }
106    
107     #undef FB_FUNC_NAME
108    
109     #ifdef FB_BLIT_1
110     #undef FB_BLIT_1
111     #endif
112    
113     #ifdef FB_BLIT_2
114     #undef FB_BLIT_2
115     #endif
116    
117     #ifdef FB_DEPTH
118     #undef FB_DEPTH
119     #endif