37 |
|
#include "video_macosx.h" |
38 |
|
|
39 |
|
#define DEBUG 0 |
40 |
+ |
#define VERBOSE 0 |
41 |
|
#include "debug.h" |
42 |
|
|
43 |
|
#ifdef NSBITMAP |
181 |
|
// Helper function to get a 32bit int from a dictionary |
182 |
|
static int32 getCFint32 (CFDictionaryRef dict, CFStringRef key) |
183 |
|
{ |
184 |
< |
CFNumberRef ref = CFDictionaryGetValue(dict, key); |
184 |
> |
CFNumberRef ref = (CFNumberRef) CFDictionaryGetValue(dict, key); |
185 |
|
|
186 |
|
if ( ref ) |
187 |
|
{ |
198 |
|
return 0; |
199 |
|
} |
200 |
|
|
201 |
< |
// Nasty hack. CGDisplayAvailableModes() does not provide bytes per row, |
201 |
> |
// Nasty hack. Under 10.1, CGDisplayAvailableModes() does not provide bytes per row, |
202 |
|
// and the emulator doesn't like setting the bytes per row after the screen, |
203 |
|
// so we use a lot of magic numbers here. |
204 |
|
// This will probably fail on some video hardware. |
259 |
|
|
260 |
|
for ( CFIndex mc = 0; mc < nModes; ++mc ) |
261 |
|
{ |
262 |
< |
CFDictionaryRef modeSpec = CFArrayGetValueAtIndex(m, mc); |
262 |
> |
CFDictionaryRef modeSpec = (CFDictionaryRef) |
263 |
> |
CFArrayGetValueAtIndex(m, mc); |
264 |
|
|
265 |
|
int32 bpp = getCFint32(modeSpec, kCGDisplayBitsPerPixel); |
266 |
|
int32 height = getCFint32(modeSpec, kCGDisplayHeight); |
267 |
|
int32 width = getCFint32(modeSpec, kCGDisplayWidth); |
268 |
+ |
#ifdef MAC_OS_X_VERSION_10_2 |
269 |
+ |
int32 bytes = getCFint32(modeSpec, kCGDisplayBytesPerRow); |
270 |
+ |
#else |
271 |
+ |
int32 bytes = 0; |
272 |
+ |
#endif |
273 |
|
video_depth depth = DepthModeForPixelDepth(bpp); |
274 |
|
|
275 |
|
if ( ! bpp || ! height || ! width ) |
283 |
|
NSLog(@"Display %ld, spec = %@", d, modeSpec); |
284 |
|
#endif |
285 |
|
|
286 |
+ |
if ( ! bytes ) |
287 |
+ |
{ |
288 |
+ |
NSLog(@"Could not get bytes per row, guessing"); |
289 |
+ |
bytes = CGBytesPerRow(width, depth); |
290 |
+ |
} |
291 |
+ |
|
292 |
|
if ( ! oldRes ) |
293 |
|
oldRes = width * height; |
294 |
|
else |
298 |
|
++res_id; |
299 |
|
} |
300 |
|
|
301 |
< |
add_mode(width, height, res_id, |
289 |
< |
CGBytesPerRow(width, depth), (const uint32) d, depth); |
301 |
> |
add_mode(width, height, res_id, bytes, (const uint32) d, depth); |
302 |
|
} |
303 |
|
} |
304 |
|
} |
306 |
|
return true; |
307 |
|
} |
308 |
|
|
309 |
+ |
#ifdef CG_USE_ALPHA |
310 |
+ |
// memset() by long instead of byte |
311 |
+ |
|
312 |
+ |
static void memsetl (long *buffer, long pattern, size_t length) |
313 |
+ |
{ |
314 |
+ |
long *buf = (long *) buffer, |
315 |
+ |
*end = buf + length/4; |
316 |
+ |
|
317 |
+ |
while ( ++buf < end ) |
318 |
+ |
*buf = pattern; |
319 |
+ |
} |
320 |
+ |
|
321 |
+ |
// Sets the alpha channel in a image to full on, except for the corners |
322 |
+ |
|
323 |
+ |
static void mask_buffer (void *buffer, size_t width, size_t size) |
324 |
+ |
{ |
325 |
+ |
long *bufl = (long *) buffer; |
326 |
+ |
char *bufc = (char *) buffer; |
327 |
+ |
|
328 |
+ |
|
329 |
+ |
memsetl(bufl, 0xFF000000, size); |
330 |
+ |
|
331 |
+ |
|
332 |
+ |
// Round upper-left corner |
333 |
+ |
*bufl = 0, *bufc+4 = 0; // XXXXX |
334 |
+ |
bufc += width, *bufc++ = 0, *bufc++ = 0, *bufc++ = 0; // XXX |
335 |
+ |
bufc += width, *bufc++ = 0, *bufc = 0; // XX |
336 |
+ |
bufc += width, *bufc = 0; // X |
337 |
+ |
bufc += width, *bufc = 0; // X |
338 |
+ |
|
339 |
+ |
|
340 |
+ |
NSLog(@"Masked buffer"); |
341 |
+ |
} |
342 |
+ |
#endif |
343 |
|
|
344 |
|
// monitor_desc subclass for Mac OS X displays |
345 |
|
|
415 |
|
set_mac_frame_base(MacFrameBaseMac); |
416 |
|
|
417 |
|
// Set variables used by UAE memory banking |
418 |
< |
MacFrameBaseHost = the_buffer; |
418 |
> |
MacFrameBaseHost = (uint8 *) the_buffer; |
419 |
|
MacFrameSize = mode.bytes_per_row * mode.y; |
420 |
|
InitFrameBufferMapping(); |
421 |
|
#else |
422 |
< |
set_mac_frame_base(Host2MacAddr(the_buffer)); |
422 |
> |
set_mac_frame_base((unsigned int)Host2MacAddr((uint8 *)the_buffer)); |
423 |
|
#endif |
424 |
|
D(bug("mac_frame_base = %08x\n", get_mac_frame_base())); |
425 |
|
} |
530 |
|
bits_from_depth(mode.depth), |
531 |
|
mode.bytes_per_row, |
532 |
|
colourSpace, |
533 |
+ |
#ifdef CG_USE_ALPHA |
534 |
+ |
kCGImageAlphaPremultipliedFirst, |
535 |
+ |
#else |
536 |
|
kCGImageAlphaNoneSkipFirst, |
537 |
+ |
#endif |
538 |
|
provider, |
539 |
< |
NULL, // colourMap |
540 |
< |
NO, // shouldInterpolate |
539 |
> |
NULL, // colourMap translation table |
540 |
> |
NO, // shouldInterpolate colours? |
541 |
|
kCGRenderingIntentDefault); |
542 |
|
if ( ! imageRef ) |
543 |
|
{ |
550 |
|
[output readyToDraw: imageRef |
551 |
|
imageWidth: mode.x |
552 |
|
imageHeight: mode.y]; |
553 |
+ |
|
554 |
+ |
#ifdef CG_USE_ALPHA |
555 |
+ |
mask_buffer(the_buffer, mode.x, the_buffer_size); |
556 |
+ |
#endif |
557 |
|
#else |
558 |
< |
unsigned char *offsetBuffer = the_buffer; |
558 |
> |
unsigned char *offsetBuffer = (unsigned char *) the_buffer; |
559 |
|
offsetBuffer += 1; // OS X NSBitmaps are RGBA, but Basilisk generates ARGB |
560 |
|
#endif |
561 |
|
|
661 |
|
ErrorSheet(@"Could not get base address of screen", the_win); |
662 |
|
return false; |
663 |
|
} |
664 |
< |
NSLog(@"Starting full screen mode, height = %d", |
665 |
< |
CGDisplayPixelsHigh(theDisplay)); |
664 |
> |
|
665 |
> |
D(NSLog(@"Starting full screen mode, height = %d", |
666 |
> |
CGDisplayPixelsHigh(theDisplay))); |
667 |
> |
|
668 |
|
[output startedFullScreen: theDisplay]; // For mouse event processing |
669 |
|
|
670 |
|
if ( mode.bytes_per_row != CGDisplayBytesPerRow(theDisplay) ) |