haltEmulation() instead of EmuHalt
This commit is contained in:
parent
244377e2a6
commit
0e4ed8ce21
|
@ -1934,13 +1934,18 @@ function globalErrorHandler(msgevent) {
|
|||
} else {
|
||||
var err = msgevent.error || msgevent.reason;
|
||||
if (err != null && err instanceof EmuHalt) {
|
||||
setDebugButtonState("pause", "stopped");
|
||||
emulationHalted(err);
|
||||
// TODO: reset platform?
|
||||
haltEmulation(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function haltEmulation(err?: EmuHalt) {
|
||||
console.log("haltEmulation");
|
||||
_pause();
|
||||
emulationHalted(err);
|
||||
// TODO: reset platform?
|
||||
}
|
||||
|
||||
// catch errors
|
||||
function installErrorHandler() {
|
||||
window.addEventListener('error', globalErrorHandler);
|
||||
|
|
|
@ -7,6 +7,8 @@ import { BASICRuntime } from "../common/basic/runtime";
|
|||
import { BASICProgram } from "../common/basic/compiler";
|
||||
import { TeleTypeWithKeyboard } from "../common/teletype";
|
||||
import { lpad } from "../common/util";
|
||||
import { FileData } from "../common/workertypes";
|
||||
import { haltEmulation } from "../ide/ui"; // TODO: make this a callback
|
||||
|
||||
const BASIC_PRESETS = [
|
||||
{ id: 'hello.bas', name: 'Hello' },
|
||||
|
@ -31,6 +33,8 @@ class BASICPlatform implements Platform {
|
|||
tty: TeleTypeWithKeyboard;
|
||||
hotReload: boolean = true;
|
||||
animcount: number = 0;
|
||||
internalFiles : {[path:string] : FileData} = {};
|
||||
transcript: string[];
|
||||
|
||||
constructor(mainElement: HTMLElement) {
|
||||
//super();
|
||||
|
@ -82,6 +86,7 @@ class BASICPlatform implements Platform {
|
|||
// TODO: why null sometimes?
|
||||
this.animcount = 0; // exit advance loop when printing
|
||||
this.tty.print(s);
|
||||
this.transcript.push(s);
|
||||
}
|
||||
this.runtime.resume = this.resume.bind(this);
|
||||
}
|
||||
|
@ -106,6 +111,7 @@ class BASICPlatform implements Platform {
|
|||
this.pause();
|
||||
if (this.runtime.exited) {
|
||||
this.exitmsg();
|
||||
this.didExit();
|
||||
}
|
||||
}
|
||||
this.clock++;
|
||||
|
@ -145,6 +151,7 @@ class BASICPlatform implements Platform {
|
|||
this.tty.clear();
|
||||
this.runtime.reset();
|
||||
this.clock = 0;
|
||||
this.transcript = [];
|
||||
}
|
||||
|
||||
pause(): void {
|
||||
|
@ -289,6 +296,17 @@ class BASICPlatform implements Platform {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
readFile(path: string) : FileData {
|
||||
return this.internalFiles[path];
|
||||
}
|
||||
writeFile(path: string, data: FileData) : boolean {
|
||||
this.internalFiles[path] = data;
|
||||
return true;
|
||||
}
|
||||
didExit() {
|
||||
this.internalFiles['stdout.txt'] = this.transcript.join("");
|
||||
haltEmulation();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -4,9 +4,9 @@ import { EmuHalt, PLATFORMS } from "../common/emu";
|
|||
import { Devel6502 } from "../machine/devel";
|
||||
import { Base6502MachinePlatform } from "../common/baseplatform";
|
||||
import { SerialIOInterface } from "../common/devices";
|
||||
import { convertDataToUint8Array, hex } from "../common/util";
|
||||
import { byteArrayToString, convertDataToUint8Array, hex } from "../common/util";
|
||||
import { TeleType } from "../common/teletype";
|
||||
import { emulationHalted, loadScript } from "../ide/ui";
|
||||
import { haltEmulation, loadScript } from "../ide/ui";
|
||||
|
||||
var DEVEL_6502_PRESETS = [
|
||||
{id:'hello.dasm', name:'Hello World (ASM)'},
|
||||
|
@ -144,8 +144,9 @@ class Devel6502Platform extends Base6502MachinePlatform<Devel6502> implements Pl
|
|||
|
||||
advance(novideo: boolean) {
|
||||
if (this.isBlocked()) {
|
||||
this.internalFiles['serialout.dat'] = new Uint8Array(this.serial.outputBytes);
|
||||
throw new EmuHalt(null); // TODO: throws nasty exception
|
||||
this.internalFiles['serialout.dat'] = byteArrayToString(this.serial.outputBytes);
|
||||
haltEmulation();
|
||||
return 0;
|
||||
}
|
||||
return super.advance(novideo);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
|
|||
//this.nes.ppu.clipToTvSize = false;
|
||||
this.nes.stop = () => {
|
||||
this.haltAndCatchFire("Illegal instruction");
|
||||
throw new EmuHalt("CPU STOPPED");
|
||||
throw new EmuHalt("CPU STOPPED"); //TODO: haltEmulation()
|
||||
};
|
||||
// insert debug hook
|
||||
this.nes.cpu._emulate = this.nes.cpu.emulate;
|
||||
|
|
Loading…
Reference in New Issue