diff --git a/A2Mac.xcodeproj/project.pbxproj b/A2Mac.xcodeproj/project.pbxproj index 0fe17d1..7c5243a 100644 --- a/A2Mac.xcodeproj/project.pbxproj +++ b/A2Mac.xcodeproj/project.pbxproj @@ -228,6 +228,8 @@ 32C82360290888D10018438F /* CheatMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32100A8A2875387300D894EE /* CheatMenu.swift */; }; 32D0897C291A44F200F2B486 /* 6502_bp.c in Sources */ = {isa = PBXBuildFile; fileRef = 32D0897B291A44F200F2B486 /* 6502_bp.c */; }; 32D0897D291A44F200F2B486 /* 6502_bp.c in Sources */ = {isa = PBXBuildFile; fileRef = 32D0897B291A44F200F2B486 /* 6502_bp.c */; }; + 32D089D8291E1BF800F2B486 /* DisassView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D089D7291E1BF800F2B486 /* DisassView.swift */; }; + 32D089D9291E1BF800F2B486 /* DisassView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D089D7291E1BF800F2B486 /* DisassView.swift */; }; 32E3126624A7193700E61891 /* disk_ii_arm.sfx in Resources */ = {isa = PBXBuildFile; fileRef = 32E3126424A7193700E61891 /* disk_ii_arm.sfx */; }; 32E3126724A7194900E61891 /* disk_ii_arm.sfx in Copy SFX Files */ = {isa = PBXBuildFile; fileRef = 32E3126424A7193700E61891 /* disk_ii_arm.sfx */; }; 32E3126924A98B9300E61891 /* dsk2woz.c in Sources */ = {isa = PBXBuildFile; fileRef = 32E3126824A98B9300E61891 /* dsk2woz.c */; }; @@ -747,6 +749,7 @@ 32D0897B291A44F200F2B486 /* 6502_bp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = 6502_bp.c; sourceTree = ""; }; 32D08987291A450400F2B486 /* 6502_bp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 6502_bp.h; sourceTree = ""; }; 32D08992291AF23500F2B486 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = A2Mac/Base.lproj/Debug.storyboard; sourceTree = ""; }; + 32D089D7291E1BF800F2B486 /* DisassView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisassView.swift; sourceTree = ""; }; 32DBF7632334657900DD50E7 /* HiRes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HiRes.swift; sourceTree = ""; }; 32DBF76723373FB400DD50E7 /* disassembler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = disassembler.h; sourceTree = ""; }; 32E21BE62491BF8B006C0C72 /* apple-rainbow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apple-rainbow.png"; sourceTree = ""; }; @@ -1179,6 +1182,7 @@ 32E3126C24AC033A00E61891 /* ToolBarController.swift */, 32C6995127C5439300D0F25D /* Debugger.swift */, 323D042F24898AB70086A901 /* PreferencesViewController.swift */, + 32D089D7291E1BF800F2B486 /* DisassView.swift */, 327B75D629064FDC00A86A71 /* DebuggerViewController.swift */, 32C823392908822E0018438F /* DebuggerWindowController.swift */, 323D04312489BFD80086A901 /* PreferencesWindowController.swift */, @@ -1661,6 +1665,7 @@ 32A6AB10266AF5160023257A /* paddle.c in Sources */, 32799F83264B1A5700255669 /* speaker.c in Sources */, 32799F84264B1A5700255669 /* common.c in Sources */, + 32D089D9291E1BF800F2B486 /* DisassView.swift in Sources */, 32799F85264B1A5700255669 /* ViewController.swift in Sources */, 32799F86264B1A5700255669 /* HiRes.swift in Sources */, 32799F87264B1A5700255669 /* LoRes.swift in Sources */, @@ -1693,6 +1698,7 @@ 325EB63623F8F78300C6B4A4 /* disk.c in Sources */, 32100A8B2875387300D894EE /* CheatMenu.swift in Sources */, 3268B97A27DE7D6A003FBDCC /* disassembler.c in Sources */, + 32D089D8291E1BF800F2B486 /* DisassView.swift in Sources */, 32C6995D27C548C800D0F25D /* Shaders.metal in Sources */, 325EB62F23F8856F00C6B4A4 /* woz.c in Sources */, 32100AB42877AB8600D894EE /* scsi.c in Sources */, diff --git a/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist b/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist index 422e8f5..ec5ebce 100644 --- a/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist +++ b/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -481,6 +481,9 @@ + + @@ -1375,5 +1378,16 @@ + + + + + + + + diff --git a/A2Mac/Base.lproj/Debugger.storyboard b/A2Mac/Base.lproj/Debugger.storyboard index a60bb5f..b20b4b4 100644 --- a/A2Mac/Base.lproj/Debugger.storyboard +++ b/A2Mac/Base.lproj/Debugger.storyboard @@ -256,8 +256,8 @@ - - + + @@ -475,7 +475,7 @@ C20D: 4C C5 FE JMP $FEC5
FEC5: 8D 06 C0 STA $C006 - + diff --git a/A2Mac/DebuggerViewController.swift b/A2Mac/DebuggerViewController.swift index bba7222..9ee292d 100644 --- a/A2Mac/DebuggerViewController.swift +++ b/A2Mac/DebuggerViewController.swift @@ -23,7 +23,7 @@ import Cocoa -class DebuggerViewController: NSViewController, NSTextFieldDelegate { +class DebuggerViewController: NSViewController { static var shared : DebuggerViewController? = nil @IBOutlet var CPU_Display: DisplayView! @@ -221,7 +221,7 @@ N V - B D I Z C let lines_to_disass = 300 - func get_scroll_line(view: DisplayView) -> Int { + func get_scroll_line(view: NSTextView) -> Int { let scrollPos = view.visibleRect.origin.y let lineSpacing = CGFloat(1.5) let lineHeight = view.font!.pointSize * lineSpacing @@ -277,7 +277,7 @@ N V - B D I Z C let lineFromTopToMiddle = 15 - func scroll_to(view: DisplayView, line: Int) { + func scroll_to(view: NSTextView, line: Int) { if let lineRange = getLineRange(inView: view, forLine: line + lineFromTopToMiddle) { view.scrollRangeToVisible(lineRange) } @@ -295,7 +295,7 @@ N V - B D I Z C ] - func remove_highlight(view: DisplayView, line: Int) { + func remove_highlight(view: NSTextView, line: Int) { if line > 0 { if let lineRange = getLineRange(inView: view, forLine: line) { view.layoutManager?.removeTemporaryAttribute(NSAttributedString.Key.backgroundColor, forCharacterRange: lineRange) @@ -305,7 +305,7 @@ N V - B D I Z C } - func highlight(view: DisplayView, line: Int, attr: [NSAttributedString.Key : Any]) { + func highlight(view: NSTextView, line: Int, attr: [NSAttributedString.Key : Any]) { if line > 0 { // remove old highlighted line remove_highlight(view: view, line: line) @@ -328,32 +328,40 @@ N V - B D I Z C } - override func mouseMoved(with event: NSEvent) { - var location = event.locationInWindow - let disass_frame = Disass_Scroll.superview?.frame - let minX = disass_frame!.minX + Disass_Scroll.frame.minX - let minY = disass_frame!.minY + Disass_Scroll.frame.minY - let maxX = minX + Disass_Scroll.frame.width - let maxY = minY + Disass_Scroll.frame.height + func highlightCursor(scrollView : NSView, display : NSTextView, mouseLocation : NSPoint) { + var location = mouseLocation + let parent_frame = scrollView.superview?.frame + + let minX = parent_frame!.minX + scrollView.frame.minX + let minY = parent_frame!.minY + scrollView.frame.minY + let maxX = minX + scrollView.frame.width + let maxY = minY + scrollView.frame.height -// if isMouseInView(view: Disass_Scroll) { if location.x > minX && location.x < maxX && location.y > minY && location.y < maxY { -// location.x -= Disass_Scroll.frame.origin.x -// location.y -= Disass_Scroll.frame.origin.y location.x = maxX - location.x - location.y = maxY - location.y + Disass_Display.visibleRect.origin.y - // print(location) + location.y = maxY - location.y + display.visibleRect.origin.y - let line = getLine(inView: Disass_Display, forY: location.y) - highlight(view: Disass_Display, line: line_number_at_PC, attr: lineAttrAtPC) - remove_highlight(view: Disass_Display, line: line_number_cursor) - highlight(view: Disass_Display, line: line, attr: lineAttrAtSelected) + let line = getLine(inView: display, forY: location.y) + highlight(view: display, line: line_number_at_PC, attr: lineAttrAtPC) + remove_highlight(view: display, line: line_number_cursor) + highlight(view: display, line: line, attr: lineAttrAtSelected) line_number_cursor = line } } + override func mouseDown(with event: NSEvent) { + let location = event.locationInWindow + highlightCursor(scrollView: Disass_Scroll, display: Disass_Display, mouseLocation: location) + } + +// override func mouseMoved(with event: NSEvent) { +// let location = event.locationInWindow +// highlightCursor(scrollView: Disass_Scroll, display: Disass_Display, mouseLocation: location) +// } + + var addr_line = [UInt16 : Int]() func DisplayDisassembly() { diff --git a/A2Mac/DisassView.swift b/A2Mac/DisassView.swift new file mode 100644 index 0000000..1034d73 --- /dev/null +++ b/A2Mac/DisassView.swift @@ -0,0 +1,87 @@ +// +// DisassView.swift +// Steve ][ +// +// Created by Tamas Rudnai on 5/11/21. +// Copyright © 2021 GameAlloy. All rights reserved. +// + +import Cocoa + +class DisassView: NSTextView { + + override var acceptsFirstResponder: Bool { + get { + return true + } + } + + var trackingArea: NSTrackingArea? + + func debugDisplayContraints() { + print( "debugDisplayContraints ----------------------------------" ) + if let view = window?.contentView { + for constraint in view.constraints { + print( "debugDisplayContraints:", constraint.identifier ?? "{Constaint has no identifier}", constraint.constant ) + } + } + } + + /// Install tracking area if window is set, remove previous one if needed. + func installTrackingArea() { + guard let window = window else { return } + window.acceptsMouseMovedEvents = true + if trackingArea != nil { removeTrackingArea(trackingArea!) } + let trackingOptions : NSTrackingArea.Options = [.activeAlways, .mouseEnteredAndExited, .mouseMoved] + trackingArea = NSTrackingArea(rect: bounds, + options: trackingOptions, + owner: self, userInfo: nil) + self.addTrackingArea(trackingArea!) + } + + + // Called when layout is modified + override func updateTrackingAreas() { + super.updateTrackingAreas() + installTrackingArea() + } + + + override func acceptsFirstMouse(for event: NSEvent?) -> Bool { + return true + } + + override func mouseDown(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.mouseDown(with: event) + + // debugDisplayContraints() + } + + override func mouseUp(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.mouseUp(with: event) + } + + override func rightMouseDown(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.rightMouseDown(with: event) + } + + override func rightMouseUp(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.rightMouseUp(with: event) + } + + override func otherMouseDown(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.otherMouseDown(with: event) + } + + override func otherMouseUp(with event: NSEvent) { + // print(#function + "DisassView") + DebuggerViewController.shared?.otherMouseUp(with: event) + } + +} +