mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-26 10:49:17 +00:00
isDebugging() instead of getDebugCallback()
This commit is contained in:
parent
a39bc2344e
commit
527660b121
@ -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();
|
||||
|
@ -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 {
|
||||
|
@ -26,6 +26,9 @@ class MarkdownPlatform implements Platform {
|
||||
isRunning() {
|
||||
return false;
|
||||
}
|
||||
isDebugging() : boolean {
|
||||
return false;
|
||||
}
|
||||
getToolForFilename(fn : string) : string {
|
||||
return "markdown";
|
||||
}
|
||||
|
@ -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),
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<cpuCyclesPerFrame; i++) {
|
||||
if (debugCond && debugCond()) {
|
||||
@ -187,7 +186,6 @@ var AtariVectorPlatform = function(mainElement) {
|
||||
}
|
||||
|
||||
var AtariColorVectorPlatform = function(mainElement) {
|
||||
var self = this;
|
||||
var masterFrequency = 12096000.0;
|
||||
var cpuFrequency = masterFrequency / 8;
|
||||
var nmiFrequency = masterFrequency / 4096 / 12;
|
||||
@ -255,7 +253,7 @@ var AtariColorVectorPlatform = 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 DVGColorStateMachine(bus, video, 0x2000);
|
||||
@ -264,10 +262,10 @@ var AtariColorVectorPlatform = function(mainElement) {
|
||||
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||
setKeyboardFromMap(video, switches, GRAVITAR_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<cpuCyclesPerFrame; i++) {
|
||||
if (debugCond && debugCond()) {
|
||||
@ -340,7 +338,6 @@ var AtariColorVectorPlatform = function(mainElement) {
|
||||
//
|
||||
|
||||
var Z80ColorVectorPlatform = function(mainElement, proto) {
|
||||
var self = this;
|
||||
var cpuFrequency = 4000000.0;
|
||||
var cpuCyclesPerFrame = Math.round(cpuFrequency/60);
|
||||
var cpu, cpuram, dvgram, rom, bus, dvg;
|
||||
@ -398,7 +395,7 @@ var Z80ColorVectorPlatform = function(mainElement, proto) {
|
||||
|
||||
};
|
||||
this.readAddress = bus.read;
|
||||
cpu = self.newCPU(bus);
|
||||
cpu = this.newCPU(bus);
|
||||
// create video/audio
|
||||
video = new VectorVideo(mainElement,1024,1024);
|
||||
dvg = new DVGColorStateMachine(bus, video, 0xa000);
|
||||
@ -407,15 +404,15 @@ var Z80ColorVectorPlatform = function(mainElement, proto) {
|
||||
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||
setKeyboardFromMap(video, switches, GRAVITAR_KEYCODE_MAP);
|
||||
}
|
||||
|
||||
this.advance = function(novideo) {
|
||||
|
||||
this.advance = (novideo) => {
|
||||
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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user