Cocoa Port:
- Add support for SLOT-1 devices. - New feature: Add new SLOT-1 Manager for handling SLOT-1 devices. Use the Emulation > Show SLOT-1 Manager menu option.
This commit is contained in:
parent
31b7f554b9
commit
664e7391bc
Binary file not shown.
|
@ -19,6 +19,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#include <pthread.h>
|
||||
#include <libkern/OSAtomic.h>
|
||||
#include <string>
|
||||
#import "cocoa_util.h"
|
||||
|
||||
|
||||
|
@ -56,6 +57,7 @@ typedef struct
|
|||
NSInteger prevCoreState;
|
||||
BOOL isSpeedLimitEnabled;
|
||||
CGFloat speedScalar;
|
||||
std::string _slot1R4Path;
|
||||
|
||||
NSUInteger emulationFlags;
|
||||
BOOL emuFlagAdvancedBusLevelTiming;
|
||||
|
@ -68,6 +70,10 @@ typedef struct
|
|||
BOOL emuFlagDebugConsole;
|
||||
BOOL emuFlagEmulateEnsata;
|
||||
NSInteger cpuEmulationEngine;
|
||||
NSInteger slot1DeviceType;
|
||||
NSString *slot1StatusText;
|
||||
|
||||
NSURL *slot1R4URL;
|
||||
|
||||
OSSpinLock spinlockCdsController;
|
||||
OSSpinLock spinlockMasterExecute;
|
||||
|
@ -101,10 +107,13 @@ typedef struct
|
|||
@property (assign) BOOL emuFlagDebugConsole;
|
||||
@property (assign) BOOL emuFlagEmulateEnsata;
|
||||
@property (assign) NSInteger cpuEmulationEngine;
|
||||
@property (assign) NSInteger slot1DeviceType;
|
||||
@property (assign) NSString *slot1StatusText;
|
||||
|
||||
@property (copy) NSURL *arm9ImageURL;
|
||||
@property (copy) NSURL *arm7ImageURL;
|
||||
@property (copy) NSURL *firmwareImageURL;
|
||||
@property (retain) NSURL *slot1R4URL;
|
||||
|
||||
@property (readonly) pthread_mutex_t *mutexCoreExecute;
|
||||
|
||||
|
@ -114,10 +123,12 @@ typedef struct
|
|||
|
||||
- (BOOL) ejectCardFlag;
|
||||
- (void) setEjectCardFlag;
|
||||
- (void) slot1Eject;
|
||||
|
||||
- (void) changeRomSaveType:(NSInteger)saveTypeID;
|
||||
- (void) changeExecutionSpeed;
|
||||
- (void) setDynaRec;
|
||||
- (void) applyDynaRec;
|
||||
- (BOOL) applySlot1Device;
|
||||
|
||||
- (void) restoreCoreState;
|
||||
- (void) reset;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "../addons.h"
|
||||
#include "../NDSSystem.h"
|
||||
#include "../slot1.h"
|
||||
#undef BOOL
|
||||
|
||||
|
||||
|
@ -61,10 +62,13 @@ volatile bool execute = true;
|
|||
@synthesize emuFlagDebugConsole;
|
||||
@synthesize emuFlagEmulateEnsata;
|
||||
@dynamic cpuEmulationEngine;
|
||||
@synthesize slot1DeviceType;
|
||||
@synthesize slot1StatusText;
|
||||
|
||||
@dynamic arm9ImageURL;
|
||||
@dynamic arm7ImageURL;
|
||||
@dynamic firmwareImageURL;
|
||||
@synthesize slot1R4URL;
|
||||
|
||||
@dynamic mutexCoreExecute;
|
||||
|
||||
|
@ -94,6 +98,9 @@ static BOOL isCoreStarted = NO;
|
|||
emuFlagDebugConsole = NO;
|
||||
emuFlagEmulateEnsata = NO;
|
||||
|
||||
slot1DeviceType = NDS_SLOT1_RETAIL;
|
||||
slot1StatusText = NSSTRING_STATUS_EMULATION_NOT_RUNNING;
|
||||
|
||||
spinlockMasterExecute = OS_SPINLOCK_INIT;
|
||||
spinlockCdsController = OS_SPINLOCK_INIT;
|
||||
spinlockExecutionChange = OS_SPINLOCK_INIT;
|
||||
|
@ -105,6 +112,9 @@ static BOOL isCoreStarted = NO;
|
|||
speedScalar = SPEED_SCALAR_NORMAL;
|
||||
prevCoreState = CORESTATE_PAUSE;
|
||||
|
||||
slot1R4URL = nil;
|
||||
_slot1R4Path = "";
|
||||
|
||||
threadParam.cdsCore = self;
|
||||
threadParam.cdsController = cdsController;
|
||||
threadParam.state = CORESTATE_PAUSE;
|
||||
|
@ -573,6 +583,15 @@ static BOOL isCoreStarted = NO;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void) slot1Eject
|
||||
{
|
||||
pthread_mutex_lock(&threadParam.mutexCoreExecute);
|
||||
NDS_TriggerCardEjectIRQ();
|
||||
pthread_mutex_unlock(&threadParam.mutexCoreExecute);
|
||||
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_NO_DEVICE];
|
||||
}
|
||||
|
||||
- (void) changeRomSaveType:(NSInteger)saveTypeID
|
||||
{
|
||||
pthread_mutex_lock(&threadParam.mutexCoreExecute);
|
||||
|
@ -605,7 +624,7 @@ static BOOL isCoreStarted = NO;
|
|||
}
|
||||
|
||||
/********************************************************************************************
|
||||
setDynaRec
|
||||
applyDynaRec
|
||||
|
||||
Sets the use_jit variable for CommonSettings.
|
||||
|
||||
|
@ -622,7 +641,7 @@ static BOOL isCoreStarted = NO;
|
|||
method to set the engine at a later time, using the last cpuEmulationEngine
|
||||
value from the user.
|
||||
********************************************************************************************/
|
||||
- (void) setDynaRec
|
||||
- (void) applyDynaRec
|
||||
{
|
||||
const NSInteger engineID = [self cpuEmulationEngine];
|
||||
|
||||
|
@ -631,6 +650,46 @@ static BOOL isCoreStarted = NO;
|
|||
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
|
||||
}
|
||||
|
||||
- (BOOL) applySlot1Device
|
||||
{
|
||||
const NSInteger deviceTypeID = [self slot1DeviceType];
|
||||
NSString *r4Path = [[self slot1R4URL] path];
|
||||
|
||||
pthread_mutex_lock(&threadParam.mutexThreadExecute);
|
||||
|
||||
_slot1R4Path = (r4Path != nil) ? std::string([r4Path cStringUsingEncoding:NSUTF8StringEncoding]) : "";
|
||||
slot1SetFatDir(_slot1R4Path);
|
||||
|
||||
BOOL result = slot1Change((NDS_SLOT1_TYPE)deviceTypeID);
|
||||
|
||||
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
|
||||
|
||||
switch (deviceTypeID)
|
||||
{
|
||||
case NDS_SLOT1_NONE:
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_NO_DEVICE];
|
||||
break;
|
||||
|
||||
case NDS_SLOT1_RETAIL:
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_RETAIL_INSERTED];
|
||||
break;
|
||||
|
||||
case NDS_SLOT1_RETAIL_NAND:
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_RETAIL_NAND_INSERTED];
|
||||
break;
|
||||
|
||||
case NDS_SLOT1_R4:
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_R4_INSERTED];
|
||||
break;
|
||||
|
||||
default:
|
||||
[self setSlot1StatusText:NSSTRING_STATUS_SLOT1_UNKNOWN_STATE];
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) restoreCoreState
|
||||
{
|
||||
[self setCoreState:prevCoreState];
|
||||
|
@ -639,7 +698,8 @@ static BOOL isCoreStarted = NO;
|
|||
- (void) reset
|
||||
{
|
||||
[self setCoreState:CORESTATE_PAUSE];
|
||||
[self setDynaRec];
|
||||
[self applyDynaRec];
|
||||
[self applySlot1Device];
|
||||
|
||||
pthread_mutex_lock(&threadParam.mutexThreadExecute);
|
||||
NDS_Reset();
|
||||
|
@ -673,7 +733,6 @@ static BOOL isCoreStarted = NO;
|
|||
|
||||
- (void) runThread:(id)object
|
||||
{
|
||||
[self setDynaRec];
|
||||
[CocoaDSCore startupCore];
|
||||
[super runThread:object];
|
||||
[CocoaDSCore shutdownCore];
|
||||
|
|
|
@ -97,6 +97,13 @@
|
|||
#define NSSTRING_STATUS_NO_ROM_LOADED NSLocalizedString(@"No ROM loaded.", nil)
|
||||
#define NSSTRING_STATUS_SIZE_BYTES NSLocalizedString(@"%i bytes", nil)
|
||||
|
||||
#define NSSTRING_STATUS_EMULATION_NOT_RUNNING NSLocalizedString(@"Emulation is not running.", nil)
|
||||
#define NSSTRING_STATUS_SLOT1_UNKNOWN_STATE NSLocalizedString(@"Unknown state.", nil)
|
||||
#define NSSTRING_STATUS_SLOT1_NO_DEVICE NSLocalizedString(@"No device inserted.", nil)
|
||||
#define NSSTRING_STATUS_SLOT1_RETAIL_INSERTED NSLocalizedString(@"Retail cartridge inserted.", nil)
|
||||
#define NSSTRING_STATUS_SLOT1_RETAIL_NAND_INSERTED NSLocalizedString(@"Retail cartridge (with NAND flash) inserted.", nil)
|
||||
#define NSSTRING_STATUS_SLOT1_R4_INSERTED NSLocalizedString(@"R4 cartridge interface inserted.", nil)
|
||||
|
||||
#define NSSTRING_DISPLAYMODE_MAIN NSLocalizedString(@"Main", nil)
|
||||
#define NSSTRING_DISPLAYMODE_TOUCH NSLocalizedString(@"Touch", nil)
|
||||
#define NSSTRING_DISPLAYMODE_COMBO NSLocalizedString(@"Combo", nil)
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -47,6 +47,7 @@ class AudioSampleBlockGenerator;
|
|||
NSArrayController *cheatListController;
|
||||
NSArrayController *cheatDatabaseController;
|
||||
|
||||
NSWindow *slot1ManagerWindow;
|
||||
NSWindow *saveFileMigrationSheet;
|
||||
NSWindow *saveStatePrecloseSheet;
|
||||
NSView *exportRomSavePanelAccessoryView;
|
||||
|
@ -101,6 +102,7 @@ class AudioSampleBlockGenerator;
|
|||
@property (readonly) IBOutlet NSArrayController *cheatListController;
|
||||
@property (readonly) IBOutlet NSArrayController *cheatDatabaseController;
|
||||
|
||||
@property (readonly) IBOutlet NSWindow *slot1ManagerWindow;
|
||||
@property (readonly) IBOutlet NSWindow *saveFileMigrationSheet;
|
||||
@property (readonly) IBOutlet NSWindow *saveStatePrecloseSheet;
|
||||
@property (readonly) IBOutlet NSView *exportRomSavePanelAccessoryView;
|
||||
|
@ -142,6 +144,7 @@ class AudioSampleBlockGenerator;
|
|||
// File Menu
|
||||
- (IBAction) newDisplayWindow:(id)sender;
|
||||
- (IBAction) openRom:(id)sender;
|
||||
- (IBAction) loadRecentRom:(id)sender;
|
||||
- (IBAction) closeWindow:(id)sender;
|
||||
- (IBAction) closeRom:(id)sender;
|
||||
- (IBAction) openEmuSaveState:(id)sender;
|
||||
|
@ -189,12 +192,16 @@ class AudioSampleBlockGenerator;
|
|||
- (IBAction) changeSpuSyncMethod:(id)sender;
|
||||
|
||||
// Misc IBActions
|
||||
- (IBAction) chooseSlot1R4Directory:(id)sender;
|
||||
- (IBAction) slot1Eject:(id)sender;
|
||||
|
||||
- (IBAction) writeDefaultsDisplayRotation:(id)sender;
|
||||
- (IBAction) writeDefaultsDisplayGap:(id)sender;
|
||||
- (IBAction) writeDefaultsHUDSettings:(id)sender;
|
||||
- (IBAction) writeDefaultsDisplayVideoSettings:(id)sender;
|
||||
- (IBAction) writeDefaults3DRenderingSettings:(id)sender;
|
||||
- (IBAction) writeDefaultsEmulationSettings:(id)sender;
|
||||
- (IBAction) writeDefaultsSlot1Settings:(id)sender;
|
||||
- (IBAction) writeDefaultsSoundSettings:(id)sender;
|
||||
|
||||
- (IBAction) closeSheet:(id)sender;
|
||||
|
@ -233,9 +240,9 @@ class AudioSampleBlockGenerator;
|
|||
- (void) didEndSaveStateSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
||||
- (void) didEndSaveStateSheetOpen:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
||||
- (void) didEndSaveStateSheetTerminate:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
||||
- (void) didEndChooseSlot1R4Directory:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
|
||||
|
||||
- (void) updateAllWindowTitles;
|
||||
- (void) setupUserDefaults;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
@synthesize cheatListController;
|
||||
@synthesize cheatDatabaseController;
|
||||
|
||||
@synthesize slot1ManagerWindow;
|
||||
@synthesize saveFileMigrationSheet;
|
||||
@synthesize saveStatePrecloseSheet;
|
||||
@synthesize exportRomSavePanelAccessoryView;
|
||||
|
@ -485,6 +486,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (IBAction) loadRecentRom:(id)sender
|
||||
{
|
||||
// Dummy selector, used for UI validation only.
|
||||
}
|
||||
|
||||
- (IBAction) closeWindow:(id)sender
|
||||
{
|
||||
[[mainWindow window] performClose:sender];
|
||||
|
@ -910,6 +916,41 @@
|
|||
[mainWindow setDisplayGap:(double)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0];
|
||||
}
|
||||
|
||||
- (IBAction) chooseSlot1R4Directory:(id)sender
|
||||
{
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
[panel setCanChooseFiles:NO];
|
||||
[panel setResolvesAliases:YES];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setTitle:@"Select R4 Directory"];
|
||||
NSArray *fileTypes = [NSArray arrayWithObjects:nil];
|
||||
|
||||
// The NSOpenPanel/NSSavePanel method -(void)beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo
|
||||
// is deprecated in Mac OS X v10.6.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
|
||||
[panel setAllowedFileTypes:fileTypes];
|
||||
[panel beginSheetModalForWindow:slot1ManagerWindow
|
||||
completionHandler:^(NSInteger result) {
|
||||
[self didEndChooseSlot1R4Directory:panel returnCode:result contextInfo:nil];
|
||||
} ];
|
||||
#else
|
||||
[panel beginSheetForDirectory:nil
|
||||
file:nil
|
||||
types:fileTypes
|
||||
modalForWindow:slot1ManagerWindow
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(didEndChooseSlot1R4Directory:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (IBAction) slot1Eject:(id)sender
|
||||
{
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[cdsCore slot1Eject];
|
||||
}
|
||||
|
||||
- (IBAction) writeDefaultsDisplayRotation:(id)sender
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setDouble:[mainWindow displayRotation] forKey:@"DisplayView_Rotation"];
|
||||
|
@ -976,6 +1017,14 @@
|
|||
[[NSUserDefaults standardUserDefaults] setObject:[firmwareDict valueForKey:@"Language"] forKey:@"FirmwareConfig_Language"];
|
||||
}
|
||||
|
||||
- (IBAction) writeDefaultsSlot1Settings:(id)sender
|
||||
{
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:[cdsCore slot1DeviceType] forKey:@"EmulationSLOT1_DeviceType"];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[[cdsCore slot1R4URL] path] forKey:@"EmulationSLOT1_R4StoragePath"];
|
||||
}
|
||||
|
||||
- (IBAction) writeDefaultsSoundSettings:(id)sender
|
||||
{
|
||||
NSMutableDictionary *speakerBindings = (NSMutableDictionary *)[cdsSoundController content];
|
||||
|
@ -1252,6 +1301,7 @@
|
|||
|
||||
[self setStatusText:NSSTRING_STATUS_EMULATOR_RESET];
|
||||
[self setIsWorking:NO];
|
||||
[self writeDefaultsSlot1Settings:nil];
|
||||
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
|
@ -1416,7 +1466,9 @@
|
|||
[self pauseCore];
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[cdsCore setDynaRec];
|
||||
[cdsCore applyDynaRec];
|
||||
[cdsCore applySlot1Device];
|
||||
[self writeDefaultsSlot1Settings:nil];
|
||||
|
||||
CocoaDSRom *newRom = [[CocoaDSRom alloc] init];
|
||||
if (newRom != nil)
|
||||
|
@ -1621,6 +1673,9 @@
|
|||
[[windowController window] displayIfNeeded];
|
||||
}
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[cdsCore setSlot1StatusText:NSSTRING_STATUS_EMULATION_NOT_RUNNING];
|
||||
|
||||
result = YES;
|
||||
|
||||
return result;
|
||||
|
@ -1756,6 +1811,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) didEndChooseSlot1R4Directory:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
|
||||
{
|
||||
[sheet orderOut:self];
|
||||
|
||||
if (returnCode == NSCancelButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL *selectedDirURL = [[sheet URLs] lastObject]; //hopefully also the first object
|
||||
if(selectedDirURL == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[selectedDirURL path] forKey:@"EmulationSLOT1_R4StoragePath"];
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[cdsCore setSlot1R4URL:selectedDirURL];
|
||||
}
|
||||
|
||||
- (void) updateAllWindowTitles
|
||||
{
|
||||
if ([windowList count] < 1)
|
||||
|
@ -1888,9 +1964,9 @@
|
|||
enable = NO;
|
||||
}
|
||||
}
|
||||
else if (theAction == @selector(_openRecentDocument:))
|
||||
else if (theAction == @selector(loadRecentRom:))
|
||||
{
|
||||
if ([self isShowingSaveStateDialog])
|
||||
if ([self isRomLoading] || [self isShowingSaveStateDialog])
|
||||
{
|
||||
enable = NO;
|
||||
}
|
||||
|
|
|
@ -411,6 +411,11 @@
|
|||
// Set the CPU emulation engine per user preferences.
|
||||
[cdsCore setCpuEmulationEngine:[[NSUserDefaults standardUserDefaults] integerForKey:@"Emulation_CPUEmulationEngine"]];
|
||||
|
||||
// Set the SLOT-1 device settings per user preferences.
|
||||
NSString *slot1R4Path = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"EmulationSLOT1_R4StoragePath"];
|
||||
[cdsCore setSlot1DeviceType:[[NSUserDefaults standardUserDefaults] integerForKey:@"EmulationSLOT1_DeviceType"]];
|
||||
[cdsCore setSlot1R4URL:(slot1R4Path != nil) ? [NSURL fileURLWithPath:slot1R4Path] : nil];
|
||||
|
||||
// Set up the firmware per user preferences.
|
||||
NSMutableDictionary *newFWDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[[NSUserDefaults standardUserDefaults] objectForKey:@"FirmwareConfig_Nickname"], @"Nickname",
|
||||
|
|
Loading…
Reference in New Issue