• Rust
  • TypeScript
  • emulation

Sharing game saves between Nostyra desktop and web

Nostyra shares in-game progress, keeps save states specific to each edition, and preserves existing saves when file sizes differ.

When I brought Nostyra to the browser, I wanted players to be able to save through a game’s menu on the desktop and continue in the web edition. If the user selects the same Data folder, both editions can read from the same place. The remaining work was deciding which files the two emulators interpret the same way and what to do when they write different data.

An emulator is a program that imitates an old console so its games run on a modern computer. Nostyra is a libretro frontend: the interface and library are Nostyra’s own, while the emulation itself is done by libretro cores, separate plug-in emulators for each console. The two editions are not identical. According to the Nostyra app page, the desktop edition runs on Windows 10 or 11 (x64, with macOS experimental), plays 20 systems, and downloads its cores from the libretro buildbot. Nostyra Online, the browser edition, plays 13 systems and needs desktop Chrome or Edge 122 or later. So a save can only travel between editions for systems both of them play.

In-game saves and save states

Saving through a game’s menu writes to the storage the game itself uses. Nostyra keeps that data in the game’s save.srm. Some cartridges also have a clock. For example, some Game Boy games running through mGBA can have an accompanying rtc.bin containing the clock data.

An emulator save state captures the whole machine at a point in time. It can preserve the moment halfway through a level so the player can resume in the same spot. Restoring it depends on the core, the component that emulates the console, and the build that produced the file. Nostyra gives the web edition the names web-slot0 through web-slot9 and web-auto in the same game folder. Next to each state sits a sidecar, a small companion file of metadata. The web edition checks the sidecar’s core and build metadata before loading a state, and the desktop interface lists its own slots.

Preserve the existing file when sizes differ

(KiB means kibibyte, 1,024 bytes.) Imagine the desktop has an 8 KiB save.srm and the web session is about to write 16 KiB. Nostyra writes the browser’s data to save.web.srm, leaving the 8 KiB file available to the desktop. On the next launch the browser prefers its own file if present and keeps writing to it, even if a later write happens to match the desktop file’s size.

Without a browser-specific copy, the browser uses save.srm when it is missing or matches the size of the incoming data. Length is a guard at write time. It does not prove that the other edition’s core can read the bytes. The only compatibility check in this flow is the one for save states described above, where the web edition reads the sidecar’s core and build metadata before loading a state.

Put together, the rules give this choice for the browser’s in-game save:

save.web.srm exists? save.srm Incoming data vs save.srm size Browser reads and writes
Yes any any save.web.srm
No missing (nothing to compare) save.srm
No present same size save.srm
No present different size save.web.srm, leaving save.srm untouched

The first row is why a later write that happens to match the desktop file’s size still goes to the browser’s own file. It also gives a simple way to see which file the web edition uses for a game: look in that game’s folder inside the Data folder. If save.web.srm is there, the browser reads and writes it; if not, the browser is sharing save.srm with the desktop.

I kept the file selection in a pure function, one whose result depends only on its inputs and which touches no files itself. Its inputs are the facts about the existing files and the size of the incoming data. To test the 8 KiB and 16 KiB case, I can pass both sizes to the function and check its choice without starting a game or creating a real save folder.

From emulator memory to the Data folder

The web edition collects save data periodically during play and when the player exits through the app. It compares checksums, short values calculated from the current save bytes and the last written bytes. If they match, the app skips the write so it does not write the same data on every check. When a write fails, the app retries. If the final write still fails, it can keep a pending copy in browser-private storage and retry later.

Two simultaneous sessions can still write to save.srm. Whichever session writes last determines what remains in the shared file. For Nostyra, the contract between the two editions therefore covers file names, the data each core understands, and when each session writes.

The app page also lists experimental cloud saves through Google Drive or a folder synced by your own sync app. How those interact with the files described here is outside the scope of this article.

Common mistakes when sharing a Data folder between the two editions:

  • Playing the same game in both editions at once. Whichever writes last wins.
  • Expecting a save state to move between editions. States are tied to the core and build that produced them; only in-game saves are meant to be shared.
  • Deleting save.web.srm to “merge” progress. The browser then falls back to save.srm only if the sizes match; otherwise it creates a new browser copy on the next write.

Conclusion

Shared folders make in-game saves portable only when both editions agree on the file format and the emulator core can read the data. A size check can prevent one class of accidental overwrite, but it does not prove compatibility. Keep incompatible saves separate and treat simultaneous writes as a last-writer-wins conflict.

Written by Duy Pham Independent developer. I build the apps on this site and write about how they work.

More about me