made EmuHalt class for NES trap

This commit is contained in:
Steven Hugg 2019-03-20 20:45:03 -04:00
parent f41d181aab
commit 7e2bf32a6f
5 changed files with 30 additions and 21 deletions

View File

@ -91,12 +91,13 @@ TODO:
- profiler restarts when paused
- it's pretty easy to add a new file named like a library file (bcd.c)
- put globals into view/controller objects
- cr/lf in files
- cr/lf in uploaded files?
- upload binary files doesn't do what's expected, changing pulldown and whatnot
- chrome autostart audio: https://github.com/processing/p5.js-sound/issues/249
- show player controls for each platform, allow touch support, navigator.getGamepads
- better undo/diff for mistakes?
- get rid of "illegal PC" instruction, replace with status msg
- ide bug/feature visualizer for sponsors

View File

@ -215,6 +215,9 @@ export class RAM {
}
}
export class EmuHalt extends Error {
}
export class AnimationTimer {
callback;
@ -234,7 +237,15 @@ export class AnimationTimer {
}
scheduleFrame(msec:number) {
var fn = () => { this.nextFrame(); }
var fn = () => {
try {
this.nextFrame();
} catch (e) {
this.running = false;
this.pulsing = false;
throw e;
}
}
if (this.useReqAnimFrame)
window.requestAnimationFrame(fn);
else

View File

@ -662,6 +662,7 @@ export class PixelTextDataNode extends PixelNode {
}
updateRight() {
var datastr = this.text.substring(this.start, this.end);
datastr = convertToHexStatements(datastr); // TODO?
var words = parseHexWords(datastr);
this.output = new Uint8Array(words); // TODO: 16/32?
}

View File

@ -1,7 +1,7 @@
"use strict";
import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, cpuStateToLongString_6502, getToolForFilename_6502, dumpStackToString, ProfilerOutput } from "../baseplatform";
import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM, KeyFlags } from "../emu";
import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM, KeyFlags, EmuHalt } from "../emu";
import { hex, lpad, lzgmini, byteArrayToString } from "../util";
import { CodeAnalyzer_nes } from "../analysis";
import { SampleAudio } from "../audio";
@ -126,9 +126,8 @@ const _JSNESPlatform = function(mainElement) {
//nes.ppu.clipToTvSize = false;
nes.stop = () => {
// TODO: trigger breakpoint
this.pause();
console.log(nes.cpu.toJSON());
throw ("CPU STOPPED @ PC $" + hex(nes.cpu.REG_PC));
throw new EmuHalt("CPU STOPPED @ PC $" + hex(nes.cpu.REG_PC));
};
// insert debug hook
nes.cpu._emulate = nes.cpu.emulate;
@ -148,14 +147,7 @@ const _JSNESPlatform = function(mainElement) {
}
advance(novideo : boolean) {
try {
nes.frame();
} catch (e) {
// TODO?
alert(e);
console.log(e);
this.breakpointHit(this.debugClock);
}
nes.frame();
}
updateDebugViews() {

View File

@ -8,7 +8,7 @@ import { CodeProject } from "./project";
import { WorkerResult, WorkerOutput, VerilogOutput, SourceFile, WorkerError, FileData } from "./workertypes";
import { ProjectWindows } from "./windows";
import { Platform, Preset, DebugSymbols, DebugEvalCondition } from "./baseplatform";
import { PLATFORMS } from "./emu";
import { PLATFORMS, EmuHalt } from "./emu";
import * as Views from "./views";
import { createNewPersistentStore } from "./store";
import { getFilenameForPath, getFilenamePrefix, highlightDifferences, invertMap, byteArrayToString, compressLZG,
@ -1292,13 +1292,17 @@ var qs = (function (a : string[]) {
function installErrorHandler() {
if (typeof window.onerror == "object") {
window.onerror = function (msgevent, url, line, col, error) {
console.log(msgevent, url, line, col);
console.log(error);
ga('send', 'exception', {
'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error,
'exFatal': true
});
alert(msgevent+"");
var msgstr = msgevent+"";
console.log(msgevent, url, line, col, error);
if (error instanceof EmuHalt || msgstr.indexOf("CPU STOP") >= 0) {
showErrorAlert([ {msg:msgstr, line:0} ]);
} else {
ga('send', 'exception', {
'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error,
'exFatal': true
});
alert(msgevent+"");
}
_pause();
};
}