Cocoa OpenEmu Plug-in:
- Ensure that the OpenEmu data directory exists before ROM loading. - Add future support for changing the DS display mode. (Not yet implemented.) - A lot of general code cleanup.
This commit is contained in:
parent
5b11947f77
commit
e214a9b6c7
|
@ -17,21 +17,25 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenEmuBase/OEGameCore.h>
|
||||
#import <OpenEmuBase/OERingBuffer.h>
|
||||
#import "OENDSSystemResponderClient.h"
|
||||
#include "../ringbuffer.h"
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
@class CocoaDSFirmware;
|
||||
@class CocoaDSMic;
|
||||
|
||||
|
||||
@interface NDSGameCore : OEGameCore
|
||||
{
|
||||
bool *input;
|
||||
CocoaDSFirmware *firmware;
|
||||
CocoaDSMic *microphone;
|
||||
NSInteger displayMode;
|
||||
OEIntRect displayRect;
|
||||
|
||||
OSSpinLock spinlockDisplayMode;
|
||||
}
|
||||
|
||||
@property (retain) CocoaDSFirmware *firmware;
|
||||
@property (retain) CocoaDSMic *microphone;
|
||||
@property (assign) NSInteger displayMode;
|
||||
|
||||
@end
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#import "cocoa_mic.h"
|
||||
#import "cocoa_output.h"
|
||||
#import "OESoundInterface.h"
|
||||
#import "OENDSSystemResponderClient.h"
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
#include "../../path.h"
|
||||
#include "../../NDSSystem.h"
|
||||
#include "../../render3D.h"
|
||||
#undef BOOL
|
||||
|
@ -34,6 +34,7 @@
|
|||
|
||||
@synthesize firmware;
|
||||
@synthesize microphone;
|
||||
@dynamic displayMode;
|
||||
|
||||
- (id)init
|
||||
{
|
||||
|
@ -43,17 +44,20 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
// Set up input handling
|
||||
input = (bool *)calloc(sizeof(bool), OENDSButtonCount);
|
||||
|
||||
microphone = [[CocoaDSMic alloc] init];
|
||||
microphone.mode = MICMODE_INTERNAL_NOISE;
|
||||
|
||||
// Set up the emulation core
|
||||
CommonSettings.advanced_timing = true;
|
||||
[CocoaDSCore startupCore];
|
||||
|
||||
// Set up the DS firmware using the internal firmware
|
||||
firmware = [[CocoaDSFirmware alloc] init];
|
||||
[firmware update];
|
||||
|
||||
// Set up the 3D renderer
|
||||
NSUInteger numberCores = [[NSProcessInfo processInfo] activeProcessorCount];
|
||||
if (numberCores >= 4)
|
||||
{
|
||||
|
@ -71,10 +75,9 @@
|
|||
CommonSettings.num_cores = numberCores;
|
||||
NDS_3D_ChangeCore(CORE3DLIST_SWRASTERIZE);
|
||||
|
||||
// Set up the sound core
|
||||
CommonSettings.spu_advanced = true;
|
||||
CommonSettings.spuInterpolationMode = SPUInterpolation_Cosine;
|
||||
|
||||
// Set up the sound core
|
||||
openEmuSoundInterfaceBuffer = [self ringBufferAtIndex:0];
|
||||
|
||||
NSInteger result = SPU_ChangeSoundCore(SNDCORE_OPENEMU, (int)SPU_BUFFER_BYTES);
|
||||
|
@ -86,6 +89,11 @@
|
|||
SPU_SetSynchMode(SPU_SYNC_MODE_SYNCHRONOUS, SPU_SYNC_METHOD_P);
|
||||
SPU_SetVolume(100);
|
||||
|
||||
// Set up the DS display
|
||||
displayMode = DS_DISPLAY_TYPE_COMBO;
|
||||
displayRect = OERectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
|
||||
spinlockDisplayMode = OS_SPINLOCK_INIT;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -103,6 +111,44 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSInteger) displayMode
|
||||
{
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
NSInteger theMode = displayMode;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
|
||||
return theMode;
|
||||
}
|
||||
|
||||
- (void) setDisplayMode:(NSInteger)theMode
|
||||
{
|
||||
OEIntRect newDisplayRect;
|
||||
|
||||
switch (theMode)
|
||||
{
|
||||
case DS_DISPLAY_TYPE_MAIN:
|
||||
newDisplayRect = OERectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
|
||||
break;
|
||||
|
||||
case DS_DISPLAY_TYPE_TOUCH:
|
||||
newDisplayRect = OERectMake(0, GPU_DISPLAY_HEIGHT + 1, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
|
||||
break;
|
||||
|
||||
case DS_DISPLAY_TYPE_COMBO:
|
||||
newDisplayRect = OERectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
displayMode = theMode;
|
||||
displayRect = newDisplayRect;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark Execution
|
||||
|
@ -136,7 +182,8 @@
|
|||
|
||||
- (BOOL)loadFileAtPath:(NSString*)path
|
||||
{
|
||||
NSURL *openEmuDataURL = [NSURL fileURLWithPath:[self batterySavesDirectoryPath]];
|
||||
NSString *openEmuDataPath = [self batterySavesDirectoryPath];
|
||||
NSURL *openEmuDataURL = [NSURL fileURLWithPath:openEmuDataPath];
|
||||
|
||||
[CocoaDSFile addURLToURLDictionary:openEmuDataURL groupKey:@PATH_OPEN_EMU fileKind:@"ROM"];
|
||||
[CocoaDSFile addURLToURLDictionary:openEmuDataURL groupKey:@PATH_OPEN_EMU fileKind:@"ROM Save"];
|
||||
|
@ -150,6 +197,11 @@
|
|||
|
||||
[CocoaDSFile setupAllFilePathsWithURLDictionary:@PATH_OPEN_EMU];
|
||||
|
||||
// Ensure that the OpenEmu data directory exists before loading the ROM.
|
||||
NSFileManager *fileManager = [[NSFileManager alloc] init];
|
||||
[fileManager createDirectoryAtPath:openEmuDataPath withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
[fileManager release];
|
||||
|
||||
return [CocoaDSFile loadRom:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
|
||||
|
@ -157,12 +209,16 @@
|
|||
|
||||
- (OEIntRect)screenRect
|
||||
{
|
||||
return (OEIntRect){{}, [self bufferSize]};
|
||||
OSSpinLockLock(&spinlockDisplayMode);
|
||||
OEIntRect theRect = displayRect;
|
||||
OSSpinLockUnlock(&spinlockDisplayMode);
|
||||
|
||||
return theRect;
|
||||
}
|
||||
|
||||
- (OEIntSize)bufferSize
|
||||
{
|
||||
return OESizeMake(256, 384);
|
||||
return OESizeMake(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
|
||||
}
|
||||
|
||||
- (const void *)videoBuffer
|
||||
|
@ -316,5 +372,4 @@
|
|||
return [CocoaDSFile loadState:[NSURL fileURLWithPath:fileName]];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "OESoundInterface.h"
|
||||
#import "OESoundInterface.h"
|
||||
|
||||
#import "cocoa_globals.h"
|
||||
|
||||
#include "cocoa_globals.h"
|
||||
|
||||
OERingBuffer *openEmuSoundInterfaceBuffer = nil;
|
||||
|
||||
|
@ -43,7 +44,6 @@ SoundInterface_struct *SNDCoreList[] = {
|
|||
|
||||
int SNDOpenEmuInit(int buffer_size)
|
||||
{
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
[openEmuSoundInterfaceBuffer setLength:buffer_size];
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue