diff --git a/src/common/baseplatform.ts b/src/common/baseplatform.ts index 942e3088..69d4d1c6 100644 --- a/src/common/baseplatform.ts +++ b/src/common/baseplatform.ts @@ -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; diff --git a/src/platform/vectrex.ts b/src/platform/vectrex.ts index f1c215d3..667601ea 100644 --- a/src/platform/vectrex.ts +++ b/src/platform/vectrex.ts @@ -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(); diff --git a/test/cli/testplatforms.js b/test/cli/testplatforms.js index 29bab823..c163d7ed 100644 --- a/test/cli/testplatforms.js +++ b/test/cli/testplatforms.js @@ -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();