Display Text Memory

This commit is contained in:
Tamas Rudnai 2019-09-08 19:55:19 -07:00
parent b9e8640178
commit f5ea13eb86
3 changed files with 63 additions and 19 deletions

View File

@ -686,8 +686,7 @@
<windowController id="B8D-0N-5wS" sceneMemberID="viewController"> <windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA"> <window key="window" title="Window" 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"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="196" y="240" width="480" height="440"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections> <connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/> <outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
@ -706,16 +705,16 @@
<objects> <objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="A2Mac" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="A2Mac" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl"> <view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/> <rect key="frame" x="0.0" y="0.0" width="480" height="440"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Uza-t6-XSw"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uza-t6-XSw">
<rect key="frame" x="20" y="20" width="440" height="235"/> <rect key="frame" x="10" y="10" width="460" height="420"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="5AO-Gd-Lzo"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" enabled="NO" refusesFirstResponder="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" borderStyle="border" alignment="center" placeholderString="Apple ][ Emulator Virtual Monitor" drawsBackground="YES" allowsEditingTextAttributes="YES" id="5AO-Gd-Lzo">
<font key="font" metaFont="fixedUser" size="11"/> <font key="font" size="14" name="Courier-Bold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="systemGreenColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" red="0.12549019607843137" green="0.17933968321917809" blue="0.12549019607843137" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
</subviews> </subviews>

View File

@ -12,14 +12,54 @@ class ViewController: NSViewController {
@IBOutlet weak var display: NSTextFieldCell! @IBOutlet weak var display: NSTextFieldCell!
func check() { static let charConvStr : String =
let textBufferPointer = UnsafeRawBufferPointer(start: &RAM+0x400, count: 0x400) "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?" +
// let string = String(bytes: ram, encoding: .utf8) "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?" +
// print(string) "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?" +
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~?"
static let charConvTbl = Array( charConvStr )
let textLineOfs : [Int] = [
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x028, 0x0A8, 0x128, 0x1A8,
0x228, 0x2A8, 0x328, 0x3A8, 0x050, 0x0D0, 0x150, 0x1D0, 0x250, 0x2D0, 0x350, 0x3D0
]
func update() {
while true {
usleep(33333) // 1/30 sec
let textBaseAddr = 0x400
let textLines = 24
let textCols = 40
var txt : String = "|"
for y in 0...textLines-1 {
let textAddr = textBaseAddr + textLineOfs[y]
let textBufferPointer = UnsafeRawBufferPointer(start: &RAM + textAddr, count: textCols)
for (index, byte) in textBufferPointer.enumerated() { for (index, byte) in textBufferPointer.enumerated() {
print("byte \(index): \(byte)") let idx = Int(byte);
let chr = ViewController.charConvTbl[idx]
// print("byte \(index): \(chr)")
txt = txt + [chr]
} }
txt = txt + "|\n|"
}
DispatchQueue.main.async {
self.display.stringValue = txt;
}
}
// DispatchQueue.main.asyncAfter(deadline: .now() + 1/30, execute: {
// self.update()
// })
} }
@ -67,10 +107,14 @@ class ViewController: NSViewController {
// } // }
// DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: { // DispatchQueue.main.asyncAfter(deadline: .now() + 1/30, execute: {
// self.check() // self.update()
// }) // })
DispatchQueue.global(qos: .background).async {
self.update()
}
} }
override var representedObject: Any? { override var representedObject: Any? {

View File

@ -98,6 +98,7 @@ static inline void STR( uint8_t * dst, uint8_t imm ) {
// if (( imm > ' ' ) && ( c < 0x7F )) // if (( imm > ' ' ) && ( c < 0x7F ))
// printf("%04X: t:%02X '%c'\n", v, imm, isprint(c) ? c : ' '); // printf("%04X: t:%02X '%c'\n", v, imm, isprint(c) ? c : ' ');
// } // }
} }
/** /**