diff --git a/A2Mac.xcodeproj/project.pbxproj b/A2Mac.xcodeproj/project.pbxproj index c0385a3..40fd6da 100644 --- a/A2Mac.xcodeproj/project.pbxproj +++ b/A2Mac.xcodeproj/project.pbxproj @@ -68,6 +68,8 @@ 325EB6AC2401118300C6B4A4 /* Xonix.woz in Resources */ = {isa = PBXBuildFile; fileRef = 325EB69B2401118300C6B4A4 /* Xonix.woz */; }; 3262F37623E169F8008BDB95 /* spk_dn.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3262F37423E169F8008BDB95 /* spk_dn.wav */; }; 3262F37723E169F8008BDB95 /* spk_up.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3262F37523E169F8008BDB95 /* spk_up.wav */; }; + 32A9F72C24668D26004902A1 /* apple-rainbow.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 32A9F72B24668D26004902A1 /* apple-rainbow.jpg */; }; + 32A9F72D24668D26004902A1 /* apple-rainbow.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 32A9F72B24668D26004902A1 /* apple-rainbow.jpg */; }; 32BFFB5B22EACC630003B53F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BFFB5A22EACC630003B53F /* AppDelegate.swift */; }; 32BFFB5D22EACC630003B53F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BFFB5C22EACC630003B53F /* ViewController.swift */; }; 32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB5E22EACC660003B53F /* Assets.xcassets */; }; @@ -186,6 +188,7 @@ 3264261023284F6F008B615F /* Apple2_mmio_8bit_ioaddr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Apple2_mmio_8bit_ioaddr.h; sourceTree = ""; }; 326426112328ADF4008B615F /* Apple_II_ROM.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = Apple_II_ROM.s; sourceTree = ""; }; 326ED2EE232D7A0000A41337 /* 6502_functional_test.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = 6502_functional_test.bin; sourceTree = SOURCE_ROOT; }; + 32A9F72B24668D26004902A1 /* apple-rainbow.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "apple-rainbow.jpg"; sourceTree = ""; }; 32B18435233F10BC00DBB4AB /* Shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; }; 32B18438233FAB3900DBB4AB /* verticies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = verticies.swift; sourceTree = ""; }; 32BFFB5722EACC630003B53F /* A2Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = A2Mac.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -390,6 +393,7 @@ 3262F37823E17013008BDB95 /* Resources */ = { isa = PBXGroup; children = ( + 32A9F72B24668D26004902A1 /* apple-rainbow.jpg */, 3262F37423E169F8008BDB95 /* spk_dn.wav */, 3262F37523E169F8008BDB95 /* spk_up.wav */, 325EB67B23FBD43800C6B4A4 /* PrintChar21.ttf */, @@ -713,6 +717,7 @@ 325EB68D23FDDFD200C6B4A4 /* Merlin-8 v2.48 (DOS 3.3).woz in Resources */, 325EB6A62401118300C6B4A4 /* ProDOS_312.woz in Resources */, 325EB6AC2401118300C6B4A4 /* Xonix.woz in Resources */, + 32A9F72D24668D26004902A1 /* apple-rainbow.jpg in Resources */, 323E2DCF245531E600156805 /* Apple2e_Enhanced.rom in Resources */, 325EB67D23FBD43800C6B4A4 /* PrintChar21.ttf in Resources */, 325EB6A42401118300C6B4A4 /* Qbit.woz in Resources */, @@ -749,6 +754,7 @@ 3262F37723E169F8008BDB95 /* spk_up.wav in Resources */, 32089E4824556DBD0036E667 /* PRNumber3.ttf in Resources */, 325EB6A92401118300C6B4A4 /* Sneakers.woz in Resources */, + 32A9F72C24668D26004902A1 /* apple-rainbow.jpg in Resources */, 325EB6A72401118300C6B4A4 /* ProDOS_402_System.woz in Resources */, 325EB69023FE028800C6B4A4 /* Donkey Kong.woz in Resources */, 325EB68923FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */, diff --git a/A2Mac/Base.lproj/Main.storyboard b/A2Mac/Base.lproj/Main.storyboard index 266337a..6a9b6df 100644 --- a/A2Mac/Base.lproj/Main.storyboard +++ b/A2Mac/Base.lproj/Main.storyboard @@ -789,7 +789,7 @@ - + @@ -804,7 +804,7 @@ - + @@ -837,16 +837,22 @@ @@@@@@@@@@@@@@@@@@22@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@23@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@24@@@@@@@@@@@@@@@@@@@@ - + - + - @@ -1074,6 +1081,6 @@ - + diff --git a/A2Mac/HiRes.swift b/A2Mac/HiRes.swift index 611a56a..2ad416f 100644 --- a/A2Mac/HiRes.swift +++ b/A2Mac/HiRes.swift @@ -400,7 +400,7 @@ class HiRes: NSView { static let ScreenBitmapSize = (PixelWidth * PixelHeight * 4) static let context = createBitmapContext(pixelsWide: PixelWidth, PixelHeight) static let pixels = UnsafeMutableRawBufferPointer(start: context?.data, count: ScreenBitmapSize) - static var typedPointer = pixels.bindMemory(to: UInt32.self) + static var pixelsRGBA = pixels.bindMemory(to: UInt32.self) #endif let R = 2 @@ -499,24 +499,21 @@ class HiRes: NSView { break case 0x01: // purple (bits are in reverse!) - HiRes.typedPointer[colorAddr] = color_purple; -// HiRes.typedPointer[colorAddr + 1] = color_black; + HiRes.pixelsRGBA[colorAddr] = color_purple; + if (prev != 0x03) && (prev != 0x07) && (prev != 0x00) && (prev != 0x04) { + HiRes.pixelsRGBA[colorAddr - 1] = color_purple; + } case 0x02: // green // reducing color bleeding - if (prev == 0x01) || - (prev == 0x05) - { -// HiRes.typedPointer[colorAddr + 1] = color_black; - } - else { - HiRes.typedPointer[colorAddr] = color_green; - HiRes.typedPointer[colorAddr + 1] = color_green; + if (colorAddr > 0) && (HiRes.pixelsRGBA[colorAddr - 1] != color_black) { + HiRes.pixelsRGBA[colorAddr] = color_green; } + HiRes.pixelsRGBA[colorAddr + 1] = color_green; case 0x03: // white - HiRes.typedPointer[colorAddr] = color_white; - HiRes.typedPointer[colorAddr + 1] = color_white; + HiRes.pixelsRGBA[colorAddr] = color_white; + HiRes.pixelsRGBA[colorAddr + 1] = color_white; case 0x04: // black 2 // HiRes.typedPointer[colorAddr] = color_black; @@ -524,24 +521,21 @@ class HiRes: NSView { break case 0x05: // blue - HiRes.typedPointer[colorAddr] = color_blue; -// HiRes.typedPointer[colorAddr + 1] = color_black; + HiRes.pixelsRGBA[colorAddr] = color_blue; + if (prev != 0x03) && (prev != 0x07) && (prev != 0x00) && (prev != 0x04) { + HiRes.pixelsRGBA[colorAddr - 1] = color_blue; + } case 0x06: // orange // reducing color bleeding - if (prev == 0x01) || - (prev == 0x05) - { -// HiRes.typedPointer[colorAddr + 1] = color_black; + if (colorAddr > 0) && (HiRes.pixelsRGBA[colorAddr - 1] != color_black) { + HiRes.pixelsRGBA[colorAddr] = color_orange; } - else { - HiRes.typedPointer[colorAddr] = color_orange; - HiRes.typedPointer[colorAddr + 1] = color_orange; - } - + HiRes.pixelsRGBA[colorAddr + 1] = color_orange; + case 0x07: // white 2 - HiRes.typedPointer[colorAddr] = color_white; - HiRes.typedPointer[colorAddr + 1] = color_white; + HiRes.pixelsRGBA[colorAddr] = color_white; + HiRes.pixelsRGBA[colorAddr + 1] = color_white; default: // HiRes.typedPointer[colorAddr] = color_black; @@ -551,40 +545,39 @@ class HiRes: NSView { // white adjustment if ( (prev & 2) == 2 ) && ( (pixel & 1) == 1 ) { - HiRes.typedPointer[colorAddr] = color_white; - HiRes.typedPointer[colorAddr - 1] = color_white; + HiRes.pixelsRGBA[colorAddr] = color_white; + HiRes.pixelsRGBA[colorAddr - 1] = color_white; // TODO: Need better check if extra green was created if (HiRes.pixels[pixelAddr - 8 + G] == 0xA2 ) { - HiRes.typedPointer[colorAddr - 2] = color_black; + HiRes.pixelsRGBA[colorAddr - 2] = color_black; } } // purple adjustment -- followed by white else if (prev == 0x01) && ( (pixel == 0x01) || - (pixel == 0x03) || (pixel == 0x07) || // white - (pixel == 0x00) || (pixel == 0x04) // black + (pixel == 0x03) || (pixel == 0x07) // white +// (pixel == 0x00) || (pixel == 0x04) // black ) { // was the previous purple pixel promoted to white or is it still purple? - if ( HiRes.pixels[pixelAddr - 8 + R] == 0xBB ) { - HiRes.typedPointer[colorAddr - 1] = color_purple; + if ( HiRes.pixelsRGBA[colorAddr - 2] == color_purple ) { + HiRes.pixelsRGBA[colorAddr - 1] = color_purple; } } // blue adjustment -- followed by white else if (prev == 0x05) && ( (pixel == 0x05) || - (pixel == 0x03) || (pixel == 0x07) || // white - (pixel == 0x00) || (pixel == 0x04) // black + (pixel == 0x03) || (pixel == 0x07) // white +// (pixel == 0x00) || (pixel == 0x04) // black ) { - // was the previous purple pixel promoted to white or is it still purple? - if ( HiRes.pixels[pixelAddr - 8 + R] == 0x11 ) { - HiRes.typedPointer[colorAddr - 1] = color_blue; + // was the previous blue pixel promoted to white or is it still blue? + if ( HiRes.pixelsRGBA[colorAddr - 2] == color_blue ) { + HiRes.pixelsRGBA[colorAddr - 1] = color_blue; } } - } @@ -669,6 +662,8 @@ class HiRes: NSView { // refresh changed block only + let screenBlockMargin = 6 + let blockScreenWidth = Int(frame.width) / HiRes.blockCols * 2 let blockScreenHeigth = Int(frame.height) / HiRes.blockRows @@ -677,10 +672,10 @@ class HiRes: NSView { if blockChanged[ blockVertIdx * HiRes.blockCols / 2 + blockHorIdx ] { // refresh the entire screen let boundingBox = CGRect( - x: blockHorIdx * blockScreenWidth - 2, - y: Int(frame.height) - blockVertIdx * blockScreenHeigth - blockScreenHeigth - 2, - width: blockScreenWidth + 4, - height: blockScreenHeigth + 4) + x: blockHorIdx * blockScreenWidth - screenBlockMargin, + y: Int(frame.height) - blockVertIdx * blockScreenHeigth - blockScreenHeigth - screenBlockMargin, + width: blockScreenWidth + screenBlockMargin * 2, + height: blockScreenHeigth + screenBlockMargin * 2) self.setNeedsDisplay( boundingBox ) } diff --git a/A2Mac/ViewController.swift b/A2Mac/ViewController.swift index ebd7213..842aaf5 100644 --- a/A2Mac/ViewController.swift +++ b/A2Mac/ViewController.swift @@ -50,6 +50,7 @@ class ViewController: NSViewController { @IBOutlet weak var display: NSTextFieldCell! @IBOutlet weak var speedometer: NSTextFieldCell! @IBOutlet weak var hires: HiRes! + @IBOutlet weak var splashScreen: NSImageView! // static let charConvStr : String = @@ -101,6 +102,28 @@ class ViewController: NSViewController { var workItem : DispatchWorkItem? = nil; @IBAction func Power(_ sender: Any) { + + //------------------------------------------------------------ + // Animated Splash Screen fade out and (Text) Monitor fade in + + displayField.alphaValue = 0 + displayField.isHidden = false + splashScreen.alphaValue = 1 + splashScreen.isHidden = false + + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 1.0 + // Use the value you want to animate to (NOT the starting value) + self.displayField.animator().alphaValue = 1 + self.splashScreen.animator().alphaValue = 0 + }, + completionHandler:{ () -> Void in + self.displayField.alphaValue = 1 + self.splashScreen.isHidden = true + }) + } + //------------------------------------------------------------ #if SPEEDTEST if ( workItem != nil ) { @@ -624,11 +647,7 @@ class ViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() -// for y in 0 ... textLines - 1 { -// txtClear[ y * (textCols + lineEndChars) + textCols * 2 + 1 ] = "\n" -// } - - hires.needsDisplay = true; + hires.clearScreen(); woz_loadFile( Bundle.main.resourcePath, "Apple DOS 3.3 January 1983.woz" ) diff --git a/Resources/apple-rainbow.jpg b/Resources/apple-rainbow.jpg new file mode 100644 index 0000000..ead56f7 Binary files /dev/null and b/Resources/apple-rainbow.jpg differ