Faster refresh of memory window

This commit is contained in:
Seth Morabito committed 2014-07-06 12:17:39 -07:00
1 parent a7ea60d250
commit 40c5397ed8
2 files changed
+18 -6

No files matched your search

@@ -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 // 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. // 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 // 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 every 10 ms. // 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. // 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()); private final static Logger logger = Logger.getLogger(Simulator.class.getName());
@@ -322,6 +322,7 @@ public class Simulator {
public void run() { public void run() {
// Now update the state // Now update the state
statusPane.updateState(cpu); statusPane.updateState(cpu);
memoryWindow.updateState();
} }
}); });
} catch (MemoryAccessException ex) { } catch (MemoryAccessException ex) {
@@ -343,6 +344,7 @@ public class Simulator {
traceLog.refresh(); traceLog.refresh();
} }
statusPane.updateState(cpu); statusPane.updateState(cpu);
memoryWindow.updateState();
} }
}); });
} catch (SymonException ex) { } catch (SymonException ex) {
@@ -390,6 +392,7 @@ public class Simulator {
public void run() { public void run() {
// Now update the state // Now update the state
statusPane.updateState(cpu); statusPane.updateState(cpu);
memoryWindow.updateState();
} }
}); });
stepsSinceLastUpdate = 0; stepsSinceLastUpdate = 0;
@@ -421,6 +424,7 @@ public class Simulator {
public void run() { public void run() {
// Now update the state // Now update the state
statusPane.updateState(cpu); statusPane.updateState(cpu);
memoryWindow.updateState();
} }
}); });
} }
@@ -489,6 +493,7 @@ public class Simulator {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
statusPane.updateState(cpu); statusPane.updateState(cpu);
memoryWindow.updateState();
runStopButton.setText("Run"); runStopButton.setText("Run");
stepButton.setEnabled(true); stepButton.setEnabled(true);
stepCountBox.setEnabled(true); stepCountBox.setEnabled(true);
@@ -190,14 +190,14 @@ public class MemoryWindow extends JFrame implements ActionListener {
if (currentPage > 0x00) { if (currentPage > 0x00) {
setPageNumber(currentPage - 1); setPageNumber(currentPage - 1);
updateControls(); updateControls();
memoryTable.updateUI(); updateState();
} }
} else if (e.getSource() == nextPageButton) { } else if (e.getSource() == nextPageButton) {
int currentPage = getPageNumber(); int currentPage = getPageNumber();
if (currentPage < 0xff) { if (currentPage < 0xff) {
setPageNumber(currentPage + 1); setPageNumber(currentPage + 1);
updateControls(); updateControls();
memoryTable.updateUI(); updateState();
} }
} else if (e.getSource() == pageNumberTextField) { } else if (e.getSource() == pageNumberTextField) {
String pageNumberInput = pageNumberTextField.getText(); 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. // Try to parse a hex value out of the pageNumber.
int newPageNumber = Integer.parseInt(pageNumberInput, 16); int newPageNumber = Integer.parseInt(pageNumberInput, 16);
setPageNumber(newPageNumber & 0xff); setPageNumber(newPageNumber & 0xff);
memoryTable.updateUI(); updateState();
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
// An invalid number was entered. Log the error, but otherwise // An invalid number was entered. Log the error, but otherwise
// take no action. // 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 * A JTable that will automatically select all text in a cell
* being edited. * being edited.