1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-03-08 00:35:47 +00:00

Made a first stab at having automatic loading be optional. But things are currently arranged such that the machine options are communicated too late to have an effect. So work to do.

This commit is contained in:
Thomas Harte 2016-08-06 17:39:27 -04:00
parent 3e65450a54
commit be54d8040e
7 changed files with 61 additions and 13 deletions

View File

@ -187,7 +187,7 @@ void Machine::add_prg(size_t length, const uint8_t *data)
{
_rom_address = (uint16_t)(data[0] | (data[1] << 8));
_rom_length = (uint16_t)(length - 2);
if(_rom_address >= 0x1000 && _rom_address+_rom_length < 0x2000)
if(_rom_address >= 0x1000 && _rom_address+_rom_length < 0x2000 && _should_automatically_load_media)
{
set_typer_for_string("RUN\n");
}
@ -203,7 +203,7 @@ void Machine::add_prg(size_t length, const uint8_t *data)
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
{
_tape.set_tape(tape);
set_typer_for_string("LOAD\nRUN\n");
if(_should_automatically_load_media) set_typer_for_string("LOAD\nRUN\n");
}
void Machine::tape_did_change_input(Tape *tape)
@ -227,7 +227,7 @@ void Machine::set_disk(std::shared_ptr<Storage::Disk> disk)
// install the ROM if it was previously set
install_disk_rom();
set_typer_for_string("LOAD\"*\",8,1\nRUN\n");
if(_should_automatically_load_media) set_typer_for_string("LOAD\"*\",8,1\nRUN\n");
}
void Machine::install_disk_rom()

View File

@ -251,6 +251,7 @@ class Machine:
}
inline void set_use_fast_tape_hack(bool activate) { _use_fast_tape_hack = activate; }
inline void set_should_automatically_load_media(bool activate) { _should_automatically_load_media = activate; }
// to satisfy CPU6502::Processor
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
@ -304,7 +305,7 @@ class Machine:
// Tape
Tape _tape;
bool _use_fast_tape_hack;
bool _use_fast_tape_hack, _should_automatically_load_media;
// Disk
std::shared_ptr<::Commodore::C1540::Machine> _c1540;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
@ -7,6 +7,7 @@
<customObject id="-2" userLabel="File's Owner" customClass="Vic20Document" customModule="Clock_Signal" customModuleProvider="target">
<connections>
<outlet property="fastLoadingButton" destination="sBT-cU-h7s" id="gWf-9E-D7l"/>
<outlet property="loadAutomaticallyButton" destination="lbt-Wo-6fc" id="Xsc-dz-1a6"/>
<outlet property="openGLView" destination="DEG-fq-cjd" id="Gxs-2u-n7B"/>
<outlet property="optionsPanel" destination="ota-g7-hOL" id="zeO-di-9i3"/>
<outlet property="window" destination="xOd-HO-29H" id="JIz-fz-R2o"/>
@ -43,17 +44,17 @@
<window title="Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="ota-g7-hOL" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES" HUD="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="83" y="102" width="200" height="83"/>
<rect key="contentRect" x="83" y="102" width="200" height="103"/>
<rect key="screenRect" x="0.0" y="0.0" width="1366" height="768"/>
<value key="minSize" type="size" width="200" height="83"/>
<value key="maxSize" type="size" width="200" height="83"/>
<view key="contentView" id="7Pv-WL-2Rq">
<rect key="frame" x="0.0" y="0.0" width="200" height="83"/>
<rect key="frame" x="0.0" y="0.0" width="200" height="103"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="sBT-cU-h7s">
<rect key="frame" x="18" y="47" width="164" height="18"/>
<buttonCell key="cell" type="check" title="Load Quickly" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="w0l-ha-esm">
<rect key="frame" x="18" y="67" width="164" height="18"/>
<buttonCell key="cell" type="check" title="Load Tapes Quickly" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="w0l-ha-esm">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -61,6 +62,16 @@
<action selector="setFastLoading:" target="-2" id="ctR-h1-CYI"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="lbt-Wo-6fc">
<rect key="frame" x="18" y="47" width="164" height="18"/>
<buttonCell key="cell" type="check" title="Load Automatically" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="jTj-uV-at1">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="setShouldLoadAutomatically:" target="-2" id="Ixe-HN-4XK"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MlB-rE-TXV">
<rect key="frame" x="18" y="17" width="165" height="26"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="UIu-uz-pTu">
@ -72,7 +83,7 @@
<menuItem title="European Machine" id="5ju-Z0-BDa"/>
<menuItem title="Japanese Machine" id="YlT-9e-azY"/>
<menuItem title="Swedish Machine" id="joU-Bt-XFb"/>
<menuItem title="US Machine" state="on" id="FXe-ca-cTY"/>
<menuItem title="US Machine" id="FXe-ca-cTY"/>
</items>
</menu>
</popUpButtonCell>
@ -80,14 +91,17 @@
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="sBT-cU-h7s" secondAttribute="trailing" constant="20" id="79b-2A-2c7"/>
<constraint firstItem="MlB-rE-TXV" firstAttribute="top" secondItem="lbt-Wo-6fc" secondAttribute="bottom" constant="8" id="DIc-Sm-VlA"/>
<constraint firstItem="sBT-cU-h7s" firstAttribute="top" secondItem="7Pv-WL-2Rq" secondAttribute="top" constant="20" id="E5m-wo-X92"/>
<constraint firstItem="MlB-rE-TXV" firstAttribute="top" secondItem="sBT-cU-h7s" secondAttribute="bottom" constant="8" id="fis-Fe-CkQ"/>
<constraint firstItem="lbt-Wo-6fc" firstAttribute="leading" secondItem="7Pv-WL-2Rq" secondAttribute="leading" constant="20" id="cID-bi-rVP"/>
<constraint firstItem="lbt-Wo-6fc" firstAttribute="top" secondItem="sBT-cU-h7s" secondAttribute="bottom" constant="6" id="ciY-E8-07P"/>
<constraint firstAttribute="trailing" secondItem="lbt-Wo-6fc" secondAttribute="trailing" constant="20" id="gMU-gX-3Sg"/>
<constraint firstItem="sBT-cU-h7s" firstAttribute="leading" secondItem="7Pv-WL-2Rq" secondAttribute="leading" constant="20" id="nDy-Xc-Ug9"/>
<constraint firstItem="MlB-rE-TXV" firstAttribute="leading" secondItem="7Pv-WL-2Rq" secondAttribute="leading" constant="20" id="qb4-Lp-ZMc"/>
<constraint firstAttribute="trailing" secondItem="MlB-rE-TXV" secondAttribute="trailing" constant="20" id="v18-62-uee"/>
</constraints>
</view>
<point key="canvasLocation" x="-2" y="6.5"/>
<point key="canvasLocation" x="-2" y="16.5"/>
</window>
</objects>
</document>

