mirror of
https://github.com/trudnai/Steve2.git
synced 2024-12-22 21:29:50 +00:00
- Fixing Color calculations
This commit is contained in:
parent
206b5a1163
commit
4f5e7aef1c
@ -952,8 +952,10 @@
|
|||||||
<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="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="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="LlM-EV-ruZ" firstAttribute="bottom" secondItem="iIF-Q5-Onc" secondAttribute="bottom" constant="-8" id="Vfh-f8-sRz"/>
|
||||||
|
<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 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="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="SEL-hl-0c0" firstAttribute="trailing" secondItem="iIF-Q5-Onc" secondAttribute="trailing" constant="-8" id="cmY-Vb-ckJ"/>
|
||||||
<constraint firstItem="iIF-Q5-Onc" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="m3e-ww-N7S"/>
|
<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="top" secondItem="iIF-Q5-Onc" secondAttribute="top" constant="8" id="mJ3-xG-dB3"/>
|
||||||
|
@ -135,6 +135,9 @@ class HiRes: NSView {
|
|||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
initHiResLineAddresses()
|
initHiResLineAddresses()
|
||||||
|
|
||||||
|
currentContext?.setShouldAntialias(false)
|
||||||
|
currentContext?.interpolationQuality = CGInterpolationQuality.none
|
||||||
|
|
||||||
// let scaleSizeW = Double((frame.size).width) / Double(HiRes.PixelWidth)
|
// let scaleSizeW = Double((frame.size).width) / Double(HiRes.PixelWidth)
|
||||||
// let scaleSizeH = Double((frame.size).height) / Double(HiRes.PixelHeight)
|
// let scaleSizeH = Double((frame.size).height) / Double(HiRes.PixelHeight)
|
||||||
let scaleSizeW = 2
|
let scaleSizeW = 2
|
||||||
@ -468,7 +471,7 @@ class HiRes: NSView {
|
|||||||
|
|
||||||
#elseif HIRESLOWCOLOR
|
#elseif HIRESLOWCOLOR
|
||||||
|
|
||||||
func hiresColorPixel ( pixelAddr : Int, pixel : Int ) {
|
func hiresColorPixel ( pixelAddr : Int, pixel : Int, prev : Int ) {
|
||||||
switch ( pixel ) {
|
switch ( pixel ) {
|
||||||
case 0x00: // black
|
case 0x00: // black
|
||||||
HiRes.pixels[pixelAddr + R] = 0x00;
|
HiRes.pixels[pixelAddr + R] = 0x00;
|
||||||
@ -476,17 +479,40 @@ class HiRes: NSView {
|
|||||||
HiRes.pixels[pixelAddr + B] = 0x00;
|
HiRes.pixels[pixelAddr + B] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + A] = 0x00;
|
HiRes.pixels[pixelAddr + A] = 0x00;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
|
||||||
|
|
||||||
case 0x01: // purple (bits are in reverse!)
|
case 0x01: // purple (bits are in reverse!)
|
||||||
HiRes.pixels[pixelAddr + R] = 0xBB;
|
HiRes.pixels[pixelAddr + R] = 0xBB;
|
||||||
HiRes.pixels[pixelAddr + G] = 0x11;
|
HiRes.pixels[pixelAddr + G] = 0x11;
|
||||||
HiRes.pixels[pixelAddr + B] = 0xEE;
|
HiRes.pixels[pixelAddr + B] = 0xEE;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
|
||||||
|
|
||||||
case 0x02: // green
|
case 0x02: // green
|
||||||
HiRes.pixels[pixelAddr + R] = 0x08;
|
if (prev != 0) && (prev != 4) {
|
||||||
HiRes.pixels[pixelAddr + G] = 0xA2;
|
HiRes.pixels[pixelAddr + R] = 0x08;
|
||||||
HiRes.pixels[pixelAddr + B] = 0x12;
|
HiRes.pixels[pixelAddr + G] = 0xA2;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + B] = 0x12;
|
||||||
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HiRes.pixels[pixelAddr + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + B] = 0x00;
|
||||||
|
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;
|
||||||
|
|
||||||
case 0x03: // white
|
case 0x03: // white
|
||||||
HiRes.pixels[pixelAddr + R] = 0xFF;
|
HiRes.pixels[pixelAddr + R] = 0xFF;
|
||||||
@ -494,23 +520,51 @@ class HiRes: NSView {
|
|||||||
HiRes.pixels[pixelAddr + B] = 0xFF;
|
HiRes.pixels[pixelAddr + B] = 0xFF;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0xFF;
|
||||||
|
|
||||||
case 0x04: // black 2
|
case 0x04: // black 2
|
||||||
HiRes.pixels[pixelAddr + R] = 0x00;
|
HiRes.pixels[pixelAddr + R] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + G] = 0x00;
|
HiRes.pixels[pixelAddr + G] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + B] = 0x00;
|
HiRes.pixels[pixelAddr + B] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + A] = 0x00;
|
HiRes.pixels[pixelAddr + A] = 0x00;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
|
||||||
|
|
||||||
case 0x05: // blue
|
case 0x05: // blue
|
||||||
HiRes.pixels[pixelAddr + R] = 0x11;
|
HiRes.pixels[pixelAddr + R] = 0x11;
|
||||||
HiRes.pixels[pixelAddr + G] = 0x66;
|
HiRes.pixels[pixelAddr + G] = 0x66;
|
||||||
HiRes.pixels[pixelAddr + B] = 0xEE;
|
HiRes.pixels[pixelAddr + B] = 0xEE;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
|
||||||
|
|
||||||
case 0x06: // orange
|
case 0x06: // orange
|
||||||
HiRes.pixels[pixelAddr + R] = 0xEE;
|
if (prev != 0) && (prev != 4) {
|
||||||
HiRes.pixels[pixelAddr + G] = 0x22;
|
HiRes.pixels[pixelAddr + R] = 0xEE;
|
||||||
HiRes.pixels[pixelAddr + B] = 0x11;
|
HiRes.pixels[pixelAddr + G] = 0x22;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + B] = 0x11;
|
||||||
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HiRes.pixels[pixelAddr + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + A] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0xEE;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x22;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x11;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0xFF;
|
||||||
|
|
||||||
case 0x07: // white 2
|
case 0x07: // white 2
|
||||||
HiRes.pixels[pixelAddr + R] = 0xFF;
|
HiRes.pixels[pixelAddr + R] = 0xFF;
|
||||||
@ -518,12 +572,53 @@ class HiRes: NSView {
|
|||||||
HiRes.pixels[pixelAddr + B] = 0xFF;
|
HiRes.pixels[pixelAddr + B] = 0xFF;
|
||||||
HiRes.pixels[pixelAddr + A] = 0xFF;
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0xFF;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HiRes.pixels[pixelAddr + R] = 0x00;
|
HiRes.pixels[pixelAddr + R] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + G] = 0x00;
|
HiRes.pixels[pixelAddr + G] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + B] = 0x00;
|
HiRes.pixels[pixelAddr + B] = 0x00;
|
||||||
HiRes.pixels[pixelAddr + A] = 0x00;
|
HiRes.pixels[pixelAddr + A] = 0x00;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr + 4 + R] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + G] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + B] = 0x00;
|
||||||
|
HiRes.pixels[pixelAddr + 4 + A] = 0x00;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// white adjustment
|
||||||
|
if ( (prev & 2) == 2 ) && ( (pixel & 1) == 1 ) {
|
||||||
|
HiRes.pixels[pixelAddr + R] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + G] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + B] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr + A] = 0xFF;
|
||||||
|
|
||||||
|
HiRes.pixels[pixelAddr - 4 + R] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + G] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + B] = 0xFF;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + A] = 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// purple adjustment
|
||||||
|
if (prev == 0x01) && (pixel != 0) && (pixel != 4) {
|
||||||
|
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 != 0) && (pixel != 4) {
|
||||||
|
HiRes.pixels[pixelAddr - 4 + R] = 0x11;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + G] = 0x66;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + B] = 0xEE;
|
||||||
|
HiRes.pixels[pixelAddr - 4 + A] = 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func draw(_ rect: CGRect) {
|
override func draw(_ rect: CGRect) {
|
||||||
@ -545,6 +640,8 @@ class HiRes: NSView {
|
|||||||
var y = 0
|
var y = 0
|
||||||
|
|
||||||
for lineAddr in HiResLineAddrTbl {
|
for lineAddr in HiResLineAddrTbl {
|
||||||
|
var prev = 0
|
||||||
|
|
||||||
for blockAddr in 0 ..< HiRes.blockCols / 2 {
|
for blockAddr in 0 ..< HiRes.blockCols / 2 {
|
||||||
let blockH = Int(HiResBufferPointer[ Int(lineAddr + blockAddr * 2) ])
|
let blockH = Int(HiResBufferPointer[ Int(lineAddr + blockAddr * 2) ])
|
||||||
let blockH7 = ( blockH >> 5 ) & 0x04
|
let blockH7 = ( blockH >> 5 ) & 0x04
|
||||||
@ -555,15 +652,16 @@ class HiRes: NSView {
|
|||||||
|
|
||||||
let screenIdx = y * HiRes.blockCols + x
|
let screenIdx = y * HiRes.blockCols + x
|
||||||
|
|
||||||
|
|
||||||
// if ( shadowScreen[ screenIdx ] != block ) {
|
// if ( shadowScreen[ screenIdx ] != block ) {
|
||||||
shadowScreen[ screenIdx ] = block
|
shadowScreen[ screenIdx ] = block
|
||||||
|
|
||||||
for px in 0 ... 2 {
|
for px in 0 ... 2 {
|
||||||
// let bitMask = 3 << ( px * 2 )
|
// let bitMask = 3 << ( px * 2 )
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockH7 | ( (block >> (px * 2)) & 3 ) ) )
|
let pixel = blockH7 | ( (block >> (px * 2)) & 3 )
|
||||||
pixelAddr += 4
|
hiresColorPixel(pixelAddr: pixelAddr, pixel: pixel, prev: prev )
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockH7 | ( (block >> (px * 2)) & 3 ) ) )
|
pixelAddr += 8
|
||||||
pixelAddr += 4
|
prev = pixel
|
||||||
|
|
||||||
// if ( minX > x ) { minX = x }
|
// if ( minX > x ) { minX = x }
|
||||||
// if ( minY > y ) { minY = y }
|
// if ( minY > y ) { minY = y }
|
||||||
@ -573,17 +671,17 @@ class HiRes: NSView {
|
|||||||
// x += 2
|
// x += 2
|
||||||
}
|
}
|
||||||
|
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockH7 | ( (block >> (3 * 2)) & 3 ) ) )
|
let pixel = blockH7 | ( (block >> (3 * 2)) & 3 )
|
||||||
pixelAddr += 4
|
hiresColorPixel(pixelAddr: pixelAddr, pixel: pixel, prev: prev )
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockL7 | ( (block >> (3 * 2)) & 3 ) ) )
|
pixelAddr += 8
|
||||||
pixelAddr += 4
|
prev = pixel
|
||||||
|
|
||||||
for px in 4 ... 6 {
|
for px in 4 ... 6 {
|
||||||
// let bitMask = 3 << ( px * 2 )
|
// let bitMask = 3 << ( px * 2 )
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockL7 | ( (block >> (px * 2)) & 3 ) ) )
|
let pixel = blockL7 | ( (block >> (px * 2)) & 3 )
|
||||||
pixelAddr += 4
|
hiresColorPixel(pixelAddr: pixelAddr, pixel: pixel, prev: prev )
|
||||||
hiresColorPixel(pixelAddr: pixelAddr, pixel: ( blockL7 | ( (block >> (px * 2)) & 3 ) ) )
|
pixelAddr += 8
|
||||||
pixelAddr += 4
|
prev = pixel
|
||||||
|
|
||||||
// if ( minX > x ) { minX = x }
|
// if ( minX > x ) { minX = x }
|
||||||
// if ( minY > y ) { minY = y }
|
// if ( minY > y ) { minY = y }
|
||||||
|
Loading…
Reference in New Issue
Block a user