Skip to content

Commit

Permalink
- undo the runloop change; that seems to cause the app to sometimes h…
Browse files Browse the repository at this point in the history
…ang when quitting

- remove some menu items that won't be supported
- added a simple warning for frame time violations
  • Loading branch information
sh95014 committed Jan 1, 2022
1 parent cc8d205 commit 950eec0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 41 deletions.
54 changes: 33 additions & 21 deletions source/frontends/mariani/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,32 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}

- (void)timerFired {
for (NSButton *driveLightButton in self.driveLightButtons) {
CardManager & cardManager = GetCardMgr();
const UINT slot = (UINT)driveLightButton.tag / 10;
const int drive = driveLightButton.tag % 10;
Disk2InterfaceCard *card = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(slot));
if (card->IsDriveEmpty(drive)) {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle.dotted" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor secondaryLabelColor];
}
else {
Disk_Status_e status[NUM_DRIVES];
card->GetLightStatus(&status[0], &status[1]);
const BOOL active = (status[drive] == DISK_STATUS_READ || status[drive] == DISK_STATUS_WRITE);
if (active) {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle.fill" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor controlAccentColor];
#ifdef DEBUG
NSDate *start = [NSDate now];
#endif

if (self.hasStatusBar) {
for (NSButton *driveLightButton in self.driveLightButtons) {
CardManager & cardManager = GetCardMgr();
const UINT slot = (UINT)driveLightButton.tag / 10;
const int drive = driveLightButton.tag % 10;
Disk2InterfaceCard *card = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(slot));
if (card->IsDriveEmpty(drive)) {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle.dotted" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor secondaryLabelColor];
}
else {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor secondaryLabelColor];
Disk_Status_e status[NUM_DRIVES];
card->GetLightStatus(&status[0], &status[1]);
const BOOL active = (status[drive] == DISK_STATUS_READ || status[drive] == DISK_STATUS_WRITE);
if (active) {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle.fill" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor controlAccentColor];
}
else {
driveLightButton.image = [NSImage imageWithSystemSymbolName:@"circle" accessibilityDescription:@""];
driveLightButton.contentTintColor = [NSColor secondaryLabelColor];
}
}
}
}
Expand All @@ -178,6 +184,14 @@ - (void)timerFired {

frameBuffer.data = frame->FrameBufferData();
[self.emulatorVC updateScreen:&frameBuffer];

#ifdef DEBUG
NSTimeInterval duration = -[start timeIntervalSinceNow];
if (duration > 1.0 / TARGET_FPS) {
// oops, took too long
NSLog(@"Frame time exceeded: %f ms", duration * 1000);
}
#endif // DEBUG
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
Expand Down Expand Up @@ -586,9 +600,7 @@ - (void)scaleWindowByFactor:(double)factor {
}

- (void)startEmulationTimer {
self.timer = [NSTimer timerWithTimeInterval:1.0 / TARGET_FPS target:self selector:@selector(timerFired) userInfo:nil repeats:YES];

[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 / TARGET_FPS target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
}

- (double)statusBarHeight {
Expand Down
21 changes: 1 addition & 20 deletions source/frontends/mariani/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,6 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/>
</connections>
</menuItem>
<menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="8hY-E0-rc2"/>
<menuItem title="Hide Status Bar" keyEquivalent="/" id="Qa1-0n-abD">
<connections>
<action selector="toggleStatusBarAction:" target="Voe-Tx-rLC" id="2SR-cY-rHy"/>
Expand Down Expand Up @@ -204,12 +191,6 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="CPg-xX-I73"/>
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSidebar:" target="-1" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
Expand Down Expand Up @@ -266,7 +247,7 @@
</items>
<point key="canvasLocation" x="-670" y="-478"/>
</menu>
<window title="Mariani" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<window title="Mariani" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" tabbingMode="disallowed" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="196" y="204" width="840" height="608"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
Expand Down

0 comments on commit 950eec0

Please sign in to comment.