mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Make breakpoints behave better
This commit is contained in:
parent
b4d6e95ec2
commit
e83fdd999e
@ -114,6 +114,7 @@ export class Apple2 implements Restorable<State>, DebuggerContainer {
|
||||
* `runAnimationFrame` will be non-null.
|
||||
*/
|
||||
run() {
|
||||
this.paused = false;
|
||||
if (this.runTimer || this.runAnimationFrame) {
|
||||
return; // already running
|
||||
}
|
||||
@ -170,6 +171,7 @@ export class Apple2 implements Restorable<State>, DebuggerContainer {
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.paused = true;
|
||||
if (this.runTimer) {
|
||||
clearInterval(this.runTimer);
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ export default class SmartPort implements Card, Restorable<SmartPortState> {
|
||||
debug('DumbPort card');
|
||||
} else {
|
||||
debug('SmartPort card');
|
||||
this.rom = smartPortRom;
|
||||
}
|
||||
this.rom = smartPortRom;
|
||||
}
|
||||
|
||||
private decodeDisk(unit: number, disk: BlockDevice) {
|
||||
|
@ -1012,7 +1012,9 @@ export default class CPU6502 {
|
||||
this.sync = false;
|
||||
op.op(op.modeFn);
|
||||
|
||||
cb?.(this);
|
||||
if (cb?.(this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,7 +1038,9 @@ export default class CPU6502 {
|
||||
this.sync = false;
|
||||
op.op(op.modeFn);
|
||||
|
||||
cb?.(this);
|
||||
if (cb?.(this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,19 +33,28 @@ export default class Debugger {
|
||||
if (this.breakpoints.get(info.pc)?.(info)) {
|
||||
debug('breakpoint', this.printDebugInfo(info));
|
||||
this.container.stop();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (this.verbose) {
|
||||
debug(this.printDebugInfo(info));
|
||||
} else {
|
||||
this.trace.push(info);
|
||||
if (this.trace.length > this.maxTrace) {
|
||||
this.trace.shift();
|
||||
}
|
||||
this.updateTrace(info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
break = () => {
|
||||
this.container.stop();
|
||||
}
|
||||
|
||||
step = () => {
|
||||
this.cpu.step(() => {
|
||||
const info = this.cpu.getDebugInfo();
|
||||
debug(this.printDebugInfo(info));
|
||||
this.updateTrace(info);
|
||||
});
|
||||
}
|
||||
|
||||
continue = () => {
|
||||
this.container.run();
|
||||
}
|
||||
@ -121,10 +130,8 @@ export default class Debugger {
|
||||
if (debugInfo === undefined) {
|
||||
debugInfo = this.cpu.getDebugInfo();
|
||||
}
|
||||
const { pc, ar, xr, yr, sr, sp } = debugInfo;
|
||||
const { ar, xr, yr, sr, sp } = debugInfo;
|
||||
return [
|
||||
toHex(pc, 4),
|
||||
'- ',
|
||||
' A=' + toHex(ar),
|
||||
' X=' + toHex(xr),
|
||||
' Y=' + toHex(yr),
|
||||
@ -180,6 +187,13 @@ export default class Debugger {
|
||||
return results;
|
||||
}
|
||||
|
||||
private updateTrace(info: DebugInfo) {
|
||||
this.trace.push(info);
|
||||
if (this.trace.length > this.maxTrace) {
|
||||
this.trace.shift();
|
||||
}
|
||||
}
|
||||
|
||||
private padWithSymbol(pc: word): string {
|
||||
const padding = ' ';
|
||||
const symbol = this.symbols[pc];
|
||||
@ -233,7 +247,7 @@ export default class Debugger {
|
||||
if (off > 127) {
|
||||
off -= 256;
|
||||
}
|
||||
pc += off + 1;
|
||||
pc += off + 2;
|
||||
result += '' + toHexOrSymbol(pc, 4) + ' (' + off + ')';
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user