weirdo swift thing

This commit is contained in:
Luigi Thirty 2017-08-12 20:24:30 -04:00
parent cafacf2f18
commit c0a340c026
8 changed files with 33 additions and 21 deletions

View File

@ -567,7 +567,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = s;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;

View File

@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>FruitMachine Release.xcscheme</key>
<key>Copy of FruitMachine.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>

View File

@ -37,10 +37,11 @@ class AppleII: AppleIIBase {
}
override func installOverrides() {
for (_, peripheral) in backplane {
for peripheral in backplane {
if(peripheral != nil) {
peripheral!.installOverrides()
peripheral!.installOverrides()
}
}
CPU.sharedInstance.memoryInterface.read_overrides.append(SoftswitchOverrides.readKeyboard)

View File

@ -22,7 +22,8 @@ var EmulatedSystemInstance: AppleIIBase?
class AppleIIBase: NSObject, EmulatedSystem {
//Peripherals
var backplane = [Int: Peripheral?]()
//var backplane = [Int: Peripheral]()
var backplane = [Peripheral?](repeating: nil, count: 8)
var frameCounter: Int = 0
var CPU_FREQUENCY: Double
@ -106,18 +107,17 @@ class AppleIIBase: NSObject, EmulatedSystem {
let slot6 = defaults.string(forKey: "a2_Peripherals_Slot6")
if(slot6 == "Disk II") {
backplane[6] = DiskII(slot: 6, romPath: "/Users/luigi/apple2/341-0027-a.p5")
//(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/Prodos_2_4_1.po")
}
//(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/Prodos_2_4_1.po")
(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/clean332sysmas.do")
}
func attachImageToDiskDrive(drive: Peripheral, image: String) {
print("drive is \(drive)")
(drive as! DiskII).attachDiskImage(imagePath: image)
}
func doColdReset() {
CPU.sharedInstance.coldReset()
//Reinitialize peripherals in case they changed.
setupPeripherals()
doReset()
}

View File

@ -38,7 +38,7 @@ class AppleIIPlus: AppleIIBase {
}
override func installOverrides() {
for (_, peripheral) in backplane {
for peripheral in backplane {
if(peripheral != nil) {
peripheral!.installOverrides()
}

View File

@ -35,7 +35,7 @@ import Cocoa
*/
class DiskII: NSObject, Peripheral, HasROM {
let debug = false
let debug = true
enum MotorPhase {
case Phase0
@ -86,6 +86,7 @@ class DiskII: NSObject, Peripheral, HasROM {
init(slot: Int, romPath: String) {
slotNumber = slot
romManager = ROMManager(path: romPath, atAddress: 0x0, size: 256)
diskImage = nil
super.init()
@ -106,7 +107,9 @@ class DiskII: NSObject, Peripheral, HasROM {
}
func attachDiskImage(imagePath: String) {
diskImage = DiskImage(diskPath: imagePath)
let image = DiskImage(diskPath: imagePath)
self.diskImage = image
print("attached image to DiskII \(self)")
}
//http://ftp.twaren.net/NetBSD/misc/wrstuden/Apple_PDFs/Software%20control%20of%20IWM.pdf
@ -215,7 +218,12 @@ class DiskII: NSObject, Peripheral, HasROM {
let blkLo: UInt8
let blkHi: UInt8
if(diskImage!.image is Dos33Image) {
if(diskImage == nil) {
print("No disk inserted, aborting. DiskII \(self)")
return 0x00
}
if(diskImage?.image is Dos33Image) {
trk = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7EC, bypassOverrides: true)
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7ED, bypassOverrides: true)
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7F4, bypassOverrides: true)
@ -223,7 +231,7 @@ class DiskII: NSObject, Peripheral, HasROM {
blkLo = 0
blkHi = 0
}
else if(diskImage!.image is ProdosImage) {
else if(diskImage?.image is ProdosImage) {
trk = CPU.sharedInstance.memoryInterface.readByte(offset: 0x41, bypassOverrides: true)
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0x3D, bypassOverrides: true)
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0x42, bypassOverrides: true)
@ -258,9 +266,9 @@ class DiskII: NSObject, Peripheral, HasROM {
}
if(debug)
{
if(diskImage!.image is Dos33Image) {
if(diskImage?.image is Dos33Image) {
print("Head is at nibble \(mediaPosition) of track \(currentTrack). DOS is trying to \(modeString) T\(trk) S\(sec).")
} else if(diskImage!.image is ProdosImage) {
} else if(diskImage?.image is ProdosImage) {
print("Head is at nibble \(mediaPosition) of track \(currentTrack). ProDOS is trying to \(modeString) Block $\(blkHi.asHexString())\(blkLo.asHexString()) (T\(trk) S\(sec)).")
if(mode == 1) {

View File

@ -138,6 +138,7 @@ class DiskImage: NSObject {
print("Couldn't load disk image")
return
}
if(filename.contains(".do")) {
//Is this a DOS 3.3 format image? Read one sector from track $11.
image = Dos33Image()

View File

@ -94,7 +94,8 @@ class AppleIIViewController: NSViewController {
}
@IBAction func doColdReset(_ sender: Any) {
setModel() //In case it changed
setModel()
EmulatedSystemInstance!.setupPeripherals()
EmulatedSystemInstance!.doColdReset()
}
@ -109,7 +110,8 @@ class AppleIIViewController: NSViewController {
picker.allowedFileTypes = ["do", "po"]
if(picker.runModal() == .OK) {
(EmulatedSystemInstance!.backplane[6] as! DiskII).attachDiskImage(imagePath: picker.url!.path)
print("insertDiskIntoDrive1: \(EmulatedSystemInstance!.backplane[6]!)")
EmulatedSystemInstance!.attachImageToDiskDrive(drive: EmulatedSystemInstance!.backplane[6]!, image: picker.url!.path)
}
}