mirror of https://github.com/trudnai/Steve2.git
Proper Step_Out & Step_Over with rendering, input and all
This commit is contained in:
parent
462e1fe8ee
commit
31d26228d8
|
@ -48,7 +48,7 @@
|
|||
value = "default_MHz_6502 * 1000 * 1000 / spkr_sample_rate">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "( (spkr_clk + m6502.clkfrm) / ( 1024000 / spkr_sample_rate ) ) * 2">
|
||||
value = "( (spkr_clk + m6502.clkfrm) / ( default_MHz_6502 * 1000 * 1000 / spkr_sample_rate)) * 2">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(int16_t)28000 + (int16_t)-32768">
|
||||
|
@ -66,7 +66,7 @@
|
|||
value = "(spkr_clk + m6502.clkfrm)">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "( (spkr_clk + m6502.clkfrm) / ( default_MHz_6502 * 1000 * 1000 / spkr_sample_rate)) * 2">
|
||||
value = "( (spkr_clk + m6502.clkfrm) / ( 1024000 / spkr_sample_rate ) ) * 2">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -166,7 +166,7 @@
|
|||
contextName = "closure #1 in ViewController.Update():ViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "txtArr">
|
||||
value = "MEMcfg.txt_page_2">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "self.shadowTxt">
|
||||
|
@ -178,7 +178,7 @@
|
|||
value = "MEMcfg.is_80STORE">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "MEMcfg.txt_page_2">
|
||||
value = "txtArr">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -307,7 +307,7 @@
|
|||
contextName = "LoRes.Update():LoRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "blockChanged[ screenIdx ]">
|
||||
value = "UInt8( (block >> 4) & 0x0F )">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UInt8(block)">
|
||||
|
@ -316,7 +316,7 @@
|
|||
value = "UInt8(block & 4)">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UInt8( (block >> 4) & 0x0F )">
|
||||
value = "blockChanged[ screenIdx ]">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -421,6 +421,20 @@
|
|||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "m6502_Debug:6502.c">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "m6502.debugger.SP">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "m6502.debugger.mask.ret">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "m6502.SP">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "BRA:6502_instr_branch.h">
|
||||
<PersistentStrings>
|
||||
|
@ -569,10 +583,10 @@
|
|||
contextName = "ToolBarController.GamePort(_:):ToolBarController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "ViewController.current?.mouseCursorJoystickEmulation">
|
||||
value = "ViewController.current?.mouseCursorHidden">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ViewController.current?.mouseCursorHidden">
|
||||
value = "ViewController.current?.mouseCursorJoystickEmulation">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -611,13 +625,13 @@
|
|||
contextName = "HiRes.compute():HiRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
|
||||
value = "UnsafeRawBufferPointer(result)">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "result[2]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UnsafeRawBufferPointer(result)">
|
||||
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -704,7 +718,7 @@
|
|||
value = "new">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZwrite.shift16">
|
||||
value = "WOZtmp.shift16">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZwrite.shift">
|
||||
|
@ -716,7 +730,7 @@
|
|||
value = "(1 << i) - 1">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZtmp.shift16">
|
||||
value = "WOZwrite.shift16">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -786,10 +800,10 @@
|
|||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "DebuggerViewController.disass_scroll_to(line:):DebuggerViewController.swift">
|
||||
contextName = "DebuggerViewController.get_scroll_line(view:):DebuggerViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "Disass_Display.visibleRect">
|
||||
value = "scrollPos / lineHeight">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -802,10 +816,10 @@
|
|||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "DebuggerViewController.get_scroll_line(view:):DebuggerViewController.swift">
|
||||
contextName = "DebuggerViewController.disass_scroll_to(line:):DebuggerViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "scrollPos / lineHeight">
|
||||
value = "Disass_Display.visibleRect">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -884,10 +898,10 @@
|
|||
contextName = "set_flags_NZC:common.h">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "(unsigned)test ">
|
||||
value = "(unsigned)0xFF">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(unsigned)0xFF">
|
||||
value = "(unsigned)test ">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -921,10 +935,10 @@
|
|||
contextName = "HiRes.draw(_:):HiRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "linAddr">
|
||||
value = "ctx?.height">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.bitsPerComponent">
|
||||
value = "ctx?.data">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.width">
|
||||
|
@ -947,15 +961,15 @@
|
|||
<PersistentString
|
||||
value = "(blockH7 | ( block & bitMask ))">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.bitsPerComponent">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "linAddr">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "HiRes.blockCols">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.height">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.data">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
|
@ -990,10 +1004,10 @@
|
|||
value = "m6502">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(void*)Apple2_64K_RAM">
|
||||
value = "Apple2_64K_AUX + 0x3600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_RAM + 0x3600">
|
||||
value = "m6502.clkfrm">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "m6502.ecoSpindown">
|
||||
|
@ -1002,10 +1016,10 @@
|
|||
value = "m6502.PC">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_AUX + 0x3600">
|
||||
value = "(void*)Apple2_64K_RAM">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "m6502.clkfrm">
|
||||
value = "Apple2_64K_RAM + 0x3600">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -1024,7 +1038,7 @@
|
|||
value = "textDisplay_height_diff">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "textDisplay.frame">
|
||||
value = "textDisplay.bounds">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "MonitorView.textViewBounds">
|
||||
|
@ -1036,7 +1050,7 @@
|
|||
value = "textDisplay_width_diff">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "textDisplay.bounds">
|
||||
value = "textDisplay.frame">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -1135,7 +1149,7 @@
|
|||
value = "pdl_value[pdl]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "normalized_time >= pdl_value[pdl] ? 255 : 0">
|
||||
value = "normalized_time">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(3300 * 255/3300)">
|
||||
|
@ -1147,7 +1161,7 @@
|
|||
value = "1 * 512 * (1 - ( 3300 / 3300.0 ))">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "normalized_time">
|
||||
value = "normalized_time >= pdl_value[pdl] ? 255 : 0">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -1218,10 +1232,10 @@
|
|||
value = "Apple2_64K_AUX + 0xC600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(void*)rom">
|
||||
value = "Apple2_64K_RAM + 0xC600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_RAM + 0xC600">
|
||||
value = "(void*)rom">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "strlen(fullPath)">
|
||||
|
|
|
@ -51,7 +51,9 @@ class DebuggerViewController: NSViewController, NSTextFieldDelegate {
|
|||
|
||||
Update()
|
||||
|
||||
DebuggerWindowController.current?.ContinuePauseButtonState()
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.PauseButtonUpdate(needUpdateMainToolbar: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
|||
@IBOutlet weak var PauseButton: NSButton!
|
||||
|
||||
|
||||
func ContinuePauseButtonState() {
|
||||
func PauseButtonUpdate(needUpdateMainToolbar: Bool = true) {
|
||||
DispatchQueue.main.async {
|
||||
switch cpuState {
|
||||
case cpuState_halted:
|
||||
|
@ -97,22 +97,38 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
if needUpdateMainToolbar {
|
||||
ToolBarController.current?.PauseButtonUpdate(needUpdateDebugToolbar: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func Continue() {
|
||||
ContinuePauseButtonState()
|
||||
ToolBarController.current?.PauseButtonUpdate()
|
||||
|
||||
ViewController.current?.Pause(0)
|
||||
|
||||
func Continue() {
|
||||
PauseButtonUpdate()
|
||||
|
||||
m6502.debugger.SP = 0xFF
|
||||
m6502.debugger.wMask = 0
|
||||
m6502.debugger.on = true
|
||||
|
||||
ViewController.current?.Resume()
|
||||
|
||||
m6502.debugger.wMask = 0
|
||||
m6502.debugger.on = false
|
||||
|
||||
PauseButtonUpdate()
|
||||
}
|
||||
|
||||
|
||||
func Pause() {
|
||||
ContinuePauseButtonState()
|
||||
ToolBarController.current?.PauseButtonUpdate()
|
||||
PauseButtonUpdate()
|
||||
|
||||
ViewController.current?.Pause(0)
|
||||
|
||||
m6502.debugger.wMask = 0
|
||||
m6502.debugger.on = false
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,19 +147,17 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
|||
|
||||
|
||||
@IBAction func Step_Over(_ sender: Any) {
|
||||
let sp = m6502.SP
|
||||
if MEM[Int(m6502.PC)] == 0x20 {
|
||||
m6502.debugger.SP = m6502.SP > 1 ? m6502.SP : 0
|
||||
m6502.debugger.mask.out = 1
|
||||
m6502.debugger.on = true
|
||||
|
||||
repeat {
|
||||
m6502_Step()
|
||||
} while m6502.SP < 0xFF && m6502.SP < sp
|
||||
|
||||
// TODO: This should be in Debugger!
|
||||
if let debugger = DebuggerViewController.shared {
|
||||
debugger.Update()
|
||||
ViewController.current?.Resume()
|
||||
}
|
||||
else {
|
||||
// not a JSR call, only do a single step
|
||||
Step_In(sender)
|
||||
}
|
||||
|
||||
// TODO: Update Screen and speaker etc
|
||||
ViewController.current?.Update()
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,28 +175,13 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
|||
|
||||
|
||||
@IBAction func Step_Out(_ sender: Any) {
|
||||
var sp = m6502.SP
|
||||
PauseButtonUpdate()
|
||||
|
||||
repeat {
|
||||
let opcode = MEM[Int(m6502.PC)]
|
||||
m6502.debugger.SP = m6502.SP < 0xFE ? m6502.SP + 1 : 0xFF
|
||||
m6502.debugger.mask.out = 1
|
||||
m6502.debugger.on = true
|
||||
|
||||
m6502_Step()
|
||||
|
||||
// If it was NOT and RTI or RTS and stack pointer is above the saved one...
|
||||
if opcode != 0x40 && opcode != 0x60 && m6502.SP > sp {
|
||||
// ... then we need to update what we are looking at to get to the true frame pointer
|
||||
sp = m6502.SP
|
||||
}
|
||||
|
||||
} while m6502.SP < 0xFE && m6502.SP <= sp
|
||||
|
||||
// TODO: This should be in Debugger!
|
||||
if let debugger = DebuggerViewController.shared {
|
||||
debugger.Update()
|
||||
}
|
||||
|
||||
// TODO: Update Screen and speaker etc
|
||||
ViewController.current?.Update()
|
||||
ViewController.current?.Resume()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,39 +156,45 @@ class ToolBarController: NSWindowController, NSWindowDelegate {
|
|||
@IBOutlet weak var PauseToolbarItem: NSToolbarItem!
|
||||
@IBOutlet weak var PauseButton: NSButton!
|
||||
|
||||
func PauseButtonUpdate() {
|
||||
switch cpuState {
|
||||
case cpuState_halted:
|
||||
if let PauseButton = PauseButton {
|
||||
PauseButton.state = .on
|
||||
}
|
||||
if let PauseToolbarItem = PauseToolbarItem {
|
||||
PauseToolbarItem.label = pauseLabel
|
||||
}
|
||||
func PauseButtonUpdate(needUpdateDebugToolbar: Bool = true) {
|
||||
DispatchQueue.main.async {
|
||||
switch cpuState {
|
||||
case cpuState_halted:
|
||||
if let PauseButton = self.PauseButton {
|
||||
PauseButton.state = .off
|
||||
}
|
||||
if let PauseToolbarItem = self.PauseToolbarItem {
|
||||
PauseToolbarItem.label = self.resumeLabel
|
||||
}
|
||||
|
||||
case cpuState_running:
|
||||
if let PauseButton = PauseButton {
|
||||
PauseButton.state = .off
|
||||
}
|
||||
if let PauseToolbarItem = PauseToolbarItem {
|
||||
PauseToolbarItem.label = resumeLabel
|
||||
}
|
||||
case cpuState_running:
|
||||
if let PauseButton = self.PauseButton {
|
||||
PauseButton.state = .on
|
||||
}
|
||||
if let PauseToolbarItem = self.PauseToolbarItem {
|
||||
PauseToolbarItem.label = self.pauseLabel
|
||||
}
|
||||
|
||||
default:
|
||||
if let PauseToolbarItem = PauseToolbarItem {
|
||||
PauseToolbarItem.isEnabled = false;
|
||||
PauseToolbarItem.label = offLabel
|
||||
default: // OFF
|
||||
if let PauseToolbarItem = self.PauseToolbarItem {
|
||||
PauseToolbarItem.isEnabled = false;
|
||||
PauseToolbarItem.label = self.offLabel
|
||||
}
|
||||
if let PauseButton = self.PauseButton {
|
||||
PauseButton.state = .off
|
||||
}
|
||||
break
|
||||
}
|
||||
if let PauseButton = PauseButton {
|
||||
PauseButton.state = .off
|
||||
}
|
||||
|
||||
if needUpdateDebugToolbar {
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.PauseButtonUpdate(needUpdateMainToolbar: false)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func Pause(_ sender: Any) {
|
||||
PauseButtonUpdate()
|
||||
|
||||
switch cpuState {
|
||||
case cpuState_halted:
|
||||
ViewController.current?.Pause(sender)
|
||||
|
@ -200,7 +206,11 @@ class ToolBarController: NSWindowController, NSWindowDelegate {
|
|||
break
|
||||
}
|
||||
|
||||
DebuggerWindowController.current?.ContinuePauseButtonState()
|
||||
PauseButtonUpdate()
|
||||
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.PauseButtonUpdate(needUpdateMainToolbar: false)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func Reset(_ sender: Any) {
|
||||
|
@ -402,9 +412,11 @@ class ToolBarController: NSWindowController, NSWindowDelegate {
|
|||
if DebuggerWindowController.current == nil {
|
||||
let debuggerStoryboard = NSStoryboard.init(name: NSStoryboard.Name("Debugger"), bundle: nil)
|
||||
debuggerStoryboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier("debuggerWindowController"))
|
||||
// debuggerControler.showWindow(self)
|
||||
}
|
||||
|
||||
DebuggerWindowController.current?.showWindow(self)
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.showWindow(self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -254,7 +254,9 @@ class ViewController: NSViewController {
|
|||
self.upd.resume()
|
||||
#endif
|
||||
|
||||
DebuggerWindowController.current?.ContinuePauseButtonState()
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.PauseButtonUpdate(needUpdateMainToolbar: false)
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
@ -320,7 +322,9 @@ class ViewController: NSViewController {
|
|||
})
|
||||
}
|
||||
|
||||
DebuggerWindowController.current?.ContinuePauseButtonState()
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.PauseButtonUpdate(needUpdateMainToolbar: false)
|
||||
}
|
||||
|
||||
|
||||
// hires.isHidden = true
|
||||
|
@ -345,7 +349,7 @@ class ViewController: NSViewController {
|
|||
cpuState = cpuState_running
|
||||
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.ContinuePauseButtonState()
|
||||
debugger.PauseButtonUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +364,7 @@ class ViewController: NSViewController {
|
|||
cpuState = cpuState_halted
|
||||
|
||||
if let debugger = DebuggerWindowController.current {
|
||||
debugger.ContinuePauseButtonState()
|
||||
debugger.PauseButtonUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1289,8 +1293,31 @@ class ViewController: NSViewController {
|
|||
// run some code
|
||||
// cpuState = cpuState_executing
|
||||
// DispatchQueue.global(qos: .userInitiated).async {
|
||||
if m6502.debug {
|
||||
if m6502.debugger.on {
|
||||
m6502_Debug()
|
||||
|
||||
switch m6502.interrupt {
|
||||
case HALT:
|
||||
Pause()
|
||||
|
||||
case BREAK:
|
||||
Pause()
|
||||
|
||||
case RET:
|
||||
if m6502.debugger.mask.ret == 1 {
|
||||
// Step_Out / Step_Over
|
||||
if m6502.PC >= m6502.debugger.SP {
|
||||
Pause()
|
||||
}
|
||||
}
|
||||
|
||||
case INV:
|
||||
Pause()
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
m6502_Run()
|
||||
|
@ -2044,11 +2071,11 @@ class ViewController: NSViewController {
|
|||
@IBAction func traceEnable(_ sender: NSButton) {
|
||||
switch sender.state {
|
||||
case .on:
|
||||
m6502.dbgLevel.trace = 1
|
||||
m6502.debugger.mask.trace = 1
|
||||
openLog()
|
||||
|
||||
default:
|
||||
m6502.dbgLevel.trace = 0
|
||||
m6502.debugger.mask.trace = 0
|
||||
closeLog()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,18 +429,54 @@ void m6502_Debug(void) {
|
|||
for ( clk_6502_per_frm_max = clk_6502_per_frm; m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() ) {
|
||||
switch (m6502.interrupt) {
|
||||
case HALT:
|
||||
return;
|
||||
if (m6502.debugger.mask.hlt) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case BREAK:
|
||||
if (m6502.debugger.mask.brk) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRQ:
|
||||
if (m6502.debugger.mask.irq) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMI:
|
||||
if (m6502.debugger.mask.nmi) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case INV:
|
||||
if (m6502.debugger.mask.inv) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case RET:
|
||||
// Step_Out & Step_Over: Return to caller
|
||||
if (m6502.debugger.mask.out) {
|
||||
if ( m6502.SP >= m6502.debugger.SP ) {
|
||||
cpuState = cpuState_halted;
|
||||
m6502.debugger.wMask = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HARDRESET:
|
||||
|
@ -452,8 +488,15 @@ void m6502_Debug(void) {
|
|||
break;
|
||||
|
||||
default:
|
||||
// Step_Out: If there was a POP (PLA, PLX, PLY, PLP), then we should update the monitoring stack pointer
|
||||
// (so we can return to the caller, not stopping at the POP)
|
||||
if ( m6502.SP > m6502.debugger.SP ) {
|
||||
m6502.debugger.SP = m6502.SP;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
m6502.interrupt = NO_INT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,16 +80,21 @@ typedef enum : uint8_t {
|
|||
} interrupt_t;
|
||||
|
||||
|
||||
typedef struct debugLevel_s {
|
||||
uint8_t trace : 1;
|
||||
uint8_t step : 1;
|
||||
uint8_t brk : 1;
|
||||
uint8_t rts : 1;
|
||||
uint8_t bra : 1;
|
||||
uint8_t bra_true : 1;
|
||||
uint8_t bra_false : 1;
|
||||
uint8_t compile : 1;
|
||||
} debugLevel_t;
|
||||
typedef struct debugMask_s {
|
||||
uint16_t trace : 1;
|
||||
uint16_t step : 1;
|
||||
uint16_t hlt : 1;
|
||||
uint16_t brk : 1;
|
||||
uint16_t irq : 1;
|
||||
uint16_t nmi : 1;
|
||||
uint16_t inv : 1;
|
||||
uint16_t out : 1;
|
||||
uint16_t ret : 1;
|
||||
uint16_t bra : 1;
|
||||
uint16_t bra_true : 1;
|
||||
uint16_t bra_false : 1;
|
||||
uint16_t compile : 1;
|
||||
} debugMask_t;
|
||||
|
||||
|
||||
typedef union flags_u {
|
||||
|
@ -108,6 +113,17 @@ typedef union flags_u {
|
|||
} flags_t;
|
||||
|
||||
|
||||
typedef struct debugger_s {
|
||||
_Bool on; // debugger is on
|
||||
uint8_t SP; // Stack Pointer for monitoring Return Stack Level -- eg. Step_Out & Step_Over
|
||||
|
||||
union {
|
||||
uint8_t wMask;
|
||||
debugMask_t mask; // 34: 0: No Debug, 1: Disassembly Only, 2: Run till BRK, 3: StepByStep
|
||||
};
|
||||
} debugger_t;
|
||||
|
||||
|
||||
//#pragma pack(1)
|
||||
typedef struct m6502_s {
|
||||
uint8_t A; // 0: Accumulator
|
||||
|
@ -137,18 +153,15 @@ typedef struct m6502_s {
|
|||
|
||||
// unsigned clk; // Clock Counter
|
||||
uint64_t clktime; // 14:
|
||||
uint64_t clklast; // 22:
|
||||
uint32_t clkfrm; // 30:
|
||||
uint64_t clklast; // 15:
|
||||
uint32_t clkfrm; // 16:
|
||||
|
||||
uint64_t clk_wrenable; // CPU clock when WRITE RAM is triggered
|
||||
|
||||
uint64_t lastIO; // Last time I/O accessed
|
||||
int ecoSpindown; // spindown counter for eco mode
|
||||
|
||||
union {
|
||||
uint8_t debug;
|
||||
debugLevel_t dbgLevel; // 34: 0: No Debug, 1: Disassembly Only, 2: Run till BRK, 3: StepByStep
|
||||
};
|
||||
debugger_t debugger;
|
||||
|
||||
union {
|
||||
unsigned int IF; // interrut flag
|
||||
|
|
|
@ -72,7 +72,8 @@ m6502_t m6502 = {
|
|||
0, // A
|
||||
0, // X
|
||||
0, // Y
|
||||
|
||||
|
||||
// flags_t
|
||||
0, // C
|
||||
0, // Z
|
||||
0, // I
|
||||
|
@ -87,15 +88,32 @@ m6502_t m6502 = {
|
|||
|
||||
0, // clktime
|
||||
0, // clklast
|
||||
0, // clkfrm
|
||||
|
||||
0, // clk_wrenable
|
||||
0, // lastIO
|
||||
0, // ecoSpindown
|
||||
|
||||
// debugger_t
|
||||
0, // on
|
||||
0, // SP
|
||||
0, // wMask
|
||||
|
||||
// debugMask_t
|
||||
0, // trace
|
||||
0, // step
|
||||
0, // hlt
|
||||
0, // brk
|
||||
0, // rts
|
||||
0, // irq
|
||||
0, // nmi
|
||||
0, // inv
|
||||
0, // out
|
||||
0, // ret
|
||||
0, // bra
|
||||
0, // bra_true
|
||||
0, // bra_false
|
||||
0, // compile
|
||||
|
||||
HALT, // IF
|
||||
|
||||
};
|
||||
|
|
|
@ -46,6 +46,7 @@ INLINE int BRK() {
|
|||
PUSH( getFlags().SR );
|
||||
m6502.I = 1;
|
||||
m6502.PC = memread16(IRQ_VECTOR);
|
||||
m6502.interrupt = BREAK;
|
||||
#endif
|
||||
return 7;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ INSTR int BRK(void) {
|
|||
PUSH( getFlags().SR );
|
||||
m6502.I = 1;
|
||||
m6502.PC = memread16(IRQ_VECTOR);
|
||||
m6502.interrupt = BREAK;
|
||||
#endif
|
||||
return 7;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue