mirror of
https://github.com/trudnai/Steve2.git
synced 2025-02-06 03:31:02 +00:00
Add / remove breakpoints by clicking at the beginning of the line
This commit is contained in:
parent
8ae44a587f
commit
94e230e51e
@ -1183,6 +1183,14 @@
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "m6502_dbg_bp_del:6502_bp.c">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "bp_idx">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "AppDelegate.showPreferences(_:):AppDelegate.swift">
|
||||
<PersistentStrings>
|
||||
|
@ -328,6 +328,22 @@ N V - B D I Z C
|
||||
}
|
||||
|
||||
|
||||
func convertMouseCoordinates(scrollView : NSView, display : NSTextView, mouseLocation : NSPoint) -> 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
|
||||
|
||||
// location.x = maxX - location.x
|
||||
location.y = maxY - location.y + display.visibleRect.origin.y
|
||||
|
||||
return location
|
||||
}
|
||||
|
||||
|
||||
func highlightCursor(scrollView : NSView, display : NSTextView, mouseLocation : NSPoint) {
|
||||
var location = mouseLocation
|
||||
let parent_frame = scrollView.superview?.frame
|
||||
@ -339,7 +355,7 @@ N V - B D I Z C
|
||||
|
||||
if location.x > minX && location.x < maxX
|
||||
&& location.y > minY && location.y < maxY {
|
||||
location.x = maxX - location.x
|
||||
// location.x = maxX - location.x
|
||||
location.y = maxY - location.y + display.visibleRect.origin.y
|
||||
|
||||
let line = getLine(inView: display, forY: location.y)
|
||||
@ -351,19 +367,50 @@ N V - B D I Z C
|
||||
}
|
||||
|
||||
|
||||
// select disassembly line
|
||||
override func mouseDown(with event: NSEvent) {
|
||||
let location = convertMouseCoordinates(scrollView: Disass_Scroll, display: Disass_Display, mouseLocation: event.locationInWindow)
|
||||
|
||||
if location.x < 30 {
|
||||
let line = getLine(inView: Disass_Display, forY: location.y)
|
||||
let addr = getAddr(forLine: line)
|
||||
|
||||
if m6502_dbg_bp_is_exists(addr) {
|
||||
m6502_dbg_bp_del(addr)
|
||||
}
|
||||
else {
|
||||
m6502_dbg_bp_add(addr)
|
||||
}
|
||||
|
||||
// force regenerate disassembly
|
||||
disass_addr = 0xFFFF
|
||||
DisplayDisassembly()
|
||||
// scroll_to(view: Disass_Display, line: line)
|
||||
}
|
||||
else {
|
||||
highlightCursor(scrollView: Disass_Scroll, display: Disass_Display, mouseLocation: location)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// context menu
|
||||
override func rightMouseDown(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 getLine(forAddr: UInt16) -> Int {
|
||||
return addr_line[forAddr] ?? 0
|
||||
}
|
||||
|
||||
func getAddr(forLine: Int) -> UInt16 {
|
||||
return addr_line.first(where: { $1 == forLine })?.key ?? 0
|
||||
}
|
||||
|
||||
|
||||
func DisplayDisassembly() {
|
||||
let m6502_saved = m6502
|
||||
var disass = ""
|
||||
@ -378,7 +425,7 @@ N V - B D I Z C
|
||||
// TODO: Also check if memory area updated!
|
||||
|
||||
var need_disass = m6502.PC < disass_addr || m6502.PC > disass_addr + disass_addr_max
|
||||
line_number_at_PC = addr_line[m6502_saved.PC] ?? 0
|
||||
line_number_at_PC = getLine(forAddr: m6502_saved.PC)
|
||||
|
||||
// if m6502.PC > disass_addr && m6502.PC < disass_addr + disass_addr_max {
|
||||
if line_number_at_PC != 0 && !need_disass {
|
||||
|
@ -58,30 +58,30 @@ class DisassView: NSTextView {
|
||||
// debugDisplayContraints()
|
||||
}
|
||||
|
||||
override func mouseUp(with event: NSEvent) {
|
||||
// print(#function + "DisassView")
|
||||
DebuggerViewController.shared?.mouseUp(with: event)
|
||||
}
|
||||
// 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 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)
|
||||
}
|
||||
// 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)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ void m6502_Run() {
|
||||
|
||||
void m6502_Debug(void) {
|
||||
m6502.clktime += m6502.clkfrm;
|
||||
m6502.clkfrm = 0;
|
||||
// m6502.clkfrm = 0;
|
||||
m6502.lastIO = 0;
|
||||
m6502.interrupt = NO_INT; // TODO: This should be taken care by the interrupt handler
|
||||
|
||||
@ -436,14 +436,9 @@ void m6502_Debug(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( m6502_dbg_bp_is_exists(m6502.PC) ) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
m6502.debugger.on = 0;
|
||||
return;
|
||||
}
|
||||
clk_6502_per_frm_max = clk_6502_per_frm;
|
||||
|
||||
for ( clk_6502_per_frm_max = clk_6502_per_frm; m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() ) {
|
||||
for ( m6502.clkfrm = m6502_Step(); m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() ) {
|
||||
switch (m6502.interrupt) {
|
||||
case HALT:
|
||||
if (m6502.debugger.mask.hlt) {
|
||||
@ -514,6 +509,14 @@ void m6502_Debug(void) {
|
||||
}
|
||||
|
||||
m6502.interrupt = NO_INT;
|
||||
|
||||
if ( m6502_dbg_bp_is_exists(m6502.PC) ) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
m6502.debugger.on = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,11 +77,11 @@ uint16_t m6502_dbg_bp_get_first() {
|
||||
/// m6502_dbg_bp_get_first
|
||||
/// Get first valid BP
|
||||
/// @return addr of BP or 0 if non
|
||||
uint16_t m6502_dbg_bp_is_exists(uint16_t addr) {
|
||||
_Bool m6502_dbg_bp_is_exists(uint16_t addr) {
|
||||
for (uint16_t bp = m6502_dbg_bp_get_first(); bp; bp = m6502_dbg_bp_get_next()) {
|
||||
if ( bp == addr) {
|
||||
// found it!
|
||||
return bp;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -103,16 +103,26 @@ int m6502_dbg_bp_add(uint16_t addr) {
|
||||
}
|
||||
|
||||
|
||||
void m6502_dbg_bp_init(void) {
|
||||
/// m6502_dbg_bp_del
|
||||
/// Remove a breakpoint
|
||||
/// @param addr address to remove
|
||||
void m6502_dbg_bp_del(uint16_t addr) {
|
||||
for (uint16_t bp = m6502_dbg_bp_get_first(); bp; bp = m6502_dbg_bp_get_next()) {
|
||||
if ( bp == addr ) {
|
||||
breakpoints[bp_idx] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void m6502_dbg_bp_del_all(void) {
|
||||
bp_idx = 0;
|
||||
memset(breakpoints, 0, sizeof(breakpoints));
|
||||
|
||||
m6502_dbg_bp_add(0xC28B); // keyin DOS 3.3
|
||||
}
|
||||
|
||||
|
||||
void m6502_dbg_init(void) {
|
||||
m6502_dbg_bp_init();
|
||||
m6502_dbg_bp_del_all();
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,9 @@ extern uint16_t breakpoints[DEBUG_MAX_BREAKPOINTS];
|
||||
|
||||
extern void m6502_dbg_init(void);
|
||||
extern int m6502_dbg_bp_add(uint16_t addr);
|
||||
extern uint16_t m6502_dbg_bp_is_exists(uint16_t addr);
|
||||
extern void m6502_dbg_bp_del(uint16_t addr);
|
||||
extern void m6502_dbg_bp_del_all(void);
|
||||
extern _Bool m6502_dbg_bp_is_exists(uint16_t addr);
|
||||
|
||||
|
||||
#endif /* _6502_bp_h */
|
||||
|
Loading…
x
Reference in New Issue
Block a user