From da087b65d66e4bf9748fd8b14c7f6aba2aca2cf3 Mon Sep 17 00:00:00 2001 From: lesleyrs <19632758+lesleyrs@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:37:10 +0100 Subject: [PATCH] quit on error --- docs/gb/gb.js | 10 +++++----- docs/gb/gb.wasm | Bin 43102 -> 43126 bytes docs/gbc/gb.js | 10 +++++----- docs/gbc/gb.wasm | Bin 46313 -> 46337 bytes gb.c | 2 +- gb.js | 10 +++++----- 6 files changed, 16 insertions(+), 16 deletions(-) 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 731f9a3c77265257a7638a30f75c9cca21eca2a5..dad40d3276d5eb892c2539c1f04b26e587e04303 100755 GIT binary patch delta 3667 zcmZ{ne{9>v6~~W~ZOQs=EAel;iu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>)>f8d}w<5Ga0h!>Q*f&X_DtutLY^OHUQ zaVE9r9^*+3&Q?S8`PoZZv;KQFz2|8;z2|j#Fz24j@qc8fa?Tx-2lJb`C$jQio^Pzu z3&}10*Q%ypxc+o1@fEQG|7_k414;Rhrpo{6d^2RJ3%2RGnvB;}ju)jG`jos@+;P4f zzY}cAn(eb7sjD|co)&y#dFagWjg_7le?LTG{tz0?8aWwmai`Y_H*hgbiuY=G8rr{w z8=);xI6B1Lh7NIg8uu}IG&fQJA2Q5M{P)N2fwB3-6w~}I za-6R3u#6|+WjOL}wN8|JD~H%yr02DA40|g%^yH5#yqE~wi(euwVy_UZ$`wJDAuk#$ zMC{YahU+_Q%=5{sq@)1of@DQ&KjA_xPi#lYbMZ1IiI%~2PlpKi?o?j4RA>fN(kQV`V zW7~d%U70lE-UcIu+gYT@1drkrda_%|vqWcraz&@u(ri5O;LbP75@l)H*0CH`U2foc zMFySkpm1K9f#6k{1YW%rz-zYf_s(qkt~KC0K@W4+Hu%<2JA=LJwxD;tN!|_QqxpOeNiv35M0Y9~ynoh*z;$n)f5(YT;W ZQyKpkPP@ceA { 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 dbf1d852ba20a7fd466e82b7031ea97d2accff69..5eef9a05324aff76989bfeba3d86c2191facdc3e 100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C2waED|kEc@KEkJO>o;Z+H!quX+qr zkisP}{^nH>e~S^}R~i6*m5T2xRDfTd#P>BSyx*#$`&tFuZ(D`!H9QZqv_nVsI+|y8 z>bSl>0qb|^_?_9E0QC*JEYN6#^i4W~RsemoGZItY1}eyGS%v3YbvWN>s05&!%`&J|Jed}ZG{V7npYYo!wHUjMfsW|&t9cCZQ jj7G?Hq^0pFBeI1(h8L;d5gcX0G#h3DJbMUVyEFWM?f^3h 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 });