1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-02-19 07:30:55 +00:00

added message when emulation stopped (EmuHalt)

This commit is contained in:
Steven Hugg 2019-12-01 11:47:42 -06:00
parent b673ffc1c9
commit cc0cb584a8
4 changed files with 10 additions and 6 deletions

View File

@ -143,7 +143,7 @@ export interface MemoryBus {
export type DebugCondition = () => boolean; export type DebugCondition = () => boolean;
export type DebugEvalCondition = (c:CpuState) => boolean; export type DebugEvalCondition = (c:CpuState) => boolean;
export type BreakpointCallback = (s:EmuState) => void; export type BreakpointCallback = (s:EmuState, msg?:string) => void;
// for composite breakpoints w/ single debug function // for composite breakpoints w/ single debug function
export class BreakpointList { export class BreakpointList {
id2bp : {[id:string] : Breakpoint} = {}; id2bp : {[id:string] : Breakpoint} = {};
@ -283,16 +283,19 @@ export abstract class BaseDebugPlatform extends BasePlatform {
wasBreakpointHit() : boolean { wasBreakpointHit() : boolean {
return this.debugBreakState != null; return this.debugBreakState != null;
} }
breakpointHit(targetClock : number) { breakpointHit(targetClock : number, reason? : string) {
console.log(this.debugTargetClock, targetClock, this.debugClock, this.isStable()); console.log(this.debugTargetClock, targetClock, this.debugClock, this.isStable());
this.debugTargetClock = targetClock; this.debugTargetClock = targetClock;
this.debugBreakState = this.saveState(); this.debugBreakState = this.saveState();
console.log("Breakpoint at clk", this.debugClock, "PC", this.debugBreakState.c.PC.toString(16)); console.log("Breakpoint at clk", this.debugClock, "PC", this.debugBreakState.c.PC.toString(16));
this.pause(); this.pause();
if (this.onBreakpointHit) { if (this.onBreakpointHit) {
this.onBreakpointHit(this.debugBreakState); this.onBreakpointHit(this.debugBreakState, reason);
} }
} }
haltAndCatchFire(reason : string) {
this.breakpointHit(this.debugClock, reason);
}
runEval(evalfunc : DebugEvalCondition) { runEval(evalfunc : DebugEvalCondition) {
this.setDebugCondition( () => { this.setDebugCondition( () => {
if (++this.debugClock >= this.debugTargetClock && this.isStable()) { if (++this.debugClock >= this.debugTargetClock && this.isStable()) {

View File

@ -251,7 +251,7 @@ export class AnimationTimer {
} catch (e) { } catch (e) {
this.running = false; this.running = false;
this.pulsing = false; this.pulsing = false;
throw e; // TODO: throw EmuHalt hides stack trace throw e;
} }
} }
if (this.useReqAnimFrame) if (this.useReqAnimFrame)

View File

@ -1123,9 +1123,10 @@ function uiDebugCallback(state: EmuState) {
} }
function setupDebugCallback(btnid? : string) { function setupDebugCallback(btnid? : string) {
if (platform.setupDebug) platform.setupDebug((state:EmuState) => { if (platform.setupDebug) platform.setupDebug((state:EmuState, msg:string) => {
uiDebugCallback(state); uiDebugCallback(state);
setDebugButtonState(btnid||"pause", "stopped"); setDebugButtonState(btnid||"pause", "stopped");
msg && showErrorAlert([{msg:"STOPPED: " + msg, line:0}]);
}); });
} }

View File

@ -131,7 +131,7 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
//this.nes.ppu.showSpr0Hit = true; //this.nes.ppu.showSpr0Hit = true;
//this.nes.ppu.clipToTvSize = false; //this.nes.ppu.clipToTvSize = false;
this.nes.stop = () => { this.nes.stop = () => {
this.breakpointHit(this.debugClock); this.haltAndCatchFire("Illegal instruction");
throw new EmuHalt("CPU STOPPED"); throw new EmuHalt("CPU STOPPED");
}; };
// insert debug hook // insert debug hook