Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/content/docs/apis/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/classes/emulator-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
3 changes: 3 additions & 0 deletions src/classes/emulator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class EmulatorOptions {

sram?: ResolvableFile | undefined

sramType?: 'sav' | 'srm'

state?: ResolvableFile | undefined

waitForInteraction: ((params: { done: () => void }) => void) | undefined
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion src/classes/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions src/types/nostalgist-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export interface NostalgistOptions {
*/
sram?: ResolvableFileInput

/**
* The type of battery save the core generates.
*/
sramType?: 'sav' | 'srm'

respondToGlobalEvents?: boolean

/**
Expand Down