diff --git a/src/platform/nes.ts b/src/platform/nes.ts index d6d17e24..c882e6bc 100644 --- a/src/platform/nes.ts +++ b/src/platform/nes.ts @@ -299,7 +299,13 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable { // TODO don't need to save ROM? saveState() { //var s = $.extend(true, {}, this.nes); - var s = this.nes.toJSON(); + var s; + if (this.nes.mmap) { + s = this.nes.toJSON(); + } else { + console.log("no nes.mmap!"); + s = { cpu: this.nes.cpu.toJSON(), ppu: this.nes.ppu.toJSON() }; + } s.c = s.cpu; this.copy6502REGvars(s.c); s.b = s.cpu.mem = s.cpu.mem.slice(0); diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index a460ceb2..7fad8526 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -187,8 +187,8 @@ class VCSPlatform extends BasePlatform { return state; } fixState(state) { - var ofs = state.ca.bo || 0; - if (state.ca.fo && (state.c.PC & 0xfff) >= 2048) + var ofs = (state.ca && state.ca.bo) || 0; + if (state.ca && state.ca.fo && (state.c.PC & 0xfff) >= 2048) ofs = state.ca.fo; // 3E/3F fixed-slice formats // TODO: for batari BASIC state.c.EPC = state.c.PC + ofs; // EPC = effective PC for ROM diff --git a/test/cli/testplatforms.js b/test/cli/testplatforms.js index 0abe5975..7d26971c 100644 --- a/test/cli/testplatforms.js +++ b/test/cli/testplatforms.js @@ -118,6 +118,7 @@ function testPlatform(platid, romname, maxframes, callback) { var platform = new emu.PLATFORMS[platid](emudiv); var rec = new recorder.StateRecorderImpl(platform); platform.start(); + assert.ok(platform.saveState()); // can save before ROM load? var rom = fs.readFileSync('./test/roms/' + platid + '/' + romname); rom = new Uint8Array(rom); platform.loadROM("ROM", rom);