diff --git a/A2Mac.xcodeproj/project.pbxproj b/A2Mac.xcodeproj/project.pbxproj index 24ad3b6..461cc69 100644 --- a/A2Mac.xcodeproj/project.pbxproj +++ b/A2Mac.xcodeproj/project.pbxproj @@ -2059,6 +2059,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = W6TFQTZ4DA; GCC_ENABLE_CPP_EXCEPTIONS = YES; GCC_ENABLE_CPP_RTTI = YES; @@ -2255,6 +2256,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = W6TFQTZ4DA; GCC_ENABLE_CPP_EXCEPTIONS = YES; GCC_ENABLE_CPP_RTTI = YES; 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 f2abebb..3949670 100644 --- a/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist +++ b/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -3,31 +3,16 @@ version = "1.0"> + contextName = "m6502_Debug:6502.c"> + value = "m6502.debugger.SP"> + value = "m6502.debugger.mask.ret"> - - - - - - - - - - + value = "m6502.SP"> @@ -35,29 +20,49 @@ contextName = "HiRes.compute():HiRes.swift"> + value = "UnsafeRawBufferPointer(result)"> + value = "computePipelineState.maxTotalThreadsPerThreadgroup"> + contextName = "ViewController.mouseMoved(with:):ViewController.swift"> + value = "oldLocation"> + value = "mouseLocation"> + + + contextName = "closure #1 in ViewController.Update():ViewController.swift"> + + + + + + + + + + + + @@ -94,10 +99,10 @@ value = "disassLineRange[forLine]"> + value = "disassLineRange.count"> + value = "disassLineRange"> @@ -137,10 +142,10 @@ contextName = "HiRes.draw(_:):HiRes.swift"> + value = "ctx?.height"> + value = "ctx?.data"> @@ -163,15 +168,15 @@ + + + + - - - - + value = "disass_addr_min"> @@ -207,7 +212,7 @@ value = "m6502.PC"> + value = "line_number"> @@ -463,10 +468,10 @@ contextName = "specialized closure #1 in DebuggerViewController.DisplayDisassembly(scrollY:):DebuggerViewController.swift"> + value = "m6502_saved.PC"> + value = "isCurrentLine"> @@ -475,7 +480,7 @@ value = "m6502.PC"> + value = "scroll_line_number"> @@ -489,7 +494,7 @@ value = "textDisplay_height_diff"> + value = "textDisplay_width_diff"> @@ -501,7 +506,7 @@ value = "MonitorView.textViewBounds"> + value = "textDisplay.frame"> @@ -567,10 +572,10 @@ contextName = "set_flags_NZC:common.h"> + value = "(unsigned)0xFF"> + value = "(unsigned)test "> @@ -594,17 +599,6 @@ - - - - - - - - @@ -678,10 +672,10 @@ value = "MEMcfg.int_Cx_ROM"> + value = "m6502.clkfrm"> + value = "(int)IOframe"> @@ -692,10 +686,10 @@ value = "Apple2_64K_AUX + 0xC600"> + value = "Apple2_64K_RAM + 0xC600"> + value = "(void*)rom"> @@ -819,16 +813,16 @@ contextName = "DisplayScrollView.scrollWheel(with:):DisplayScrollView.swift"> + value = "documentView"> + value = "textView.defaultParagraphStyle?.lineSpacing"> + value = "subviews[1].subviews"> @@ -920,25 +914,25 @@ contextName = "_fetch_dbg:mmio.c"> + value = "disassembly.pOpcode"> + value = "memread8_low(m6502.PC)"> + + - - + value = "disassLineRange"> @@ -1033,7 +1027,7 @@ value = "scroll_line_number"> + value = "highlighted_line_number"> @@ -1149,7 +1143,7 @@ contextName = "LoRes.Update():LoRes.swift"> + value = "UInt8( (block >> 4) & 0x0F )"> @@ -1158,7 +1152,7 @@ value = "UInt8(block & 4)"> + value = "blockChanged[ screenIdx ]"> @@ -1215,10 +1209,10 @@ value = "m6502"> + value = "m6502.PC"> + value = "m6502.clkfrm"> @@ -1227,10 +1221,10 @@ value = "Apple2_64K_AUX + 0x3600"> + value = "(void*)Apple2_64K_RAM"> + value = "Apple2_64K_RAM + 0x3600"> @@ -1244,7 +1238,7 @@ value = "pdl_value[pdl]"> + value = "normalized_time"> @@ -1256,7 +1250,7 @@ value = "1 * 512 * (1 - ( 3300 / 3300.0 ))"> + value = "normalized_time >= pdl_value[pdl] ? 255 : 0"> @@ -1275,10 +1269,10 @@ contextName = "ToolBarController.GamePort(_:):ToolBarController.swift"> + value = "ViewController.current?.mouseCursorHidden"> + value = "ViewController.current?.mouseCursorJoystickEmulation"> @@ -1501,7 +1495,7 @@ value = "m6502.PC"> + value = "m6502.debugger.on"> @@ -1510,7 +1504,7 @@ value = "frameCounter"> + value = "m6502.clkfrm"> @@ -1536,6 +1530,17 @@ + + + + + + + + @@ -1544,6 +1549,35 @@ + + + + + + + + + + + + + + + + + + + + @@ -1555,6 +1589,9 @@ + + @@ -1565,7 +1602,7 @@ value = "new"> + value = "WOZtmp.shift16"> @@ -1577,7 +1614,7 @@ value = "(1 << i) - 1"> + value = "WOZwrite.shift16"> @@ -1615,53 +1652,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/A2Mac/Base.lproj/Debugger.storyboard b/A2Mac/Base.lproj/Debugger.storyboard index 9596384..5db6364 100644 --- a/A2Mac/Base.lproj/Debugger.storyboard +++ b/A2Mac/Base.lproj/Debugger.storyboard @@ -367,7 +367,7 @@ - + @@ -428,6 +428,9 @@ + + + @@ -544,7 +547,7 @@ - + diff --git a/A2Mac/DebuggerViewController.swift b/A2Mac/DebuggerViewController.swift index 7b328eb..b533180 100644 --- a/A2Mac/DebuggerViewController.swift +++ b/A2Mac/DebuggerViewController.swift @@ -79,7 +79,14 @@ class DebuggerViewController: NSViewController { // For the fake text view scroller // 64K RAM/2 as an average bytes / instruction - Disass_Display.string = String(repeating: "\n", count: 32768); +// Disass_Display.string = String(repeating: "\n", count: 2220); + + Disass_Display.string = "" + // for proper address scrolling + var r = Disass_Display.frame + r.size.height = 65535 + Disass_Display.frame = r + } @@ -97,29 +104,53 @@ class DebuggerViewController: NSViewController { } - override func scrollWheel(with event: NSEvent) { - super.scrollWheel(with: event) - let location = event.locationInWindow - print("scrollWheel") + /// Disassembly View Scroll changed + func disassScroller(needScroll : Bool = false) { + var scrollTo = Disass_Display.visibleRect.origin + let maxAddr = Float(0xFFD0) + let scrollPos = Disass_Scroll.verticalScroller?.floatValue ?? 0 + let addr = scrollPos * maxAddr + disass_addr_pc = addr < maxAddr ? UInt16(addr) : UInt16(maxAddr) - if location.x > Disass_Scroll.frame.minX - && location.x < Disass_Scroll.frame.maxX - && location.y < Disass_Scroll.frame.minY - && location.y < Disass_Scroll.frame.maxY - { - print("Disass_Scroll") - var scrollTo = Disass_Display.visibleRect.origin - let lineSpacing = CGFloat(1.5) - let fontPointSize = CGFloat(10) // Disass_Display.font!.pointSize - let lineHeight = fontPointSize * lineSpacing - - let y1 = round( (scrollTo.y + round(event.scrollingDeltaY) * lineHeight) / lineHeight) * lineHeight - - scrollTo.y = y1 +// print("disassScroller ", "scrollTo", scrollTo, "scrollPos", scrollPos, " addr:", disass_addr_pc) + if needScroll { + scrollTo.y = Disass_Display.frame.height * CGFloat(scrollPos) Disass_Display.scroll(scrollTo) } + DisassAddressPC.state = .off + DisplayDisassembly(scrollY: scrollTo.y) + } + + + override func scrollWheel(with event: NSEvent) { + super.scrollWheel(with: event) + + let location = event.locationInWindow + +// print("scrollWheel, location:", location, +// Disass_Scroll.frame.minX, +// Disass_Scroll.frame.maxX, +// Disass_Scroll.frame.minY, +// Disass_Scroll.frame.maxY +// ) + + if location.x > Disass_Scroll.frame.minX + && location.x < Disass_Scroll.frame.maxX + && location.y > Disass_Scroll.frame.minY + && location.y < Disass_Scroll.frame.maxY + { + disassScroller() + } + + } + + + /// Disassemby View had been Scrolled using the ScrollBar Y + /// - Parameter sender: ScrollBar + @IBAction func DisassScrolled(_ sender: NSScroller) { + disassScroller(needScroll: true) } @@ -271,7 +302,7 @@ N V - B D I Z C var disass_addr : UInt16 = 0 /// Address disassembled in the window var disass_addr_pc : UInt16 = 0 /// Address to disassemble let disass_addr_pre : UInt16 = 20 - let disass_addr_min_pre : UInt16 = 0 // 320 - 20 + let disass_addr_min_pre : UInt16 = 32 // how many bytes we need to start to disassemble before our target address var line_number = 0 var scroll_line_number = 0 var highlighted_line_number = 0 @@ -348,13 +379,14 @@ N V - B D I Z C let lineFromTopToMiddle = 0 + func scroll_to(view: NSTextView, line: Int) { let lineSpacing = 1.5 let fontPointSize = 10.0 // Disass_Display.font!.pointSize let lineHeight = fontPointSize * lineSpacing let line = line > 0 ? line - 1 : 0 - if let lineRange = getLineRange(disassLineRange, forLine: line + lineFromTopToMiddle) { + if getLineRange(disassLineRange, forLine: line + lineFromTopToMiddle) != nil { view.scroll( NSPoint(x: 0, y: Double(line) * lineHeight ) ) } @@ -544,7 +576,6 @@ N V - B D I Z C var isCurrentLine = false func DisplayDisassembly( scrollY : CGFloat = -1 ) { -// var disass = "" var disass = "" var loc = 0 @@ -565,7 +596,7 @@ N V - B D I Z C disass_addr_pc = m6502.PC } // } - var need_disass = disass_addr_pc < disass_addr || UInt(disass_addr_pc) > UInt(disass_addr) + UInt(disass_addr_max) + var need_disass = scrollY > 0 || disass_addr_pc < disass_addr || UInt(disass_addr_pc) > UInt(disass_addr) + UInt(disass_addr_max) scroll_line_number = getLine(forAddr: disass_addr_pc) highlighted_line_number = getLine(forAddr: m6502.PC) @@ -637,34 +668,17 @@ N V - B D I Z C DispatchQueue.main.async { if need_disass { - self.Disass_Display.scroll(CGPoint.zero) self.disassDisplay(str: disass) } let currentScrollLine = self.get_scroll_line(view: self.Disass_Display) + 1 if self.highlighted_line_number <= currentScrollLine || self.highlighted_line_number > currentScrollLine + 25 { - - if scrollY < 0 { - self.scroll_to(view: self.Disass_Display, line: /*preLines +*/ self.scroll_line_number) - - // at the beginning it takes a while to fill up the buffer -- maybe allocation issue? -// if currentScrollLine == 1 { -// // so we need to scroll a bit later when the string is already populated -// // DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { -// self.scroll_to(view: self.Disass_Display, line: self.line_number_at_PC - 5) -// // } -// } - } - else { - // caller wants a specific scroll location... - self.Disass_Display.scroll(NSPoint(x: 0, y: scrollY)) + if scrollY < 0 && self.DisassAddressPC.state == .off { + self.Disass_Display.scroll(NSPoint(x: 0, y: Int(self.disass_addr))) } } self.highlight(view: self.Disass_Display, line: self.highlighted_line_number, attr: self.lineAttrAtPC) } -// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - // your code here -// } } @@ -700,6 +714,7 @@ N V - B D I Z C // sender.stringValue = "4321" // MemoryAddressField.stringValue DisassAddressPC.state = .off disass_addr_pc = UInt16(sender.stringValue.hexValue()) +// Disass_Display.scroll(NSPoint(x: 0, y: Int(disass_addr_pc))) DisplayDisassembly() } diff --git a/A2Mac/DisplayScrollView.swift b/A2Mac/DisplayScrollView.swift index 836c4fb..7e553ce 100644 --- a/A2Mac/DisplayScrollView.swift +++ b/A2Mac/DisplayScrollView.swift @@ -14,6 +14,7 @@ class DisplayScrollView : NSScrollView { var scrollEnabled = false override func scrollWheel(with event: NSEvent) { +// print("DisplayScrollView.scrollWheel") if scrollEnabled { super.scrollWheel(with: event) } @@ -21,11 +22,14 @@ class DisplayScrollView : NSScrollView { let textView = documentView as! NSTextView var scrollTo = textView.visibleRect.origin let lineSpacing = CGFloat(1.5) // textView.defaultParagraphStyle?.lineSpacing ?? CGFloat(1.5) - let lineHeight = textView.font!.pointSize * lineSpacing + let fontPointSize = CGFloat(10) // textView.font!.pointSize + let lineHeight = fontPointSize * lineSpacing - scrollTo.y = scrollTo.y + event.scrollingDeltaY * lineHeight + scrollTo.y = scrollTo.y + event.scrollingDeltaY // * lineHeight textView.scroll(scrollTo) + + DebuggerViewController.shared?.scrollWheel(with: event) } }