mirror of
https://github.com/sethm/symon.git
synced 2025-08-09 11:25:13 +00:00
Make StatusPanel aware of the Machine
This commit is contained in:
@@ -143,7 +143,7 @@ public class Simulator {
|
|||||||
|
|
||||||
// UI components used for I/O.
|
// UI components used for I/O.
|
||||||
this.console = new com.loomcom.symon.ui.Console(80, 25, DEFAULT_FONT);
|
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);
|
console.setBorderWidth(CONSOLE_BORDER_WIDTH);
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ public class Simulator {
|
|||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Now update the state
|
// Now update the state
|
||||||
statusPane.updateState(machine.getCpu());
|
statusPane.updateState();
|
||||||
memoryWindow.updateState();
|
memoryWindow.updateState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -317,7 +317,7 @@ public class Simulator {
|
|||||||
if (traceLog.isVisible()) {
|
if (traceLog.isVisible()) {
|
||||||
traceLog.refresh();
|
traceLog.refresh();
|
||||||
}
|
}
|
||||||
statusPane.updateState(machine.getCpu());
|
statusPane.updateState();
|
||||||
memoryWindow.updateState();
|
memoryWindow.updateState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -364,7 +364,7 @@ public class Simulator {
|
|||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Now update the state
|
// Now update the state
|
||||||
statusPane.updateState(machine.getCpu());
|
statusPane.updateState();
|
||||||
memoryWindow.updateState();
|
memoryWindow.updateState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -396,7 +396,7 @@ public class Simulator {
|
|||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Now update the state
|
// Now update the state
|
||||||
statusPane.updateState(machine.getCpu());
|
statusPane.updateState();
|
||||||
memoryWindow.updateState();
|
memoryWindow.updateState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -443,7 +443,7 @@ public class Simulator {
|
|||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
statusPane.updateState(machine.getCpu());
|
statusPane.updateState();
|
||||||
memoryWindow.updateState();
|
memoryWindow.updateState();
|
||||||
runStopButton.setText("Run");
|
runStopButton.setText("Run");
|
||||||
stepButton.setEnabled(true);
|
stepButton.setEnabled(true);
|
||||||
|
@@ -24,11 +24,14 @@
|
|||||||
package com.loomcom.symon.ui;
|
package com.loomcom.symon.ui;
|
||||||
|
|
||||||
import com.loomcom.symon.Cpu;
|
import com.loomcom.symon.Cpu;
|
||||||
|
import com.loomcom.symon.machines.Machine;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.EtchedBorder;
|
import javax.swing.border.EtchedBorder;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI component that displays the current state of the simulated CPU.
|
* 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 xLabel;
|
||||||
private JLabel yLabel;
|
private JLabel yLabel;
|
||||||
|
|
||||||
|
private Machine machine;
|
||||||
|
|
||||||
private static final int EMPTY_BORDER = 10;
|
private static final int EMPTY_BORDER = 10;
|
||||||
private static final Border LABEL_BORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0);
|
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 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 LARGE_TEXT_FIELD_SIZE = new Dimension(134, 22);
|
||||||
private static final Dimension SMALL_TEXT_FIELD_SIZE = new Dimension(65, 22);
|
private static final Dimension SMALL_TEXT_FIELD_SIZE = new Dimension(65, 22);
|
||||||
|
|
||||||
public StatusPanel() {
|
public StatusPanel(Machine machine) {
|
||||||
super();
|
super();
|
||||||
|
this.machine = machine;
|
||||||
createUi();
|
createUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,14 +226,13 @@ public class StatusPanel extends JPanel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the display based on the current state of the CPU.
|
* 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();
|
Cpu.CpuState cpuState = cpu.getCpuState();
|
||||||
|
|
||||||
// Update the Processor Status Flag display
|
// Update the Processor Status Flag display
|
||||||
int status = cpu.getCpuState().getStatusFlag();
|
int status = cpuState.getStatusFlag();
|
||||||
|
|
||||||
carryFlagLabel.setIcon(iconForFlag(status, 0));
|
carryFlagLabel.setIcon(iconForFlag(status, 0));
|
||||||
zeroFlagLabel.setIcon(iconForFlag(status, 1));
|
zeroFlagLabel.setIcon(iconForFlag(status, 1));
|
||||||
|
Reference in New Issue
Block a user