mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-10 06:31:13 +00:00
Robustify disk interface
* Don't keep extra non-GUI state * Better ability to (un)select startup disks * Don't error when selecting inflated disk already in drive * Adds an OK button to dismiss disks window
This commit is contained in:
parent
ec0af686b2
commit
3297f671b3
@ -23,7 +23,7 @@
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Reboot..." id="FjO-UG-hG2" userLabel="Menu Item - Reboot">
|
||||
<menuItem title="Reboot Emulator" id="FjO-UG-hG2" userLabel="Menu Item - Reboot">
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
CA
|
||||
</string>
|
||||
@ -52,7 +52,7 @@ CA
|
||||
<action selector="makeKeyAndOrderFront:" target="Mzv-VG-jce" id="Oek-48-Eyd"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Toggle Full Screen..." keyEquivalent="F" id="rP9-cs-9dM">
|
||||
<menuItem title="Toggle Full Screen" keyEquivalent="F" id="rP9-cs-9dM">
|
||||
<connections>
|
||||
<action selector="toggleFullScreen:" target="M8b-ga-iOS" id="Xan-eQ-CRM"/>
|
||||
</connections>
|
||||
@ -62,6 +62,11 @@ CA
|
||||
<action selector="toggleCPUSpeed:" target="M8b-ga-iOS" id="fA3-dJ-wtg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Pause Emulation" keyEquivalent="X" id="r9g-Ro-UwW">
|
||||
<connections>
|
||||
<action selector="togglePause:" target="M8b-ga-iOS" id="c65-mm-bIj"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="143">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
@ -121,7 +126,7 @@ CA
|
||||
<rect key="frame" x="0.0" y="-1" width="568" height="384"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
<point key="canvasLocation" x="-200" y="-887"/>
|
||||
<point key="canvasLocation" x="-315" y="-1328"/>
|
||||
</window>
|
||||
<customObject id="494" userLabel="EmulatorGLView" customClass="EmulatorGLView"/>
|
||||
<customObject id="M8b-ga-iOS" customClass="EmulatorWindowController" colorLabel="IBBuiltInLabel-Blue">
|
||||
@ -129,12 +134,11 @@ CA
|
||||
<outlet property="chooseDiskA" destination="j1W-BP-P7S" id="CuH-rj-ae4"/>
|
||||
<outlet property="chooseDiskB" destination="lI0-3f-IsR" id="Ym9-IW-I4c"/>
|
||||
<outlet property="diskAProperties" destination="e89-G9-nNt" id="rwR-9Z-oT4"/>
|
||||
<outlet property="diskAProtection" destination="0vx-rm-Mio" id="zF2-n5-s1R"/>
|
||||
<outlet property="diskBProperties" destination="AOj-bZ-LXp" id="6Q1-mW-fpP"/>
|
||||
<outlet property="diskBProtection" destination="Alr-gf-yTN" id="Tyr-Oa-jKg"/>
|
||||
<outlet property="diskInA" destination="cb9-Pc-Ggd" id="kP3-qf-vci"/>
|
||||
<outlet property="diskInB" destination="5oU-oN-vUH" id="lNx-Lm-0FA"/>
|
||||
<outlet property="disksWindow" destination="RAk-at-ZT4" id="64k-qW-zF5"/>
|
||||
<outlet property="pauseMenuItem" destination="r9g-Ro-UwW" id="4YW-pt-lai"/>
|
||||
<outlet property="prefsWindow" destination="Mzv-VG-jce" id="dQt-pf-qdi"/>
|
||||
<outlet property="view" destination="372" id="pRG-Kn-92X"/>
|
||||
<outlet property="window" destination="371" id="z3B-S9-PsV"/>
|
||||
@ -150,7 +154,7 @@ CA
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="laF-n4-ciZ">
|
||||
<rect key="frame" x="38" y="262" width="225" height="17"/>
|
||||
<rect key="frame" x="18" y="273" width="237" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Slot 6 Drive A" id="Vea-pb-q49">
|
||||
<font key="font" metaFont="systemBold"/>
|
||||
@ -159,7 +163,7 @@ CA
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Wzz-Yt-xlT">
|
||||
<rect key="frame" x="257" y="262" width="225" height="17"/>
|
||||
<rect key="frame" x="269" y="273" width="235" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Slot 6 Drive B" id="pUB-KI-7ef">
|
||||
<font key="font" metaFont="systemBold"/>
|
||||
@ -168,7 +172,7 @@ CA
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" id="j1W-BP-P7S">
|
||||
<rect key="frame" x="101" y="98" width="99" height="32"/>
|
||||
<rect key="frame" x="82" y="75" width="99" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Choose..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nVq-kA-8RS">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@ -179,7 +183,7 @@ CA
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" id="lI0-3f-IsR">
|
||||
<rect key="frame" x="320" y="98" width="99" height="32"/>
|
||||
<rect key="frame" x="337" y="75" width="99" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Choose..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nmE-5R-fEx">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@ -190,7 +194,7 @@ CA
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="cb9-Pc-Ggd">
|
||||
<rect key="frame" x="38" y="217" width="216" height="17"/>
|
||||
<rect key="frame" x="18" y="237" width="226" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="U5Boot.do" id="UOE-Fx-vng">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -199,7 +203,7 @@ CA
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="e89-G9-nNt">
|
||||
<rect key="frame" x="38" y="153" width="216" height="17"/>
|
||||
<rect key="frame" x="18" y="212" width="216" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title=".dsk 143360 bytes" id="rQi-K1-5Cu">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -208,7 +212,7 @@ CA
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="AOj-bZ-LXp">
|
||||
<rect key="frame" x="269" y="153" width="216" height="17"/>
|
||||
<rect key="frame" x="269" y="212" width="216" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title=".dsk 143360 bytes" id="POW-zB-gIf">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -217,7 +221,7 @@ CA
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="5oU-oN-vUH">
|
||||
<rect key="frame" x="269" y="217" width="213" height="17"/>
|
||||
<rect key="frame" x="269" y="237" width="235" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="U5Brit.do" id="KvS-JR-AdI">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -237,7 +241,7 @@ CA
|
||||
</connections>
|
||||
</button>
|
||||
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="0vx-rm-Mio">
|
||||
<rect key="frame" x="40" y="184" width="212" height="18"/>
|
||||
<rect key="frame" x="20" y="153" width="212" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
<size key="cellSize" width="91" height="18"/>
|
||||
@ -265,7 +269,7 @@ CA
|
||||
</connections>
|
||||
</matrix>
|
||||
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="Alr-gf-yTN">
|
||||
<rect key="frame" x="271" y="184" width="212" height="18"/>
|
||||
<rect key="frame" x="271" y="153" width="212" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
<size key="cellSize" width="91" height="18"/>
|
||||
@ -293,30 +297,55 @@ CA
|
||||
</connections>
|
||||
</matrix>
|
||||
<button id="Ur3-rW-YJG">
|
||||
<rect key="frame" x="149" y="59" width="355" height="18"/>
|
||||
<rect key="frame" x="18" y="133" width="172" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Startup with these disks" bezelStyle="regularSquare" imagePosition="right" alignment="right" inset="2" id="Jxo-4D-2c5">
|
||||
<buttonCell key="cell" type="check" title="Load on app startup" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Jxo-4D-2c5">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<connections>
|
||||
<action selector="startupDiskAChoiceChanged:" target="FHO-g2-V3A" id="vKm-na-GhG"/>
|
||||
</connections>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button id="Ceo-uO-cRu">
|
||||
<rect key="frame" x="269" y="133" width="172" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Load on app startup" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="koX-nf-iKo">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="startupDiskChoiceChanged:" target="FHO-g2-V3A" id="eHE-yK-gIr"/>
|
||||
<action selector="startupDiskBChoiceChanged:" target="FHO-g2-V3A" id="tQS-5l-DDf"/>
|
||||
</connections>
|
||||
</button>
|
||||
<box autoresizesSubviews="NO" verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="7ZU-H6-jQn">
|
||||
<rect key="frame" x="12" y="85" width="498" height="5"/>
|
||||
<rect key="frame" x="12" y="59" width="498" height="5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<box autoresizesSubviews="NO" horizontalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="864-Ov-2tE">
|
||||
<rect key="frame" x="248" y="96" width="5" height="194"/>
|
||||
<rect key="frame" x="259" y="70" width="5" height="217"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" id="tLd-IJ-Kjl">
|
||||
<rect key="frame" x="338" y="13" width="85" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="mSV-MT-MmA">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="disksOK:" target="FHO-g2-V3A" id="8qD-fL-VNb"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="-139" y="-901"/>
|
||||
@ -326,13 +355,14 @@ CA
|
||||
<outlet property="chooseDiskA" destination="j1W-BP-P7S" id="1jF-yu-aLA"/>
|
||||
<outlet property="chooseDiskB" destination="lI0-3f-IsR" id="8rt-Zh-lzZ"/>
|
||||
<outlet property="diskAProperties" destination="e89-G9-nNt" id="rw2-9O-jsk"/>
|
||||
<outlet property="diskAProtection" destination="0vx-rm-Mio" id="vNp-5l-F4p"/>
|
||||
<outlet property="diskAProtection" destination="0vx-rm-Mio" id="Gfn-Md-Dr4"/>
|
||||
<outlet property="diskBProperties" destination="AOj-bZ-LXp" id="dFn-b1-mHV"/>
|
||||
<outlet property="diskBProtection" destination="Alr-gf-yTN" id="MPY-dd-Zp3"/>
|
||||
<outlet property="diskBProtection" destination="Alr-gf-yTN" id="ae9-Xe-end"/>
|
||||
<outlet property="diskInA" destination="cb9-Pc-Ggd" id="chv-2S-Y2R"/>
|
||||
<outlet property="diskInB" destination="5oU-oN-vUH" id="8fb-s5-EKa"/>
|
||||
<outlet property="disksWindow" destination="RAk-at-ZT4" id="4wu-vw-EhL"/>
|
||||
<outlet property="startupDisksChoice" destination="Ur3-rW-YJG" id="gv4-SX-8jH"/>
|
||||
<outlet property="startupLoadDiskA" destination="Ur3-rW-YJG" id="re3-gT-qj3"/>
|
||||
<outlet property="startupLoadDiskB" destination="Ceo-uO-cRu" id="V0B-0f-YZu"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<window title="Apple2Mac Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="Mzv-VG-jce" userLabel="Window - Prefs">
|
||||
@ -574,7 +604,7 @@ CA
|
||||
<menuItem title="Keypad Emulation" id="fm9-GS-v01">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Mac Joystick/Gamepad" state="on" id="rYd-Zm-Btm"/>
|
||||
<menuItem title="Mac Joystick/Gamepad" id="rYd-Zm-Btm"/>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
@ -693,5 +723,14 @@ CA
|
||||
<outlet property="soundCardChoice" destination="3d5-Z5-xDN" id="uHI-Ip-s2E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="pRW-C0-1xO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="38" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="F3o-9U-Mth">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</objects>
|
||||
</document>
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define NO_DISK_INSERTED @"(No Disk Inserted)"
|
||||
#define DSK_PROPERTIES @".dsk 143360 bytes"
|
||||
#define NIB_PROPERTIES @".nib 232960 bytes"
|
||||
#define GZ_EXTENSION @"gz"
|
||||
|
||||
#define kApple2DisksURL @"kApple2DisksURL"
|
||||
|
||||
@ -29,18 +28,13 @@
|
||||
@property (assign) IBOutlet NSMatrix *diskBProtection;
|
||||
@property (assign) IBOutlet NSButton *chooseDiskA;
|
||||
@property (assign) IBOutlet NSButton *chooseDiskB;
|
||||
@property (assign) IBOutlet NSButton *startupDisksChoice;
|
||||
|
||||
@property (nonatomic, copy) NSString *diskAPath;
|
||||
@property (nonatomic, copy) NSString *diskBPath;
|
||||
@property (assign) IBOutlet NSButton *startupLoadDiskA;
|
||||
@property (assign) IBOutlet NSButton *startupLoadDiskB;
|
||||
|
||||
@end
|
||||
|
||||
@implementation EmulatorDiskController
|
||||
|
||||
@synthesize diskAPath = _diskAPath;
|
||||
@synthesize diskBPath = _diskBPath;
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[self.diskInA setStringValue:NO_DISK_INSERTED];
|
||||
@ -49,78 +43,105 @@
|
||||
[self.diskBProperties setStringValue:@""];
|
||||
[self.chooseDiskA setKeyEquivalent:@"\r"];
|
||||
[self.chooseDiskA setBezelStyle:NSRoundedBezelStyle];
|
||||
[self.startupDisksChoice setState:NSOffState];
|
||||
[self.startupLoadDiskA setState:NSOffState];
|
||||
[self.startupLoadDiskB setState:NSOffState];
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
NSString *startupDiskA = [defaults stringForKey:kApple2PrefStartupDiskA];
|
||||
BOOL startupDiskAProtection = [defaults boolForKey:kApple2PrefStartupDiskAProtected];
|
||||
BOOL readOnlyA = [defaults boolForKey:kApple2PrefStartupDiskAProtected];
|
||||
if (startupDiskA)
|
||||
{
|
||||
const char *err = c_new_diskette_6(0, [startupDiskA UTF8String], startupDiskAProtection);
|
||||
const char *err = c_new_diskette_6(0, [startupDiskA UTF8String], readOnlyA);
|
||||
if (err)
|
||||
{
|
||||
NSString *diskA = [NSString stringWithFormat:@"%@.gz", startupDiskA];
|
||||
err = c_new_diskette_6(0, [diskA UTF8String], startupDiskAProtection);
|
||||
err = c_new_diskette_6(0, [diskA UTF8String], readOnlyA);
|
||||
}
|
||||
if (!err)
|
||||
{
|
||||
[self.diskInA setStringValue:[[startupDiskA pathComponents] lastObject]];
|
||||
[self.startupDisksChoice setState:NSOnState];
|
||||
[self.startupLoadDiskA setState:NSOnState];
|
||||
[self.diskAProtection setState:(readOnlyA ? NSOnState : NSOffState) atRow:0 column:0];
|
||||
[self.diskAProtection setState:(!readOnlyA ? NSOnState : NSOffState) atRow:0 column:1];
|
||||
}
|
||||
}
|
||||
|
||||
NSString *startupDiskB = [defaults stringForKey:kApple2PrefStartupDiskB];
|
||||
BOOL startupDiskBProtection = [defaults boolForKey:kApple2PrefStartupDiskBProtected];
|
||||
BOOL readOnlyB = [defaults boolForKey:kApple2PrefStartupDiskBProtected];
|
||||
if (startupDiskB)
|
||||
{
|
||||
const char *err = c_new_diskette_6(1, [startupDiskB UTF8String], startupDiskBProtection);
|
||||
const char *err = c_new_diskette_6(1, [startupDiskB UTF8String], readOnlyB);
|
||||
if (err)
|
||||
{
|
||||
NSString *diskB = [NSString stringWithFormat:@"%@.gz", startupDiskB];
|
||||
err = c_new_diskette_6(0, [diskB UTF8String], startupDiskBProtection);
|
||||
err = c_new_diskette_6(1, [diskB UTF8String], readOnlyB);
|
||||
}
|
||||
if (!err)
|
||||
{
|
||||
[self.diskInB setStringValue:[[startupDiskB pathComponents] lastObject]];
|
||||
[self.startupDisksChoice setState:NSOnState];
|
||||
[self.startupLoadDiskB setState:NSOnState];
|
||||
[self.diskBProtection setState:(readOnlyB ? NSOnState : NSOffState) atRow:0 column:0];
|
||||
[self.diskBProtection setState:(!readOnlyB ? NSOnState : NSOffState) atRow:0 column:1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void)_savePrefs
|
||||
{
|
||||
self.diskAPath = nil;
|
||||
self.diskBPath = nil;
|
||||
[super dealloc];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskA];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskB];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskAProtected];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskBProtected];
|
||||
|
||||
if ([self.startupLoadDiskA state] == NSOnState)
|
||||
{
|
||||
if (disk6.disk[0].fp)
|
||||
{
|
||||
NSString *diskA = [NSString stringWithUTF8String:disk6.disk[0].file_name];
|
||||
[defaults setObject:diskA forKey:kApple2PrefStartupDiskA];
|
||||
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject];
|
||||
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskAProtected];
|
||||
}
|
||||
}
|
||||
|
||||
if ([self.startupLoadDiskB state] == NSOnState)
|
||||
{
|
||||
if (disk6.disk[1].fp)
|
||||
{
|
||||
NSString *diskB = [NSString stringWithUTF8String:disk6.disk[1].file_name];
|
||||
[defaults setObject:diskB forKey:kApple2PrefStartupDiskB];
|
||||
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject];
|
||||
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskBProtected];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_protectionChangedForDrive:(int)drive
|
||||
{
|
||||
if (disk6.disk[drive].fp == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// HACK NOTE : dispatch so that state of outlet property is set properly
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSButtonCell *readOnlyChoice = [[(drive == 0 ? [self diskAProtection] : [self diskBProtection]) cells] firstObject];
|
||||
NSString *path = [NSString stringWithUTF8String:disk6.disk[drive].file_name];
|
||||
[self _insertDisketteInDrive:drive path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
[self _savePrefs];
|
||||
});
|
||||
}
|
||||
|
||||
- (IBAction)diskAProtectionChanged:(id)sender
|
||||
{
|
||||
if ([[[self diskInA] stringValue] isEqualToString:NO_DISK_INSERTED])
|
||||
{
|
||||
return;
|
||||
}
|
||||
// HACK NOTE : dispatch so that state of outlet property is set properly
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject];
|
||||
NSString *path = [self diskAPath];
|
||||
[self _insertDisketteInDrive:0 path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
});
|
||||
[self _protectionChangedForDrive:0];
|
||||
}
|
||||
|
||||
- (IBAction)diskBProtectionChanged:(id)sender
|
||||
{
|
||||
if ([[[self diskInB] stringValue] isEqualToString:NO_DISK_INSERTED])
|
||||
{
|
||||
return;
|
||||
}
|
||||
// HACK NOTE : dispatch so that state of outlet property is set properly
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject];
|
||||
NSString *path = [self diskBPath];
|
||||
[self _insertDisketteInDrive:1 path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
});
|
||||
[self _protectionChangedForDrive:1];
|
||||
}
|
||||
|
||||
- (BOOL)_insertDisketteInDrive:(int)drive path:(NSString *)path type:(NSString *)type readOnly:(BOOL)readOnly
|
||||
@ -130,33 +151,48 @@
|
||||
const char *errMsg = c_new_diskette_6(drive, [path UTF8String], readOnly);
|
||||
if (errMsg)
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithError:[NSError errorWithDomain:[NSString stringWithUTF8String:errMsg] code:-1 userInfo:nil]];
|
||||
[alert beginSheetModalForWindow:[self disksWindow] completionHandler:nil];
|
||||
if (!drive)
|
||||
path = [NSString stringWithFormat:@"%@.gz", path];
|
||||
errMsg = c_new_diskette_6(drive, [path UTF8String], readOnly);
|
||||
if (errMsg)
|
||||
{
|
||||
[[self diskInA] setStringValue:NO_DISK_INSERTED];
|
||||
[[self diskAProperties] setStringValue:@""];
|
||||
NSAlert *alert = [NSAlert alertWithError:[NSError errorWithDomain:[NSString stringWithUTF8String:errMsg] code:-1 userInfo:nil]];
|
||||
[alert beginSheetModalForWindow:[self disksWindow] completionHandler:nil];
|
||||
if (!drive)
|
||||
{
|
||||
[[self diskInA] setStringValue:NO_DISK_INSERTED];
|
||||
[[self diskAProperties] setStringValue:@""];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self diskInB] setStringValue:NO_DISK_INSERTED];
|
||||
[[self diskBProperties] setStringValue:@""];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self diskInB] setStringValue:NO_DISK_INSERTED];
|
||||
[[self diskBProperties] setStringValue:@""];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
path = [NSString stringWithUTF8String:disk6.disk[drive].file_name];
|
||||
NSString *imageName = [[path pathComponents] lastObject];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if (!drive)
|
||||
if (drive == 0)
|
||||
{
|
||||
self.diskAPath = path;
|
||||
[[self diskInA] setStringValue:imageName];
|
||||
if ([[defaults stringForKey:kApple2PrefStartupDiskA] isEqualToString:path])
|
||||
{
|
||||
[self.startupLoadDiskA setState:NSOnState];
|
||||
//[self.diskAProtection setState:(readOnly ? NSOnState : NSOffState) atRow:0 column:0];
|
||||
//[self.diskAProtection setState:(!readOnly ? NSOnState : NSOffState) atRow:0 column:1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.diskBPath = path;
|
||||
[[self diskInB] setStringValue:imageName];
|
||||
if ([[defaults stringForKey:kApple2PrefStartupDiskB] isEqualToString:path])
|
||||
{
|
||||
[self.startupLoadDiskB setState:NSOnState];
|
||||
//[self.diskBProtection setState:(readOnly ? NSOnState : NSOffState) atRow:0 column:0];
|
||||
//[self.diskBProtection setState:(!readOnly ? NSOnState : NSOffState) atRow:0 column:1];
|
||||
}
|
||||
}
|
||||
|
||||
if ([type isEqualToString:@"dsk"] || [type isEqualToString:@"do"] || [type isEqualToString:@"po"])
|
||||
@ -190,7 +226,7 @@
|
||||
static NSSet *set = nil;
|
||||
static dispatch_once_t onceToken = 0L;
|
||||
dispatch_once(&onceToken, ^{
|
||||
set = [[NSSet alloc] initWithObjects:@"dsk", @"nib", @"do", @"po", GZ_EXTENSION, nil];
|
||||
set = [[NSSet alloc] initWithObjects:@"dsk", @"nib", @"do", @"po", @"gz", nil];
|
||||
});
|
||||
return [[set retain] autorelease];
|
||||
}
|
||||
@ -199,7 +235,7 @@
|
||||
{
|
||||
NSString *extension0 = [path pathExtension];
|
||||
NSString *extension1 = [[path stringByDeletingPathExtension] pathExtension];
|
||||
if ([extension0 isEqualToString:GZ_EXTENSION])
|
||||
if ([extension0 isEqualToString:@"gz"])
|
||||
{
|
||||
extension0 = extension1;
|
||||
}
|
||||
@ -256,8 +292,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
[(drive == 0) ? self.startupLoadDiskA : self.startupLoadDiskB setState:NSOffState];
|
||||
[self _insertDisketteInDrive:drive path:path type:extension readOnly:readOnly];
|
||||
[self startupDiskChoiceChanged:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -274,31 +310,19 @@
|
||||
[self _chooseDisk:1 readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
}
|
||||
|
||||
- (IBAction)startupDiskChoiceChanged:(id)sender
|
||||
- (IBAction)startupDiskAChoiceChanged:(id)sender
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskA];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskB];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskAProtected];
|
||||
[defaults removeObjectForKey:kApple2PrefStartupDiskBProtected];
|
||||
|
||||
if ([self.startupDisksChoice state] == NSOnState)
|
||||
{
|
||||
if (disk6.disk[0].fp)
|
||||
{
|
||||
NSString *diskA = [NSString stringWithUTF8String:disk6.disk[0].file_name];
|
||||
[defaults setObject:diskA forKey:kApple2PrefStartupDiskA];
|
||||
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject];
|
||||
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskAProtected];
|
||||
}
|
||||
if (disk6.disk[1].fp)
|
||||
{
|
||||
NSString *diskB = [NSString stringWithUTF8String:disk6.disk[1].file_name];
|
||||
[defaults setObject:diskB forKey:kApple2PrefStartupDiskB];
|
||||
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject];
|
||||
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskBProtected];
|
||||
}
|
||||
}
|
||||
[self _savePrefs];
|
||||
}
|
||||
|
||||
- (IBAction)startupDiskBChoiceChanged:(id)sender
|
||||
{
|
||||
[self _savePrefs];
|
||||
}
|
||||
|
||||
- (IBAction)disksOK:(id)sender
|
||||
{
|
||||
[[self disksWindow] close];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user