Save/Load
js-dos supports saving and restoring game progress. You can play game from time to time without losing progress. It's working automatically while you don't change bundle url.
This feature works by dumping changes of file system into second bundle
and use it to override original file system
on next load. This feature is backed by CommandInterface persist
function.
You can implement your own save/load feature like this:
const ci = await Dos(<element>).run(<bundle url>);
// saving
const changesBundle = await ci.persist();
// <new session>
// loading
const ci = await Dos(<element>)
.run(<original bundle url>,
URL.createObjectURL(new Blob([changesBundle.buffer]));
#
Where progress is storedWhile you use default Save/Load feature of js-dos all updates are stored in indexed db emulators-ui-saves
.
The changes bundle is stored like key value record, where key is a bundle url
and value is Uint8Array
from ci.persist()
call.
All progress will be lost if you change bundle url.
Default implementation:
https://raw.githubusercontent.com/js-dos/emulators-ui/main/src/persist/save-load.ts
Run
{}