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