1
0
mirror of https://github.com/sethm/symon.git synced 2024-06-14 17:29:38 +00:00

Make StatusPanel aware of the Machine

This commit is contained in:
Seth Morabito 2014-08-10 14:08:15 -07:00
parent bb82db6672
commit eac387e472
2 changed files with 16 additions and 11 deletions

View File

@ -143,7 +143,7 @@ public class Simulator {
// UI components used for I/O.
this.console = new com.loomcom.symon.ui.Console(80, 25, DEFAULT_FONT);
this.statusPane = new StatusPanel();
this.statusPane = new StatusPanel(machine);
console.setBorderWidth(CONSOLE_BORDER_WIDTH);
@ -295,7 +295,7 @@ public class Simulator {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Now update the state
statusPane.updateState(machine.getCpu());
statusPane.updateState();
memoryWindow.updateState();
}
});
@ -317,7 +317,7 @@ public class Simulator {
if (traceLog.isVisible()) {
traceLog.refresh();
}
statusPane.updateState(machine.getCpu());
statusPane.updateState();
memoryWindow.updateState();
}
});
@ -364,7 +364,7 @@ public class Simulator {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Now update the state
statusPane.updateState(machine.getCpu());
statusPane.updateState();
memoryWindow.updateState();
}
});
@ -396,7 +396,7 @@ public class Simulator {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Now update the state
statusPane.updateState(machine.getCpu());
statusPane.updateState();
memoryWindow.updateState();
}
});
@ -443,7 +443,7 @@ public class Simulator {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
statusPane.updateState(machine.getCpu());
statusPane.updateState();
memoryWindow.updateState();
runStopButton.setText("Run");
stepButton.setEnabled(true);

View File

@ -24,11 +24,14 @@
package com.loomcom.symon.ui;
import com.loomcom.symon.Cpu;
import com.loomcom.symon.machines.Machine;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* UI component that displays the current state of the simulated CPU.
@ -73,14 +76,17 @@ public class StatusPanel extends JPanel {
private JLabel xLabel;
private JLabel yLabel;
private Machine machine;
private static final int EMPTY_BORDER = 10;
private static final Border LABEL_BORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0);
private static final Font LABEL_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 12);
private static final Dimension LARGE_TEXT_FIELD_SIZE = new Dimension(134, 22);
private static final Dimension SMALL_TEXT_FIELD_SIZE = new Dimension(65, 22);
public StatusPanel() {
public StatusPanel(Machine machine) {
super();
this.machine = machine;
createUi();
}
@ -220,14 +226,13 @@ public class StatusPanel extends JPanel {
/**
* Update the display based on the current state of the CPU.
*
* @param cpu The simulated 6502 CPU.
*/
public void updateState(Cpu cpu) {
public void updateState() {
Cpu cpu = machine.getCpu();
Cpu.CpuState cpuState = cpu.getCpuState();
// Update the Processor Status Flag display
int status = cpu.getCpuState().getStatusFlag();
int status = cpuState.getStatusFlag();
carryFlagLabel.setIcon(iconForFlag(status, 0));
zeroFlagLabel.setIcon(iconForFlag(status, 1));