Display Registers

This commit is contained in:
tudnai 2022-10-26 07:20:52 -07:00
parent f84481e3b6
commit e3c872d23c
4 changed files with 64 additions and 6 deletions

View File

@ -1159,6 +1159,7 @@
32C6995127C5439300D0F25D /* Debugger.swift */,
323D042F24898AB70086A901 /* PreferencesViewController.swift */,
327B75D629064FDC00A86A71 /* DebuggerViewController.swift */,
32C823392908822E0018438F /* DebuggerWindowController.swift */,
323D04312489BFD80086A901 /* PreferencesWindowController.swift */,
32B18435233F10BC00DBB4AB /* Shaders.metal */,
32C4532D233345420000EBA1 /* MonitorView.swift */,
@ -1178,7 +1179,6 @@
32BFFB6422EACC660003B53F /* A2Mac.entitlements */,
32439F7222ECD8AC0077AAE0 /* A2Mac-Bridging-Header.h */,
32E3126C24AC033A00E61891 /* ToolBarController.swift */,
32C823392908822E0018438F /* DebuggerWindowController.swift */,
3267641724BCC9A5000BEA11 /* COPYING */,
3277D7A2273C603600749544 /* DisplayScrollView.swift */,
3268B96F27DBD219003FBDCC /* convert_spkr_buf_to_wav.py */,

View File

@ -195,7 +195,7 @@
<scene sceneID="TCG-Cv-QBI">
<objects>
<viewController title="Debugger Controller Scene" id="R5e-co-cXs" customClass="DebuggerViewController" customModule="A2MacTests" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" identifier="Monitor View" wantsLayer="YES" focusRingType="none" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" misplaced="YES" id="Myj-W6-YvY" customClass="MonitorView" customModule="A2MacTests" customModuleProvider="target">
<view key="view" identifier="Monitor View" wantsLayer="YES" focusRingType="none" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" misplaced="YES" id="Myj-W6-YvY" userLabel="Debugger View">
<rect key="frame" x="0.0" y="0.0" width="1024" height="622"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
@ -220,7 +220,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" selectable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" horizontallyResizable="YES" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsCharacterPickerTouchBarItem="NO" textCompletion="NO" id="Hwx-Gd-XW1" userLabel="Display" customClass="DisplayView" customModule="A2MacTests" customModuleProvider="target">
<rect key="frame" x="0.0" y="113" width="288" height="1271"/>
<rect key="frame" x="0.0" y="113" width="288" height="1270"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.12549019610000001" green="0.12549019610000001" blue="0.12549019610000001" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
@ -451,7 +451,7 @@ C20D: 4C C5 FE JMP $FEC5
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" selectable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" horizontallyResizable="YES" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsCharacterPickerTouchBarItem="NO" textCompletion="NO" id="BHr-Q4-rBI" userLabel="Display" customClass="DisplayView" customModule="A2MacTests" customModuleProvider="target">
<rect key="frame" x="0.0" y="-42" width="349" height="181"/>
<rect key="frame" x="0.0" y="-43" width="349" height="182"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="windowBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -763,6 +763,9 @@ C20D: 4C C5 FE JMP $FEC5
<constraint firstAttribute="trailing" secondItem="JUf-qx-iuW" secondAttribute="trailing" constant="8" id="kwa-ri-Rtq"/>
</constraints>
</view>
<connections>
<outlet property="CPU_Display" destination="Wrs-Qt-Kmd" id="SUW-Lc-Zv4"/>
</connections>
</viewController>
<customObject id="DyX-eh-3mW" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<toolbarItem implicitItemIdentifier="BFA7134C-38B0-453E-9AFB-33B380479DB4" label="Game" paletteLabel="Game" image="Joystick" id="mKu-aU-HoF">

View File

@ -25,6 +25,8 @@ import Cocoa
class DebuggerViewController: NSViewController {
@IBOutlet var CPU_Display: DisplayView!
override func viewDidLoad() {
super.viewDidLoad()
@ -37,5 +39,60 @@ class DebuggerViewController: NSViewController {
// // Update window title with the active TableView Title
// self.parent?.view.window?.title = self.title!
DisplayRegisters()
}
func bin(n : UInt8, sp : String = "", mid : String = " ") -> String {
var str = ""
var n = n
for i in 1...8 {
if n & 0x80 == 0 {
str += "0"
}
else {
str += "1"
}
str += sp
if i == 4 {
str += mid
}
n <<= 1
}
return str
}
func DisplayRegisters() {
let registers = String(format:"""
A: %02X %3u %@
X: %02X %3u %@
Y: %02X %3u %@
SP: %02X
PC: %04X
N V - B D I Z C
%d %d %d %d %d %d %d %d
""",
m6502.A, m6502.A, bin(n: m6502.A),
m6502.X, m6502.X, bin(n: m6502.X),
m6502.Y, m6502.Y, bin(n: m6502.Y),
m6502.SP,
m6502.PC,
m6502.N > 0, m6502.V > 0, m6502.res > 0, m6502.B > 0, m6502.D > 0, m6502.I > 0, m6502.Z > 0, m6502.C > 0
)
CPU_Display.string = registers
}
}

View File

@ -39,8 +39,6 @@ class DebuggerToolBarController: NSWindowController, NSWindowDelegate {
if isWindowFullscreen {
window?.toggleFullScreen(self)
}
NSLog("Debugger Window")
}