Skip to content

Commit

Permalink
Work on track icon dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 1, 2025
1 parent ed233dc commit e69c08f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 22 deletions.
19 changes: 19 additions & 0 deletions Emulator/Misc/RetroShell/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Console::lastLineIsEmpty()
void
Console::printState()
{
/*
std::stringstream ss;
ss << "\n";
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Emulator/Misc/RetroShell/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Emulator/VAmiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,5 +1967,11 @@ AmigaAPI::setAutoInspectionMask(u64 mask)
amiga->setAutoInspectionMask(mask);
}

string
AmigaAPI::stateString()
{
return amiga->retroShell.debugger.stateString();
}


}
3 changes: 3 additions & 0 deletions Emulator/VAmiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ struct AmigaAPI : public API {
*/
void setAutoInspectionMask(u64 mask);

// Experimental
string stateString();

/// @}
};

Expand Down
32 changes: 16 additions & 16 deletions GUI/MyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ extension MyController {
serialOut = ""
}

setInfo("")
clearInfo()
passToInspector()

case .RUN:

needsSaving = true
toolbar.updateToolbar()
refreshStatusBar()
setInfo("")
clearInfo()
passToInspector()

case .PAUSE:
Expand All @@ -418,11 +418,11 @@ extension MyController {
case .STEP:

needsSaving = true
setInfo("")
clearInfo()
passToInspector()

case .RESET:
setInfo("")
clearInfo()
passToInspector()

case .RSH_CLOSE:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -657,7 +657,7 @@ extension MyController {
}
}

func setInfo(_ text: String, _ text2: String = "") {
func setInfo(_ text: String?, _ text2: String? = nil) {

info = text
info2 = text2
Expand All @@ -666,7 +666,7 @@ extension MyController {

func clearInfo() {

info = ""
info2 = ""
info = nil
info2 = nil
}
}
21 changes: 15 additions & 6 deletions GUI/MyControllerStatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}
}
Expand Down
2 changes: 2 additions & 0 deletions Proxy/EmulatorProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@
- (MediaFileProxy *) takeSnapshot;
- (void) loadSnapshot:(MediaFileProxy *)proxy exception:(ExceptionWrapper *)ex;

@property (readonly) NSString *stateString;

@end


Expand Down
5 changes: 5 additions & 0 deletions Proxy/EmulatorProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit e69c08f

Please sign in to comment.