Color bleeding removal

This commit is contained in:
Tamas Rudnai 2020-02-28 00:28:22 -08:00
parent 44681298c1
commit 06b911be9c
3 changed files with 58 additions and 38 deletions

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
3213936624079C30007F5C4A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
32439F8722ECD8AD0077AAE0 /* 6502.c in Sources */ = {isa = PBXBuildFile; fileRef = 32439F7422ECD8AD0077AAE0 /* 6502.c */; };
32439F8822ECD8AD0077AAE0 /* apple.rom in Resources */ = {isa = PBXBuildFile; fileRef = 32439F8422ECD8AD0077AAE0 /* apple.rom */; };
325EB62F23F8856F00C6B4A4 /* woz.c in Sources */ = {isa = PBXBuildFile; fileRef = 325EB62E23F8856F00C6B4A4 /* woz.c */; };
@ -83,9 +84,6 @@
32C4532E233345430000EBA1 /* MonitorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C4532D233345420000EBA1 /* MonitorView.swift */; };
32C4532F233345820000EBA1 /* MonitorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C4532D233345420000EBA1 /* MonitorView.swift */; };
32C45330233345820000EBA1 /* MonitorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C4532D233345420000EBA1 /* MonitorView.swift */; };
32C4533123335E560000EBA1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
32C4533223335E570000EBA1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
32C4533323335E570000EBA1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -728,6 +726,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3213936624079C30007F5C4A /* Main.storyboard in Resources */,
325EB6A12401118300C6B4A4 /* Wavy Navy.woz in Resources */,
325EB68023FBDF8F00C6B4A4 /* Apple2Plus.rom in Resources */,
325EB68323FBDFBB00C6B4A4 /* DISK_II_C600.ROM in Resources */,
@ -739,7 +738,6 @@
325EB69023FE028800C6B4A4 /* Donkey Kong.woz in Resources */,
325EB68923FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */,
325EB69F2401118300C6B4A4 /* Crossfire.woz in Resources */,
32C4533123335E560000EBA1 /* Main.storyboard in Resources */,
32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */,
325EB68C23FDDFD200C6B4A4 /* Merlin-8 v2.48 (DOS 3.3).woz in Resources */,
325EB6A52401118300C6B4A4 /* ProDOS_312.woz in Resources */,
@ -771,7 +769,6 @@
buildActionMask = 2147483647;
files = (
32C453112331F7220000EBA1 /* fail1.txt in Resources */,
32C4533223335E570000EBA1 /* Main.storyboard in Resources */,
32C453122331F7220000EBA1 /* Assets.xcassets in Resources */,
32C453132331F7220000EBA1 /* apple.rom in Resources */,
32C453152331F7220000EBA1 /* 6502_functional_test.bin in Resources */,
@ -783,7 +780,6 @@
buildActionMask = 2147483647;
files = (
32C453232331FED90000EBA1 /* fail1.txt in Resources */,
32C4533323335E570000EBA1 /* Main.storyboard in Resources */,
32C453242331FED90000EBA1 /* Assets.xcassets in Resources */,
32C453252331FED90000EBA1 /* apple.rom in Resources */,
32C453272331FED90000EBA1 /* 6502_functional_test.bin in Resources */,

View File

@ -750,7 +750,7 @@
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="A2Mac" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" canDrawConcurrently="YES" id="m2S-Jp-Qdl" customClass="MonitorView" customModule="A2Mac" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="680" height="400"/>
<rect key="frame" x="0.0" y="0.0" width="684" height="400"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<textField canDrawConcurrently="YES" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" mirrorLayoutDirectionWhenInternationalizing="never" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iIF-Q5-Onc">
@ -803,13 +803,12 @@
<customView canDrawConcurrently="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LlM-EV-ruZ" customClass="HiRes" customModule="A2Mac" customModuleProvider="target">
<rect key="frame" x="16" y="8" width="568" height="384"/>
</customView>
<imageView hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="M1E-lz-4q8">
<rect key="frame" x="20" y="8" width="564" height="382"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" enabled="NO" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSQuickLookTemplate" id="Zax-kI-rxd"/>
<imageView hidden="YES" canDrawConcurrently="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="M1E-lz-4q8" userLabel="HiRes Image View">
<rect key="frame" x="16" y="8" width="568" height="384"/>
<imageCell key="cell" continuous="YES" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSQuickLookTemplate" id="Zax-kI-rxd"/>
</imageView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mfd-12-bcR">
<rect key="frame" x="594" y="362" width="82" height="32"/>
<rect key="frame" x="594" y="362" width="86" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="t2i-0h-wau"/>
</constraints>
@ -822,7 +821,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rR3-9T-NFu">
<rect key="frame" x="594" y="331" width="82" height="32"/>
<rect key="frame" x="594" y="331" width="86" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="sbX-nh-SV3"/>
</constraints>
@ -834,8 +833,8 @@
</connections>
</buttonCell>
</button>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" fixedFrame="YES" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lVP-FP-u6x">
<rect key="frame" x="600" y="19" width="70" height="161"/>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lVP-FP-u6x">
<rect key="frame" x="606" y="8" width="70" height="161"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fb7-Jc-jmt">
<rect key="frame" x="-2" y="144" width="74" height="17"/>
@ -929,7 +928,7 @@
</customSpacing>
</stackView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FZk-VW-alq">
<rect key="frame" x="631" y="20" width="41" height="17"/>
<rect key="frame" x="635" y="20" width="41" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="ai1-6C-5tW"/>
</constraints>
@ -946,22 +945,26 @@
<constraint firstAttribute="trailing" secondItem="rR3-9T-NFu" secondAttribute="trailing" constant="10" id="68s-0C-BVZ"/>
<constraint firstAttribute="bottom" secondItem="FZk-VW-alq" secondAttribute="bottom" constant="20" id="E2f-MY-c2Y"/>
<constraint firstItem="iIF-Q5-Onc" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="LGA-tZ-gFh"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="leading" secondItem="iIF-Q5-Onc" secondAttribute="leading" constant="16" id="Lak-zX-Szi"/>
<constraint firstItem="rR3-9T-NFu" firstAttribute="leading" secondItem="iIF-Q5-Onc" secondAttribute="trailing" constant="8" id="ON4-IE-HmP"/>
<constraint firstAttribute="trailing" secondItem="FZk-VW-alq" secondAttribute="trailing" constant="10" id="Q0s-uC-GPT"/>
<constraint firstItem="SEL-hl-0c0" firstAttribute="bottom" secondItem="iIF-Q5-Onc" secondAttribute="bottom" constant="-8" id="Q2B-a3-gBp"/>
<constraint firstItem="SEL-hl-0c0" firstAttribute="leading" secondItem="iIF-Q5-Onc" secondAttribute="leading" constant="16" id="QGx-a9-RR9"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="bottom" secondItem="iIF-Q5-Onc" secondAttribute="bottom" constant="-8" id="Vfh-f8-sRz"/>
<constraint firstItem="M1E-lz-4q8" firstAttribute="leading" secondItem="SEL-hl-0c0" secondAttribute="leading" id="SK0-9r-JCV"/>
<constraint firstItem="M1E-lz-4q8" firstAttribute="bottom" secondItem="SEL-hl-0c0" secondAttribute="bottom" id="aA5-fx-nSB"/>
<constraint firstAttribute="bottom" secondItem="lVP-FP-u6x" secondAttribute="bottom" constant="8" id="aW1-s4-d8i"/>
<constraint firstItem="SEL-hl-0c0" firstAttribute="top" secondItem="iIF-Q5-Onc" secondAttribute="top" constant="8" id="aWz-Ad-PIM"/>
<constraint firstAttribute="bottom" secondItem="iIF-Q5-Onc" secondAttribute="bottom" id="acb-Dy-fu5"/>
<constraint firstAttribute="trailing" secondItem="lVP-FP-u6x" secondAttribute="trailing" constant="8" id="cIM-UK-rEG"/>
<constraint firstItem="SEL-hl-0c0" firstAttribute="trailing" secondItem="iIF-Q5-Onc" secondAttribute="trailing" constant="-8" id="cmY-Vb-ckJ"/>
<constraint firstItem="M1E-lz-4q8" firstAttribute="top" secondItem="SEL-hl-0c0" secondAttribute="top" id="jxb-rD-Gun"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="top" secondItem="SEL-hl-0c0" secondAttribute="top" id="lDs-jy-edU"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="bottom" secondItem="SEL-hl-0c0" secondAttribute="bottom" id="ltj-Ea-Vtb"/>
<constraint firstItem="iIF-Q5-Onc" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="m3e-ww-N7S"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="top" secondItem="iIF-Q5-Onc" secondAttribute="top" constant="8" id="mJ3-xG-dB3"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="trailing" secondItem="iIF-Q5-Onc" secondAttribute="trailing" constant="-8" id="nCM-Ge-DZf"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="trailing" secondItem="SEL-hl-0c0" secondAttribute="trailing" id="nAy-xD-Y3s"/>
<constraint firstItem="M1E-lz-4q8" firstAttribute="trailing" secondItem="SEL-hl-0c0" secondAttribute="trailing" id="oPZ-wI-6Yu"/>
<constraint firstItem="rR3-9T-NFu" firstAttribute="top" secondItem="mfd-12-bcR" secondAttribute="bottom" constant="10" id="ycb-iY-X4I"/>
<constraint firstItem="mfd-12-bcR" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" constant="10" id="zDl-Cs-xmz"/>
<constraint firstItem="LlM-EV-ruZ" firstAttribute="leading" secondItem="SEL-hl-0c0" secondAttribute="leading" id="zkY-0O-xcA"/>
</constraints>
</view>
<connections>

View File

@ -135,8 +135,8 @@ class HiRes: NSView {
super.init(coder: aDecoder)
initHiResLineAddresses()
currentContext?.setShouldAntialias(false)
currentContext?.interpolationQuality = CGInterpolationQuality.none
// currentContext?.setShouldAntialias(false)
// currentContext?.interpolationQuality = CGInterpolationQuality.none
// let scaleSizeW = Double((frame.size).width) / Double(HiRes.PixelWidth)
// let scaleSizeH = Double((frame.size).height) / Double(HiRes.PixelHeight)
@ -496,8 +496,7 @@ class HiRes: NSView {
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
case 0x02: // green
if (prev == 0x02) || (prev == 0x03) || (prev == 0x07) {
// if (prev != 0) && (prev != 4) {
if (prev == 0x02) || (prev == 0x06) || (prev == 0x03) || (prev == 0x07) || (prev == 0x00) || (prev == 0x04) {
HiRes.pixels[pixelAddr + R] = 0x08;
HiRes.pixels[pixelAddr + G] = 0xA2;
HiRes.pixels[pixelAddr + B] = 0x12;
@ -510,10 +509,19 @@ class HiRes: NSView {
HiRes.pixels[pixelAddr + A] = 0x00;
}
HiRes.pixels[pixelAddr + 4 + R] = 0x08;
HiRes.pixels[pixelAddr + 4 + G] = 0xA2;
HiRes.pixels[pixelAddr + 4 + B] = 0x12;
HiRes.pixels[pixelAddr + 4 + A] = 0xFF;
// reducing color bleeding
if (prev == 0x01) || (prev == 0x05) {
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
}
else {
HiRes.pixels[pixelAddr + 4 + R] = 0x08;
HiRes.pixels[pixelAddr + 4 + G] = 0xA2;
HiRes.pixels[pixelAddr + 4 + B] = 0x12;
HiRes.pixels[pixelAddr + 4 + A] = 0xFF;
}
case 0x03: // white
HiRes.pixels[pixelAddr + R] = 0xFF;
@ -549,8 +557,8 @@ class HiRes: NSView {
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
case 0x06: // orange
// do we need to extend the color?
if (prev == 0x06) || (prev == 0x03) || (prev == 0x07) {
// if (prev != 0) && (prev != 4) {
HiRes.pixels[pixelAddr + R] = 0xEE;
HiRes.pixels[pixelAddr + G] = 0x22;
HiRes.pixels[pixelAddr + B] = 0x11;
@ -603,19 +611,29 @@ class HiRes: NSView {
HiRes.pixels[pixelAddr - 4 + G] = 0xFF;
HiRes.pixels[pixelAddr - 4 + B] = 0xFF;
HiRes.pixels[pixelAddr - 4 + A] = 0xFF;
// TODO: Need better check if extra green was created
if (HiRes.pixels[pixelAddr - 8 + G] == 0xA2 ) {
HiRes.pixels[pixelAddr - 8 + R] = 0x00;
HiRes.pixels[pixelAddr - 8 + G] = 0x00;
HiRes.pixels[pixelAddr - 8 + B] = 0x00;
HiRes.pixels[pixelAddr - 8 + A] = 0x00;
}
}
// purple adjustment
if (prev == 0x01) && ( (pixel == 0x01) || (pixel == 0x03) || (pixel == 0x07) ) {
HiRes.pixels[pixelAddr - 4 + R] = 0xBB;
HiRes.pixels[pixelAddr - 4 + G] = 0x11;
HiRes.pixels[pixelAddr - 4 + B] = 0xEE;
HiRes.pixels[pixelAddr - 4 + A] = 0xFF;
// purple adjustment -- followed by white
else if (prev == 0x01) && ( (pixel == 0x01) || (pixel == 0x03) || (pixel == 0x07) || (pixel == 0x00) || (pixel == 0x04) ) {
// was the previous purple pixel promoted to white or is it still purple?
if ( HiRes.pixels[pixelAddr - 8 + R] == 0xBB ) {
HiRes.pixels[pixelAddr - 4 + R] = 0xBB;
HiRes.pixels[pixelAddr - 4 + G] = 0x11;
HiRes.pixels[pixelAddr - 4 + B] = 0xEE;
HiRes.pixels[pixelAddr - 4 + A] = 0xFF;
}
}
// blue adjustment
if (prev == 0x05) && ( (pixel == 0x05) || (pixel == 0x03) || (pixel == 0x07) ) {
// if (prev == 0x05) && (pixel != 0) && (pixel != 4) {
else if (prev == 0x05) && ( (pixel == 0x05) || (pixel == 0x03) || (pixel == 0x07) ) {
HiRes.pixels[pixelAddr - 4 + R] = 0x11;
HiRes.pixels[pixelAddr - 4 + G] = 0x66;
HiRes.pixels[pixelAddr - 4 + B] = 0xEE;
@ -704,6 +722,9 @@ class HiRes: NSView {
x = 0
}
// HiRes.context?.setShouldAntialias(true)
// HiRes.context?.interpolationQuality = CGInterpolationQuality.low
guard let image = HiRes.context?.makeImage() else { return }
let boundingBox = CGRect(x: 0, y: 0, width: CGFloat(HiRes.PixelWidth), height: CGFloat(HiRes.PixelHeight))
currentContext!.draw (image, in: boundingBox)