LibretroNativeCore class is the main entry point for native libretro emulation in GameLord. It handles path validation, directory setup, and autosave management before delegating actual emulation to a worker process.
This class does not load the native addon or drive the emulation loop directly. Those responsibilities belong to the worker process managed by
EmulationWorkerClient.Architecture
In the current architecture, the actual emulation loop runs in a dedicated utility process.LibretroNativeCore is responsible for:
- Path validation — Ensuring ROM and core paths are safe before handing them to the worker process
- Config storage — Exposing validated paths so
EmulationWorkerClientcan initialize the worker - Autosave management — Filesystem checks for resume-game prompts that happen before the worker is spawned
Constructor
Base path for storing libretro cores
userData/savestates— Save statesuserData/saves— SRAM/battery savesuserData/BIOS— System BIOS files
Methods
launch
Validate and prepare ROM/core paths for emulation.Absolute path to the ROM file
Absolute path to the libretro core (.dylib, .dll, or .so)
Core path security
Cores must be loaded from one of these allowed directories:- App-managed:
userData/cores - RetroArch (macOS):
~/Library/Application Support/RetroArch/cores - RetroArch (Windows):
%APPDATA%/RetroArch/cores - RetroArch (Linux):
~/.config/retroarch/cores
Example
Path getters
These methods expose validated paths for the worker process.getCorePath
launch() has not been called.
getRomPath
launch() has not been called.
getSystemDir
launch() has not been called.
getSaveDir
getSramDir
getSaveStatesDir
Autosave management
These methods check and manage autosave files before the worker starts.hasAutoSave
true if an autosave exists for the currently loaded ROM.
hasAutoSaveForRom
Path to the ROM file to check
true if an autosave exists for the specified ROM.
deleteAutoSave
deleteAutoSaveForRom
Path to the ROM whose autosave should be deleted
Example usage
Lifecycle methods
These methods emit events but defer actual emulation control to the worker.pause
paused event. Actual pause control happens in the worker.
resume
resumed event. Actual resume control happens in the worker.
reset
reset event. Actual reset control happens in the worker.
terminate
terminated event.
isActive
true if the core is currently running.
Events
Inherits fromEventEmitter and emits the following events:
launched—{ romPath: string, corePath: string }— Fired after successful path validationpaused— Fired when pause is requestedresumed— Fired when resume is requestedreset— Fired when reset is requestedterminated— Fired when the core is terminated
Worker integration
This class is designed to work withEmulationWorkerClient, which handles the actual emulation loop:
Related
- EmulationWorkerClient — Worker process client for running emulation
- CoreDownloader — Download and manage libretro cores