diff --git a/README.md b/README.md index dd55ae4..2833f62 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,7 @@ to specify machine type and CPU type. The options are: - `-machine simple`: Use the **Simple** machine type by default. - `-machine beneater`: Use the **BenEater** machine type by default. - `-rom `: Use the specified file as the ROM image. + - `-brk`: Halt the simulator on a BRK instruction (default is to continue) ### 4.2 ROM images diff --git a/src/main/java/com/loomcom/symon/Main.java b/src/main/java/com/loomcom/symon/Main.java index 8d7dfc8..54478f0 100644 --- a/src/main/java/com/loomcom/symon/Main.java +++ b/src/main/java/com/loomcom/symon/Main.java @@ -53,6 +53,7 @@ public class Main { options.addOption(new Option("m", "machine", true, "Specify machine type.")); options.addOption(new Option("c", "cpu", true, "Specify CPU type.")); options.addOption(new Option("r", "rom", true, "Specify ROM file.")); + options.addOption(new Option("b", "brk", false, "Halt on BRK")); CommandLineParser parser = new DefaultParser(); @@ -60,6 +61,7 @@ public class Main { CommandLine line = parser.parse(options, args); InstructionTable.CpuBehavior cpuBehavior = null; String romFile = null; + boolean haltOnBreak = false; if (line.hasOption("machine")) { String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH); @@ -104,6 +106,10 @@ public class Main { romFile = line.getOptionValue("rom"); } + if (line.hasOption("brk")) { + haltOnBreak = true; + } + while (true) { if (machineClass == null) { Object[] possibilities = {"Symon", "Multicomp", "Simple", "BenEater"}; @@ -132,7 +138,7 @@ public class Main { cpuBehavior = InstructionTable.CpuBehavior.NMOS_6502; } - final Simulator simulator = new Simulator(machineClass, cpuBehavior, romFile); + final Simulator simulator = new Simulator(machineClass, cpuBehavior, romFile, haltOnBreak); SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/src/main/java/com/loomcom/symon/Preferences.java b/src/main/java/com/loomcom/symon/Preferences.java index fc86de8..bf7a88a 100644 --- a/src/main/java/com/loomcom/symon/Preferences.java +++ b/src/main/java/com/loomcom/symon/Preferences.java @@ -29,8 +29,6 @@ public interface Preferences { int DEFAULT_PROGRAM_LOAD_ADDRESS = 0x0300; - boolean DEFAULT_HALT_ON_BREAK = true; - JDialog getDialog(); int getProgramStartAddress(); diff --git a/src/main/java/com/loomcom/symon/Simulator.java b/src/main/java/com/loomcom/symon/Simulator.java index 589fce6..6bacb6d 100644 --- a/src/main/java/com/loomcom/symon/Simulator.java +++ b/src/main/java/com/loomcom/symon/Simulator.java @@ -126,6 +126,8 @@ public class Simulator { private MainCommand command = MainCommand.NONE; + private boolean haltOnBreak; + public enum MainCommand { NONE, SELECTMACHINE @@ -137,16 +139,17 @@ public class Simulator { private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"}; public Simulator(Class machineClass) throws Exception { - this(machineClass, InstructionTable.CpuBehavior.NMOS_6502, null); + this(machineClass, InstructionTable.CpuBehavior.NMOS_6502, null, false); } - public Simulator(Class machineClass, InstructionTable.CpuBehavior cpuType, String romFile) throws Exception { + public Simulator(Class machineClass, InstructionTable.CpuBehavior cpuType, + String romFile, boolean haltOnBreak) throws Exception { + this.haltOnBreak = haltOnBreak; this.breakpoints = new Breakpoints(this); this.machine = (Machine) machineClass.getConstructors()[0].newInstance(romFile); this.machine.getCpu().setBehavior(cpuType); - // Initialize final fields in the constructor. this.traceLog = new TraceLog(); this.memoryWindow = new MemoryWindow(machine.getBus()); @@ -176,7 +179,7 @@ public class Simulator { // File Chooser fileChooser = new JFileChooser(System.getProperty("user.dir")); - preferences = new PreferencesDialog(mainWindow, true); + preferences = new PreferencesDialog(mainWindow, true, haltOnBreak); // Panel for Console and Buttons JPanel consoleContainer = new JPanel(); diff --git a/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java b/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java index 1b188a4..15fb243 100644 --- a/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java +++ b/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java @@ -42,11 +42,11 @@ public class PreferencesDialog extends Observable implements Preferences { private JTextField programLoadAddressField; private int programLoadAddress = DEFAULT_PROGRAM_LOAD_ADDRESS; - private boolean haltOnBreak = DEFAULT_HALT_ON_BREAK; + private boolean haltOnBreak; - public PreferencesDialog(Frame parent, boolean modal) { + public PreferencesDialog(Frame parent, boolean modal, boolean haltOnBreak) { this.dialog = new JDialog(parent, modal); - + this.haltOnBreak = haltOnBreak; createUi(); updateUi(); }