import { ISX } from /**/"./ISX.js"; // Debug mode UI manager class Debugger { ///////////////////////////// Static Methods ////////////////////////////// // Data type conversions static F32 = new Float32Array(1); static U32 = new Uint32Array(this.F32.buffer); // Reinterpret a float32 as a u32 static fxi(x) { this.F32[0] = x; return this.U32[0]; } // Process file data as ISM static isx(data) { return new ISX(data); } // Reinterpret a u32 as a float32 static ixf(x) { this.U32[0] = x; return this.F32[0]; } // Compute the number of lines scrolled by a WheelEvent static linesScrolled(e, lineHeight, pageLines, delta) { let ret = { delta: delta, lines: 0 }; // No scrolling occurred if (e.deltaY == 0); // Scrolling by pixel else if (e.deltaMode == WheelEvent.DOM_DELTA_PIXEL) { ret.delta += e.deltaY; ret.lines = Math.sign(ret.delta) * Math.floor(Math.abs(ret.delta) / lineHeight); ret.delta -= ret.lines * lineHeight; } // Scrolling by line else if (e.deltaMode == WheelEvent.DOM_DELTA_LINE) ret.lines = Math.trunc(e.deltaY); // Scrolling by page else if (e.deltaMode == WheelEvent.DOM_DELTA_PAGE) ret.lines = Math.trunc(e.deltaY) * pageLines; // Unknown scrolling mode else ret.lines = 3 * Math.sign(e.deltaY); return ret; } ///////////////////////// Initialization Methods ////////////////////////// constructor(app, sim, index) { // Configure instance fields this.app = app; this.core = app.core; this.dasm = app.dasm; this.sim = sim; // Configure debugger windows this.cpu = new Debugger.CPU (this, index); this.memory = new Debugger.Memory(this, index); } ///////////////////////////// Package Methods ///////////////////////////// // Disassembler configuration has changed dasmConfigured() { this.cpu .dasmConfigured(); this.memory.dasmConfigured(); } // Ensure PC is visible in the disassembler followPC(pc = null) { this.cpu.disassembler.followPC(pc); } // Format a number as hexadecimal hex(value, digits = null, decorated = true) { return this.dasm.hex(value, digits, decorated); } } // Register component classes (await import(/**/"./CPU.js" )).register(Debugger); (await import(/**/"./Memory.js")).register(Debugger); export { Debugger };