Skip to content

Commit

Permalink
Track icon in status bar is now clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 1, 2025
1 parent 511fd83 commit ed233dc
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 66 deletions.
34 changes: 2 additions & 32 deletions GUI/Dialogs/Inspector/Inspector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Inspector: DialogController {

// Commons
@IBOutlet weak var panel: NSTabView!
@IBOutlet weak var message: NSTextField!

// CPU panel
@IBOutlet weak var cpuInstrView: InstrTableView!
Expand Down Expand Up @@ -629,7 +628,6 @@ class Inspector: DialogController {
override func awakeFromNib() {

super.awakeFromNib()
message.stringValue = ""

// Hide the panel selector
panel.tabPosition = .none
Expand Down Expand Up @@ -708,12 +706,10 @@ class Inspector: DialogController {

case .POWER:

message.stringValue = ""
fullRefresh()

case .RUN:

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

Expand All @@ -723,14 +719,12 @@ class Inspector: DialogController {

case .STEP:

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

case .RESET:

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

Expand All @@ -740,50 +734,26 @@ class Inspector: DialogController {

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)

case .CATCHPOINT_REACHED:

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

case .SWTRAP_REACHED:

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

case .COPPERBP_REACHED:

message.stringValue = "Copper breakpoint reached"

case .COPPERWP_REACHED:

message.stringValue = "Copper watchpoint reached"

case .BEAMTRAP_REACHED:

message.stringValue = "Beamtrap reached"

case .EOF_REACHED:

message.stringValue = "End of frame reached"

case .EOL_REACHED:

message.stringValue = "End of line reached"

case .MEM_LAYOUT:
case .COPPERBP_REACHED, .COPPERWP_REACHED, .BEAMTRAP_REACHED,
.EOF_REACHED, .EOL_REACHED, .MEM_LAYOUT:

fullRefresh()

Expand Down
65 changes: 54 additions & 11 deletions GUI/MyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class MyController: NSWindowController, MessageReceiver {
// Indicates if a status bar is shown
var statusBar = true

// Information message shown in the status bar
var info: String? = nil
var info2: String? = nil

// Pictograms for being used in NSMenuItems
var smallDisk = NSImage(named: "diskTemplate")!.resize(width: 16.0, height: 16.0)
var smallHdr = NSImage(named: "hdrTemplate")!.resize(width: 16.0, height: 16.0)
Expand Down Expand Up @@ -363,11 +367,13 @@ extension MyController {
var nr: Int { return Int(msg.drive.nr) }
var cyl: Int { return Int(msg.drive.value) }
var pc: Int { return Int(msg.cpu.pc) }
var pcHex: String { return String(format: "%X", pc) }
var vector: Int { return Int(msg.cpu.vector) }
var volume: Int { return Int(msg.drive.volume) }
var pan: Int { return Int(msg.drive.pan) }
var acceleration: Double { return Double(msg.value == 0 ? 1 : msg.value) }

var pos: String { return "(\(emu.amiga.info.vpos),\(emu.amiga.info.hpos))" }

func passToInspector() {
for inspector in inspectors { inspector.processMessage(msg) }
}
Expand All @@ -391,19 +397,17 @@ extension MyController {
renderer.canvas.open(delay: 1.5)
serialIn = ""
serialOut = ""
toolbar.updateToolbar()

} else {

toolbar.updateToolbar()
}

setInfo("")
passToInspector()

case .RUN:

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

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

needsSaving = true
setInfo("")
passToInspector()

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

case .RSH_CLOSE:
Expand Down Expand Up @@ -459,7 +465,6 @@ extension MyController {
powerLED.image = NSImage(named: "ledGrey")

case .DMA_DEBUG:

msg.value != 0 ? renderer.zoomTextureOut() : renderer.zoomTextureIn()

case .VIDEO_FORMAT:
Expand All @@ -471,11 +476,36 @@ extension MyController {
activityBar.warningValue = 77.0 * acceleration
activityBar.criticalValue = 105.0 * acceleration

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:
case .COPPERBP_UPDATED, .COPPERWP_UPDATED, .GUARD_UPDATED:
passToInspector()

case .BREAKPOINT_REACHED:
setInfo("Breakpoint reached", "Breakpoint hit at address \(pcHex).")

case .WATCHPOINT_REACHED:
setInfo("Watchpoint reached", "Watchpoint hit at address \(pcHex).")

case .CATCHPOINT_REACHED:
let name = emu.cpu.vectorName(vector)!
setInfo("Exception vector catched", "Vector \(vector) executed (\(name)).")

case .COPPERBP_REACHED:
setInfo("Copper breakpoint reached", "Breakpoint hit at address \(pcHex).")

case .COPPERWP_REACHED:
setInfo("Copper watchpoint reached", "Watchpoint hit at address \(pcHex).")

case .SWTRAP_REACHED:
setInfo("Software trap reached at address \(pc)", "Trapped CPU at address \(pcHex).")

case .BEAMTRAP_REACHED:
setInfo("Beamtrap reached", "Trapped beam at position \(pos).")

case .EOF_REACHED:
setInfo("End of frame reached", "Trapped beam at position \(pos).")

case .EOL_REACHED:
setInfo("End of line reached", "Trapped beam at position \(pos).")

case .CPU_HALT:
refreshStatusBar()
Expand Down Expand Up @@ -626,4 +656,17 @@ extension MyController {
fatalError()
}
}

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

info = text
info2 = text2
refreshStatusBar()
}

func clearInfo() {

info = ""
info2 = ""
}
}
26 changes: 26 additions & 0 deletions GUI/MyControllerStatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ extension MyController {
cmdLeftIcon.image = cmdKeyIcon(mapLeft)
cmdRightIcon.image = cmdKeyIcon(mapRight)

// Track icon
trackIcon.toolTip = info
trackIcon.contentTintColor = info == "" ? nil : NSColor.warning
if let image = NSImage(systemSymbolName: "waveform.badge.magnifyingglass", accessibilityDescription: nil) {
trackIcon.image = image
}

// Remote server icon
serverIcon.image = emu.remoteManager.icon

Expand Down Expand Up @@ -311,6 +318,25 @@ extension MyController {
emu?.set(.AMIGA_SPEED_BOOST, value: value)
}

@IBAction func infoAction(_ sender: Any!) {

if let info = info {

let alert = NSAlert()

let amigaInfo = emu.amiga.info
let cpuInfo = emu.cpu.info

alert.messageText = info
alert.informativeText = info2 ?? ""
alert.alertStyle = .informational
alert.icon = NSImage(systemSymbolName: "waveform.badge.magnifyingglass",
accessibilityDescription: nil)
alert.addButton(withTitle: "OK")
alert.runModal()
}
}

@IBAction func speedResetAction(_ sender: Any!) {

emu?.set(.AMIGA_SPEED_BOOST, value: 100)
Expand Down
Loading

0 comments on commit ed233dc

Please sign in to comment.