Cocoa Port:

- New feature: Add support for multiple display windows. Use the File > New Display Window menu option!
- Add menu option File > Close Window (Command-W).
- The menu option File > Unload ROM keyboard shortcut has been changed to Command-Option-W.
- Rename menu option View > Show Video Output Settings... to View > Show Display Video Settings..., and also change its position in the menu.
- Obsolete and remove the following classes: EmuWindowDelegate, DisplayViewDelegate, ImageDisplayView, OpenGLDisplayView. (Their functionality has been incorporated into DisplayWindowController and DisplayView.)
- Obsolete and remove the following protocols: DisplayViewDelegate. (The new DisplayView class uses the CocoaDSDisplayVideoDelegate protocol directly.)
- Fix several bugs with thread handling and cleanup.
- Do heavy code cleanup of EmuControllerDelegate.
This commit is contained in:
rogerman 2013-02-19 01:31:04 +00:00
parent 514e09a159
commit dc661e3edb
22 changed files with 4202 additions and 4008 deletions

View File

@ -261,8 +261,6 @@
AB2F3C2A15CF9C6000858373 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; };
AB2F3C2B15CF9C6000858373 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
AB2F3C2C15CF9C6000858373 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
AB2F3C2D15CF9C6000858373 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
AB2F3C2E15CF9C6000858373 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
AB2F3C2F15CF9C6000858373 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
AB2F3C3015CF9C6000858373 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
AB2F3C3115CF9C6000858373 /* 2xsai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABFE14FA14C92FF5005D6699 /* 2xsai.cpp */; };
@ -283,8 +281,6 @@
AB2F3C4115CF9C6000858373 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AB0A0D1914AACA9600E83E91 /* libz.dylib */; };
AB3ACB7814C2361100D7D192 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
AB3ACB7914C2361100D7D192 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
AB3ACB7A14C2361100D7D192 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
AB3ACB7B14C2361100D7D192 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
AB3ACB7C14C2361100D7D192 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
AB3ACB7D14C2361100D7D192 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
AB3ACC4414C24D5400D7D192 /* AUTHORS in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3814C24D5400D7D192 /* AUTHORS */; };
@ -300,6 +296,14 @@
AB6A198416CAD66900384EED /* cocoa_GPU.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB6A198216CAD66900384EED /* cocoa_GPU.mm */; };
AB6A198516CAD66900384EED /* cocoa_GPU.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB6A198216CAD66900384EED /* cocoa_GPU.mm */; };
AB6A198616CAD66900384EED /* cocoa_GPU.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB6A198216CAD66900384EED /* cocoa_GPU.mm */; };
AB700DBA16CDDBC400FBD336 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */; };
AB700DBB16CDDBC400FBD336 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */; };
AB700DBC16CDDBC400FBD336 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */; };
AB700DBD16CDDBC400FBD336 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */; };
AB700DDE16CDE4C300FBD336 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */; };
AB700DDF16CDE4C300FBD336 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */; };
AB700DE016CDE4C300FBD336 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */; };
AB700DE116CDE4C300FBD336 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */; };
AB711ED21481C35F009011C8 /* KeyNames.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB02475B13886BF300E9F9AB /* KeyNames.plist */; };
AB711ED31481C35F009011C8 /* DefaultKeyMappings.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABC719E1138CB25E002827A9 /* DefaultKeyMappings.plist */; };
AB711ED81481C35F009011C8 /* DefaultUserPrefs.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABBC0F8C1394B1AA0028B6BD /* DefaultUserPrefs.plist */; };
@ -578,8 +582,6 @@
AB73AA181507C9F500A310C8 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; };
AB73AA191507C9F500A310C8 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
AB73AA1A1507C9F500A310C8 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
AB73AA1B1507C9F500A310C8 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
AB73AA1C1507C9F500A310C8 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
AB73AA1D1507C9F500A310C8 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
AB73AA1E1507C9F500A310C8 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
AB73AA1F1507C9F500A310C8 /* 2xsai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABFE14FA14C92FF5005D6699 /* 2xsai.cpp */; };
@ -772,8 +774,6 @@
ABAD102015ACE7A00000EC47 /* OGLRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEC11345AC8400AF11D1 /* OGLRender.cpp */; };
ABAD102115ACE7A00000EC47 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
ABAD102215ACE7A00000EC47 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
ABAD102315ACE7A00000EC47 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
ABAD102415ACE7A00000EC47 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
ABAD102515ACE7A00000EC47 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
ABAD102615ACE7A00000EC47 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
ABAD102715ACE7A00000EC47 /* 2xsai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABFE14FA14C92FF5005D6699 /* 2xsai.cpp */; };
@ -957,10 +957,6 @@
AB3ACB6714C2361100D7D192 /* appDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = appDelegate.mm; sourceTree = "<group>"; };
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cheatWindowDelegate.h; sourceTree = "<group>"; };
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cheatWindowDelegate.mm; sourceTree = "<group>"; };
AB3ACB6A14C2361100D7D192 /* displayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = displayView.h; sourceTree = "<group>"; };
AB3ACB6B14C2361100D7D192 /* displayView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = displayView.mm; sourceTree = "<group>"; };
AB3ACB6C14C2361100D7D192 /* emuWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = emuWindowDelegate.h; sourceTree = "<group>"; };
AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = emuWindowDelegate.mm; sourceTree = "<group>"; };
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inputPrefsView.h; sourceTree = "<group>"; };
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = inputPrefsView.mm; sourceTree = "<group>"; };
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = preferencesWindowDelegate.h; sourceTree = "<group>"; };
@ -980,6 +976,9 @@
AB6A198116CAD66900384EED /* cocoa_GPU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_GPU.h; sourceTree = "<group>"; };
AB6A198216CAD66900384EED /* cocoa_GPU.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_GPU.mm; sourceTree = "<group>"; };
AB6FBEF5139B6258007BB045 /* slot1_retail_nand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slot1_retail_nand.cpp; sourceTree = "<group>"; };
AB700DB916CDDBC400FBD336 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = translations/English.lproj/DisplayWindow.xib; sourceTree = "<group>"; };
AB700DDC16CDE4C300FBD336 /* DisplayWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayWindowController.h; sourceTree = "<group>"; };
AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayWindowController.mm; sourceTree = "<group>"; };
AB711F7F1481C35F009011C8 /* DeSmuME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeSmuME.app; sourceTree = BUILT_PRODUCTS_DIR; };
AB73AA331507C9F500A310C8 /* DeSmuME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeSmuME.app; sourceTree = BUILT_PRODUCTS_DIR; };
AB75226D14C7BB51009B97B3 /* AppIcon_FirmwareConfig.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon_FirmwareConfig.icns; sourceTree = "<group>"; };
@ -1458,6 +1457,7 @@
children = (
ABC2ECD613B1C87000FAAA2A /* Images */,
AB00E87C14205EBC00DE561F /* MainMenu.xib */,
AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */,
AB350D3A147A1D93007165AC /* HID_usage_strings.plist */,
8D1107310486CEB800E47090 /* Info.plist */,
AB02791814415E4C0075E58C /* Info (Debug).plist */,
@ -1490,17 +1490,15 @@
children = (
AB3ACB6614C2361100D7D192 /* appDelegate.h */,
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */,
AB3ACB6A14C2361100D7D192 /* displayView.h */,
AB700DDC16CDE4C300FBD336 /* DisplayWindowController.h */,
AB6A187A16C9951C00384EED /* EmuControllerDelegate.h */,
AB3ACB6C14C2361100D7D192 /* emuWindowDelegate.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABA0356E169127BB00817C69 /* troubleshootingWindowDelegate.h */,
AB3ACB6714C2361100D7D192 /* appDelegate.mm */,
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */,
AB3ACB6B14C2361100D7D192 /* displayView.mm */,
AB700DDD16CDE4C300FBD336 /* DisplayWindowController.mm */,
AB6A187B16C9951C00384EED /* EmuControllerDelegate.mm */,
AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */,
@ -2165,6 +2163,7 @@
AB2F3BC115CF9C6000858373 /* README in Resources */,
AB2F3BC215CF9C6000858373 /* README.MAC in Resources */,
AB2F3BC315CF9C6000858373 /* AppIcon_FirmwareConfig.icns in Resources */,
AB700DBA16CDDBC400FBD336 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2243,6 +2242,7 @@
AB3ACC4714C24D5400D7D192 /* README in Resources */,
AB3ACC4914C24D5400D7D192 /* README.MAC in Resources */,
AB75226F14C7BB51009B97B3 /* AppIcon_FirmwareConfig.icns in Resources */,
AB700DBB16CDDBC400FBD336 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2321,6 +2321,7 @@
AB73A9AE1507C9F500A310C8 /* README in Resources */,
AB73A9B01507C9F500A310C8 /* README.MAC in Resources */,
AB73A9B11507C9F500A310C8 /* AppIcon_FirmwareConfig.icns in Resources */,
AB700DBD16CDDBC400FBD336 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2399,6 +2400,7 @@
ABAD0FB715ACE7A00000EC47 /* README in Resources */,
ABAD0FB815ACE7A00000EC47 /* README.MAC in Resources */,
ABAD0FB915ACE7A00000EC47 /* AppIcon_FirmwareConfig.icns in Resources */,
AB700DBC16CDDBC400FBD336 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2622,8 +2624,6 @@
AB2F3C2A15CF9C6000858373 /* OGLRender.cpp in Sources */,
AB2F3C2B15CF9C6000858373 /* appDelegate.mm in Sources */,
AB2F3C2C15CF9C6000858373 /* cheatWindowDelegate.mm in Sources */,
AB2F3C2D15CF9C6000858373 /* displayView.mm in Sources */,
AB2F3C2E15CF9C6000858373 /* emuWindowDelegate.mm in Sources */,
AB2F3C2F15CF9C6000858373 /* inputPrefsView.mm in Sources */,
AB2F3C3015CF9C6000858373 /* preferencesWindowDelegate.mm in Sources */,
AB2F3C3115CF9C6000858373 /* 2xsai.cpp in Sources */,
@ -2649,6 +2649,7 @@
AB279D6E16A4E6DE00ECC692 /* TDStretch.cpp in Sources */,
AB6A187C16C9951C00384EED /* EmuControllerDelegate.mm in Sources */,
AB6A198316CAD66900384EED /* cocoa_GPU.mm in Sources */,
AB700DDF16CDE4C300FBD336 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2750,8 +2751,6 @@
AB711F6E1481C35F009011C8 /* cocoa_videofilter.mm in Sources */,
AB3ACB7814C2361100D7D192 /* appDelegate.mm in Sources */,
AB3ACB7914C2361100D7D192 /* cheatWindowDelegate.mm in Sources */,
AB3ACB7A14C2361100D7D192 /* displayView.mm in Sources */,
AB3ACB7B14C2361100D7D192 /* emuWindowDelegate.mm in Sources */,
AB3ACB7C14C2361100D7D192 /* inputPrefsView.mm in Sources */,
AB3ACB7D14C2361100D7D192 /* preferencesWindowDelegate.mm in Sources */,
ABFE150F14C92FF5005D6699 /* 2xsai.cpp in Sources */,
@ -2807,6 +2806,7 @@
AB279D7916A4E6DE00ECC692 /* TDStretch.cpp in Sources */,
AB6A187E16C9951C00384EED /* EmuControllerDelegate.mm in Sources */,
AB6A198516CAD66900384EED /* cocoa_GPU.mm in Sources */,
AB700DE116CDE4C300FBD336 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2908,8 +2908,6 @@
AB73AA181507C9F500A310C8 /* OGLRender.cpp in Sources */,
AB73AA191507C9F500A310C8 /* appDelegate.mm in Sources */,
AB73AA1A1507C9F500A310C8 /* cheatWindowDelegate.mm in Sources */,
AB73AA1B1507C9F500A310C8 /* displayView.mm in Sources */,
AB73AA1C1507C9F500A310C8 /* emuWindowDelegate.mm in Sources */,
AB73AA1D1507C9F500A310C8 /* inputPrefsView.mm in Sources */,
AB73AA1E1507C9F500A310C8 /* preferencesWindowDelegate.mm in Sources */,
AB73AA1F1507C9F500A310C8 /* 2xsai.cpp in Sources */,
@ -2965,6 +2963,7 @@
AB279D6316A4E6DE00ECC692 /* TDStretch.cpp in Sources */,
AB6A187F16C9951C00384EED /* EmuControllerDelegate.mm in Sources */,
AB6A198616CAD66900384EED /* cocoa_GPU.mm in Sources */,
AB700DDE16CDE4C300FBD336 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3066,8 +3065,6 @@
ABAD102015ACE7A00000EC47 /* OGLRender.cpp in Sources */,
ABAD102115ACE7A00000EC47 /* appDelegate.mm in Sources */,
ABAD102215ACE7A00000EC47 /* cheatWindowDelegate.mm in Sources */,
ABAD102315ACE7A00000EC47 /* displayView.mm in Sources */,
ABAD102415ACE7A00000EC47 /* emuWindowDelegate.mm in Sources */,
ABAD102515ACE7A00000EC47 /* inputPrefsView.mm in Sources */,
ABAD102615ACE7A00000EC47 /* preferencesWindowDelegate.mm in Sources */,
ABAD102715ACE7A00000EC47 /* 2xsai.cpp in Sources */,
@ -3093,6 +3090,7 @@
AB279D8416A4E6DE00ECC692 /* TDStretch.cpp in Sources */,
AB6A187D16C9951C00384EED /* EmuControllerDelegate.mm in Sources */,
AB6A198416CAD66900384EED /* cocoa_GPU.mm in Sources */,
AB700DE016CDE4C300FBD336 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3123,6 +3121,14 @@
name = HID_usage_strings.plist;
sourceTree = "<group>";
};
AB700DB816CDDBC400FBD336 /* DisplayWindow.xib */ = {
isa = PBXVariantGroup;
children = (
AB700DB916CDDBC400FBD336 /* English */,
);
name = DisplayWindow.xib;
sourceTree = "<group>";
};
AB901BDD1420706100348EEC /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (

View File

@ -77,8 +77,6 @@
AB3A656316CC5438001F5D4A /* cocoa_GPU.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3A656016CC5438001F5D4A /* cocoa_GPU.mm */; };
AB3ACB7214C2361100D7D192 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
AB3ACB7314C2361100D7D192 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
AB3ACB7414C2361100D7D192 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
AB3ACB7514C2361100D7D192 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
AB3ACB7614C2361100D7D192 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
AB3ACB7714C2361100D7D192 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
AB3ACC3E14C24D5400D7D192 /* AUTHORS in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3814C24D5400D7D192 /* AUTHORS */; };
@ -360,8 +358,6 @@
AB796D5415CDCBA200C59155 /* cocoa_videofilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABE5DFE4143FB1DA00835AD8 /* cocoa_videofilter.mm */; };
AB796D5515CDCBA200C59155 /* appDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6714C2361100D7D192 /* appDelegate.mm */; };
AB796D5615CDCBA200C59155 /* cheatWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */; };
AB796D5715CDCBA200C59155 /* displayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6B14C2361100D7D192 /* displayView.mm */; };
AB796D5815CDCBA200C59155 /* emuWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */; };
AB796D5915CDCBA200C59155 /* inputPrefsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */; };
AB796D5A15CDCBA200C59155 /* preferencesWindowDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */; };
AB796D5B15CDCBA200C59155 /* 2xsai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABFE14FA14C92FF5005D6699 /* 2xsai.cpp */; };
@ -382,6 +378,10 @@
AB796D6B15CDCBA200C59155 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABC570D4134431DA00E7B0B1 /* OpenGL.framework */; };
AB796D6C15CDCBA200C59155 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AB0A0D1914AACA9600E83E91 /* libz.dylib */; };
AB80E04D142BC4A800A52038 /* cocoa_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB80E04C142BC4A800A52038 /* cocoa_util.mm */; };
AB8967D916D2ED0700F826F1 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB8967D816D2ED0700F826F1 /* DisplayWindowController.mm */; };
AB8967DA16D2ED0700F826F1 /* DisplayWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB8967D816D2ED0700F826F1 /* DisplayWindowController.mm */; };
AB8967DD16D2ED2700F826F1 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB8967DB16D2ED2700F826F1 /* DisplayWindow.xib */; };
AB8967DE16D2ED2700F826F1 /* DisplayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB8967DB16D2ED2700F826F1 /* DisplayWindow.xib */; };
AB901BDE1420706100348EEC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = AB901BDD1420706100348EEC /* Localizable.strings */; };
AB91D46B13BD013800462471 /* fs-linux.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEB21345AC8400AF11D1 /* fs-linux.cpp */; };
ABA6574B14511EC90077E5E9 /* cocoa_cheat.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABA6574A14511EC90077E5E9 /* cocoa_cheat.mm */; };
@ -692,10 +692,6 @@
AB3ACB6714C2361100D7D192 /* appDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = appDelegate.mm; sourceTree = "<group>"; };
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cheatWindowDelegate.h; sourceTree = "<group>"; };
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cheatWindowDelegate.mm; sourceTree = "<group>"; };
AB3ACB6A14C2361100D7D192 /* displayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = displayView.h; sourceTree = "<group>"; };
AB3ACB6B14C2361100D7D192 /* displayView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = displayView.mm; sourceTree = "<group>"; };
AB3ACB6C14C2361100D7D192 /* emuWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = emuWindowDelegate.h; sourceTree = "<group>"; };
AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = emuWindowDelegate.mm; sourceTree = "<group>"; };
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inputPrefsView.h; sourceTree = "<group>"; };
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = inputPrefsView.mm; sourceTree = "<group>"; };
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = preferencesWindowDelegate.h; sourceTree = "<group>"; };
@ -791,6 +787,9 @@
AB80E050142BC4FA00A52038 /* cocoa_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_util.h; sourceTree = "<group>"; };
AB817A34143EE2DB00A7DFE9 /* videofilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = videofilter.h; sourceTree = "<group>"; };
AB817A35143EE2DB00A7DFE9 /* videofilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = videofilter.cpp; sourceTree = "<group>"; };
AB8967D716D2ED0700F826F1 /* DisplayWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayWindowController.h; sourceTree = "<group>"; };
AB8967D816D2ED0700F826F1 /* DisplayWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayWindowController.mm; sourceTree = "<group>"; };
AB8967DC16D2ED2700F826F1 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = translations/English.lproj/DisplayWindow.xib; sourceTree = "<group>"; };
AB901BDF1420706B00348EEC /* Japanese */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = Japanese; path = translations/Japanese.lproj/Localizable.strings; sourceTree = "<group>"; };
AB901BE01420706F00348EEC /* French */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = French; path = translations/French.lproj/Localizable.strings; sourceTree = "<group>"; };
AB901BE11420707400348EEC /* Italian */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = Italian; path = translations/Italian.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1202,6 +1201,7 @@
children = (
ABC2ECD613B1C87000FAAA2A /* Images */,
AB00E87C14205EBC00DE561F /* MainMenu.xib */,
AB8967DB16D2ED2700F826F1 /* DisplayWindow.xib */,
AB350D3A147A1D93007165AC /* HID_usage_strings.plist */,
8D1107310486CEB800E47090 /* Info.plist */,
AB02791814415E4C0075E58C /* Info (Debug).plist */,
@ -1234,17 +1234,15 @@
children = (
AB3ACB6614C2361100D7D192 /* appDelegate.h */,
AB3ACB6814C2361100D7D192 /* cheatWindowDelegate.h */,
AB3ACB6A14C2361100D7D192 /* displayView.h */,
AB8967D716D2ED0700F826F1 /* DisplayWindowController.h */,
AB3A655C16CC5416001F5D4A /* EmuControllerDelegate.h */,
AB3ACB6C14C2361100D7D192 /* emuWindowDelegate.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABF2B9F81690412A000FF7C0 /* troubleshootingWindowDelegate.h */,
AB3ACB6714C2361100D7D192 /* appDelegate.mm */,
AB3ACB6914C2361100D7D192 /* cheatWindowDelegate.mm */,
AB3ACB6B14C2361100D7D192 /* displayView.mm */,
AB8967D816D2ED0700F826F1 /* DisplayWindowController.mm */,
AB3A655D16CC5421001F5D4A /* EmuControllerDelegate.mm */,
AB3ACB6D14C2361100D7D192 /* emuWindowDelegate.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABF2B9FA16904133000FF7C0 /* troubleshootingWindowDelegate.mm */,
@ -1903,6 +1901,7 @@
AB3ACC4114C24D5400D7D192 /* README in Resources */,
AB3ACC4314C24D5400D7D192 /* README.MAC in Resources */,
AB75226E14C7BB51009B97B3 /* AppIcon_FirmwareConfig.icns in Resources */,
AB8967DE16D2ED2700F826F1 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1981,6 +1980,7 @@
AB796CEB15CDCBA200C59155 /* README in Resources */,
AB796CEC15CDCBA200C59155 /* README.MAC in Resources */,
AB796CED15CDCBA200C59155 /* AppIcon_FirmwareConfig.icns in Resources */,
AB8967DD16D2ED2700F826F1 /* DisplayWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2192,8 +2192,6 @@
AB0F291D14BE6F4A009ABC6F /* OGLRender.cpp in Sources */,
AB3ACB7214C2361100D7D192 /* appDelegate.mm in Sources */,
AB3ACB7314C2361100D7D192 /* cheatWindowDelegate.mm in Sources */,
AB3ACB7414C2361100D7D192 /* displayView.mm in Sources */,
AB3ACB7514C2361100D7D192 /* emuWindowDelegate.mm in Sources */,
AB3ACB7614C2361100D7D192 /* inputPrefsView.mm in Sources */,
AB3ACB7714C2361100D7D192 /* preferencesWindowDelegate.mm in Sources */,
ABFE150714C92FF5005D6699 /* 2xsai.cpp in Sources */,
@ -2240,6 +2238,7 @@
AB23567516C2FAD800DA782E /* OGLRender_3_2.cpp in Sources */,
AB3A655F16CC5421001F5D4A /* EmuControllerDelegate.mm in Sources */,
AB3A656216CC5438001F5D4A /* cocoa_GPU.mm in Sources */,
AB8967DA16D2ED0700F826F1 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2351,8 +2350,6 @@
AB796D5415CDCBA200C59155 /* cocoa_videofilter.mm in Sources */,
AB796D5515CDCBA200C59155 /* appDelegate.mm in Sources */,
AB796D5615CDCBA200C59155 /* cheatWindowDelegate.mm in Sources */,
AB796D5715CDCBA200C59155 /* displayView.mm in Sources */,
AB796D5815CDCBA200C59155 /* emuWindowDelegate.mm in Sources */,
AB796D5915CDCBA200C59155 /* inputPrefsView.mm in Sources */,
AB796D5A15CDCBA200C59155 /* preferencesWindowDelegate.mm in Sources */,
AB796D5B15CDCBA200C59155 /* 2xsai.cpp in Sources */,
@ -2398,6 +2395,7 @@
AB26D87C16B5253D00A2305C /* OGLRender_3_2.cpp in Sources */,
AB3A655E16CC5421001F5D4A /* EmuControllerDelegate.mm in Sources */,
AB3A656116CC5438001F5D4A /* cocoa_GPU.mm in Sources */,
AB8967D916D2ED0700F826F1 /* DisplayWindowController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2573,6 +2571,14 @@
name = HID_usage_strings.plist;
sourceTree = "<group>";
};
AB8967DB16D2ED2700F826F1 /* DisplayWindow.xib */ = {
isa = PBXVariantGroup;
children = (
AB8967DC16D2ED2700F826F1 /* English */,
);
name = DisplayWindow.xib;
sourceTree = "<group>";
};
AB901BDD1420706100348EEC /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (

View File

@ -37,7 +37,8 @@ typedef struct
unsigned int framesToSkip;
uint64_t timeBudgetMachAbsTime;
bool exitThread;
pthread_mutex_t *mutexCoreExecute;
pthread_mutex_t mutexCoreExecute;
pthread_mutex_t mutexOutputList;
pthread_mutex_t mutexThreadExecute;
pthread_cond_t condThreadExecute;
} CoreThreadParam;
@ -68,7 +69,6 @@ typedef struct
BOOL emuFlagEmulateEnsata;
NSInteger cpuEmulationEngine;
pthread_mutex_t *mutexCoreExecute;
OSSpinLock spinlockCdsController;
OSSpinLock spinlockMasterExecute;
OSSpinLock spinlockExecutionChange;

View File

@ -66,7 +66,7 @@ volatile bool execute = true;
@dynamic arm7ImageURL;
@dynamic firmwareImageURL;
@synthesize mutexCoreExecute;
@dynamic mutexCoreExecute;
static BOOL isCoreStarted = NO;
@ -94,8 +94,6 @@ static BOOL isCoreStarted = NO;
emuFlagDebugConsole = NO;
emuFlagEmulateEnsata = NO;
mutexCoreExecute = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(mutexCoreExecute, NULL);
spinlockMasterExecute = OS_SPINLOCK_INIT;
spinlockCdsController = OS_SPINLOCK_INIT;
spinlockExecutionChange = OS_SPINLOCK_INIT;
@ -119,12 +117,13 @@ static BOOL isCoreStarted = NO;
threadParam.timeBudgetMachAbsTime = *(uint64_t *)&timeBudgetAbsTime;
threadParam.exitThread = false;
threadParam.mutexCoreExecute = mutexCoreExecute;
pthread_mutex_init(&threadParam.mutexCoreExecute, NULL);
pthread_mutex_init(&threadParam.mutexOutputList, NULL);
pthread_mutex_init(&threadParam.mutexThreadExecute, NULL);
pthread_cond_init(&threadParam.condThreadExecute, NULL);
pthread_create(&coreThread, NULL, &RunCoreThread, &threadParam);
[cdsGPU setMutexProducer:mutexCoreExecute];
[cdsGPU setMutexProducer:self.mutexCoreExecute];
return self;
}
@ -155,10 +154,6 @@ static BOOL isCoreStarted = NO;
pthread_mutex_destroy(&threadParam.mutexThreadExecute);
pthread_cond_destroy(&threadParam.condThreadExecute);
pthread_mutex_destroy(self.mutexCoreExecute);
free(self.mutexCoreExecute);
mutexCoreExecute = nil;
self.cdsController = nil;
self.cdsFirmware = nil;
self.cdsGPU = nil;
@ -166,6 +161,9 @@ static BOOL isCoreStarted = NO;
[self removeAllOutputs];
[cdsOutputList release];
pthread_mutex_destroy(&threadParam.mutexOutputList);
pthread_mutex_destroy(&threadParam.mutexCoreExecute);
[super dealloc];
}
@ -337,7 +335,7 @@ static BOOL isCoreStarted = NO;
emulationFlags = theFlags;
OSSpinLockUnlock(&spinlockEmulationFlags);
pthread_mutex_lock(self.mutexCoreExecute);
pthread_mutex_lock(&threadParam.mutexCoreExecute);
if (theFlags & EMULATION_ADVANCED_BUS_LEVEL_TIMING_MASK)
{
@ -438,7 +436,7 @@ static BOOL isCoreStarted = NO;
CommonSettings.DebugConsole = false;
}
pthread_mutex_unlock(self.mutexCoreExecute);
pthread_mutex_unlock(&threadParam.mutexCoreExecute);
}
- (NSUInteger) emulationFlags
@ -548,6 +546,11 @@ static BOOL isCoreStarted = NO;
return [NSURL fileURLWithPath:[NSString stringWithCString:CommonSettings.Firmware encoding:NSUTF8StringEncoding]];
}
- (pthread_mutex_t *) mutexCoreExecute
{
return &threadParam.mutexCoreExecute;
}
- (void) setEjectCardFlag
{
if (nds.cardEjected)
@ -572,9 +575,9 @@ static BOOL isCoreStarted = NO;
- (void) changeRomSaveType:(NSInteger)saveTypeID
{
pthread_mutex_lock(self.mutexCoreExecute);
pthread_mutex_lock(&threadParam.mutexCoreExecute);
[CocoaDSRom changeRomSaveType:saveTypeID];
pthread_mutex_unlock(self.mutexCoreExecute);
pthread_mutex_unlock(&threadParam.mutexCoreExecute);
}
- (void) changeExecutionSpeed
@ -648,18 +651,24 @@ static BOOL isCoreStarted = NO;
- (void) addOutput:(CocoaDSOutput *)theOutput
{
pthread_mutex_lock(&threadParam.mutexOutputList);
theOutput.mutexProducer = self.mutexCoreExecute;
[self.cdsOutputList addObject:theOutput];
pthread_mutex_unlock(&threadParam.mutexOutputList);
}
- (void) removeOutput:(CocoaDSOutput *)theOutput
{
pthread_mutex_lock(&threadParam.mutexOutputList);
[self.cdsOutputList removeObject:theOutput];
pthread_mutex_unlock(&threadParam.mutexOutputList);
}
- (void) removeAllOutputs
{
pthread_mutex_lock(&threadParam.mutexOutputList);
[self.cdsOutputList removeAllObjects];
pthread_mutex_unlock(&threadParam.mutexOutputList);
}
- (void) runThread:(id)object
@ -709,9 +718,9 @@ static void* RunCoreThread(void *arg)
NDS_endProcessingInput();
// Execute the frame and increment the frame counter.
pthread_mutex_lock(param->mutexCoreExecute);
pthread_mutex_lock(&param->mutexCoreExecute);
NDS_exec<false>();
pthread_mutex_unlock(param->mutexCoreExecute);
pthread_mutex_unlock(&param->mutexCoreExecute);
// Check if an internal execution error occurred that halted the emulation.
if (!execute)
@ -727,6 +736,7 @@ static void* RunCoreThread(void *arg)
param->frameCount++;
}
pthread_mutex_lock(&param->mutexOutputList);
for(CocoaDSOutput *cdsOutput in cdsOutputList)
{
if (param->framesToSkip > 0 && [cdsOutput isMemberOfClass:[CocoaDSDisplay class]])
@ -736,6 +746,7 @@ static void* RunCoreThread(void *arg)
[cdsOutput doCoreEmuFrame];
}
pthread_mutex_unlock(&param->mutexOutputList);
// Determine the number of frames to skip based on how much time "debt"
// we owe on timeBudget.

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2013 DeSmuME team
Copyright (C) 2012-2013 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
@ -48,6 +48,8 @@
#define NSSTRING_TITLE_ENABLE_HUD NSLocalizedString(@"Enable HUD", nil)
#define NSSTRING_TITLE_HIDE_STATUS_BAR NSLocalizedString(@"Hide Status Bar", nil)
#define NSSTRING_TITLE_SHOW_STATUS_BAR NSLocalizedString(@"Show Status Bar", nil)
#define NSSTRING_TITLE_HIDE_TOOLBAR NSLocalizedString(@"Hide Toolbar", nil)
#define NSSTRING_TITLE_SHOW_TOOLBAR NSLocalizedString(@"Show Toolbar", nil)
#define NSSTRING_TITLE_SPEED_1X NSLocalizedString(@"Speed 1x", nil)
#define NSSTRING_TITLE_SPEED_2X NSLocalizedString(@"Speed 2x", nil)
#define NSSTRING_TITLE_SLOT_NUMBER NSLocalizedString(@"Slot %ld", nil)

