ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.h
Revision: 1.14
Committed: 2005-04-02T09:56:12Z (19 years, 7 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: nigel-build-19, nigel-build-17
Changes since 1.13: +1 -0 lines
Log Message:
cosmetics

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * video_blit.h - Video/graphics emulation, blitters
3     *
4 gbeauche 1.12 * Basilisk II (C) 1997-2005 Christian Bauer
5 gbeauche 1.1 *
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 gbeauche 1.8 #ifndef DEFINE_VIDEO_BLITTERS
22    
23     #ifndef VIDEO_BLIT_H
24     #define VIDEO_BLIT_H
25    
26     // Format of the target visual
27     struct VisualFormat {
28 gbeauche 1.13 bool fullscreen; // Full screen mode?
29 gbeauche 1.8 int depth; // Screen depth
30     uint32 Rmask, Gmask, Bmask; // RGB mask values
31     uint32 Rshift, Gshift, Bshift; // RGB shift values
32     };
33    
34 gbeauche 1.9 // Prototypes
35 gbeauche 1.8 extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length);
36     extern bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth);
37     extern uint32 ExpandMap[256];
38    
39 gbeauche 1.9 // Glue for SheepShaver and BasiliskII
40     #ifdef SHEEPSHAVER
41     enum {
42     VIDEO_DEPTH_1BIT = APPLE_1_BIT,
43     VIDEO_DEPTH_2BIT = APPLE_2_BIT,
44     VIDEO_DEPTH_4BIT = APPLE_4_BIT,
45     VIDEO_DEPTH_8BIT = APPLE_8_BIT,
46     VIDEO_DEPTH_16BIT = APPLE_16_BIT,
47     VIDEO_DEPTH_32BIT = APPLE_32_BIT
48     };
49     #define VIDEO_MODE VideoInfo
50     #define VIDEO_MODE_INIT VideoInfo const & mode = VModes[cur_mode]
51 gbeauche 1.10 #define VIDEO_MODE_INIT_MONITOR VIDEO_MODE_INIT
52 gbeauche 1.9 #define VIDEO_MODE_ROW_BYTES mode.viRowBytes
53     #define VIDEO_MODE_X mode.viXsize
54     #define VIDEO_MODE_Y mode.viYsize
55     #define VIDEO_MODE_RESOLUTION mode.viAppleID
56     #define VIDEO_MODE_DEPTH mode.viAppleMode
57     #else
58     enum {
59     VIDEO_DEPTH_1BIT = VDEPTH_1BIT,
60     VIDEO_DEPTH_2BIT = VDEPTH_2BIT,
61     VIDEO_DEPTH_4BIT = VDEPTH_4BIT,
62     VIDEO_DEPTH_8BIT = VDEPTH_8BIT,
63     VIDEO_DEPTH_16BIT = VDEPTH_16BIT,
64     VIDEO_DEPTH_32BIT = VDEPTH_32BIT
65     };
66     #define VIDEO_MODE video_mode
67     #define VIDEO_MODE_INIT video_mode const & mode = drv->mode
68 gbeauche 1.10 #define VIDEO_MODE_INIT_MONITOR video_mode const & mode = monitor.get_current_mode()
69 gbeauche 1.9 #define VIDEO_MODE_ROW_BYTES mode.bytes_per_row
70     #define VIDEO_MODE_X mode.x
71     #define VIDEO_MODE_Y mode.y
72     #define VIDEO_MODE_RESOLUTION mode.resolution_id
73 gbeauche 1.11 #define VIDEO_MODE_DEPTH mode.depth
74 gbeauche 1.9 #endif
75    
76 gbeauche 1.8 #endif /* VIDEO_BLIT_H */
77    
78     #else
79    
80 gbeauche 1.4 #ifndef FB_DEPTH
81     # error "Undefined screen depth"
82     #endif
83    
84     #if !defined(FB_BLIT_1) && (FB_DEPTH <= 16)
85 gbeauche 1.1 # error "Undefined 16-bit word blit function"
86     #endif
87    
88 gbeauche 1.4 #if !defined(FB_BLIT_2)
89 gbeauche 1.1 # error "Undefined 32-bit word blit function"
90     #endif
91    
92 gbeauche 1.5 #if !defined(FB_BLIT_4)
93     # error "Undefined 64-bit word blit function"
94     #endif
95    
96 gbeauche 1.1 static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length)
97     {
98 gbeauche 1.5 #define DEREF_WORD_PTR(ptr, ofs) (((uint16 *)(ptr))[(ofs)])
99 gbeauche 1.4 #define DEREF_LONG_PTR(ptr, ofs) (((uint32 *)(ptr))[(ofs)])
100 gbeauche 1.5 #define DEREF_QUAD_PTR(ptr, ofs) (((uint64 *)(ptr))[(ofs)])
101 gbeauche 1.3
102 gbeauche 1.4 #ifndef UNALIGNED_PROFITABLE
103 gbeauche 1.1 #if FB_DEPTH <= 8
104     // Align source and dest to 16-bit word boundaries
105 gbeauche 1.4 if (((unsigned long) source) & 1) {
106     *dest++ = *source++;
107 gbeauche 1.1 length -= 1;
108     }
109     #endif
110    
111     #if FB_DEPTH <= 16
112     // Align source and dest to 32-bit word boundaries
113     if (((unsigned long) source) & 2) {
114 gbeauche 1.4 FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
115     dest += 2; source += 2;
116 gbeauche 1.1 length -= 2;
117     }
118     #endif
119 gbeauche 1.4 #endif
120 gbeauche 1.1
121 gbeauche 1.5 // Blit 8-byte words
122     if (length >= 8) {
123     const int remainder = (length / 8) % 8;
124     source += remainder * 8;
125     dest += remainder * 8;
126 gbeauche 1.1
127 gbeauche 1.5 int n = ((length / 8) + 7) / 8;
128 gbeauche 1.1 switch (remainder) {
129     case 0: do {
130 gbeauche 1.5 dest += 64; source += 64;
131     FB_BLIT_4(DEREF_QUAD_PTR(dest, -8), DEREF_QUAD_PTR(source, -8));
132     case 7: FB_BLIT_4(DEREF_QUAD_PTR(dest, -7), DEREF_QUAD_PTR(source, -7));
133     case 6: FB_BLIT_4(DEREF_QUAD_PTR(dest, -6), DEREF_QUAD_PTR(source, -6));
134     case 5: FB_BLIT_4(DEREF_QUAD_PTR(dest, -5), DEREF_QUAD_PTR(source, -5));
135     case 4: FB_BLIT_4(DEREF_QUAD_PTR(dest, -4), DEREF_QUAD_PTR(source, -4));
136     case 3: FB_BLIT_4(DEREF_QUAD_PTR(dest, -3), DEREF_QUAD_PTR(source, -3));
137     case 2: FB_BLIT_4(DEREF_QUAD_PTR(dest, -2), DEREF_QUAD_PTR(source, -2));
138     case 1: FB_BLIT_4(DEREF_QUAD_PTR(dest, -1), DEREF_QUAD_PTR(source, -1));
139 gbeauche 1.1 } while (--n > 0);
140     }
141     }
142    
143 gbeauche 1.5 // There could be one long left to blit
144     if (length & 4) {
145     FB_BLIT_2(DEREF_LONG_PTR(dest, 0), DEREF_LONG_PTR(source, 0));
146     #if FB_DEPTH <= 16
147     dest += 4;
148     source += 4;
149     #endif
150     }
151    
152 gbeauche 1.1 #if FB_DEPTH <= 16
153 gbeauche 1.4 // There could be one word left to blit
154 gbeauche 1.1 if (length & 2) {
155 gbeauche 1.4 FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
156 gbeauche 1.3 #if FB_DEPTH <= 8
157 gbeauche 1.4 dest += 2;
158     source += 2;
159 gbeauche 1.3 #endif
160 gbeauche 1.2 }
161     #endif
162    
163     #if FB_DEPTH <= 8
164 gbeauche 1.4 // There could be one byte left to blit
165 gbeauche 1.3 if (length & 1)
166 gbeauche 1.4 *dest = *source;
167 gbeauche 1.1 #endif
168 gbeauche 1.4
169 gbeauche 1.14 #undef DEREF_QUAD_PTR
170 gbeauche 1.4 #undef DEREF_LONG_PTR
171     #undef DEREF_WORD_PTR
172 gbeauche 1.1 }
173    
174     #undef FB_FUNC_NAME
175    
176     #ifdef FB_BLIT_1
177     #undef FB_BLIT_1
178     #endif
179    
180     #ifdef FB_BLIT_2
181     #undef FB_BLIT_2
182 gbeauche 1.5 #endif
183    
184     #ifdef FB_BLIT_4
185     #undef FB_BLIT_4
186 gbeauche 1.1 #endif
187    
188     #ifdef FB_DEPTH
189     #undef FB_DEPTH
190     #endif
191 gbeauche 1.8
192     #endif /* DEFINE_VIDEO_BLITTERS */