View File

@ -176,9 +176,12 @@ class MachineDocument:
}
// MARK: IBActions
final func prefixedUserDefaultsKey(key: String) -> String {
return "\(self.name).\(key)"
}
var fastLoadingUserDefaultsKey: String {
get {
return "\(self.name).fastLoading"
return prefixedUserDefaultsKey("fastLoading")
}
}

View File

@ -66,4 +66,26 @@ class Vic20Document: MachineDocument {
override func readFromData(data: NSData, ofType typeName: String) throws {
vic20.setPRG(data)
}
@IBOutlet var loadAutomaticallyButton: NSButton!
var autoloadingUserDefaultsKey: String {
get { return prefixedUserDefaultsKey("autoload") }
}
@IBAction func setShouldLoadAutomatically(sender: NSButton!) {
let loadAutomatically = sender.state == NSOnState
vic20.shouldLoadAutomatically = loadAutomatically
self.loadAutomaticallyButton.state = loadAutomatically ? NSOnState : NSOffState
}
override func establishStoredOptions() {
super.establishStoredOptions()
let standardUserDefaults = NSUserDefaults.standardUserDefaults()
standardUserDefaults.registerDefaults([
autoloadingUserDefaultsKey: true
])
let loadAutomatically = standardUserDefaults.boolForKey(self.autoloadingUserDefaultsKey)
vic20.shouldLoadAutomatically = loadAutomatically
self.loadAutomaticallyButton.state = loadAutomatically ? NSOnState : NSOffState
}
}

View File

@ -23,5 +23,6 @@
- (BOOL)openD64AtURL:(nonnull NSURL *)URL;
@property (nonatomic, assign) BOOL useFastLoadingHack;
@property (nonatomic, assign) BOOL shouldLoadAutomatically;
@end

View File

@ -197,4 +197,11 @@ using namespace Commodore::Vic20;
}
}
- (void)setShouldLoadAutomatically:(BOOL)shouldLoadAutomatically {
@synchronized(self) {
_shouldLoadAutomatically = shouldLoadAutomatically;
_vic20.set_should_automatically_load_media(shouldLoadAutomatically ? true : false);
}
}
@end