From 40c5397ed8f369d505ec95444b22ace869ceed33 Mon Sep 17 00:00:00 2001 From: Seth Morabito Date: Sun, 6 Jul 2014 12:17:39 -0700 Subject: [PATCH] Faster refresh of memory window --- src/main/java/com/loomcom/symon/Simulator.java | 11 ++++++++--- .../java/com/loomcom/symon/ui/MemoryWindow.java | 13 ++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/loomcom/symon/Simulator.java b/src/main/java/com/loomcom/symon/Simulator.java index b31199e..7ec8455 100644 --- a/src/main/java/com/loomcom/symon/Simulator.java +++ b/src/main/java/com/loomcom/symon/Simulator.java @@ -84,12 +84,12 @@ public class Simulator { // to refresh the status view on every simulated clock cycle. Instead, we will only refresh the status view // after this number of steps when running normally. // - // Since we're simulating a 1MHz 6502 here, we have a 1 us delay between steps. Setting this to 10000 - // should give us a status update every 10 ms. + // Since we're simulating a 1MHz 6502 here, we have a 1 us delay between steps. Setting this to 20000 + // should give us a status update about every 100 ms. // // TODO: Work around the event dispatch thread with custom painting code instead of relying on Swing. // - private static final int MAX_STEPS_BETWEEN_UPDATES = 10000; + private static final int MAX_STEPS_BETWEEN_UPDATES = 20000; private final static Logger logger = Logger.getLogger(Simulator.class.getName()); @@ -322,6 +322,7 @@ public class Simulator { public void run() { // Now update the state statusPane.updateState(cpu); + memoryWindow.updateState(); } }); } catch (MemoryAccessException ex) { @@ -343,6 +344,7 @@ public class Simulator { traceLog.refresh(); } statusPane.updateState(cpu); + memoryWindow.updateState(); } }); } catch (SymonException ex) { @@ -390,6 +392,7 @@ public class Simulator { public void run() { // Now update the state statusPane.updateState(cpu); + memoryWindow.updateState(); } }); stepsSinceLastUpdate = 0; @@ -421,6 +424,7 @@ public class Simulator { public void run() { // Now update the state statusPane.updateState(cpu); + memoryWindow.updateState(); } }); } @@ -489,6 +493,7 @@ public class Simulator { SwingUtilities.invokeLater(new Runnable() { public void run() { statusPane.updateState(cpu); + memoryWindow.updateState(); runStopButton.setText("Run"); stepButton.setEnabled(true); stepCountBox.setEnabled(true); diff --git a/src/main/java/com/loomcom/symon/ui/MemoryWindow.java b/src/main/java/com/loomcom/symon/ui/MemoryWindow.java index b358dbc..01ca193 100644 --- a/src/main/java/com/loomcom/symon/ui/MemoryWindow.java +++ b/src/main/java/com/loomcom/symon/ui/MemoryWindow.java @@ -190,14 +190,14 @@ public class MemoryWindow extends JFrame implements ActionListener { if (currentPage > 0x00) { setPageNumber(currentPage - 1); updateControls(); - memoryTable.updateUI(); + updateState(); } } else if (e.getSource() == nextPageButton) { int currentPage = getPageNumber(); if (currentPage < 0xff) { setPageNumber(currentPage + 1); updateControls(); - memoryTable.updateUI(); + updateState(); } } else if (e.getSource() == pageNumberTextField) { String pageNumberInput = pageNumberTextField.getText(); @@ -205,7 +205,7 @@ public class MemoryWindow extends JFrame implements ActionListener { // Try to parse a hex value out of the pageNumber. int newPageNumber = Integer.parseInt(pageNumberInput, 16); setPageNumber(newPageNumber & 0xff); - memoryTable.updateUI(); + updateState(); } catch (NumberFormatException ex) { // An invalid number was entered. Log the error, but otherwise // take no action. @@ -216,6 +216,13 @@ public class MemoryWindow extends JFrame implements ActionListener { } } + /** + * Refresh the view of memory + */ + public void updateState() { + memoryTable.updateUI(); + } + /** * A JTable that will automatically select all text in a cell * being edited.