Mac: Lightly tested Metal renderer

This commit is contained in:
Michael Buckley 2019-12-21 07:09:04 -08:00
parent 402fa9aed6
commit aa64f39dac
13 changed files with 300 additions and 3952 deletions

BIN
macosx/.DS_Store vendored

Binary file not shown.

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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 <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <OpenGL/OpenGL.h>
#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);
}
}

View File

@ -23,39 +23,12 @@
#define _mac_os_h_
#import <Cocoa/Cocoa.h>
#import <MetalKit/MetalKit.h>
#import <os/lock.h>
#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);

View File

@ -45,13 +45,11 @@
#import <pthread.h>
#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:^
{

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,6 @@
void InitGraphics (void);
void DeinitGraphics (void);
void DrawPauseScreen (CGContextRef, HIRect);
void ClearGFXScreen (void);
void DrawFreezeDefrostScreen (uint8 *);
void GetGameDisplay (int *, int *);

File diff suppressed because it is too large Load Diff

52
macosx/shaders.metal Normal file
View File

@ -0,0 +1,52 @@
#include <metal_stdlib>
#include <simd/simd.h>
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<half> colorTexture [[ texture(0) ]])
{
constexpr sampler textureSampler (mag_filter::nearest, min_filter::nearest);
const half4 colorSample = colorTexture.sample(textureSampler, in.textureCoordinate);
return float4(colorSample);
}

View File

@ -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 = "<group>"; };
3082C4282379199F0081CA7C /* S9xApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xApplication.h; sourceTree = "<group>"; };
3082C4292379199F0081CA7C /* S9xApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xApplication.m; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
30AD1D1F22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
30AD1D2022FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = folder; name = en; path = "en.lproj/Snes9x Help"; sourceTree = "<group>"; };
@ -359,8 +362,6 @@
CFEFAE9010EAC92B00FB081A /* snes_ntsc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snes_ntsc.h; sourceTree = "<group>"; };
EA00D01D0A5A9956000C58E0 /* logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logger.cpp; sourceTree = "<group>"; usesTabs = 1; };
EA00D01F0A5A998F000C58E0 /* logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logger.h; sourceTree = "<group>"; usesTabs = 1; };
EA0C952D08364A4A009307B4 /* mac-coreimage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-coreimage.h"; sourceTree = "<group>"; };
EA0C952E08364A4A009307B4 /* mac-coreimage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-coreimage.mm"; sourceTree = "<group>"; };
EA0C95D808364AAE009307B4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
EA16053E0639E655004412AB /* mac-netplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-netplay.h"; sourceTree = "<group>"; };
EA1605500639E735004412AB /* mac-netplay.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-netplay.mm"; sourceTree = "<group>"; };
@ -435,7 +436,6 @@
EAA7B5F307609F76001BAB8B /* winout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = winout.h; sourceTree = "<group>"; };
EAB7319C0527033000A80003 /* memmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = memmap.cpp; sourceTree = "<group>"; usesTabs = 1; };
EAC5E47003D2D9C800A80004 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
EACDDBB004D6A89700A80003 /* mac-appleevent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-appleevent.mm"; sourceTree = "<group>"; };
EAD978980555059300E8BBFD /* mac-global_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-global_prefix.h"; sourceTree = "<group>"; };
EADE6347052E5C4300A80003 /* mac-audio.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-audio.mm"; sourceTree = "<group>"; };
EADE6349052E5C5300A80003 /* mac-audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-audio.h"; sourceTree = "<group>"; };
@ -502,8 +502,6 @@
EAE061EB0526CCB900A80003 /* tile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = tile.cpp; sourceTree = "<group>"; usesTabs = 1; };
EAE061EC0526CCB900A80003 /* tile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = tile.h; sourceTree = "<group>"; usesTabs = 1; };
EAE0E96604D582B700A80003 /* mac-os.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-os.mm"; sourceTree = "<group>"; };
EAE0E96B04D584B700A80003 /* mac-prefs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-prefs.mm"; sourceTree = "<group>"; };
EAECB66D04AC7FCD00A80003 /* mac-appleevent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-appleevent.h"; sourceTree = "<group>"; };
EAECB67004AC7FCE00A80003 /* mac-cart.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-cart.mm"; sourceTree = "<group>"; };
EAECB67104AC7FCE00A80003 /* mac-cart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-cart.h"; sourceTree = "<group>"; };
EAECB67204AC7FCE00A80003 /* mac-cheat.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-cheat.mm"; sourceTree = "<group>"; };
@ -520,7 +518,6 @@
EAECB68004AC7FCE00A80003 /* mac-musicbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-musicbox.h"; sourceTree = "<group>"; };
EAECB68204AC7FCE00A80003 /* mac-os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-os.h"; sourceTree = "<group>"; usesTabs = 1; };
EAECB68304AC7FCE00A80003 /* mac-prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-prefix.h"; sourceTree = "<group>"; };
EAECB68504AC7FCE00A80003 /* mac-prefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-prefs.h"; sourceTree = "<group>"; };
EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-snes9x.mm"; sourceTree = "<group>"; usesTabs = 1; };
EAECB68704AC7FCE00A80003 /* mac-snes9x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "mac-snes9x.h"; sourceTree = "<group>"; };
EAECB68804AC7FCE00A80003 /* mac-stringtools.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = "mac-stringtools.mm"; sourceTree = "<group>"; };
@ -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 = "<group>";
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 = "<group>";
@ -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 */,