mirror of
https://github.com/Luigi30/FruitMachine-Swift.git
synced 2024-11-26 21:52:45 +00:00
weirdo swift thing
This commit is contained in:
parent
cafacf2f18
commit
c0a340c026
@ -567,7 +567,7 @@
|
|||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
GCC_OPTIMIZATION_LEVEL = s;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>SchemeUserState</key>
|
<key>SchemeUserState</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>FruitMachine Release.xcscheme</key>
|
<key>Copy of FruitMachine.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
|
@ -37,10 +37,11 @@ class AppleII: AppleIIBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func installOverrides() {
|
override func installOverrides() {
|
||||||
for (_, peripheral) in backplane {
|
for peripheral in backplane {
|
||||||
if(peripheral != nil) {
|
if(peripheral != nil) {
|
||||||
peripheral!.installOverrides()
|
peripheral!.installOverrides()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CPU.sharedInstance.memoryInterface.read_overrides.append(SoftswitchOverrides.readKeyboard)
|
CPU.sharedInstance.memoryInterface.read_overrides.append(SoftswitchOverrides.readKeyboard)
|
||||||
|
@ -22,7 +22,8 @@ var EmulatedSystemInstance: AppleIIBase?
|
|||||||
|
|
||||||
class AppleIIBase: NSObject, EmulatedSystem {
|
class AppleIIBase: NSObject, EmulatedSystem {
|
||||||
//Peripherals
|
//Peripherals
|
||||||
var backplane = [Int: Peripheral?]()
|
//var backplane = [Int: Peripheral]()
|
||||||
|
var backplane = [Peripheral?](repeating: nil, count: 8)
|
||||||
var frameCounter: Int = 0
|
var frameCounter: Int = 0
|
||||||
|
|
||||||
var CPU_FREQUENCY: Double
|
var CPU_FREQUENCY: Double
|
||||||
@ -106,18 +107,17 @@ class AppleIIBase: NSObject, EmulatedSystem {
|
|||||||
let slot6 = defaults.string(forKey: "a2_Peripherals_Slot6")
|
let slot6 = defaults.string(forKey: "a2_Peripherals_Slot6")
|
||||||
if(slot6 == "Disk II") {
|
if(slot6 == "Disk II") {
|
||||||
backplane[6] = DiskII(slot: 6, romPath: "/Users/luigi/apple2/341-0027-a.p5")
|
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() {
|
func doColdReset() {
|
||||||
CPU.sharedInstance.coldReset()
|
CPU.sharedInstance.coldReset()
|
||||||
|
|
||||||
//Reinitialize peripherals in case they changed.
|
|
||||||
setupPeripherals()
|
|
||||||
|
|
||||||
doReset()
|
doReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class AppleIIPlus: AppleIIBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func installOverrides() {
|
override func installOverrides() {
|
||||||
for (_, peripheral) in backplane {
|
for peripheral in backplane {
|
||||||
if(peripheral != nil) {
|
if(peripheral != nil) {
|
||||||
peripheral!.installOverrides()
|
peripheral!.installOverrides()
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import Cocoa
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class DiskII: NSObject, Peripheral, HasROM {
|
class DiskII: NSObject, Peripheral, HasROM {
|
||||||
let debug = false
|
let debug = true
|
||||||
|
|
||||||
enum MotorPhase {
|
enum MotorPhase {
|
||||||
case Phase0
|
case Phase0
|
||||||
@ -86,6 +86,7 @@ class DiskII: NSObject, Peripheral, HasROM {
|
|||||||
init(slot: Int, romPath: String) {
|
init(slot: Int, romPath: String) {
|
||||||
slotNumber = slot
|
slotNumber = slot
|
||||||
romManager = ROMManager(path: romPath, atAddress: 0x0, size: 256)
|
romManager = ROMManager(path: romPath, atAddress: 0x0, size: 256)
|
||||||
|
diskImage = nil
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -106,7 +107,9 @@ class DiskII: NSObject, Peripheral, HasROM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func attachDiskImage(imagePath: String) {
|
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
|
//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 blkLo: UInt8
|
||||||
let blkHi: 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)
|
trk = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7EC, bypassOverrides: true)
|
||||||
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7ED, bypassOverrides: true)
|
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7ED, bypassOverrides: true)
|
||||||
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7F4, bypassOverrides: true)
|
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0xB7F4, bypassOverrides: true)
|
||||||
@ -223,7 +231,7 @@ class DiskII: NSObject, Peripheral, HasROM {
|
|||||||
blkLo = 0
|
blkLo = 0
|
||||||
blkHi = 0
|
blkHi = 0
|
||||||
}
|
}
|
||||||
else if(diskImage!.image is ProdosImage) {
|
else if(diskImage?.image is ProdosImage) {
|
||||||
trk = CPU.sharedInstance.memoryInterface.readByte(offset: 0x41, bypassOverrides: true)
|
trk = CPU.sharedInstance.memoryInterface.readByte(offset: 0x41, bypassOverrides: true)
|
||||||
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0x3D, bypassOverrides: true)
|
sec = CPU.sharedInstance.memoryInterface.readByte(offset: 0x3D, bypassOverrides: true)
|
||||||
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0x42, bypassOverrides: true)
|
mode = CPU.sharedInstance.memoryInterface.readByte(offset: 0x42, bypassOverrides: true)
|
||||||
@ -258,9 +266,9 @@ class DiskII: NSObject, Peripheral, HasROM {
|
|||||||
}
|
}
|
||||||
if(debug)
|
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).")
|
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)).")
|
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) {
|
if(mode == 1) {
|
||||||
|
@ -138,6 +138,7 @@ class DiskImage: NSObject {
|
|||||||
print("Couldn't load disk image")
|
print("Couldn't load disk image")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if(filename.contains(".do")) {
|
if(filename.contains(".do")) {
|
||||||
//Is this a DOS 3.3 format image? Read one sector from track $11.
|
//Is this a DOS 3.3 format image? Read one sector from track $11.
|
||||||
image = Dos33Image()
|
image = Dos33Image()
|
||||||
|
@ -94,7 +94,8 @@ class AppleIIViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func doColdReset(_ sender: Any) {
|
@IBAction func doColdReset(_ sender: Any) {
|
||||||
setModel() //In case it changed
|
setModel()
|
||||||
|
EmulatedSystemInstance!.setupPeripherals()
|
||||||
EmulatedSystemInstance!.doColdReset()
|
EmulatedSystemInstance!.doColdReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,8 @@ class AppleIIViewController: NSViewController {
|
|||||||
picker.allowedFileTypes = ["do", "po"]
|
picker.allowedFileTypes = ["do", "po"]
|
||||||
|
|
||||||
if(picker.runModal() == .OK) {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user