diff --git a/src/main/java/jace/apple2e/MOS65C02.java b/src/main/java/jace/apple2e/MOS65C02.java index cfa2c25..a6b003d 100644 --- a/src/main/java/jace/apple2e/MOS65C02.java +++ b/src/main/java/jace/apple2e/MOS65C02.java @@ -1045,8 +1045,9 @@ public class MOS65C02 extends CPU { int pc = getProgramCounter(); String traceEntry = null; - if (isTraceEnabled() || isLogEnabled() || warnAboutExtendedOpcodes) { + if (isSingleTraceEnabled() || isTraceEnabled() || isLogEnabled() || warnAboutExtendedOpcodes) { traceEntry = getState().toUpperCase() + " " + Integer.toString(pc, 16) + " : " + disassemble(); + captureSingleTrace(traceEntry); if (isTraceEnabled()) { Logger.getLogger(getClass().getName()).info(traceEntry); } diff --git a/src/main/java/jace/cheat/MetaCheat.java b/src/main/java/jace/cheat/MetaCheat.java index 9e9b9ea..384b019 100644 --- a/src/main/java/jace/cheat/MetaCheat.java +++ b/src/main/java/jace/cheat/MetaCheat.java @@ -309,6 +309,7 @@ public class MetaCheat extends Cheats { @Override public void tick() { + computer.cpu.performSingleTrace(); if (fadeCounter-- <= 0) { fadeCounter = FADE_TIMER_VALUE; memoryCells.values().stream() @@ -341,9 +342,6 @@ public class MetaCheat extends Cheats { 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); diff --git a/src/main/java/jace/core/CPU.java b/src/main/java/jace/core/CPU.java index 7d534da..aa7bb8b 100644 --- a/src/main/java/jace/core/CPU.java +++ b/src/main/java/jace/core/CPU.java @@ -72,14 +72,6 @@ public abstract class CPU extends Device { traceLog.add(line); } - public String getLastTrace() { - if (traceLog.isEmpty()) { - return "???"; - } else { - return traceLog.get(traceLog.size()-1); - } - } - public void dumpTrace() { computer.pause(); ArrayList newLog = new ArrayList<>(); @@ -167,4 +159,20 @@ public abstract class CPU extends Device { } abstract public void JSR(int pointer); + + boolean singleTraceEnabled = false; + public String lastTrace = "START"; + public void performSingleTrace() { + singleTraceEnabled = true; + } + public boolean isSingleTraceEnabled() { + return singleTraceEnabled; + } + public String getLastTrace() { + return lastTrace; + } + public void captureSingleTrace(String trace) { + lastTrace = trace; + singleTraceEnabled = false; + } } \ No newline at end of file