ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.h
Revision: 1.1
Committed: 2000-09-22T17:15:27Z (23 years, 9 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
Log Message:
- blit functions

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     #if FB_DEPTH <= 8
36     // Align source and dest to 16-bit word boundaries
37     if (FB_DEPTH <= 8 && ((unsigned long) source) & 1) {
38     *dest++ = *source++;
39     length -= 1;
40     }
41     #endif
42    
43     // source and dest are mutually aligned
44     uint16 * swp = ((uint16 *)source);
45     uint16 * dwp = ((uint16 *) dest );
46    
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 = *swp++;
51     FB_BLIT_1(*dwp++, val);
52     length -= 2;
53     }
54     #endif
55    
56     // Blit 4-byte words
57     if (length >= 4) {
58     const int remainder = (length / 4) % 8;
59     uint32 * slp = (uint32 *)swp + remainder;
60     uint32 * dlp = (uint32 *)dwp + remainder;
61    
62     int n = ((length / 4) + 7) / 8;
63     switch (remainder) {
64     case 0: do {
65     slp += 8; dlp += 8;
66     FB_BLIT_2(dlp[-8], slp[-8]);
67     case 7: FB_BLIT_2(dlp[-7], slp[-7]);
68     case 6: FB_BLIT_2(dlp[-6], slp[-6]);
69     case 5: FB_BLIT_2(dlp[-5], slp[-5]);
70     case 4: FB_BLIT_2(dlp[-4], slp[-4]);
71     case 3: FB_BLIT_2(dlp[-3], slp[-3]);
72     case 2: FB_BLIT_2(dlp[-2], slp[-2]);
73     case 1: FB_BLIT_2(dlp[-1], slp[-1]);
74     } while (--n > 0);
75     }
76     }
77    
78     #if FB_DEPTH <= 16
79     // There might remain one word to blit
80     if (length & 2) {
81     uint16 * const s = (uint16 *)(((uint8 *)swp) + length - 2);
82     uint16 * const d = (uint16 *)(((uint8 *)dwp) + length - 2);
83     FB_BLIT_1(*d, *s);
84     }
85     #endif
86     }
87    
88     #undef FB_FUNC_NAME
89    
90     #ifdef FB_BLIT_1
91     #undef FB_BLIT_1
92     #endif
93    
94     #ifdef FB_BLIT_2
95     #undef FB_BLIT_2
96     #endif
97    
98     #ifdef FB_DEPTH
99     #undef FB_DEPTH
100     #endif