diff --git a/macosx/.DS_Store b/macosx/.DS_Store index a8ddca29..932db0ad 100644 Binary files a/macosx/.DS_Store and b/macosx/.DS_Store differ diff --git a/macosx/mac-appleevent.h b/macosx/mac-appleevent.h deleted file mode 100755 index d4e74962..00000000 --- a/macosx/mac-appleevent.h +++ /dev/null @@ -1,28 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#ifndef _mac_appleevent_h_ -#define _mac_appleevent_h_ - -void InitAppleEvents (void); -void DeinitAppleEvents (void); - -#endif diff --git a/macosx/mac-appleevent.mm b/macosx/mac-appleevent.mm deleted file mode 100755 index 89abbe0c..00000000 --- a/macosx/mac-appleevent.mm +++ /dev/null @@ -1,169 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#include "port.h" - -#include "mac-prefix.h" -#include "mac-os.h" -#include "mac-snes9x.h" -#include "mac-appleevent.h" - -static AEEventHandlerUPP oappUPP, rappUPP, pdocUPP, quitUPP, odocUPP; - -static OSErr AEoapp (const AppleEvent *, AppleEvent *, long); -static OSErr AErapp (const AppleEvent *, AppleEvent *, long); -static OSErr AEpdoc (const AppleEvent *, AppleEvent *, long); -static OSErr AEquit (const AppleEvent *, AppleEvent *, long); -static OSErr AEodoc (const AppleEvent *, AppleEvent *, long); - - -static OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) -{ - if (running) - return (noErr); - - if (startopendlog) - { - if (SNES9X_OpenCart(NULL)) - { - SNES9X_Go(); - //QuitApplicationEventLoop(); - } - else - AdjustMenus(); - } - - return (noErr); -} - -static OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) -{ - if (running) - return (noErr); - - if (!cartOpen) - { - if (startopendlog) - { - if (SNES9X_OpenCart(NULL)) - { - SNES9X_Go(); - //QuitApplicationEventLoop(); - } - else - AdjustMenus(); - } - } - else - { - SNES9X_Go(); - //QuitApplicationEventLoop(); - } - - return (noErr); -} - -static OSErr AEpdoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) -{ - return (errAEEventNotHandled); -} - -static OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) -{ - if (running) - return (noErr); - - SNES9X_Quit(); - //QuitApplicationEventLoop(); - - return (noErr); -} - -static OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) -{ -// OSErr err; -// FSRef ref; -// AEDescList docList; -// AEKeyword keywd; -// DescType rtype; -// Size acsize; -// long count; -// -// if (running) -// return (noErr); -// -// err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &docList); -// if (err) -// return (noErr); -// -// err = AECountItems(&docList, &count); -// if (err || (count != 1)) -// { -// err = AEDisposeDesc(&docList); -// return (noErr); -// } -// -// err = AEGetNthPtr(&docList, 1, typeFSRef, &keywd, &rtype, &ref, sizeof(FSRef), &acsize); -// if (err == noErr) -// { -// if (SNES9X_OpenCart(&ref)) -// { -// SNES9X_Go(); -// //QuitApplicationEventLoop(); -// } -// else -// AdjustMenus(); -// } -// -// err = AEDisposeDesc(&docList); -// -// return (noErr); - return 0; -} - -void InitAppleEvents (void) -{ -// OSErr err; -// -// oappUPP = NewAEEventHandlerUPP(AEoapp); -// err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, oappUPP, 0L, false); -// -// odocUPP = NewAEEventHandlerUPP(AEodoc); -// err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, odocUPP, 0L, false); -// -// pdocUPP = NewAEEventHandlerUPP(AEpdoc); -// err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, pdocUPP, 0L, false); -// -// quitUPP = NewAEEventHandlerUPP(AEquit); -// err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, quitUPP, 0L, false); -// -// rappUPP = NewAEEventHandlerUPP(AErapp); -// err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, rappUPP, 0L, false); -} - -void DeinitAppleEvents (void) -{ - DisposeAEEventHandlerUPP(oappUPP); - DisposeAEEventHandlerUPP(odocUPP); - DisposeAEEventHandlerUPP(pdocUPP); - DisposeAEEventHandlerUPP(quitUPP); - DisposeAEEventHandlerUPP(rappUPP); -} diff --git a/macosx/mac-coreimage.h b/macosx/mac-coreimage.h deleted file mode 100644 index 6614d2b4..00000000 --- a/macosx/mac-coreimage.h +++ /dev/null @@ -1,34 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#ifndef _mac_coreimage_h_ -#define _mac_coreimage_h_ - -void InitCoreImage (void); -void DeinitCoreImage (void); -void InitCoreImageFilter (void); -void DeinitCoreImageFilter (void); -void ConfigureCoreImageFilter (void); -void InitCoreImageContext (CGLContextObj, CGLPixelFormatObj); -void DeinitCoreImageContext (void); -void DrawWithCoreImageFilter (CGRect, CGImageRef); - -#endif diff --git a/macosx/mac-coreimage.mm b/macosx/mac-coreimage.mm deleted file mode 100644 index cd270f64..00000000 --- a/macosx/mac-coreimage.mm +++ /dev/null @@ -1,816 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#import "port.h" - -#import -#import -#import - -#import "mac-prefix.h" -#import "mac-dialog.h" -#import "mac-os.h" -#import "mac-coreimage.h" - -enum -{ - kCITypeNone = 0, - kCITypeBoolean = 1000, - kCITypeScalar, - kCITypeColor -}; - -#define mCoreImageFilter 501 -#define FIXEDRANGE 0x10000 -#define kCommandFilterMenuBase 0x41000000 -#define kCommandCheckBoxBase 0x49000000 -#define kCommandSliderBase 0x51000000 -#define kCommandColorButtonBase 0x59000000 -#define kCIFilterNamePrefKey CFSTR("CoreImageFilterName") - -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 -#define truncEnd 0 -#endif - -typedef struct { - char name[256]; - char displayName[256]; - int type; - union { - struct { - bool8 cur; - } b; - - struct { - float max, min, cur; - } s; - - struct { - float r, g, b, a; - } c; - } u; -} FilterParam; - -static NSMutableArray *ciFilterNameList = NULL; -static NSMutableArray *ciFilterLocalizedNameList = NULL; -static NSArray *ciFilterInputKeys = NULL; -static CIFilter *ciFilter = NULL; -static CIContext *ciContext = NULL; -static FilterParam *ciFilterParam = NULL; -static CFStringRef ciFilterName = NULL; -static HIViewRef ciFilterUIPane = NULL; -static MenuRef ciFilterMenu = NULL; -static CGColorSpaceRef cgColor = NULL; -static dispatch_semaphore_t cisem = NULL; -static bool8 ciFilterHasInputCenter = false; -static bool8 ciFilterHasInputImage = false; -static int ciFilterInputKeysCount = 0; - -static void LoadFilterPrefs (void); -static void SaveFilterPrefs (void); -static void FilterParamToFilter (void); -static void FilterToFilterParam (void); -static void BuildCoreImageFilterListAndMenu (void); -static void ReleaseCoreImageFilterListAndMenu (void); -static void ReplaceFilterUI (WindowRef); -static void FilterUIAddSubviews (WindowRef, HIViewRef); -static void FilterUISetValues (HIViewRef); -static bool8 IsCoreImageFilterSupported (CIFilter *); -static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef, EventRef, void *); - - -void InitCoreImage (void) -{ - @autoreleasepool - { - ciFilterName = (CFStringRef) CFPreferencesCopyAppValue(kCIFilterNamePrefKey, kCFPreferencesCurrentApplication); - if (!ciFilterName) - ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("CIGammaAdjust")); - - BuildCoreImageFilterListAndMenu(); - - cisem = dispatch_semaphore_create(0); - } -} - -void DeinitCoreImage (void) -{ - ReleaseCoreImageFilterListAndMenu(); - - CFPreferencesSetAppValue(kCIFilterNamePrefKey, ciFilterName, kCFPreferencesCurrentApplication); - - CFRelease(ciFilterName); -} - -void InitCoreImageFilter (void) -{ - @autoreleasepool - { - ciFilter = [CIFilter filterWithName: (__bridge NSString *) ciFilterName]; - [ciFilter setDefaults]; - - ciFilterInputKeys = [ciFilter inputKeys]; - ciFilterInputKeysCount = [ciFilterInputKeys count]; - - ciFilterParam = new FilterParam [ciFilterInputKeysCount]; - memset(ciFilterParam, 0, sizeof(FilterParam) * ciFilterInputKeysCount); - - ciFilterHasInputCenter = false; - ciFilterHasInputImage = false; - - LoadFilterPrefs(); - } -} - -void DeinitCoreImageFilter (void) -{ - @autoreleasepool - { - SaveFilterPrefs(); - - ciFilterHasInputCenter = false; - ciFilterHasInputImage = false; - - delete [] ciFilterParam; - - ciFilterInputKeys = nil; - ciFilterInputKeysCount = 0; - - ciFilter = nil; - } -} - -static void LoadFilterPrefs (void) -{ - CFDataRef data; - int n = sizeof(FilterParam) * ciFilterInputKeysCount; - - data = (CFDataRef) CFPreferencesCopyAppValue(ciFilterName, kCFPreferencesCurrentApplication); - if (data) - { - if (CFDataGetLength(data) == n) - { - CFDataGetBytes(data, CFRangeMake(0, n), (UInt8 *) ciFilterParam); - FilterParamToFilter(); - } - - CFRelease(data); - } - - FilterToFilterParam(); -} - -static void SaveFilterPrefs (void) -{ - CFDataRef data; - int n = sizeof(FilterParam) * ciFilterInputKeysCount; - - data = CFDataCreate(kCFAllocatorDefault, (UInt8 *) ciFilterParam, n); - if (data) - { - CFPreferencesSetAppValue(ciFilterName, data, kCFPreferencesCurrentApplication); - CFRelease(data); - } -} - -static void FilterParamToFilter (void) -{ - NSString *key; - NSNumber *num; - CIColor *color; - - for (int i = 0; i < ciFilterInputKeysCount; i++) - { - key = [NSString stringWithUTF8String: ciFilterParam[i].name]; - if (key) - { - switch (ciFilterParam[i].type) - { - case kCITypeBoolean: - num = [NSNumber numberWithBool: ciFilterParam[i].u.b.cur]; - [ciFilter setValue: num forKey: key]; - break; - - case kCITypeScalar: - num = [NSNumber numberWithFloat: ciFilterParam[i].u.s.cur]; - [ciFilter setValue: num forKey: key]; - break; - - case kCITypeColor: - color = [CIColor colorWithRed: ciFilterParam[i].u.c.r green: ciFilterParam[i].u.c.g - blue: ciFilterParam[i].u.c.b alpha: ciFilterParam[i].u.c.a]; - [ciFilter setValue: color forKey: key]; - break; - - default: - break; - } - } - } -} - -static void FilterToFilterParam (void) -{ - NSDictionary *attr; - NSString *key, *label, *className, *typeName; - NSNumber *num; - CIColor *color; - id param; - - attr = [ciFilter attributes]; - ciFilterHasInputCenter = false; - ciFilterHasInputImage = false; - - for (int i = 0; i < ciFilterInputKeysCount; i++) - { - key = [ciFilterInputKeys objectAtIndex: i]; - param = [attr objectForKey: key]; - - strncpy(ciFilterParam[i].name, [key UTF8String], sizeof(ciFilterParam[i].name)); - ciFilterParam[i].displayName[0] = 0; - - if ([param isKindOfClass: [NSDictionary class]]) - { - label = [(NSDictionary *) param objectForKey: kCIAttributeDisplayName]; - if (!label) - label = [NSString stringWithString: key]; - strncpy(ciFilterParam[i].displayName, [label UTF8String], sizeof(ciFilterParam[i].displayName)); - - className = [(NSDictionary *) param objectForKey: kCIAttributeClass]; - - if ([className isEqualToString: @"NSNumber"]) - { - typeName = [(NSDictionary *) param objectForKey: kCIAttributeType]; - - if ([typeName isEqualToString: kCIAttributeTypeBoolean]) - { - ciFilterParam[i].type = kCITypeBoolean; - - num = [ciFilter valueForKey: key]; - ciFilterParam[i].u.b.cur = [num boolValue]; - } - else - { - ciFilterParam[i].type = kCITypeScalar; - - num = [ciFilter valueForKey: key]; - ciFilterParam[i].u.s.cur = [num floatValue]; - - num = [(NSDictionary *) param objectForKey: kCIAttributeSliderMax]; - if (!num) - num = [(NSDictionary *) param objectForKey: kCIAttributeMax]; - ciFilterParam[i].u.s.max = [num floatValue]; - - num = [(NSDictionary *) param objectForKey: kCIAttributeSliderMin]; - if (!num) - num = [(NSDictionary *) param objectForKey: kCIAttributeMin]; - ciFilterParam[i].u.s.min = [num floatValue]; - } - } - else - if ([className isEqualToString: @"CIColor"]) - { - ciFilterParam[i].type = kCITypeColor; - - color = [ciFilter valueForKey: key]; - ciFilterParam[i].u.c.r = [color red]; - ciFilterParam[i].u.c.g = [color green]; - ciFilterParam[i].u.c.b = [color blue]; - ciFilterParam[i].u.c.a = [color alpha]; - } - else - { - ciFilterParam[i].type = kCITypeNone; - - if ([className isEqualToString: @"CIVector"] && [key isEqualToString: @"inputCenter"]) - ciFilterHasInputCenter = true; - - if ([className isEqualToString: @"CIImage" ] && [key isEqualToString: @"inputImage" ]) - ciFilterHasInputImage = true; - } - } - } -} - -static void BuildCoreImageFilterListAndMenu (void) -{ -// NSArray *categories, *filterNames; -// OSStatus err; -// -// categories = [NSArray arrayWithObject: kCICategoryStillImage]; -// filterNames = [CIFilter filterNamesInCategories: categories]; -// -// ciFilterNameList = [[NSMutableArray alloc] initWithCapacity: 1]; -// ciFilterLocalizedNameList = [[NSMutableArray alloc] initWithCapacity: 1]; -// err = CreateNewMenu(mCoreImageFilter, 0, &ciFilterMenu); -// -// int n = [filterNames count], m = 0; -// for (int i = 0; i < n; i++) -// { -// CIFilter *filter; -// NSString *name, *localName; -// -// name = [filterNames objectAtIndex: i]; -// filter = [CIFilter filterWithName: name]; -// -// if (IsCoreImageFilterSupported(filter)) -// { -// [ciFilterNameList addObject: name]; -// -// localName = [CIFilter localizedNameForFilterName: name]; -// if (!localName) -// localName = [NSString stringWithString: name]; -// -// [ciFilterLocalizedNameList addObject: localName]; -// -// err = AppendMenuItemTextWithCFString(ciFilterMenu, (CFStringRef) localName, 0, kCommandFilterMenuBase + m, NULL); -// m++; -// } -// } -} - -static void ReleaseCoreImageFilterListAndMenu (void) -{ - CFRelease(ciFilterMenu); - ciFilterLocalizedNameList = nil; - ciFilterNameList = nil; -} - -static bool8 IsCoreImageFilterSupported (CIFilter *filter) -{ - NSDictionary *attr; - NSArray *inputKeys; - NSString *key, *className; - id param; - bool8 result = true, hasInputImage = false; - - attr = [filter attributes]; - inputKeys = [filter inputKeys]; - - int n = [inputKeys count]; - for (int i = 0; i < n; i++) - { - key = [inputKeys objectAtIndex: i]; - param = [attr objectForKey: key]; - - if ([param isKindOfClass: [NSDictionary class]]) - { - className = [(NSDictionary *) param objectForKey: kCIAttributeClass]; - - if ([className isEqualToString: @"CIImage"]) - { - if (![key isEqualToString: @"inputImage"]) - result = false; - else - hasInputImage = true; - } - else - if ([className isEqualToString: @"CIVector"]) - { - if (![key isEqualToString: @"inputCenter"]) - result = false; - } - else - if (![className isEqualToString: @"NSNumber"] && ![className isEqualToString: @"CIColor"]) - result = false; - } - } - - if (hasInputImage == false) - result = false; - - return (result); -} - -void ConfigureCoreImageFilter (void) -{ -// NSAutoreleasePool *pool; -// OSStatus err; -// IBNibRef nibRef; -// -// pool = [[NSAutoreleasePool alloc] init]; -// -// err = CreateNibReference(kMacS9XCFString, &nibRef); -// if (err == noErr) -// { -// WindowRef window; -// -// err = CreateWindowFromNib(nibRef, CFSTR("CIFilter"), &window); -// if (err == noErr) -// { -// EventHandlerRef eref; -// EventHandlerUPP eUPP; -// EventTypeSpec event[] = { { kEventClassWindow, kEventWindowClose }, -// { kEventClassCommand, kEventCommandProcess }, -// { kEventClassCommand, kEventCommandUpdateStatus } }; -// HIViewRef ctl, root; -// HIViewID cid; -// Rect rct; -// int value; -// -// ciFilterUIPane = NULL; -// -// FilterToFilterParam(); -// -// root = HIViewGetRoot(window); -// -// SetHIViewID(&cid, 'FILT', 0); -// rct.left = 74; -// rct.top = 20; -// rct.right = 74 + 279; -// rct.bottom = 20 + 20; -// err = CreatePopupButtonControl(window, &rct, NULL, -12345, false, 0, 0, 0, &ctl); -// HIViewSetID(ctl, cid); -// int n = CountMenuItems(ciFilterMenu); -// SetControlPopupMenuHandle(ctl, ciFilterMenu); -// HIViewSetMaximum(ctl, n); -// value = [ciFilterNameList indexOfObject: (NSString *) ciFilterName]; -// HIViewSetValue(ctl, value + 1); -// -// ReplaceFilterUI(window); -// -// eUPP = NewEventHandlerUPP(CoreImageFilterEventHandler); -// err = InstallWindowEventHandler(window, eUPP, GetEventTypeCount(event), event, (void *) window, &eref); -// -// MoveWindowPosition(window, kWindowCoreImageFilter, false); -// ShowWindow(window); -// err = RunAppModalLoopForWindow(window); -// HideWindow(window); -// SaveWindowPosition(window, kWindowCoreImageFilter); -// -// err = RemoveEventHandler(eref); -// DisposeEventHandlerUPP(eUPP); -// -// FilterParamToFilter(); -// -// CFRelease(window); -// } -// -// DisposeNibReference(nibRef); -// } -// -// [pool release]; -} - -static void ReplaceFilterUI (WindowRef window) -{ -// OSStatus err; -// HIRect frame; -// Rect bounds, rct; -// -// if (ciFilterUIPane) -// { -// HIViewSetVisible(ciFilterUIPane, false); -// DisposeControl(ciFilterUIPane); -// ciFilterUIPane = NULL; -// } -// -// GetWindowBounds(window, kWindowStructureRgn, &bounds); -// -// rct.left = 15; -// rct.right = bounds.right - bounds.left - 15; -// rct.top = 81; -// rct.bottom = rct.top + 40; -// err = CreateUserPaneControl(window, &rct, kControlSupportsEmbedding, &ciFilterUIPane); -// HIViewSetVisible(ciFilterUIPane, false); -// FilterUIAddSubviews(window, ciFilterUIPane); -// -// HIViewGetFrame(ciFilterUIPane, &frame); -// bounds.bottom = bounds.top + (short) (frame.origin.y + frame.size.height + 30); -// -// err = TransitionWindow(window, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &bounds); -// HIViewSetVisible(ciFilterUIPane, true); -} - -static void FilterUIAddSubviews (WindowRef window, HIViewRef parent) -{ -// OSStatus err; -// CFMutableStringRef label; -// CFStringRef str; -// HIViewRef ctl; -// HIViewID cid; -// HIRect bounds, frame; -// Rect rct; -// SInt32 value; -// -// HIViewGetFrame(parent, &bounds); -// rct.left = 0; -// rct.top = 0; -// rct.right = 200; -// rct.bottom = 20; -// -// int m = 0; -// for (int i = 0; i < ciFilterInputKeysCount; i++) -// { -// str = CFStringCreateWithCString(kCFAllocatorDefault, ciFilterParam[i].displayName, kCFStringEncodingUTF8); -// if (!str) -// str = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("Parameter")); -// label = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, str); -// CFRelease(str); -// -// switch (ciFilterParam[i].type) -// { -// case kCITypeBoolean: -// { -// err = CreateCheckBoxControl(window, &rct, label, ciFilterParam[i].u.b.cur, true, &ctl); -// SetHIViewID(&cid, kCommandCheckBoxBase + i, i); -// HIViewSetID(ctl, cid); -// HIViewSetCommandID(ctl, cid.signature); -// err = HIViewAddSubview(parent, ctl); -// frame.origin.x = 5.0f; -// frame.origin.y = (float) (m * 28); -// frame.size.width = bounds.size.width - 10.0f; -// frame.size.height = 20.0f; -// err = HIViewSetFrame(ctl, &frame); -// m++; -// -// break; -// } -// -// case kCITypeScalar: -// { -// CFStringAppend(label, CFSTR(" :")); -// err = CreateStaticTextControl(window, &rct, label, NULL, &ctl); -// SetStaticTextTrunc(ctl, truncEnd, true); -// err = HIViewAddSubview(parent, ctl); -// frame.origin.x = 5.0f; -// frame.origin.y = (float) (m * 28); -// frame.size.width = 120.0f; -// frame.size.height = 20.0f; -// err = HIViewSetFrame(ctl, &frame); -// -// value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE); -// err = CreateSliderControl(window, &rct, value, 0, FIXEDRANGE, kControlSliderDoesNotPoint, 0, false, NULL, &ctl); -// SetHIViewID(&cid, kCommandSliderBase + i, i); -// HIViewSetID(ctl, cid); -// HIViewSetCommandID(ctl, cid.signature); -// err = HIViewAddSubview(parent, ctl); -// frame.origin.x = 135.0f; -// frame.origin.y = (float) (m * 28) - 1.0f; -// frame.size.width = bounds.size.width - 140.0f; -// frame.size.height = 20.0f; -// err = HIViewSetFrame(ctl, &frame); -// m++; -// -// break; -// } -// -// case kCITypeColor: -// { -// CFStringAppend(label, CFSTR("...")); -// err = CreatePushButtonControl(window, &rct, label, &ctl); -// SetHIViewID(&cid, kCommandColorButtonBase + i, i); -// HIViewSetID(ctl, cid); -// HIViewSetCommandID(ctl, cid.signature); -// err = HIViewAddSubview(parent, ctl); -// frame.origin.x = bounds.size.width - 180.0f; -// frame.origin.y = (float) (m * 28); -// frame.size.width = 175.0f; -// frame.size.height = 20.0f; -// err = HIViewSetFrame(ctl, &frame); -// m++; -// -// break; -// } -// -// default: -// break; -// } -// -// CFRelease(label); -// } -// -// if (m) -// { -// str = CFCopyLocalizedString(CFSTR("ResetCIFilter"), "Reset"); -// err = CreatePushButtonControl(window, &rct, str, &ctl); -// SetHIViewID(&cid, 'rSET', 0); -// HIViewSetID(ctl, cid); -// HIViewSetCommandID(ctl, cid.signature); -// err = HIViewAddSubview(parent, ctl); -// frame.origin.x = bounds.size.width - 180.0f; -// frame.origin.y = (float) (m * 28 + 12); -// frame.size.width = 175.0f; -// frame.size.height = 20.0f; -// err = HIViewSetFrame(ctl, &frame); -// CFRelease(str); -// bounds.size.height = frame.origin.y + 32.0f; -// } -// else -// bounds.size.height = 4.0f; -// -// err = HIViewSetFrame(parent, &bounds); -} - -static void FilterUISetValues (HIViewRef parent) -{ -// HIViewRef ctl; -// HIViewID cid; -// SInt32 value; -// -// for (int i = 0; i < ciFilterInputKeysCount; i++) -// { -// switch (ciFilterParam[i].type) -// { -// case kCITypeBoolean: -// SetHIViewID(&cid, kCommandCheckBoxBase + i, i); -// HIViewFindByID(parent, cid, &ctl); -// HIViewSetValue(ctl, ciFilterParam[i].u.b.cur); -// break; -// -// case kCITypeScalar: -// value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE); -// SetHIViewID(&cid, kCommandSliderBase + i, i); -// HIViewFindByID(parent, cid, &ctl); -// HIViewSetValue(ctl, value); -// break; -// -// default: -// break; -// } -// } -} - -static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) -{ -// OSStatus err, result = eventNotHandledErr; -// WindowRef window = (WindowRef) inUserData; -// -// switch (GetEventClass(inEvent)) -// { -// case kEventClassWindow: -// switch (GetEventKind(inEvent)) -// { -// case kEventWindowClose: -// QuitAppModalLoopForWindow(window); -// result = noErr; -// } -// -// break; -// -// case kEventClassCommand: -// switch (GetEventKind(inEvent)) -// { -// HICommandExtended tHICommand; -// -// case kEventCommandUpdateStatus: -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand); -// if (err == noErr && tHICommand.commandID == 'clos') -// { -// UpdateMenuCommandStatus(true); -// result = noErr; -// } -// -// break; -// -// case kEventCommandProcess: -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand); -// if (err == noErr) -// { -// err = MPWaitOnSemaphore(cisem, kDurationForever); -// -// if (tHICommand.commandID == 'rSET') -// { -// [ciFilter setDefaults]; -// FilterToFilterParam(); -// FilterUISetValues(ciFilterUIPane); -// -// result = noErr; -// } -// else -// { -// unsigned long i = tHICommand.commandID & 0x00FFFFFF; -// -// switch (tHICommand.commandID & 0xFF000000) -// { -// case kCommandFilterMenuBase: -// DeinitCoreImageFilter(); -// -// CFRelease(ciFilterName); -// ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef) [ciFilterNameList objectAtIndex: i]); -// -// InitCoreImageFilter(); -// -// ReplaceFilterUI(window); -// -// break; -// -// case kCommandCheckBoxBase: -// ciFilterParam[i].u.b.cur = !(ciFilterParam[i].u.b.cur); -// FilterParamToFilter(); -// result = noErr; -// -// break; -// -// case kCommandSliderBase: -// SInt32 value; -// -// value = HIViewGetValue(tHICommand.source.control); -// ciFilterParam[i].u.s.cur = ciFilterParam[i].u.s.min + (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) value / (float) FIXEDRANGE; -// FilterParamToFilter(); -// result = noErr; -// -// break; -// -// case kCommandColorButtonBase: -// NColorPickerInfo info; -// -// memset(&info, 0, sizeof(NColorPickerInfo)); -// info.placeWhere = kCenterOnMainScreen; -// info.flags = kColorPickerDialogIsMoveable | kColorPickerDialogIsModal; -// info.theColor.color.rgb.red = (int) (65535.0 * ciFilterParam[i].u.c.r); -// info.theColor.color.rgb.green = (int) (65535.0 * ciFilterParam[i].u.c.g); -// info.theColor.color.rgb.blue = (int) (65535.0 * ciFilterParam[i].u.c.b); -// -// err = NPickColor(&info); -// -// if ((err == noErr) && info.newColorChosen) -// { -// ciFilterParam[i].u.c.r = (float) info.theColor.color.rgb.red / 65535.0f; -// ciFilterParam[i].u.c.g = (float) info.theColor.color.rgb.green / 65535.0f; -// ciFilterParam[i].u.c.b = (float) info.theColor.color.rgb.blue / 65535.0f; -// } -// -// FilterParamToFilter(); -// result = noErr; -// -// break; -// } -// } -// -// err = MPSignalSemaphore(cisem); -// } -// } -// } -// -// return (result); - return 0; -} - -void InitCoreImageContext (CGLContextObj cglctx, CGLPixelFormatObj cglpix) -{ - @autoreleasepool - { - FilterToFilterParam(); - - cgColor = CGColorSpaceCreateDeviceRGB(); - - #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT - ciContext = [[CIContext contextWithCGLContext: cglctx pixelFormat: cglpix options: NULL] retain]; - #else - ciContext = [CIContext contextWithCGLContext: cglctx pixelFormat: cglpix colorSpace: cgColor options: NULL]; - #endif - } -} - -void DeinitCoreImageContext (void) -{ - ciContext = nil; - CGColorSpaceRelease(cgColor); -} - -void DrawWithCoreImageFilter (CGRect src, CGImageRef img) -{ - @autoreleasepool - { - dispatch_semaphore_wait(cisem, DISPATCH_TIME_FOREVER); - - if (ciFilterHasInputImage) - { - CIImage *image; - - image = [CIImage imageWithCGImage: img]; - [ciFilter setValue: image forKey: @"inputImage" ]; - } - - if (ciFilterHasInputCenter) - { - CIVector *vector; - - vector = [CIVector vectorWithX: (src.origin.x + src.size.width / 2) Y: (src.origin.y + src.size.height / 2)]; - [ciFilter setValue: vector forKey: @"inputCenter"]; - } - - [ciContext drawImage: [ciFilter valueForKey: @"outputImage"] atPoint: CGPointZero fromRect: src]; - - dispatch_semaphore_signal(cisem); - } -} diff --git a/macosx/mac-os.h b/macosx/mac-os.h index cc1a89cb..76687519 100644 --- a/macosx/mac-os.h +++ b/macosx/mac-os.h @@ -23,39 +23,12 @@ #define _mac_os_h_ #import +#import #import #import "mac-controls.h" -enum -{ - kDrawingReserved1 = 1, // unused - kDrawingOpenGL, - kDrawingBlitGL -}; - -enum -{ - kWindowControllers = 0, - kWindowPreferences, - kWindowAbout, - kWindowAutoFire, - kWindowRomInfo, - kWindowCheatFinder, - kWindowKeyConfig, - kWindowCheatEntry, - kWindowScreen, - kWindowServer, - kWindowClient, - kWindowExtra, - kWindowSoundEffect, - kWindowCoreImageFilter, - kWindowMultiCart, - - kWindowCount -}; - enum { SNES_MULTIPLAYER5, @@ -102,39 +75,24 @@ typedef struct SInt32 frequency; } AutoFireState; -typedef struct -{ - bool8 benchmark; - bool8 glForceNoTextureRectangle; - bool8 glUseClientStrageApple; - bool8 glUseTexturePriority; - int glStorageHint; -} ExtraOption; - #define kMacWindowHeight (SNES_HEIGHT_EXTENDED) #define MAC_MAX_CHEATS 150 extern volatile bool8 running, s9xthreadrunning; extern volatile bool8 eventQueued, windowExtend; -extern volatile int windowResizeCount; extern uint32 controlPad[MAC_MAX_PLAYERS]; extern uint8 romDetect, interleaveDetect, videoDetect, headerDetect; extern WindowRef gWindow; extern uint32 glScreenW, glScreenH; extern CGRect glScreenBounds; -extern Point windowPos[kWindowCount]; -extern CGSize windowSize[kWindowCount]; extern CGImageRef macIconImage[118]; extern int macPadIconIndex, macLegendIconIndex, macMusicBoxIconIndex, macFunctionIconIndex; extern int macFrameSkip; extern int32 skipFrames; extern int64 lastFrame; extern unsigned long spcFileCount, pngFileCount; -extern bool8 finished, cartOpen, - autofire, hidExist, directDisplay; -extern bool8 fullscreen, autoRes, - glstretch, gl32bit, vsync, drawoverscan, lastoverscan, screencurvature, - ciFilterEnable; +extern bool8 finished, cartOpen, autofire; +extern bool8 fullscreen, autoRes, glstretch, gl32bit, vsync, drawoverscan, lastoverscan; extern long drawingMethod; extern int videoMode; extern SInt32 macSoundVolume; @@ -156,7 +114,6 @@ extern int macControllerOption; extern CGPoint unlimitedCursor; extern char npServerIP[256], npName[256]; extern AutoFireState autofireRec[MAC_MAX_PLAYERS]; -extern ExtraOption extraOptions; extern CFStringRef multiCartPath[2]; #ifdef MAC_PANTHER_SUPPORT @@ -167,7 +124,7 @@ extern bool8 pressedKeys[MAC_MAX_PLAYERS][kNumButtons]; extern bool8 pressedGamepadButtons[MAC_MAX_PLAYERS][kNumButtons]; extern pthread_mutex_t keyLock; -extern NSOpenGLView *s9xView; +extern MTKView *s9xView; void AdjustMenus (void); void UpdateMenuCommandStatus (Boolean); diff --git a/macosx/mac-os.mm b/macosx/mac-os.mm index 32d198a9..c202d156 100644 --- a/macosx/mac-os.mm +++ b/macosx/mac-os.mm @@ -45,13 +45,11 @@ #import #import "mac-prefix.h" -#import "mac-appleevent.h" #import "mac-audio.h" #import "mac-cheat.h" #import "mac-cheatfinder.h" #import "mac-cocoatools.h" #import "mac-controls.h" -#import "mac-coreimage.h" #import "mac-dialog.h" #import "mac-file.h" #import "mac-gworld.h" @@ -60,7 +58,6 @@ #import "mac-multicart.h" #import "mac-musicbox.h" #import "mac-netplay.h" -#import "mac-prefs.h" #import "mac-render.h" #import "mac-screenshot.h" #import "mac-snes9x.h" @@ -72,7 +69,6 @@ volatile bool8 running = false; volatile bool8 s9xthreadrunning = false; -volatile int windowResizeCount = 1; volatile bool8 windowExtend = true; uint32 controlPad[MAC_MAX_PLAYERS]; @@ -86,8 +82,6 @@ WindowRef gWindow = NULL; uint32 glScreenW, glScreenH; CGRect glScreenBounds; -Point windowPos[kWindowCount]; -CGSize windowSize[kWindowCount]; CGImageRef macIconImage[118]; int macPadIconIndex, @@ -110,19 +104,14 @@ unsigned long spcFileCount = 0, bool8 finished = false, cartOpen = false, - autofire = false, - hidExist = true, - directDisplay = false; + autofire = false; bool8 fullscreen = false, autoRes = false, glstretch = true, gl32bit = true, vsync = true, - drawoverscan = false, - screencurvature = false, - ciFilterEnable = false; -long drawingMethod = kDrawingOpenGL; + drawoverscan = false; int videoMode = VIDEOMODE_BLOCKY; SInt32 macSoundVolume = 80; // % @@ -166,8 +155,6 @@ bool8 lastoverscan = false; CGPoint unlimitedCursor; -ExtraOption extraOptions; - CFStringRef multiCartPath[2]; #ifdef MAC_PANTHER_SUPPORT @@ -234,7 +221,7 @@ bool8 heldFunctionButtons[kNumFunctionButtons] = { 0 }; pthread_mutex_t keyLock; pthread_mutex_t renderLock; -NSOpenGLView *s9xView; +MTKView *s9xView; enum { @@ -1116,16 +1103,6 @@ static inline void EmulationLoop (void) // menu = GetMenuRef(mControl); // EnableMenuItem(menu, iKeyboardLayout); // EnableMenuItem(menu, iAutoFire); -// if (hidExist) -// { -// EnableMenuItem(menu, iISpLayout); -// EnableMenuItem(menu, iISpPreset); -// } -// else -// { -// DisableMenuItem(menu, iISpLayout); -// DisableMenuItem(menu, iISpPreset); -// } // // menu = GetMenuRef(mEmulation); // str = CFCopyLocalizedString(CFSTR("RunMenu"), "run"); @@ -1736,12 +1713,6 @@ int PromptFreezeDefrost (Boolean freezing) const int w = SNES_WIDTH << 1, h = SNES_HEIGHT << 1; const char letters[] = "123456789ABC", *filename; - if (!directDisplay) - { - S9xInitDisplay(NULL, NULL); - SNES9X_Go(); - } - frzselecting = true; oldInactiveMode = inactiveMode; if (inactiveMode == 3) @@ -2068,7 +2039,6 @@ int PromptFreezeDefrost (Boolean freezing) usleep(30000); - windowResizeCount = 2; UpdateFreezeDefrostScreen(current_selection, image, draw, ctx); } while (result == -2); @@ -2085,8 +2055,6 @@ int PromptFreezeDefrost (Boolean freezing) inactiveMode = oldInactiveMode; frzselecting = false; - windowResizeCount = 2; - return (result); } @@ -2291,9 +2259,6 @@ static void ProcessInput (void) CopyPressedKeys(keys, gamepadButtons); isok = SNES9X_Freeze(); - pthread_mutex_lock(&renderLock); - ClearGFXScreen(); - pthread_mutex_unlock(&renderLock); return; } @@ -2304,9 +2269,6 @@ static void ProcessInput (void) CopyPressedKeys(keys, gamepadButtons); isok = SNES9X_Defrost(); - pthread_mutex_lock(&renderLock); - ClearGFXScreen(); - pthread_mutex_unlock(&renderLock); return; } @@ -2614,20 +2576,6 @@ static void Initialize (void) machTimeNumerator = info.numer; machTimeDenominator = info.denom * 1000; - for (int a = 0; a < kWindowCount; a++) - { - windowPos[a].h = 40; - windowPos[a].v = 80; - windowSize[a].width = -1.0f; - windowSize[a].height = -1.0f; - } - - extraOptions.benchmark = false; - extraOptions.glForceNoTextureRectangle = false; - extraOptions.glUseClientStrageApple = true; - extraOptions.glUseTexturePriority = false; - extraOptions.glStorageHint = 2; - npServerIP[0] = 0; npName[0] = 0; @@ -2635,13 +2583,10 @@ static void Initialize (void) CreateIconImages(); - InitAppleEvents(); InitKeyboard(); InitAutofire(); InitCheatFinder(); - LoadPrefs(); - InitGraphics(); InitMacSound(); SetUpHID(); @@ -2668,26 +2613,18 @@ static void Initialize (void) S9xSetControllerCrosshair(X_MOUSE1, 0, NULL, NULL); S9xSetControllerCrosshair(X_MOUSE2, 0, NULL, NULL); - - InitCoreImage(); - InitCoreImageFilter(); } static void Deinitialize (void) { - DeinitCoreImageFilter(); - DeinitCoreImage(); - deviceSetting = deviceSettingMaster; DeinitMultiCart(); - SavePrefs(); ReleaseHID(); DeinitCheatFinder(); DeinitGraphics(); DeinitKeyboard(); DeinitMacSound(); - DeinitAppleEvents(); ReleaseIconImages(); S9xGraphicsDeinit(); @@ -2725,95 +2662,85 @@ void S9xSyncSpeed (void) { long long currentFrame, adjustment; - if (directDisplay) + if (Settings.SoundSync) { - if (extraOptions.benchmark) - IPPU.RenderThisFrame = true; - else + while (!S9xSyncSound()) + usleep(0); + } + + if (!macQTRecord) + { + if (macFrameSkip < 0) // auto skip { - if (Settings.SoundSync) + skipFrames--; + + if (skipFrames <= 0) { - while (!S9xSyncSound()) - usleep(0); - } - - if (!macQTRecord) - { - if (macFrameSkip < 0) // auto skip - { - skipFrames--; - - if (skipFrames <= 0) - { - adjustment = (Settings.TurboMode ? (macFrameAdvanceRate / macFastForwardRate) : macFrameAdvanceRate) / Memory.ROMFramesPerSecond; - currentFrame = GetMicroseconds(); - - skipFrames = (int32) ((currentFrame - lastFrame) / adjustment); - lastFrame += frameCount * adjustment; - - if (skipFrames < 1) - skipFrames = 1; - else - if (skipFrames > 7) - { - skipFrames = 7; - lastFrame = GetMicroseconds(); - } - - frameCount = skipFrames; - - if (lastFrame > currentFrame) - usleep((useconds_t) (lastFrame - currentFrame)); - - IPPU.RenderThisFrame = true; - } - else - IPPU.RenderThisFrame = false; - } - else // constant - { - skipFrames--; - - if (skipFrames <= 0) - { - adjustment = macFrameAdvanceRate * macFrameSkip / Memory.ROMFramesPerSecond; - currentFrame = GetMicroseconds(); - - if (currentFrame - lastFrame < adjustment) - { - usleep((useconds_t) (adjustment + lastFrame - currentFrame)); - currentFrame = GetMicroseconds(); - } - - lastFrame = currentFrame; - skipFrames = macFrameSkip; - if (Settings.TurboMode) - skipFrames *= macFastForwardRate; - - IPPU.RenderThisFrame = true; - } - else - IPPU.RenderThisFrame = false; - } - } - else - { - //MacQTRecordFrame(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight); - - adjustment = macFrameAdvanceRate / Memory.ROMFramesPerSecond; + adjustment = (Settings.TurboMode ? (macFrameAdvanceRate / macFastForwardRate) : macFrameAdvanceRate) / Memory.ROMFramesPerSecond; currentFrame = GetMicroseconds(); - if (currentFrame - lastFrame < adjustment) - usleep((useconds_t) (adjustment + lastFrame - currentFrame)); + skipFrames = (int32) ((currentFrame - lastFrame) / adjustment); + lastFrame += frameCount * adjustment; - lastFrame = currentFrame; + if (skipFrames < 1) + skipFrames = 1; + else + if (skipFrames > 7) + { + skipFrames = 7; + lastFrame = GetMicroseconds(); + } + + frameCount = skipFrames; + + if (lastFrame > currentFrame) + usleep((useconds_t) (lastFrame - currentFrame)); IPPU.RenderThisFrame = true; } + else + IPPU.RenderThisFrame = false; + } + else // constant + { + skipFrames--; + + if (skipFrames <= 0) + { + adjustment = macFrameAdvanceRate * macFrameSkip / Memory.ROMFramesPerSecond; + currentFrame = GetMicroseconds(); + + if (currentFrame - lastFrame < adjustment) + { + usleep((useconds_t) (adjustment + lastFrame - currentFrame)); + currentFrame = GetMicroseconds(); + } + + lastFrame = currentFrame; + skipFrames = macFrameSkip; + if (Settings.TurboMode) + skipFrames *= macFastForwardRate; + + IPPU.RenderThisFrame = true; + } + else + IPPU.RenderThisFrame = false; } } else - IPPU.RenderThisFrame = false; + { + //MacQTRecordFrame(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight); + + adjustment = macFrameAdvanceRate / Memory.ROMFramesPerSecond; + currentFrame = GetMicroseconds(); + + if (currentFrame - lastFrame < adjustment) + usleep((useconds_t) (adjustment + lastFrame - currentFrame)); + + lastFrame = currentFrame; + + IPPU.RenderThisFrame = true; + } } void S9xAutoSaveSRAM (void) @@ -2873,7 +2800,7 @@ void QuitWithFatalError ( NSString *message) [NSApp terminate:nil]; } -@interface S9xView : NSOpenGLView +@interface S9xView : MTKView @end @implementation S9xView @@ -2884,9 +2811,9 @@ void QuitWithFatalError ( NSString *message) renderLock = PTHREAD_MUTEX_INITIALIZER; } -- (instancetype)initWithFrame:(NSRect)frameRect pixelFormat:(nullable NSOpenGLPixelFormat *)format +- (instancetype)initWithFrame:(NSRect)frameRect { - self = [super initWithFrame:frameRect pixelFormat:format]; + self = [super initWithFrame:frameRect]; if (self) { @@ -3025,7 +2952,6 @@ void QuitWithFatalError ( NSString *message) { if ( !NSEqualRects(frame, self.frame) ) { - windowResizeCount = 2; [super setFrame:frame]; } } @@ -3056,12 +2982,13 @@ void QuitWithFatalError ( NSString *message) Initialize(); CGRect frame = NSMakeRect(0, 0, SNES_WIDTH * 2, SNES_HEIGHT * 2); - s9xView = [[S9xView alloc] initWithFrame:frame pixelFormat:nil]; + s9xView = [[S9xView alloc] initWithFrame:frame]; s9xView.translatesAutoresizingMaskIntoConstraints = NO; s9xView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable; [s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:s9xView attribute:NSLayoutAttributeWidth multiplier:(CGFloat)SNES_HEIGHT/(CGFloat)SNES_WIDTH constant:0.0]]; [s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_WIDTH * 2.0]]; [s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_HEIGHT * 2.0]]; + s9xView.device = MTLCreateSystemDefaultDevice(); } return self; @@ -3089,9 +3016,6 @@ void QuitWithFatalError ( NSString *message) skipFrames = macFrameSkip; S9xInitDisplay(NULL, NULL); - pthread_mutex_lock(&renderLock); - ClearGFXScreen(); - pthread_mutex_unlock(&renderLock); [NSThread detachNewThreadWithBlock:^ { diff --git a/macosx/mac-prefs.h b/macosx/mac-prefs.h deleted file mode 100755 index 0a6cd2fd..00000000 --- a/macosx/mac-prefs.h +++ /dev/null @@ -1,30 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#ifndef _mac_prefs_h_ -#define _mac_prefs_h_ - -void LoadPrefs (void); -void SavePrefs (void); -void ConfigurePreferences (void); -void ConfigureExtraOptions (void); - -#endif diff --git a/macosx/mac-prefs.mm b/macosx/mac-prefs.mm deleted file mode 100755 index a72aa4a4..00000000 --- a/macosx/mac-prefs.mm +++ /dev/null @@ -1,1594 +0,0 @@ -/*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. - For further information, consult the LICENSE file in the root directory. -\*****************************************************************************/ - -/*********************************************************************************** - SNES9X for Mac OS (c) Copyright John Stiles - - Snes9x for Mac OS X - - (c) Copyright 2001 - 2011 zones - (c) Copyright 2002 - 2005 107 - (c) Copyright 2002 PB1400c - (c) Copyright 2004 Alexander and Sander - (c) Copyright 2004 - 2005 Steven Seeger - (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley - ***********************************************************************************/ - - -#include "snes9x.h" -#include "memmap.h" -#include "blit.h" - -#include -#define __STDC_FORMAT_MACROS -#include - -#include "mac-prefix.h" -#include "mac-audio.h" -#include "mac-cart.h" -#include "mac-coreimage.h" -#include "mac-dialog.h" -#include "mac-file.h" -#include "mac-keyboard.h" -#include "mac-os.h" -#include "mac-render.h" -#include "mac-snes9x.h" -#include "mac-stringtools.h" -#include "mac-prefs.h" - -enum -{ - iNibGFullScreen = 1, - iNibGSwitchResolution, - iNibGShowFrameRate, - iNibGCIFilterEnable, - iNibGTransparency, - iNibGGL32bit, - iNibGGLStretch, - iNibGCoreImageFilter, - iNibGVideoMode, - iNibGDirectMP, - iNibGGLVSync, - iNibGDrawOverscan, - iNibGScreenCurvature, - iNibGCurvatureWarp, - iNibGAspectRatio, - iNibGAspectRatioText, - - iNibSSynchronize = 201, - iNibS16BitPlayback, - iNibSStereo, - iNibSReverseStereo, - iNibSPlaybackRate, - iNibSBufferSize, - iNibSVolume, - iNibSInputRate, - iNibSInputRateText, - iNibSAllowLag, - iNibSInterval, - - iNibOSaveFolder = 401, - iNibOAutoSaveInterval, - - iNibMCPUCycles = 601, - iNibMReserved1, - iNibMTurboSkipArrows, - iNibMTurboSkipText, - iNibMFrameSkip, - iNibMAllowInvalidVRAMAccess, - iNibMAllowSpecificGameHacks, - - iNibXStartOpenDialog = 801, - iNibXShowTimeInFrz, - iNibXMusicBoxMode, - iNibXEnableToggle, - iNibXBSXBootup, - iNibXSaveWindowPos, - iNibXUseIPSPatch, - iNibXOnScreenInfo, - iNibXInactiveMode -}; - -enum -{ - iOpenGLBlocky = 1, - iOpenGLTVMode, - iOpenGLSmoothMode, - iOpenGLBlendMode, - iOpenGLEagleMode, - iOpenGL2xSAIMode, - iOpenGLSuper2xSAIMode, - iOpenGLEPXMode, - iOpenGLHQ2xMode, - iOpenGLHQ3xMode, - iOpenGLHQ4xMode, - iOpenGLNTSC_CMode, - iOpenGLNTSC_SMode, - iOpenGLNTSC_RMode, - iOpenGLNTSC_MMode, - iOpenGLNTSC_TV_CMode, - iOpenGLNTSC_TV_SMode, - iOpenGLNTSC_TV_RMode, - iOpenGLNTSC_TV_MMode -}; - -enum -{ - iNibSaveFolderNameMenuItem = 5 -}; - -static int lastTabIndex = 1; -static int tabList[] = { 5, 129, 130, 131, 132, 133 }; - -struct PrefList -{ - OSType itemName; - void *itemPointer; - int size; -}; - -static PrefList prefList[] = -{ - { 'flsc', &fullscreen, sizeof(bool8 ) }, - { 'reso', &autoRes, sizeof(bool8 ) }, - { 'dfps', &Settings.DisplayFrameRate, sizeof(bool8 ) }, - { 'tran', &Settings.Transparency, sizeof(bool8 ) }, - { 'gl32', &gl32bit, sizeof(bool8 ) }, - { 'glst', &glstretch, sizeof(bool8 ) }, - { 'draw', &drawingMethod, sizeof(long ) }, - { 'Vmod', &videoMode, sizeof(int ) }, - { 'VSNC', &vsync, sizeof(bool8 ) }, - { 'H239', &drawoverscan, sizeof(bool8 ) }, - { 'SCur', &screencurvature, sizeof(bool8 ) }, - { 'SCuW', &macCurvatureWarp, sizeof(int ) }, - { 'ASPe', &macAspectRatio, sizeof(int ) }, - { 'CIFl', &ciFilterEnable, sizeof(bool8 ) }, - - { 'sSyn', &Settings.SoundSync, sizeof(bool8 ) }, - { 'srat', &Settings.SoundPlaybackRate, sizeof(uint32 ) }, - { 'InRt', &Settings.SoundInputRate, sizeof(uint32 ) }, - { 'MxIv', &macSoundInterval_ms, sizeof(uint32 ) }, - { 'SBuf', &macSoundBuffer_ms, sizeof(uint32 ) }, - { 'Volm', &macSoundVolume, sizeof(SInt32 ) }, - { 'AUef', &aueffect, sizeof(uint16 ) }, - { 'AUce', &cureffect, sizeof(int ) }, - - { 'romf', &saveInROMFolder, sizeof(uint8 ) }, - { 'atsv', &Settings.AutoSaveDelay, sizeof(int32 ) }, - { 'RFlg', &macRecordFlag, sizeof(uint16 ) }, - { 'PFlg', &macPlayFlag, sizeof(uint16 ) }, - { 'QTfg', &macQTMovFlag, sizeof(uint16 ) }, - - { 'HHck', &Settings.HDMATimingHack, sizeof(int32 ) }, - { 'TbRt', &macFastForwardRate, sizeof(int ) }, - { 'FSkp', &macFrameSkip, sizeof(int ) }, - { 'IvVR', &Settings.BlockInvalidVRAMAccessMaster, sizeof(bool8 ) }, - { 'GSHk', &Settings.DisableGameSpecificHacks, sizeof(bool8 ) }, - - { 'StOp', &startopendlog, sizeof(bool8 ) }, - { 'STiF', &showtimeinfrz, sizeof(bool8 ) }, - { 'Togl', &enabletoggle, sizeof(bool8 ) }, - { 'SvWp', &savewindowpos, sizeof(bool8 ) }, - { 'OnSc', &onscreeninfo, sizeof(bool8 ) }, - { 'NIPS', &Settings.NoPatch, sizeof(bool8 ) }, - { 'BSX_', &Settings.BSXBootup, sizeof(bool8 ) }, - { 'MbxM', &musicboxmode, sizeof(int ) }, - { 'InAc', &inactiveMode, sizeof(int ) }, - - { 'tab ', &lastTabIndex, sizeof(int ) }, - { 'Ftab', &autofireLastTabIndex, sizeof(int ) }, - { 'keyb', keyCodes, sizeof(keyCodes ) }, - { 'pset', &padSetting, sizeof(int ) }, - { 'dset', &deviceSetting, sizeof(int ) }, - { 'chea', &applycheat, sizeof(bool8 ) }, - - { 'ARec', autofireRec, sizeof(autofireRec) }, - { 'wPos', windowPos, sizeof(windowPos ) }, - { 'wSiz', windowSize, sizeof(windowSize ) }, - { 'wExt', (void *) &windowExtend, sizeof(bool8 ) }, - - { 'NPIP', npServerIP, sizeof(npServerIP ) }, - { 'NPNM', npName, sizeof(npName ) }, - - { 'L239', &lastoverscan, sizeof(bool8 ) }, - - { 'ExT1', &(extraOptions.benchmark), sizeof(bool8 ) }, - { 'ExT2', &(extraOptions.glForceNoTextureRectangle), sizeof(bool8 ) }, - { 'ExT3', &(extraOptions.glUseClientStrageApple), sizeof(bool8 ) }, - { 'ExT4', &(extraOptions.glUseTexturePriority), sizeof(bool8 ) }, - { 'ExT5', &(extraOptions.glStorageHint), sizeof(int ) } -}; - -#define kPrefListSize (sizeof(prefList) / sizeof(prefList[0])) - -static void SelectTabPane (HIViewRef, SInt16); -static void InputRateSliderActionProc (HIViewRef, HIViewPartCode); -static void LittleArrowsActionProc (HIViewRef, HIViewPartCode); -static OSStatus InputRateTextEventHandler (EventHandlerCallRef, EventRef, void *); -static OSStatus AspectRatioTextEventHandler (EventHandlerCallRef, EventRef, void *); -static OSStatus TabEventHandler (EventHandlerCallRef, EventRef, void *); -static OSStatus PreferencesEventHandler (EventHandlerCallRef, EventRef, void *); - - -void SavePrefs (void) -{ -// CFMutableStringRef mref; -// CFStringRef sref; -// CFDataRef data; -// -// for (unsigned int i = 0; i < kPrefListSize; i++) -// { -// mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_")); -// if (mref) -// { -// sref = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8 *) &(prefList[i].itemName), sizeof(OSType), kCFStringEncodingMacRoman, false); -// if (sref) -// { -// CFStringAppend(mref, sref); -// -// data = CFDataCreate(kCFAllocatorDefault, (UInt8 *) prefList[i].itemPointer, prefList[i].size); -// if (data) -// { -// CFPreferencesSetAppValue(mref, data, kCFPreferencesCurrentApplication); -// CFRelease(data); -// } -// -// CFRelease(sref); -// } -// -// CFRelease(mref); -// } -// } -// -// mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_SaveFolder")); -// if (mref) -// { -// if (saveFolderPath) -// { -// CFPreferencesSetAppValue(mref, saveFolderPath, kCFPreferencesCurrentApplication); -// CFRelease(saveFolderPath); -// } -// else -// CFPreferencesSetAppValue(mref, NULL, kCFPreferencesCurrentApplication); -// -// CFRelease(mref); -// } -// -// sref = (CFStringRef) CFDictionaryGetValue(CFBundleGetInfoDictionary(CFBundleGetMainBundle()), CFSTR("CFBundleShortVersionString")); -// if (sref) -// { -// CFPreferencesSetAppValue(CFSTR("LastVersionUsed"), sref, kCFPreferencesCurrentApplication); -// } -// -// CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); -} - -void LoadPrefs (void) -{ -// CFMutableStringRef mref; -// CFStringRef sref; -// CFDataRef data; -// -// for (unsigned int i = 0; i < kPrefListSize; i++) -// { -// mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_")); -// if (mref) -// { -// sref = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8 *) &(prefList[i].itemName), sizeof(OSType), kCFStringEncodingMacRoman, false); -// if (sref) -// { -// CFStringAppend(mref, sref); -// -// data = (CFDataRef) CFPreferencesCopyAppValue(mref, kCFPreferencesCurrentApplication); -// if (data) -// { -// if (CFDataGetLength(data) == prefList[i].size) -// CFDataGetBytes(data, CFRangeMake(0, prefList[i].size), (UInt8 *) prefList[i].itemPointer); -// CFRelease(data); -// } -// -// CFRelease(sref); -// } -// -// CFRelease(mref); -// } -// } -// -// mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_SaveFolder")); -// if (mref) -// { -// sref = (CFStringRef) CFPreferencesCopyAppValue(mref, kCFPreferencesCurrentApplication); -// if (sref) -// saveFolderPath = sref; -// -// CFRelease(mref); -// } -// -// sref = (CFStringRef) CFPreferencesCopyAppValue(CFSTR("LastVersionUsed"), kCFPreferencesCurrentApplication); -// if (!sref) { -// Settings.SoundInputRate = 31950; -// macSoundBuffer_ms = 80; -// } -// else CFRelease(sref); -} - -void ConfigurePreferences (void) -{ -// OSStatus err; -// IBNibRef nibRef; -// -// err = CreateNibReference(kMacS9XCFString, &nibRef); -// if (err == noErr) -// { -// WindowRef tWindowRef; -// SInt32 oldVolume; -// uint32 oldPlaybackRate, oldInputRate, oldInterval, oldBufferSize; -// bool8 oldSynchronize, old16BitPlayback, oldStereo, oldReverseStereo, oldLagEnable; -// -// oldSynchronize = Settings.SoundSync; -// old16BitPlayback = Settings.SixteenBitSound; -// oldStereo = Settings.Stereo; -// oldReverseStereo = Settings.ReverseStereo; -// oldPlaybackRate = Settings.SoundPlaybackRate; -// oldInputRate = Settings.SoundInputRate; -// oldInterval = macSoundInterval_ms; -// oldBufferSize = macSoundBuffer_ms; -// oldLagEnable = macSoundLagEnable; -// oldVolume = macSoundVolume; -// -// if (cartOpen) -// DeinitGameWindow(); -// -// S9xGraphicsDeinit(); -// -// err = CreateWindowFromNib(nibRef, CFSTR("Preferences"), &tWindowRef); -// if (err == noErr) -// { -// EventHandlerUPP tUPP, iUPP, aUPP, pUPP; -// EventHandlerRef tRef, iRef, aRef, pRef; -// EventTypeSpec tEvents[] = { { kEventClassControl, kEventControlHit } }, -// iEvents[] = { { kEventClassControl, kEventControlClick } }, -// aEvents[] = { { kEventClassControl, kEventControlClick } }, -// pEvents[] = { { kEventClassWindow, kEventWindowClose }, -// { kEventClassCommand, kEventCommandProcess }, -// { kEventClassCommand, kEventCommandUpdateStatus } }; -// ControlActionUPP arrowsUPP, sliderUPP; -// HIViewRef ctl, root; -// HIViewID cid; -// MenuRef menu; -// char num[16]; -// -// root = HIViewGetRoot(tWindowRef); -// -// cid.signature = 'tabs'; -// cid.id = 128; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, lastTabIndex); -// SelectTabPane(ctl, lastTabIndex); -// tUPP = NewEventHandlerUPP(TabEventHandler); -// err = InstallControlEventHandler(ctl, tUPP, GetEventTypeCount(tEvents), tEvents, 0, &tRef); -// -// cid.signature = 'snd_'; -// cid.id = iNibSInputRateText; -// HIViewFindByID(root, cid, &ctl); -// iUPP = NewEventHandlerUPP(InputRateTextEventHandler); -// err = InstallControlEventHandler(ctl, iUPP, GetEventTypeCount(iEvents), iEvents, 0, &iRef); -// -// cid.signature = 'grap'; -// cid.id = iNibGAspectRatioText; -// HIViewFindByID(root, cid, &ctl); -// aUPP = NewEventHandlerUPP(AspectRatioTextEventHandler); -// err = InstallControlEventHandler(ctl, aUPP, GetEventTypeCount(aEvents), aEvents, 0, &aRef); -// -// pUPP = NewEventHandlerUPP(PreferencesEventHandler); -// err = InstallWindowEventHandler(tWindowRef, pUPP, GetEventTypeCount(pEvents), pEvents, (void *) tWindowRef, &pRef); -// -// sliderUPP = NewControlActionUPP(InputRateSliderActionProc); -// arrowsUPP = NewControlActionUPP(LittleArrowsActionProc); -// -// cid.signature = 'grap'; -// -// cid.id = iNibGFullScreen; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, fullscreen); -// -// cid.id = iNibGSwitchResolution; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, autoRes); -// -// cid.id = iNibGShowFrameRate; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.DisplayFrameRate); -// -// cid.id = iNibGTransparency; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.Transparency); -// -// cid.id = iNibGGL32bit; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, gl32bit); -// -// cid.id = iNibGGLStretch; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, glstretch); -// -// cid.id = iNibGVideoMode; -// HIViewFindByID(root, cid, &ctl); -// switch (videoMode) -// { -// case VIDEOMODE_BLOCKY: -// SetControl32BitValue(ctl, iOpenGLBlocky); -// break; -// -// case VIDEOMODE_TV: -// SetControl32BitValue(ctl, iOpenGLTVMode); -// break; -// -// case VIDEOMODE_SMOOTH: -// SetControl32BitValue(ctl, iOpenGLSmoothMode); -// break; -// -// case VIDEOMODE_BLEND: -// SetControl32BitValue(ctl, iOpenGLBlendMode); -// break; -// -// case VIDEOMODE_SUPEREAGLE: -// SetControl32BitValue(ctl, iOpenGLEagleMode); -// break; -// -// case VIDEOMODE_2XSAI: -// SetControl32BitValue(ctl, iOpenGL2xSAIMode); -// break; -// -// case VIDEOMODE_SUPER2XSAI: -// SetControl32BitValue(ctl, iOpenGLSuper2xSAIMode); -// break; -// -// case VIDEOMODE_EPX: -// SetControl32BitValue(ctl, iOpenGLEPXMode); -// break; -// -// case VIDEOMODE_HQ2X: -// SetControl32BitValue(ctl, iOpenGLHQ2xMode); -// break; -// -// case VIDEOMODE_HQ3X: -// SetControl32BitValue(ctl, iOpenGLHQ3xMode); -// break; -// -// case VIDEOMODE_HQ4X: -// SetControl32BitValue(ctl, iOpenGLHQ4xMode); -// break; -// -// case VIDEOMODE_NTSC_C: -// SetControl32BitValue(ctl, iOpenGLNTSC_CMode); -// break; -// -// case VIDEOMODE_NTSC_S: -// SetControl32BitValue(ctl, iOpenGLNTSC_SMode); -// break; -// -// case VIDEOMODE_NTSC_R: -// SetControl32BitValue(ctl, iOpenGLNTSC_RMode); -// break; -// -// case VIDEOMODE_NTSC_M: -// SetControl32BitValue(ctl, iOpenGLNTSC_MMode); -// break; -// -// case VIDEOMODE_NTSC_TV_C: -// SetControl32BitValue(ctl, iOpenGLNTSC_TV_CMode); -// break; -// -// case VIDEOMODE_NTSC_TV_S: -// SetControl32BitValue(ctl, iOpenGLNTSC_TV_SMode); -// break; -// -// case VIDEOMODE_NTSC_TV_R: -// SetControl32BitValue(ctl, iOpenGLNTSC_TV_RMode); -// break; -// -// case VIDEOMODE_NTSC_TV_M: -// SetControl32BitValue(ctl, iOpenGLNTSC_TV_MMode); -// break; -// } -// -// cid.id = iNibGDirectMP; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, multiprocessor); -// -// cid.id = iNibGGLVSync; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, vsync); -// -// cid.id = iNibGDrawOverscan; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, drawoverscan); -// -// cid.id = iNibGScreenCurvature; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, screencurvature); -// -// cid.id = iNibGCurvatureWarp; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macCurvatureWarp); -// if (!screencurvature) -// DeactivateControl(ctl); -// -// cid.id = iNibGAspectRatio; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macAspectRatio); -// if (!glstretch) -// DeactivateControl(ctl); -// -// cid.id = iNibGCIFilterEnable; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, ciFilterEnable); -// if (systemVersion < 0x1040) -// DisableControl(ctl); -// -// if (systemVersion < 0x1040) -// { -// cid.id = iNibGCoreImageFilter; -// HIViewFindByID(root, cid, &ctl); -// DisableControl(ctl); -// } -// -// cid.signature = 'snd_'; -// -// cid.id = iNibSSynchronize; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.SoundSync); -// -// cid.id = iNibS16BitPlayback; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.SixteenBitSound); -// DeactivateControl(ctl); -// -// cid.id = iNibSStereo; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.Stereo); -// DeactivateControl(ctl); -// -// cid.id = iNibSReverseStereo; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.ReverseStereo); -// DeactivateControl(ctl); -// -// cid.id = iNibSPlaybackRate; -// HIViewFindByID(root, cid, &ctl); -// switch (Settings.SoundPlaybackRate) -// { -// case 48000: -// SetControl32BitValue(ctl, 1); -// break; -// -// case 44100: -// SetControl32BitValue(ctl, 2); -// break; -// -// case 35000: -// SetControl32BitValue(ctl, 3); -// break; -// -// case 32000: -// SetControl32BitValue(ctl, 4); -// break; -// -// case 30000: -// SetControl32BitValue(ctl, 5); -// break; -// -// case 22050: -// SetControl32BitValue(ctl, 6); -// break; -// -// case 16000: -// SetControl32BitValue(ctl, 7); -// break; -// -// case 11025: -// SetControl32BitValue(ctl, 8); -// break; -// -// case 8000: -// SetControl32BitValue(ctl, 9); -// break; -// } -// -// cid.id = iNibSInputRate; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.SoundInputRate); -// SetControlAction(ctl, sliderUPP); -// -// cid.id = iNibSInputRateText; -// HIViewFindByID(root, cid, &ctl); -// sprintf(num, "%d", Settings.SoundInputRate); -// SetStaticTextCStr(ctl, num, false); -// -// cid.id = iNibSInterval; -// HIViewFindByID(root, cid, &ctl); -// switch (macSoundInterval_ms) -// { -// case 8: -// SetControl32BitValue(ctl, 1); -// break; -// -// case 16: -// SetControl32BitValue(ctl, 2); -// break; -// -// case 32: -// SetControl32BitValue(ctl, 3); -// break; -// -// case 64: -// SetControl32BitValue(ctl, 4); -// break; -// -// case 0: -// default: -// SetControl32BitValue(ctl, 6); -// break; -// } -// -// cid.id = iNibSBufferSize; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macSoundBuffer_ms / 20); -// -// cid.id = iNibSAllowLag; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macSoundLagEnable); -// DeactivateControl(ctl); -// -// cid.id = iNibSVolume; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macSoundVolume); -// -// cid.signature = 'othe'; -// -// cid.id = iNibOSaveFolder; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, saveInROMFolder + 1); -// err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); -// if (saveFolderPath) -// { -// CFURLRef url; -// CFStringRef ref; -// -// url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, saveFolderPath, kCFURLPOSIXPathStyle, true); -// ref = CFURLCopyLastPathComponent(url); -// err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref); -// CFRelease(ref); -// CFRelease(url); -// EnableMenuItem(menu, iNibSaveFolderNameMenuItem); -// } -// else -// { -// CFStringRef ref; -// -// ref = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected"); -// err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref); -// CFRelease(ref); -// DisableMenuItem(menu, iNibSaveFolderNameMenuItem); -// } -// -// cid.id = iNibOAutoSaveInterval; -// HIViewFindByID(root, cid, &ctl); -// sprintf(num, "%d", Settings.AutoSaveDelay); -// SetEditTextCStr(ctl, num, false); -// -// cid.signature = 'msc2'; -// -// cid.id = iNibMCPUCycles; -// HIViewFindByID(root, cid, &ctl); -// sprintf(num, "%" PRIi32, Settings.HDMATimingHack); -// SetEditTextCStr(ctl, num, false); -// -// cid.id = iNibMTurboSkipArrows; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macFastForwardRate); -// SetControlAction(ctl, arrowsUPP); -// -// cid.id = iNibMTurboSkipText; -// HIViewFindByID(root, cid, &ctl); -// sprintf(num, "%d", macFastForwardRate); -// SetStaticTextCStr(ctl, num, false); -// -// cid.id = iNibMFrameSkip; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, macFrameSkip + 2); -// -// cid.id = iNibMAllowInvalidVRAMAccess; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, !Settings.BlockInvalidVRAMAccessMaster); -// -// cid.id = iNibMAllowSpecificGameHacks; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, !Settings.DisableGameSpecificHacks); -// -// cid.signature = 'osx_'; -// -// cid.id = iNibXStartOpenDialog; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, startopendlog); -// -// cid.id = iNibXShowTimeInFrz; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, showtimeinfrz); -// -// cid.id = iNibXMusicBoxMode; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, musicboxmode); -// -// cid.id = iNibXEnableToggle; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, enabletoggle); -// -// cid.id = iNibXSaveWindowPos; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, savewindowpos); -// -// cid.id = iNibXUseIPSPatch; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, !Settings.NoPatch); -// -// cid.id = iNibXOnScreenInfo; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, onscreeninfo); -// -// cid.id = iNibXInactiveMode; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, inactiveMode); -// -// cid.id = iNibXBSXBootup; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, Settings.BSXBootup); -// -// MoveWindowPosition(tWindowRef, kWindowPreferences, false); -// ShowWindow(tWindowRef); -// err = RunAppModalLoopForWindow(tWindowRef); -// HideWindow(tWindowRef); -// SaveWindowPosition(tWindowRef, kWindowPreferences); -// -// cid.signature = 'grap'; -// -// cid.id = iNibGFullScreen; -// HIViewFindByID(root, cid, &ctl); -// fullscreen = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGSwitchResolution; -// HIViewFindByID(root, cid, &ctl); -// autoRes = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGShowFrameRate; -// HIViewFindByID(root, cid, &ctl); -// Settings.DisplayFrameRate = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGTransparency; -// HIViewFindByID(root, cid, &ctl); -// Settings.Transparency = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGGL32bit; -// HIViewFindByID(root, cid, &ctl); -// gl32bit = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGGLStretch; -// HIViewFindByID(root, cid, &ctl); -// glstretch = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGVideoMode; -// HIViewFindByID(root, cid, &ctl); -// switch (GetControl32BitValue(ctl)) -// { -// case iOpenGLBlocky: -// drawingMethod = kDrawingOpenGL; -// videoMode = VIDEOMODE_BLOCKY; -// break; -// -// case iOpenGLTVMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_TV; -// break; -// -// case iOpenGLSmoothMode: -// drawingMethod = kDrawingOpenGL; -// videoMode = VIDEOMODE_SMOOTH; -// break; -// -// case iOpenGLBlendMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_BLEND; -// break; -// -// case iOpenGLEagleMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_SUPEREAGLE; -// break; -// -// case iOpenGL2xSAIMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_2XSAI; -// break; -// -// case iOpenGLSuper2xSAIMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_SUPER2XSAI; -// break; -// -// case iOpenGLEPXMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_EPX; -// break; -// -// case iOpenGLHQ2xMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_HQ2X; -// break; -// -// case iOpenGLHQ3xMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_HQ3X; -// break; -// -// case iOpenGLHQ4xMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_HQ4X; -// break; -// -// case iOpenGLNTSC_CMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_C; -// S9xBlitNTSCFilterSet(&snes_ntsc_composite); -// break; -// -// case iOpenGLNTSC_SMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_S; -// S9xBlitNTSCFilterSet(&snes_ntsc_svideo); -// break; -// -// case iOpenGLNTSC_RMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_R; -// S9xBlitNTSCFilterSet(&snes_ntsc_rgb); -// break; -// -// case iOpenGLNTSC_MMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_M; -// S9xBlitNTSCFilterSet(&snes_ntsc_monochrome); -// break; -// -// case iOpenGLNTSC_TV_CMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_TV_C; -// S9xBlitNTSCFilterSet(&snes_ntsc_composite); -// break; -// -// case iOpenGLNTSC_TV_SMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_TV_S; -// S9xBlitNTSCFilterSet(&snes_ntsc_svideo); -// break; -// -// case iOpenGLNTSC_TV_RMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_TV_R; -// S9xBlitNTSCFilterSet(&snes_ntsc_rgb); -// break; -// -// case iOpenGLNTSC_TV_MMode: -// drawingMethod = kDrawingBlitGL; -// videoMode = VIDEOMODE_NTSC_TV_M; -// S9xBlitNTSCFilterSet(&snes_ntsc_monochrome); -// break; -// } -// -// cid.id = iNibGDirectMP; -// HIViewFindByID(root, cid, &ctl); -// multiprocessor = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGGLVSync; -// HIViewFindByID(root, cid, &ctl); -// vsync = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGDrawOverscan; -// HIViewFindByID(root, cid, &ctl); -// drawoverscan = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGScreenCurvature; -// HIViewFindByID(root, cid, &ctl); -// screencurvature = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibGCurvatureWarp; -// HIViewFindByID(root, cid, &ctl); -// macCurvatureWarp = GetControl32BitValue(ctl); -// -// cid.id = iNibGAspectRatio; -// HIViewFindByID(root, cid, &ctl); -// macAspectRatio = GetControl32BitValue(ctl); -// -// cid.id = iNibGCIFilterEnable; -// HIViewFindByID(root, cid, &ctl); -// ciFilterEnable = GetControl32BitValue(ctl) ? true : false; -// -// cid.signature = 'snd_'; -// -// cid.id = iNibSSynchronize; -// HIViewFindByID(root, cid, &ctl); -// Settings.SoundSync = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibS16BitPlayback; -// HIViewFindByID(root, cid, &ctl); -// Settings.SixteenBitSound = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibSStereo; -// HIViewFindByID(root, cid, &ctl); -// Settings.Stereo = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibSReverseStereo; -// HIViewFindByID(root, cid, &ctl); -// Settings.ReverseStereo = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibSPlaybackRate; -// HIViewFindByID(root, cid, &ctl); -// switch (GetControl32BitValue(ctl)) -// { -// case 1: -// Settings.SoundPlaybackRate = 48000; -// break; -// -// case 2: -// Settings.SoundPlaybackRate = 44100; -// break; -// -// case 3: -// Settings.SoundPlaybackRate = 35000; -// break; -// -// case 4: -// Settings.SoundPlaybackRate = 32000; -// break; -// -// case 5: -// Settings.SoundPlaybackRate = 30000; -// break; -// -// case 6: -// Settings.SoundPlaybackRate = 22050; -// break; -// -// case 7: -// Settings.SoundPlaybackRate = 16000; -// break; -// -// case 8: -// Settings.SoundPlaybackRate = 11025; -// break; -// -// case 9: -// Settings.SoundPlaybackRate = 8000; -// break; -// } -// -// cid.id = iNibSInputRate; -// HIViewFindByID(root, cid, &ctl); -// Settings.SoundInputRate = GetControl32BitValue(ctl); -// -// cid.id = iNibSInterval; -// HIViewFindByID(root, cid, &ctl); -// switch (GetControl32BitValue(ctl)) -// { -// case 1: -// macSoundInterval_ms = 8; -// break; -// -// case 2: -// macSoundInterval_ms = 16; -// break; -// -// case 3: -// macSoundInterval_ms = 32; -// break; -// -// case 4: -// macSoundInterval_ms = 64; -// break; -// -// case 6: -// default: -// macSoundInterval_ms = 0; -// break; -// } -// -// cid.id = iNibSBufferSize; -// HIViewFindByID(root, cid, &ctl); -// macSoundBuffer_ms = GetControl32BitValue(ctl) * 20; -// -// cid.id = iNibSAllowLag; -// HIViewFindByID(root, cid, &ctl); -// macSoundLagEnable = GetControl32BitValue(ctl); -// -// cid.id = iNibSVolume; -// HIViewFindByID(root, cid, &ctl); -// macSoundVolume = GetControl32BitValue(ctl); -// -// cid.signature = 'othe'; -// -// cid.id = iNibOSaveFolder; -// HIViewFindByID(root, cid, &ctl); -// saveInROMFolder = GetControl32BitValue(ctl) - 1; -// -// cid.id = iNibOAutoSaveInterval; -// HIViewFindByID(root, cid, &ctl); -// GetEditTextCStr(ctl, num); -// Settings.AutoSaveDelay = atoi(num); -// -// cid.signature = 'msc2'; -// -// cid.id = iNibMCPUCycles; -// HIViewFindByID(root, cid, &ctl); -// GetEditTextCStr(ctl, num); -// Settings.HDMATimingHack = atoi(num); -// if ((Settings.HDMATimingHack <= 0) || (Settings.HDMATimingHack >= 200)) -// Settings.HDMATimingHack = 100; -// -// cid.id = iNibMTurboSkipArrows; -// HIViewFindByID(root, cid, &ctl); -// macFastForwardRate = GetControl32BitValue(ctl); -// -// cid.id = iNibMFrameSkip; -// HIViewFindByID(root, cid, &ctl); -// macFrameSkip = GetControl32BitValue(ctl) - 2; -// -// cid.id = iNibMAllowInvalidVRAMAccess; -// HIViewFindByID(root, cid, &ctl); -// Settings.BlockInvalidVRAMAccessMaster = GetControl32BitValue(ctl) ? false : true; -// -// cid.id = iNibMAllowSpecificGameHacks; -// HIViewFindByID(root, cid, &ctl); -// Settings.DisableGameSpecificHacks = GetControl32BitValue(ctl) ? false : true; -// -// cid.signature = 'osx_'; -// -// cid.id = iNibXStartOpenDialog; -// HIViewFindByID(root, cid, &ctl); -// startopendlog = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibXShowTimeInFrz; -// HIViewFindByID(root, cid, &ctl); -// showtimeinfrz = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibXMusicBoxMode; -// HIViewFindByID(root, cid, &ctl); -// musicboxmode = GetControl32BitValue(ctl); -// -// cid.id = iNibXEnableToggle; -// HIViewFindByID(root, cid, &ctl); -// enabletoggle = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibXSaveWindowPos; -// HIViewFindByID(root, cid, &ctl); -// savewindowpos = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibXUseIPSPatch; -// HIViewFindByID(root, cid, &ctl); -// Settings.NoPatch = GetControl32BitValue(ctl) ? false : true; -// -// cid.id = iNibXOnScreenInfo; -// HIViewFindByID(root, cid, &ctl); -// onscreeninfo = GetControl32BitValue(ctl) ? true : false; -// -// cid.id = iNibXInactiveMode; -// HIViewFindByID(root, cid, &ctl); -// inactiveMode = GetControl32BitValue(ctl); -// -// cid.id = iNibXBSXBootup; -// HIViewFindByID(root, cid, &ctl); -// Settings.BSXBootup = GetControl32BitValue(ctl) ? true : false; -// -// DisposeControlActionUPP(arrowsUPP); -// DisposeControlActionUPP(sliderUPP); -// -// err = RemoveEventHandler(pRef); -// DisposeEventHandlerUPP(pUPP); -// -// err = RemoveEventHandler(aRef); -// DisposeEventHandlerUPP(aUPP); -// -// err = RemoveEventHandler(iRef); -// DisposeEventHandlerUPP(iUPP); -// -// err = RemoveEventHandler(tRef); -// DisposeEventHandlerUPP(tUPP); -// -// CFRelease(tWindowRef); -// } -// -// DisposeNibReference(nibRef); -// -// S9xGraphicsInit(); -// -// if (((oldSynchronize != Settings.SoundSync ) || -// (old16BitPlayback != Settings.SixteenBitSound ) || -// (oldStereo != Settings.Stereo ) || -// (oldReverseStereo != Settings.ReverseStereo ) || -// (oldPlaybackRate != Settings.SoundPlaybackRate) || -// (oldInputRate != Settings.SoundInputRate ) || -// (oldInterval != macSoundInterval_ms ) || -// (oldBufferSize != macSoundBuffer_ms ) || -// (oldLagEnable != macSoundLagEnable ) || -// (oldVolume != macSoundVolume )) && cartOpen) -// SNES9X_InitSound(); -// -// if (!fullscreen && cartOpen) -// { -// InitGameWindow(); -// ShowWindow(gWindow); -// } -// -// if (cartOpen) -// { -// FSRef ref; -// -// err = FSPathMakeRef((unsigned char *) Memory.ROMFilename, &ref, NULL); -// if (err == noErr) -// CheckSaveFolder(&ref); -// } -// } -} - -static void SelectTabPane (HIViewRef tabControl, SInt16 index) -{ -// HIViewRef sup, userPane, selectedPane = NULL; -// HIViewID cid; -// -// lastTabIndex = index; -// -// sup = HIViewGetSuperview(tabControl); -// cid.signature = 'tabs'; -// -// for (int i = 1; i < tabList[0] + 1; i++) -// { -// cid.id = tabList[i]; -// HIViewFindByID(sup, cid, &userPane); -// -// if (i == index) -// selectedPane = userPane; -// else -// HIViewSetVisible(userPane, false); -// } -// -// if (selectedPane != NULL) -// HIViewSetVisible(selectedPane, true); -// -// HIViewSetNeedsDisplay(tabControl, true); -} - -static void InputRateSliderActionProc (HIViewRef slider, HIViewPartCode partCode) -{ -// HIViewRef ctl; -// HIViewID cid; -// char num[10]; -// -// cid.signature = 'snd_'; -// cid.id = iNibSInputRateText; -// HIViewFindByID(HIViewGetSuperview(slider), cid, &ctl); -// -// sprintf(num, "%ld", GetControl32BitValue(slider)); -// SetStaticTextCStr(ctl, num, true); -} - -static void LittleArrowsActionProc (HIViewRef arrows, HIViewPartCode partCode) -{ -// HIViewRef ctl; -// HIViewID cid = { 'msc2', iNibMTurboSkipText }; -// char num[8]; -// -// if (partCode == kControlUpButtonPart) -// SetControl32BitValue(arrows, GetControl32BitValue(arrows) + 1); -// else -// if (partCode == kControlDownButtonPart) -// SetControl32BitValue(arrows, GetControl32BitValue(arrows) - 1); -// -// HIViewFindByID(HIViewGetSuperview(arrows), cid, &ctl); -// sprintf(num, "%ld", GetControl32BitValue(arrows)); -// SetStaticTextCStr(ctl, num, true); -} - -static OSStatus InputRateTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) -{ -// OSStatus err, result = eventNotHandledErr; -// HIViewRef ctl, slider; -// HIViewID cid; -// SInt32 value; -// char num[10]; -// -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl); -// if (err == noErr) -// { -// cid.signature = 'snd_'; -// cid.id = iNibSInputRate; -// HIViewFindByID(HIViewGetSuperview(ctl), cid, &slider); -// value = GetControl32BitValue(slider); -// -// value /= 50; -// value *= 50; -// if (value > 33000) -// value = 33000; -// if (value < 31000) -// value = 31000; -// -// SetControl32BitValue(slider, value); -// sprintf(num, "%ld", value); -// SetEditTextCStr(ctl, num, true); -// -// result = noErr; -// } -// -// return (result); - - return 0; -} - -static OSStatus AspectRatioTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) -{ -// OSStatus err, result = eventNotHandledErr; -// HIViewRef ctl, slider; -// HIViewID cid; -// float w, h, v; -// int iw, ih; -// -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl); -// if (err == noErr) -// { -// cid.signature = 'grap'; -// cid.id = iNibGAspectRatio; -// HIViewFindByID(HIViewGetSuperview(ctl), cid, &slider); -// -// GetGameDisplay(&iw, &ih); -// w = (float) iw; -// h = (float) ih; -// -// v = (float) SNES_WIDTH / (float) SNES_HEIGHT * h; -// macAspectRatio = (int) (((4.0f / 3.0f) * h - v) / (w - v) * 10000.0f); -// -// SetControl32BitValue(slider, macAspectRatio); -// -// result = noErr; -// } -// -// return (result); - - return 0; -} - -static OSStatus TabEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) -{ -// OSStatus err, result = eventNotHandledErr; -// HIViewRef ctl; -// HIViewID cid; -// SInt32 value; -// -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl); -// if (err == noErr) -// { -// GetControlID(ctl, &cid); -// value = GetControl32BitValue(ctl); -// -// if ((cid.id == 128) && (value != lastTabIndex)) -// { -// SelectTabPane(ctl, value); -// result = noErr; -// } -// } -// -// return (result); - - return 0; -} - -static OSStatus PreferencesEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) -{ -// OSStatus err, result = eventNotHandledErr; -// WindowRef tWindowRef = (WindowRef) inUserData; -// -// switch (GetEventClass(inEvent)) -// { -// case kEventClassWindow: -// { -// switch (GetEventKind(inEvent)) -// { -// case kEventWindowClose: -// { -// QuitAppModalLoopForWindow(tWindowRef); -// result = noErr; -// break; -// } -// } -// -// break; -// } -// -// case kEventClassCommand: -// { -// switch (GetEventKind(inEvent)) -// { -// HICommand tHICommand; -// -// case kEventCommandUpdateStatus: -// { -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); -// if (err == noErr && tHICommand.commandID == 'clos') -// { -// UpdateMenuCommandStatus(true); -// result = noErr; -// } -// -// break; -// } -// -// case kEventCommandProcess: -// { -// HIViewRef ctl, root; -// HIViewID cid; -// SInt32 value; -// FSRef ref; -// bool8 r; -// -// root = HIViewGetRoot(tWindowRef); -// -// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); -// if (err == noErr) -// { -// switch (tHICommand.commandID) -// { -// case 'S_EF': -// { -// HideWindow(tWindowRef); -// ConfigureSoundEffects(); -// ShowWindow(tWindowRef); -// -// result = noErr; -// break; -// } -// -// case 'G_FL': -// { -// if (systemVersion >= 0x1040) -// { -// HideWindow(tWindowRef); -// ConfigureCoreImageFilter(); -// ShowWindow(tWindowRef); -// } -// -// result = noErr; -// break; -// } -// -// case 'G__7': -// { -// cid.signature = 'grap'; -// cid.id = iNibGGLStretch; -// HIViewFindByID(root, cid, &ctl); -// value = GetControl32BitValue(ctl); -// -// cid.id = iNibGAspectRatio; -// HIViewFindByID(root, cid, &ctl); -// if (value) -// ActivateControl(ctl); -// else -// DeactivateControl(ctl); -// -// result = noErr; -// break; -// } -// -// case 'G_13': -// { -// cid.signature = 'grap'; -// cid.id = iNibGScreenCurvature; -// HIViewFindByID(root, cid, &ctl); -// value = GetControl32BitValue(ctl); -// -// cid.id = iNibGCurvatureWarp; -// HIViewFindByID(root, cid, &ctl); -// if (value) -// ActivateControl(ctl); -// else -// DeactivateControl(ctl); -// -// result = noErr; -// break; -// } -// -// case 'S__3': -// { -// cid.signature = 'snd_'; -// cid.id = iNibSStereo; -// HIViewFindByID(root, cid, &ctl); -// value = GetControl32BitValue(ctl); -// -// cid.id = iNibSReverseStereo; -// HIViewFindByID(root, cid, &ctl); -// if (value) -// ActivateControl(ctl); -// else -// DeactivateControl(ctl); -// -// result = noErr; -// break; -// } -// -// case 'F_FL': -// { -// UInt32 modifierkey; -// -// err = GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifierkey); -// if (err == noErr) -// { -// if (modifierkey & optionKey) -// { -// CFStringRef str; -// MenuRef menu; -// -// str = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected"); -// -// cid.signature = 'othe'; -// cid.id = iNibOSaveFolder; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, 3); -// err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); -// err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str); -// DisableMenuItem(menu, iNibSaveFolderNameMenuItem); -// HIViewSetNeedsDisplay(ctl, true); -// -// CFRelease(str); -// -// if (saveFolderPath) -// CFRelease(saveFolderPath); -// saveFolderPath = NULL; -// } -//// else -//// r = NavChooseFolderSheet(tWindowRef); -// } -// -// result = noErr; -// break; -// } -// -// case 'NvDn': -// { -// //r = NavEndChooseFolderSheet(&ref); -// if (r) -// { -// CFStringRef str; -// CFURLRef url; -// MenuRef menu; -// -// url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref); -// str = CFURLCopyLastPathComponent(url); -// -// cid.signature = 'othe'; -// cid.id = iNibOSaveFolder; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, iNibSaveFolderNameMenuItem); -// err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); -// err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str); -// EnableMenuItem(menu, iNibSaveFolderNameMenuItem); -// HIViewSetNeedsDisplay(ctl, true); -// -// CFRelease(str); -// -// str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); -// if (saveFolderPath) -// CFRelease(saveFolderPath); -// saveFolderPath = str; -// -// CFRelease(url); -// } -// -// result = noErr; -// break; -// } -// } -// } -// -// break; -// } -// } -// -// break; -// } -// } -// -// return (result); - return 0; -} - -void ConfigureExtraOptions (void) -{ -// OSStatus err; -// IBNibRef nibRef; -// -// err = CreateNibReference(kMacS9XCFString, &nibRef); -// if (err == noErr) -// { -// WindowRef tWindowRef; -// -// err = CreateWindowFromNib(nibRef, CFSTR("ExtraOptions"), &tWindowRef); -// if (err == noErr) -// { -// EventHandlerRef eref; -// EventHandlerUPP eventUPP; -// EventTypeSpec windowEvents[] = { { kEventClassWindow, kEventWindowClose }, -// { kEventClassCommand, kEventCommandUpdateStatus } }; -// HIViewRef ctl, root; -// HIViewID cid; -// -// root = HIViewGetRoot(tWindowRef); -// cid.id = 0; -// -// cid.signature = 'BMrk'; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, extraOptions.benchmark); -// -// cid.signature = 'NoTR'; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, extraOptions.glForceNoTextureRectangle); -// -// cid.signature = 'CSAp'; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, extraOptions.glUseClientStrageApple); -// -// cid.signature = 'AGPT'; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, extraOptions.glUseTexturePriority); -// -// cid.signature = 'Hint'; -// HIViewFindByID(root, cid, &ctl); -// SetControl32BitValue(ctl, extraOptions.glStorageHint); -// -// eventUPP = NewEventHandlerUPP(DefaultEventHandler); -// err = InstallWindowEventHandler(tWindowRef, eventUPP, GetEventTypeCount(windowEvents), windowEvents, (void *) tWindowRef, &eref); -// -// MoveWindowPosition(tWindowRef, kWindowExtra, false); -// ShowWindow(tWindowRef); -// err = RunAppModalLoopForWindow(tWindowRef); -// HideWindow(tWindowRef); -// SaveWindowPosition(tWindowRef, kWindowExtra); -// -// cid.signature = 'BMrk'; -// HIViewFindByID(root, cid, &ctl); -// extraOptions.benchmark = GetControl32BitValue(ctl) ? true : false; -// -// cid.signature = 'NoTR'; -// HIViewFindByID(root, cid, &ctl); -// extraOptions.glForceNoTextureRectangle = GetControl32BitValue(ctl) ? true : false; -// -// cid.signature = 'CSAp'; -// HIViewFindByID(root, cid, &ctl); -// extraOptions.glUseClientStrageApple = GetControl32BitValue(ctl) ? true : false; -// -// cid.signature = 'AGPT'; -// HIViewFindByID(root, cid, &ctl); -// extraOptions.glUseTexturePriority = GetControl32BitValue(ctl) ? true : false; -// -// cid.signature = 'Hint'; -// HIViewFindByID(root, cid, &ctl); -// extraOptions.glStorageHint = GetControl32BitValue(ctl); -// -// err = RemoveEventHandler(eref); -// DisposeEventHandlerUPP(eventUPP); -// -// CFRelease(tWindowRef); -// } -// -// DisposeNibReference(nibRef); -// } -} diff --git a/macosx/mac-render.h b/macosx/mac-render.h index d92c802d..e034ca1d 100644 --- a/macosx/mac-render.h +++ b/macosx/mac-render.h @@ -24,8 +24,6 @@ void InitGraphics (void); void DeinitGraphics (void); -void DrawPauseScreen (CGContextRef, HIRect); -void ClearGFXScreen (void); void DrawFreezeDefrostScreen (uint8 *); void GetGameDisplay (int *, int *); diff --git a/macosx/mac-render.mm b/macosx/mac-render.mm index 58ca533d..6c4bcdbb 100644 --- a/macosx/mac-render.mm +++ b/macosx/mac-render.mm @@ -26,143 +26,40 @@ #include "display.h" #include "blit.h" -#include -#include -#include -#include -#include -#include #include #include "mac-prefix.h" #include "mac-cheatfinder.h" -#include "mac-coreimage.h" #include "mac-os.h" #include "mac-screenshot.h" #include "mac-render.h" -typedef void (* Blitter) (uint8 *, int, uint8 *, int, int, int); - -static void S9xInitFullScreen (void); -static void S9xDeinitFullScreen (void); -static void S9xInitWindowMode (void); -static void S9xDeinitWindowMode (void); -static void S9xInitOpenGL (void); -static void S9xDeinitOpenGL(void); -static void S9xInitBlitGL (void); -static void S9xDeinitBlitGL (void); -static void S9xInitOpenGLContext (void); -static void S9xDeinitOpenGLContext (void); -static void S9xInitCoreImage (void); -static void S9xDeinitCoreImage (void); -static void S9xPutImageOpenGL (int, int); -static void S9xPutImageBlitGL (int, int); -static void S9xPutImageBlitGL2 (int, int); -static void GLMakeScreenMesh (GLfloat *, int, int); -static void GLMakeTextureMesh (GLfloat *, int, int, float, float); -static void GLPrepareTexture (bool8, int, int, int, int, int, int); -static inline void RenderBlitScreen (Blitter, int, int, int, int, int, uint16 *); - -enum -{ - kMPBlitFrame = 1, - kMPBlitDone, - kMPBlitNone -}; - -enum -{ - kGL256256 = 0, - kGL256512, - kGL512256, - kGL512512, - kGLBlit2x, - kGLBlit3x, - kGLBlit4x, - kGLNTS256, - kGLNTS512, - kGLNumTextures -}; - -enum -{ - kSC2xNormal = 0, - kSC2xExtend, - kSC2xNHiRes, - kSC2xEHiRes, - kSC2xNInter, - kSC2xEInter, - kSC3xNormal, - kSC3xExtend, - kSC3xNHiRes, - kSC3xEHiRes, - kSCNTNormal, - kSCNTExtend, - kSCNumTextures -}; - -enum -{ - kSCMeshX = 10, - kSCMeshY = 9 -}; - -typedef struct -{ - Blitter blitFn; - int nx; - int srcWidth; - int srcHeight; - int copyWidth; - int copyHeight; - uint16 *gfxBuffer; -} MPData; - -typedef struct -{ - GLint internal_format; - GLint format; - GLint type; - GLenum target; - GLuint textures[kGLNumTextures]; - GLfloat vertex[kGLNumTextures][8]; - GLint texW[kGLNumTextures]; - GLint texH[kGLNumTextures]; - GLboolean rangeExt; - GLint storage_hint; - GLint storage_apple; - GLfloat agp_texturing; -} OpenGLData; +static void S9xInitMetal (void); +static void S9xDeinitMetal(void); +static void S9xPutImageMetal (int, int, uint8 *); static uint16 *gfxScreen[2], *snesScreenA, *snesScreenB; static uint8 *blitGLBuffer; -static MPTaskID taskID = NULL; -static MPQueueID notificationQueue = NULL, - taskQueue = NULL; -static MPSemaphoreID readySemaphore = NULL; -static MPData *mpBlit = NULL; - -static OpenGLData OpenGL; - -static CGImageRef cgGameImage = NULL, - cgBlitImage = NULL; - static int whichBuf = 0; static int textureNum = 0; static int prevBlitWidth, prevBlitHeight; static int imageWidth[2], imageHeight[2]; static int nx = 2; -static GLfloat *scTexArray[kSCNumTextures]; -static GLfloat *scScnArray; - -static struct timeval bencht1, bencht2; - -static const int ntsc_width = SNES_NTSC_OUT_WIDTH(SNES_WIDTH); // 602 +typedef struct +{ + vector_float2 position; + vector_float2 textureCoordinate; +} MetalVertex; +CAMetalLayer *metalLayer = nil; +id metalDevice = nil; +id metalTexture = nil; +id metalCommandQueue = nil; +id metalPipelineState = nil; void InitGraphics (void) { @@ -238,51 +135,6 @@ void DeinitGraphics (void) } } -void DrawPauseScreen (CGContextRef ctx, HIRect bounds) -{ - CGImageRef image; - CGRect rct; - float sh, mh, rofs, ry; - - if ((IPPU.RenderedScreenWidth == 0) || (IPPU.RenderedScreenHeight == 0)) - return; - - sh = (float) ((IPPU.RenderedScreenHeight > 256) ? IPPU.RenderedScreenHeight : IPPU.RenderedScreenHeight * 2); - mh = (float) (SNES_HEIGHT_EXTENDED * 2); - - if (drawoverscan) - { - rofs = (mh - sh) / mh; - ry = sh / mh; - } - else - if (windowExtend) - { - rofs = (mh - sh) / mh / 2.0f; - ry = sh / mh; - } - else - { - rofs = 0.0f; - ry = 1.0f; - } - - image = CreateGameScreenCGImage(); - if (image) - { - CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 1.0f); - CGContextFillRect(ctx, bounds); - - rct = CGRectMake(0.0f, bounds.size.height * rofs, bounds.size.width, bounds.size.height * ry); - CGContextDrawImage(ctx, rct, image); - - CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 0.5f); - CGContextFillRect(ctx, bounds); - - CGImageRelease(image); - } -} - void DrawFreezeDefrostScreen (uint8 *draw) { const int w = SNES_WIDTH << 1, h = SNES_HEIGHT << 1; @@ -291,7 +143,7 @@ void DrawFreezeDefrostScreen (uint8 *draw) imageWidth[1] = imageHeight[1] = 0; prevBlitWidth = prevBlitHeight = 0; - if (nx < 0 && !ciFilterEnable) + if (nx < 0) { for (int y = 0; y < h; y++) memcpy(blitGLBuffer + y * 1024 * 2, draw + y * w * 2, w * 2); @@ -299,345 +151,45 @@ void DrawFreezeDefrostScreen (uint8 *draw) else memcpy(blitGLBuffer, draw, w * h * 2); - S9xPutImageBlitGL2(w, h); + S9xPutImageMetal(w, h, draw); } -void ClearGFXScreen (void) +static void S9xInitMetal (void) { - memset(gfxScreen[0], 0, 512 * 512 * 2); - memset(gfxScreen[1], 0, 512 * 512 * 2); - memset(blitGLBuffer, 0, 1024 * 1024 * 2); - - S9xBlitClearDelta(); - - imageWidth[0] = imageHeight[0] = 0; - imageWidth[1] = imageHeight[1] = 0; - prevBlitWidth = prevBlitHeight = 0; - - CGLSetCurrentContext(s9xView.openGLContext.CGLContextObj); - glViewport(0, 0, glScreenW, glScreenH); - - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - for (int i = 0; i < 2; i++) - { - glClear(GL_COLOR_BUFFER_BIT); - glSwapAPPLE(); - //CGLFlushDrawable(s9xView.openGLContext.CGLContextObj); - } -} - -static void S9xInitFullScreen (void) -{ - [NSCursor hide]; - CGAssociateMouseAndMouseCursorPosition(false); -} - -static void S9xDeinitFullScreen (void) -{ - CGAssociateMouseAndMouseCursorPosition(true); - [NSCursor unhide]; -} - -static void S9xInitWindowMode (void) -{ -} - -static void S9xDeinitWindowMode (void) -{ -} - -static void S9xInitOpenGL (void) -{ - GLint glSwapInterval = vsync ? 1 : 0; - if (extraOptions.benchmark) - glSwapInterval = 0; - CGLSetParameter(s9xView.openGLContext.CGLContextObj, kCGLCPSwapInterval, &glSwapInterval); - CGLSetCurrentContext(s9xView.openGLContext.CGLContextObj); - glScreenW = glScreenBounds.size.width; glScreenH = glScreenBounds.size.height; + + metalLayer = (CAMetalLayer *)s9xView.layer; + //metalLayer.presentsWithTransaction = YES; + + metalDevice = s9xView.device; + + NSError *error = nil; + id defaultLibrary = [metalDevice newDefaultLibraryWithBundle:[NSBundle bundleForClass:[S9xEngine class]] error:&error]; + + MTLRenderPipelineDescriptor *descriptor = [MTLRenderPipelineDescriptor new]; + descriptor.label = @"Snes9x Pipeline"; + descriptor.vertexFunction = [defaultLibrary newFunctionWithName:@"vertexShader"]; + descriptor.fragmentFunction = [defaultLibrary newFunctionWithName:@"samplingShader"]; + descriptor.colorAttachments[0].pixelFormat = s9xView.colorPixelFormat; + + metalPipelineState = [metalDevice newRenderPipelineStateWithDescriptor:descriptor error:&error]; + + if (metalPipelineState == nil) + { + NSLog(@"%@",error); + } + + metalCommandQueue = [metalDevice newCommandQueue]; } -static void S9xDeinitOpenGL (void) +static void S9xDeinitMetal (void) { - CGLSetCurrentContext(NULL); -} - -static void S9xInitBlitGL (void) -{ -} - -static void S9xDeinitBlitGL (void) -{ -} - -static void GLPrepareTexture (bool8 useRange, int texNo, int rangeOnW, int rangeOnH, int rangeOffW, int rangeOffH, int filter) -{ - bool8 rangeAvailable = OpenGL.rangeExt & useRange; - - OpenGL.texW[texNo] = rangeAvailable ? rangeOnW : rangeOffW; - OpenGL.texH[texNo] = rangeAvailable ? rangeOnH : rangeOffH; - - OpenGL.vertex[texNo][0] = 0; - OpenGL.vertex[texNo][1] = 0; - OpenGL.vertex[texNo][2] = rangeAvailable ? rangeOnW : 1; - OpenGL.vertex[texNo][3] = 0; - OpenGL.vertex[texNo][4] = rangeAvailable ? rangeOnW : 1; - OpenGL.vertex[texNo][5] = rangeAvailable ? rangeOnH : 1; - OpenGL.vertex[texNo][6] = 0; - OpenGL.vertex[texNo][7] = rangeAvailable ? rangeOnH : 1; - - glBindTexture(OpenGL.target, OpenGL.textures[texNo]); - - if (rangeAvailable) - { - glTextureRangeAPPLE(OpenGL.target, OpenGL.texW[texNo] * OpenGL.texH[texNo] * 2, GFX.Screen); - glTexParameteri(OpenGL.target, GL_TEXTURE_STORAGE_HINT_APPLE, OpenGL.storage_hint); - } - - glTexParameterf(OpenGL.target, GL_TEXTURE_PRIORITY, OpenGL.agp_texturing); - glTexParameteri(OpenGL.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(OpenGL.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(OpenGL.target, GL_TEXTURE_MAG_FILTER, filter); - glTexParameteri(OpenGL.target, GL_TEXTURE_MIN_FILTER, filter); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexImage2D(OpenGL.target, 0, OpenGL.internal_format, OpenGL.texW[texNo], OpenGL.texH[texNo], 0, OpenGL.format, OpenGL.type, GFX.Screen); -} - -static void GLMakeScreenMesh (GLfloat *vertex3D, int meshx, int meshy) -{ - GLfloat *v; - float warp; - - v = vertex3D; - warp = macCurvatureWarp * 0.001f; - - for (int y = 0; y < meshy; y++) - { - for (int x = 0; x <= meshx; x++) - { - float u1, v1, v2; - - u1 = -1.0f + 2.0f / (float) meshx * (float) x; - v1 = -1.0f + 2.0f / (float) meshy * (float) y; - v2 = -1.0f + 2.0f / (float) meshy * (float) (y + 1); - - *v++ = u1; - *v++ = v2; - *v++ = -1.0f - (u1 * u1 + v2 * v2) * warp; - - *v++ = u1; - *v++ = v1; - *v++ = -1.0f - (u1 * u1 + v1 * v1) * warp; - } - } -} - -static void GLMakeTextureMesh (GLfloat *vertex2D, int meshx, int meshy, float lx, float ly) -{ - GLfloat *v; - - v = vertex2D; - - for (int y = meshy; y > 0; y--) - { - for (int x = 0; x <= meshx; x++) - { - float u1, v1, v2; - - u1 = lx / (float) meshx * (float) x; - v1 = ly / (float) meshy * (float) y; - v2 = ly / (float) meshy * (float) (y - 1); - - *v++ = u1; - *v++ = v2; - - *v++ = u1; - *v++ = v1; - } - } -} - -static void S9xInitOpenGLContext (void) -{ - OpenGL.internal_format = GL_RGB5_A1; - OpenGL.format = GL_BGRA; - OpenGL.type = GL_UNSIGNED_SHORT_1_5_5_5_REV; - OpenGL.rangeExt = gluCheckExtension((const GLubyte *) "GL_APPLE_texture_range", glGetString(GL_EXTENSIONS)); - OpenGL.target = OpenGL.rangeExt ? GL_TEXTURE_RECTANGLE_EXT : GL_TEXTURE_2D; - - OpenGL.storage_apple = extraOptions.glUseClientStrageApple ? 1 : 0; - OpenGL.agp_texturing = extraOptions.glUseTexturePriority ? 0.0f : 1.0f; - switch (extraOptions.glStorageHint) - { - case 1: OpenGL.storage_hint = GL_STORAGE_PRIVATE_APPLE; break; - case 2: OpenGL.storage_hint = GL_STORAGE_CACHED_APPLE; break; - case 3: OpenGL.storage_hint = GL_STORAGE_SHARED_APPLE; break; - } - - if (screencurvature || videoMode >= VIDEOMODE_NTSC_C || extraOptions.glForceNoTextureRectangle) - { - OpenGL.rangeExt = false; - OpenGL.target = GL_TEXTURE_2D; - } - - printf("TextureRange: %s\n", OpenGL.rangeExt ? "enable" : "disable"); - - glDisable(GL_BLEND); - glDisable(GL_DITHER); - glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); - - glEnable(GL_CULL_FACE); - glPolygonMode(GL_FRONT, GL_FILL); - glCullFace(GL_BACK); - - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_RECTANGLE_EXT); - glEnable(OpenGL.target); - - glGenTextures(kGLNumTextures, OpenGL.textures); - - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, OpenGL.storage_apple); - glPixelStorei(GL_UNPACK_ALIGNMENT, 8); - - int filter = (videoMode == VIDEOMODE_SMOOTH) ? GL_LINEAR : GL_NEAREST; - GLPrepareTexture(true, kGL256256, SNES_WIDTH, SNES_HEIGHT_EXTENDED, 256, 256, filter); - GLPrepareTexture(true, kGL256512, SNES_WIDTH, SNES_HEIGHT_EXTENDED * 2, 256, 512, filter); - GLPrepareTexture(true, kGL512256, SNES_WIDTH * 2, SNES_HEIGHT_EXTENDED, 512, 256, filter); - GLPrepareTexture(true, kGL512512, SNES_WIDTH * 2, SNES_HEIGHT_EXTENDED * 2, 512, 512, filter); - GLPrepareTexture(true, kGLBlit2x, SNES_WIDTH * 2, SNES_HEIGHT_EXTENDED * 2, 512, 512, GL_LINEAR); - GLPrepareTexture(true, kGLBlit3x, SNES_WIDTH * 3, SNES_HEIGHT_EXTENDED * 3, 1024, 1024, GL_LINEAR); - GLPrepareTexture(true, kGLBlit4x, SNES_WIDTH * 4, SNES_HEIGHT_EXTENDED * 4, 1024, 1024, GL_LINEAR); - GLPrepareTexture(false, kGLNTS256, 1024, 256, 1024, 256, GL_LINEAR); - GLPrepareTexture(false, kGLNTS512, 1024, 512, 1024, 512, GL_LINEAR); - - if (!screencurvature) - { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - else - { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1.0, 1.0, -1.0, 1.0, 0.95, 5.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - int mesh = (kSCMeshX + 1) * 2 * kSCMeshY * 2; - scTexArray[kSC2xNormal] = new GLfloat [mesh]; - scTexArray[kSC2xExtend] = new GLfloat [mesh]; - scTexArray[kSC2xNHiRes] = new GLfloat [mesh]; - scTexArray[kSC2xEHiRes] = new GLfloat [mesh]; - scTexArray[kSC2xNInter] = new GLfloat [mesh]; - scTexArray[kSC2xEInter] = new GLfloat [mesh]; - scTexArray[kSC3xNormal] = new GLfloat [mesh]; - scTexArray[kSC3xExtend] = new GLfloat [mesh]; - scTexArray[kSC3xNHiRes] = new GLfloat [mesh]; - scTexArray[kSC3xEHiRes] = new GLfloat [mesh]; - scTexArray[kSCNTNormal] = new GLfloat [mesh]; - scTexArray[kSCNTExtend] = new GLfloat [mesh]; - - GLMakeTextureMesh(scTexArray[kSC2xNormal], kSCMeshX, kSCMeshY, 1.0f, 224.0f / 256.0f); - GLMakeTextureMesh(scTexArray[kSC2xExtend], kSCMeshX, kSCMeshY, 1.0f, 239.0f / 256.0f); - GLMakeTextureMesh(scTexArray[kSC2xNHiRes], kSCMeshX, kSCMeshY, 1.0f, 224.0f / 512.0f); - GLMakeTextureMesh(scTexArray[kSC2xEHiRes], kSCMeshX, kSCMeshY, 1.0f, 239.0f / 512.0f); - GLMakeTextureMesh(scTexArray[kSC2xNInter], kSCMeshX, kSCMeshY, 256.0f / 512.0f, 224.0f / 256.0f); - GLMakeTextureMesh(scTexArray[kSC2xEInter], kSCMeshX, kSCMeshY, 256.0f / 512.0f, 239.0f / 256.0f); - GLMakeTextureMesh(scTexArray[kSC3xNormal], kSCMeshX, kSCMeshY, 768.0f / 1024.0f, 672.0f / 1024.0f); - GLMakeTextureMesh(scTexArray[kSC3xExtend], kSCMeshX, kSCMeshY, 768.0f / 1024.0f, 717.0f / 1024.0f); - GLMakeTextureMesh(scTexArray[kSC3xNHiRes], kSCMeshX, kSCMeshY, 768.0f / 1024.0f, 672.0f / 2048.0f); - GLMakeTextureMesh(scTexArray[kSC3xEHiRes], kSCMeshX, kSCMeshY, 768.0f / 1024.0f, 717.0f / 2048.0f); - GLMakeTextureMesh(scTexArray[kSCNTNormal], kSCMeshX, kSCMeshY, (float) ntsc_width / 1024.0f, 224.0f / 256.0f); - GLMakeTextureMesh(scTexArray[kSCNTExtend], kSCMeshX, kSCMeshY, (float) ntsc_width / 1024.0f, 239.0f / 256.0f); - - scScnArray = new GLfloat [(kSCMeshX + 1) * 2 * kSCMeshY * 3]; - GLMakeScreenMesh(scScnArray, kSCMeshX, kSCMeshY); - } - - CGLSetCurrentContext(s9xView.openGLContext.CGLContextObj); - glViewport(0, 0, glScreenW, glScreenH); - - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - for (int i = 0; i < 2; i++) - { - glClear(GL_COLOR_BUFFER_BIT); - //CGLFlushDrawable(s9xView.openGLContext.CGLContextObj); - } -} - -static void S9xDeinitOpenGLContext (void) -{ - if (screencurvature) - { - delete [] scTexArray[kSC2xNormal]; - delete [] scTexArray[kSC2xExtend]; - delete [] scTexArray[kSC2xNHiRes]; - delete [] scTexArray[kSC2xEHiRes]; - delete [] scTexArray[kSC2xNInter]; - delete [] scTexArray[kSC2xEInter]; - delete [] scTexArray[kSC3xNormal]; - delete [] scTexArray[kSC3xExtend]; - delete [] scTexArray[kSC3xNHiRes]; - delete [] scTexArray[kSC3xEHiRes]; - delete [] scTexArray[kSCNTNormal]; - delete [] scTexArray[kSCNTExtend]; - delete [] scScnArray; - - scTexArray[kSC2xNormal] = NULL; - scTexArray[kSC2xExtend] = NULL; - scTexArray[kSC2xNHiRes] = NULL; - scTexArray[kSC2xEHiRes] = NULL; - scTexArray[kSC2xNInter] = NULL; - scTexArray[kSC2xEInter] = NULL; - scTexArray[kSC3xNormal] = NULL; - scTexArray[kSC3xExtend] = NULL; - scTexArray[kSC3xNHiRes] = NULL; - scTexArray[kSC3xEHiRes] = NULL; - scTexArray[kSCNTNormal] = NULL; - scTexArray[kSCNTExtend] = NULL; - scScnArray = NULL; - } - - glDeleteTextures(kGLNumTextures, OpenGL.textures); -} - -static void S9xInitCoreImage (void) -{ - cgGameImage = NULL; - cgBlitImage = NULL; - - InitCoreImageContext(s9xView.openGLContext.CGLContextObj, s9xView.pixelFormat.CGLPixelFormatObj); -} - -static void S9xDeinitCoreImage (void) -{ - DeinitCoreImageContext(); - - if (cgGameImage) - { - CGImageRelease(cgGameImage); - cgGameImage = NULL; - } - - if (cgBlitImage) - { - CGImageRelease(cgBlitImage); - cgBlitImage = NULL; - } + + metalCommandQueue = nil; + metalDevice = nil; + metalTexture = nil; + metalLayer = nil; } void GetGameDisplay (int *w, int *h) @@ -651,9 +203,6 @@ void GetGameDisplay (int *w, int *h) void S9xInitDisplay (int argc, char **argv) { - if (directDisplay) - return; - glScreenBounds = s9xView.frame; unlimitedCursor = CGPointMake(0.0f, 0.0f); @@ -694,58 +243,16 @@ void S9xInitDisplay (int argc, char **argv) break; } - if (fullscreen) - { - S9xInitFullScreen(); - } - else - { - S9xInitWindowMode(); - } - - S9xInitOpenGL(); - - S9xInitOpenGLContext(); - if (ciFilterEnable) - S9xInitCoreImage(); - if (drawingMethod == kDrawingBlitGL) - S9xInitBlitGL(); + S9xInitMetal(); S9xSetSoundMute(false); lastFrame = GetMicroseconds(); - - windowResizeCount = 1; - - gettimeofday(&bencht1, NULL); - - directDisplay = true; } void S9xDeinitDisplay (void) { - if (!directDisplay) - return; - S9xSetSoundMute(true); - - if (drawingMethod == kDrawingBlitGL) - S9xDeinitBlitGL(); - if (ciFilterEnable) - S9xDeinitCoreImage(); - S9xDeinitOpenGLContext(); - - if (fullscreen) - { - S9xDeinitFullScreen(); - } - else - { - S9xDeinitWindowMode(); - } - - S9xDeinitOpenGL(); - - directDisplay = false; + S9xDeinitMetal(); } bool8 S9xInitUpdate (void) @@ -755,12 +262,7 @@ bool8 S9xInitUpdate (void) bool8 S9xDeinitUpdate (int width, int height) { - if (directDisplay) - dispatch_async(dispatch_get_main_queue(),^{ - [s9xView setNeedsDisplay:YES]; - }); - - return (true); + return true; } bool8 S9xContinueUpdate (int width, int height) @@ -768,539 +270,130 @@ bool8 S9xContinueUpdate (int width, int height) return (true); } -static inline void RenderBlitScreen (Blitter Fn, int x, int sW, int sH, int cW, int cH, uint16 *buf) -{ - switch (x) - { - case -1: - (Fn) ((uint8 *) buf, sW * 2, blitGLBuffer, 1024 * 2, sW, sH); - break; - - case -2: - if (sH > SNES_HEIGHT_EXTENDED) - (Fn) ((uint8 *) buf, sW * 2, blitGLBuffer, 1024 * 2, sW, sH); - else - { - uint8 *tmpBuffer = blitGLBuffer + (1024 * 512 * 2); - int aligned = ((ntsc_width + 2) >> 1) << 1; - (Fn) ((uint8 *) buf, sW * 2, tmpBuffer, 1024 * 2, sW, sH); - S9xBlitPixMixedTV1x2(tmpBuffer, 1024 * 2, blitGLBuffer, 1024 * 2, aligned, cH); - cH *= 2; - } - - break; - - default: - int dstbytes = (OpenGL.rangeExt ? cW : ((cW > 512) ? 1024 : ((cW > 256) ? 512 : 256))) * 2; - (Fn) ((uint8 *) buf, sW * 2, blitGLBuffer, dstbytes, sW, sH); - break; - } - - S9xPutImageBlitGL2(cW, cH); -} - void S9xPutImage (int width, int height) { - static float fps = 0.0f; - static long count = 0; - static char text[32]; + if (cfIsWatching) + CheatFinderDrawWatchAddr(); - if (extraOptions.benchmark) - { - uint16 *basePtr; - long delta; - size_t len; + if (Settings.DisplayFrameRate) + { + static int drawnFrames[60] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + static int tableIndex = 0; + int frameCalc = 0; - count++; - - gettimeofday(&bencht2, NULL); - - delta = 1000000 * (bencht2.tv_sec - bencht1.tv_sec) + (bencht2.tv_usec - bencht1.tv_usec); - if (delta > 1000000) - { - fps = (1000000.0f * (float) count) / (float) delta; - count = 0; - - gettimeofday(&bencht1, NULL); - } - - sprintf(text, "%.1f", fps); - - basePtr = GFX.Screen + 1; - len = strlen(text); - - for (unsigned int i = 0; i < len; i++) - { - S9xDisplayChar(basePtr, text[i]); - basePtr += (8 - 1); - } - } - else - { - if (cfIsWatching) - CheatFinderDrawWatchAddr(); - - if (Settings.DisplayFrameRate) - { - static int drawnFrames[60] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - static int tableIndex = 0; - int frameCalc = 0; - - drawnFrames[tableIndex] = skipFrames; - - if (Settings.TurboMode) - { - drawnFrames[tableIndex] = (drawnFrames[tableIndex] + (macFastForwardRate / 2)) / macFastForwardRate; - if (drawnFrames[tableIndex] == 0) - drawnFrames[tableIndex] = 1; - } - - tableIndex = (tableIndex + 1) % 60; - - for (int i = 0; i < 60; i++) - frameCalc += drawnFrames[i]; - - IPPU.DisplayedRenderedFrameCount = (Memory.ROMFramesPerSecond * 60) / frameCalc; - } - } - - switch (drawingMethod) - { - case kDrawingOpenGL: - S9xPutImageOpenGL(width, height); - break; - - case kDrawingBlitGL: - S9xPutImageBlitGL(width, height); - break; - } -} - -static void S9xPutImageOpenGL (int width, int height) -{ - int orig_height = height; - - if ((imageWidth[0] != width) || (imageHeight[0] != height)) - windowResizeCount += 2; - - if (windowResizeCount > 0) - { - if (drawoverscan && (height % SNES_HEIGHT == 0)) - { - int pitch = width << 1; - int extbtm = (height > 256) ? (SNES_HEIGHT_EXTENDED << 1) : SNES_HEIGHT_EXTENDED; - uint32 *extarea = (uint32 *) ((uint8 *) GFX.Screen + height * pitch); - - for (int i = 0; i < (((extbtm - height) * pitch) >> 2); i++) - extarea[i] = 0; - - height = extbtm; - } - - int vh = (height > 256) ? height : (height << 1); - - CGLSetCurrentContext(s9xView.openGLContext.CGLContextObj); - - glViewport(0, 0, glScreenW, glScreenH); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); - - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); - - if (!ciFilterEnable) - { - textureNum = (width <= 256) ? ((height <= 256) ? kGL256256 : kGL256512) : ((height <= 256) ? kGL512256 : kGL512512); - OpenGL.vertex[textureNum][5] = OpenGL.vertex[textureNum][7] = OpenGL.rangeExt ? height : (vh / 512.0f); - glBindTexture(OpenGL.target, OpenGL.textures[textureNum]); - } - else - { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, width, orig_height - height, orig_height, -1, 1); - - if (cgGameImage) - CGImageRelease(cgGameImage); - cgGameImage = CreateGameScreenCGImage(); - } - - imageWidth[0] = width; - imageHeight[0] = height; - - windowResizeCount--; - } - else - { - if (drawoverscan) - height = (height > 256) ? (SNES_HEIGHT_EXTENDED << 1) : SNES_HEIGHT_EXTENDED; - } - - if (!ciFilterEnable) - { - glTexSubImage2D(OpenGL.target, 0, 0, 0, OpenGL.texW[textureNum], OpenGL.texH[textureNum], OpenGL.format, OpenGL.type, GFX.Screen); - - if (!screencurvature && OpenGL.texW[textureNum] > 0) - { - glBegin(GL_QUADS); - - glTexCoord2fv(&OpenGL.vertex[textureNum][6]); - glVertex2f(-1.0f, -1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][4]); - glVertex2f( 1.0f, -1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][2]); - glVertex2f( 1.0f, 1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][0]); - glVertex2f(-1.0f, 1.0f); - - glEnd(); - } - else - { - GLfloat *t, *s; - - t = scTexArray[(height % SNES_HEIGHT) ? kSC2xExtend : kSC2xNormal]; - s = scScnArray; - - for (int i = 0; i < kSCMeshY; i++) - { - glTexCoordPointer(2, GL_FLOAT, 0, t); - glVertexPointer(3, GL_FLOAT, 0, s); - glDrawArrays(GL_TRIANGLE_STRIP, 0, (kSCMeshX + 1) * 2); - - t += (kSCMeshX + 1) * 2 * 2; - s += (kSCMeshX + 1) * 2 * 3; - } - } - - glFinishObjectAPPLE(GL_TEXTURE, OpenGL.textures[textureNum]); - } - else - { - CGRect src; - - src = CGRectMake(0, 0, width, orig_height); - DrawWithCoreImageFilter(src, cgGameImage); - } - - //CGLFlushDrawable(s9xView.openGLContext.CGLContextObj); - glSwapAPPLE(); -} - -static void S9xPutImageBlitGL (int width, int height) -{ - Blitter blitFn; - int copyWidth, copyHeight; - - if ((imageWidth[whichBuf] != width) || (imageHeight[whichBuf] != height)) - { - if ((videoMode == VIDEOMODE_TV) && (width <= 256)) - S9xBlitClearDelta(); - - if (drawoverscan && (height % SNES_HEIGHT == 0)) - { - memset(blitGLBuffer, 0, 1024 * 1024 * 2); - - int pitch = width << 1; - int extbtm = (height > 256) ? (SNES_HEIGHT_EXTENDED << 1) : SNES_HEIGHT_EXTENDED; - uint32 *extarea = (uint32 *) ((uint8 *) GFX.Screen + height * pitch); - - for (int i = 0; i < (((extbtm - height) * pitch) >> 2); i++) - extarea[i] = 0; - - height = extbtm; - } - } - else - { - if (drawoverscan) - height = (height > 256) ? (SNES_HEIGHT_EXTENDED << 1) : SNES_HEIGHT_EXTENDED; - } - - switch (nx) - { - default: - case 2: - if (videoMode == VIDEOMODE_BLEND) - { - if (width <= 256) - { - copyWidth = width * 2; - copyHeight = height; - blitFn = S9xBlitPixBlend2x1; - } - else - { - copyWidth = width; - copyHeight = height; - blitFn = S9xBlitPixBlend1x1; - } - } - else - if (height <= 256) - { - if (width <= 256) - { - copyWidth = width * 2; - copyHeight = height * 2; - - switch (videoMode) - { - default: - case VIDEOMODE_TV: blitFn = S9xBlitPixTV2x2; break; - case VIDEOMODE_SUPEREAGLE: blitFn = S9xBlitPixSuperEagle16; break; - case VIDEOMODE_2XSAI: blitFn = S9xBlitPix2xSaI16; break; - case VIDEOMODE_SUPER2XSAI: blitFn = S9xBlitPixSuper2xSaI16; break; - case VIDEOMODE_EPX: blitFn = S9xBlitPixEPX16; break; - case VIDEOMODE_HQ2X: blitFn = S9xBlitPixHQ2x16; break; - } - } - else - { - if (videoMode == VIDEOMODE_TV) - { - copyWidth = width; - copyHeight = height * 2; - blitFn = S9xBlitPixTV1x2; - } - else - { - copyWidth = width; - copyHeight = height; - blitFn = S9xBlitPixSimple1x1; - } - } - } - else - { - copyWidth = width; - copyHeight = height; - blitFn = S9xBlitPixSimple1x1; - } - - break; - - case 3: - if (width <= 256 && height <= 256) - { - copyWidth = width * 3; - copyHeight = height * 3; - blitFn = S9xBlitPixHQ3x16; - } - else - { - copyWidth = width; - copyHeight = height; - blitFn = S9xBlitPixSimple1x1; - } - - break; - - case 4: - if (width <= 256 && height <= 256) - { - copyWidth = width * 4; - copyHeight = height * 4; - blitFn = S9xBlitPixHQ4x16; - } - else - if (width > 256 && height > 256) - { - copyWidth = width * 2; - copyHeight = height * 2; - blitFn = S9xBlitPixHQ2x16; - } - else - { - copyWidth = width; - copyHeight = height; - blitFn = S9xBlitPixSimple1x1; - } - - break; - - case -1: - case -2: - copyWidth = ntsc_width; - copyHeight = height; - - if (width <= 256) - blitFn = S9xBlitPixNTSC16; - else - blitFn = S9xBlitPixHiResNTSC16; - - break; - } - - imageWidth[whichBuf] = width; - imageHeight[whichBuf] = height; - - RenderBlitScreen(blitFn, nx, width, height, copyWidth, copyHeight, GFX.Screen); -} - -static void S9xPutImageBlitGL2 (int blit_width, int blit_height) -{ - if ((prevBlitWidth != blit_width) || (prevBlitHeight != blit_height)) - windowResizeCount += 2; - - if (windowResizeCount > 0) - { - CGLSetCurrentContext(s9xView.openGLContext.CGLContextObj); - - glViewport(0, 0, glScreenW, glScreenH); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); + drawnFrames[tableIndex] = skipFrames; + if (Settings.TurboMode) { - int sw, sh; - - if (nx < 0) - { - sw = ntsc_width; - sh = ((blit_height % SNES_HEIGHT) ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT) * 2; - } - else - { - sw = SNES_WIDTH * nx; - sh = ((blit_height % SNES_HEIGHT) ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT) * nx; - } - - glViewport((glScreenW - sw) >> 1, (glScreenH - sh) >> 1, sw, sh); + drawnFrames[tableIndex] = (drawnFrames[tableIndex] + (macFastForwardRate / 2)) / macFastForwardRate; + if (drawnFrames[tableIndex] == 0) + drawnFrames[tableIndex] = 1; } - if (!ciFilterEnable) - { - if (nx < 0) - textureNum = (blit_height > 256) ? kGLNTS512 : kGLNTS256; - else - { - switch (blit_width / SNES_WIDTH) - { - default: - case 1: - case 2: textureNum = kGLBlit2x; break; - case 3: textureNum = kGLBlit3x; break; - case 4: textureNum = kGLBlit4x; break; - } - } + tableIndex = (tableIndex + 1) % 60; - if (nx < 0) - { - int sh = (blit_height > 256) ? 512 : 256; - OpenGL.vertex[textureNum][2] = OpenGL.vertex[textureNum][4] = blit_width / 1024.0f; - OpenGL.vertex[textureNum][5] = OpenGL.vertex[textureNum][7] = blit_height / (float) sh; - glPixelStorei(GL_UNPACK_ROW_LENGTH, 1024); - } - else - { - if (OpenGL.rangeExt) - { - OpenGL.vertex[textureNum][2] = OpenGL.vertex[textureNum][4] = blit_width; - OpenGL.vertex[textureNum][5] = OpenGL.vertex[textureNum][7] = blit_height; - glPixelStorei(GL_UNPACK_ROW_LENGTH, blit_width); - } - else - { - int sl = (blit_width > 512) ? 1024 : 512; - int sh = (blit_height > 512) ? 1024 : 512; - OpenGL.vertex[textureNum][2] = OpenGL.vertex[textureNum][4] = blit_width / (float) sl; - OpenGL.vertex[textureNum][5] = OpenGL.vertex[textureNum][7] = blit_height / (float) sh; - glPixelStorei(GL_UNPACK_ROW_LENGTH, (blit_width > 512) ? 1024 : ((blit_width > 256) ? 512 : 256)); - } - } + for (int i = 0; i < 60; i++) + frameCalc += drawnFrames[i]; - glBindTexture(OpenGL.target, OpenGL.textures[textureNum]); - } - else - { - int sl = OpenGL.rangeExt ? blit_width : ((blit_width > 512) ? 1024 : ((blit_width > 256) ? 512 : 256)); + IPPU.DisplayedRenderedFrameCount = (Memory.ROMFramesPerSecond * 60) / frameCalc; + } - glPixelStorei(GL_UNPACK_ROW_LENGTH, sl); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, blit_width, 0, blit_height, -1, 1); - - if (cgBlitImage) - CGImageRelease(cgBlitImage); - cgBlitImage = CreateBlitScreenCGImage(blit_width, blit_height, sl << 1, blitGLBuffer); - } - - prevBlitWidth = blit_width; - prevBlitHeight = blit_height; - - windowResizeCount--; - } - - if (!ciFilterEnable) + uint8 buffer[width * height * 4]; + for (int i = 0; i < width * height; ++i) { - glTexSubImage2D(OpenGL.target, 0, 0, 0, OpenGL.texW[textureNum], OpenGL.texH[textureNum], OpenGL.format, OpenGL.type, blitGLBuffer); - - if (!screencurvature) - { - glBegin(GL_QUADS); - - glTexCoord2fv(&OpenGL.vertex[textureNum][6]); - glVertex2f(-1.0f, -1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][4]); - glVertex2f( 1.0f, -1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][2]); - glVertex2f( 1.0f, 1.0f); - glTexCoord2fv(&OpenGL.vertex[textureNum][0]); - glVertex2f(-1.0f, 1.0f); - - glEnd(); - } - else - { - GLfloat *t, *s; - int tex; - - if (nx < 0) - tex = (blit_height % SNES_HEIGHT) ? kSCNTExtend : kSCNTNormal; - else - if (blit_width > blit_height * 2) - { - if (blit_width / SNES_WIDTH != 3) - tex = (blit_height % SNES_HEIGHT) ? kSC2xEHiRes : kSC2xNHiRes; - else - tex = (blit_height % SNES_HEIGHT) ? kSC3xEHiRes : kSC3xNHiRes; - } - else - if (blit_width > blit_height) - { - if (blit_width / SNES_WIDTH != 3) - tex = (blit_height % SNES_HEIGHT) ? kSC2xExtend : kSC2xNormal; - else - tex = (blit_height % SNES_HEIGHT) ? kSC3xExtend : kSC3xNormal; - } - else - tex = (blit_height % SNES_HEIGHT) ? kSC2xEInter : kSC2xNInter; - - t = scTexArray[tex]; - s = scScnArray; - - for (int i = 0; i < kSCMeshY; i++) - { - glTexCoordPointer(2, GL_FLOAT, 0, t); - glVertexPointer(3, GL_FLOAT, 0, s); - glDrawArrays(GL_TRIANGLE_STRIP, 0, (kSCMeshX + 1) * 2); - - t += (kSCMeshX + 1) * 2 * 2; - s += (kSCMeshX + 1) * 2 * 3; - } - } - - glFinishObjectAPPLE(GL_TEXTURE, OpenGL.textures[textureNum]); + uint16 pixel = GFX.Screen[i]; + unsigned int red = (pixel & FIRST_COLOR_MASK_RGB555) >> 10; + unsigned int green = (pixel & SECOND_COLOR_MASK_RGB555) >> 5; + unsigned int blue = (pixel & THIRD_COLOR_MASK_RGB555); + + red = ( red * 527 + 23 ) >> 6; + green = ( green * 527 + 23 ) >> 6; + blue = ( blue * 527 + 23 ) >> 6; + + int offset = i * 4; + buffer[offset++] = (uint8)red; + buffer[offset++] = (uint8)green; + buffer[offset++] = (uint8)blue; + buffer[offset] = 0xFF; } - else + + S9xPutImageMetal(width, height, buffer); +} + + +static void S9xPutImageMetal (int width, int height, uint8 *buffer) +{ + CGSize layerSize = metalLayer.bounds.size; + + MTLTextureDescriptor *descriptor = [MTLTextureDescriptor new]; + descriptor.pixelFormat = MTLPixelFormatRGBA8Unorm; + descriptor.width = width; + descriptor.height = height; + + metalTexture = [metalDevice newTextureWithDescriptor:descriptor]; + + [metalTexture replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:buffer bytesPerRow:width * 4]; + + float vWidth = layerSize.width / 2.0; + float vHeight = layerSize.height / 2.0; + + const MetalVertex verticies[] = { - CGRect src; + // Pixel positions, Texture coordinates + { { vWidth, -vHeight }, { 1.f, 1.f } }, + { { -vWidth, -vHeight }, { 0.f, 1.f } }, + { { -vWidth, vHeight }, { 0.f, 0.f } }, - src = CGRectMake(0, 0, blit_width, blit_height); - DrawWithCoreImageFilter(src, cgBlitImage); - } + { { vWidth, -vHeight }, { 1.f, 1.f } }, + { { -vWidth, vHeight }, { 0.f, 0.f } }, + { { vWidth, vHeight }, { 1.f, 0.f } }, + }; + + id vertexBuffer = [metalDevice newBufferWithBytes:verticies length:sizeof(verticies) options:MTLResourceStorageModeShared]; + + id commandBuffer = [metalCommandQueue commandBuffer]; + commandBuffer.label = @"Snes9x command buffer"; + + id drawable = [metalLayer nextDrawable]; + + MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor]; - glSwapAPPLE(); + renderPassDescriptor.colorAttachments[0].texture = drawable.texture; + renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; + renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(0.0,0.0,0.0,1.0); + + if(renderPassDescriptor != nil) + { + id renderEncoder = + [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; + renderEncoder.label = @"Snes9x render encoder"; + + vector_uint2 viewportSize = { static_cast(layerSize.width), static_cast(layerSize.height) }; + + CGFloat scale = metalLayer.contentsScale; + [renderEncoder setViewport:(MTLViewport){0.0, 0.0, layerSize.width * scale, layerSize.height * scale, -1.0, 1.0 }]; + + [renderEncoder setRenderPipelineState:metalPipelineState]; + + [renderEncoder setVertexBuffer:vertexBuffer + offset:0 + atIndex:0]; + + [renderEncoder setVertexBytes:&viewportSize + length:sizeof(viewportSize) + atIndex:1]; + + [renderEncoder setFragmentTexture:metalTexture atIndex:0]; + + [renderEncoder drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:6]; + + [renderEncoder endEncoding]; + + [commandBuffer presentDrawable:drawable]; + } + + [commandBuffer commit]; } void S9xTextMode (void) diff --git a/macosx/shaders.metal b/macosx/shaders.metal new file mode 100644 index 00000000..b2b1f4ce --- /dev/null +++ b/macosx/shaders.metal @@ -0,0 +1,52 @@ +#include +#include + +using namespace metal; + +typedef struct +{ + vector_float2 position; + vector_float2 textureCoordinate; +} MetalVertex; + +typedef struct +{ + // The [[position]] attribute qualifier of this member indicates this value is + // the clip space position of the vertex when this structure is returned from + // the vertex shader + float4 position [[position]]; + + // Since this member does not have a special attribute qualifier, the rasterizer + // will interpolate its value with values of other vertices making up the triangle + // and pass that interpolated value to the fragment shader for each fragment in + // that triangle. + float2 textureCoordinate; + +} RasterizerData; + +// Vertex Function +vertex RasterizerData +vertexShader(uint vertexID [[ vertex_id ]], constant MetalVertex *vertexArray [[ buffer(0) ]], constant vector_uint2 *viewportSizePointer [[ buffer(1) ]]) +{ + + RasterizerData out; + + float2 pixelSpacePosition = vertexArray[vertexID].position.xy; + + float2 viewportSize = float2(*viewportSizePointer); + + out.position = vector_float4(0.0, 0.0, 0.0, 1.0); + out.position.xy = pixelSpacePosition / (viewportSize / 2.0); + out.textureCoordinate = vertexArray[vertexID].textureCoordinate; + + return out; +} + +fragment float4 +samplingShader(RasterizerData in [[stage_in]], texture2d colorTexture [[ texture(0) ]]) +{ + constexpr sampler textureSampler (mag_filter::nearest, min_filter::nearest); + const half4 colorSample = colorTexture.sample(textureSampler, in.textureCoordinate); + return float4(colorSample); +} + diff --git a/macosx/snes9x.xcodeproj/project.pbxproj b/macosx/snes9x.xcodeproj/project.pbxproj index fe34c955..3ab94bbf 100755 --- a/macosx/snes9x.xcodeproj/project.pbxproj +++ b/macosx/snes9x.xcodeproj/project.pbxproj @@ -35,19 +35,16 @@ 307C861D22D29DD2001B879E /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 307C861C22D29DD2001B879E /* GLUT.framework */; }; 307C861E22D29DF1001B879E /* mac-controls.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA809FA108F8F2420072CDFB /* mac-controls.mm */; }; 307C861F22D29E0D001B879E /* mac-screenshot.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA2DBC0D0510ABE700A80003 /* mac-screenshot.mm */; }; - 307C862022D29E29001B879E /* mac-appleevent.mm in Sources */ = {isa = PBXBuildFile; fileRef = EACDDBB004D6A89700A80003 /* mac-appleevent.mm */; }; 307C862122D29E29001B879E /* mac-audio.mm in Sources */ = {isa = PBXBuildFile; fileRef = EADE6347052E5C4300A80003 /* mac-audio.mm */; }; 307C862222D29E29001B879E /* mac-cart.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67004AC7FCE00A80003 /* mac-cart.mm */; }; 307C862322D29E29001B879E /* mac-cheat.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67204AC7FCE00A80003 /* mac-cheat.mm */; }; 307C862422D29E29001B879E /* mac-cheatfinder.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67404AC7FCE00A80003 /* mac-cheatfinder.mm */; }; 307C862622D29E29001B879E /* mac-cocoatools.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA85C24E0B4EC13300F5F9C9 /* mac-cocoatools.mm */; }; - 307C862722D29E29001B879E /* mac-coreimage.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA0C952E08364A4A009307B4 /* mac-coreimage.mm */; }; 307C862922D29E29001B879E /* mac-gworld.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67904AC7FCE00A80003 /* mac-gworld.mm */; }; 307C862A22D29E29001B879E /* mac-keyboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67D04AC7FCE00A80003 /* mac-keyboard.mm */; }; 307C862B22D29E29001B879E /* mac-multicart.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA26BBD50B3676E800A570B5 /* mac-multicart.mm */; }; 307C862C22D29E29001B879E /* mac-musicbox.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB67F04AC7FCE00A80003 /* mac-musicbox.mm */; }; 307C862D22D29E29001B879E /* mac-netplay.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA1605500639E735004412AB /* mac-netplay.mm */; }; - 307C862E22D29E29001B879E /* mac-prefs.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAE0E96B04D584B700A80003 /* mac-prefs.mm */; }; 307C863022D29E29001B879E /* mac-render.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA942A50059B0F9000D7D022 /* mac-render.mm */; }; 307C863222D29E29001B879E /* mac-snes9x.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */; }; 307C863322D29E29001B879E /* mac-stringtools.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68804AC7FCE00A80003 /* mac-stringtools.mm */; }; @@ -61,6 +58,9 @@ 3082C4262378BCE80081CA7C /* FakeResources.c in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4212378BCE80081CA7C /* FakeResources.c */; }; 3082C4272378BCE80081CA7C /* FakeResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 3082C4222378BCE80081CA7C /* FakeResources.h */; }; 3082C42A2379199F0081CA7C /* S9xApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4292379199F0081CA7C /* S9xApplication.m */; }; + 30A6F62423B2771A00630584 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30A6F62323B2771A00630584 /* MetalKit.framework */; }; + 30A6F62623B29EF500630584 /* shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 30A6F62523B29EF500630584 /* shaders.metal */; }; + 30A6F62823B29F8200630584 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30A6F62723B29F8200630584 /* Metal.framework */; }; 30D15CF322CE6B5A005BC352 /* snes9x_framework.h in Headers */ = {isa = PBXBuildFile; fileRef = 30D15CF122CE6B5A005BC352 /* snes9x_framework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30D15CFC22CE6B74005BC352 /* sha256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90A20DDB18D00C038E9 /* sha256.cpp */; }; 30D15CFE22CE6B74005BC352 /* bml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90620DDB15B00C038E9 /* bml.cpp */; }; @@ -285,6 +285,9 @@ 3082C4222378BCE80081CA7C /* FakeResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeResources.h; sourceTree = ""; }; 3082C4282379199F0081CA7C /* S9xApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xApplication.h; sourceTree = ""; }; 3082C4292379199F0081CA7C /* S9xApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xApplication.m; sourceTree = ""; }; + 30A6F62323B2771A00630584 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; + 30A6F62523B29EF500630584 /* shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = shaders.metal; sourceTree = ""; }; + 30A6F62723B29F8200630584 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; 30AD1D1E22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 30AD1D1F22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 30AD1D2022FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = folder; name = en; path = "en.lproj/Snes9x Help"; sourceTree = ""; }; @@ -359,8 +362,6 @@ CFEFAE9010EAC92B00FB081A /* snes_ntsc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snes_ntsc.h; sourceTree = ""; }; EA00D01D0A5A9956000C58E0 /* logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logger.cpp; sourceTree = ""; usesTabs = 1; }; EA00D01F0A5A998F000C58E0 /* logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logger.h; sourceTree = ""; usesTabs = 1; }; - EA0C952D08364A4A009307B4 /* mac-coreimage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-coreimage.h"; sourceTree = ""; }; - EA0C952E08364A4A009307B4 /* mac-coreimage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-coreimage.mm"; sourceTree = ""; }; EA0C95D808364AAE009307B4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; EA16053E0639E655004412AB /* mac-netplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-netplay.h"; sourceTree = ""; }; EA1605500639E735004412AB /* mac-netplay.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-netplay.mm"; sourceTree = ""; }; @@ -435,7 +436,6 @@ EAA7B5F307609F76001BAB8B /* winout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = winout.h; sourceTree = ""; }; EAB7319C0527033000A80003 /* memmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = memmap.cpp; sourceTree = ""; usesTabs = 1; }; EAC5E47003D2D9C800A80004 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = ""; }; - EACDDBB004D6A89700A80003 /* mac-appleevent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-appleevent.mm"; sourceTree = ""; }; EAD978980555059300E8BBFD /* mac-global_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-global_prefix.h"; sourceTree = ""; }; EADE6347052E5C4300A80003 /* mac-audio.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-audio.mm"; sourceTree = ""; }; EADE6349052E5C5300A80003 /* mac-audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-audio.h"; sourceTree = ""; }; @@ -502,8 +502,6 @@ EAE061EB0526CCB900A80003 /* tile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = tile.cpp; sourceTree = ""; usesTabs = 1; }; EAE061EC0526CCB900A80003 /* tile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = tile.h; sourceTree = ""; usesTabs = 1; }; EAE0E96604D582B700A80003 /* mac-os.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-os.mm"; sourceTree = ""; }; - EAE0E96B04D584B700A80003 /* mac-prefs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-prefs.mm"; sourceTree = ""; }; - EAECB66D04AC7FCD00A80003 /* mac-appleevent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-appleevent.h"; sourceTree = ""; }; EAECB67004AC7FCE00A80003 /* mac-cart.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-cart.mm"; sourceTree = ""; }; EAECB67104AC7FCE00A80003 /* mac-cart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-cart.h"; sourceTree = ""; }; EAECB67204AC7FCE00A80003 /* mac-cheat.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-cheat.mm"; sourceTree = ""; }; @@ -520,7 +518,6 @@ EAECB68004AC7FCE00A80003 /* mac-musicbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-musicbox.h"; sourceTree = ""; }; EAECB68204AC7FCE00A80003 /* mac-os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-os.h"; sourceTree = ""; usesTabs = 1; }; EAECB68304AC7FCE00A80003 /* mac-prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-prefix.h"; sourceTree = ""; }; - EAECB68504AC7FCE00A80003 /* mac-prefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-prefs.h"; sourceTree = ""; }; EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-snes9x.mm"; sourceTree = ""; usesTabs = 1; }; EAECB68704AC7FCE00A80003 /* mac-snes9x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-snes9x.h"; sourceTree = ""; }; EAECB68804AC7FCE00A80003 /* mac-stringtools.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-stringtools.mm"; sourceTree = ""; }; @@ -542,6 +539,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 30A6F62823B29F8200630584 /* Metal.framework in Frameworks */, + 30A6F62423B2771A00630584 /* MetalKit.framework in Frameworks */, 3042F7E3232E9BDD00C03F5E /* Carbon.framework in Frameworks */, 308092F92320B06F006A2860 /* Quartz.framework in Frameworks */, 308092F72320B041006A2860 /* CoreGraphics.framework in Frameworks */, @@ -583,6 +582,7 @@ ); name = "Snes9x CVS"; sourceTree = ""; + usesTabs = 1; }; 20286C2AFDCF999611CA2CEA /* Sources */ = { isa = PBXGroup; @@ -613,6 +613,8 @@ 3045A1EB22D03C420092B97D /* Frameworks */ = { isa = PBXGroup; children = ( + 30A6F62723B29F8200630584 /* Metal.framework */, + 30A6F62323B2771A00630584 /* MetalKit.framework */, 3042F7E2232E9BDD00C03F5E /* Carbon.framework */, 3042F7E0232E9BD200C03F5E /* CoreServices.framework */, 308092F82320B06F006A2860 /* Quartz.framework */, @@ -910,14 +912,12 @@ EAECB65C04AC7FCD00A80003 /* macosx */ = { isa = PBXGroup; children = ( - EAECB66D04AC7FCD00A80003 /* mac-appleevent.h */, EADE6349052E5C5300A80003 /* mac-audio.h */, EAECB67104AC7FCE00A80003 /* mac-cart.h */, EAECB67304AC7FCE00A80003 /* mac-cheat.h */, EAECB67504AC7FCE00A80003 /* mac-cheatfinder.h */, EA85C24D0B4EC13300F5F9C9 /* mac-cocoatools.h */, EA809F9D08F8F2190072CDFB /* mac-controls.h */, - EA0C952D08364A4A009307B4 /* mac-coreimage.h */, EA2DBC0A0510ABE700A80003 /* mac-file.h */, EAECB67A04AC7FCE00A80003 /* mac-gworld.h */, EAECB67C04AC7FCE00A80003 /* mac-joypad.h */, @@ -926,7 +926,6 @@ EAECB68004AC7FCE00A80003 /* mac-musicbox.h */, EA16053E0639E655004412AB /* mac-netplay.h */, EAECB68204AC7FCE00A80003 /* mac-os.h */, - EAECB68504AC7FCE00A80003 /* mac-prefs.h */, EA2DBC090510ABE700A80003 /* mac-render.h */, EA2DBC070510ABE700A80003 /* mac-screenshot.h */, EAECB68704AC7FCE00A80003 /* mac-snes9x.h */, @@ -936,14 +935,12 @@ EA362C3E086119D100FBE476 /* HID_Utilities_External.h */, CF3E45BD137349960077DE32 /* zconf.h */, CF3E45D013734A920077DE32 /* zlib.h */, - EACDDBB004D6A89700A80003 /* mac-appleevent.mm */, EADE6347052E5C4300A80003 /* mac-audio.mm */, EAECB67004AC7FCE00A80003 /* mac-cart.mm */, EAECB67204AC7FCE00A80003 /* mac-cheat.mm */, EAECB67404AC7FCE00A80003 /* mac-cheatfinder.mm */, EA85C24E0B4EC13300F5F9C9 /* mac-cocoatools.mm */, EA809FA108F8F2420072CDFB /* mac-controls.mm */, - EA0C952E08364A4A009307B4 /* mac-coreimage.mm */, EA2DBC0C0510ABE700A80003 /* mac-file.mm */, EAECB67904AC7FCE00A80003 /* mac-gworld.mm */, EAECB67B04AC7FCE00A80003 /* mac-joypad.mm */, @@ -952,7 +949,6 @@ EAECB67F04AC7FCE00A80003 /* mac-musicbox.mm */, EA1605500639E735004412AB /* mac-netplay.mm */, EAE0E96604D582B700A80003 /* mac-os.mm */, - EAE0E96B04D584B700A80003 /* mac-prefs.mm */, EA942A50059B0F9000D7D022 /* mac-render.mm */, EA2DBC0D0510ABE700A80003 /* mac-screenshot.mm */, EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */, @@ -979,6 +975,7 @@ EA3D2F580A26085800BDACCC /* libHIDUtilities_u.a */, CF3E42491372D48F0077DE32 /* libz_u.a */, 30CCAD422290472E00549AED /* Info.plist */, + 30A6F62523B29EF500630584 /* shaders.metal */, ); path = macosx; sourceTree = ""; @@ -1215,19 +1212,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 307C862022D29E29001B879E /* mac-appleevent.mm in Sources */, 307C862122D29E29001B879E /* mac-audio.mm in Sources */, 307C862222D29E29001B879E /* mac-cart.mm in Sources */, 307C862322D29E29001B879E /* mac-cheat.mm in Sources */, 307C862422D29E29001B879E /* mac-cheatfinder.mm in Sources */, 307C862622D29E29001B879E /* mac-cocoatools.mm in Sources */, - 307C862722D29E29001B879E /* mac-coreimage.mm in Sources */, 307C862922D29E29001B879E /* mac-gworld.mm in Sources */, 307C862A22D29E29001B879E /* mac-keyboard.mm in Sources */, 307C862B22D29E29001B879E /* mac-multicart.mm in Sources */, 307C862C22D29E29001B879E /* mac-musicbox.mm in Sources */, 307C862D22D29E29001B879E /* mac-netplay.mm in Sources */, - 307C862E22D29E29001B879E /* mac-prefs.mm in Sources */, 307C863022D29E29001B879E /* mac-render.mm in Sources */, 307C863222D29E29001B879E /* mac-snes9x.mm in Sources */, 307C863322D29E29001B879E /* mac-stringtools.mm in Sources */, @@ -1250,6 +1244,7 @@ 30D15D3522CE6B74005BC352 /* cpuexec.cpp in Sources */, 30D15D3622CE6B74005BC352 /* cpuops.cpp in Sources */, 30D15D3722CE6B74005BC352 /* crosshairs.cpp in Sources */, + 30A6F62623B29EF500630584 /* shaders.metal in Sources */, 30D15D3822CE6B74005BC352 /* debug.cpp in Sources */, 30D15D3922CE6B74005BC352 /* dma.cpp in Sources */, 307C861222D27C53001B879E /* tileimpl-n1x1.cpp in Sources */,