Disk II can boot disks now! Maybe soon you'll actually be able to *select* disk images, too.
This commit is contained in:
parent
8bac7aace2
commit
e501990af3
|
@ -77,8 +77,7 @@ class DiskII: NSObject, Peripheral {
|
||||||
var mediaPosition: Int = 0
|
var mediaPosition: Int = 0
|
||||||
var motorPhase: MotorPhase = .Phase0
|
var motorPhase: MotorPhase = .Phase0
|
||||||
|
|
||||||
var diskImage = DiskImage(diskPath: "/Users/luigi/apple2/clean332sysmas.do")
|
var diskImage: DiskImage?
|
||||||
|
|
||||||
|
|
||||||
init(slot: Int, romPath: String) {
|
init(slot: Int, romPath: String) {
|
||||||
slotNumber = slot
|
slotNumber = slot
|
||||||
|
@ -102,6 +101,10 @@ class DiskII: NSObject, Peripheral {
|
||||||
action: actionDispatchOperation)
|
action: actionDispatchOperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func attachDiskImage(imagePath: String) {
|
||||||
|
diskImage = DiskImage(diskPath: imagePath)
|
||||||
|
}
|
||||||
|
|
||||||
//http://ftp.twaren.net/NetBSD/misc/wrstuden/Apple_PDFs/Software%20control%20of%20IWM.pdf
|
//http://ftp.twaren.net/NetBSD/misc/wrstuden/Apple_PDFs/Software%20control%20of%20IWM.pdf
|
||||||
private func actionDispatchOperation(something: AnyObject, address: UInt16, byte: UInt8?) -> UInt8? {
|
private func actionDispatchOperation(something: AnyObject, address: UInt16, byte: UInt8?) -> UInt8? {
|
||||||
let operationNumber = UInt8(address & 0xFF) - UInt8(0x80 & 0xFF) - UInt8(0x10 * slotNumber)
|
let operationNumber = UInt8(address & 0xFF) - UInt8(0x80 & 0xFF) - UInt8(0x10 * slotNumber)
|
||||||
|
@ -224,7 +227,7 @@ class DiskII: NSObject, Peripheral {
|
||||||
modeString = "???"
|
modeString = "???"
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Reading byte \(mediaPosition) of track \(currentTrack). DOS is \(modeString) T\(trk) S\(sec).")
|
print("Head is at nibble \(mediaPosition) of track \(currentTrack). DOS is \(modeString) T\(trk) S\(sec).")
|
||||||
return readByteOfTrack(track: currentTrack, advance: softswitches.MotorPowered ? 1 : 0)
|
return readByteOfTrack(track: currentTrack, advance: softswitches.MotorPowered ? 1 : 0)
|
||||||
}
|
}
|
||||||
case 13:
|
case 13:
|
||||||
|
@ -243,11 +246,14 @@ class DiskII: NSObject, Peripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readByteOfTrack(track: Int, advance: Int) -> UInt8 {
|
func readByteOfTrack(track: Int, advance: Int) -> UInt8 {
|
||||||
let trackData = diskImage.encodedTracks[track]
|
if(diskImage == nil) { return 0x00 } //No disk inserted, fail.
|
||||||
|
|
||||||
let result = trackData[mediaPosition]
|
let trackData = diskImage?.encodedTracks[track]
|
||||||
|
if(trackData == nil) { return 0x00 } //No disk inserted, fail.
|
||||||
|
|
||||||
|
let result = trackData![mediaPosition]
|
||||||
//Advance the drive to the next byte
|
//Advance the drive to the next byte
|
||||||
mediaPosition = (mediaPosition + advance) % trackData.count
|
mediaPosition = (mediaPosition + advance) % trackData!.count
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,14 @@ class AppleIIViewController: NSViewController {
|
||||||
// Do view setup here.
|
// Do view setup here.
|
||||||
|
|
||||||
preferencesWindowController = PreferencesWindowController()
|
preferencesWindowController = PreferencesWindowController()
|
||||||
|
|
||||||
self.view.addSubview(computer.emulatorView)
|
self.view.addSubview(computer.emulatorView)
|
||||||
|
|
||||||
setupDriveNotifications()
|
setupDriveNotifications()
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(self.debuggerBreak), name: DebuggerNotifications.Break, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(self.debuggerBreak), name: DebuggerNotifications.Break, object: nil)
|
||||||
|
|
||||||
|
let drive = computer.backplane[6]! as! DiskII
|
||||||
|
drive.attachDiskImage(imagePath: "/Users/luigi/apple2/clean332sysmas.do")
|
||||||
|
|
||||||
self.frameTimer = Timer.scheduledTimer(timeInterval: 1.0/60.0,
|
self.frameTimer = Timer.scheduledTimer(timeInterval: 1.0/60.0,
|
||||||
target: self,
|
target: self,
|
||||||
selector: #selector(runEmulation),
|
selector: #selector(runEmulation),
|
||||||
|
|
|
@ -64,6 +64,12 @@
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<menu key="submenu" title="File" id="bib-Uj-vzu">
|
<menu key="submenu" title="File" id="bib-Uj-vzu">
|
||||||
<items>
|
<items>
|
||||||
|
<menuItem title="Insert Disk into Drive 0..." id="IYa-pn-S38">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
</menuItem>
|
||||||
|
<menuItem title="Insert Disk into Drive 1..." id="Gdi-Dy-E1U">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
</menuItem>
|
||||||
<menuItem title="Reset" keyEquivalent="r" id="aTl-1u-JFS">
|
<menuItem title="Reset" keyEquivalent="r" id="aTl-1u-JFS">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="doReset:" target="Ady-hI-5gd" id="7dg-B5-6Ok"/>
|
<action selector="doReset:" target="Ady-hI-5gd" id="7dg-B5-6Ok"/>
|
||||||
|
|
Loading…
Reference in New Issue