mirror of
https://github.com/trudnai/Steve2.git
synced 2025-03-10 02:32:57 +00:00
- Paste into VM
- HiRes (HIRESOWCOLOR) now respects pages and mixed mode
This commit is contained in:
parent
3a01ee2934
commit
126f76c9a4
@ -731,7 +731,7 @@
|
||||
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
|
||||
<window key="window" title="Apple ][ Emulator" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="720" height="420"/>
|
||||
<rect key="contentRect" x="196" y="240" width="1440" height="840"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
|
||||
@ -750,11 +750,11 @@
|
||||
<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="684" height="400"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="1368" height="784"/>
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="0.0" width="592" height="400"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="1152" height="784"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" baseWritingDirection="leftToRight" title="Display Background" drawsBackground="YES" id="cIa-Sd-4OZ">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" red="0.078431372549019607" green="0.10980392156862745" blue="0.078431372549019607" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -765,13 +765,13 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField canDrawConcurrently="YES" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" mirrorLayoutDirectionWhenInternationalizing="never" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SEL-hl-0c0">
|
||||
<rect key="frame" x="14" y="8" width="572" height="384"/>
|
||||
<rect key="frame" x="14" y="8" width="1124" height="768"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="568" id="uez-Mi-0Sh"/>
|
||||
<constraint firstAttribute="height" constant="384" id="zl6-au-oZj"/>
|
||||
<constraint firstAttribute="width" constant="1120" id="uez-Mi-0Sh"/>
|
||||
<constraint firstAttribute="height" constant="768" id="zl6-au-oZj"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" refusesFirstResponder="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" baseWritingDirection="leftToRight" id="pIk-RC-s5g">
|
||||
<font key="font" size="16" name="PrintChar21"/>
|
||||
<font key="font" size="32" name="PrintChar21"/>
|
||||
<string key="title">1234567890123456789012345678901234567890
|
||||
@@@@@@@@@1@@@@@@@@@2@@@@@@@@@3@@@@@@@@@4
|
||||
@@@@@@@@@@@@@@@@@@@3@@@@@@@@@@@@@@@@@@@@
|
||||
@ -801,14 +801,14 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<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"/>
|
||||
<rect key="frame" x="16" y="8" width="1120" height="768"/>
|
||||
</customView>
|
||||
<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"/>
|
||||
<rect key="frame" x="16" y="8" width="1120" height="768"/>
|
||||
<imageCell key="cell" continuous="YES" enabled="NO" 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="86" height="32"/>
|
||||
<rect key="frame" x="1154" y="746" width="210" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="21" id="t2i-0h-wau"/>
|
||||
</constraints>
|
||||
@ -821,7 +821,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rR3-9T-NFu">
|
||||
<rect key="frame" x="594" y="331" width="86" height="32"/>
|
||||
<rect key="frame" x="1154" y="715" width="210" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="21" id="sbX-nh-SV3"/>
|
||||
</constraints>
|
||||
@ -834,7 +834,7 @@
|
||||
</buttonCell>
|
||||
</button>
|
||||
<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"/>
|
||||
<rect key="frame" x="1290" 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"/>
|
||||
@ -928,7 +928,7 @@
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FZk-VW-alq">
|
||||
<rect key="frame" x="635" y="20" width="41" height="17"/>
|
||||
<rect key="frame" x="1319" y="20" width="41" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="17" id="ai1-6C-5tW"/>
|
||||
</constraints>
|
||||
@ -955,7 +955,7 @@
|
||||
<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="SEL-hl-0c0" firstAttribute="trailing" secondItem="iIF-Q5-Onc" secondAttribute="trailing" constant="-16" 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"/>
|
||||
|
@ -140,9 +140,10 @@ class HiRes: NSView {
|
||||
|
||||
// let scaleSizeW = Double((frame.size).width) / Double(HiRes.PixelWidth)
|
||||
// let scaleSizeH = Double((frame.size).height) / Double(HiRes.PixelHeight)
|
||||
let scaleSizeW = 2
|
||||
let scaleSizeH = 2
|
||||
scaleUnitSquare(to: NSSize(width: scaleSizeW, height: scaleSizeH))
|
||||
|
||||
// let scaleSizeW = 4
|
||||
// let scaleSizeH = 4
|
||||
// scaleUnitSquare(to: NSSize(width: scaleSizeW, height: scaleSizeH))
|
||||
|
||||
// create smaller box views for draw optimization
|
||||
createHiRes()
|
||||
@ -399,7 +400,8 @@ class HiRes: NSView {
|
||||
let B = 0
|
||||
let A = 3
|
||||
|
||||
var shadowScreen = [Int](repeating: 1, count: PageSize)
|
||||
var blockChanged = [Bool](repeating: false, count: HiRes.blockRows * HiRes.blockCols / 2)
|
||||
var shadowScreen = [Int](repeating: 0, count: PageSize)
|
||||
|
||||
var was = 0;
|
||||
|
||||
@ -665,6 +667,24 @@ class HiRes: NSView {
|
||||
// return
|
||||
// }
|
||||
// was += 1
|
||||
|
||||
var height = HiRes.PixelHeight
|
||||
|
||||
// do not even render it...
|
||||
if videoMode.text == 1 {
|
||||
return
|
||||
}
|
||||
else {
|
||||
if videoMode.mixed == 1 {
|
||||
height = HiRes.MixedHeight
|
||||
}
|
||||
if videoMode.page == 1 {
|
||||
HiResBufferPointer = HiResBuffer2
|
||||
}
|
||||
else {
|
||||
HiResBufferPointer = HiResBuffer1
|
||||
}
|
||||
}
|
||||
|
||||
var pixelAddr = 0
|
||||
|
||||
@ -676,23 +696,35 @@ class HiRes: NSView {
|
||||
var x = 0
|
||||
var y = 0
|
||||
|
||||
HiRes.context?.clear( CGRect(x: 0, y: 0, width: frame.width, height: frame.height) )
|
||||
|
||||
for lineAddr in HiResLineAddrTbl {
|
||||
|
||||
if ( height <= 0 ) {
|
||||
break
|
||||
}
|
||||
height -= 1
|
||||
|
||||
let blockVertIdx = y / 8 * HiRes.blockCols / 2
|
||||
var prev = 0
|
||||
|
||||
for blockAddr in 0 ..< HiRes.blockCols / 2 {
|
||||
let blockH = Int(HiResBufferPointer[ Int(lineAddr + blockAddr * 2) ])
|
||||
for blockHorIdx in 0 ..< HiRes.blockCols / 2 {
|
||||
let blockH = Int(HiResBufferPointer[ Int(lineAddr + blockHorIdx * 2) ])
|
||||
let blockH7 = ( blockH >> 5 ) & 0x04
|
||||
let blockL = Int(HiResBufferPointer[ Int(lineAddr + blockAddr * 2) + 1 ])
|
||||
let blockL = Int(HiResBufferPointer[ Int(lineAddr + blockHorIdx * 2) + 1 ])
|
||||
let blockL7 = ( blockL >> 5 ) & 0x04
|
||||
|
||||
let block = ( blockL << 7 ) | ( blockH & 0x7F ) & 0x3FFF
|
||||
|
||||
let screenIdx = y * HiRes.blockCols + x
|
||||
|
||||
let screenIdx = y * HiRes.blockCols + blockHorIdx
|
||||
if ( shadowScreen[ screenIdx ] != block ) {
|
||||
blockChanged[ blockVertIdx + blockHorIdx ] = true
|
||||
}
|
||||
else {
|
||||
blockChanged[ blockVertIdx + blockHorIdx ] = false
|
||||
}
|
||||
|
||||
// if ( shadowScreen[ screenIdx ] != block ) {
|
||||
shadowScreen[ screenIdx ] = block
|
||||
|
||||
for px in 0 ... 2 {
|
||||
// let bitMask = 3 << ( px * 2 )
|
||||
let pixel = blockH7 | ( (block >> (px * 2)) & 3 )
|
||||
@ -727,12 +759,12 @@ class HiRes: NSView {
|
||||
//
|
||||
// x += 2
|
||||
}
|
||||
// }
|
||||
}
|
||||
// else {
|
||||
// pixelAddr += 4 * 7
|
||||
// x += 7
|
||||
// }
|
||||
}
|
||||
// }
|
||||
|
||||
y += 1
|
||||
x = 0
|
||||
@ -742,7 +774,22 @@ class HiRes: NSView {
|
||||
// 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))
|
||||
|
||||
// let blockScreenWidth = HiRes.PixelWidth * 4 / (HiRes.blockCols / 2)
|
||||
// let blockScreenHeigth = HiRes.PixelHeight * 4 / HiRes.blockRows
|
||||
//
|
||||
// for y in 0 ..< HiRes.blockRows {
|
||||
// for x in 0 ..< HiRes.blockCols / 2 {
|
||||
// // refresh the entire screen
|
||||
// let boundingBox = CGRect(x: x * blockScreenWidth, y: y * blockScreenHeigth, width: blockScreenWidth, height: blockScreenHeigth)
|
||||
// currentContext!.draw (image, in: boundingBox)
|
||||
//return
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// refresh the entire screen
|
||||
let boundingBox = CGRect(x: 0, y: 0, width: frame.width, height: frame.height)
|
||||
currentContext!.draw (image, in: boundingBox)
|
||||
}
|
||||
|
||||
@ -837,16 +884,18 @@ class HiRes: NSView {
|
||||
#elseif HIRESDRAW
|
||||
let path = NSBezierPath()
|
||||
override func draw(_ rect: CGRect) {
|
||||
|
||||
let pixelWidth = bounds.width / CGFloat(HiRes.PixelWidth)
|
||||
let pixelHeight = bounds.height / CGFloat(HiRes.PixelHeight)
|
||||
|
||||
// self.hidden = videoMode.text == 1
|
||||
|
||||
// NSColor.green.setFill()
|
||||
// NSColor(calibratedRed: 0.0314, green: 0.635, blue: 0.071, alpha: 1.0).setStroke()
|
||||
// NSColor(calibratedRed: 0.05, green: 0.7, blue: 0.1, alpha: 1.0).setStroke()
|
||||
NSColor.systemGreen.setStroke()
|
||||
|
||||
|
||||
path.removeAllPoints()
|
||||
path.lineWidth = 0.7
|
||||
path.lineWidth = 0.7 * pixelHeight
|
||||
path.move(to: NSPoint(x: 0, y: 0))
|
||||
|
||||
// path.appendRect(NSRect(x: 0, y: 0, width: 10, height: 10))
|
||||
@ -869,6 +918,7 @@ class HiRes: NSView {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for y in 0 ..< height {
|
||||
var inX = false
|
||||
path.move(to: NSPoint(x: 0, y: y))
|
||||
@ -888,13 +938,13 @@ class HiRes: NSView {
|
||||
if (block & bitMask) == 0 {
|
||||
if inX {
|
||||
inX = false
|
||||
path.line(to: NSPoint(x: x, y: 192-y))
|
||||
path.line(to: NSPoint(x: CGFloat(x) * pixelWidth, y: CGFloat(192 - y) * pixelHeight ))
|
||||
}
|
||||
}
|
||||
else { // 28CD41
|
||||
if ( inX == false ) {
|
||||
inX = true
|
||||
path.move(to: NSPoint(x: x, y: 192-y))
|
||||
path.move(to: NSPoint(x: CGFloat(x) * pixelWidth, y: CGFloat(192 - y) * pixelHeight ))
|
||||
}
|
||||
}
|
||||
|
||||
@ -905,14 +955,14 @@ class HiRes: NSView {
|
||||
// make sure we close the path if the next block is completely zero
|
||||
if inX {
|
||||
inX = false
|
||||
path.line(to: NSPoint(x: x, y: 192-y))
|
||||
path.line(to: NSPoint(x: CGFloat(x) * pixelWidth, y: CGFloat(192 - y) * pixelHeight ))
|
||||
}
|
||||
}
|
||||
} // x
|
||||
// make sure we close the path at the end of the horizontal line
|
||||
if inX {
|
||||
inX = false
|
||||
path.line(to: NSPoint(x: 279, y: 192-y))
|
||||
path.line(to: NSPoint(x: 279 * pixelWidth, y: CGFloat(192 - y) * pixelHeight ))
|
||||
}
|
||||
}
|
||||
// path.fill()
|
||||
|
@ -181,10 +181,12 @@ class ViewController: NSViewController {
|
||||
override func keyDown(with event: NSEvent) {
|
||||
print("KBD Event")
|
||||
|
||||
for i in 0...65536 {
|
||||
ddd = Int(event.keyCode) + i
|
||||
}
|
||||
ddd = ddd * 2
|
||||
// for i in 0...65536 {
|
||||
// ddd = Int(event.keyCode) + i
|
||||
// }
|
||||
// ddd = ddd * 2
|
||||
|
||||
|
||||
// switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
|
||||
// case [.command] where event.characters == "l",
|
||||
// [.command, .shift] where event.characters == "l":
|
||||
@ -195,37 +197,64 @@ class ViewController: NSViewController {
|
||||
// print( "key = " + (event.charactersIgnoringModifiers ?? ""))
|
||||
// print( "\ncharacter = " + (event.characters ?? ""))
|
||||
|
||||
#if FUNCTIONTEST
|
||||
#else
|
||||
let keyCode = Int(event.keyCode)
|
||||
switch keyCode {
|
||||
case leftArrowKey:
|
||||
kbdInput(0x08)
|
||||
setIO(0xC064, 0);
|
||||
print("LEFT", ddd);
|
||||
case rightArrowKey:
|
||||
kbdInput(0x15)
|
||||
setIO(0xC064, 255);
|
||||
print("RIGHT")
|
||||
case downArrowKey:
|
||||
kbdInput(0x0B)
|
||||
setIO(0xC065, 255);
|
||||
print("DOWN")
|
||||
case upArrowKey:
|
||||
kbdInput(0x0A)
|
||||
setIO(0xC065, 0);
|
||||
print("UP")
|
||||
default:
|
||||
// print("keycode: %d", keyCode)
|
||||
if let chars = event.characters {
|
||||
let char = chars.uppercased()[chars.startIndex]
|
||||
if let ascii = char.asciiValue {
|
||||
kbdInput(ascii)
|
||||
|
||||
if event.modifierFlags.contains(.command) { // .shift, .option, .control ...
|
||||
if let chars = event.charactersIgnoringModifiers {
|
||||
switch chars {
|
||||
case "v":
|
||||
print("CMD + V")
|
||||
|
||||
let pasteBoard = NSPasteboard.general
|
||||
if let str = pasteBoard.string( forType: .string ) {
|
||||
print("PASTED:", str)
|
||||
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
for char in str.uppercased() {
|
||||
if let ascii = char.asciiValue {
|
||||
kbdInput(ascii)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else {
|
||||
#if FUNCTIONTEST
|
||||
#else
|
||||
let keyCode = Int(event.keyCode)
|
||||
switch keyCode {
|
||||
case leftArrowKey:
|
||||
kbdInput(0x08)
|
||||
setIO(0xC064, 0);
|
||||
print("LEFT", ddd);
|
||||
case rightArrowKey:
|
||||
kbdInput(0x15)
|
||||
setIO(0xC064, 255);
|
||||
print("RIGHT")
|
||||
case downArrowKey:
|
||||
kbdInput(0x0B)
|
||||
setIO(0xC065, 255);
|
||||
print("DOWN")
|
||||
case upArrowKey:
|
||||
kbdInput(0x0A)
|
||||
setIO(0xC065, 0);
|
||||
print("UP")
|
||||
default:
|
||||
// print("keycode: %d", keyCode)
|
||||
if let chars = event.characters {
|
||||
let char = chars.uppercased()[chars.startIndex]
|
||||
if let ascii = char.asciiValue {
|
||||
kbdInput(ascii)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
override func keyUp(with event: NSEvent) {
|
||||
|
@ -473,10 +473,10 @@ void setIO ( uint16_t ioaddr, uint8_t val ) {
|
||||
void kbdInput ( uint8_t code ) {
|
||||
// printf("kbdInput: %02X ('%c')\n", code, isprint(code) ? code : ' ');
|
||||
switch ( code ) {
|
||||
// case '\n':
|
||||
// code = 0x0D;
|
||||
// break;
|
||||
//
|
||||
case '\n':
|
||||
code = 0x0D;
|
||||
break;
|
||||
|
||||
case 0x7F: // BackSlash
|
||||
code = 0x08;
|
||||
break;
|
||||
@ -487,8 +487,8 @@ void kbdInput ( uint8_t code ) {
|
||||
|
||||
code |= 0x80;
|
||||
|
||||
for( int i = 1000; i && ( RAM[io_KBD] > 0x7F ); --i ) {
|
||||
usleep(10);
|
||||
for( int i = 10000000; i && ( RAM[io_KBD] > 0x7F ); --i ) {
|
||||
usleep(1);
|
||||
}
|
||||
|
||||
RAM[io_KBD] = code;
|
||||
|
Loading…
x
Reference in New Issue
Block a user