From 5b7e0a6330a3374d7df2dd5de9556e6a3cc0bdb4 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 17 Apr 2021 12:22:02 -0500 Subject: [PATCH] vcs: fixed instant replay, KIL ($02) instruction --- doc/notes.txt | 1 + index.html | 2 +- javatari.js | 2 +- src/platform/vcs.ts | 24 +++++++++++++++++++----- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 375b3006..12fca099 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -203,6 +203,7 @@ can't modify/delete an include file if project doesn't compile Probing - probe log doesn't start @ reset Debug, play then halt cpu doesn't highlight final line +vcs: input not preserved when replaying frames? WEB WORKER FORMAT diff --git a/index.html b/index.html index 7d40a147..5b324a23 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) { - + diff --git a/javatari.js b/javatari.js index 977bf9ca..9d124f08 160000 --- a/javatari.js +++ b/javatari.js @@ -1 +1 @@ -Subproject commit 977bf9ca6c284dc27a3c4e27cc1ee49f22c934de +Subproject commit 9d124f087e1f0c7f74f9244b9679cc62e71fa524 diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index 109bea7f..d99ac655 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -1,7 +1,7 @@ "use strict"; -import { Platform, BasePlatform, cpuStateToLongString_6502, BaseMAMEPlatform, EmuRecorder, dumpStackToString, DisasmLine, CpuState } from "../common/baseplatform"; -import { PLATFORMS, RAM, newAddressDecoder, dumpRAM } from "../common/emu"; +import { Platform, BasePlatform, cpuStateToLongString_6502, BaseMAMEPlatform, EmuRecorder, dumpStackToString, DisasmLine, CpuState, DebugCondition } from "../common/baseplatform"; +import { PLATFORMS, RAM, newAddressDecoder, dumpRAM, EmuHalt } from "../common/emu"; import { hex, lpad, tobin, byte2signed } from "../common/util"; import { CodeAnalyzer_vcs } from "../common/analysis"; import { disassemble6502 } from "../common/cpu/disasm6502"; @@ -84,6 +84,11 @@ class VCSPlatform extends BasePlatform { self.updateRecorder(); self.probe.logNewFrame(); this.oldClockPulse(); + // look for KIL instruction + if (Javatari.room.console.getCPUState().o == 0x02) { + Javatari.room.console.onBreakpointHit(Javatari.room.console.saveState()); + throw new EmuHalt("CPU STOPPED"); + } } // intercept TIA end of line var videoSignal = console.tia.getVideoOutput(); @@ -100,7 +105,7 @@ class VCSPlatform extends BasePlatform { var x = e.pageX - vcanvas.offset().left; var y = e.pageY - vcanvas.offset().top; var new_x = Math.floor(x * 152 / vcanvas.width()); - var new_y = Math.floor((y-37) * (210+37) / vcanvas.height()); + var new_y = Math.floor((y-10) * (192+37+30) / vcanvas.height()); this.runEval( (c) => { var pos = this.getRasterPosition(); return (pos.x >= new_x) && (pos.y >= new_y); @@ -155,8 +160,17 @@ class VCSPlatform extends BasePlatform { } advance() : number { Javatari.room.console.clockPulse(); - return 0; //TODO + return 0; // TODO: advanceFrameClock() and return 76*262 (or PAL) } + /* + advanceFrameClock?(trap: DebugCondition, step: number) : number { + this.runEval( (c) => { + var clkfs = Javatari.room.console.getClocksFromFrameStart() - 1; + return clkfs >= step; + }); + return step; + } + */ // for unit test nextFrame() { Javatari.room.console.clockPulse(); @@ -216,7 +230,7 @@ class VCSPlatform extends BasePlatform { return Javatari.room.console.loadState(state); } getCPUState() : CpuState { - return Javatari.room.console.saveState().c; + return Javatari.room.console.getCPUState(); } saveControlsState() { return Javatari.room.console.saveControlsState();