From e69c08fcd928a6bf3d4c527031afc4dda7046f2f Mon Sep 17 00:00:00 2001 From: Dirk Hoffmann Date: Wed, 1 Jan 2025 11:34:59 +0100 Subject: [PATCH] Work on track icon dialog --- Emulator/Misc/RetroShell/Console.cpp | 19 +++++++++++++++++ Emulator/Misc/RetroShell/Console.h | 5 +++++ Emulator/VAmiga.cpp | 6 ++++++ Emulator/VAmiga.h | 3 +++ GUI/MyController.swift | 32 ++++++++++++++-------------- GUI/MyControllerStatusBar.swift | 21 ++++++++++++------ Proxy/EmulatorProxy.h | 2 ++ Proxy/EmulatorProxy.mm | 5 +++++ 8 files changed, 71 insertions(+), 22 deletions(-) diff --git a/Emulator/Misc/RetroShell/Console.cpp b/Emulator/Misc/RetroShell/Console.cpp index 44525ec09..991db6fd5 100644 --- a/Emulator/Misc/RetroShell/Console.cpp +++ b/Emulator/Misc/RetroShell/Console.cpp @@ -173,6 +173,7 @@ Console::lastLineIsEmpty() void Console::printState() { + /* std::stringstream ss; ss << "\n"; @@ -184,6 +185,24 @@ Console::printState() ss << "\n"; *this << ss; + */ + *this << stateString(); +} + +string +Console::stateString() const +{ + std::stringstream ss; + + ss << "\n"; + cpu.dumpLogBuffer(ss, 8); + ss << "\n"; + amiga.dump(Category::Current, ss); + ss << "\n"; + cpu.disassembleRange(ss, cpu.getPC0(), 8); + ss << "\n"; + + return ss.str(); } void diff --git a/Emulator/Misc/RetroShell/Console.h b/Emulator/Misc/RetroShell/Console.h index 5e3f9601c..ab04f55e4 100644 --- a/Emulator/Misc/RetroShell/Console.h +++ b/Emulator/Misc/RetroShell/Console.h @@ -196,6 +196,11 @@ class Console : public SubComponent { // Prints a state summary (used by the debug shell) void printState(); +public: + + // Experimental + string stateString() const; + // // Managing user input diff --git a/Emulator/VAmiga.cpp b/Emulator/VAmiga.cpp index 6f7b52034..98da63ffb 100644 --- a/Emulator/VAmiga.cpp +++ b/Emulator/VAmiga.cpp @@ -1967,5 +1967,11 @@ AmigaAPI::setAutoInspectionMask(u64 mask) amiga->setAutoInspectionMask(mask); } +string +AmigaAPI::stateString() +{ + return amiga->retroShell.debugger.stateString(); +} + } diff --git a/Emulator/VAmiga.h b/Emulator/VAmiga.h index 5c5b8b4eb..bc66e31a0 100644 --- a/Emulator/VAmiga.h +++ b/Emulator/VAmiga.h @@ -120,6 +120,9 @@ struct AmigaAPI : public API { */ void setAutoInspectionMask(u64 mask); + // Experimental + string stateString(); + /// @} }; diff --git a/GUI/MyController.swift b/GUI/MyController.swift index c6855aa77..7eaed8f82 100644 --- a/GUI/MyController.swift +++ b/GUI/MyController.swift @@ -399,7 +399,7 @@ extension MyController { serialOut = "" } - setInfo("") + clearInfo() passToInspector() case .RUN: @@ -407,7 +407,7 @@ extension MyController { needsSaving = true toolbar.updateToolbar() refreshStatusBar() - setInfo("") + clearInfo() passToInspector() case .PAUSE: @@ -418,11 +418,11 @@ extension MyController { case .STEP: needsSaving = true - setInfo("") + clearInfo() passToInspector() case .RESET: - setInfo("") + clearInfo() passToInspector() case .RSH_CLOSE: @@ -480,32 +480,32 @@ extension MyController { passToInspector() case .BREAKPOINT_REACHED: - setInfo("Breakpoint reached", "Breakpoint hit at address \(pcHex).") + setInfo("Breakpoint reached", "Interrupted at address \(pcHex)") case .WATCHPOINT_REACHED: - setInfo("Watchpoint reached", "Watchpoint hit at address \(pcHex).") + setInfo("Watchpoint reached", "Interrupted at address \(pcHex)") case .CATCHPOINT_REACHED: let name = emu.cpu.vectorName(vector)! - setInfo("Exception vector catched", "Vector \(vector) executed (\(name)).") + setInfo("Exception vector catched", "Caught vector \(vector) (\(name))") case .COPPERBP_REACHED: - setInfo("Copper breakpoint reached", "Breakpoint hit at address \(pcHex).") + setInfo("Copper breakpoint reached", "Interrupted at address \(pcHex)") case .COPPERWP_REACHED: - setInfo("Copper watchpoint reached", "Watchpoint hit at address \(pcHex).") + setInfo("Copper watchpoint reached", "Interrupted at address \(pcHex)") case .SWTRAP_REACHED: - setInfo("Software trap reached at address \(pc)", "Trapped CPU at address \(pcHex).") + setInfo("Software trap reached at address \(pc)", "Interrupted at address \(pcHex)") case .BEAMTRAP_REACHED: - setInfo("Beamtrap reached", "Trapped beam at position \(pos).") + setInfo("Beamtrap reached", "Interrupted at location \(pos)") case .EOF_REACHED: - setInfo("End of frame reached", "Trapped beam at position \(pos).") + setInfo("End of frame reached", "Interrupted at location \(pos)") case .EOL_REACHED: - setInfo("End of line reached", "Trapped beam at position \(pos).") + setInfo("End of line reached", "Interrupted at location \(pos)") case .CPU_HALT: refreshStatusBar() @@ -657,7 +657,7 @@ extension MyController { } } - func setInfo(_ text: String, _ text2: String = "") { + func setInfo(_ text: String?, _ text2: String? = nil) { info = text info2 = text2 @@ -666,7 +666,7 @@ extension MyController { func clearInfo() { - info = "" - info2 = "" + info = nil + info2 = nil } } diff --git a/GUI/MyControllerStatusBar.swift b/GUI/MyControllerStatusBar.swift index a40417b45..95059790f 100644 --- a/GUI/MyControllerStatusBar.swift +++ b/GUI/MyControllerStatusBar.swift @@ -64,7 +64,7 @@ extension MyController { // Track icon trackIcon.toolTip = info - trackIcon.contentTintColor = info == "" ? nil : NSColor.warning + trackIcon.contentTintColor = info == nil ? nil : NSColor.warning if let image = NSImage(systemSymbolName: "waveform.badge.magnifyingglass", accessibilityDescription: nil) { trackIcon.image = image } @@ -321,18 +321,27 @@ extension MyController { @IBAction func infoAction(_ sender: Any!) { if let info = info { - - let alert = NSAlert() + + // Get some auxiliary debug information from the emulator + let attributes = [NSAttributedString.Key.font: NSFont.monospaced(ofSize: 11, weight: .semibold)] + let text = NSAttributedString(string: emu.amiga.stateString!, attributes: attributes) + let size = CGRect(x: 0, y: 0, width: text.size().width + 16, height: text.size().height) + + // Put the information into an accessory view + let accessory = NSTextView(frame: size) + accessory.textStorage?.setAttributedString(text) + accessory.drawsBackground = false - let amigaInfo = emu.amiga.info - let cpuInfo = emu.cpu.info - + // Create an alert + let alert = NSAlert() alert.messageText = info alert.informativeText = info2 ?? "" alert.alertStyle = .informational alert.icon = NSImage(systemSymbolName: "waveform.badge.magnifyingglass", accessibilityDescription: nil) alert.addButton(withTitle: "OK") + alert.accessoryView = accessory + alert.runModal() } } diff --git a/Proxy/EmulatorProxy.h b/Proxy/EmulatorProxy.h index 773b5b906..247a08ca5 100644 --- a/Proxy/EmulatorProxy.h +++ b/Proxy/EmulatorProxy.h @@ -376,6 +376,8 @@ - (MediaFileProxy *) takeSnapshot; - (void) loadSnapshot:(MediaFileProxy *)proxy exception:(ExceptionWrapper *)ex; +@property (readonly) NSString *stateString; + @end diff --git a/Proxy/EmulatorProxy.mm b/Proxy/EmulatorProxy.mm index 312d37dd5..ddee9c80f 100644 --- a/Proxy/EmulatorProxy.mm +++ b/Proxy/EmulatorProxy.mm @@ -2148,6 +2148,11 @@ - (void)loadSnapshot:(MediaFileProxy *)proxy exception:(ExceptionWrapper *)ex catch (Error &error) { [ex save:error]; } } +- (NSString *)stateString +{ + return @([self amiga]->stateString().c_str()); +} + @end