Changed how traces are handled so that if boot takes a little while we don't see a dump of BRK traces to STDOUT on startup

This commit is contained in:
Brendan Robert 2015-09-05 17:29:21 -05:00
parent 674d9d6980
commit 11b26305f8
3 changed files with 19 additions and 12 deletions

View File

@ -1045,8 +1045,9 @@ public class MOS65C02 extends CPU {
int pc = getProgramCounter(); int pc = getProgramCounter();
String traceEntry = null; String traceEntry = null;
if (isTraceEnabled() || isLogEnabled() || warnAboutExtendedOpcodes) { if (isSingleTraceEnabled() || isTraceEnabled() || isLogEnabled() || warnAboutExtendedOpcodes) {
traceEntry = getState().toUpperCase() + " " + Integer.toString(pc, 16) + " : " + disassemble(); traceEntry = getState().toUpperCase() + " " + Integer.toString(pc, 16) + " : " + disassemble();
captureSingleTrace(traceEntry);
if (isTraceEnabled()) { if (isTraceEnabled()) {
Logger.getLogger(getClass().getName()).info(traceEntry); Logger.getLogger(getClass().getName()).info(traceEntry);
} }

View File

@ -309,6 +309,7 @@ public class MetaCheat extends Cheats {
@Override @Override
public void tick() { public void tick() {
computer.cpu.performSingleTrace();
if (fadeCounter-- <= 0) { if (fadeCounter-- <= 0) {
fadeCounter = FADE_TIMER_VALUE; fadeCounter = FADE_TIMER_VALUE;
memoryCells.values().stream() memoryCells.values().stream()
@ -341,9 +342,6 @@ public class MetaCheat extends Cheats {
CPU cpu = Emulator.computer.getCpu(); CPU cpu = Emulator.computer.getCpu();
int pc = cpu.getProgramCounter(); int pc = cpu.getProgramCounter();
String trace = cpu.getLastTrace(); String trace = cpu.getLastTrace();
if (!cpu.isLogEnabled()) {
cpu.traceLength = 1;
}
switch (e.getType()) { switch (e.getType()) {
case EXECUTE: case EXECUTE:
cell.execInstructionsDisassembly.add(trace); cell.execInstructionsDisassembly.add(trace);

View File

@ -72,14 +72,6 @@ public abstract class CPU extends Device {
traceLog.add(line); traceLog.add(line);
} }
public String getLastTrace() {
if (traceLog.isEmpty()) {
return "???";
} else {
return traceLog.get(traceLog.size()-1);
}
}
public void dumpTrace() { public void dumpTrace() {
computer.pause(); computer.pause();
ArrayList<String> newLog = new ArrayList<>(); ArrayList<String> newLog = new ArrayList<>();
@ -167,4 +159,20 @@ public abstract class CPU extends Device {
} }
abstract public void JSR(int pointer); 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;
}
} }