Cocoa Port (OpenEmu Plug-in): Update the OpenEmu plug-in to work using the latest version of the SDK.
This commit is contained in:
parent
4abfa4466a
commit
509d117f5f
|
@ -546,7 +546,7 @@ void ClientInputHandler::ProcessInputs()
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( (this->_execControl != NULL) && (this->_execControl->GetExecutionBehaviorApplied() != ExecutionBehavior_FrameJump) )
|
||||
if ( (this->_execControl == NULL) || ((this->_execControl != NULL) && (this->_execControl->GetExecutionBehaviorApplied() != ExecutionBehavior_FrameJump)) )
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
|
|
|
@ -4832,7 +4832,6 @@
|
|||
"\"$(SRCROOT)/openemu\"",
|
||||
);
|
||||
GCC_PREFIX_HEADER = openemu/DeSmuME_Prefix_OpenEmu.pch;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
INFOPLIST_FILE = "openemu/Info (OpenEmu Plug-in).plist";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_NAME = DeSmuME;
|
||||
|
@ -4850,7 +4849,6 @@
|
|||
"\"$(SRCROOT)/openemu\"",
|
||||
);
|
||||
GCC_PREFIX_HEADER = openemu/DeSmuME_Prefix_OpenEmu.pch;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
INFOPLIST_FILE = "openemu/Info (OpenEmu Plug-in).plist";
|
||||
LLVM_LTO = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
|
|
|
@ -22,30 +22,44 @@
|
|||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "ABB3C6461501BC6D00E0C22E"
|
||||
BuildableName = "DeSmuME.oecoreplugin"
|
||||
BlueprintName = "DeSmuME (OpenEmu Plug-in)"
|
||||
ReferencedContainer = "container:DeSmuME (Latest).xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
|
|
|
@ -250,7 +250,7 @@
|
|||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright ©2007-2015 DeSmuME Team. All rights reserved.</string>
|
||||
<string>Copyright ©2007-2017 DeSmuME Team. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
|
@ -250,7 +250,7 @@
|
|||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright ©2007-2015 DeSmuME Team. All rights reserved.</string>
|
||||
<string>Copyright ©2007-2017 DeSmuME Team. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
|
@ -28,14 +28,20 @@
|
|||
#undef BOOL
|
||||
#endif
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_11) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11)
|
||||
#define ENABLE_APPLE_METAL
|
||||
#if defined(PORT_VERSION_OS_X_APP)
|
||||
#define ENABLE_SHARED_FETCH_OBJECT
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SHARED_FETCH_OBJECT) && defined(MAC_OS_X_VERSION_10_11) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11)
|
||||
#define ENABLE_APPLE_METAL
|
||||
#endif
|
||||
|
||||
#define VIDEO_FLUSH_TIME_LIMIT_OFFSET 8 // The amount of time, in seconds, to wait for a flush to occur on a given CVDisplayLink before stopping it.
|
||||
|
||||
class GPUEventHandlerOSX;
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
|
||||
typedef std::map<CGDirectDisplayID, CVDisplayLinkRef> DisplayLinksActiveMap;
|
||||
typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
|
||||
|
||||
|
@ -77,6 +83,8 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
|
|||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@interface CocoaDSGPU : NSObject
|
||||
{
|
||||
UInt32 gpuStateFlags;
|
||||
|
@ -87,6 +95,7 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
|
|||
|
||||
OSSpinLock spinlockGpuState;
|
||||
GPUEventHandlerOSX *gpuEvent;
|
||||
|
||||
GPUClientFetchObject *fetchObject;
|
||||
}
|
||||
|
||||
|
@ -95,8 +104,6 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
|
|||
@property (assign) NSUInteger gpuScale;
|
||||
@property (assign) NSUInteger gpuColorFormat;
|
||||
@property (readonly) pthread_rwlock_t *gpuFrameRWLock;
|
||||
@property (readonly, nonatomic) GPUClientFetchObject *fetchObject;
|
||||
@property (readonly, nonatomic) MacClientSharedObject *sharedData;
|
||||
|
||||
@property (assign) BOOL layerMainGPU;
|
||||
@property (assign) BOOL layerMainBG0;
|
||||
|
@ -124,7 +131,13 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
|
|||
@property (assign) NSUInteger render3DTextureScalingFactor;
|
||||
@property (assign) BOOL render3DFragmentSamplingHack;
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
@property (readonly, nonatomic) GPUClientFetchObject *fetchObject;
|
||||
@property (readonly, nonatomic) MacClientSharedObject *sharedData;
|
||||
|
||||
- (void) setOutputList:(NSMutableArray *)theOutputList mutexPtr:(pthread_mutex_t *)theMutex;
|
||||
#endif
|
||||
|
||||
- (BOOL) gpuStateByBit:(const UInt32)stateBit;
|
||||
- (NSString *) render3DRenderingEngineString;
|
||||
- (void) clearWithColor:(const uint16_t)colorBGRA5551;
|
||||
|
@ -137,6 +150,8 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
|
||||
static void* RunFetchThread(void *arg);
|
||||
|
||||
CVReturn MacDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
||||
|
@ -145,6 +160,7 @@ CVReturn MacDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||
CVOptionFlags flagsIn,
|
||||
CVOptionFlags *flagsOut,
|
||||
void *displayLinkContext);
|
||||
#endif
|
||||
|
||||
bool OSXOpenGLRendererInit();
|
||||
bool OSXOpenGLRendererBegin();
|
||||
|
|
|
@ -95,8 +95,6 @@ public:
|
|||
@dynamic gpuScale;
|
||||
@dynamic gpuColorFormat;
|
||||
@dynamic gpuFrameRWLock;
|
||||
@synthesize fetchObject;
|
||||
@dynamic sharedData;
|
||||
|
||||
@dynamic layerMainGPU;
|
||||
@dynamic layerMainBG0;
|
||||
|
@ -124,6 +122,10 @@ public:
|
|||
@dynamic render3DTextureScalingFactor;
|
||||
@dynamic render3DFragmentSamplingHack;
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
@synthesize fetchObject;
|
||||
@dynamic sharedData;
|
||||
#endif
|
||||
|
||||
- (id)init
|
||||
{
|
||||
|
@ -186,6 +188,7 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
if (fetchObject == NULL)
|
||||
{
|
||||
fetchObject = new MacOGLClientFetchObject;
|
||||
|
@ -193,6 +196,7 @@ public:
|
|||
|
||||
fetchObject->Init();
|
||||
gpuEvent->SetFetchObject(fetchObject);
|
||||
#endif
|
||||
|
||||
[self clearWithColor:0x8000];
|
||||
|
||||
|
@ -253,14 +257,20 @@ public:
|
|||
{
|
||||
gpuEvent->Render3DLock();
|
||||
gpuEvent->FramebufferLockWrite();
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
pthread_rwlock_wrlock([[self sharedData] rwlockFramebufferAtIndex:0]);
|
||||
pthread_rwlock_wrlock([[self sharedData] rwlockFramebufferAtIndex:1]);
|
||||
#endif
|
||||
|
||||
GPU->SetCustomFramebufferSize(theDimensions.width, theDimensions.height);
|
||||
fetchObject->SetFetchBuffers(GPU->GetDisplayInfo());
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
fetchObject->SetFetchBuffers(GPU->GetDisplayInfo());
|
||||
pthread_rwlock_unlock([[self sharedData] rwlockFramebufferAtIndex:1]);
|
||||
pthread_rwlock_unlock([[self sharedData] rwlockFramebufferAtIndex:0]);
|
||||
#endif
|
||||
|
||||
gpuEvent->FramebufferUnlock();
|
||||
gpuEvent->Render3DUnlock();
|
||||
}
|
||||
|
@ -304,14 +314,20 @@ public:
|
|||
// Change the color format.
|
||||
gpuEvent->Render3DLock();
|
||||
gpuEvent->FramebufferLockWrite();
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
pthread_rwlock_wrlock([[self sharedData] rwlockFramebufferAtIndex:0]);
|
||||
pthread_rwlock_wrlock([[self sharedData] rwlockFramebufferAtIndex:1]);
|
||||
#endif
|
||||
|
||||
GPU->SetColorFormat((NDSColorFormat)colorFormat);
|
||||
fetchObject->SetFetchBuffers(GPU->GetDisplayInfo());
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
fetchObject->SetFetchBuffers(GPU->GetDisplayInfo());
|
||||
pthread_rwlock_unlock([[self sharedData] rwlockFramebufferAtIndex:1]);
|
||||
pthread_rwlock_unlock([[self sharedData] rwlockFramebufferAtIndex:0]);
|
||||
#endif
|
||||
|
||||
gpuEvent->FramebufferUnlock();
|
||||
gpuEvent->Render3DUnlock();
|
||||
}
|
||||
|
@ -332,10 +348,12 @@ public:
|
|||
return gpuEvent->GetFrameRWLock();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
- (void) setOutputList:(NSMutableArray *)theOutputList mutexPtr:(pthread_mutex_t *)theMutex
|
||||
{
|
||||
[(MacClientSharedObject *)fetchObject->GetClientData() setOutputList:theOutputList mutex:theMutex];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void) setRender3DRenderingEngine:(NSInteger)rendererID
|
||||
{
|
||||
|
@ -851,15 +869,20 @@ public:
|
|||
- (void) clearWithColor:(const uint16_t)colorBGRA5551
|
||||
{
|
||||
gpuEvent->FramebufferLockWrite();
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
const u8 bufferIndex = GPU->GetDisplayInfo().bufferIndex;
|
||||
pthread_rwlock_wrlock([[self sharedData] rwlockFramebufferAtIndex:bufferIndex]);
|
||||
#endif
|
||||
|
||||
GPU->ClearWithColor(colorBGRA5551);
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
pthread_rwlock_unlock([[self sharedData] rwlockFramebufferAtIndex:bufferIndex]);
|
||||
#endif
|
||||
gpuEvent->FramebufferUnlock();
|
||||
|
||||
#if !defined(PORT_VERSION_OPENEMU)
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
[[self sharedData] signalFetchAtIndex:bufferIndex];
|
||||
#endif
|
||||
}
|
||||
|
@ -886,6 +909,8 @@ public:
|
|||
|
||||
@end
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
|
||||
@implementation MacClientSharedObject
|
||||
|
||||
@synthesize GPUFetchObject;
|
||||
|
@ -1206,6 +1231,8 @@ public:
|
|||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
|
||||
GPUEventHandlerOSX::GPUEventHandlerOSX()
|
||||
|
@ -1245,7 +1272,7 @@ void GPUEventHandlerOSX::DidFrameBegin(bool isFrameSkipRequested, const u8 targe
|
|||
{
|
||||
this->FramebufferLockWrite();
|
||||
|
||||
#if !defined(PORT_VERSION_OPENEMU)
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
if (!isFrameSkipRequested)
|
||||
{
|
||||
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)this->_fetchObject->GetClientData();
|
||||
|
@ -1256,7 +1283,7 @@ void GPUEventHandlerOSX::DidFrameBegin(bool isFrameSkipRequested, const u8 targe
|
|||
|
||||
void GPUEventHandlerOSX::DidFrameEnd(bool isFrameSkipped, const NDSDisplayInfo &latestDisplayInfo)
|
||||
{
|
||||
#if !defined(PORT_VERSION_OPENEMU)
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)this->_fetchObject->GetClientData();
|
||||
if (!isFrameSkipped)
|
||||
{
|
||||
|
@ -1267,7 +1294,7 @@ void GPUEventHandlerOSX::DidFrameEnd(bool isFrameSkipped, const NDSDisplayInfo &
|
|||
|
||||
this->FramebufferUnlock();
|
||||
|
||||
#if !defined(PORT_VERSION_OPENEMU)
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
if (!isFrameSkipped)
|
||||
{
|
||||
[sharedViewObject signalFetchAtIndex:latestDisplayInfo.bufferIndex];
|
||||
|
@ -1371,6 +1398,8 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
|
|||
CGLPBufferObj OSXOpenGLRendererPBuffer = NULL;
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef ENABLE_SHARED_FETCH_OBJECT
|
||||
|
||||
static void* RunFetchThread(void *arg)
|
||||
{
|
||||
MacClientSharedObject *sharedData = (MacClientSharedObject *)arg;
|
||||
|
@ -1392,6 +1421,8 @@ CVReturn MacDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||
return kCVReturnSuccess;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool OSXOpenGLRendererInit()
|
||||
{
|
||||
static bool isContextAlreadyCreated = false;
|
||||
|
|
|
@ -18,18 +18,20 @@
|
|||
<string>v0.9.12 (OpenEmu Plug-in)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.9.12</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<string>yes</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2012-2015 DeSmuME Team. All rights reserved.</string>
|
||||
<string>Copyright © 2012-2017 DeSmuME Team. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>OEGameCoreController</string>
|
||||
<key>OEGameCoreClass</key>
|
||||
<string>NDSGameCore</string>
|
||||
<key>OEGameCorePlayerCount</key>
|
||||
<string>1</string>
|
||||
<key>OEGameCoreOptions</key>
|
||||
<dict>
|
||||
<key>openemu.system.nds</key>
|
||||
|
@ -38,15 +40,17 @@
|
|||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>OEGameCorePlayerCount</key>
|
||||
<string>1</string>
|
||||
<key>OEProjectURL</key>
|
||||
<string>http://desmume.org/</string>
|
||||
<key>OESystemIdentifiers</key>
|
||||
<array>
|
||||
<string>openemu.system.nds</string>
|
||||
</array>
|
||||
<key>SUFeedURL</key>
|
||||
<string>https://raw.github.com/OpenEmu/OpenEmu-Update/master/desmume_appcast.xml</string>
|
||||
<key>SUEnableAutomaticChecks</key>
|
||||
<string>1</string>
|
||||
<key>SUFeedURL</key>
|
||||
<string>https://raw.github.com/OpenEmu/OpenEmu-Update/master/desmume_appcast.xml</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2012-2015 DeSmuME team
|
||||
Copyright (C) 2012-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -39,7 +39,7 @@
|
|||
NSInteger displayMode;
|
||||
OEIntRect displayRect;
|
||||
OEIntSize displayAspectRatio;
|
||||
NSInteger inputID[OENDSButtonCount]; // Key = OpenEmu's input ID, Value = DeSmuME's input ID
|
||||
NSUInteger inputID[OENDSButtonCount]; // Key = OpenEmu's input ID, Value = DeSmuME's input ID
|
||||
|
||||
OSSpinLock spinlockDisplayMode;
|
||||
pthread_rwlock_t rwlockCoreExecute;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#import "cocoa_firmware.h"
|
||||
#import "cocoa_GPU.h"
|
||||
#import "cocoa_input.h"
|
||||
#import "ClientDisplayView.h"
|
||||
#import "ClientInputHandler.h"
|
||||
#import "OESoundInterface.h"
|
||||
#import "OENDSSystemResponderClient.h"
|
||||
|
||||
|
@ -57,21 +59,21 @@ volatile bool execute = true;
|
|||
touchLocation.x = 0;
|
||||
touchLocation.y = 0;
|
||||
|
||||
inputID[OENDSButtonUp] = DSControllerState_Up;
|
||||
inputID[OENDSButtonDown] = DSControllerState_Down;
|
||||
inputID[OENDSButtonLeft] = DSControllerState_Left;
|
||||
inputID[OENDSButtonRight] = DSControllerState_Right;
|
||||
inputID[OENDSButtonA] = DSControllerState_A;
|
||||
inputID[OENDSButtonB] = DSControllerState_B;
|
||||
inputID[OENDSButtonX] = DSControllerState_X;
|
||||
inputID[OENDSButtonY] = DSControllerState_Y;
|
||||
inputID[OENDSButtonL] = DSControllerState_L;
|
||||
inputID[OENDSButtonR] = DSControllerState_R;
|
||||
inputID[OENDSButtonStart] = DSControllerState_Start;
|
||||
inputID[OENDSButtonSelect] = DSControllerState_Select;
|
||||
inputID[OENDSButtonMicrophone] = DSControllerState_Microphone;
|
||||
inputID[OENDSButtonLid] = DSControllerState_Lid;
|
||||
inputID[OENDSButtonDebug] = DSControllerState_Debug;
|
||||
inputID[OENDSButtonUp] = NDSInputID_Up;
|
||||
inputID[OENDSButtonDown] = NDSInputID_Down;
|
||||
inputID[OENDSButtonLeft] = NDSInputID_Left;
|
||||
inputID[OENDSButtonRight] = NDSInputID_Right;
|
||||
inputID[OENDSButtonA] = NDSInputID_A;
|
||||
inputID[OENDSButtonB] = NDSInputID_B;
|
||||
inputID[OENDSButtonX] = NDSInputID_X;
|
||||
inputID[OENDSButtonY] = NDSInputID_Y;
|
||||
inputID[OENDSButtonL] = NDSInputID_L;
|
||||
inputID[OENDSButtonR] = NDSInputID_R;
|
||||
inputID[OENDSButtonStart] = NDSInputID_Start;
|
||||
inputID[OENDSButtonSelect] = NDSInputID_Select;
|
||||
inputID[OENDSButtonMicrophone] = NDSInputID_Microphone;
|
||||
inputID[OENDSButtonLid] = NDSInputID_Lid;
|
||||
inputID[OENDSButtonDebug] = NDSInputID_Debug;
|
||||
|
||||
// Set up the emulation core
|
||||
CommonSettings.advanced_timing = true;
|
||||
|
@ -86,7 +88,7 @@ volatile bool execute = true;
|
|||
|
||||
// Set up the DS controller
|
||||
cdsController = [[[[CocoaDSController alloc] init] retain] autorelease];
|
||||
[cdsController setMicMode:MicrophoneMode_InternalNoise];
|
||||
[cdsController startHardwareMicDevice];
|
||||
|
||||
// Set up the cheat system
|
||||
cdsCheats = [[[[CocoaDSCheatManager alloc] init] retain] autorelease];
|
||||
|
@ -105,7 +107,7 @@ volatile bool execute = true;
|
|||
openEmuSoundInterfaceBuffer = [self ringBufferAtIndex:0];
|
||||
|
||||
NSInteger result = SPU_ChangeSoundCore(SNDCORE_OPENEMU, (int)SPU_BUFFER_BYTES);
|
||||
if(result == -1)
|
||||
if (result == -1)
|
||||
{
|
||||
SPU_ChangeSoundCore(SNDCORE_DUMMY, 0);
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ volatile bool execute = true;
|
|||
- (NSInteger) displayMode
|
||||
{
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
NSInteger theMode = displayMode;
|
||||
const NSInteger theMode = displayMode;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
|
||||
return theMode;
|
||||
|
@ -187,46 +189,7 @@ volatile bool execute = true;
|
|||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - Execution
|
||||
|
||||
- (BOOL)rendersToOpenGL
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - ABSTRACT METHODS
|
||||
|
||||
- (void)resetEmulation
|
||||
{
|
||||
pthread_rwlock_wrlock(&rwlockCoreExecute);
|
||||
NDS_Reset();
|
||||
pthread_rwlock_unlock(&rwlockCoreExecute);
|
||||
execute = true;
|
||||
}
|
||||
|
||||
- (void)executeFrameSkippingFrame:(BOOL)skip
|
||||
{
|
||||
if (skip)
|
||||
{
|
||||
NDS_SkipNextFrame();
|
||||
}
|
||||
|
||||
[self executeFrame];
|
||||
}
|
||||
|
||||
- (void)executeFrame
|
||||
{
|
||||
[cdsController flush];
|
||||
|
||||
NDS_beginProcessingInput();
|
||||
NDS_endProcessingInput();
|
||||
|
||||
pthread_rwlock_wrlock(&rwlockCoreExecute);
|
||||
NDS_exec<false>();
|
||||
pthread_rwlock_unlock(&rwlockCoreExecute);
|
||||
|
||||
SPU_Emulate_user();
|
||||
}
|
||||
#pragma mark - Starting
|
||||
|
||||
- (BOOL)loadFileAtPath:(NSString*)path
|
||||
{
|
||||
|
@ -258,12 +221,75 @@ volatile bool execute = true;
|
|||
return isRomLoaded;
|
||||
}
|
||||
|
||||
#pragma mark - Execution
|
||||
|
||||
- (NSTimeInterval)frameInterval
|
||||
{
|
||||
return DS_FRAMES_PER_SECOND;
|
||||
}
|
||||
|
||||
- (void)executeFrame
|
||||
{
|
||||
ClientInputHandler *inputHandler = [cdsController inputHandler];
|
||||
inputHandler->ProcessInputs();
|
||||
inputHandler->ApplyInputs();
|
||||
|
||||
pthread_rwlock_wrlock(&rwlockCoreExecute);
|
||||
NDS_exec<false>();
|
||||
pthread_rwlock_unlock(&rwlockCoreExecute);
|
||||
|
||||
SPU_Emulate_user();
|
||||
}
|
||||
|
||||
- (void)resetEmulation
|
||||
{
|
||||
pthread_rwlock_wrlock(&rwlockCoreExecute);
|
||||
NDS_Reset();
|
||||
pthread_rwlock_unlock(&rwlockCoreExecute);
|
||||
execute = true;
|
||||
}
|
||||
|
||||
- (void)executeFrameSkippingFrame:(BOOL)skip
|
||||
{
|
||||
if (skip)
|
||||
{
|
||||
NDS_SkipNextFrame();
|
||||
}
|
||||
|
||||
[self executeFrame];
|
||||
}
|
||||
|
||||
#pragma mark - Video
|
||||
|
||||
- (const void *)getVideoBufferWithHint:(void *)hint
|
||||
{
|
||||
return GPU->GetDisplayInfo().masterNativeBuffer;
|
||||
}
|
||||
|
||||
- (OEGameCoreRendering)gameCoreRendering
|
||||
{
|
||||
return OEGameCoreRendering2DVideo;
|
||||
}
|
||||
|
||||
- (BOOL)hasAlternateRenderingThread
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)needsDoubleBufferedFBO
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (OEIntSize)bufferSize
|
||||
{
|
||||
return OEIntSizeMake(GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
}
|
||||
|
||||
- (OEIntRect)screenRect
|
||||
{
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
OEIntRect theRect = displayRect;
|
||||
const OEIntRect theRect = displayRect;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
|
||||
return theRect;
|
||||
|
@ -272,64 +298,27 @@ volatile bool execute = true;
|
|||
- (OEIntSize)aspectSize
|
||||
{
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
OEIntSize theAspectRatio = displayAspectRatio;
|
||||
const OEIntSize theAspectRatio = displayAspectRatio;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
|
||||
return theAspectRatio;
|
||||
}
|
||||
|
||||
- (OEIntSize)bufferSize
|
||||
{
|
||||
return OEIntSizeMake(GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
}
|
||||
|
||||
- (const void *)videoBuffer
|
||||
{
|
||||
return GPU->GetDisplayInfo().masterNativeBuffer;
|
||||
}
|
||||
|
||||
- (GLenum)pixelFormat
|
||||
{
|
||||
return GL_RGBA;
|
||||
}
|
||||
|
||||
- (GLenum)pixelType
|
||||
{
|
||||
return GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
}
|
||||
|
||||
- (GLenum)pixelFormat
|
||||
{
|
||||
return GL_RGBA;
|
||||
}
|
||||
|
||||
- (GLenum)internalPixelFormat
|
||||
{
|
||||
return GL_RGB5_A1;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)frameInterval
|
||||
{
|
||||
return DS_FRAMES_PER_SECOND;
|
||||
}
|
||||
|
||||
- (void)changeDisplayMode
|
||||
{
|
||||
switch (displayMode)
|
||||
{
|
||||
case ClientDisplayMode_Main:
|
||||
[self setDisplayMode:ClientDisplayMode_Touch];
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Touch:
|
||||
[self setDisplayMode:ClientDisplayMode_Dual];
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Dual:
|
||||
[self setDisplayMode:ClientDisplayMode_Main];
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Audio
|
||||
|
||||
- (NSUInteger)audioBufferCount
|
||||
|
@ -342,16 +331,16 @@ volatile bool execute = true;
|
|||
return SPU_NUMBER_CHANNELS;
|
||||
}
|
||||
|
||||
- (NSUInteger)audioBitDepth
|
||||
{
|
||||
return SPU_SAMPLE_RESOLUTION;
|
||||
}
|
||||
|
||||
- (double)audioSampleRate
|
||||
{
|
||||
return SPU_SAMPLE_RATE;
|
||||
}
|
||||
|
||||
- (NSUInteger)audioBitDepth
|
||||
{
|
||||
return SPU_SAMPLE_RESOLUTION;
|
||||
}
|
||||
|
||||
- (NSUInteger)channelCountForBuffer:(NSUInteger)buffer
|
||||
{
|
||||
return [self channelCount];
|
||||
|
@ -367,6 +356,74 @@ volatile bool execute = true;
|
|||
return [self audioSampleRate];
|
||||
}
|
||||
|
||||
#pragma mark - Save States
|
||||
|
||||
- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void(^)(BOOL success, NSError *error))block
|
||||
{
|
||||
BOOL fileSuccess = [CocoaDSFile saveState:[NSURL fileURLWithPath:fileName]];
|
||||
|
||||
if (block != nil)
|
||||
{
|
||||
block(fileSuccess, nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadStateFromFileAtPath:(NSString *)fileName completionHandler:(void(^)(BOOL success, NSError *error))block
|
||||
{
|
||||
BOOL fileSuccess = [CocoaDSFile loadState:[NSURL fileURLWithPath:fileName]];
|
||||
|
||||
if (block != nil)
|
||||
{
|
||||
block(fileSuccess, nil);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Optional
|
||||
|
||||
- (NSTrackingAreaOptions)mouseTrackingOptions
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma mark - Cheats - Optional
|
||||
|
||||
- (void)setCheat:(NSString *)code setType:(NSString *)type setEnabled:(BOOL)enabled
|
||||
{
|
||||
// This method can be used for both adding a new cheat or setting the enable
|
||||
// state on an existing cheat, so be sure to account for both cases.
|
||||
|
||||
// First check if the cheat exists.
|
||||
CocoaDSCheatItem *cheatItem = (CocoaDSCheatItem *)[addedCheatsDict objectForKey:code];
|
||||
|
||||
if (cheatItem == nil)
|
||||
{
|
||||
// If the cheat doesn't already exist, then create a new one and add it.
|
||||
cheatItem = [[[CocoaDSCheatItem alloc] init] autorelease];
|
||||
[cheatItem setCheatType:CHEAT_TYPE_ACTION_REPLAY]; // Default to Action Replay for now
|
||||
[cheatItem setFreezeType:0];
|
||||
[cheatItem setDescription:@""]; // OpenEmu takes care of this
|
||||
[cheatItem setCode:code];
|
||||
[cheatItem setMemAddress:0x00000000]; // UNUSED
|
||||
[cheatItem setBytes:1]; // UNUSED
|
||||
[cheatItem setValue:0]; // UNUSED
|
||||
|
||||
[cheatItem setEnabled:enabled];
|
||||
[[self cdsCheats] add:cheatItem];
|
||||
|
||||
// OpenEmu doesn't currently save cheats per game, so assume that the
|
||||
// cheat list is short and that code strings are unique. This allows
|
||||
// us to get away with simply saving the cheat code string and hashing
|
||||
// for it later.
|
||||
[addedCheatsDict setObject:cheatItem forKey:code];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the cheat does exist, then just set its enable state.
|
||||
[cheatItem setEnabled:enabled];
|
||||
[[self cdsCheats] update:cheatItem];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Input
|
||||
|
||||
- (oneway void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player
|
||||
|
@ -432,65 +489,25 @@ volatile bool execute = true;
|
|||
[cdsController setTouchState:NO location:touchLocation];
|
||||
}
|
||||
|
||||
- (NSTrackingAreaOptions)mouseTrackingOptions
|
||||
- (void)changeDisplayMode
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void)settingWasSet:(id)aValue forKey:(NSString *)keyName
|
||||
{
|
||||
DLog(@"keyName = %@", keyName);
|
||||
//[self doesNotImplementSelector:_cmd];
|
||||
}
|
||||
|
||||
#pragma mark - Save State
|
||||
|
||||
- (BOOL)saveStateToFileAtPath:(NSString *)fileName
|
||||
{
|
||||
return [CocoaDSFile saveState:[NSURL fileURLWithPath:fileName]];
|
||||
}
|
||||
|
||||
- (BOOL)loadStateFromFileAtPath:(NSString *)fileName
|
||||
{
|
||||
return [CocoaDSFile loadState:[NSURL fileURLWithPath:fileName]];
|
||||
}
|
||||
|
||||
#pragma mark - Miscellaneous
|
||||
|
||||
- (void)setCheat:(NSString *)code setType:(NSString *)type setEnabled:(BOOL)enabled
|
||||
{
|
||||
// This method can be used for both adding a new cheat or setting the enable
|
||||
// state on an existing cheat, so be sure to account for both cases.
|
||||
|
||||
// First check if the cheat exists.
|
||||
CocoaDSCheatItem *cheatItem = (CocoaDSCheatItem *)[addedCheatsDict objectForKey:code];
|
||||
|
||||
if (cheatItem == nil)
|
||||
switch (displayMode)
|
||||
{
|
||||
// If the cheat doesn't already exist, then create a new one and add it.
|
||||
cheatItem = [[[CocoaDSCheatItem alloc] init] autorelease];
|
||||
[cheatItem setCheatType:CHEAT_TYPE_ACTION_REPLAY]; // Default to Action Replay for now
|
||||
[cheatItem setFreezeType:0];
|
||||
[cheatItem setDescription:@""]; // OpenEmu takes care of this
|
||||
[cheatItem setCode:code];
|
||||
[cheatItem setMemAddress:0x00000000]; // UNUSED
|
||||
[cheatItem setBytes:1]; // UNUSED
|
||||
[cheatItem setValue:0]; // UNUSED
|
||||
|
||||
[cheatItem setEnabled:enabled];
|
||||
[[self cdsCheats] add:cheatItem];
|
||||
|
||||
// OpenEmu doesn't currently save cheats per game, so assume that the
|
||||
// cheat list is short and that code strings are unique. This allows
|
||||
// us to get away with simply saving the cheat code string and hashing
|
||||
// for it later.
|
||||
[addedCheatsDict setObject:cheatItem forKey:code];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the cheat does exist, then just set its enable state.
|
||||
[cheatItem setEnabled:enabled];
|
||||
[[self cdsCheats] update:cheatItem];
|
||||
case ClientDisplayMode_Main:
|
||||
[self setDisplayMode:ClientDisplayMode_Touch];
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Touch:
|
||||
[self setDisplayMode:ClientDisplayMode_Dual];
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Dual:
|
||||
[self setDisplayMode:ClientDisplayMode_Main];
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2012-2015 DeSmuME team
|
||||
Copyright (C) 2012-2017 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -82,7 +82,20 @@ void SNDOpenEmuUpdateAudio(s16 *buffer, u32 num_samples)
|
|||
}
|
||||
|
||||
u32 SNDOpenEmuGetAudioSpace()
|
||||
{
|
||||
{
|
||||
// The latest version of the OpenEmu API (as of 11/11/2017) renames [OERingBuffer usedBytes]
|
||||
// to [OERingBuffer freeBytes]. Due to poor planning on their part, using [OERingBuffer freeBytes]
|
||||
// on the current release version of OpenEmu.app, v2.0.5, will cause the plug-in to fail due to
|
||||
// [OERingBuffer freeBytes] not being available in that version.
|
||||
//
|
||||
// Therefore, let's make a note of the problem here and revert OpenEmuBase.framework back to a
|
||||
// version before the method renaming broke things, then use the older-named method instead.
|
||||
//
|
||||
// TODO: Use the newer-named method, [OERingBuffer freeBytes], when a newer version of OpenEmu.app
|
||||
// is finally released. Or maybe wait for the OpenEmu Team to bring back [OERingBuffer usedBytes]
|
||||
// and let them deprecate it correctly.
|
||||
|
||||
//return (u32)[openEmuSoundInterfaceBuffer freeBytes] / SPU_SAMPLE_SIZE;
|
||||
return (u32)[openEmuSoundInterfaceBuffer usedBytes] / SPU_SAMPLE_SIZE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue