Skip to content

Commit

Permalink
cleanup (moved some message processing code inside Inspector)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Dec 31, 2024
1 parent 5aba6ac commit 69fb41d
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 126 deletions.
173 changes: 94 additions & 79 deletions GUI/Dialogs/Inspector/Inspector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -685,104 +685,119 @@ class Inspector: DialogController {
}
}

func showMessage(_ msg: String) {

message.stringValue = msg
}
func processMessage(_ msg: Message) {

func scrollToPC() {
var pc: Int { return Int(msg.cpu.pc) }
var vector: Int { return Int(msg.cpu.vector) }

switch msg.type {

case .CONFIG:

fullRefresh()

case .POWER:

message.stringValue = ""
fullRefresh()

case .RUN:

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()

if cpuInfo != nil {
scrollToPC(pc: Int(cpuInfo.pc0))
}
}
case .PAUSE:

fullRefresh()

case .STEP:

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()
scrollToPC()

case .RESET:

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()

func scrollToPC(pc: Int) {
case .COPPERBP_UPDATED, .COPPERWP_UPDATED, .GUARD_UPDATED:

fullRefresh()

cpuInstrView.jumpTo(addr: pc)
}
case .BREAKPOINT_REACHED:

message.stringValue = "Breakpoint reached"
cpuInstrView.alertAddr = nil
scrollToPC(pc: pc)

case .WATCHPOINT_REACHED:

message.stringValue = "Watchpoint reached"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)

func powerOn() {

message.stringValue = ""
fullRefresh()
}
case .CATCHPOINT_REACHED:

let name = emu.cpu.vectorName(vector)!
message.stringValue = "Catched exception vector \(vector) (\(name))"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)

func powerOff() {

message.stringValue = ""
fullRefresh()
}
case .SWTRAP_REACHED:
message.stringValue = "Software trap reached"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)

func run() {

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()
}

func pause() {

fullRefresh()
}
case .COPPERBP_REACHED:

message.stringValue = "Copper breakpoint reached"

func step() {

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()
scrollToPC()
}

func reset() {

message.stringValue = ""
cpuInstrView.alertAddr = nil
fullRefresh()
}

func signalBreakPoint(pc: Int) {
case .COPPERWP_REACHED:

message.stringValue = "Breakpoint reached"
cpuInstrView.alertAddr = nil
scrollToPC(pc: pc)
}
message.stringValue = "Copper watchpoint reached"

case .BEAMTRAP_REACHED:

message.stringValue = "Beamtrap reached"

func signalWatchPoint(pc: Int) {

message.stringValue = "Watchpoint reached"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)
case .EOF_REACHED:

message.stringValue = "End of frame reached"

case .EOL_REACHED:

message.stringValue = "End of line reached"

case .MEM_LAYOUT:

fullRefresh()

default:
break
}
}

func signalCatchPoint(pc: Int, vector: Int) {

let name = emu.cpu.vectorName(vector)!
message.stringValue = "Catched exception vector \(vector) (\(name))"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)
}

