ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_blit.cpp
Revision: 1.10
Committed: 2002-01-15T14:58:37Z (22 years, 10 months ago) by cebix
Branch: MAIN
CVS Tags: nigel-build-12, nigel-build-13, snapshot-15012002
Changes since 1.9: +1 -1 lines
Log Message:
- documentation updates
- 2001 -> 2002
- version 0.9 -> 1.0

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * video_blit.cpp - Video/graphics emulation, blitters
3     *
4 cebix 1.10 * Basilisk II (C) 1997-2002 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     #include "sysdeps.h"
22 cebix 1.4 #include "video.h"
23 gbeauche 1.1
24     #include <stdio.h>
25     #include <stdlib.h>
26     #include <X11/Xlib.h>
27     #include <X11/Xutil.h>
28    
29     #ifdef ENABLE_VOSF
30     // Format of the target visual
31     struct VisualFormat {
32     int depth; // Screen depth
33     uint32 Rmask, Gmask, Bmask; // RGB mask values
34     uint32 Rshift, Gshift, Bshift; // RGB shift values
35     };
36     static VisualFormat visualFormat;
37    
38 cebix 1.5 // This holds the pixels values of the palette colors for 8->16/32-bit expansion
39     uint32 ExpandMap[256];
40    
41 gbeauche 1.1 /* -------------------------------------------------------------------------- */
42     /* --- Raw Copy / No conversion required --- */
43     /* -------------------------------------------------------------------------- */
44    
45     static void Blit_Copy_Raw(uint8 * dest, const uint8 * source, uint32 length)
46     {
47     // This function is likely to be inlined and/or highly optimized
48     memcpy(dest, source, length);
49     }
50    
51     /* -------------------------------------------------------------------------- */
52     /* --- RGB 555 --- */
53     /* -------------------------------------------------------------------------- */
54    
55     #ifdef WORDS_BIGENDIAN
56     # define FB_FUNC_NAME Blit_RGB555_OBO
57     #else
58     # define FB_FUNC_NAME Blit_RGB555_NBO
59     #endif
60    
61     #define FB_BLIT_1(dst, src) \
62     (dst = (((src) >> 8) & 0xff) | (((src) & 0xff) << 8))
63    
64     #define FB_BLIT_2(dst, src) \
65     (dst = (((src) >> 8) & 0x00ff00ff) | (((src) & 0x00ff00ff) << 8))
66    
67 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
68     (dst = (((src) >> 8) & UVAL64(0x00ff00ff00ff00ff)) | \
69     (((src) & UVAL64(0x00ff00ff00ff00ff)) << 8))
70    
71 gbeauche 1.1 #define FB_DEPTH 15
72     #include "video_blit.h"
73    
74     /* -------------------------------------------------------------------------- */
75     /* --- BGR 555 --- */
76     /* -------------------------------------------------------------------------- */
77    
78 gbeauche 1.2 #ifdef WORDS_BIGENDIAN
79    
80     // Native byte order
81    
82     #define FB_BLIT_1(dst, src) \
83     (dst = (((src) >> 10) & 0x001f) | ((src) & 0x03e0) | (((src) << 10) & 0x7c00))
84    
85     #define FB_BLIT_2(dst, src) \
86     (dst = (((src) >> 10) & 0x001f001f) | ((src) & 0x03e003e0) | (((src) << 10) & 0x7c007c00))
87    
88 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
89     (dst = (((src) >> 10) & UVAL64(0x001f001f001f001f)) | \
90     ( (src) & UVAL64(0x03e003e003e003e0)) | \
91     (((src) << 10) & UVAL64(0x7c007c007c007c00)))
92    
93 gbeauche 1.2 #define FB_DEPTH 15
94     #define FB_FUNC_NAME Blit_BGR555_NBO
95     #include "video_blit.h"
96    
97     // Opposite byte order (untested)
98    
99     #define FB_BLIT_1(dst, src) \
100     (dst = (((src) >> 2) & 0x1f00) | (((src) >> 8) & 3) | (((src) << 8) & 0xe000) | (((src) << 2) & 0x7c))
101    
102     #define FB_BLIT_2(dst, src) \
103     (dst = (((src) >> 2) & 0x1f001f00) | (((src) >> 8) & 0x30003) | (((src) << 8) & 0xe000e000) | (((src) << 2) & 0x7c007c))
104    
105 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
106     (dst = (((src) >> 2) & UVAL64(0x1f001f001f001f00)) | \
107     (((src) >> 8) & UVAL64(0x0003000300030003)) | \
108     (((src) << 8) & UVAL64(0xe000e000e000e000)) | \
109     (((src) << 2) & UVAL64(0x007c007c007c007c)))
110    
111 gbeauche 1.2 #define FB_DEPTH 15
112     #define FB_FUNC_NAME Blit_BGR555_OBO
113     #include "video_blit.h"
114    
115     #else
116    
117     // Native byte order (untested)
118    
119     #define FB_BLIT_1(dst, src) \
120     (dst = (((src) >> 2) & 0x1f) | (((src) >> 8) & 0xe0) | (((src) << 8) & 0x0300) | (((src) << 2) & 0x7c00))
121    
122     #define FB_BLIT_2(dst, src) \
123     (dst = (((src) >> 2) & 0x1f001f) | (((src) >> 8) & 0xe000e0) | (((src) << 8) & 0x03000300) | (((src) << 2) & 0x7c007c00))
124    
125 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
126     (dst = (((src) >> 2) & UVAL64(0x001f001f001f001f)) | \
127     (((src) >> 8) & UVAL64(0x00e000e000e000e0)) | \
128     (((src) << 8) & UVAL64(0x0300030003000300)) | \
129     (((src) << 2) & UVAL64(0x7c007c007c007c00)))
130    
131 gbeauche 1.2 #define FB_DEPTH 15
132     #define FB_FUNC_NAME Blit_BGR555_NBO
133     #include "video_blit.h"
134    
135     // Opposite byte order (untested)
136    
137     #define FB_BLIT_1(dst, src) \
138     (dst = (((src) << 6) & 0x1f00) | ((src) & 0xe003) | (((src) >> 6) & 0x7c))
139    
140     #define FB_BLIT_2(dst, src) \
141     (dst = (((src) << 6) & 0x1f001f00) | ((src) & 0xe003e003) | (((src) >> 6) & 0x7c007c))
142    
143 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
144     (dst = (((src) << 6) & UVAL64(0x1f001f001f001f00)) | \
145     ( (src) & UVAL64(0xe003e003e003e003)) | \
146     (((src) >> 6) & UVAL64(0x007c007c007c007c)))
147    
148 gbeauche 1.2 #define FB_DEPTH 15
149     #define FB_FUNC_NAME Blit_BGR555_OBO
150     #include "video_blit.h"
151    
152     #endif
153 gbeauche 1.1
154     /* -------------------------------------------------------------------------- */
155     /* --- RGB 565 --- */
156     /* -------------------------------------------------------------------------- */
157    
158     #ifdef WORDS_BIGENDIAN
159    
160     // Native byte order
161    
162     #define FB_BLIT_1(dst, src) \
163     (dst = (((src) & 0x1f) | (((src) << 1) & 0xffc0)))
164    
165     #define FB_BLIT_2(dst, src) \
166     (dst = (((src) & 0x001f001f) | (((src) << 1) & 0xffc0ffc0)))
167    
168 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
169     (dst = (((src) & UVAL64(0x001f001f001f001f)) | \
170     (((src) << 1) & UVAL64(0xffc0ffc0ffc0ffc0))))
171    
172 gbeauche 1.1 #define FB_DEPTH 16
173     #define FB_FUNC_NAME Blit_RGB565_NBO
174     #include "video_blit.h"
175    
176     // Opposite byte order
177    
178     #define FB_BLIT_1(dst, src) \
179     (dst = ((((src) >> 7) & 0xff) | (((src) << 9) & 0xc000) | (((src) << 8) & 0x1f00)))
180    
181     #define FB_BLIT_2(dst, src) \
182     (dst = ((((src) >> 7) & 0x00ff00ff) | (((src) << 9) & 0xc000c000) | (((src) << 8) & 0x1f001f00)))
183    
184 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
185     (dst = (((src) >> 7) & UVAL64(0x00ff00ff00ff00ff)) | \
186     (((src) << 9) & UVAL64(0xc000c000c000c000)) | \
187     (((src) << 8) & UVAL64(0x1f001f001f001f00)))
188    
189 gbeauche 1.1 #define FB_DEPTH 16
190     #define FB_FUNC_NAME Blit_RGB565_OBO
191     #include "video_blit.h"
192    
193     #else
194    
195     // Native byte order
196    
197     #define FB_BLIT_1(dst, src) \
198     (dst = (((src) >> 8) & 0x001f) | (((src) << 9) & 0xfe00) | (((src) >> 7) & 0x01c0))
199    
200     #define FB_BLIT_2(dst, src) \
201     (dst = (((src) >> 8) & 0x001f001f) | (((src) << 9) & 0xfe00fe00) | (((src) >> 7) & 0x01c001c0))
202    
203 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
204     (dst = (((src) >> 8) & UVAL64(0x001f001f001f001f)) | \
205     (((src) << 9) & UVAL64(0xfe00fe00fe00fe00)) | \
206     (((src) >> 7) & UVAL64(0x01c001c001c001c0)))
207 gbeauche 1.1
208     #define FB_DEPTH 16
209     #define FB_FUNC_NAME Blit_RGB565_NBO
210     #include "video_blit.h"
211    
212     // Opposite byte order (untested)
213    
214     #define FB_BLIT_1(dst, src) \
215     (dst = (((src) & 0x1f00) | (((src) << 1) & 0xe0fe) | (((src) >> 15) & 1)))
216    
217     #define FB_BLIT_2(dst, src) \
218     (dst = (((src) & 0x1f001f00) | (((src) << 1) & 0xe0fee0fe) | (((src) >> 15) & 0x10001)))
219    
220 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
221     (dst = (((src) & UVAL64(0x1f001f001f001f00)) | \
222     (((src) << 1) & UVAL64(0xe0fee0fee0fee0fe)) | \
223     (((src) >> 15) & UVAL64(0x0001000100010001))))
224    
225 gbeauche 1.1 #define FB_DEPTH 16
226     #define FB_FUNC_NAME Blit_RGB565_OBO
227     #include "video_blit.h"
228    
229     #endif
230    
231     /* -------------------------------------------------------------------------- */
232     /* --- RGB 888 --- */
233     /* -------------------------------------------------------------------------- */
234    
235     #ifdef WORDS_BIGENDIAN
236     # define FB_FUNC_NAME Blit_RGB888_OBO
237     #else
238     # define FB_FUNC_NAME Blit_RGB888_NBO
239     #endif
240    
241     #define FB_BLIT_2(dst, src) \
242     (dst = (((src) >> 24) & 0xff) | (((src) >> 8) & 0xff00) | (((src) & 0xff00) << 8) | (((src) & 0xff) << 24))
243    
244 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
245     (dst = (((src) >> 24) & UVAL64(0x000000ff000000ff)) | \
246     (((src) >> 8) & UVAL64(0x0000ff000000ff00)) | \
247     (((src) & UVAL64(0x0000ff000000ff00)) << 8) | \
248     (((src) & UVAL64(0x000000ff000000ff)) << 24))
249    
250 gbeauche 1.1 #define FB_DEPTH 24
251     #include "video_blit.h"
252    
253     /* -------------------------------------------------------------------------- */
254     /* --- BGR 888 --- */
255     /* -------------------------------------------------------------------------- */
256    
257 gbeauche 1.2 // Native byte order [BE] (untested)
258 gbeauche 1.1
259     #ifdef WORDS_BIGENDIAN
260    
261     #define FB_BLIT_2(dst, src) \
262     (dst = (((src) >> 16) & 0xff) | ((src) & 0xff00) | (((src) & 0xff) << 16))
263    
264 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
265     (dst = (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \
266     ( (src) & UVAL64(0x0000ff000000ff00)) | \
267     (((src) & UVAL64(0x000000ff000000ff)) << 16))
268    
269 gbeauche 1.1 #define FB_FUNC_NAME Blit_BGR888_NBO
270     #define FB_DEPTH 24
271     #include "video_blit.h"
272    
273     #else
274    
275 gbeauche 1.2 // Opposite byte order [LE] (untested)
276    
277 gbeauche 1.1 #define FB_BLIT_2(dst, src) \
278     (dst = (((src) >> 16) & 0xff) | ((src) & 0xff0000) | (((src) & 0xff) << 16))
279    
280 gbeauche 1.9 #define FB_BLIT_4(dst, src) \
281     (dst = (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \
282     ( (src) & UVAL64(0x00ff000000ff0000)) | \
283     (((src) & UVAL64(0x000000ff000000ff)) << 16))
284    
285 gbeauche 1.1 #define FB_FUNC_NAME Blit_BGR888_OBO
286     #define FB_DEPTH 24
287     #include "video_blit.h"
288    
289     #endif
290    
291 gbeauche 1.2 // Opposite byte order [BE] (untested) / Native byte order [LE] (untested)
292 gbeauche 1.1
293     #ifdef WORDS_BIGENDIAN
294     # define FB_FUNC_NAME Blit_BGR888_OBO
295     #else
296     # define FB_FUNC_NAME Blit_BGR888_NBO
297     #endif
298    
299     #define FB_BLIT_2(dst, src) \
300     (dst = ((src) & 0xff00ff) | (((src) & 0xff00) << 16))
301 gbeauche 1.9
302     #define FB_BLIT_4(dst, src) \
303     (dst = ((src) & UVAL64(0x00ff00ff00ff00ff)) | (((src) & UVAL64(0x0000ff000000ff00)) << 16))
304 gbeauche 1.1
305     #define FB_DEPTH 24
306     #include "video_blit.h"
307    
308     /* -------------------------------------------------------------------------- */
309 cebix 1.7 /* --- 2/4-bit indexed to 8-bit mode conversion --- */
310     /* -------------------------------------------------------------------------- */
311    
312     static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length)
313     {
314     uint8 *q = (uint8 *)dest;
315 cebix 1.8 for (uint32 i=0; i<length; i++) {
316 cebix 1.7 uint8 c = *p++;
317     *q++ = c >> 6;
318     *q++ = (c >> 4) & 3;
319     *q++ = (c >> 2) & 3;
320     *q++ = c & 3;
321     }
322     }
323    
324     static void Blit_Expand_4_To_8(uint8 * dest, const uint8 * p, uint32 length)
325     {
326     uint8 *q = (uint8 *)dest;
327 cebix 1.8 for (uint32 i=0; i<length; i++) {
328 cebix 1.7 uint8 c = *p++;
329     *q++ = c >> 4;
330     *q++ = c & 0x0f;
331     }
332     }
333    
334     /* -------------------------------------------------------------------------- */
335 cebix 1.6 /* --- 2/4/8-bit indexed to 16-bit mode color expansion --- */
336 cebix 1.5 /* -------------------------------------------------------------------------- */
337    
338 cebix 1.6 static void Blit_Expand_2_To_16(uint8 * dest, const uint8 * p, uint32 length)
339     {
340     uint16 *q = (uint16 *)dest;
341 cebix 1.8 for (uint32 i=0; i<length; i++) {
342 cebix 1.6 uint8 c = *p++;
343     *q++ = ExpandMap[c >> 6];
344     *q++ = ExpandMap[c >> 4];
345     *q++ = ExpandMap[c >> 2];
346     *q++ = ExpandMap[c];
347     }
348     }
349    
350     static void Blit_Expand_4_To_16(uint8 * dest, const uint8 * p, uint32 length)
351     {
352     uint16 *q = (uint16 *)dest;
353 cebix 1.8 for (uint32 i=0; i<length; i++) {
354 cebix 1.6 uint8 c = *p++;
355     *q++ = ExpandMap[c >> 4];
356     *q++ = ExpandMap[c];
357     }
358     }
359    
360 cebix 1.5 static void Blit_Expand_8_To_16(uint8 * dest, const uint8 * p, uint32 length)
361     {
362     uint16 *q = (uint16 *)dest;
363 cebix 1.8 for (uint32 i=0; i<length; i++)
364 cebix 1.5 *q++ = ExpandMap[*p++];
365     }
366    
367     /* -------------------------------------------------------------------------- */
368 cebix 1.6 /* --- 2/4/8-bit indexed to 32-bit mode color expansion --- */
369 cebix 1.5 /* -------------------------------------------------------------------------- */
370    
371 cebix 1.6 static void Blit_Expand_2_To_32(uint8 * dest, const uint8 * p, uint32 length)
372     {
373     uint32 *q = (uint32 *)dest;
374 cebix 1.8 for (uint32 i=0; i<length; i++) {
375 cebix 1.6 uint8 c = *p++;
376     *q++ = ExpandMap[c >> 6];
377     *q++ = ExpandMap[c >> 4];
378     *q++ = ExpandMap[c >> 2];
379     *q++ = ExpandMap[c];
380     }
381     }
382    
383     static void Blit_Expand_4_To_32(uint8 * dest, const uint8 * p, uint32 length)
384     {
385     uint32 *q = (uint32 *)dest;
386 cebix 1.8 for (uint32 i=0; i<length; i++) {
387 cebix 1.6 uint8 c = *p++;
388     *q++ = ExpandMap[c >> 4];
389     *q++ = ExpandMap[c];
390     }
391     }
392    
393 cebix 1.5 static void Blit_Expand_8_To_32(uint8 * dest, const uint8 * p, uint32 length)
394     {
395     uint32 *q = (uint32 *)dest;
396 cebix 1.8 for (uint32 i=0; i<length; i++)
397 cebix 1.5 *q++ = ExpandMap[*p++];
398     }
399    
400     /* -------------------------------------------------------------------------- */
401 gbeauche 1.1 /* --- Blitters to the host frame buffer, or XImage buffer --- */
402     /* -------------------------------------------------------------------------- */
403    
404     // Function used to update the hosst frame buffer (DGA), or an XImage buffer (WIN)
405     // --> Shall be initialized only through the Screen_blitter_init() function
406     typedef void (*Screen_blit_func)(uint8 * dest, const uint8 * source, uint32 length);
407     Screen_blit_func Screen_blit = 0;
408    
409     // Structure used to match the adequate framebuffer update function
410     struct Screen_blit_func_info {
411     int depth; // Screen depth
412     uint32 Rmask; // Red mask
413     uint32 Gmask; // Green mask
414     uint32 Bmask; // Blue mask
415     Screen_blit_func handler_nbo; // Update function (native byte order)
416     Screen_blit_func handler_obo; // Update function (opposite byte order)
417     };
418    
419     // Table of visual formats supported and their respective handler
420     static Screen_blit_func_info Screen_blitters[] = {
421     #ifdef WORDS_BIGENDIAN
422     { 1, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // NT
423     { 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO)
424     { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw , Blit_RGB555_OBO }, // OK (OBO)
425 gbeauche 1.2 { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT
426 gbeauche 1.1 { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (OBO)
427     { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK (OBO)
428     { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT
429 gbeauche 1.2 { 32, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK
430     { 32, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO } // OK
431 gbeauche 1.1 #else
432     { 1, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // NT
433     { 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO)
434     { 15, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO , Blit_Copy_Raw }, // OK (NBO)
435 gbeauche 1.2 { 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT
436 gbeauche 1.1 { 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (NBO)
437     { 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_RGB888_NBO , Blit_Copy_Raw }, // OK (NBO)
438     { 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT
439     { 32, 0xff0000, 0x00ff00, 0x0000ff, Blit_RGB888_NBO , Blit_Copy_Raw }, // OK (NBO)
440     { 32, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO } // NT
441     #endif
442     };
443    
444     // Initialize the framebuffer update function
445     // Returns FALSE, if the function was to be reduced to a simple memcpy()
446     // --> In that case, VOSF is not necessary
447 cebix 1.4 bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, video_depth mac_depth)
448 gbeauche 1.1 {
449 gbeauche 1.3 #if REAL_ADDRESSING || DIRECT_ADDRESSING
450 cebix 1.4 if (mac_depth == VDEPTH_1BIT) {
451    
452     // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines
453     Screen_blit = Blit_Copy_Raw;
454    
455     } else {
456    
457     visualFormat.depth = visual_info->depth;
458     visualFormat.Rmask = visual_info->red_mask;
459     visualFormat.Gmask = visual_info->green_mask;
460     visualFormat.Bmask = visual_info->blue_mask;
461 cebix 1.5
462 cebix 1.4 // Compute RGB shift values
463     visualFormat.Rshift = 0;
464     for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1)
465     ++visualFormat.Rshift;
466     visualFormat.Gshift = 0;
467     for (uint32 Gmask = visualFormat.Gmask; Gmask && ((Gmask & 1) != 1); Gmask >>= 1)
468     ++visualFormat.Gshift;
469     visualFormat.Bshift = 0;
470     for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1)
471     ++visualFormat.Bshift;
472 cebix 1.5
473     bool blitter_found = false;
474    
475 cebix 1.7 // 2/4/8-bit mode on 8/16/32-bit screen?
476     if (visualFormat.depth == 8) {
477     if (mac_depth == VDEPTH_2BIT) {
478     Screen_blit = Blit_Expand_2_To_8;
479     blitter_found = true;
480     } else if (mac_depth == VDEPTH_4BIT) {
481     Screen_blit = Blit_Expand_4_To_8;
482     blitter_found = true;
483     }
484     } else if (visualFormat.depth == 15 || visualFormat.depth == 16) {
485     if (mac_depth == VDEPTH_2BIT) {
486     Screen_blit = Blit_Expand_2_To_16;
487     blitter_found = true;
488     } else if (mac_depth == VDEPTH_4BIT) {
489     Screen_blit = Blit_Expand_4_To_16;
490     blitter_found = true;
491     } else if (mac_depth == VDEPTH_8BIT) {
492     Screen_blit = Blit_Expand_8_To_16;
493     blitter_found = true;
494     }
495     } else if (visualFormat.depth == 24 || visualFormat.depth == 32) {
496 cebix 1.6 if (mac_depth == VDEPTH_2BIT) {
497 cebix 1.7 Screen_blit = Blit_Expand_2_To_32;
498     blitter_found = true;
499 cebix 1.6 } else if (mac_depth == VDEPTH_4BIT) {
500 cebix 1.7 Screen_blit = Blit_Expand_4_To_32;
501     blitter_found = true;
502 cebix 1.6 } else if (mac_depth == VDEPTH_8BIT) {
503 cebix 1.7 Screen_blit = Blit_Expand_8_To_32;
504     blitter_found = true;
505 cebix 1.5 }
506     }
507 gbeauche 1.1
508 cebix 1.4 // Search for an adequate blit function
509     const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]);
510     for (int i = 0; !blitter_found && (i < blitters_count); i++) {
511     if ( (visualFormat.depth == Screen_blitters[i].depth)
512     && (visualFormat.Rmask == Screen_blitters[i].Rmask)
513     && (visualFormat.Gmask == Screen_blitters[i].Gmask)
514     && (visualFormat.Bmask == Screen_blitters[i].Bmask)
515     )
516     {
517     blitter_found = true;
518     Screen_blit = native_byte_order
519     ? Screen_blitters[i].handler_nbo
520     : Screen_blitters[i].handler_obo
521     ;
522     }
523 gbeauche 1.1 }
524    
525 cebix 1.4 // No appropriate blitter found, dump RGB mask values and abort()
526     if (!blitter_found) {
527     fprintf(stderr, "### No appropriate blitter found\n");
528     fprintf(stderr, "\tR/G/B mask values : 0x%06x, 0x%06x, 0x%06x (depth = %d)\n",
529     visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask, visualFormat.depth);
530     fprintf(stderr, "\tR/G/B shift values : %d/%d/%d\n",
531     visualFormat.Rshift, visualFormat.Gshift, visualFormat.Bshift);
532     abort();
533     }
534 gbeauche 1.1 }
535 gbeauche 1.3 #else
536     // The UAE memory handlers will blit correctly
537     // --> no need for specialised blitters here
538     Screen_blit = Blit_Copy_Raw;
539     #endif
540 gbeauche 1.1
541     // If the blitter simply reduces to a copy, we don't need VOSF in DGA mode
542     // --> In that case, we return FALSE
543     return (Screen_blit != Blit_Copy_Raw);
544     }
545     #endif /* ENABLE_VOSF */