1 |
|
/* |
2 |
|
* video_blit.cpp - Video/graphics emulation, blitters |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 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 |
19 |
|
*/ |
20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
+ |
#include "video.h" |
23 |
+ |
#include "video_blit.h" |
24 |
|
|
25 |
|
#include <stdio.h> |
26 |
|
#include <stdlib.h> |
25 |
– |
#include <X11/Xlib.h> |
26 |
– |
#include <X11/Xutil.h> |
27 |
|
|
28 |
– |
#ifdef ENABLE_VOSF |
28 |
|
// Format of the target visual |
30 |
– |
struct VisualFormat { |
31 |
– |
int depth; // Screen depth |
32 |
– |
uint32 Rmask, Gmask, Bmask; // RGB mask values |
33 |
– |
uint32 Rshift, Gshift, Bshift; // RGB shift values |
34 |
– |
}; |
29 |
|
static VisualFormat visualFormat; |
30 |
|
|
31 |
+ |
// This holds the pixels values of the palette colors for 8->16/32-bit expansion |
32 |
+ |
uint32 ExpandMap[256]; |
33 |
+ |
|
34 |
+ |
// Mark video_blit.h for specialization |
35 |
+ |
#define DEFINE_VIDEO_BLITTERS 1 |
36 |
+ |
|
37 |
|
/* -------------------------------------------------------------------------- */ |
38 |
|
/* --- Raw Copy / No conversion required --- */ |
39 |
|
/* -------------------------------------------------------------------------- */ |
60 |
|
#define FB_BLIT_2(dst, src) \ |
61 |
|
(dst = (((src) >> 8) & 0x00ff00ff) | (((src) & 0x00ff00ff) << 8)) |
62 |
|
|
63 |
+ |
#define FB_BLIT_4(dst, src) \ |
64 |
+ |
(dst = (((src) >> 8) & UVAL64(0x00ff00ff00ff00ff)) | \ |
65 |
+ |
(((src) & UVAL64(0x00ff00ff00ff00ff)) << 8)) |
66 |
+ |
|
67 |
|
#define FB_DEPTH 15 |
68 |
|
#include "video_blit.h" |
69 |
|
|
71 |
|
/* --- BGR 555 --- */ |
72 |
|
/* -------------------------------------------------------------------------- */ |
73 |
|
|
74 |
< |
// TODO: BGR 555 (SGI/Irix) |
75 |
< |
// R/G/B mask values: 0x001f, 0x03e0, 0x7c00 |
74 |
> |
#ifdef WORDS_BIGENDIAN |
75 |
> |
|
76 |
> |
// Native byte order |
77 |
> |
|
78 |
> |
#define FB_BLIT_1(dst, src) \ |
79 |
> |
(dst = (((src) >> 10) & 0x001f) | ((src) & 0x03e0) | (((src) << 10) & 0x7c00)) |
80 |
> |
|
81 |
> |
#define FB_BLIT_2(dst, src) \ |
82 |
> |
(dst = (((src) >> 10) & 0x001f001f) | ((src) & 0x03e003e0) | (((src) << 10) & 0x7c007c00)) |
83 |
> |
|
84 |
> |
#define FB_BLIT_4(dst, src) \ |
85 |
> |
(dst = (((src) >> 10) & UVAL64(0x001f001f001f001f)) | \ |
86 |
> |
( (src) & UVAL64(0x03e003e003e003e0)) | \ |
87 |
> |
(((src) << 10) & UVAL64(0x7c007c007c007c00))) |
88 |
> |
|
89 |
> |
#define FB_DEPTH 15 |
90 |
> |
#define FB_FUNC_NAME Blit_BGR555_NBO |
91 |
> |
#include "video_blit.h" |
92 |
> |
|
93 |
> |
// Opposite byte order (untested) |
94 |
> |
|
95 |
> |
#define FB_BLIT_1(dst, src) \ |
96 |
> |
(dst = (((src) >> 2) & 0x1f00) | (((src) >> 8) & 3) | (((src) << 8) & 0xe000) | (((src) << 2) & 0x7c)) |
97 |
> |
|
98 |
> |
#define FB_BLIT_2(dst, src) \ |
99 |
> |
(dst = (((src) >> 2) & 0x1f001f00) | (((src) >> 8) & 0x30003) | (((src) << 8) & 0xe000e000) | (((src) << 2) & 0x7c007c)) |
100 |
> |
|
101 |
> |
#define FB_BLIT_4(dst, src) \ |
102 |
> |
(dst = (((src) >> 2) & UVAL64(0x1f001f001f001f00)) | \ |
103 |
> |
(((src) >> 8) & UVAL64(0x0003000300030003)) | \ |
104 |
> |
(((src) << 8) & UVAL64(0xe000e000e000e000)) | \ |
105 |
> |
(((src) << 2) & UVAL64(0x007c007c007c007c))) |
106 |
> |
|
107 |
> |
#define FB_DEPTH 15 |
108 |
> |
#define FB_FUNC_NAME Blit_BGR555_OBO |
109 |
> |
#include "video_blit.h" |
110 |
> |
|
111 |
> |
#else |
112 |
> |
|
113 |
> |
// Native byte order (untested) |
114 |
> |
|
115 |
> |
#define FB_BLIT_1(dst, src) \ |
116 |
> |
(dst = (((src) >> 2) & 0x1f) | (((src) >> 8) & 0xe0) | (((src) << 8) & 0x0300) | (((src) << 2) & 0x7c00)) |
117 |
> |
|
118 |
> |
#define FB_BLIT_2(dst, src) \ |
119 |
> |
(dst = (((src) >> 2) & 0x1f001f) | (((src) >> 8) & 0xe000e0) | (((src) << 8) & 0x03000300) | (((src) << 2) & 0x7c007c00)) |
120 |
> |
|
121 |
> |
#define FB_BLIT_4(dst, src) \ |
122 |
> |
(dst = (((src) >> 2) & UVAL64(0x001f001f001f001f)) | \ |
123 |
> |
(((src) >> 8) & UVAL64(0x00e000e000e000e0)) | \ |
124 |
> |
(((src) << 8) & UVAL64(0x0300030003000300)) | \ |
125 |
> |
(((src) << 2) & UVAL64(0x7c007c007c007c00))) |
126 |
> |
|
127 |
> |
#define FB_DEPTH 15 |
128 |
> |
#define FB_FUNC_NAME Blit_BGR555_NBO |
129 |
> |
#include "video_blit.h" |
130 |
> |
|
131 |
> |
// Opposite byte order (untested) |
132 |
> |
|
133 |
> |
#define FB_BLIT_1(dst, src) \ |
134 |
> |
(dst = (((src) << 6) & 0x1f00) | ((src) & 0xe003) | (((src) >> 6) & 0x7c)) |
135 |
> |
|
136 |
> |
#define FB_BLIT_2(dst, src) \ |
137 |
> |
(dst = (((src) << 6) & 0x1f001f00) | ((src) & 0xe003e003) | (((src) >> 6) & 0x7c007c)) |
138 |
> |
|
139 |
> |
#define FB_BLIT_4(dst, src) \ |
140 |
> |
(dst = (((src) << 6) & UVAL64(0x1f001f001f001f00)) | \ |
141 |
> |
( (src) & UVAL64(0xe003e003e003e003)) | \ |
142 |
> |
(((src) >> 6) & UVAL64(0x007c007c007c007c))) |
143 |
> |
|
144 |
> |
#define FB_DEPTH 15 |
145 |
> |
#define FB_FUNC_NAME Blit_BGR555_OBO |
146 |
> |
#include "video_blit.h" |
147 |
> |
|
148 |
> |
#endif |
149 |
|
|
150 |
|
/* -------------------------------------------------------------------------- */ |
151 |
|
/* --- RGB 565 --- */ |
161 |
|
#define FB_BLIT_2(dst, src) \ |
162 |
|
(dst = (((src) & 0x001f001f) | (((src) << 1) & 0xffc0ffc0))) |
163 |
|
|
164 |
+ |
#define FB_BLIT_4(dst, src) \ |
165 |
+ |
(dst = (((src) & UVAL64(0x001f001f001f001f)) | \ |
166 |
+ |
(((src) << 1) & UVAL64(0xffc0ffc0ffc0ffc0)))) |
167 |
+ |
|
168 |
|
#define FB_DEPTH 16 |
169 |
|
#define FB_FUNC_NAME Blit_RGB565_NBO |
170 |
|
#include "video_blit.h" |
177 |
|
#define FB_BLIT_2(dst, src) \ |
178 |
|
(dst = ((((src) >> 7) & 0x00ff00ff) | (((src) << 9) & 0xc000c000) | (((src) << 8) & 0x1f001f00))) |
179 |
|
|
180 |
+ |
#define FB_BLIT_4(dst, src) \ |
181 |
+ |
(dst = (((src) >> 7) & UVAL64(0x00ff00ff00ff00ff)) | \ |
182 |
+ |
(((src) << 9) & UVAL64(0xc000c000c000c000)) | \ |
183 |
+ |
(((src) << 8) & UVAL64(0x1f001f001f001f00))) |
184 |
+ |
|
185 |
|
#define FB_DEPTH 16 |
186 |
|
#define FB_FUNC_NAME Blit_RGB565_OBO |
187 |
|
#include "video_blit.h" |
193 |
|
#define FB_BLIT_1(dst, src) \ |
194 |
|
(dst = (((src) >> 8) & 0x001f) | (((src) << 9) & 0xfe00) | (((src) >> 7) & 0x01c0)) |
195 |
|
|
110 |
– |
// gb-- Disabled because I don't see any improvement |
111 |
– |
#if 0 && defined(__i386__) && defined(X86_ASSEMBLY) |
112 |
– |
|
113 |
– |
#define FB_BLIT_2(dst, src) \ |
114 |
– |
__asm__ ( "movl %0,%%ebx\n\t" \ |
115 |
– |
"movl %0,%%ebp\n\t" \ |
116 |
– |
"andl $0x1f001f00,%%ebx\n\t" \ |
117 |
– |
"andl $0x007f007f,%0\n\t" \ |
118 |
– |
"andl $0xe000e000,%%ebp\n\t" \ |
119 |
– |
"shrl $8,%%ebx\n\t" \ |
120 |
– |
"shrl $7,%%ebp\n\t" \ |
121 |
– |
"shll $9,%0\n\t" \ |
122 |
– |
"orl %%ebx,%%ebp\n\t" \ |
123 |
– |
"orl %%ebp,%0\n\t" \ |
124 |
– |
: "=r" (dst) : "0" (src) : "ebx", "ebp", "cc" ) |
125 |
– |
|
126 |
– |
#else |
127 |
– |
|
196 |
|
#define FB_BLIT_2(dst, src) \ |
197 |
|
(dst = (((src) >> 8) & 0x001f001f) | (((src) << 9) & 0xfe00fe00) | (((src) >> 7) & 0x01c001c0)) |
198 |
|
|
199 |
< |
#endif |
199 |
> |
#define FB_BLIT_4(dst, src) \ |
200 |
> |
(dst = (((src) >> 8) & UVAL64(0x001f001f001f001f)) | \ |
201 |
> |
(((src) << 9) & UVAL64(0xfe00fe00fe00fe00)) | \ |
202 |
> |
(((src) >> 7) & UVAL64(0x01c001c001c001c0))) |
203 |
|
|
204 |
|
#define FB_DEPTH 16 |
205 |
|
#define FB_FUNC_NAME Blit_RGB565_NBO |
213 |
|
#define FB_BLIT_2(dst, src) \ |
214 |
|
(dst = (((src) & 0x1f001f00) | (((src) << 1) & 0xe0fee0fe) | (((src) >> 15) & 0x10001))) |
215 |
|
|
216 |
+ |
#define FB_BLIT_4(dst, src) \ |
217 |
+ |
(dst = (((src) & UVAL64(0x1f001f001f001f00)) | \ |
218 |
+ |
(((src) << 1) & UVAL64(0xe0fee0fee0fee0fe)) | \ |
219 |
+ |
(((src) >> 15) & UVAL64(0x0001000100010001)))) |
220 |
+ |
|
221 |
|
#define FB_DEPTH 16 |
222 |
|
#define FB_FUNC_NAME Blit_RGB565_OBO |
223 |
|
#include "video_blit.h" |
237 |
|
#define FB_BLIT_2(dst, src) \ |
238 |
|
(dst = (((src) >> 24) & 0xff) | (((src) >> 8) & 0xff00) | (((src) & 0xff00) << 8) | (((src) & 0xff) << 24)) |
239 |
|
|
240 |
+ |
#define FB_BLIT_4(dst, src) \ |
241 |
+ |
(dst = (((src) >> 24) & UVAL64(0x000000ff000000ff)) | \ |
242 |
+ |
(((src) >> 8) & UVAL64(0x0000ff000000ff00)) | \ |
243 |
+ |
(((src) & UVAL64(0x0000ff000000ff00)) << 8) | \ |
244 |
+ |
(((src) & UVAL64(0x000000ff000000ff)) << 24)) |
245 |
+ |
|
246 |
|
#define FB_DEPTH 24 |
247 |
|
#include "video_blit.h" |
248 |
|
|
250 |
|
/* --- BGR 888 --- */ |
251 |
|
/* -------------------------------------------------------------------------- */ |
252 |
|
|
253 |
< |
// Native byte order (untested) |
253 |
> |
// Native byte order [BE] (untested) |
254 |
|
|
255 |
|
#ifdef WORDS_BIGENDIAN |
256 |
|
|
257 |
|
#define FB_BLIT_2(dst, src) \ |
258 |
|
(dst = (((src) >> 16) & 0xff) | ((src) & 0xff00) | (((src) & 0xff) << 16)) |
259 |
|
|
260 |
+ |
#define FB_BLIT_4(dst, src) \ |
261 |
+ |
(dst = (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \ |
262 |
+ |
( (src) & UVAL64(0x0000ff000000ff00)) | \ |
263 |
+ |
(((src) & UVAL64(0x000000ff000000ff)) << 16)) |
264 |
+ |
|
265 |
|
#define FB_FUNC_NAME Blit_BGR888_NBO |
266 |
|
#define FB_DEPTH 24 |
267 |
|
#include "video_blit.h" |
268 |
|
|
269 |
|
#else |
270 |
|
|
271 |
+ |
// Opposite byte order [LE] (untested) |
272 |
+ |
|
273 |
|
#define FB_BLIT_2(dst, src) \ |
274 |
|
(dst = (((src) >> 16) & 0xff) | ((src) & 0xff0000) | (((src) & 0xff) << 16)) |
275 |
|
|
276 |
+ |
#define FB_BLIT_4(dst, src) \ |
277 |
+ |
(dst = (((src) >> 16) & UVAL64(0x000000ff000000ff)) | \ |
278 |
+ |
( (src) & UVAL64(0x00ff000000ff0000)) | \ |
279 |
+ |
(((src) & UVAL64(0x000000ff000000ff)) << 16)) |
280 |
+ |
|
281 |
|
#define FB_FUNC_NAME Blit_BGR888_OBO |
282 |
|
#define FB_DEPTH 24 |
283 |
|
#include "video_blit.h" |
284 |
|
|
285 |
|
#endif |
286 |
|
|
287 |
< |
// Opposite byte order (untested) |
287 |
> |
// Opposite byte order [BE] (untested) / Native byte order [LE] (untested) |
288 |
|
|
289 |
|
#ifdef WORDS_BIGENDIAN |
290 |
|
# define FB_FUNC_NAME Blit_BGR888_OBO |
295 |
|
#define FB_BLIT_2(dst, src) \ |
296 |
|
(dst = ((src) & 0xff00ff) | (((src) & 0xff00) << 16)) |
297 |
|
|
298 |
+ |
#define FB_BLIT_4(dst, src) \ |
299 |
+ |
(dst = ((src) & UVAL64(0x00ff00ff00ff00ff)) | (((src) & UVAL64(0x0000ff000000ff00)) << 16)) |
300 |
+ |
|
301 |
|
#define FB_DEPTH 24 |
302 |
|
#include "video_blit.h" |
303 |
|
|
304 |
|
/* -------------------------------------------------------------------------- */ |
305 |
+ |
/* --- 1/2/4-bit indexed to 8-bit mode conversion --- */ |
306 |
+ |
/* -------------------------------------------------------------------------- */ |
307 |
+ |
|
308 |
+ |
static void Blit_Expand_1_To_8(uint8 * dest, const uint8 * p, uint32 length) |
309 |
+ |
{ |
310 |
+ |
uint8 *q = (uint8 *)dest; |
311 |
+ |
for (uint32 i=0; i<length; i++) { |
312 |
+ |
uint8 c = *p++; |
313 |
+ |
*q++ = c >> 7; |
314 |
+ |
*q++ = (c >> 6) & 1; |
315 |
+ |
*q++ = (c >> 5) & 1; |
316 |
+ |
*q++ = (c >> 4) & 1; |
317 |
+ |
*q++ = (c >> 3) & 1; |
318 |
+ |
*q++ = (c >> 2) & 1; |
319 |
+ |
*q++ = (c >> 1) & 1; |
320 |
+ |
*q++ = c & 1; |
321 |
+ |
} |
322 |
+ |
} |
323 |
+ |
|
324 |
+ |
static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length) |
325 |
+ |
{ |
326 |
+ |
uint8 *q = (uint8 *)dest; |
327 |
+ |
for (uint32 i=0; i<length; i++) { |
328 |
+ |
uint8 c = *p++; |
329 |
+ |
*q++ = c >> 6; |
330 |
+ |
*q++ = (c >> 4) & 3; |
331 |
+ |
*q++ = (c >> 2) & 3; |
332 |
+ |
*q++ = c & 3; |
333 |
+ |
} |
334 |
+ |
} |
335 |
+ |
|
336 |
+ |
static void Blit_Expand_4_To_8(uint8 * dest, const uint8 * p, uint32 length) |
337 |
+ |
{ |
338 |
+ |
uint8 *q = (uint8 *)dest; |
339 |
+ |
for (uint32 i=0; i<length; i++) { |
340 |
+ |
uint8 c = *p++; |
341 |
+ |
*q++ = c >> 4; |
342 |
+ |
*q++ = c & 0x0f; |
343 |
+ |
} |
344 |
+ |
} |
345 |
+ |
|
346 |
+ |
/* -------------------------------------------------------------------------- */ |
347 |
+ |
/* --- 1/2/4/8-bit indexed to 16-bit mode color expansion --- */ |
348 |
+ |
/* -------------------------------------------------------------------------- */ |
349 |
+ |
|
350 |
+ |
static void Blit_Expand_1_To_16(uint8 * dest, const uint8 * p, uint32 length) |
351 |
+ |
{ |
352 |
+ |
uint16 *q = (uint16 *)dest; |
353 |
+ |
for (uint32 i=0; i<length; i++) { |
354 |
+ |
uint8 c = *p++; |
355 |
+ |
*q++ = -(c >> 7); |
356 |
+ |
*q++ = -((c >> 6) & 1); |
357 |
+ |
*q++ = -((c >> 5) & 1); |
358 |
+ |
*q++ = -((c >> 4) & 1); |
359 |
+ |
*q++ = -((c >> 3) & 1); |
360 |
+ |
*q++ = -((c >> 2) & 1); |
361 |
+ |
*q++ = -((c >> 1) & 1); |
362 |
+ |
*q++ = -(c & 1); |
363 |
+ |
} |
364 |
+ |
} |
365 |
+ |
|
366 |
+ |
static void Blit_Expand_2_To_16(uint8 * dest, const uint8 * p, uint32 length) |
367 |
+ |
{ |
368 |
+ |
uint16 *q = (uint16 *)dest; |
369 |
+ |
for (uint32 i=0; i<length; i++) { |
370 |
+ |
uint8 c = *p++; |
371 |
+ |
*q++ = ExpandMap[c >> 6]; |
372 |
+ |
*q++ = ExpandMap[c >> 4]; |
373 |
+ |
*q++ = ExpandMap[c >> 2]; |
374 |
+ |
*q++ = ExpandMap[c]; |
375 |
+ |
} |
376 |
+ |
} |
377 |
+ |
|
378 |
+ |
static void Blit_Expand_4_To_16(uint8 * dest, const uint8 * p, uint32 length) |
379 |
+ |
{ |
380 |
+ |
uint16 *q = (uint16 *)dest; |
381 |
+ |
for (uint32 i=0; i<length; i++) { |
382 |
+ |
uint8 c = *p++; |
383 |
+ |
*q++ = ExpandMap[c >> 4]; |
384 |
+ |
*q++ = ExpandMap[c]; |
385 |
+ |
} |
386 |
+ |
} |
387 |
+ |
|
388 |
+ |
static void Blit_Expand_8_To_16(uint8 * dest, const uint8 * p, uint32 length) |
389 |
+ |
{ |
390 |
+ |
uint16 *q = (uint16 *)dest; |
391 |
+ |
for (uint32 i=0; i<length; i++) |
392 |
+ |
*q++ = ExpandMap[*p++]; |
393 |
+ |
} |
394 |
+ |
|
395 |
+ |
/* -------------------------------------------------------------------------- */ |
396 |
+ |
/* --- 1/2/4/8-bit indexed to 32-bit mode color expansion --- */ |
397 |
+ |
/* -------------------------------------------------------------------------- */ |
398 |
+ |
|
399 |
+ |
static void Blit_Expand_1_To_32(uint8 * dest, const uint8 * p, uint32 length) |
400 |
+ |
{ |
401 |
+ |
uint32 *q = (uint32 *)dest; |
402 |
+ |
for (uint32 i=0; i<length; i++) { |
403 |
+ |
uint8 c = *p++; |
404 |
+ |
*q++ = -(c >> 7); |
405 |
+ |
*q++ = -((c >> 6) & 1); |
406 |
+ |
*q++ = -((c >> 5) & 1); |
407 |
+ |
*q++ = -((c >> 4) & 1); |
408 |
+ |
*q++ = -((c >> 3) & 1); |
409 |
+ |
*q++ = -((c >> 2) & 1); |
410 |
+ |
*q++ = -((c >> 1) & 1); |
411 |
+ |
*q++ = -(c & 1); |
412 |
+ |
} |
413 |
+ |
} |
414 |
+ |
|
415 |
+ |
static void Blit_Expand_2_To_32(uint8 * dest, const uint8 * p, uint32 length) |
416 |
+ |
{ |
417 |
+ |
uint32 *q = (uint32 *)dest; |
418 |
+ |
for (uint32 i=0; i<length; i++) { |
419 |
+ |
uint8 c = *p++; |
420 |
+ |
*q++ = ExpandMap[c >> 6]; |
421 |
+ |
*q++ = ExpandMap[c >> 4]; |
422 |
+ |
*q++ = ExpandMap[c >> 2]; |
423 |
+ |
*q++ = ExpandMap[c]; |
424 |
+ |
} |
425 |
+ |
} |
426 |
+ |
|
427 |
+ |
static void Blit_Expand_4_To_32(uint8 * dest, const uint8 * p, uint32 length) |
428 |
+ |
{ |
429 |
+ |
uint32 *q = (uint32 *)dest; |
430 |
+ |
for (uint32 i=0; i<length; i++) { |
431 |
+ |
uint8 c = *p++; |
432 |
+ |
*q++ = ExpandMap[c >> 4]; |
433 |
+ |
*q++ = ExpandMap[c]; |
434 |
+ |
} |
435 |
+ |
} |
436 |
+ |
|
437 |
+ |
static void Blit_Expand_8_To_32(uint8 * dest, const uint8 * p, uint32 length) |
438 |
+ |
{ |
439 |
+ |
uint32 *q = (uint32 *)dest; |
440 |
+ |
for (uint32 i=0; i<length; i++) |
441 |
+ |
*q++ = ExpandMap[*p++]; |
442 |
+ |
} |
443 |
+ |
|
444 |
+ |
/* -------------------------------------------------------------------------- */ |
445 |
|
/* --- Blitters to the host frame buffer, or XImage buffer --- */ |
446 |
|
/* -------------------------------------------------------------------------- */ |
447 |
|
|
466 |
|
{ 1, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // NT |
467 |
|
{ 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO) |
468 |
|
{ 15, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw , Blit_RGB555_OBO }, // OK (OBO) |
469 |
+ |
{ 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT |
470 |
+ |
{ 16, 0x007c00, 0x0003e0, 0x00001f, Blit_Copy_Raw , Blit_RGB555_OBO }, // OK (OBO) |
471 |
|
{ 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (OBO) |
472 |
|
{ 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK (OBO) |
473 |
|
{ 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT |
474 |
< |
{ 32, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK (OBO) |
475 |
< |
{ 32, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO } // NT |
474 |
> |
{ 32, 0xff0000, 0x00ff00, 0x0000ff, Blit_Copy_Raw , Blit_RGB888_OBO }, // OK |
475 |
> |
{ 32, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO } // OK |
476 |
|
#else |
477 |
|
{ 1, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // NT |
478 |
|
{ 8, 0x000000, 0x000000, 0x000000, Blit_Copy_Raw , Blit_Copy_Raw }, // OK (NBO) |
479 |
|
{ 15, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO , Blit_Copy_Raw }, // OK (NBO) |
480 |
+ |
{ 15, 0x00001f, 0x0003e0, 0x007c00, Blit_BGR555_NBO , Blit_BGR555_OBO }, // NT |
481 |
+ |
{ 16, 0x007c00, 0x0003e0, 0x00001f, Blit_RGB555_NBO , Blit_Copy_Raw }, // OK (NBO) |
482 |
|
{ 16, 0x00f800, 0x0007e0, 0x00001f, Blit_RGB565_NBO , Blit_RGB565_OBO }, // OK (NBO) |
483 |
|
{ 24, 0xff0000, 0x00ff00, 0x0000ff, Blit_RGB888_NBO , Blit_Copy_Raw }, // OK (NBO) |
484 |
|
{ 24, 0x0000ff, 0x00ff00, 0xff0000, Blit_BGR888_NBO , Blit_BGR888_OBO }, // NT |
490 |
|
// Initialize the framebuffer update function |
491 |
|
// Returns FALSE, if the function was to be reduced to a simple memcpy() |
492 |
|
// --> In that case, VOSF is not necessary |
493 |
< |
bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order) |
493 |
> |
bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth) |
494 |
|
{ |
495 |
< |
visualFormat.depth = visual_info->depth; |
496 |
< |
visualFormat.Rmask = visual_info->red_mask; |
497 |
< |
visualFormat.Gmask = visual_info->green_mask; |
498 |
< |
visualFormat.Bmask = visual_info->blue_mask; |
499 |
< |
|
500 |
< |
// Compute RGB shift values |
501 |
< |
visualFormat.Rshift = 0; |
502 |
< |
for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1) |
503 |
< |
++visualFormat.Rshift; |
504 |
< |
visualFormat.Gshift = 0; |
505 |
< |
for (uint32 Gmask = visualFormat.Gmask; Gmask && ((Gmask & 1) != 1); Gmask >>= 1) |
506 |
< |
++visualFormat.Gshift; |
507 |
< |
visualFormat.Bshift = 0; |
508 |
< |
for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1) |
509 |
< |
++visualFormat.Bshift; |
495 |
> |
#if USE_SDL_VIDEO |
496 |
> |
const bool use_sdl_video = true; |
497 |
> |
#else |
498 |
> |
const bool use_sdl_video = false; |
499 |
> |
#endif |
500 |
> |
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
501 |
> |
if (mac_depth == 1 && !use_sdl_video && !visual_format.fullscreen) { |
502 |
> |
|
503 |
> |
// Windowed 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines |
504 |
> |
Screen_blit = Blit_Copy_Raw; |
505 |
> |
|
506 |
> |
} else { |
507 |
> |
|
508 |
> |
// Compute RGB shift values |
509 |
> |
visualFormat = visual_format; |
510 |
> |
visualFormat.Rshift = 0; |
511 |
> |
for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1) |
512 |
> |
++visualFormat.Rshift; |
513 |
> |
visualFormat.Gshift = 0; |
514 |
> |
for (uint32 Gmask = visualFormat.Gmask; Gmask && ((Gmask & 1) != 1); Gmask >>= 1) |
515 |
> |
++visualFormat.Gshift; |
516 |
> |
visualFormat.Bshift = 0; |
517 |
> |
for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1) |
518 |
> |
++visualFormat.Bshift; |
519 |
> |
|
520 |
> |
// 1/2/4/8-bit mode on 8/16/32-bit screen? |
521 |
> |
Screen_blit = NULL; |
522 |
> |
switch (visualFormat.depth) { |
523 |
> |
case 8: |
524 |
> |
switch (mac_depth) { |
525 |
> |
case 1: Screen_blit = Blit_Expand_1_To_8; break; |
526 |
> |
case 2: Screen_blit = Blit_Expand_2_To_8; break; |
527 |
> |
case 4: Screen_blit = Blit_Expand_4_To_8; break; |
528 |
> |
} |
529 |
> |
break; |
530 |
> |
case 15: |
531 |
> |
case 16: |
532 |
> |
switch (mac_depth) { |
533 |
> |
case 1: Screen_blit = Blit_Expand_1_To_16; break; |
534 |
> |
case 2: Screen_blit = Blit_Expand_2_To_16; break; |
535 |
> |
case 4: Screen_blit = Blit_Expand_4_To_16; break; |
536 |
> |
case 8: Screen_blit = Blit_Expand_8_To_16; break; |
537 |
> |
} |
538 |
> |
break; |
539 |
> |
case 24: |
540 |
> |
case 32: |
541 |
> |
switch (mac_depth) { |
542 |
> |
case 1: Screen_blit = Blit_Expand_1_To_32; break; |
543 |
> |
case 2: Screen_blit = Blit_Expand_2_To_32; break; |
544 |
> |
case 4: Screen_blit = Blit_Expand_4_To_32; break; |
545 |
> |
case 8: Screen_blit = Blit_Expand_8_To_32; break; |
546 |
> |
} |
547 |
> |
break; |
548 |
> |
} |
549 |
> |
bool blitter_found = (Screen_blit != NULL); |
550 |
|
|
551 |
< |
// Search for an adequate blit function |
552 |
< |
bool blitter_found = false; |
553 |
< |
const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]); |
554 |
< |
for (int i = 0; !blitter_found && (i < blitters_count); i++) { |
555 |
< |
if ( (visualFormat.depth == Screen_blitters[i].depth) |
556 |
< |
&& (visualFormat.Rmask == Screen_blitters[i].Rmask) |
557 |
< |
&& (visualFormat.Gmask == Screen_blitters[i].Gmask) |
558 |
< |
&& (visualFormat.Bmask == Screen_blitters[i].Bmask) |
559 |
< |
) |
560 |
< |
{ |
561 |
< |
blitter_found = true; |
562 |
< |
Screen_blit = native_byte_order |
563 |
< |
? Screen_blitters[i].handler_nbo |
564 |
< |
: Screen_blitters[i].handler_obo |
565 |
< |
; |
551 |
> |
// Search for an adequate blit function |
552 |
> |
const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]); |
553 |
> |
for (int i = 0; !blitter_found && (i < blitters_count); i++) { |
554 |
> |
if ( (visualFormat.depth == Screen_blitters[i].depth) |
555 |
> |
&& (visualFormat.Rmask == Screen_blitters[i].Rmask) |
556 |
> |
&& (visualFormat.Gmask == Screen_blitters[i].Gmask) |
557 |
> |
&& (visualFormat.Bmask == Screen_blitters[i].Bmask) |
558 |
> |
) |
559 |
> |
{ |
560 |
> |
blitter_found = true; |
561 |
> |
Screen_blit = native_byte_order |
562 |
> |
? Screen_blitters[i].handler_nbo |
563 |
> |
: Screen_blitters[i].handler_obo |
564 |
> |
; |
565 |
> |
} |
566 |
|
} |
286 |
– |
} |
567 |
|
|
568 |
< |
// No appropriate blitter found, dump RGB mask values and abort() |
569 |
< |
if (!blitter_found) { |
570 |
< |
fprintf(stderr, "### No appropriate blitter found\n"); |
571 |
< |
fprintf(stderr, "\tR/G/B mask values : 0x%06x, 0x%06x, 0x%06x (depth = %d)\n", |
572 |
< |
visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask, visualFormat.depth); |
573 |
< |
fprintf(stderr, "\tR/G/B shift values : %d/%d/%d\n", |
574 |
< |
visualFormat.Rshift, visualFormat.Gshift, visualFormat.Bshift); |
575 |
< |
abort(); |
568 |
> |
// No appropriate blitter found, dump RGB mask values and abort() |
569 |
> |
if (!blitter_found) { |
570 |
> |
fprintf(stderr, "### No appropriate blitter found\n"); |
571 |
> |
fprintf(stderr, "\tR/G/B mask values : 0x%06x, 0x%06x, 0x%06x (depth = %d)\n", |
572 |
> |
visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask, visualFormat.depth); |
573 |
> |
fprintf(stderr, "\tR/G/B shift values : %d/%d/%d\n", |
574 |
> |
visualFormat.Rshift, visualFormat.Gshift, visualFormat.Bshift); |
575 |
> |
abort(); |
576 |
> |
} |
577 |
|
} |
578 |
+ |
#else |
579 |
+ |
// The UAE memory handlers will blit correctly |
580 |
+ |
// --> no need for specialised blitters here |
581 |
+ |
Screen_blit = Blit_Copy_Raw; |
582 |
+ |
#endif |
583 |
|
|
584 |
|
// If the blitter simply reduces to a copy, we don't need VOSF in DGA mode |
585 |
|
// --> In that case, we return FALSE |
586 |
|
return (Screen_blit != Blit_Copy_Raw); |
587 |
|
} |
302 |
– |
#endif /* ENABLE_VOSF */ |