diff --git a/docs/src/content/docs/apis/launch.md b/docs/src/content/docs/apis/launch.md index def1cb6..64431fb 100644 --- a/docs/src/content/docs/apis/launch.md +++ b/docs/src/content/docs/apis/launch.md @@ -178,6 +178,12 @@ const nostalgist = await Nostalgist.launch({ The initial SRAM to be loaded after launching. + + #### `sramType` + + **type:** `srm | sav` + + Sets the save file battery type used by Nostalgist internally. Use `'sav'` for cores like melonDS. Defaults to `'srm'`. + + #### `shader` **type:** `string` diff --git a/readme.md b/readme.md index e9bd501..2bd7546 100644 --- a/readme.md +++ b/readme.md @@ -125,6 +125,10 @@ Please refer to [nostalgist.js.org/apis](https://nostalgist.js.org/apis). The high-performance, preservation-focused netflix style emulation engine powered by Nostalgist. ++ [Foxol](https://play.foxol.app) + + Foxol is a modern emulator platform with multiplayer, cloud saves, cheats, and deep customization across every device. + ### Credits diff --git a/src/classes/emulator-file-system.ts b/src/classes/emulator-file-system.ts index 62733c3..60a2f94 100644 --- a/src/classes/emulator-file-system.ts +++ b/src/classes/emulator-file-system.ts @@ -56,6 +56,11 @@ export class EmulatorFileSystem { FS.mkdirTree(directory) } + readdir(path: string) { + const { FS } = this + return FS.readdir(path) + } + readFile(path: string, encoding: 'binary' | 'utf8' = 'utf8') { const { FS } = this return FS.readFile(path, { encoding }) diff --git a/src/classes/emulator-options.ts b/src/classes/emulator-options.ts index a87cbae..e5ca0b9 100644 --- a/src/classes/emulator-options.ts +++ b/src/classes/emulator-options.ts @@ -68,6 +68,8 @@ export class EmulatorOptions { sram?: ResolvableFile | undefined + sramType?: 'sav' | 'srm' + state?: ResolvableFile | undefined waitForInteraction: ((params: { done: () => void }) => void) | undefined @@ -127,6 +129,7 @@ export class EmulatorOptions { this.respondToGlobalEvents = options.respondToGlobalEvents ?? true this.signal = options.signal this.size = options.size ?? 'auto' + this.sramType = options.sramType ?? 'srm' // eslint-disable-next-line sonarjs/deprecation this.waitForInteraction = options.waitForInteraction this.element = this.getElement() diff --git a/src/classes/emulator.ts b/src/classes/emulator.ts index e151f22..2731318 100644 --- a/src/classes/emulator.ts +++ b/src/classes/emulator.ts @@ -86,7 +86,11 @@ export class Emulator { } private get sramFilePath() { - return path.join(this.sramFileDirectory, `${this.romBaseName}.srm`) + return path.join(this.sramFileDirectory, `${this.romBaseName}.${this.sramFileType}`) + } + + private get sramFileType() { + return this.options.sramType } private get stateFileDirectory() { diff --git a/src/types/nostalgist-options.ts b/src/types/nostalgist-options.ts index 09d9a1f..2097f65 100644 --- a/src/types/nostalgist-options.ts +++ b/src/types/nostalgist-options.ts @@ -147,6 +147,11 @@ export interface NostalgistOptions { */ sram?: ResolvableFileInput + /** + * The type of battery save the core generates. + */ + sramType?: 'sav' | 'srm' + respondToGlobalEvents?: boolean /**