View File

@ -117,7 +117,6 @@ typedef struct
@required
- (void) doDisplayModeChanged:(NSInteger)displayModeID;
@property (retain) NSPort *sendPortDisplay;
@property (assign) BOOL isHudEnabled;
@property (assign) BOOL isHudEditingModeEnabled;

View File

@ -43,7 +43,7 @@
- (id)init
{
self = [super init];
self = [super initWithAutoreleaseInterval:0.1];
if (self == nil)
{
return self;
@ -65,17 +65,8 @@
- (void)dealloc
{
// Exit the thread.
if (self.thread != nil)
{
self.threadExit = YES;
// Wait until the thread has shut down.
while (self.thread != nil)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
}
}
// Force the thread to exit now so that we can safely release other resources.
[self forceThreadExit];
self.frameData = nil;
self.frameAttributesData = nil;
@ -474,7 +465,6 @@
if (theDelegate != nil)
{
[theDelegate retain];
[theDelegate setSendPortDisplay:self.receivePort];
}
[delegate release];
@ -822,7 +812,6 @@
if (theDelegate != nil)
{
[theDelegate retain];
[theDelegate setSendPortDisplay:self.receivePort];
}
[videoDelegate release];

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2012 DeSmuME team
Copyright (C) 2012-2013 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
@ -67,14 +67,15 @@
NSPort *receivePort;
}
@property (retain) NSThread *thread;
@property (assign) NSThread *thread;
@property (assign) BOOL threadExit;
@property (assign) NSTimeInterval autoreleaseInterval;
@property (retain) NSPort *sendPort;
@property (readonly) NSPort *receivePort;
@property (assign) NSPort *sendPort;
@property (assign) NSPort *receivePort;
- (id) initWithAutoreleaseInterval:(NSTimeInterval)interval;
- (void) runThread:(id)object;
- (void) forceThreadExit;
@end

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2013 DeSmuME team
Copyright (C) 2012-2013 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
@ -35,6 +35,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWay:(NSPort *)sendPort msgID:(NSInteger)msgID
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSPortMessage *message = [[NSPortMessage alloc] initWithSendPort:sendPort receivePort:nil components:nil];
[message setMsgid:msgID];
[message sendBeforeDate:distantFutureDate];
@ -43,6 +48,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithMessageComponents:(NSPort *)sendPort msgID:(NSInteger)msgID array:(NSArray *)msgDataArray
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSPortMessage *message = [[NSPortMessage alloc] initWithSendPort:sendPort receivePort:nil components:msgDataArray];
[message setMsgid:msgID];
[message sendBeforeDate:distantFutureDate];
@ -51,6 +61,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithData:(NSPort *)sendPort msgID:(NSInteger)msgID data:(NSData *)msgData
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSArray *messageComponents = [[NSArray alloc] initWithObjects:msgData, nil];
[CocoaDSUtil messageSendOneWayWithMessageComponents:sendPort msgID:msgID array:messageComponents];
[messageComponents release];
@ -58,6 +73,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithInteger:(NSPort *)sendPort msgID:(NSInteger)msgID integerValue:(NSInteger)integerValue
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSData *messageData = [[NSData alloc] initWithBytes:&integerValue length:sizeof(NSInteger)];
[CocoaDSUtil messageSendOneWayWithData:sendPort msgID:msgID data:messageData];
[messageData release];
@ -65,6 +85,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithFloat:(NSPort *)sendPort msgID:(NSInteger)msgID floatValue:(float)floatValue
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSData *messageData = [[NSData alloc] initWithBytes:&floatValue length:sizeof(float)];
[CocoaDSUtil messageSendOneWayWithData:sendPort msgID:msgID data:messageData];
[messageData release];
@ -72,6 +97,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithBool:(NSPort *)sendPort msgID:(NSInteger)msgID boolValue:(BOOL)boolValue
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSData *messageData = [[NSData alloc] initWithBytes:&boolValue length:sizeof(BOOL)];
[CocoaDSUtil messageSendOneWayWithData:sendPort msgID:msgID data:messageData];
[messageData release];
@ -79,6 +109,11 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
+ (void) messageSendOneWayWithRect:(NSPort *)sendPort msgID:(NSInteger)msgID rect:(NSRect)rect
{
if (sendPort == nil || ![sendPort isValid])
{
return;
}
NSData *messageData = [[NSData alloc] initWithBytes:&rect length:sizeof(NSRect)];
[CocoaDSUtil messageSendOneWayWithData:sendPort msgID:msgID data:messageData];
[messageData release];
@ -239,21 +274,7 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
- (void)dealloc
{
// Exit the thread.
if (self.thread != nil)
{
// Tell the thread to shut down.
self.threadExit = YES;
// Wait until the thread has shut down.
while (self.thread != nil)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
}
}
self.sendPort = nil;
[receivePort release];
[self forceThreadExit];
[super dealloc];
}
@ -261,24 +282,48 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
- (void) runThread:(id)object
{
NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init];
NSRunLoop *runLoop = [[NSRunLoop currentRunLoop] retain];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop addPort:self.receivePort forMode:NSDefaultRunLoopMode];
self.thread = [NSThread currentThread];
[runLoop addPort:[self receivePort] forMode:NSDefaultRunLoopMode];
[self setThread:[NSThread currentThread]];
do
{
NSAutoreleasePool *runLoopPool = [[NSAutoreleasePool alloc] init];
NSDate *runDate = [[NSDate alloc] initWithTimeIntervalSinceNow:self.autoreleaseInterval];
NSDate *runDate = [[NSDate alloc] initWithTimeIntervalSinceNow:[self autoreleaseInterval]];
[runLoop runUntilDate:runDate];
[runDate release];
[runLoopPool release];
} while (!self.threadExit);
} while (![self threadExit]);
self.thread = nil;
[runLoop release];
NSPort *tempSendPort = [self sendPort];
[self setSendPort:nil];
[tempSendPort invalidate];
[tempSendPort release];
NSPort *tempReceivePort = [self receivePort];
[self setReceivePort:nil];
[tempReceivePort invalidate];
[tempReceivePort release];
[threadPool release];
[self setThread:nil];
}
- (void) forceThreadExit
{
if ([self thread] == nil)
{
return;
}
[self setThreadExit:YES];
// Wait until the thread has shut down.
while ([self thread] != nil)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
}
}
- (void)handlePortMessage:(NSPortMessage *)portMessage
@ -288,7 +333,7 @@ static NSDate *distantFutureDate = [[NSDate distantFuture] retain];
switch (message)
{
case MESSAGE_EXIT_THREAD:
self.threadExit = YES;
[self setThreadExit:YES];
break;
default:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2013 DeSmuME team
Copyright (C) 2013 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
@ -14,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#import <Cocoa/Cocoa.h>
#include <OpenGL/OpenGL.h>
@ -22,104 +21,22 @@
#import "cocoa_output.h"
enum OGLVertexAttributeID
{
OGLVertexAttributeID_Position = 0,
OGLVertexAttributeID_TexCoord0 = 8
};
@class DisplayViewDelegate;
@class CocoaDSController;
@class EmuControllerDelegate;
@protocol DisplayViewDelegate
@required
- (void) doInitVideoOutput:(NSDictionary *)properties;
- (void) doProcessVideoFrame:(const void *)videoFrameData displayMode:(const NSInteger)displayModeID width:(const NSInteger)frameWidth height:(const NSInteger)frameHeight;
@property (retain) DisplayViewDelegate *dispViewDelegate;
@optional
- (void) doResizeView:(NSRect)rect;
- (void) doTransformView:(const DisplayOutputTransformData *)transformData;
- (void) doRedraw;
- (void) doDisplayModeChanged:(NSInteger)displayModeID;
- (void) doDisplayOrientationChanged:(NSInteger)displayOrientationID;
- (void) doDisplayOrderChanged:(NSInteger)displayOrderID;
- (void) doBilinearOutputChanged:(BOOL)useBilinear;
- (void) doVerticalSyncChanged:(BOOL)useVerticalSync;
- (void) doVideoFilterChanged:(NSInteger)videoFilterTypeID frameSize:(NSSize)videoFilterDestSize;
@end
@interface DisplayViewDelegate : NSObject <CocoaDSDisplayVideoDelegate>
@interface DisplayView : NSView <CocoaDSDisplayVideoDelegate>
{
NSView <DisplayViewDelegate> *view;
NSPort *sendPortDisplay;
NSPort *sendPortInput;
CocoaDSController *cdsController;
// Display thread
BOOL isHudEnabled;
BOOL isHudEditingModeEnabled;
NSSize normalSize;
NSMutableDictionary *bindings;
OSSpinLock spinlockNormalSize;
OSSpinLock spinlockScale;
OSSpinLock spinlockRotation;
OSSpinLock spinlockUseBilinearOutput;
OSSpinLock spinlockUseVerticalSync;
OSSpinLock spinlockDisplayType;
OSSpinLock spinlockDisplayOrientation;
OSSpinLock spinlockDisplayOrder;
}
@property (retain) NSView <DisplayViewDelegate> *view;
@property (retain) NSPort *sendPortInput;
@property (retain) CocoaDSController *cdsController;
@property (readonly) NSSize normalSize;
@property (assign) double scale;
@property (assign) double rotation;
@property (assign) BOOL useBilinearOutput;
@property (assign) BOOL useVerticalSync;
@property (assign) NSInteger displayMode;
@property (assign) NSInteger displayOrientation;
@property (assign) NSInteger displayOrder;
@property (readonly) NSMutableDictionary *bindings;
- (void) setVideoFilterType:(NSInteger)theType;
- (void) setViewToBlack;
- (void) setViewToWhite;
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType;
- (void) copyToPasteboard;
- (NSPoint) dsPointFromEvent:(NSEvent *)theEvent;
- (NSPoint) convertPointToDS:(NSPoint)clickLoc;
- (BOOL) handleKeyPress:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
- (BOOL) handleMouseButton:(NSEvent *)theEvent buttonPressed:(BOOL)buttonPressed;
@end
@interface ImageDisplayView : NSImageView <DisplayViewDelegate>
{
DisplayViewDelegate *dispViewDelegate;
NSImage *imageData;
NSBitmapImageRep *currentImageRep;
}
- (NSBitmapImageRep *) bitmapImageRep:(const void *)videoFrameData displayMode:(const NSInteger)displayModeID width:(const NSInteger)imageWidth height:(const NSInteger)imageHeight;
@end
@interface OpenGLDisplayView : NSOpenGLView <DisplayViewDelegate>
{
// OpenGL context
NSOpenGLContext *context;
CGLContextObj cglDisplayContext;
BOOL isShaderSupported;
DisplayViewDelegate *dispViewDelegate;
NSInteger lastDisplayMode;
NSInteger currentDisplayOrientation;
GLenum glTexPixelFormat;
@ -130,13 +47,11 @@ enum OGLVertexAttributeID
GLuint vboVertexID;
GLuint vboTexCoordID;
GLuint vboElementID;
GLuint vaoMainStatesID;
GLuint vertexShaderID;
GLuint fragmentShaderID;
GLuint shaderProgram;
GLuint vaoMainStatesID;
GLint uniformAngleDegrees;
GLint uniformScalar;
GLint uniformViewSize;
@ -145,10 +60,13 @@ enum OGLVertexAttributeID
GLfloat texCoordBuffer[2 * 8];
GLubyte vtxIndexBuffer[12];
BOOL isShaderSupported;
unsigned int vtxBufferOffset;
}
- (void) setupOpenGL;
@property (retain) CocoaDSController *cdsController;
- (void) startupOpenGL;
- (void) shutdownOpenGL;
- (void) setupShaderIO;
- (BOOL) setupShadersWithVertexProgram:(const char *)vertShaderProgram fragmentProgram:(const char *)fragShaderProgram;
@ -160,4 +78,86 @@ enum OGLVertexAttributeID
- (void) updateDisplayVerticesUsingDisplayMode:(const NSInteger)displayModeID orientation:(const NSInteger)displayOrientationID;
- (void) updateTexCoordS:(GLfloat)s T:(GLfloat)t;
- (NSPoint) dsPointFromEvent:(NSEvent *)theEvent;
- (NSPoint) convertPointToDS:(NSPoint)clickLoc;
- (BOOL) handleKeyPress:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
- (BOOL) handleMouseButton:(NSEvent *)theEvent buttonPressed:(BOOL)buttonPressed;
- (void) clearToBlack;
- (void) clearToWhite;
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType;
@end
@interface DisplayWindowController : NSWindowController
{
DisplayView *view;
NSView *saveScreenshotPanelAccessoryView;
EmuControllerDelegate *emuControl;
CocoaDSDisplayVideo *cdsVideoOutput;
NSSize _normalSize;
double _displayScale;
double _displayRotation;
BOOL _useBilinearOutput;
BOOL _useVerticalSync;
NSInteger _displayMode;
NSInteger _displayOrientation;
NSInteger _displayOrder;
NSInteger _videoFilterType;
NSInteger screenshotFileFormat;
NSSize _minDisplayViewSize;
BOOL _isMinSizeNormal;
NSUInteger _statusBarHeight;
OSSpinLock spinlockNormalSize;
OSSpinLock spinlockScale;
OSSpinLock spinlockRotation;
OSSpinLock spinlockUseBilinearOutput;
OSSpinLock spinlockUseVerticalSync;
OSSpinLock spinlockDisplayMode;
OSSpinLock spinlockDisplayOrientation;
OSSpinLock spinlockDisplayOrder;
OSSpinLock spinlockVideoFilterType;
}
@property (readonly) IBOutlet DisplayView *view;
@property (readonly) IBOutlet NSView *saveScreenshotPanelAccessoryView;
@property (retain) EmuControllerDelegate *emuControl;
@property (assign) CocoaDSDisplayVideo *cdsVideoOutput;
@property (readonly) NSSize normalSize;
@property (assign) double displayScale;
@property (assign) double displayRotation;
@property (assign) BOOL useBilinearOutput;
@property (assign) BOOL useVerticalSync;
@property (assign) NSInteger displayMode;
@property (assign) NSInteger displayOrientation;
@property (assign) NSInteger displayOrder;
@property (assign) NSInteger videoFilterType;
@property (assign) NSInteger screenshotFileFormat;
@property (assign) BOOL isMinSizeNormal;
@property (assign) BOOL isShowingStatusBar;
- (id)initWithWindowNibName:(NSString *)windowNibName emuControlDelegate:(EmuControllerDelegate *)theEmuController;
- (void) setCdsController:(CocoaDSController *)theController;
- (void) setupUserDefaults;
- (double) resizeWithTransform:(NSSize)normalBounds scalar:(double)scalar rotation:(double)angleDegrees;
- (double) maxContentScalar:(NSSize)contentBounds;
- (IBAction) copy:(id)sender;
- (IBAction) changeVolume:(id)sender;
- (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender;
- (IBAction) toggleStatusBar:(id)sender;
- (IBAction) executeCoreToggle:(id)sender;
- (IBAction) resetCore:(id)sender;
- (IBAction) changeCoreSpeed:(id)sender;
- (IBAction) openRom:(id)sender;
- (IBAction) changeRotationRelative:(id)sender;
- (IBAction) saveScreenshotAs:(id)sender;
@end

View File

@ -16,12 +16,15 @@
*/
#import <Cocoa/Cocoa.h>
#include <libkern/OSAtomic.h>
@class CocoaDSRom;
@class CocoaDSFirmware;
@class CocoaDSOutput;
@class CocoaDSSpeaker;
@class CocoaDSCheatManager;
@class CheatWindowDelegate;
@class DisplayWindowController;
@interface EmuControllerDelegate : NSObject <NSUserInterfaceValidations>
@ -68,7 +71,11 @@
NSImage *iconSpeedNormal;
NSImage *iconSpeedDouble;
DisplayWindowController *mainWindow;
NSMutableArray *windowList;
OSSpinLock spinlockFirmware;
OSSpinLock spinlockSpeaker;
}
@property (assign) CocoaDSRom *currentRom; // Don't rely on autorelease since the emulator doesn't support concurrent unloading
@ -89,6 +96,15 @@
@property (readonly) IBOutlet NSWindow *saveStatePrecloseSheet;
@property (readonly) IBOutlet NSView *exportRomSavePanelAccessoryView;
@property (readonly) NSImage *iconExecute;
@property (readonly) NSImage *iconPause;
@property (readonly) NSImage *iconSpeedNormal;
@property (readonly) NSImage *iconSpeedDouble;
@property (readonly) BOOL masterExecuteFlag;
@property (readonly) NSInteger executionState;
@property (readonly) CGFloat speedScalar;
@property (assign) BOOL isWorking;
@property (assign) BOOL isRomLoading;
@property (assign) NSString *statusText;
@ -110,10 +126,13 @@
@property (assign) BOOL render3DLineHack;
@property (assign) BOOL render3DMultisample;
@property (retain) DisplayWindowController *mainWindow;
@property (readonly) NSMutableArray *windowList;
// File Menu
- (IBAction) newDisplayWindow:(id)sender;
- (IBAction) openRom:(id)sender;
- (IBAction) closeWindow:(id)sender;
- (IBAction) closeRom:(id)sender;
- (IBAction) openEmuSaveState:(id)sender;
- (IBAction) saveEmuSaveState:(id)sender;
@ -125,6 +144,9 @@
- (IBAction) exportRomSave:(id)sender;
- (IBAction) selectExportRomSaveFormat:(id)sender;
// Edit Menu
- (IBAction) copy:(id)sender;
// Emulation Menu
- (IBAction) speedLimitDisable:(id)sender;
- (IBAction) toggleAutoFrameSkip:(id)sender;
@ -133,21 +155,21 @@
- (IBAction) resetCore:(id)sender;
- (IBAction) changeRomSaveType:(id)sender;
// View Menu
- (IBAction) changeScale:(id)sender;
- (IBAction) changeRotation:(id)sender;
- (IBAction) changeRotationRelative:(id)sender;
- (IBAction) changeDisplayMode:(id)sender;
- (IBAction) changeDisplayOrientation:(id)sender;
- (IBAction) changeDisplayOrder:(id)sender;
- (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender;
- (IBAction) toggleStatusBar:(id)sender;
- (IBAction) toggleToolbarShown:(id)sender;
- (IBAction) runToolbarCustomizationPalette:(id)sender;
// Tools Menu
- (IBAction) toggleGPUState:(id)sender;
// Window Menu
- (IBAction) newDisplayWindow:(id)sender;
- (BOOL) handleLoadRom:(NSURL *)fileURL;
- (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL;
- (BOOL) loadRom:(NSURL *)romURL;
- (void) loadRomDidFinish:(NSNotification *)aNotification;
- (BOOL) unloadRom;
- (void) executeCore;
- (void) pauseCore;
- (void) restoreCoreState;
- (IBAction) saveScreenshotAs:(id)sender;
- (IBAction) changeCoreSpeed:(id)sender;
- (IBAction) changeCoreEmuFlags:(id)sender;
@ -159,15 +181,35 @@
- (IBAction) changeSpuSyncMode:(id)sender;
- (IBAction) changeSpuSyncMethod:(id)sender;
// Misc IBActions
- (IBAction) writeDefaultsDisplayRotation:(id)sender;
- (IBAction) writeDefaultsHUDSettings:(id)sender;
- (IBAction) writeDefaultsDisplayVideoSettings:(id)sender;
- (IBAction) writeDefaults3DRenderingSettings:(id)sender;
- (IBAction) writeDefaultsEmulationSettings:(id)sender;
- (IBAction) writeDefaultsSoundSettings:(id)sender;
- (IBAction) closeSheet:(id)sender;
- (BOOL) handleLoadRom:(NSURL *)fileURL;
- (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL;
- (BOOL) loadRom:(NSURL *)romURL;
- (void) loadRomDidFinish:(NSNotification *)aNotification;
- (BOOL) unloadRom;
- (void) addOutputToCore:(CocoaDSOutput *)theOutput;
- (void) removeOutputFromCore:(CocoaDSOutput *)theOutput;
- (void) executeCore;
- (void) pauseCore;
- (void) restoreCoreState;
- (void) didEndFileMigrationSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (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) updateAllWindowTitles;
- (void) setupUserDefaults;
- (IBAction) writeDefaults3DRenderingSettings:(id)sender;
- (IBAction) writeDefaultsEmulationSettings:(id)sender;
- (IBAction) writeDefaultsSoundSettings:(id)sender;
@end

File diff suppressed because it is too large Load Diff

View File

@ -36,12 +36,10 @@
NSObjectController *emuControlController;
NSObjectController *cdsSoundController;
NSObjectController *romInfoPanelController;
NSObjectController *emuWindowController;
NSObjectController *prefWindowController;
NSObjectController *cheatWindowController;
NSObjectController *cdsCoreController;
NSWindow *mainWindow;
NSWindow *prefWindow;
NSWindow *troubleshootingWindow;
NSWindow *cheatListWindow;
@ -70,11 +68,9 @@
@property (readonly) IBOutlet NSObjectController *emuControlController;
@property (readonly) IBOutlet NSObjectController *cdsSoundController;
@property (readonly) IBOutlet NSObjectController *romInfoPanelController;
@property (readonly) IBOutlet NSObjectController *emuWindowController;
@property (readonly) IBOutlet NSObjectController *prefWindowController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSObjectController *cdsCoreController;
@property (readonly) IBOutlet NSWindow *mainWindow;
@property (readonly) IBOutlet NSWindow *prefWindow;
@property (readonly) IBOutlet NSWindow *troubleshootingWindow;
@property (readonly) IBOutlet NSWindow *cheatListWindow;

View File

@ -17,12 +17,11 @@
*/
#import "appDelegate.h"
#import "DisplayWindowController.h"
#import "EmuControllerDelegate.h"
#import "emuWindowDelegate.h"
#import "preferencesWindowDelegate.h"
#import "troubleshootingWindowDelegate.h"
#import "cheatWindowDelegate.h"
#import "displayView.h"
#import "inputPrefsView.h"
#import "cocoa_core.h"
@ -39,7 +38,6 @@
@implementation AppDelegate
@dynamic dummyObject;
@synthesize mainWindow;
@synthesize prefWindow;
@synthesize troubleshootingWindow;
@synthesize cheatListWindow;
@ -53,7 +51,6 @@
@synthesize emuControlController;
@synthesize cdsSoundController;
@synthesize romInfoPanelController;
@synthesize emuWindowController;
@synthesize prefWindowController;
@synthesize cdsCoreController;
@synthesize cheatWindowController;
@ -100,8 +97,7 @@
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
EmuWindowDelegate *mainWindowDelegate = [mainWindow delegate];
PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate];
PreferencesWindowDelegate *prefWindowDelegate = (PreferencesWindowDelegate *)[prefWindow delegate];
CheatWindowDelegate *cheatWindowDelegate = (CheatWindowDelegate *)[cheatListWindow delegate];
// Determine if we're running on Intel or PPC.
@ -119,7 +115,6 @@
return;
}
[[emuControl windowList] addObject:mainWindow];
[CocoaDSFile setupAllFilePaths];
// Setup the About window.
@ -151,7 +146,7 @@
if (prefsDict == nil)
{
[[NSAlert alertWithMessageText:NSSTRING_ALERT_CRITICAL_FILE_MISSING_PRI defaultButton:nil alternateButton:nil otherButton:nil informativeTextWithFormat:NSSTRING_ALERT_CRITICAL_FILE_MISSING_SEC] runModal];
[NSApp terminate: nil];
[NSApp terminate:nil];
return;
}
@ -162,9 +157,7 @@
[self setRomInfoPanelBoxTitleColors];
// Set up all the object controllers according to our default windows.
[cdsSoundController setContent:nil];
[romInfoPanelController setContent:[CocoaDSRom romNotLoadedBindings]];
[emuWindowController setContent:[mainWindowDelegate bindings]];
[prefWindowController setContent:[prefWindowDelegate bindings]];
[cheatWindowController setContent:[cheatWindowDelegate bindings]];
@ -178,12 +171,6 @@
// Setup the HID Input manager.
[self setHidManager:[[[CocoaHIDManager alloc] init] autorelease]];
// Set the display view delegate.
DisplayViewDelegate *newDispViewDelegate = [[[DisplayViewDelegate alloc] init] autorelease];
[newDispViewDelegate setView:[mainWindowDelegate displayView]];
[mainWindowDelegate setDispViewDelegate:newDispViewDelegate];
[[mainWindowDelegate displayView] setDispViewDelegate:newDispViewDelegate];
// Init the DS emulation core.
CocoaDSCore *newCore = [[[CocoaDSCore alloc] init] autorelease];
[cdsCoreController setContent:newCore];
@ -193,14 +180,6 @@
CocoaDSController *newController = [[[CocoaDSController alloc] initWithMic:newMic] autorelease];
[newCore setCdsController:newController];
[inputPrefsView setCdsController:newController];
[newDispViewDelegate setCdsController:newController];
// Init the DS displays.
CocoaDSDisplayVideo *newVideoDisplay = [[[CocoaDSDisplayVideo alloc] init] autorelease];
[newVideoDisplay setDelegate:newDispViewDelegate];
[newCore addOutput:newVideoDisplay];
NSPort *guiPort = [NSPort port];
[[NSRunLoop currentRunLoop] addPort:guiPort forMode:NSDefaultRunLoopMode];
// Init the DS speakers.
CocoaDSSpeaker *newSpeaker = [[[CocoaDSSpeaker alloc] init] autorelease];
@ -217,32 +196,27 @@
}
// Start up the threads for our outputs.
[NSThread detachNewThreadSelector:@selector(runThread:) toTarget:newVideoDisplay withObject:nil];
[NSThread detachNewThreadSelector:@selector(runThread:) toTarget:newSpeaker withObject:nil];
// Wait until the GPU and SPU are finished starting up.
while ([newVideoDisplay thread] == nil || [newSpeaker thread] == nil)
// Wait until the SPU is finished starting up.
while ([newSpeaker thread] == nil)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
}
// Setup the applications settings from the user defaults file.
[self setupUserDefaults];
// Setup the window display view.
[[mainWindowDelegate displayView] setNextResponder:mainWindow];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
EmuWindowDelegate *mainWindowDelegate = [mainWindow delegate];
// Load a new ROM on launch per user preferences.
BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"];
const BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"];
if (loadROMOnLaunch && [emuControl currentRom] == nil)
{
NSInteger autoloadRomOption = [[NSUserDefaults standardUserDefaults] integerForKey:@"General_AutoloadROMOption"];
const NSInteger autoloadRomOption = [[NSUserDefaults standardUserDefaults] integerForKey:@"General_AutoloadROMOption"];
NSURL *autoloadRomURL = nil;
if (autoloadRomOption == ROMAUTOLOADOPTION_LOAD_LAST)
@ -264,14 +238,9 @@
}
}
// Make the display view black.
[[mainWindowDelegate dispViewDelegate] setViewToBlack];
//Bring the application to the front
[NSApp activateIgnoringOtherApps:TRUE];
[mainWindow setTitle:(NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]];
[mainWindow makeKeyAndOrderFront:nil];
[mainWindow makeMainWindow];
[emuControl newDisplayWindow:nil];
// Present the file migration window to the user (if they haven't disabled it).
[self setMigrationFilesPresent:NO];
@ -287,7 +256,7 @@
// If a file needs to be saved, give the user a chance to save it
// before quitting.
BOOL didRomClose = [emuControl handleUnloadRom:REASONFORCLOSE_TERMINATE romToLoad:nil];
const BOOL didRomClose = [emuControl handleUnloadRom:REASONFORCLOSE_TERMINATE romToLoad:nil];
if (!didRomClose)
{
if ([emuControl isShowingSaveStateDialog])
@ -343,11 +312,10 @@
- (void) setupSlotMenuItems
{
NSInteger i;
NSMenuItem *loadItem = nil;
NSMenuItem *saveItem = nil;
for(i = 0; i < MAX_SAVESTATE_SLOTS; i++)
for(NSInteger i = 0; i < MAX_SAVESTATE_SLOTS; i++)
{
loadItem = [self addSlotMenuItem:mLoadStateSlot slotNumber:(NSUInteger)(i + 1)];
[loadItem setKeyEquivalentModifierMask:0];
@ -383,7 +351,6 @@
- (void) setupUserDefaults
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
EmuWindowDelegate *mainWindowDelegate = [mainWindow delegate];
PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate];
NSMutableDictionary *prefBindings = [prefWindowDelegate bindings];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
@ -457,7 +424,6 @@
nil];
CocoaDSFirmware *newFirmware = [[[CocoaDSFirmware alloc] initWithDictionary:newFWDict] autorelease];
[cdsCore setCdsFirmware:newFirmware];
[newFirmware update];
[emuControl setCdsFirmware:newFirmware];
@ -538,13 +504,12 @@
[self updateInputDisplayFields];
// Set the menu for the display rotation.
double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
[prefWindowDelegate updateDisplayRotationMenu:displayRotation];
// Set the default sound volume per user preferences.
[prefWindowDelegate updateVolumeIcon:nil];
[mainWindowDelegate setupUserDefaults];
[emuControl setupUserDefaults];
}
@ -586,15 +551,7 @@
NSMutableArray *fileList = [CocoaDSFile completeFileList];
if (fileList != nil)
{
if ([fileList count] == 0)
{
[self setMigrationFilesPresent:NO];
}
else
{
[self setMigrationFilesPresent:YES];
}
[self setMigrationFilesPresent:([fileList count] == 0) ? NO : YES];
if (sender == nil && ![self migrationFilesPresent])
{
return;
@ -608,7 +565,7 @@
- (IBAction) handleMigrationWindow:(id)sender
{
NSInteger option = [(NSControl *)sender tag];
const NSInteger option = [(NSControl *)sender tag];
NSMutableArray *fileList = [fileMigrationList content];
switch (option)

View File

@ -1,101 +0,0 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2013 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
@protocol DisplayViewDelegate;
@class DisplayViewDelegate;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface EmuWindowDelegate : NSObject <NSWindowDelegate>
#else
@interface EmuWindowDelegate : NSObject
#endif
{
NSObject *dummyObject;
NSWindow *window;
NSWindow *saveFileMigrationSheet;
NSWindow *saveStatePrecloseSheet;
NSView <DisplayViewDelegate> *displayView;
NSView *saveScreenshotPanelAccessoryView;
DisplayViewDelegate *dispViewDelegate;
NSObjectController *cdsDisplayController;
NSObjectController *emuControlController;
NSObjectController *emuWindowController;
BOOL isShowingStatusBar;
NSUInteger statusBarHeight;
NSSize minDisplayViewSize;
BOOL isMinSizeNormal;
NSBitmapImageFileType screenshotFileFormat;
NSMutableDictionary *bindings;
}
@property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet NSWindow *window;
@property (readonly) IBOutlet NSView <DisplayViewDelegate> *displayView;
@property (readonly) IBOutlet NSView *saveScreenshotPanelAccessoryView;
@property (retain) DisplayViewDelegate *dispViewDelegate;
@property (readonly) IBOutlet NSObjectController *cdsDisplayController;
@property (readonly) IBOutlet NSObjectController *emuControlController;
@property (readonly) IBOutlet NSObjectController *emuWindowController;
@property (assign) BOOL isMinSizeNormal;
@property (readonly) NSMutableDictionary *bindings;
- (void) setContentScalar:(double)s;
- (void) setContentRotation:(double)angleDegrees;
- (double) resizeWithTransform:(NSSize)normalBounds scalar:(double)scalar rotation:(double)angleDegrees;
- (double) maxContentScalar:(NSSize)contentBounds;
// Edit Menu
- (IBAction) copy:(id)sender;
// View Menu
- (IBAction) hudDisable:(id)sender;
- (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender;
- (IBAction) toggleStatusBar:(id)sender;
// Tools Menu
- (IBAction) selectScreenshotFileFormat:(id)sender;
- (IBAction) saveScreenshotAs:(id)sender;
- (void) saveScreenshotAsFinish:(NSNotification *)aNotification;
- (IBAction) changeScale:(id)sender;
- (IBAction) changeRotation:(id)sender;
- (IBAction) changeRotationRelative:(id)sender;
- (IBAction) changeBilinearOutput:(id)sender;
- (IBAction) changeVerticalSync:(id)sender;
- (IBAction) changeDisplayMode:(id)sender;
- (IBAction) changeDisplayOrientation:(id)sender;
- (IBAction) changeDisplayOrder:(id)sender;
- (IBAction) changeVideoFilter:(id)sender;
- (void) setShowStatusBar:(BOOL)showStatusBar;
- (void) setupUserDefaults;
- (IBAction) writeDefaultsDisplayRotation:(id)sender;
- (IBAction) writeDefaultsHUDSettings:(id)sender;
- (IBAction) writeDefaultsVideoOutputSettings:(id)sender;
@end

View File

@ -1,626 +0,0 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2013 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import "emuWindowDelegate.h"
#import "EmuControllerDelegate.h"
#import "displayView.h"
#import "cocoa_globals.h"
#import "cocoa_file.h"
#import "cocoa_util.h"
#undef BOOL
@implementation EmuWindowDelegate
@dynamic dummyObject;
@synthesize window;
@synthesize displayView;
@synthesize saveScreenshotPanelAccessoryView;
@synthesize dispViewDelegate;
@synthesize cdsDisplayController;
@synthesize emuControlController;
@synthesize emuWindowController;
@dynamic isMinSizeNormal;
@synthesize bindings;
- (id)init
{
self = [super init];
if(self == nil)
{
return nil;
}
bindings = [[NSMutableDictionary alloc] init];
if (bindings == nil)
{
[self release];
self = nil;
return self;
}
dispViewDelegate = nil;
isShowingStatusBar = YES;
statusBarHeight = WINDOW_STATUS_BAR_HEIGHT;
minDisplayViewSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
isMinSizeNormal = YES;
screenshotFileFormat = NSTIFFFileType;
[bindings setValue:[NSNumber numberWithBool:YES] forKey:@"isShowingStatusBar"];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(saveScreenshotAsFinish:)
name:@"org.desmume.DeSmuME.requestScreenshotDidFinish"
object:nil];
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self setDispViewDelegate:nil];
[bindings release];
[super dealloc];
}
- (void) setContentScalar:(double)s
{
// Resize the window when contentScalar changes.
// No need to set the view's scale here since window resizing will implicitly change it.
[self resizeWithTransform:[dispViewDelegate normalSize] scalar:s rotation:[dispViewDelegate rotation]];
}
- (void) setContentRotation:(double)angleDegrees
{
double newAngleDegrees = fmod(angleDegrees, 360.0);
if (newAngleDegrees < 0.0)
{
newAngleDegrees = 360.0 + newAngleDegrees;
}
if (newAngleDegrees == 360.0)
{
newAngleDegrees = 0.0;
}
[dispViewDelegate setRotation:newAngleDegrees];
// Set the minimum content size for the window, since this will change based on rotation.
NSSize minContentSize = GetTransformedBounds(minDisplayViewSize, 1.0, CLOCKWISE_DEGREES(newAngleDegrees));
minContentSize.height += statusBarHeight;
[window setContentMinSize:minContentSize];
// Resize the window.
const NSSize oldBounds = [window frame].size;
[self resizeWithTransform:[dispViewDelegate normalSize] scalar:[dispViewDelegate scale] rotation:newAngleDegrees];
const NSSize newBounds = [window frame].size;
// If the window size didn't change, it is possible that the old and new rotation angles
// are 180 degrees offset from each other. In this case, we'll need to force the
// display view to update itself.
if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height)
{
[displayView setNeedsDisplay:YES];
}
}
- (double) resizeWithTransform:(NSSize)normalBounds scalar:(double)scalar rotation:(double)angleDegrees
{
// Convert angle to clockwise-direction degrees.
angleDegrees = CLOCKWISE_DEGREES(angleDegrees);
// Get the maximum scalar size within drawBounds. Constrain scalar to maxScalar if necessary.
const NSSize checkSize = GetTransformedBounds(normalBounds, 1.0, angleDegrees);
const double maxScalar = [self maxContentScalar:checkSize];
if (scalar > maxScalar)
{
scalar = maxScalar;
}
// Get the new bounds for the window's content view based on the transformed draw bounds.
const NSSize transformedBounds = GetTransformedBounds(normalBounds, scalar, angleDegrees);
// Get the center of the content view in screen coordinates.
const NSRect windowContentRect = [[window contentView] bounds];
const double translationX = (windowContentRect.size.width - transformedBounds.width) / 2.0;
const double translationY = ((windowContentRect.size.height - statusBarHeight) - transformedBounds.height) / 2.0;
// Resize the window.
const NSRect windowFrame = [window frame];
const NSRect newFrame = [window frameRectForContentRect:NSMakeRect(windowFrame.origin.x + translationX, windowFrame.origin.y + translationY, transformedBounds.width, transformedBounds.height + statusBarHeight)];
[window setFrame:newFrame display:YES animate:NO];
// Return the actual scale used for the view (may be constrained).
return scalar;
}
- (double) maxContentScalar:(NSSize)contentBounds
{
// Determine the maximum scale based on the visible screen size (which
// doesn't include the menu bar or dock).
const NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
const NSRect windowFrame = [window frameRectForContentRect:NSMakeRect(0.0, 0.0, contentBounds.width, contentBounds.height + statusBarHeight)];
const NSSize visibleScreenBounds = { (screenFrame.size.width - (windowFrame.size.width - contentBounds.width)), (screenFrame.size.height - (windowFrame.size.height - contentBounds.height)) };
return GetMaxScalarInBounds(contentBounds.width, contentBounds.height, visibleScreenBounds.width, visibleScreenBounds.height);
}
- (void) setIsMinSizeNormal:(BOOL)theState
{
isMinSizeNormal = theState;
if ([dispViewDelegate displayMode] == DS_DISPLAY_TYPE_COMBO)
{
if ([dispViewDelegate displayOrientation] == DS_DISPLAY_ORIENTATION_HORIZONTAL)
{
minDisplayViewSize.width = GPU_DISPLAY_WIDTH * 2;
minDisplayViewSize.height = GPU_DISPLAY_HEIGHT;
}
else
{
minDisplayViewSize.width = GPU_DISPLAY_WIDTH;
minDisplayViewSize.height = GPU_DISPLAY_HEIGHT * 2;
}
}
else
{
minDisplayViewSize.width = GPU_DISPLAY_WIDTH;
minDisplayViewSize.height = GPU_DISPLAY_HEIGHT;
}
if (!isMinSizeNormal)
{
minDisplayViewSize.width /= 4;
minDisplayViewSize.height /= 4;
}
// Set the minimum content size, keeping the display rotation in mind.
NSSize transformedMinSize = GetTransformedBounds(minDisplayViewSize, 1.0, CLOCKWISE_DEGREES([dispViewDelegate rotation]));
transformedMinSize.height += statusBarHeight;
[window setContentMinSize:transformedMinSize];
}
- (BOOL) isMinSizeNormal
{
return isMinSizeNormal;
}
- (IBAction)copy:(id)sender
{
[dispViewDelegate copyToPasteboard];
}
- (IBAction) changeScale:(id)sender
{
[self setContentScalar:(double)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0];
}
- (IBAction) changeRotation:(id)sender
{
// Get the rotation value from the sender.
if ([sender isMemberOfClass:[NSSlider class]])
{
[self setContentRotation:[(NSSlider *)sender doubleValue]];
}
else
{
[self setContentRotation:(double)[CocoaDSUtil getIBActionSenderTag:sender]];
}
}
- (IBAction) changeRotationRelative:(id)sender
{
const double angleDegrees = [dispViewDelegate rotation] + (double)[CocoaDSUtil getIBActionSenderTag:sender];
[self setContentRotation:angleDegrees];
}
- (IBAction) changeBilinearOutput:(id)sender
{
[dispViewDelegate setUseBilinearOutput:[CocoaDSUtil getIBActionSenderButtonStateBool:sender]];
}
- (IBAction) changeVerticalSync:(id)sender
{
[dispViewDelegate setUseVerticalSync:[CocoaDSUtil getIBActionSenderButtonStateBool:sender]];
}
- (IBAction) changeDisplayMode:(id)sender
{
const NSInteger newDisplayModeID = [CocoaDSUtil getIBActionSenderTag:sender];
if (newDisplayModeID == [dispViewDelegate displayMode])
{
return;
}
[dispViewDelegate setDisplayMode:newDisplayModeID];
[self resizeWithTransform:[dispViewDelegate normalSize] scalar:[dispViewDelegate scale] rotation:[dispViewDelegate rotation]];
}
- (IBAction) changeDisplayOrientation:(id)sender
{
const NSInteger newDisplayOrientation = [CocoaDSUtil getIBActionSenderTag:sender];
if (newDisplayOrientation == [dispViewDelegate displayOrientation])
{
return;
}
[dispViewDelegate setDisplayOrientation:newDisplayOrientation];
[self setIsMinSizeNormal:[self isMinSizeNormal]];
[self resizeWithTransform:[dispViewDelegate normalSize] scalar:[dispViewDelegate scale] rotation:[dispViewDelegate rotation]];
}
- (IBAction) changeDisplayOrder:(id)sender
{
[dispViewDelegate setDisplayOrder:[CocoaDSUtil getIBActionSenderTag:sender]];
}
- (IBAction) changeVideoFilter:(id)sender
{
[dispViewDelegate setVideoFilterType:[CocoaDSUtil getIBActionSenderTag:sender]];
}
- (IBAction) hudDisable:(id)sender
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
if ([dispViewDelegate isHudEnabled])
{
[dispViewDelegate setIsHudEnabled:NO];
[emuControl setStatusText:NSSTRING_STATUS_HUD_DISABLED];
}
else
{
[dispViewDelegate setIsHudEnabled:YES];
[emuControl setStatusText:NSSTRING_STATUS_HUD_ENABLED];
}
}
- (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender
{
if ([self isMinSizeNormal])
{
[self setIsMinSizeNormal:NO];
}
else
{
[self setIsMinSizeNormal:YES];
// Set the minimum content size, keeping the display rotation in mind.
NSSize transformedMinSize = GetTransformedBounds(minDisplayViewSize, 1.0, CLOCKWISE_DEGREES([dispViewDelegate rotation]));
transformedMinSize.height += statusBarHeight;
// Resize the window if it's smaller than the minimum content size.
NSRect windowContentRect = [window contentRectForFrameRect:[window frame]];
if (windowContentRect.size.width < transformedMinSize.width || windowContentRect.size.height < transformedMinSize.height)
{
// Prepare to resize.
NSRect oldFrameRect = [window frame];
windowContentRect.size = transformedMinSize;
NSRect newFrameRect = [window frameRectForContentRect:windowContentRect];
// Keep the window centered when expanding the size.
newFrameRect.origin.x = oldFrameRect.origin.x - ((newFrameRect.size.width - oldFrameRect.size.width) / 2);
newFrameRect.origin.y = oldFrameRect.origin.y - ((newFrameRect.size.height - oldFrameRect.size.height) / 2);
// Set the window size.
[window setFrame:newFrameRect display:YES animate:NO];
}
}
}
- (IBAction) toggleStatusBar:(id)sender
{
[self setShowStatusBar:(isShowingStatusBar) ? NO : YES];
}
- (void) setShowStatusBar:(BOOL)showStatusBar
{
NSRect frameRect = [window frame];
if (showStatusBar)
{
statusBarHeight = WINDOW_STATUS_BAR_HEIGHT;
frameRect.size.height += WINDOW_STATUS_BAR_HEIGHT;
NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
if (frameRect.size.height > screenFrame.size.height)
{
NSRect windowContentRect = [[window contentView] bounds];
double widthToHeightRatio = windowContentRect.size.width / windowContentRect.size.height;
windowContentRect.size.height -= frameRect.size.height - screenFrame.size.height;
windowContentRect.size.width = windowContentRect.size.height * widthToHeightRatio;
frameRect.size.height = screenFrame.size.height;
frameRect.size.width = windowContentRect.size.width;
}
else
{
frameRect.origin.y -= WINDOW_STATUS_BAR_HEIGHT;
}
}
else
{
statusBarHeight = 0;
frameRect.origin.y += WINDOW_STATUS_BAR_HEIGHT;
frameRect.size.height -= WINDOW_STATUS_BAR_HEIGHT;
}
isShowingStatusBar = showStatusBar;
[[self bindings] setValue:[NSNumber numberWithBool:showStatusBar] forKey:@"isShowingStatusBar"];
[[NSUserDefaults standardUserDefaults] setBool:showStatusBar forKey:@"DisplayView_ShowStatusBar"];
[window setFrame:frameRect display:YES animate:NO];
}
- (IBAction) selectScreenshotFileFormat:(id)sender
{
screenshotFileFormat = (NSBitmapImageFileType)[CocoaDSUtil getIBActionSenderTag:sender];
}
- (IBAction) saveScreenshotAs:(id)sender
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
[emuControl pauseCore];
NSSavePanel *panel = [NSSavePanel savePanel];
[panel setCanCreateDirectories:YES];
[panel setTitle:NSSTRING_TITLE_SAVE_SCREENSHOT_PANEL];
[panel setAccessoryView:saveScreenshotPanelAccessoryView];
const NSInteger buttonClicked = [panel runModal];
if(buttonClicked == NSOKButton)
{
[dispViewDelegate requestScreenshot:[panel URL] fileType:screenshotFileFormat];
}
else
{
[emuControl restoreCoreState];
}
}
- (void) saveScreenshotAsFinish:(NSNotification *)aNotification
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
NSURL *fileURL = (NSURL *)[[aNotification userInfo] valueForKey:@"fileURL"];
NSBitmapImageFileType fileType = (NSBitmapImageFileType)[(NSNumber *)[[aNotification userInfo] valueForKey:@"fileType"] integerValue];
NSImage *screenshotImage = (NSImage *)[[aNotification userInfo] valueForKey:@"screenshotImage"];
const BOOL fileSaved = [CocoaDSFile saveScreenshot:fileURL bitmapData:[[screenshotImage representations] objectAtIndex:0] fileType:fileType];
if (!fileSaved)
{
[CocoaDSUtil quickDialogUsingTitle:NSSTRING_ERROR_TITLE_LEGACY message:NSSTRING_ERROR_SCREENSHOT_FAILED_LEGACY];
}
[emuControl restoreCoreState];
}
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)theItem
{
BOOL enable = YES;
const SEL theAction = [theItem action];
if (theAction == @selector(changeScale:))
{
const NSInteger viewScale = (NSInteger)([dispViewDelegate scale] * 100.0);
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setState:(viewScale == [theItem tag]) ? NSOnState : NSOffState];
}
}
else if (theAction == @selector(changeRotation:))
{
NSInteger viewRotation = (NSInteger)([dispViewDelegate rotation]);
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
if ([theItem tag] == -1)
{
if (viewRotation == 0 ||
viewRotation == 90 ||
viewRotation == 180 ||
viewRotation == 270)
{
[(NSMenuItem*)theItem setState:NSOffState];
}
else
{
[(NSMenuItem*)theItem setState:NSOnState];
}
}
else if (viewRotation == [theItem tag])
{
[(NSMenuItem*)theItem setState:NSOnState];
}
else
{
[(NSMenuItem*)theItem setState:NSOffState];
}
}
}
else if (theAction == @selector(changeDisplayMode:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setState:([dispViewDelegate displayMode] == [theItem tag]) ? NSOnState : NSOffState];
}
}
else if (theAction == @selector(changeDisplayOrientation:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setState:([dispViewDelegate displayOrientation] == [theItem tag]) ? NSOnState : NSOffState];
}
}
else if (theAction == @selector(changeDisplayOrder:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setState:([dispViewDelegate displayOrder] == [theItem tag]) ? NSOnState : NSOffState];
}
}
else if (theAction == @selector(hudDisable:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setTitle:([dispViewDelegate isHudEnabled]) ? NSSTRING_TITLE_DISABLE_HUD : NSSTRING_TITLE_ENABLE_HUD];
}
}
else if (theAction == @selector(toggleStatusBar:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setTitle:(isShowingStatusBar) ? NSSTRING_TITLE_HIDE_STATUS_BAR : NSSTRING_TITLE_SHOW_STATUS_BAR];
}
}
else if (theAction == @selector(toggleKeepMinDisplaySizeAtNormal:))
{
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
[(NSMenuItem*)theItem setState:(isMinSizeNormal) ? NSOnState : NSOffState];
}
}
return enable;
}
- (void)windowDidBecomeMain:(NSNotification *)notification
{
[emuWindowController setContent:[self bindings]];
[cdsDisplayController setContent:[dispViewDelegate bindings]];
}
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
{
// Get a content Rect so that we can make our comparison.
// This will be based on the proposed frameSize.
const NSRect frameRect = NSMakeRect(0.0f, 0.0f, frameSize.width, frameSize.height);
const NSRect contentRect = [sender contentRectForFrameRect:frameRect];
// Find the maximum scalar we can use for the display view, bounded by the
// content Rect.
const NSSize checkSize = GetTransformedBounds([dispViewDelegate normalSize], 1.0, [dispViewDelegate rotation]);
const NSSize contentBounds = NSMakeSize(contentRect.size.width, contentRect.size.height - statusBarHeight);
const double maxS = GetMaxScalarInBounds(checkSize.width, checkSize.height, contentBounds.width, contentBounds.height);
// Make a new content Rect with our max scalar, and convert it back to a frame Rect.
const NSRect finalContentRect = NSMakeRect(0.0f, 0.0f, checkSize.width * maxS, (checkSize.height * maxS) + statusBarHeight);
const NSRect finalFrameRect = [sender frameRectForContentRect:finalContentRect];
// Set the final size based on our new frame Rect.
const NSSize finalSize = {finalFrameRect.size.width, finalFrameRect.size.height};
return finalSize;
}
- (void)windowDidResize:(NSNotification *)notification
{
if (dispViewDelegate == nil)
{
return;
}
// Get the max scalar within the window's current content bounds.
const NSSize checkSize = GetTransformedBounds([dispViewDelegate normalSize], 1.0, [dispViewDelegate rotation]);
NSSize contentBounds = [[window contentView] bounds].size;
contentBounds.height -= statusBarHeight;
const double maxS = GetMaxScalarInBounds(checkSize.width, checkSize.height, contentBounds.width, contentBounds.height);
// Set the display view's properties.
[dispViewDelegate setScale:maxS];
// Resize the view.
NSRect newContentFrame = [[window contentView] bounds];
newContentFrame.origin.y = statusBarHeight;
newContentFrame.size.height -= statusBarHeight;
[displayView setFrame:newContentFrame];
}
- (BOOL)windowShouldClose:(id)sender
{
BOOL shouldClose = YES;
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
// If no ROM is loaded, terminate the application.
if ([emuControl currentRom] == nil)
{
[NSApp terminate:sender];
}
// If a ROM is loaded, just close the ROM, but don't terminate.
else
{
shouldClose = NO;
[emuControl closeRom:nil];
}
return shouldClose;
}
- (void) setupUserDefaults
{
// Set the display window per user preferences.
[self setShowStatusBar:[[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_ShowStatusBar"]];
// Set the display settings per user preferences.
const double displayScalar = (double)([[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Size"] / 100.0);
const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
[dispViewDelegate setDisplayMode:[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_Mode"]];
[dispViewDelegate setDisplayOrientation:[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Orientation"]];
[dispViewDelegate setDisplayOrder:[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Order"]];
[self setContentScalar:displayScalar];
[self setContentRotation:displayRotation];
// Setup the window display view per user preferences.
[[self dispViewDelegate] setVideoFilterType:[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"]];
[[self dispViewDelegate] setUseBilinearOutput:[[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"]];
[[self dispViewDelegate] setUseVerticalSync:[[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseVerticalSync"]];
}
- (IBAction) writeDefaultsDisplayRotation:(id)sender
{
NSMutableDictionary *dispViewBindings = (NSMutableDictionary *)[cdsDisplayController content];
[[NSUserDefaults standardUserDefaults] setDouble:[[dispViewBindings valueForKey:@"rotation"] doubleValue] forKey:@"DisplayView_Rotation"];
}
- (IBAction) writeDefaultsHUDSettings:(id)sender
{
// TODO: Not implemented.
}
- (IBAction) writeDefaultsVideoOutputSettings:(id)sender
{
NSMutableDictionary *dispViewBindings = (NSMutableDictionary *)[cdsDisplayController content];
[[NSUserDefaults standardUserDefaults] setInteger:[[dispViewBindings valueForKey:@"videoFilterType"] integerValue] forKey:@"DisplayView_VideoFilter"];
[[NSUserDefaults standardUserDefaults] setBool:[[dispViewBindings valueForKey:@"useBilinearOutput"] boolValue] forKey:@"DisplayView_UseBilinearOutput"];
[[NSUserDefaults standardUserDefaults] setBool:[[dispViewBindings valueForKey:@"useVerticalSync"] boolValue] forKey:@"DisplayView_UseVerticalSync"];
}
@end

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2012 DeSmuME team
Copyright (C) 2012-2013 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
@ -32,7 +32,7 @@
NSWindow *window;
NSWindow *firmwareConfigSheet;
NSObjectController *cdsCoreController;
NSObjectController *emuWindowController;
NSObjectController *emuController;
NSObjectController *prefWindowController;
NSObjectController *cheatWindowController;
NSArrayController *cheatDatabaseController;
@ -64,7 +64,7 @@
@property (readonly) IBOutlet NSWindow *window;
@property (readonly) IBOutlet NSWindow *firmwareConfigSheet;
@property (readonly) IBOutlet NSObjectController *cdsCoreController;
@property (readonly) IBOutlet NSObjectController *emuWindowController;
@property (readonly) IBOutlet NSObjectController *emuController;
@property (readonly) IBOutlet NSObjectController *prefWindowController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSArrayController *cheatDatabaseController;

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2012 DeSmuME team
Copyright (C) 2012-2013 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
@ -17,7 +17,7 @@
*/
#import "preferencesWindowDelegate.h"
#import "displayView.h"
#import "EmuControllerDelegate.h"
#import "cocoa_core.h"
#import "cocoa_cheat.h"
@ -35,7 +35,7 @@
@synthesize window;
@synthesize firmwareConfigSheet;
@synthesize cdsCoreController;
@synthesize emuWindowController;
@synthesize emuController;
@synthesize prefWindowController;
@synthesize cheatWindowController;
@synthesize cheatDatabaseController;
@ -320,7 +320,7 @@
[[NSUserDefaults standardUserDefaults] setObject:selectedFile forKey:@"R4Cheat_DatabasePath"];
[bindings setValue:[selectedFile lastPathComponent] forKey:@"R4CheatDatabaseName"];
const BOOL isRomLoaded = [(NSNumber *)[(NSMutableDictionary *)[emuWindowController content] valueForKey:@"isRomLoaded"] boolValue];
const BOOL isRomLoaded = [(EmuControllerDelegate *)[emuController content] currentRom] != nil;
NSMutableDictionary *cheatWindowBindings = (NSMutableDictionary *)[cheatWindowController content];
CocoaDSCheatManager *cdsCheats = (CocoaDSCheatManager *)[cheatWindowBindings valueForKey:@"cheatList"];