diff --git a/docs/gb/gb.js b/docs/gb/gb.js index 4c49876..b8f34b8 100644 --- a/docs/gb/gb.js +++ b/docs/gb/gb.js @@ -273,7 +273,7 @@ class GameBoy { window.addEventListener('keydown', this.keyDown); window.addEventListener('keyup', this.keyUp); - this.wasm.instance.exports.main() && this.exit(); + this.wasm.instance.exports.main() && this.quit(); const memory = new Uint16Array(this.wasm.instance.exports.memory.buffer); const imageData = this.ctx.createImageData(canvas.width, canvas.height); @@ -281,7 +281,7 @@ class GameBoy { const update = () => { if (this.quit_request) { - this.quit = true; + this.exit = true; return; } @@ -349,7 +349,7 @@ class GameBoy { update(); } - exit() { + quit() { this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height); this.quit_request = true; } @@ -384,7 +384,7 @@ class GameBoy { } #await_quit(romBytes, savBytes) { - if (this.quit) { + if (this.exit) { this.#reset(romBytes, savBytes); } else { // NOTE: is there no better way to do this? 10 is magic @@ -418,7 +418,7 @@ class GameBoy { this.keyDown = undefined; this.keyUp = undefined; this.quit_request = undefined; - this.quit = undefined; + this.exit = undefined; this.fetching = undefined; this.startSec = undefined; this.start({ wasmPath: "gb.wasm", canvasId: "gb", rom: romBytes, sav: savBytes }); diff --git a/docs/gb/gb.wasm b/docs/gb/gb.wasm index 731f9a3..dad40d3 100755 Binary files a/docs/gb/gb.wasm and b/docs/gb/gb.wasm differ diff --git a/docs/gbc/gb.js b/docs/gbc/gb.js index 4c49876..b8f34b8 100644 --- a/docs/gbc/gb.js +++ b/docs/gbc/gb.js @@ -273,7 +273,7 @@ class GameBoy { window.addEventListener('keydown', this.keyDown); window.addEventListener('keyup', this.keyUp); - this.wasm.instance.exports.main() && this.exit(); + this.wasm.instance.exports.main() && this.quit(); const memory = new Uint16Array(this.wasm.instance.exports.memory.buffer); const imageData = this.ctx.createImageData(canvas.width, canvas.height); @@ -281,7 +281,7 @@ class GameBoy { const update = () => { if (this.quit_request) { - this.quit = true; + this.exit = true; return; } @@ -349,7 +349,7 @@ class GameBoy { update(); } - exit() { + quit() { this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height); this.quit_request = true; } @@ -384,7 +384,7 @@ class GameBoy { } #await_quit(romBytes, savBytes) { - if (this.quit) { + if (this.exit) { this.#reset(romBytes, savBytes); } else { // NOTE: is there no better way to do this? 10 is magic @@ -418,7 +418,7 @@ class GameBoy { this.keyDown = undefined; this.keyUp = undefined; this.quit_request = undefined; - this.quit = undefined; + this.exit = undefined; this.fetching = undefined; this.startSec = undefined; this.start({ wasmPath: "gb.wasm", canvasId: "gb", rom: romBytes, sav: savBytes }); diff --git a/docs/gbc/gb.wasm b/docs/gbc/gb.wasm index dbf1d85..5eef9a0 100755 Binary files a/docs/gbc/gb.wasm and b/docs/gbc/gb.wasm differ diff --git a/gb.c b/gb.c index 09e0229..4953ac2 100644 --- a/gb.c +++ b/gb.c @@ -95,7 +95,6 @@ void gb_error(struct gb_s *gb, const enum gb_error_e gb_err, "HALT FOREVER"}; uint8_t instr_byte = __gb_read(gb, addr); - // TODO: see what happens on a real error, can call this.quit if needed save(); if (addr >= 0x4000 && addr < 0x8000) { @@ -116,6 +115,7 @@ void gb_error(struct gb_s *gb, const enum gb_error_e gb_err, } alert("Error: check browser console"); + quit(); } #if ENABLE_LCD diff --git a/gb.js b/gb.js index 4c49876..b8f34b8 100644 --- a/gb.js +++ b/gb.js @@ -273,7 +273,7 @@ class GameBoy { window.addEventListener('keydown', this.keyDown); window.addEventListener('keyup', this.keyUp); - this.wasm.instance.exports.main() && this.exit(); + this.wasm.instance.exports.main() && this.quit(); const memory = new Uint16Array(this.wasm.instance.exports.memory.buffer); const imageData = this.ctx.createImageData(canvas.width, canvas.height); @@ -281,7 +281,7 @@ class GameBoy { const update = () => { if (this.quit_request) { - this.quit = true; + this.exit = true; return; } @@ -349,7 +349,7 @@ class GameBoy { update(); } - exit() { + quit() { this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height); this.quit_request = true; } @@ -384,7 +384,7 @@ class GameBoy { } #await_quit(romBytes, savBytes) { - if (this.quit) { + if (this.exit) { this.#reset(romBytes, savBytes); } else { // NOTE: is there no better way to do this? 10 is magic @@ -418,7 +418,7 @@ class GameBoy { this.keyDown = undefined; this.keyUp = undefined; this.quit_request = undefined; - this.quit = undefined; + this.exit = undefined; this.fetching = undefined; this.startSec = undefined; this.start({ wasmPath: "gb.wasm", canvasId: "gb", rom: romBytes, sav: savBytes });