diff --git a/src/common/baseplatform.ts b/src/common/baseplatform.ts index f7cee339..12acf75c 100644 --- a/src/common/baseplatform.ts +++ b/src/common/baseplatform.ts @@ -133,6 +133,7 @@ export interface Platform { resize?() : void; getRasterScanline?() : number; + getRasterLineClock?() : number; setBreakpoint?(id : string, cond : DebugCondition); clearBreakpoint?(id : string); hasBreakpoint?(id : string) : boolean; diff --git a/src/ide/ui.ts b/src/ide/ui.ts index 7a8d6e21..3c47880e 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -1491,7 +1491,7 @@ function setupDebugCallback(btnid? : DebugCommandType) { } } -function setupBreakpoint(btnid? : DebugCommandType) { +export function setupBreakpoint(btnid? : DebugCommandType) { if (!checkRunReady()) return; _disableRecording(); setupDebugCallback(btnid); @@ -1591,7 +1591,7 @@ function runStepBackwards() { platform.stepBack(); } -function clearBreakpoint() { +export function clearBreakpoint() { lastDebugState = null; if (platform.clearDebug) platform.clearDebug(); setupDebugCallback(); // in case of BRK/trap diff --git a/src/ide/views/debugviews.ts b/src/ide/views/debugviews.ts index d5135368..2fa5a50f 100644 --- a/src/ide/views/debugviews.ts +++ b/src/ide/views/debugviews.ts @@ -1,7 +1,7 @@ import { newDiv, ProjectView } from "./baseviews"; import { Segment } from "../../common/workertypes"; -import { platform, compparams, current_project, projectWindows } from "../ui"; +import { platform, compparams, current_project, projectWindows, runToPC, setupBreakpoint } from "../ui"; import { hex, lpad, rpad } from "../../common/util"; import { VirtualList } from "../../common/vlist"; import { getMousePos, getVisibleEditorLineHeight, VirtualTextLine, VirtualTextScroller } from "../../common/emu"; @@ -470,7 +470,19 @@ abstract class ProbeViewBase extends ProbeViewBaseBase { getTooltipText(x:number, y:number) : string { return null; } - + + getOpAtPos(x:number, y:number, mask:number) : number { + x = x|0; + y = y|0; + let result = 0; + this.redraw( (op,addr,col,row,clk,value) => { + if (!result && row == y && col >= x && (op & mask) != 0) { + result = op | addr; + } + }); + return result; + } + clear() { } @@ -546,6 +558,15 @@ export class AddressHeatMapView extends ProbeBitmapViewBase implements ProjectVi return this.createCanvas(parent, 256, 256); } + initCanvas() { + super.initCanvas(); + this.canvas.onclick = (e) => { + var pos = getMousePos(this.canvas, e); + var opaddr = Math.floor(pos.x) + Math.floor(pos.y) * 256; + runToPC(opaddr & 0xffff); + } + } + clear() { for (var i=0; i<=0xffff; i++) { var v = platform.readAddress(i); @@ -554,7 +575,8 @@ export class AddressHeatMapView extends ProbeBitmapViewBase implements ProjectVi this.datau32[i] = rgb | OPAQUE_BLACK; } } - + + // TODO: show current PC drawEvent(op, addr, col, row) { var rgb = this.getOpRGB(op, addr); if (!rgb) return; @@ -598,6 +620,27 @@ export class AddressHeatMapView extends ProbeBitmapViewBase implements ProjectVi export class RasterPCHeatMapView extends ProbeBitmapViewBase implements ProjectView { + initCanvas() { + super.initCanvas(); + // TODO: run to exact x/y position + this.canvas.onclick = (e) => { + var pos = getMousePos(this.canvas, e); + var x = Math.floor(pos.x); + var y = Math.floor(pos.y); + var opaddr = this.getOpAtPos(pos.x, pos.y, ProbeFlags.EXECUTE); + if (opaddr) { + //runToPC(opaddr & 0xffff); + setupBreakpoint("toline"); + platform.runEval(() => { + let onrow = platform.getRasterScanline && platform.getRasterScanline() >= y; + if (onrow && platform.getRasterLineClock) { + return onrow && platform.getRasterLineClock() > x; + } else return onrow; + }); + } + } + } + drawEvent(op, addr, col, row) { var rgb = this.getOpRGB(op, addr); if (!rgb) return; diff --git a/src/machine/atari8.ts b/src/machine/atari8.ts index 6859a051..690e3a02 100644 --- a/src/machine/atari8.ts +++ b/src/machine/atari8.ts @@ -247,6 +247,9 @@ export class Atari800 extends BasicScanlineMachine { getRasterScanline() { return this.antic.v; } + getRasterLineClock() { + return this.antic.h; + } getDebugCategories() { return ['CPU', 'Stack', 'ANTIC', 'GTIA', 'POKEY']; } diff --git a/src/platform/nes.ts b/src/platform/nes.ts index 9454e317..c8a99c10 100644 --- a/src/platform/nes.ts +++ b/src/platform/nes.ts @@ -295,6 +295,9 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable { getRasterScanline() : number { return this.nes.ppu.scanline; } + getRasterLineClock() : number { + return this.nes.ppu.curX; + } getCPUState() { var c = this.nes.cpu.toJSON(); diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index f49964a6..a9987822 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -156,6 +156,9 @@ class VCSPlatform extends BasePlatform { getRasterScanline() : number { return this.getRasterPosition().y; } + getRasterLineClock() : number { + return this.getRasterPosition().x; + } // TODO: Clock changes this on event, so it may not be current isRunning() {