diff --git a/backend/config/config_manager.py b/backend/config/config_manager.py index e1a7b5be4..b7712bc03 100644 --- a/backend/config/config_manager.py +++ b/backend/config/config_manager.py @@ -59,6 +59,7 @@ class Config: FIRMWARE_FOLDER_NAME: str HIGH_PRIO_STRUCTURE_PATH: str EJS_DEBUG: bool + EJS_CACHE_LIMIT: int | None EJS_SETTINGS: dict[str, EjsOption] # core_name -> EjsOption EJS_CONTROLS: dict[str, EjsControls] # core_name -> EjsControls @@ -169,6 +170,9 @@ class ConfigManager: self._raw_config, "filesystem.firmware_folder", "bios" ), EJS_DEBUG=pydash.get(self._raw_config, "emulatorjs.debug", False), + EJS_CACHE_LIMIT=pydash.get( + self._raw_config, "emulatorjs.cache_limit", None + ), EJS_SETTINGS=pydash.get(self._raw_config, "emulatorjs.settings", {}), EJS_CONTROLS=self._get_ejs_controls(), ) @@ -273,6 +277,14 @@ class ConfigManager: log.critical("Invalid config.yml: emulatorjs.debug must be a boolean") sys.exit(3) + if self.config.EJS_CACHE_LIMIT is not None and not isinstance( + self.config.EJS_CACHE_LIMIT, int + ): + log.critical( + "Invalid config.yml: emulatorjs.cache_limit must be an integer" + ) + sys.exit(3) + if not isinstance(self.config.EJS_SETTINGS, dict): log.critical("Invalid config.yml: emulatorjs.settings must be a dictionary") sys.exit(3) diff --git a/backend/endpoints/configs.py b/backend/endpoints/configs.py index 78f5325b5..f1a5439da 100644 --- a/backend/endpoints/configs.py +++ b/backend/endpoints/configs.py @@ -37,6 +37,7 @@ def get_config() -> ConfigResponse: PLATFORMS_BINDING=cfg.PLATFORMS_BINDING, PLATFORMS_VERSIONS=cfg.PLATFORMS_VERSIONS, EJS_DEBUG=cfg.EJS_DEBUG, + EJS_CACHE_LIMIT=cfg.EJS_CACHE_LIMIT, EJS_CONTROLS=cfg.EJS_CONTROLS, EJS_SETTINGS=cfg.EJS_SETTINGS, ) diff --git a/backend/endpoints/responses/config.py b/backend/endpoints/responses/config.py index 2e1bfedc3..40b68defd 100644 --- a/backend/endpoints/responses/config.py +++ b/backend/endpoints/responses/config.py @@ -13,5 +13,6 @@ class ConfigResponse(TypedDict): PLATFORMS_BINDING: dict[str, str] PLATFORMS_VERSIONS: dict[str, str] EJS_DEBUG: bool + EJS_CACHE_LIMIT: int | None EJS_SETTINGS: dict[str, dict[str, str]] EJS_CONTROLS: dict[str, EjsControls] diff --git a/backend/tests/config/fixtures/config/config.yml b/backend/tests/config/fixtures/config/config.yml index 7a1c5fd91..a1f0947fb 100644 --- a/backend/tests/config/fixtures/config/config.yml +++ b/backend/tests/config/fixtures/config/config.yml @@ -32,6 +32,7 @@ filesystem: emulatorjs: debug: true + cache_limit: 1000 settings: parallel_n64: vsync: disable diff --git a/backend/tests/config/test_config_loader.py b/backend/tests/config/test_config_loader.py index 7cd7b3cbf..18df44321 100644 --- a/backend/tests/config/test_config_loader.py +++ b/backend/tests/config/test_config_loader.py @@ -20,6 +20,7 @@ def test_config_loader(): assert loader.config.ROMS_FOLDER_NAME == "ROMS" assert loader.config.FIRMWARE_FOLDER_NAME == "BIOS" assert loader.config.EJS_DEBUG + assert loader.config.EJS_CACHE_LIMIT == 1000 assert loader.config.EJS_SETTINGS == { "parallel_n64": {"vsync": "disable"}, "snes9x": {"snes9x_region": "ntsc"}, @@ -52,5 +53,6 @@ def test_empty_config_loader(): assert loader.config.ROMS_FOLDER_NAME == "roms" assert loader.config.FIRMWARE_FOLDER_NAME == "bios" assert not loader.config.EJS_DEBUG + assert not loader.config.EJS_CACHE_LIMIT assert loader.config.EJS_SETTINGS == {} assert loader.config.EJS_CONTROLS == {} diff --git a/examples/config.example.yml b/examples/config.example.yml index 0576e4476..80952761c 100644 --- a/examples/config.example.yml +++ b/examples/config.example.yml @@ -50,6 +50,7 @@ filesystem: {} # { roms_folder: 'roms' } For example if your folder structure is # EmulatorJS per-core options emulatorjs: # debug: true # Available options will be logged to the browser console + # cache_limit: 100000000 # Cache limit per ROM (in bytes) settings: parallel_n64: # Use the exact core name # vsync: disable diff --git a/frontend/src/__generated__/models/ConfigResponse.ts b/frontend/src/__generated__/models/ConfigResponse.ts index 40b23fd72..e2672861f 100644 --- a/frontend/src/__generated__/models/ConfigResponse.ts +++ b/frontend/src/__generated__/models/ConfigResponse.ts @@ -13,6 +13,7 @@ export type ConfigResponse = { PLATFORMS_BINDING: Record; PLATFORMS_VERSIONS: Record; EJS_DEBUG: boolean; + EJS_CACHE_LIMIT: (number | null); EJS_SETTINGS: Record>; EJS_CONTROLS: Record; }; diff --git a/frontend/src/components/common/Navigation/ConsoleModeBtn.vue b/frontend/src/components/common/Navigation/ConsoleModeBtn.vue index c20e26a1f..b69d3479a 100644 --- a/frontend/src/components/common/Navigation/ConsoleModeBtn.vue +++ b/frontend/src/components/common/Navigation/ConsoleModeBtn.vue @@ -55,7 +55,7 @@ function enterConsoleMode() { class="text-caption text-center" :class="{ 'text-primary': route.path.startsWith('/console') }" > - Play + Console diff --git a/frontend/src/console/views/Play.vue b/frontend/src/console/views/Play.vue index ca3043ad0..6e4760d95 100644 --- a/frontend/src/console/views/Play.vue +++ b/frontend/src/console/views/Play.vue @@ -420,7 +420,10 @@ async function boot() { if (ejsControls) window.EJS_defaultControls = ejsControls; window.EJS_language = selectedLanguage.value.value.replace("_", "-"); window.EJS_disableAutoLang = true; - window.EJS_DEBUG_XX = configStore.config.EJS_DEBUG; + + const { EJS_DEBUG, EJS_CACHE_LIMIT } = configStore.config; + if (EJS_CACHE_LIMIT) window.EJS_CacheLimit = EJS_CACHE_LIMIT; + window.EJS_DEBUG_XX = EJS_DEBUG; // Set a valid game name (affects per-game settings keys) window.EJS_gameName = rom.fs_name_no_tags diff --git a/frontend/src/stores/config.ts b/frontend/src/stores/config.ts index c58d34597..6f1c3e526 100644 --- a/frontend/src/stores/config.ts +++ b/frontend/src/stores/config.ts @@ -21,6 +21,7 @@ const defaultConfig = { PLATFORMS_BINDING: {}, PLATFORMS_VERSIONS: {}, EJS_DEBUG: false, + EJS_CACHE_LIMIT: 1073741824, EJS_SETTINGS: {}, EJS_CONTROLS: {}, } as ConfigResponse; diff --git a/frontend/src/views/Player/EmulatorJS/Player.vue b/frontend/src/views/Player/EmulatorJS/Player.vue index fbcf5f382..833fcda56 100644 --- a/frontend/src/views/Player/EmulatorJS/Player.vue +++ b/frontend/src/views/Player/EmulatorJS/Player.vue @@ -80,6 +80,7 @@ declare global { EJS_language: string; EJS_disableAutoLang: boolean; EJS_DEBUG_XX: boolean; + EJS_CacheLimit: number; EJS_Buttons: Record; EJS_VirtualGamepadSettings: {}; EJS_onGameStart: () => void; @@ -136,7 +137,10 @@ window.EJS_gameName = romRef.value.fs_name_no_tags .trim(); window.EJS_language = selectedLanguage.value.value.replace("_", "-"); window.EJS_disableAutoLang = true; -window.EJS_DEBUG_XX = configStore.config.EJS_DEBUG; + +const { EJS_DEBUG, EJS_CACHE_LIMIT } = configStore.config; +if (EJS_CACHE_LIMIT) window.EJS_CacheLimit = EJS_CACHE_LIMIT; +window.EJS_DEBUG_XX = EJS_DEBUG; onMounted(() => { window.scrollTo(0, 0);