From 0e91abe6bbb257e4c372cfbc07b9f668e72b1df4 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 4 Jan 2020 14:14:36 -0600 Subject: [PATCH] working on new textual probe view --- src/ide/ui.ts | 3 + src/ide/views.ts | 272 +++++++++++++++++++++++++++++------------------ 2 files changed, 174 insertions(+), 101 deletions(-) diff --git a/src/ide/ui.ts b/src/ide/ui.ts index b1756805..1d767267 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -282,6 +282,9 @@ function refreshWindowList() { addWindowItem("#crtheatmap", "CRT Probe", () => { return new Views.RasterPCHeatMapView(); }); + addWindowItem("#probelog", "Probe Log", () => { + return new Views.ProbeLogView(); + }); /* addWindowItem("#spheatmap", "Stack Probe", () => { return new Views.RasterStackMapView(); diff --git a/src/ide/views.ts b/src/ide/views.ts index d3814f3d..f650b812 100644 --- a/src/ide/views.ts +++ b/src/ide/views.ts @@ -1,7 +1,7 @@ //import CodeMirror = require("codemirror"); import { SourceFile, WorkerError, Segment, FileData } from "../common/workertypes"; -import { Platform, EmuState, lookupSymbol, BaseDebugPlatform } from "../common/baseplatform"; +import { Platform, EmuState, lookupSymbol, BaseDebugPlatform, BaseZ80MachinePlatform, BaseZ80Platform } from "../common/baseplatform"; import { hex, lpad, rpad, safeident, rgb2bgr } from "../common/util"; import { CodeAnalyzer } from "../common/analysis"; import { platform, platform_id, compparams, current_project, lastDebugState, projectWindows } from "./ui"; @@ -821,13 +821,102 @@ export class MemoryMapView implements ProjectView { // TODO: clear buffer when scrubbing -abstract class ProbeViewBase { - +abstract class ProbeViewBaseBase { probe : ProbeRecorder; + tooldiv : HTMLElement; + + addr2str(addr : number) : string { + var _addr2sym = (platform.debugSymbols && platform.debugSymbols.addr2symbol) || {}; + var sym = _addr2sym[addr]; + if (typeof sym === 'string') + return '$' + hex(addr) + ' (' + sym + ')'; + else + return '$' + hex(addr); + } + + showTooltip(s:string) { + if (s) { + if (!this.tooldiv) { + this.tooldiv = document.createElement("div"); + this.tooldiv.setAttribute("class", "tooltiptrack"); + document.body.appendChild(this.tooldiv); + } + $(this.tooldiv).text(s).show(); + } else { + $(this.tooldiv).hide(); + } + } + + setVisible(showing : boolean) : void { + if (showing) { + this.probe = platform.startProbing(); + this.tick(); + } else { + platform.stopProbing(); + this.probe = null; + } + } + + abstract tick() : void; + + redraw( eventfn:(op,addr,col,row,clk) => void ) { + var p = this.probe; + if (!p || !p.idx) return; // if no probe, or if empty + var row=0; + var col=0; + var clk=0; + for (var i=0; i void ) { - var p = this.probe; - if (!p || !p.idx) return; // if no probe, or if empty - var row=0; - var col=0; - for (var i=0; i { + var s = this.getMemoryLineAt(row); + var linediv = document.createElement("div"); + linediv.appendChild(document.createTextNode(s)); + return linediv; + } + }); + $(parent).append(this.memorylist.container); + } + + getMemoryLineAt(row : number) : string { + var line = this.dumplines && this.dumplines[row]; + if (line != null) { + var xtra = line.info.join(" "); + return "(" + lpad(line.row,3) + ", " + lpad(line.col,3) + ") " + rpad(line.asm||"",20) + xtra; + } else return ""; + } + refresh() { + this.tick(); + } + tick() { + const isz80 = platform instanceof BaseZ80MachinePlatform || platform instanceof BaseZ80Platform; // TODO? + // cache each line in frame + this.dumplines = {}; + this.redraw((op,addr,col,row,clk) => { + if (isz80) clk >>= 2; + var line = this.dumplines[clk]; + if (line == null) { + line = {op:op, addr:addr, row:row, col:col, asm:null, info:[]}; + this.dumplines[clk] = line; + } + switch (op) { + case ProbeFlags.EXECUTE: + if (platform.disassemble) { + var disasm = platform.disassemble(addr, platform.readAddress.bind(platform)); + line.asm = disasm && disasm.line; + } + break; + default: + var xtra = this.opToString(op, addr); + if (xtra != "") line.info.push(xtra); + break; + } + }); + // TODO: refactor with elsewhere + if (this.memorylist) { + $(this.maindiv).find('[data-index]').each( (i,e) => { + var div = $(e); + var row = parseInt(div.attr('data-index')); + var oldtext = div.text(); + var newtext = this.getMemoryLineAt(row); + if (oldtext != newtext) + div.text(newtext); + }); + } + } +} + /// export class AssetEditorView implements ProjectView, pixed.EditorContext {