From 627fba2f9c3853fb6b0a51765f793f421e49f8c8 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Fri, 13 Dec 2024 10:32:47 -0600 Subject: [PATCH] Add call to mount file systems before loading game assets --- data/src/GameManager.js | 14 +++++++++----- data/src/emulator.js | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/data/src/GameManager.js b/data/src/GameManager.js index 15c046b..8ca4fd3 100644 --- a/data/src/GameManager.js +++ b/data/src/GameManager.js @@ -31,14 +31,9 @@ class EJS_GameManager { getFrameNum: this.Module.cwrap('get_current_frame_count', 'number', ['']), setVSync: this.Module.cwrap('set_vsync', 'null', ['number']) } - this.mkdir("/data"); - this.mkdir("/data/saves"); this.writeFile("/home/web_user/retroarch/userdata/retroarch.cfg", this.getRetroArchCfg()); - this.FS.mount(this.FS.filesystems.IDBFS, {autoPersist: true}, '/data/saves'); - //this.FS.syncfs(true, () => {}); - this.writeConfigFile(); this.initShaders(); @@ -47,6 +42,7 @@ class EJS_GameManager { this.functions.saveSaveFiles(); setTimeout(() => { try { + this.FS.unmount('/data/saves'); this.Module.abort(); } catch(e) { console.warn(e); @@ -54,6 +50,14 @@ class EJS_GameManager { }, 1000); }) } + mountFileSystems() { + return new Promise(async resolve => { + this.mkdir("/data"); + this.mkdir("/data/saves"); + this.FS.mount(this.FS.filesystems.IDBFS, {autoPersist: true}, '/data/saves'); + this.FS.syncfs(true, resolve); + }); + } writeConfigFile() { if (!this.EJS.defaultCoreOpts.file || !this.EJS.defaultCoreOpts.settings) { return; diff --git a/data/src/emulator.js b/data/src/emulator.js index 836f60b..507ee0e 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -980,6 +980,7 @@ class EmulatorJS { (async () => { this.gameManager = new window.EJS_GameManager(this.Module, this); await this.gameManager.loadExternalFiles(); + await this.gameManager.mountFileSystems(); if (this.getCore() === "ppsspp") { await this.gameManager.loadPpssppAssets(); }