From a4a110dcef8d74797f0ea4818256640e6d998e98 Mon Sep 17 00:00:00 2001 From: Seth Morabito Date: Tue, 29 Dec 2015 14:40:42 -0800 Subject: [PATCH] Bugfixes, change logger, update copyright - IR field in status panel now correctly displays the next instruction to be executed, instead of the instruction that was just executed. - Switched from built-in Java util logger to Logback - Updated all copyright strings to 2016 --- pom.xml | 5 + src/main/java/com/loomcom/symon/Bus.java | 2 +- src/main/java/com/loomcom/symon/Cpu.java | 67 ++++++++-- .../com/loomcom/symon/InstructionTable.java | 2 +- src/main/java/com/loomcom/symon/Main.java | 2 +- .../java/com/loomcom/symon/MemoryRange.java | 2 +- .../java/com/loomcom/symon/Preferences.java | 2 +- .../java/com/loomcom/symon/Simulator.java | 121 ++++++++---------- .../java/com/loomcom/symon/devices/Acia.java | 2 +- .../com/loomcom/symon/devices/Acia6551.java | 2 +- .../com/loomcom/symon/devices/Acia6850.java | 2 +- .../java/com/loomcom/symon/devices/Crtc.java | 2 +- .../com/loomcom/symon/devices/Device.java | 2 +- .../symon/devices/DeviceChangeListener.java | 2 +- .../com/loomcom/symon/devices/Memory.java | 2 +- .../java/com/loomcom/symon/devices/Pia.java | 2 +- .../loomcom/symon/devices/SdController.java | 2 +- .../com/loomcom/symon/devices/Via6522.java | 2 +- .../exceptions/FifoUnderrunException.java | 2 +- .../exceptions/MemoryAccessException.java | 2 +- .../exceptions/MemoryRangeException.java | 2 +- .../symon/exceptions/SymonException.java | 2 +- .../com/loomcom/symon/machines/Machine.java | 2 +- .../symon/machines/MulticompMachine.java | 2 +- .../loomcom/symon/machines/SimpleMachine.java | 2 +- .../loomcom/symon/machines/SymonMachine.java | 14 +- .../java/com/loomcom/symon/ui/Console.java | 2 +- .../com/loomcom/symon/ui/MemoryWindow.java | 2 +- .../loomcom/symon/ui/PreferencesDialog.java | 2 +- .../com/loomcom/symon/ui/StatusPanel.java | 11 +- .../java/com/loomcom/symon/ui/TraceLog.java | 6 +- .../com/loomcom/symon/ui/VideoWindow.java | 2 +- .../loomcom/symon/util/FifoRingBuffer.java | 2 +- .../java/com/loomcom/symon/util/HexUtil.java | 2 +- 34 files changed, 161 insertions(+), 119 deletions(-) diff --git a/pom.xml b/pom.xml index 1056dae..b042cf1 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,11 @@ + + ch.qos.logback + logback-classic + 1.1.3 + junit junit diff --git a/src/main/java/com/loomcom/symon/Bus.java b/src/main/java/com/loomcom/symon/Bus.java index f4d4da0..d2c6fbf 100644 --- a/src/main/java/com/loomcom/symon/Bus.java +++ b/src/main/java/com/loomcom/symon/Bus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/Cpu.java b/src/main/java/com/loomcom/symon/Cpu.java index 54e64de..b455221 100644 --- a/src/main/java/com/loomcom/symon/Cpu.java +++ b/src/main/java/com/loomcom/symon/Cpu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,8 +25,9 @@ package com.loomcom.symon; import com.loomcom.symon.exceptions.MemoryAccessException; import com.loomcom.symon.util.HexUtil; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This class provides a simulation of the MOS 6502 CPU's state machine. @@ -35,6 +36,8 @@ import java.util.logging.Logger; */ public class Cpu implements InstructionTable { + private final static Logger logger = LoggerFactory.getLogger(Cpu.class.getName()); + /* Process status register mnemonics */ public static final int P_CARRY = 0x01; public static final int P_ZERO = 0x02; @@ -146,6 +149,8 @@ public class Cpu implements InstructionTable { state.a = 0; state.x = 0; state.y = 0; + + peekAhead(); } public void step(int num) throws MemoryAccessException { @@ -732,6 +737,18 @@ public class Cpu implements InstructionTable { } delayLoop(state.ir); + + // Peek ahead to the next insturction and arguments + peekAhead(); + } + + private void peekAhead() throws MemoryAccessException { + state.nextIr = bus.read(state.pc); + int nextInstSize = Cpu.instructionSizes[state.nextIr]; + for (int i = 1; i < nextInstSize; i++) { + int nextRead = (state.pc + i) % bus.endAddress(); + state.nextArgs[i-1] = bus.read(nextRead); + } } private void handleIrq(int returnPc) throws MemoryAccessException { @@ -1117,6 +1134,14 @@ public class Cpu implements InstructionTable { public void setProgramCounter(int addr) { state.pc = addr; + + // As a side-effect of setting the program counter, + // we want to peek ahead at the next state. + try { + peekAhead(); + } catch (MemoryAccessException ex) { + logger.error("Could not peek ahead at next instruction state."); + } } public int getStackPointer() { @@ -1359,15 +1384,20 @@ public class Cpu implements InstructionTable { */ public int pc; /** - * Instruction Register + * Last Loaded Instruction Register */ public int ir; - public int lastPc; + /** + * Peek-Ahead to next IR + */ + public int nextIr; public int[] args = new int[2]; + public int[] nextArgs = new int[2]; public int instSize; public boolean opTrap; public boolean irqAsserted; public boolean nmiAsserted; + public int lastPc; /* Status Flag Register bits */ public boolean carryFlag; @@ -1387,7 +1417,7 @@ public class Cpu implements InstructionTable { /** * Snapshot a copy of the CpuState. * - * (This is a copy constructor rather than an implementation of Clonable + * (This is a copy constructor rather than an implementation of Cloneable * based on Josh Bloch's recommendation) * * @param s The CpuState to copy. @@ -1399,9 +1429,12 @@ public class Cpu implements InstructionTable { this.sp = s.sp; this.pc = s.pc; this.ir = s.ir; + this.nextIr = s.nextIr; this.lastPc = s.lastPc; this.args[0] = s.args[0]; this.args[1] = s.args[1]; + this.nextArgs[0] = s.nextArgs[0]; + this.nextArgs[1] = s.nextArgs[1]; this.instSize = s.instSize; this.opTrap = s.opTrap; this.irqAsserted = s.irqAsserted; @@ -1421,7 +1454,7 @@ public class Cpu implements InstructionTable { * @return a string formatted for the trace log. */ public String toTraceEvent() { - String opcode = disassembleOp(); + String opcode = disassembleLastOp(); StringBuilder sb = new StringBuilder(getInstructionByteStatus()); sb.append(" "); sb.append(String.format("%-14s", opcode)); @@ -1483,13 +1516,13 @@ public class Cpu implements InstructionTable { } } - /** - * Given an opcode and its operands, return a formatted name. + * Return a formatted string representing the last instruction and + * operands that were executed. * * @return A string representing the mnemonic and operands of the instruction */ - public String disassembleOp() { + private String disassembleOp(int ir, int[] args) { String mnemonic = opcodeNames[ir]; if (mnemonic == null) { @@ -1535,6 +1568,20 @@ public class Cpu implements InstructionTable { return sb.toString(); } + public String disassembleLastOp() { + return disassembleOp(ir, args); + } + + /** + * Return a formatted string representing the next instruction and + * operands to be executed. + * + * @return A string representing the mnemonic and operands of the instruction + */ + public String disassembleNextOp() { + return disassembleOp(nextIr, nextArgs); + } + /** * Given two bytes, return an address. */ diff --git a/src/main/java/com/loomcom/symon/InstructionTable.java b/src/main/java/com/loomcom/symon/InstructionTable.java index fb98422..a453453 100644 --- a/src/main/java/com/loomcom/symon/InstructionTable.java +++ b/src/main/java/com/loomcom/symon/InstructionTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/Main.java b/src/main/java/com/loomcom/symon/Main.java index 6376e15..01f48b2 100644 --- a/src/main/java/com/loomcom/symon/Main.java +++ b/src/main/java/com/loomcom/symon/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/MemoryRange.java b/src/main/java/com/loomcom/symon/MemoryRange.java index cdebf86..a672939 100644 --- a/src/main/java/com/loomcom/symon/MemoryRange.java +++ b/src/main/java/com/loomcom/symon/MemoryRange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/Preferences.java b/src/main/java/com/loomcom/symon/Preferences.java index 7db2d83..08c40cf 100644 --- a/src/main/java/com/loomcom/symon/Preferences.java +++ b/src/main/java/com/loomcom/symon/Preferences.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/Simulator.java b/src/main/java/com/loomcom/symon/Simulator.java index 965cb8d..5047f53 100644 --- a/src/main/java/com/loomcom/symon/Simulator.java +++ b/src/main/java/com/loomcom/symon/Simulator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyrighi (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -31,14 +31,14 @@ import com.loomcom.symon.exceptions.SymonException; import com.loomcom.symon.machines.Machine; import com.loomcom.symon.ui.*; import com.loomcom.symon.ui.Console; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.*; import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Symon Simulator Interface and Control. @@ -50,6 +50,8 @@ import java.util.logging.Logger; */ public class Simulator { + private final static Logger logger = LoggerFactory.getLogger(Simulator.class.getName()); + // UI constants private static final int DEFAULT_FONT_SIZE = 12; private static final Font DEFAULT_FONT = new Font(Font.MONOSPACED, Font.PLAIN, DEFAULT_FONT_SIZE); @@ -66,8 +68,6 @@ public class Simulator { // private static final int MAX_STEPS_BETWEEN_UPDATES = 20000; - private final static Logger logger = Logger.getLogger(Simulator.class.getName()); - // The simulated machine private Machine machine; @@ -287,7 +287,7 @@ public class Simulator { } try { - logger.log(Level.INFO, "Reset requested. Resetting CPU."); + logger.info("Reset requested. Resetting CPU."); // Reset CPU machine.getCpu().reset(); // Clear the console. @@ -302,15 +302,9 @@ public class Simulator { } } // Update status. - SwingUtilities.invokeLater(new Runnable() { - public void run() { - // Now update the state - statusPane.updateState(); - memoryWindow.updateState(); - } - }); + updateVisibleState(); } catch (MemoryAccessException ex) { - logger.log(Level.SEVERE, "Exception during simulator reset: " + ex.getMessage()); + logger.error("Exception during simulator reset", ex); } } @@ -322,17 +316,9 @@ public class Simulator { for (int i = 0; i < numSteps; i++) { step(); } - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (traceLog.isVisible()) { - traceLog.refresh(); - } - statusPane.updateState(); - memoryWindow.updateState(); - } - }); + updateVisibleState(); } catch (SymonException ex) { - logger.log(Level.SEVERE, "Exception during simulator step: " + ex.getMessage()); + logger.error("Exception during simulator step", ex); ex.printStackTrace(); } } @@ -359,7 +345,7 @@ public class Simulator { machine.getAcia().rxWrite((int) console.readInputChar()); } } catch (FifoUnderrunException ex) { - logger.severe("Console type-ahead buffer underrun!"); + logger.error("Console type-ahead buffer underrun!"); } if (videoWindow != null && stepsSinceLastCrtcRefresh++ > stepsBetweenCrtcRefreshes) { @@ -373,13 +359,7 @@ public class Simulator { // a delay, so we don't want to overwhelm the Swing event processing thread // with requests. Limit the number of ui updates that can be performed. if (stepsSinceLastUpdate++ > MAX_STEPS_BETWEEN_UPDATES) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - // Now update the state - statusPane.updateState(); - memoryWindow.updateState(); - } - }); + updateVisibleState(); stepsSinceLastUpdate = 0; } @@ -394,8 +374,7 @@ public class Simulator { machine.getBus().write(addr++, program[i] & 0xff); } - logger.log(Level.INFO, "Loaded " + i + " bytes at address 0x" + - Integer.toString(startAddress, 16)); + logger.info("Loaded {} bytes at address 0x{}", i, Integer.toString(startAddress, 16)); // After loading, be sure to reset and // Reset (but don't clear memory, naturally) @@ -405,16 +384,9 @@ public class Simulator { machine.getCpu().setProgramCounter(preferences.getProgramStartAddress()); // Immediately update the UI. - SwingUtilities.invokeLater(new Runnable() { - public void run() { - // Now update the state - statusPane.updateState(); - memoryWindow.updateState(); - } - }); + updateVisibleState(); } - /** * The main run thread. */ @@ -430,7 +402,7 @@ public class Simulator { } public void run() { - logger.log(Level.INFO, "Starting main run loop."); + logger.info("Starting main run loop."); isRunning = true; SwingUtilities.invokeLater(new Runnable() { @@ -449,8 +421,7 @@ public class Simulator { step(); } while (shouldContinue()); } catch (SymonException ex) { - logger.log(Level.SEVERE, "Exception in main simulator run thread. Exiting run."); - ex.printStackTrace(); + logger.error("Exception in main simulator run thread. Exiting run.", ex); } SwingUtilities.invokeLater(new Runnable() { @@ -529,10 +500,10 @@ public class Simulator { } } } catch (IOException ex) { - logger.log(Level.SEVERE, "Unable to read program file: " + ex.getMessage()); + logger.error("Unable to read program file.", ex); JOptionPane.showMessageDialog(mainWindow, ex.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); } catch (MemoryAccessException ex) { - logger.log(Level.SEVERE, "Memory access error loading program: " + ex.getMessage()); + logger.error("Memory access error loading program", ex); JOptionPane.showMessageDialog(mainWindow, ex.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); } } @@ -555,34 +526,36 @@ public class Simulator { if (fileSize != machine.getRomSize()) { throw new IOException("ROM file must be exactly " + String.valueOf(machine.getRomSize()) + " bytes."); - } else { - - // Load the new ROM image - Memory rom = Memory.makeROM(machine.getRomBase(), machine.getRomBase() + machine.getRomSize() - 1, romFile); - machine.setRom(rom); - - // Now, reset - machine.getCpu().reset(); - - logger.log(Level.INFO, "ROM File `" + romFile.getName() + "' loaded at " + - String.format("0x%04X", machine.getRomBase())); - // TODO: "Don't Show Again" checkbox - JOptionPane.showMessageDialog(mainWindow, - "Loaded Successfully At " + - String.format("$%04X", machine.getRomBase()), - "OK", - JOptionPane.PLAIN_MESSAGE); } + + // Load the new ROM image + Memory rom = Memory.makeROM(machine.getRomBase(), machine.getRomBase() + machine.getRomSize() - 1, romFile); + machine.setRom(rom); + + // Now, reset + machine.getCpu().reset(); + + updateVisibleState(); + + logger.info("ROM File `{}' loaded at {}", romFile.getName(), + String.format("0x%04X", machine.getRomBase())); + // TODO: "Don't Show Again" checkbox + JOptionPane.showMessageDialog(mainWindow, + "Loaded Successfully At " + + String.format("$%04X", machine.getRomBase()), + "OK", + JOptionPane.PLAIN_MESSAGE); + } } } catch (IOException ex) { - logger.log(Level.SEVERE, "Unable to read ROM file: " + ex.getMessage()); + logger.error("Unable to read ROM file: {}", ex.getMessage()); JOptionPane.showMessageDialog(mainWindow, ex.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); } catch (MemoryRangeException ex) { - logger.log(Level.SEVERE, "Memory range error while loading ROM file: " + ex.getMessage()); + logger.error("Memory range error while loading ROM file: {}", ex.getMessage()); JOptionPane.showMessageDialog(mainWindow, ex.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); } catch (MemoryAccessException ex) { - logger.log(Level.SEVERE, "Memory access error while loading ROM file: " + ex.getMessage()); + logger.error("Memory access error while loading ROM file: {}", ex.getMessage()); JOptionPane.showMessageDialog(mainWindow, ex.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); } } @@ -837,4 +810,18 @@ public class Simulator { } } + private void updateVisibleState() { + // Immediately update the UI. + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // Now update the state + statusPane.updateState(); + memoryWindow.updateState(); + if (traceLog.shouldUpdate()) { + traceLog.refresh(); + } + } + }); + } + } diff --git a/src/main/java/com/loomcom/symon/devices/Acia.java b/src/main/java/com/loomcom/symon/devices/Acia.java index 48b09be..eb97e45 100644 --- a/src/main/java/com/loomcom/symon/devices/Acia.java +++ b/src/main/java/com/loomcom/symon/devices/Acia.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/Acia6551.java b/src/main/java/com/loomcom/symon/devices/Acia6551.java index 7cdeeb3..f64deaa 100644 --- a/src/main/java/com/loomcom/symon/devices/Acia6551.java +++ b/src/main/java/com/loomcom/symon/devices/Acia6551.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/Acia6850.java b/src/main/java/com/loomcom/symon/devices/Acia6850.java index 315fe6c..2c4ed63 100644 --- a/src/main/java/com/loomcom/symon/devices/Acia6850.java +++ b/src/main/java/com/loomcom/symon/devices/Acia6850.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/devices/Crtc.java b/src/main/java/com/loomcom/symon/devices/Crtc.java index 308292a..f26f8cc 100644 --- a/src/main/java/com/loomcom/symon/devices/Crtc.java +++ b/src/main/java/com/loomcom/symon/devices/Crtc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/Device.java b/src/main/java/com/loomcom/symon/devices/Device.java index 30f918a..3cf9a4d 100644 --- a/src/main/java/com/loomcom/symon/devices/Device.java +++ b/src/main/java/com/loomcom/symon/devices/Device.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/DeviceChangeListener.java b/src/main/java/com/loomcom/symon/devices/DeviceChangeListener.java index bd8cb6a..4b9f8d7 100644 --- a/src/main/java/com/loomcom/symon/devices/DeviceChangeListener.java +++ b/src/main/java/com/loomcom/symon/devices/DeviceChangeListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/Memory.java b/src/main/java/com/loomcom/symon/devices/Memory.java index 74cc0af..e8a4f3d 100644 --- a/src/main/java/com/loomcom/symon/devices/Memory.java +++ b/src/main/java/com/loomcom/symon/devices/Memory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/Pia.java b/src/main/java/com/loomcom/symon/devices/Pia.java index 7d1e06c..1eaa667 100644 --- a/src/main/java/com/loomcom/symon/devices/Pia.java +++ b/src/main/java/com/loomcom/symon/devices/Pia.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/devices/SdController.java b/src/main/java/com/loomcom/symon/devices/SdController.java index b6c7869..0c6b33b 100644 --- a/src/main/java/com/loomcom/symon/devices/SdController.java +++ b/src/main/java/com/loomcom/symon/devices/SdController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/devices/Via6522.java b/src/main/java/com/loomcom/symon/devices/Via6522.java index c9d28a6..64aac36 100644 --- a/src/main/java/com/loomcom/symon/devices/Via6522.java +++ b/src/main/java/com/loomcom/symon/devices/Via6522.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/exceptions/FifoUnderrunException.java b/src/main/java/com/loomcom/symon/exceptions/FifoUnderrunException.java index 597283d..0926c0b 100644 --- a/src/main/java/com/loomcom/symon/exceptions/FifoUnderrunException.java +++ b/src/main/java/com/loomcom/symon/exceptions/FifoUnderrunException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/exceptions/MemoryAccessException.java b/src/main/java/com/loomcom/symon/exceptions/MemoryAccessException.java index 44fea58..312d5cf 100644 --- a/src/main/java/com/loomcom/symon/exceptions/MemoryAccessException.java +++ b/src/main/java/com/loomcom/symon/exceptions/MemoryAccessException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/exceptions/MemoryRangeException.java b/src/main/java/com/loomcom/symon/exceptions/MemoryRangeException.java index a79eb7b..074adec 100644 --- a/src/main/java/com/loomcom/symon/exceptions/MemoryRangeException.java +++ b/src/main/java/com/loomcom/symon/exceptions/MemoryRangeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/exceptions/SymonException.java b/src/main/java/com/loomcom/symon/exceptions/SymonException.java index dcd82d0..570176f 100644 --- a/src/main/java/com/loomcom/symon/exceptions/SymonException.java +++ b/src/main/java/com/loomcom/symon/exceptions/SymonException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/machines/Machine.java b/src/main/java/com/loomcom/symon/machines/Machine.java index 396c469..52035ad 100644 --- a/src/main/java/com/loomcom/symon/machines/Machine.java +++ b/src/main/java/com/loomcom/symon/machines/Machine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/machines/MulticompMachine.java b/src/main/java/com/loomcom/symon/machines/MulticompMachine.java index 9b96db7..d1d784d 100644 --- a/src/main/java/com/loomcom/symon/machines/MulticompMachine.java +++ b/src/main/java/com/loomcom/symon/machines/MulticompMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/machines/SimpleMachine.java b/src/main/java/com/loomcom/symon/machines/SimpleMachine.java index 2d5d1ed..430d543 100644 --- a/src/main/java/com/loomcom/symon/machines/SimpleMachine.java +++ b/src/main/java/com/loomcom/symon/machines/SimpleMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/main/java/com/loomcom/symon/machines/SymonMachine.java b/src/main/java/com/loomcom/symon/machines/SymonMachine.java index 1b98c5f..50abf31 100644 --- a/src/main/java/com/loomcom/symon/machines/SymonMachine.java +++ b/src/main/java/com/loomcom/symon/machines/SymonMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining @@ -28,13 +28,14 @@ import com.loomcom.symon.Bus; import com.loomcom.symon.Cpu; import com.loomcom.symon.devices.*; import com.loomcom.symon.exceptions.MemoryRangeException; -import java.io.File; -import java.util.logging.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.File; public class SymonMachine implements Machine { - private final static Logger logger = Logger.getLogger(SymonMachine.class.getName()); + private final static Logger logger = LoggerFactory.getLogger(SymonMachine.class.getName()); // Constants used by the simulated system. These define the memory map. private static final int BUS_BOTTOM = 0x0000; @@ -86,11 +87,10 @@ public class SymonMachine implements Machine { // TODO: Make this configurable, of course. File romImage = new File("rom.bin"); if (romImage.canRead()) { - logger.info("Loading ROM image from file " + romImage); + logger.info("Loading ROM image from file {}", romImage); this.rom = Memory.makeROM(ROM_BASE, ROM_BASE + ROM_SIZE - 1, romImage); } else { - logger.info("Default ROM file " + romImage + - " not found, loading empty R/W memory image."); + logger.info("Default ROM file {} not found, loading empty R/W memory image.", romImage); this.rom = Memory.makeRAM(ROM_BASE, ROM_BASE + ROM_SIZE - 1); } diff --git a/src/main/java/com/loomcom/symon/ui/Console.java b/src/main/java/com/loomcom/symon/ui/Console.java index 4bf51d8..dffc136 100644 --- a/src/main/java/com/loomcom/symon/ui/Console.java +++ b/src/main/java/com/loomcom/symon/ui/Console.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/ui/MemoryWindow.java b/src/main/java/com/loomcom/symon/ui/MemoryWindow.java index 273645f..7096b2e 100644 --- a/src/main/java/com/loomcom/symon/ui/MemoryWindow.java +++ b/src/main/java/com/loomcom/symon/ui/MemoryWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java b/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java index bb75724..4c7ce5a 100644 --- a/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java +++ b/src/main/java/com/loomcom/symon/ui/PreferencesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/ui/StatusPanel.java b/src/main/java/com/loomcom/symon/ui/StatusPanel.java index 5165fbe..4a497c6 100644 --- a/src/main/java/com/loomcom/symon/ui/StatusPanel.java +++ b/src/main/java/com/loomcom/symon/ui/StatusPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -32,9 +32,6 @@ import javax.swing.border.EtchedBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Pattern; /** * UI component that displays the current state of the simulated CPU. @@ -154,7 +151,7 @@ public class StatusPanel extends JPanel { // Create and add register and address labels statusFlagsLabel = makeLabel("Flags"); - opcodeLabel = makeLabel("IR"); + opcodeLabel = makeLabel("Next IR"); pcLabel = makeLabel("PC"); spLabel = makeLabel("SP"); aLabel = makeLabel("A"); @@ -317,7 +314,9 @@ public class StatusPanel extends JPanel { negativeFlagLabel.setIcon(iconForFlag(status, 7)); // Update the register and address displays - opcodeField.setText(cpu.getCpuState().disassembleOp()); + + // We always want to show the NEXT instruction that will be executed + opcodeField.setText(cpu.getCpuState().disassembleNextOp()); pcField.setText(cpu.getProgramCounterStatus()); spField.setText(cpu.getStackPointerStatus()); aField.setText(cpu.getAccumulatorStatus()); diff --git a/src/main/java/com/loomcom/symon/ui/TraceLog.java b/src/main/java/com/loomcom/symon/ui/TraceLog.java index a161d35..17ff48e 100644 --- a/src/main/java/com/loomcom/symon/ui/TraceLog.java +++ b/src/main/java/com/loomcom/symon/ui/TraceLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * Maik Merten * * Permission is hereby granted, free of charge, to any person obtaining @@ -113,4 +113,8 @@ public class TraceLog extends JFrame { traceLogTextArea.setEnabled(true); } + public boolean shouldUpdate() { + return isVisible() && traceLogTextArea.isEnabled(); + } + } diff --git a/src/main/java/com/loomcom/symon/ui/VideoWindow.java b/src/main/java/com/loomcom/symon/ui/VideoWindow.java index f0f1bf5..305ac9c 100644 --- a/src/main/java/com/loomcom/symon/ui/VideoWindow.java +++ b/src/main/java/com/loomcom/symon/ui/VideoWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/util/FifoRingBuffer.java b/src/main/java/com/loomcom/symon/util/FifoRingBuffer.java index b254da9..f2e528c 100644 --- a/src/main/java/com/loomcom/symon/util/FifoRingBuffer.java +++ b/src/main/java/com/loomcom/symon/util/FifoRingBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/main/java/com/loomcom/symon/util/HexUtil.java b/src/main/java/com/loomcom/symon/util/HexUtil.java index 4a8d1e2..304e207 100644 --- a/src/main/java/com/loomcom/symon/util/HexUtil.java +++ b/src/main/java/com/loomcom/symon/util/HexUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Seth J. Morabito + * Copyright (c) 2016 Seth J. Morabito * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the