Compile (beta) thread cores

This commit is contained in:
Ethan O'Brien 2023-08-26 11:49:05 -04:00
parent 3ad97e7b41
commit 9932460301
10 changed files with 8 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,5 @@
class EmulatorJS {
version = 8; //Increase by 1 when cores are updated
version = 9; //Increase by 1 when cores are updated
getCore(generic) {
const core = this.config.system;
/*todo:
@ -589,6 +589,12 @@ class EmulatorJS {
}
downloadGameCore() {
this.textElem.innerText = this.localization("Download Game Core");
if (this.config.threads && ((typeof window.SharedArrayBuffer) !== "function")) {
this.textElem.innerText = this.localization('Error for site owner')+"\n"+this.localization("Check console");
this.textElem.style.color = "red";
console.warn("Threads is set to true, but the SharedArrayBuffer function is not exposed. Threads requires 2 headers to be set when sending you html page. See https://stackoverflow.com/a/68630724");
return;
}
const gotCore = (data) => {
this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Core")).then((data) => {
let js, thread, wasm;
@ -627,12 +633,6 @@ class EmulatorJS {
})
}
initGameCore(js, wasm, thread) {
if (thread && ((typeof window.SharedArrayBuffer) !== "function")) {
this.textElem.innerText = this.localization('Error for site owner')+"\n"+this.localization("Check console");
this.textElem.style.color = "red";
console.warn("The "+this.getCore()+" core requires threads, but threads requires 2 headers to be set when sending you html page. See https://stackoverflow.com/a/68630724");
return;
}
this.initModule(wasm, thread);
let script = this.createElement("script");
script.src = URL.createObjectURL(new Blob([js], {type: "application/javascript"}));

View file

@ -1,6 +1,6 @@
(async function() {
const folderPath = (path) => path.substring(0, path.length - path.split('/').pop().length);
const scriptPath = (typeof window.EJS_pathtodata === "string") ? window.EJS_pathtodata : folderPath((new URL(document.currentScript.src)).pathname);
let scriptPath = (typeof window.EJS_pathtodata === "string") ? window.EJS_pathtodata : folderPath((new URL(document.currentScript.src)).pathname);
if (!scriptPath.endsWith('/')) scriptPath+='/';
//console.log(scriptPath);
function loadScript(file) {