MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / downloadGameCore

Method downloadGameCore

data/src/emulator.js:524–638  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

522 this.failedToStart = true;
523 }
524 downloadGameCore() {
525 this.textElem.innerText = this.localization("Download Game Core");
526 if (!this.config.threads && this.requiresThreads(this.getCore())) {
527 this.startGameError(this.localization("Error for site owner") + "\n" + this.localization("Check console"));
528 console.warn("This core requires threads, but EJS_threads is not set!");
529 return;
530 }
531 if (!this.supportsWebgl2 && this.requiresWebGL2(this.getCore())) {
532 this.startGameError(this.localization("Outdated graphics driver"));
533 return;
534 }
535 if (this.config.threads && typeof window.SharedArrayBuffer !== "function") {
536 this.startGameError(this.localization("Error for site owner") + "\n" + this.localization("Check console"));
537 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");
538 return;
539 }
540 const gotCore = (data) => {
541 this.defaultCoreOpts = {};
542 this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Core")).then((data) => {
543 let js, thread, wasm;
544 for (let k in data) {
545 if (k.endsWith(".wasm")) {
546 wasm = data[k];
547 } else if (k.endsWith(".worker.js")) {
548 thread = data[k];
549 } else if (k.endsWith(".js")) {
550 js = data[k];
551 } else if (k === "build.json") {
552 this.checkCoreCompatibility(JSON.parse(new TextDecoder().decode(data[k])));
553 } else if (k === "core.json") {
554 let core = JSON.parse(new TextDecoder().decode(data[k]));
555 this.extensions = core.extensions;
556 this.coreName = core.name;
557 this.repository = core.repo;
558 this.defaultCoreOpts = core.options;
559 this.enableMouseLock = core.options.supportsMouse;
560 this.retroarchOpts = core.retroarchOpts;
561 this.saveFileExt = core.save;
562 } else if (k === "license.txt") {
563 this.license = new TextDecoder().decode(data[k]);
564 }
565 }
566
567 if (this.saveFileExt === false) {
568 this.elements.bottomBar.saveSavFiles[0].style.display = "none";
569 this.elements.bottomBar.loadSavFiles[0].style.display = "none";
570 }
571
572 this.initGameCore(js, wasm, thread);
573 });
574 }
575 const report = "cores/reports/" + this.getCore() + ".json";
576 this.downloadFile(report, null, false, { responseType: "text", method: "GET" }).then(async rep => {
577 if (rep === -1 || typeof rep === "string" || typeof rep.data === "string") {
578 rep = {};
579 } else {
580 rep = rep.data;
581 }

Callers 1

startButtonClickedMethod · 0.95

Calls 9

localizationMethod · 0.95
requiresThreadsMethod · 0.95
getCoreMethod · 0.95
startGameErrorMethod · 0.95
requiresWebGL2Method · 0.95
downloadFileMethod · 0.95
preGetSettingMethod · 0.95
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected