Skip to content

Commit 41371ca

Browse files
Merge pull request #73 from perrello/foxol-compat
Support for .sav SRAM files.
2 parents 8b3d5c6 + 17ced62 commit 41371ca

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

docs/src/content/docs/apis/launch.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ const nostalgist = await Nostalgist.launch({
178178
179179
The initial SRAM to be loaded after launching.
180180
181+
+ #### `sramType`
182+
183+
**type:** `srm | sav`
184+
185+
Sets the save file battery type used by Nostalgist internally. Use `'sav'` for cores like melonDS. Defaults to `'srm'`.
186+
181187
+ #### `shader`
182188
183189
**type:** `string`

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Please refer to [nostalgist.js.org/apis](https://nostalgist.js.org/apis).
125125

126126
The high-performance, preservation-focused netflix style emulation engine powered by Nostalgist.
127127

128+
+ [Foxol](https://play.foxol.app)
129+
130+
Foxol is a modern emulator platform with multiplayer, cloud saves, cheats, and deep customization across every device.
131+
128132

129133
### Credits
130134

src/classes/emulator-file-system.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export class EmulatorFileSystem {
5656
FS.mkdirTree(directory)
5757
}
5858

59+
readdir(path: string) {
60+
const { FS } = this
61+
return FS.readdir(path)
62+
}
63+
5964
readFile(path: string, encoding: 'binary' | 'utf8' = 'utf8') {
6065
const { FS } = this
6166
return FS.readFile(path, { encoding })

src/classes/emulator-options.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export class EmulatorOptions {
6868

6969
sram?: ResolvableFile | undefined
7070

71+
sramType?: 'sav' | 'srm'
72+
7173
state?: ResolvableFile | undefined
7274

7375
waitForInteraction: ((params: { done: () => void }) => void) | undefined
@@ -127,6 +129,7 @@ export class EmulatorOptions {
127129
this.respondToGlobalEvents = options.respondToGlobalEvents ?? true
128130
this.signal = options.signal
129131
this.size = options.size ?? 'auto'
132+
this.sramType = options.sramType ?? 'srm'
130133
// eslint-disable-next-line sonarjs/deprecation
131134
this.waitForInteraction = options.waitForInteraction
132135
this.element = this.getElement()

src/classes/emulator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ export class Emulator {
8686
}
8787

8888
private get sramFilePath() {
89-
return path.join(this.sramFileDirectory, `${this.romBaseName}.srm`)
89+
return path.join(this.sramFileDirectory, `${this.romBaseName}.${this.sramFileType}`)
90+
}
91+
92+
private get sramFileType() {
93+
return this.options.sramType
9094
}
9195

9296
private get stateFileDirectory() {

src/types/nostalgist-options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ export interface NostalgistOptions {
147147
*/
148148
sram?: ResolvableFileInput
149149

150+
/**
151+
* The type of battery save the core generates.
152+
*/
153+
sramType?: 'sav' | 'srm'
154+
150155
respondToGlobalEvents?: boolean
151156

152157
/**

0 commit comments

Comments
 (0)