Cocoa Port:

- Condense the UI in DeSmuME Preferences for autoloading ROMs on startup.
- Rename the "Combo" display mode to "Dual Screen" display mode.
- Do some minor code cleanup.
This commit is contained in:
rogerman 2013-09-24 05:15:41 +00:00
parent 5ea6410107
commit d221b1d3d5
10 changed files with 361 additions and 508 deletions

View File

@ -586,7 +586,7 @@ GPU3DInterface *core3DList[] = {
}
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
if (flags & (GPUSTATE_MAIN_GPU_MASK | GPUSTATE_SUB_GPU_MASK))
{
result = YES;
@ -614,7 +614,7 @@ GPU3DInterface *core3DList[] = {
flags &= ~GPUSTATE_SUB_GPU_MASK;
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
flags &= ~GPUSTATE_MAIN_GPU_MASK;
flags &= ~GPUSTATE_SUB_GPU_MASK;
break;
@ -640,7 +640,7 @@ GPU3DInterface *core3DList[] = {
flags |= GPUSTATE_SUB_GPU_MASK;
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
flags |= GPUSTATE_MAIN_GPU_MASK;
flags |= GPUSTATE_SUB_GPU_MASK;
break;
@ -674,7 +674,7 @@ void SetGPULayerState(const int gpuType, const unsigned int i, const bool state)
theGpu = MainScreen.gpu;
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
SetGPULayerState(DS_GPU_TYPE_SUB, i, state); // Recursive call
theGpu = MainScreen.gpu;
break;
@ -722,7 +722,7 @@ bool GetGPULayerState(const int gpuType, const unsigned int i)
}
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
if (SubScreen.gpu != NULL && MainScreen.gpu != NULL)
{
theState = (CommonSettings.dispLayers[SubScreen.gpu->core][i] && CommonSettings.dispLayers[MainScreen.gpu->core][i]);
@ -748,7 +748,7 @@ void SetGPUDisplayState(const int gpuType, const bool state)
CommonSettings.showGpu.main = state;
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
CommonSettings.showGpu.sub = state;
CommonSettings.showGpu.main = state;
break;
@ -772,7 +772,7 @@ bool GetGPUDisplayState(const int gpuType)
theState = CommonSettings.showGpu.main;
break;
case DS_GPU_TYPE_COMBO:
case DS_GPU_TYPE_MAIN_AND_SUB:
theState = (CommonSettings.showGpu.sub && CommonSettings.showGpu.main);
break;

View File

@ -107,9 +107,11 @@
#define NSSTRING_STATUS_SLOT1_R4_INSERTED NSLocalizedString(@"R4 cartridge interface inserted.", nil)
#define NSSTRING_STATUS_SLOT1_STANDARD_INSERTED NSLocalizedString(@"Standard retail cartridge inserted.", nil)
#define NSSTRING_STATUS_AUTOLOAD_ROM_NAME_NONE NSLocalizedString(@"No ROM chosen.", nil)
#define NSSTRING_DISPLAYMODE_MAIN NSLocalizedString(@"Main", nil)
#define NSSTRING_DISPLAYMODE_TOUCH NSLocalizedString(@"Touch", nil)
#define NSSTRING_DISPLAYMODE_COMBO NSLocalizedString(@"Combo", nil)
#define NSSTRING_DISPLAYMODE_DUAL NSLocalizedString(@"Dual Screen", nil)
#define NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED NSLocalizedString(@"%ld Input Mapped", nil)
#define NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED_PLURAL NSLocalizedString(@"%ld Inputs Mapped", nil)
@ -229,7 +231,9 @@
enum
{
ROMAUTOLOADOPTION_LOAD_LAST = 0,
ROMAUTOLOADOPTION_LOAD_SELECTED = 1
ROMAUTOLOADOPTION_LOAD_SELECTED = 1,
ROMAUTOLOADOPTION_LOAD_NONE = 10000,
ROMAUTOLOADOPTION_CHOOSE_ROM = 10001
};
enum
@ -422,7 +426,7 @@ enum
{
DS_DISPLAY_TYPE_MAIN = 0,
DS_DISPLAY_TYPE_TOUCH,
DS_DISPLAY_TYPE_COMBO
DS_DISPLAY_TYPE_DUAL
};
enum
@ -444,7 +448,7 @@ enum
{
DS_GPU_TYPE_MAIN = 0,
DS_GPU_TYPE_SUB,
DS_GPU_TYPE_COMBO
DS_GPU_TYPE_MAIN_AND_SUB
};
/*

View File

@ -436,7 +436,7 @@
spinlockDisplayType = OS_SPINLOCK_INIT;
delegate = nil;
displayMode = DS_DISPLAY_TYPE_COMBO;
displayMode = DS_DISPLAY_TYPE_DUAL;
frameSize = NSMakeSize((CGFloat)GPU_DISPLAY_WIDTH, (CGFloat)GPU_DISPLAY_HEIGHT * 2);
[property setValue:[NSNumber numberWithInteger:displayMode] forKey:@"displayMode"];
@ -497,8 +497,8 @@
newDispString = NSSTRING_DISPLAYMODE_TOUCH;
break;
case DS_DISPLAY_TYPE_COMBO:
newDispString = NSSTRING_DISPLAYMODE_COMBO;
case DS_DISPLAY_TYPE_DUAL:
newDispString = NSSTRING_DISPLAYMODE_DUAL;
newFrameSize.height *= 2;
break;
@ -551,7 +551,7 @@
{
gpuData = [[NSData alloc] initWithBytes:(GPU_screen + GPU_SCREEN_SIZE_BYTES) length:GPU_SCREEN_SIZE_BYTES];
}
else if(displayModeID == DS_DISPLAY_TYPE_COMBO)
else if(displayModeID == DS_DISPLAY_TYPE_DUAL)
{
gpuData = [[NSData alloc] initWithBytes:GPU_screen length:GPU_SCREEN_SIZE_BYTES * 2];
}
@ -667,7 +667,7 @@
{
const NSInteger displayModeID = [self displayMode];
const NSSize displayFrameSize = [self frameSize];
const size_t numberBytes = (displayModeID == DS_DISPLAY_TYPE_COMBO) ? GPU_SCREEN_SIZE_BYTES * 2 : GPU_SCREEN_SIZE_BYTES;
const size_t numberBytes = (displayModeID == DS_DISPLAY_TYPE_DUAL) ? GPU_SCREEN_SIZE_BYTES * 2 : GPU_SCREEN_SIZE_BYTES;
UInt16 *gpuBytes = (UInt16 *)malloc(numberBytes);
if (gpuBytes == NULL)
@ -767,7 +767,7 @@
}
videoDelegate = nil;
lastDisplayMode = DS_DISPLAY_TYPE_COMBO;
lastDisplayMode = DS_DISPLAY_TYPE_DUAL;
spinlockVideoFilterType = OS_SPINLOCK_INIT;
spinlockVFBuffers = OS_SPINLOCK_INIT;

File diff suppressed because it is too large Load Diff

View File

@ -140,7 +140,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
// These need to be initialized first since there are dependencies on these.
_displayGap = 0.0;
_displayMode = DS_DISPLAY_TYPE_COMBO;
_displayMode = DS_DISPLAY_TYPE_DUAL;
_displayOrientation = DS_DISPLAY_ORIENTATION_VERTICAL;
_minDisplayViewSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT*2.0 + (DS_DISPLAY_GAP*_displayGap));
@ -322,10 +322,10 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
modeString = NSSTRING_DISPLAYMODE_TOUCH;
break;
case DS_DISPLAY_TYPE_COMBO:
case DS_DISPLAY_TYPE_DUAL:
{
const double gapScalar = [self displayGap];
modeString = NSSTRING_DISPLAYMODE_COMBO;
modeString = NSSTRING_DISPLAYMODE_DUAL;
if ([self displayOrientation] == DS_DISPLAY_ORIENTATION_VERTICAL)
{
@ -372,7 +372,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
_displayOrientation = theOrientation;
OSSpinLockUnlock(&spinlockDisplayOrientation);
if ([self displayMode] == DS_DISPLAY_TYPE_COMBO)
if ([self displayMode] == DS_DISPLAY_TYPE_DUAL)
{
const double gapScalar = [self displayGap];
NSSize newDisplaySize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
@ -430,7 +430,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
_displayGap = gapScalar;
OSSpinLockUnlock(&spinlockDisplayGap);
if ([self displayMode] == DS_DISPLAY_TYPE_COMBO)
if ([self displayMode] == DS_DISPLAY_TYPE_DUAL)
{
NSSize newDisplaySize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
@ -489,7 +489,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
_isMinSizeNormal = theState;
if ([self displayMode] == DS_DISPLAY_TYPE_COMBO)
if ([self displayMode] == DS_DISPLAY_TYPE_DUAL)
{
if ([self displayOrientation] == DS_DISPLAY_ORIENTATION_HORIZONTAL)
{
@ -1135,7 +1135,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
// Set the video filter source size now since the proper size is needed on initialization.
// If we don't do this, new windows could draw incorrectly.
const NSSize vfSrcSize = NSMakeSize(GPU_DISPLAY_WIDTH, ([self displayMode] == DS_DISPLAY_TYPE_COMBO) ? GPU_DISPLAY_HEIGHT * 2 : GPU_DISPLAY_HEIGHT);
const NSSize vfSrcSize = NSMakeSize(GPU_DISPLAY_WIDTH, ([self displayMode] == DS_DISPLAY_TYPE_DUAL) ? GPU_DISPLAY_HEIGHT * 2 : GPU_DISPLAY_HEIGHT);
[[cdsVideoOutput vf] setSourceSize:vfSrcSize];
[CocoaDSUtil messageSendOneWayWithInteger:[cdsVideoOutput receivePort] msgID:MESSAGE_CHANGE_VIDEO_FILTER integerValue:[self videoFilterType]];
@ -1340,7 +1340,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
[format release];
cglDisplayContext = (CGLContextObj)[context CGLContextObj];
_currentDisplayMode = DS_DISPLAY_TYPE_COMBO;
_currentDisplayMode = DS_DISPLAY_TYPE_DUAL;
_currentDisplayOrientation = DS_DISPLAY_ORIENTATION_VERTICAL;
_currentGapScalar = 0.0f;
_currentNormalSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT*2.0 + (DS_DISPLAY_GAP*_currentGapScalar));
@ -1643,7 +1643,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
[self uploadVertices];
}
const GLsizei vtxElementCount = (displayModeID == DS_DISPLAY_TYPE_COMBO) ? 12 : 6;
const GLsizei vtxElementCount = (displayModeID == DS_DISPLAY_TYPE_DUAL) ? 12 : 6;
const GLubyte *elementPointer = !(displayModeID == DS_DISPLAY_TYPE_TOUCH) ? 0 : (GLubyte *)(vtxElementCount * sizeof(GLubyte));
glClear(GL_COLOR_BUFFER_BIT);
@ -1661,7 +1661,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
const GLfloat h = GPU_DISPLAY_HEIGHT;
const GLfloat gap = DS_DISPLAY_GAP * gapScalar / 2.0;
if (displayModeID == DS_DISPLAY_TYPE_COMBO)
if (displayModeID == DS_DISPLAY_TYPE_DUAL)
{
// displayOrder == DS_DISPLAY_ORDER_MAIN_FIRST
if (displayOrientationID == DS_DISPLAY_ORIENTATION_VERTICAL)
@ -1751,7 +1751,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
viewAngle);
// Normalize the touch location to the DS.
if ([windowController displayMode] == DS_DISPLAY_TYPE_COMBO)
if ([windowController displayMode] == DS_DISPLAY_TYPE_DUAL)
{
const NSInteger theOrientation = [windowController displayOrientation];
const NSInteger theOrder = [windowController displayOrder];
@ -1864,7 +1864,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
// and finally to DS touchscreen coordinates.
NSPoint touchLoc = NSMakePoint(-2.0, -2.0);
if (displayModeID == DS_DISPLAY_TYPE_TOUCH || displayModeID == DS_DISPLAY_TYPE_COMBO)
if (displayModeID == DS_DISPLAY_TYPE_TOUCH || displayModeID == DS_DISPLAY_TYPE_DUAL)
{
touchLoc = [self dsPointFromEvent:theEvent];
}
@ -2211,7 +2211,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
[self uploadVertices];
if (_currentDisplayMode == DS_DISPLAY_TYPE_COMBO)
if (_currentDisplayMode == DS_DISPLAY_TYPE_DUAL)
{
const NSSize viewSize = [self bounds].size;
const CGSize checkSize = GetTransformedBounds(_currentNormalSize.width, _currentNormalSize.height, 1.0, _currentRotation);
@ -2252,7 +2252,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
[self uploadVertices];
if (_currentDisplayMode == DS_DISPLAY_TYPE_COMBO)
if (_currentDisplayMode == DS_DISPLAY_TYPE_DUAL)
{
[self renderDisplayUsingDisplayMode:_currentDisplayMode];
[self drawVideoFrame];
@ -2274,7 +2274,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
[self uploadVertices];
if (_currentDisplayMode == DS_DISPLAY_TYPE_COMBO)
if (_currentDisplayMode == DS_DISPLAY_TYPE_DUAL)
{
const NSSize viewSize = [self bounds].size;
const CGSize checkSize = GetTransformedBounds(_currentNormalSize.width, _currentNormalSize.height, 1.0, _currentRotation);
@ -2316,7 +2316,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
glTexPixelFormat = GL_UNSIGNED_SHORT_1_5_5_5_REV;
}
if (_currentDisplayMode != DS_DISPLAY_TYPE_COMBO)
if (_currentDisplayMode != DS_DISPLAY_TYPE_DUAL)
{
videoFilterDestSize.height = (uint32_t)videoFilterDestSize.height * 2;
}

View File

@ -243,23 +243,50 @@
[self restoreDisplayWindowStates];
// Load a new ROM on launch per user preferences.
const BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"];
if (loadROMOnLaunch && [emuControl currentRom] == nil)
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"General_AutoloadROMOnLaunch"] != nil)
{
// Older versions of DeSmuME used General_AutoloadROMOnLaunch to determine whether to
// load a ROM on launch or not. This has been superseded by the autoload ROM option
// ROMAUTOLOADOPTION_LOAD_NONE. So if this object key exists in the user defaults, we
// need to update the user defaults key/values as needed, and then remove the
// General_AutoloadROMOnLaunch object key.
const BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"];
if (!loadROMOnLaunch)
{
[[NSUserDefaults standardUserDefaults] setInteger:ROMAUTOLOADOPTION_LOAD_NONE forKey:@"General_AutoloadROMOption"];
}
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"General_AutoloadROMOnLaunch"];
}
if ([emuControl currentRom] == nil)
{
const NSInteger autoloadRomOption = [[NSUserDefaults standardUserDefaults] integerForKey:@"General_AutoloadROMOption"];
NSURL *autoloadRomURL = nil;
if (autoloadRomOption == ROMAUTOLOADOPTION_LOAD_LAST)
switch (autoloadRomOption)
{
autoloadRomURL = [CocoaDSFile lastLoadedRomURL];
}
else if(autoloadRomOption == ROMAUTOLOADOPTION_LOAD_SELECTED)
{
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
if (autoloadRomPath != nil && [autoloadRomPath length] > 0)
case ROMAUTOLOADOPTION_LOAD_NONE:
autoloadRomURL = nil;
break;
case ROMAUTOLOADOPTION_LOAD_LAST:
autoloadRomURL = [CocoaDSFile lastLoadedRomURL];
break;
case ROMAUTOLOADOPTION_LOAD_SELECTED:
{
autoloadRomURL = [NSURL fileURLWithPath:autoloadRomPath];
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
if (autoloadRomPath != nil && [autoloadRomPath length] > 0)
{
autoloadRomURL = [NSURL fileURLWithPath:autoloadRomPath];
}
break;
}
default:
break;
}
if (autoloadRomURL != nil)
@ -536,7 +563,7 @@
[[prefWindowDelegate spuSyncMethodMenu] setEnabled:YES];
}
// Set the text field for the autoloaded ROM.
// Set the name of the autoloaded ROM.
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
if (autoloadRomPath != nil)
{
@ -544,7 +571,7 @@
}
else
{
[prefBindings setValue:nil forKey:@"AutoloadRomName"];
[prefBindings setValue:NSSTRING_STATUS_AUTOLOAD_ROM_NAME_NONE forKey:@"AutoloadRomName"];
}
// Set the menu for the display rotation.

View File

@ -89,7 +89,6 @@
- (IBAction) showSoundView:(id)sender;
- (IBAction) showEmulationView:(id)sender;
- (IBAction) selectAutoloadRomOption:(id)sender;
- (IBAction) chooseAdvansceneDatabase:(id)sender;
- (void) chooseAdvansceneDatabaseDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (IBAction) chooseRomForAutoload:(id)sender;
@ -97,8 +96,6 @@
- (IBAction) chooseCheatDatabase:(id)sender;
- (void) chooseCheatDatabaseDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (IBAction) selectDisplayMode:(id)sender;
- (IBAction) selectDisplaySize:(id)sender;
- (IBAction) selectDisplayRotation:(id)sender;
- (void) updateDisplayRotationMenu:(double)displayRotation;

View File

@ -154,22 +154,6 @@
[self switchContentView:viewEmulation];
}
- (IBAction) selectAutoloadRomOption:(id)sender
{
const NSInteger option = [(NSMenuItem *)sender tag];
[[NSUserDefaults standardUserDefaults] setInteger:option forKey:@"General_AutoloadROMOption"];
if (option == 1)
{
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
if ([autoloadRomPath length] == 0)
{
[self chooseRomForAutoload:sender];
}
}
}
- (IBAction) chooseRomForAutoload:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
@ -205,17 +189,20 @@
if (returnCode == NSCancelButton)
{
[[NSUserDefaults standardUserDefaults] setInteger:ROMAUTOLOADOPTION_LOAD_NONE forKey:@"General_AutoloadROMOption"];
return;
}
NSURL *selectedFileURL = [[sheet URLs] lastObject]; //hopefully also the first object
if(selectedFileURL == nil)
{
[[NSUserDefaults standardUserDefaults] setInteger:ROMAUTOLOADOPTION_LOAD_NONE forKey:@"General_AutoloadROMOption"];
return;
}
NSString *selectedFile = [selectedFileURL path];
[[NSUserDefaults standardUserDefaults] setInteger:ROMAUTOLOADOPTION_LOAD_SELECTED forKey:@"General_AutoloadROMOption"];
[[NSUserDefaults standardUserDefaults] setObject:selectedFile forKey:@"General_AutoloadROMSelectedPath"];
[bindings setValue:[selectedFile lastPathComponent] forKey:@"AutoloadRomName"];
}
@ -376,18 +363,6 @@
}
}
- (IBAction) selectDisplayMode:(id)sender
{
const NSInteger displayMode = [(NSMenuItem *)sender tag];
[[NSUserDefaults standardUserDefaults] setInteger:displayMode forKey:@"DisplayView_Mode"];
}
- (IBAction) selectDisplaySize:(id)sender
{
const NSInteger displaySize = [(NSMenuItem *)sender tag];
[[NSUserDefaults standardUserDefaults] setInteger:displaySize forKey:@"DisplayView_Size"];
}
- (IBAction) selectDisplayRotation:(id)sender
{
const NSInteger displayRotation = [(NSMenuItem *)sender tag];