reload debug break state before resuming, fixes frame de-sync problem

This commit is contained in:
Steven Hugg 2022-09-06 19:32:02 -05:00
parent 58e3f3f9fb
commit 162113b915
3 changed files with 20 additions and 2 deletions

View File

@ -270,6 +270,9 @@ export abstract class BaseDebugPlatform extends BasePlatform {
this.onBreakpointHit = callback;
}
clearDebug() {
if (this.debugBreakState != null) {
this.loadState(this.debugSavedState);
}
this.debugSavedState = null;
this.debugBreakState = null;
this.debugTargetClock = -1;

View File

@ -849,12 +849,12 @@ class VectrexPlatform extends Base6809Platform {
var frameCycles = 1500000 / 60;
var cycles = 0;
while (cycles < frameCycles) {
cycles += this.step();
cycles += this.nextCycle();
}
return cycles;
}
step() {
nextCycle() {
this.probe.logExecute(this.getPC(), this.getSP());
if (this.via.ifr & 0x80) {
this._cpu.interrupt();

View File

@ -194,6 +194,21 @@ async function testPlatform(platid, romname, maxframes, callback) {
}
assert.equal(clks, proberec.countClocks());
}
// debugging
let bpState = null;
if (platform.setupDebug) {
let stated1 = platform.saveState();
platform.setupDebug((state,msg) => {
bpState = state;
});
if (platform.step) platform.step();
platform.nextFrame();
platform.clearDebug();
let stated3 = platform.saveState();
assert.ok(bpState);
console.log(stated1.c.PC, bpState.c.PC, stated3.c.PC);
assert.equal(stated1.c.PC, stated3.c.PC);
}
// debug tree
if (platform.getDebugTree != null) {
var dbgtree = platform.getDebugTree();