diff --git a/desmume/src/cocoa/main.mm b/desmume/src/cocoa/main.mm index 0d9d7f63e..f9a19f321 100644 --- a/desmume/src/cocoa/main.mm +++ b/desmume/src/cocoa/main.mm @@ -74,6 +74,9 @@ extern NSMenuItem *reset_item; extern NSMenuItem *frame_skip_auto_item; extern NSMenuItem *frame_skip_item[]; +extern NSMenuItem *save_type_item[]; +extern NSString *save_types[]; + extern NSMenuItem *speed_limit_25_item; extern NSMenuItem *speed_limit_50_item; extern NSMenuItem *speed_limit_75_item; @@ -283,7 +286,27 @@ void CreateMenu(AppDelegate *delegate) [speed_limit_menu release]; } - // + // Backup media type + temp = [emulation_menu addItemWithTitle:NSLocalizedString(@"Backup Media Type", nil) action:nil keyEquivalent:@""]; + + NSMenu *save_type_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Backup Media Type", nil)]; + if(save_type_menu != nil) + { + [temp setSubmenu:save_type_menu]; + + // Add autodetect apart from the others + save_type_item[0] = [save_type_menu addItemWithTitle:save_types[0] action:@selector(setSaveTypeFromMenuItem:) keyEquivalent:@""]; + [save_type_menu addItem:[NSMenuItem separatorItem]]; + + // Add the rest + for(i = 1; i < MAX_SAVE_TYPE; i++) + { + save_type_item[i] = [save_type_menu addItemWithTitle:save_types[i] action:@selector(setSaveTypeFromMenuItem:) keyEquivalent:@""]; + } + + [save_type_menu release]; + } + [emulation_menu addItem:[NSMenuItem separatorItem]]; diff --git a/desmume/src/cocoa/main_window.h b/desmume/src/cocoa/main_window.h index 53c87a01e..10b453e7d 100644 --- a/desmume/src/cocoa/main_window.h +++ b/desmume/src/cocoa/main_window.h @@ -25,6 +25,10 @@ @class InputHandler; //this is used internally by VideoOutputWindow +// Backup media type array length +#define MAX_SAVE_TYPE 7 + + //This interface is to create and manaage the window //that displays DS video output and takes keyboard/mouse input //do not instanciate more than one of these @@ -52,6 +56,7 @@ - (void)pause; - (void)reset; - (void)setFrameSkip:(int)frameskip; +- (void)setSaveType:(int)savetype; - (void)closeROM; //save features overloaded from nds class diff --git a/desmume/src/cocoa/main_window.mm b/desmume/src/cocoa/main_window.mm index 44eb554a7..82aa156e8 100644 --- a/desmume/src/cocoa/main_window.mm +++ b/desmume/src/cocoa/main_window.mm @@ -32,6 +32,18 @@ #define MAX_FRAME_SKIP 10 +// Save types settings +NSString *save_types[MAX_SAVE_TYPE] = { + NSLocalizedString(@"Auto Detect", nil), // 0 + NSLocalizedString(@"EEPROM 4kbit", nil), // 1 + NSLocalizedString(@"EEPROM 64kbit", nil), // 2 + NSLocalizedString(@"EEPROM 512kbit", nil), // 3 + NSLocalizedString(@"FRAM 256knit", nil), // 4 + NSLocalizedString(@"FLASH 2mbit", nil), // 5 + NSLocalizedString(@"FLASH 4mbit", nil), // 6 +}; + + #define DS_SCREEN_HEIGHT_COMBINED (192*2) /*height of the two screens*/ #define DS_SCREEN_X_RATIO (256.0 / (192.0 * 2.0)) #define DS_SCREEN_Y_RATIO ((192.0 * 2.0) / 256.0) @@ -55,6 +67,7 @@ NSMenuItem *speed_limit_100_item = nil; NSMenuItem *speed_limit_200_item = nil; NSMenuItem *speed_limit_none_item = nil; NSMenuItem *speed_limit_custom_item = nil; ++NSMenuItem *save_type_item[MAX_SAVE_TYPE] = { nil, nil, nil, nil, nil, nil, nil }; NSMenuItem *volume_item[10] = { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil }; NSMenuItem *mute_item = nil; @@ -430,6 +443,33 @@ NSMenuItem *screenshot_to_file_item = nil; } } +- (void)setSaveType:(int)savetype +{ + [super setSaveType:savetype]; + savetype = [super saveType]; + + int i; + for(i = 0; i < MAX_SAVE_TYPE; i++) + if([save_type_item[i] target] == self) + if(i == savetype) + [save_type_item[i] setState:NSOnState]; + else + [save_type_item[i] setState:NSOffState]; +} + +- (void)setSaveTypeFromMenuItem:(id)sender +{ + // Find the culprit + int i; + for(i = 0; i < MAX_SAVE_TYPE; i++) + if(sender == save_type_item[i]) + { + [self setSaveType:i]; + return; + } +} + + - (void)closeROM { [super closeROM]; @@ -1137,6 +1177,11 @@ NSMenuItem *screenshot_to_file_item = nil; [frame_skip_auto_item setTarget:self]; for(i = 0; i < MAX_FRAME_SKIP; i++)[frame_skip_item[i] setTarget:self]; [self setFrameSkip:[self frameSkip]]; //set the menu checkmarks correctly + + // Backup media type + for(i = 0; i < MAX_SAVE_TYPE; i++)[save_type_item[i] setTarget:self]; + [self setSaveType:[self saveType]]; // initalize the menu + [speed_limit_25_item setTarget:self]; [speed_limit_50_item setTarget:self]; diff --git a/desmume/src/cocoa/nds_control.h b/desmume/src/cocoa/nds_control.h index 177bb3998..59eab8ec5 100644 --- a/desmume/src/cocoa/nds_control.h +++ b/desmume/src/cocoa/nds_control.h @@ -61,6 +61,7 @@ volatile int frame_skip; volatile int speed_limit; + volatile int save_type; NSString *current_file; NSString *flash_file; @@ -113,6 +114,8 @@ - (int)frameSkip; //defaults to -1 - (void)setSpeedLimit:(int)percent; //0 is off, 1-1000 is the pertance speed it runs at, anything else does nothing - (int)speedLimit; +- (void)setSaveType:(int)savetype; // see save_types in src/mmu.h +- (int)saveType; // default is 0, which is autodetect //touch screen - (void)touch:(NSPoint)point; diff --git a/desmume/src/cocoa/nds_control.mm b/desmume/src/cocoa/nds_control.mm index d00b4c7fb..3fe401f5d 100644 --- a/desmume/src/cocoa/nds_control.mm +++ b/desmume/src/cocoa/nds_control.mm @@ -624,6 +624,20 @@ bool opengl_init() return speed_limit; } +- (void)setSaveType:(int)savetype +{ + if(savetype < 0 || savetype > 6) savetype = 0; + + // Set the savetype + backup_setManualBackupType(savetype); +} + +- (int)saveType +{ + return CommonSettings.manualBackupType; +} + + - (void)touch:(NSPoint)point { NDS_setTouchPos((unsigned short)point.x, (unsigned short)point.y);