func showMessage(_ msg: String) {

func signalSoftwareTrap(pc: Int) {

message.stringValue = "Software trap reached"
cpuInstrView.alertAddr = pc
scrollToPC(pc: pc)
message.stringValue = msg
}

func signalCopperBreakpoint() {

message.stringValue = "Copper breakpoint reached"
}
func scrollToPC() {

func signalCopperWatchpoint() {

message.stringValue = "Copper watchpoint reached"
if cpuInfo != nil {
scrollToPC(pc: Int(cpuInfo.pc0))
}
}

func signalBeamtrap() {
func scrollToPC(pc: Int) {

message.stringValue = "Beamtrap reached"
cpuInstrView.jumpTo(addr: pc)
}

@IBAction func refreshAction(_ sender: Any!) {
Expand Down
70 changes: 25 additions & 45 deletions GUI/MyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ extension MyController {

config = Configuration(with: self)
macAudio = MacAudio(with: self)
inspector = Inspector(with: self, nibName: "Inspector")
// inspector = Inspector(with: self, nibName: "Inspector")

ledSlot = [ ledSlot0, ledSlot1, letSlot2, ledSlot3 ]
cylSlot = [ cylSlot0, cylSlot1, cylSlot2, cylSlot3 ]
Expand Down Expand Up @@ -281,7 +281,7 @@ extension MyController {

if frames % 5 == 0 {

// Animate the inspector
// Animate the inspectors
if inspector?.window?.isVisible == true { inspector!.continuousRefresh() }
}

Expand Down Expand Up @@ -367,50 +367,57 @@ extension MyController {
var pan: Int { return Int(msg.drive.pan) }
var acceleration: Double { return Double(msg.value == 0 ? 1 : msg.value) }

func passToInspector() {

inspector?.processMessage(msg)
}

// Only proceed if the proxy object is still alive
if emu == nil { return }

switch msg.type {

case .CONFIG:
inspector?.fullRefresh()

monitor?.refresh()
configurator?.refresh()
refreshStatusBar()

passToInspector()

case .POWER:

if value != 0 {

renderer.canvas.open(delay: 1.5)
serialIn = ""
serialOut = ""
toolbar.updateToolbar()
inspector?.powerOn()

} else {

toolbar.updateToolbar()
inspector?.powerOff()
}
passToInspector()

case .RUN:

needsSaving = true
toolbar.updateToolbar()
inspector?.run()
refreshStatusBar()
passToInspector()

case .PAUSE:
toolbar.updateToolbar()
inspector?.pause()
refreshStatusBar()
passToInspector()

case .STEP:

needsSaving = true
inspector?.step()
passToInspector()

case .RESET:
inspector?.reset()
passToInspector()

case .RSH_CLOSE:
renderer.console.close(delay: 0.25)
Expand Down Expand Up @@ -463,51 +470,24 @@ extension MyController {
activityBar.maxValue = 140.0 * acceleration // TODO: REMOVE??
activityBar.warningValue = 77.0 * acceleration
activityBar.criticalValue = 105.0 * acceleration

case .COPPERBP_UPDATED, .COPPERWP_UPDATED:
inspector?.fullRefresh()

case .GUARD_UPDATED:
inspector?.fullRefresh()

case .BREAKPOINT_REACHED:
inspector?.signalBreakPoint(pc: pc)

case .WATCHPOINT_REACHED:
inspector?.signalWatchPoint(pc: pc)

case .CATCHPOINT_REACHED:
inspector?.signalCatchPoint(pc: pc, vector: vector)

case .SWTRAP_REACHED:
inspector?.signalSoftwareTrap(pc: pc)

case .COPPERBP_REACHED:
inspector?.signalCopperBreakpoint()

case .COPPERWP_REACHED:
inspector?.signalCopperWatchpoint()
case .COPPERBP_UPDATED, .COPPERWP_UPDATED, .GUARD_UPDATED,
.BREAKPOINT_REACHED, .WATCHPOINT_REACHED, .CATCHPOINT_REACHED,
.COPPERBP_REACHED, .COPPERWP_REACHED,
.SWTRAP_REACHED, .BEAMTRAP_REACHED, .EOF_REACHED, .EOL_REACHED:
passToInspector()

case .CPU_HALT:
refreshStatusBar()

case .BEAMTRAP_REACHED:
inspector?.signalBeamtrap()

case .EOF_REACHED:
inspector?.showMessage("End of frame reached")

case .EOL_REACHED:
inspector?.showMessage("End of line reached")


case .VIEWPORT:
renderer.canvas.updateTextureRect(hstrt: Int(msg.viewport.hstrt),
vstrt: Int(msg.viewport.vstrt),
hstop: Int(msg.viewport.hstop),
vstop: Int(msg.viewport.vstop))

case .MEM_LAYOUT:
inspector?.fullRefresh()
passToInspector()

case .DRIVE_CONNECT:

Expand Down
5 changes: 3 additions & 2 deletions GUI/XIB files/Inspector.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" id="858-OJ-L3r">
<rect key="frame" x="1" y="1" width="625" height="211"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView wantsLayer="YES" focusRingType="exterior" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="15" headerView="WPj-Ua-UtF" id="WbL-UR-zTx" customClass="MemTableView" customModule="vAmiga" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="625" height="186"/>
Expand Down Expand Up @@ -2365,7 +2365,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" id="jJo-Pz-BlY">
<rect key="frame" x="1" y="1" width="158" height="211"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView wantsLayer="YES" focusRingType="exterior" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="15" headerView="lgi-Sv-OLV" id="RzZ-Zx-t06" customClass="BankTableView" customModule="vAmiga" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="158" height="186"/>
Expand Down Expand Up @@ -8427,6 +8427,7 @@
</connections>
<point key="canvasLocation" x="143" y="252"/>
</window>
<viewController id="4re-LI-oh5"/>
</objects>
<resources>
<image name="NSAddTemplate" width="18" height="17"/>
Expand Down

0 comments on commit 69fb41d

Please sign in to comment.