diff --git a/src/baseplatform.ts b/src/baseplatform.ts index 8b51b099..4adcc1cc 100644 --- a/src/baseplatform.ts +++ b/src/baseplatform.ts @@ -21,7 +21,7 @@ export interface CpuState { o?:number;/*opcode*/ SP?:number /* - A:number, X:number, Y:number, SP:number, R:boolean, + A:number, X:number, Y:number, SP:number, R:boolean, N,V,D,Z,C:boolean*/ }; export interface EmuState { @@ -44,7 +44,7 @@ export type AddrSymbolMap = {[address:number]:string}; export class DebugSymbols { symbolmap : SymbolMap; // symbol -> address addr2symbol : AddrSymbolMap; // address -> symbol - + constructor(symbolmap : SymbolMap) { this.symbolmap = symbolmap; this.addr2symbol = invertMap(symbolmap); @@ -68,13 +68,14 @@ export interface Platform { saveState?() : EmuState; loadControlsState?(state : EmuControlsState) : void; saveControlsState?() : EmuControlsState; - + inspect?(ident:string) : string; disassemble?(addr:number, readfn:(addr:number)=>number) : DisasmLine; readAddress?(addr:number) : number; setFrameRate?(fps:number) : void; getFrameRate?() : number; + isDebugging() : boolean; setupDebug?(debugfn : (state)=>void) : void; clearDebug?() : void; step?() : void; @@ -83,8 +84,7 @@ export interface Platform { runUntilReturn?() : void; stepBack?() : void; runEval?(evalfunc/* : DebugEvalCondition*/) : void; - getDebugCallback?() : any; // TODO - + getOpcodeMetadata?(opcode:number, offset:number) : OpcodeMetadata; //TODO getSP?() : number; getOriginPC?() : number; @@ -92,10 +92,10 @@ export interface Platform { getDebugCategories?() : string[]; getDebugInfo?(category:string, state:EmuState) : string; - + setRecorder?(recorder : EmuRecorder) : void; advance?(novideo? : boolean) : void; - + debugSymbols? : DebugSymbols; } @@ -157,6 +157,9 @@ export abstract class BaseDebugPlatform extends BasePlatform { getDebugCallback() : DebugCondition { return this.debugCondition; } + isDebugging() : boolean { + return this.debugCondition != null; + } setupDebug(callback : BreakpointCallback) { this.onBreakpointHit = callback; } @@ -323,7 +326,7 @@ export abstract class Base6502Platform extends BaseFrameBasedPlatform { } getToolForFilename = getToolForFilename_6502; getDefaultExtension() { return ".a"; }; - + getDebugCategories() { return ['CPU','ZPRAM','Stack']; } @@ -645,7 +648,7 @@ export abstract class BaseMAMEPlatform { js_lua_string; onBreakpointHit; mainElement; - + constructor(mainElement) { this.mainElement = mainElement; } @@ -876,6 +879,9 @@ export abstract class BaseMAMEPlatform { getDebugCallback() { return this.onBreakpointHit;// TODO? } + isDebugging() : boolean { + return this.onBreakpointHit != null; + } setupDebug(callback) { if (this.loaded) { // TODO? this.initlua(); diff --git a/src/codemirror/bataribasic.js b/src/codemirror/bataribasic.js index 461c3c4b..db5a04b8 100644 --- a/src/codemirror/bataribasic.js +++ b/src/codemirror/bataribasic.js @@ -79,7 +79,6 @@ CodeMirror.defineMode('bataribasic', function(_config, parserConfig) { if (style) return style; - console.log(w, numbers.test(w)); if (numbers.test(w)) { return 'number'; } else { diff --git a/src/platform/markdown.ts b/src/platform/markdown.ts index a6e2c553..6f196078 100644 --- a/src/platform/markdown.ts +++ b/src/platform/markdown.ts @@ -26,6 +26,9 @@ class MarkdownPlatform implements Platform { isRunning() { return false; } + isDebugging() : boolean { + return false; + } getToolForFilename(fn : string) : string { return "markdown"; } diff --git a/src/platform/sound_konami.ts b/src/platform/sound_konami.ts index 9d850c0f..8218f8d1 100644 --- a/src/platform/sound_konami.ts +++ b/src/platform/sound_konami.ts @@ -11,7 +11,6 @@ var KONAMISOUND_PRESETS = [ ]; var KonamiSoundPlatform = function(mainElement) { - var self = this; this.__proto__ = new (BaseZ80Platform as any)(); var cpu, ram, rom, membus, iobus; @@ -91,10 +90,10 @@ var KonamiSoundPlatform = function(mainElement) { */ } }); - timer = new AnimationTimer(60, function() { - if (!self.isRunning()) + timer = new AnimationTimer(60, () => { + if (!this.isRunning()) return; - var debugCond = self.getDebugCallback(); + var debugCond = this.getDebugCallback(); var targetTstates = cpu.getTstates() + cpuCyclesPerFrame; if (debugCond) { while (cpu.getTstates() < targetTstates) { @@ -118,7 +117,7 @@ var KonamiSoundPlatform = function(mainElement) { } this.saveState = function() { return { - c:self.getCPUState(), + c:this.getCPUState(), b:ram.mem.slice(0), }; } diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index bb75406b..dee4ce63 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -132,6 +132,9 @@ class VCSPlatform extends BasePlatform { } Javatari.room.speaker.mute(); } + isDebugging() : boolean { + return Javatari.room.console.onBreakpointHit != null; + } clearDebug() { this.lastDebugState = null; Javatari.room.console.disableDebug(); @@ -160,7 +163,8 @@ class VCSPlatform extends BasePlatform { var ofs = state.ca.bo || 0; if (state.ca.fo && (state.c.PC & 0xfff) >= 2048) ofs = state.ca.fo; // 3E/3F fixed-slice formats - state.c.EPC = state.c.PC + ofs; // ofs = effective PC for ROM + // TODO: for batari BASIC + state.c.EPC = state.c.PC + ofs; // EPC = effective PC for ROM } loadState(state) { return Javatari.room.console.loadState(state); diff --git a/src/platform/vector.ts b/src/platform/vector.ts index 4664d4dc..85b12178 100644 --- a/src/platform/vector.ts +++ b/src/platform/vector.ts @@ -53,7 +53,6 @@ function newPOKEYAudio() { } var AtariVectorPlatform = function(mainElement) { - var self = this; var XTAL = 12096000; var cpuFrequency = XTAL/8; var cpuCyclesPer3khz = Math.round(cpuFrequency/(XTAL/4096)); // ~3 Khz @@ -100,7 +99,7 @@ var AtariVectorPlatform = function(mainElement) { }; this.readAddress = bus.read; - cpu = self.newCPU(bus); + cpu = this.newCPU(bus); // create video/audio video = new VectorVideo(mainElement,1024,1024); dvg = new DVGBWStateMachine(bus, video, 0x4000); @@ -109,10 +108,10 @@ var AtariVectorPlatform = function(mainElement) { timer = new AnimationTimer(60, this.nextFrame.bind(this)); setKeyboardFromMap(video, switches, ASTEROIDS_KEYCODE_MAP); } - - this.advance = function(novideo) { + + this.advance = (novideo) => { if (!novideo) video.clear(); - var debugCond = self.getDebugCallback(); + var debugCond = this.getDebugCallback(); clock = 0; for (var i=0; i { if (!novideo) video.clear(); - var debugCond = self.getDebugCallback(); + var debugCond = this.getDebugCallback(); clock = 0; for (var i=0; i { if (!novideo) video.clear(); - self.runCPU(cpu, cpuCyclesPerFrame); + this.runCPU(cpu, cpuCyclesPerFrame); cpu.requestInterrupt(); switches[0xf] = (switches[0xf] + 1) & 0x3; if (--switches[0xe] <= 0) { console.log("WATCHDOG FIRED"); // TODO: alert on video - self.reset(); // watchdog reset + this.reset(); // watchdog reset } } @@ -472,7 +469,6 @@ var Z80ColorVectorPlatform = function(mainElement, proto) { // DIGITAL VIDEO GENERATOR var DVGBWStateMachine = function(bus, video, bofs) { - var self = this; var pc = 0; var x = 0; var y = 0; @@ -583,7 +579,6 @@ var DVGBWStateMachine = function(bus, video, bofs) { } var DVGColorStateMachine = function(bus, video, bofs) { - var self = this; var pc = 0; var x = 0; var y = 0; diff --git a/src/views.ts b/src/views.ts index 27fd1808..01d6d62f 100644 --- a/src/views.ts +++ b/src/views.ts @@ -529,15 +529,11 @@ export class ListingView extends DisassemblerView implements ProjectView { this.refreshListing(); if (!this.assemblyfile) return; // TODO? var state = lastDebugState || platform.saveState(); - var pc = state.c ? (state.c.PC || state.c.EPC) : 0; + var pc = state.c ? (state.c.EPC || state.c.PC) : 0; var asmtext = this.assemblyfile.text; var disasmview = this.getDisasmView(); - if (platform_id == 'base_z80') { // TODO - asmtext = asmtext.replace(/[ ]+\d+\s+;.+\n/g, ''); - asmtext = asmtext.replace(/[ ]+\d+\s+.area .+\n/g, ''); - } disasmview.setValue(asmtext); - var debugging = platform.getDebugCallback && platform.getDebugCallback(); + var debugging = platform.isDebugging && platform.isDebugging(); var findPC = debugging ? pc : -1; if (findPC >= 0 && this.assemblyfile) { var lineno = this.assemblyfile.findLineForOffset(findPC, 15);