SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit abaf471350c7b2a88c4bae5eaf9955989601dce1 parent ea40a7be05f5eb6a2481572819b29d10c62d8312 Author: Lior Halphon <LIJI32@gmail.com> Date: Sat, 17 Sep 2022 13:17:03 +0300 Cart hot-swapping (Cocoa) Diffstat:
| M | Cocoa/Document.m | 30 | ++++++++++++++++++++++++++++++ |
| M | Cocoa/MainMenu.xib | 6 | ++++++ |
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/Cocoa/Document.m b/Cocoa/Document.m @@ -2527,5 +2527,35 @@ static bool is_path_writeable(const char *path) GB_set_channel_muted(&gb, sender.tag, !GB_is_channel_muted(&gb, sender.tag)); } +- (IBAction)cartSwap:(id)sender +{ + bool wasRunning = running; + if (wasRunning) { + [self stop]; + } + [[NSDocumentController sharedDocumentController] beginOpenPanelWithCompletionHandler:^(NSArray<NSURL *> *urls) { + if (urls.count == 1) { + bool ok = true; + for (Document *document in [NSDocumentController sharedDocumentController].documents) { + if ([document.fileURL isEqual:urls.firstObject]) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:[NSString stringWithFormat:@"‘%@’ is already open in another window. Close ‘%@’ before hot swapping it into this instance.", + urls.firstObject.lastPathComponent, urls.firstObject.lastPathComponent]]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert runModal]; + ok = false; + break; + } + } + if (ok) { + self.fileURL = urls.firstObject; + [self loadROM]; + } + } + if (wasRunning) { + [self start]; + } + }]; +} @end diff --git a/Cocoa/MainMenu.xib b/Cocoa/MainMenu.xib @@ -82,6 +82,12 @@ <action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/> </connections> </menuItem> + <menuItem title="Hot Swap Cartridge…" keyEquivalent="o" id="Rik-p8-QCf"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="cartSwap:" target="-1" id="iXS-Ol-IS0"/> + </connections> + </menuItem> <menuItem title="Open Recent" id="tXI-mr-wws"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.