Added execution stack tracking and more UI adjustments

This commit is contained in:
Brendan Robert 2015-09-05 14:14:40 -05:00
parent ac753c9c0c
commit f7ee8272b5
5 changed files with 24 additions and 20 deletions

View File

@ -30,6 +30,7 @@ public class MemoryCell implements Comparable<MemoryCell> {
public ObservableList<String> readInstructionsDisassembly = FXCollections.observableArrayList(new ArrayList<>());
public ObservableList<Integer> writeInstructions = FXCollections.observableList(new ArrayList<>());
public ObservableList<String> writeInstructionsDisassembly = FXCollections.observableArrayList(new ArrayList<>());
public ObservableList<String> execInstructionsDisassembly = FXCollections.observableArrayList(new ArrayList<>());
private int x;
private int y;
private int width;

View File

@ -339,11 +339,17 @@ public class MetaCheat extends Cheats {
MemoryCell cell = getMemoryCell(e.getAddress());
if (cell != null) {
CPU cpu = Emulator.computer.getCpu();
int pc = cpu.getProgramCounter();
String trace = cpu.getLastTrace();
if (!cpu.isLogEnabled()) {
cpu.traceLength = 1;
}
switch (e.getType()) {
case EXECUTE:
cell.execInstructionsDisassembly.add(trace);
if (cell.execInstructionsDisassembly.size() > historyLength) {
cell.execInstructionsDisassembly.remove(0);
}
case READ_OPERAND:
cell.execCount.set(Math.min(255, cell.execCount.get() + lightRate));
break;
@ -351,8 +357,6 @@ public class MetaCheat extends Cheats {
cell.writeCount.set(Math.min(255, cell.writeCount.get() + lightRate));
if (ui.isInspecting(cell.address)) {
if (pendingInspectorUpdates.incrementAndGet() < 5) {
int pc = cpu.getProgramCounter();
String trace = cpu.getLastTrace();
Platform.runLater(() -> {
pendingInspectorUpdates.decrementAndGet();
cell.writeInstructions.add(pc);
@ -376,8 +380,6 @@ public class MetaCheat extends Cheats {
cell.readCount.set(Math.min(255, cell.readCount.get() + lightRate));
if (ui.isInspecting(cell.address)) {
if (pendingInspectorUpdates.incrementAndGet() < 5) {
int pc = cpu.getProgramCounter();
String trace = cpu.getLastTrace();
Platform.runLater(() -> {
pendingInspectorUpdates.decrementAndGet();
cell.readInstructions.add(pc);

View File

@ -310,7 +310,7 @@ public class MetacheatUI {
});
memoryViewPane.boundsInParentProperty().addListener((prop, oldVal, newVal) -> redrawMemoryView());
drawScale = isRetina ? 0.5 : 1.0;
memoryViewCanvas.widthProperty().bind(memoryViewPane.widthProperty().multiply(drawScale));
memoryViewCanvas.widthProperty().bind(memoryViewPane.widthProperty().multiply(drawScale).subtract(8));
watchesPane.setHgap(5);
watchesPane.setVgap(5);
@ -471,18 +471,10 @@ public class MetacheatUI {
cheatEngine.initMemoryView();
int pixelsPerBlock = 16 * MEMORY_BOX_TOTAL_SIZE;
memoryViewColumns = (int) (memoryViewPane.getWidth() / pixelsPerBlock * 16);
memoryViewColumns = (int) (memoryViewPane.getWidth() / pixelsPerBlock) * 16;
memoryViewRows = ((cheatEngine.getEndAddress() - cheatEngine.getStartAddress()) / memoryViewColumns) + 1;
double canvasHeight = memoryViewRows * MEMORY_BOX_TOTAL_SIZE * drawScale;
// Guard against asking for a big texture because bad things will happen!
while (canvasHeight >= 16384) {
memoryViewColumns += 16;
memoryViewRows = ((cheatEngine.getEndAddress() - cheatEngine.getStartAddress()) / memoryViewColumns) + 1;
canvasHeight = memoryViewRows * MEMORY_BOX_TOTAL_SIZE * drawScale;
}
double canvasWidth = memoryViewColumns * MEMORY_BOX_TOTAL_SIZE * drawScale;
memoryViewContents.setPrefHeight(canvasHeight);
memoryViewCanvas.setHeight(canvasHeight);
GraphicsContext context = memoryViewCanvas.getGraphicsContext2D();
@ -503,7 +495,7 @@ public class MetacheatUI {
redrawNodes.add(newCell);
});
setZoom((1/drawScale) - 0.1);
setZoom(1/drawScale);
if (resume) {
Emulator.computer.resume();

View File

@ -1,13 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import java.net.*?>
<?import javafx.scene.canvas.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="520.0" prefWidth="710.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="jace.ui.MetacheatUI">
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="520.0" prefWidth="710.0" stylesheets="@../styles/style.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="jace.ui.MetacheatUI">
<stylesheets>
<URL value="@/styles/style.css" />
</stylesheets>
<children>
<ToolBar prefHeight="40.0" prefWidth="200.0" VBox.vgrow="NEVER">
<items>
@ -215,12 +219,12 @@
<tabs>
<Tab text="W">
<content>
<ListView fx:id="codeInspectorWriteList" editable="true" />
<ListView fx:id="codeInspectorWriteList" editable="true" styleClass="codeInspector" />
</content>
</Tab>
<Tab text="R">
<content>
<ListView fx:id="codeInspectorReadList" editable="true" />
<ListView fx:id="codeInspectorReadList" editable="true" styleClass="codeInspector" />
</content>
</Tab>
</tabs>

View File

@ -14,3 +14,8 @@
-fx-graphic: "/jace/data/icon_keyboard.gif";
-fx-graphic-text-gap: 2;
}
.codeInspector .list-cell {
-fx-font-size: 9pt;
-fx-font-family: "Courier New";
}