From 69fb41d6ba83f3c7a80efebb5e8fe95fab596961 Mon Sep 17 00:00:00 2001 From: Dirk Hoffmann Date: Tue, 31 Dec 2024 09:27:34 +0100 Subject: [PATCH] cleanup (moved some message processing code inside Inspector) --- GUI/Dialogs/Inspector/Inspector.swift | 173 ++++++++++++++------------ GUI/MyController.swift | 70 ++++------- GUI/XIB files/Inspector.xib | 5 +- 3 files changed, 122 insertions(+), 126 deletions(-) diff --git a/GUI/Dialogs/Inspector/Inspector.swift b/GUI/Dialogs/Inspector/Inspector.swift index 389aa00b5..79a8f0a4b 100644 --- a/GUI/Dialogs/Inspector/Inspector.swift +++ b/GUI/Dialogs/Inspector/Inspector.swift @@ -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!) { diff --git a/GUI/MyController.swift b/GUI/MyController.swift index 1fbcaaa04..ace593c0d 100644 --- a/GUI/MyController.swift +++ b/GUI/MyController.swift @@ -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 ] @@ -281,7 +281,7 @@ extension MyController { if frames % 5 == 0 { - // Animate the inspector + // Animate the inspectors if inspector?.window?.isVisible == true { inspector!.continuousRefresh() } } @@ -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) @@ -463,43 +470,16 @@ 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), @@ -507,7 +487,7 @@ extension MyController { vstop: Int(msg.viewport.vstop)) case .MEM_LAYOUT: - inspector?.fullRefresh() + passToInspector() case .DRIVE_CONNECT: diff --git a/GUI/XIB files/Inspector.xib b/GUI/XIB files/Inspector.xib index 70db8eec7..ab18dfe49 100644 --- a/GUI/XIB files/Inspector.xib +++ b/GUI/XIB files/Inspector.xib @@ -1901,7 +1901,7 @@ - + @@ -2365,7 +2365,7 @@ - + @@ -8427,6 +8427,7 @@ +