andymikulski / nES6

NES emulator written in ES6
Other
4 stars 1 forks source link

Expose Savestate API #5

Closed andymikulski closed 7 years ago

andymikulski commented 7 years ago

Note: The language of 'import/export' is used here to keep in line with the design philosophy of nES6. It's not nES6's place to actually save anything to, say, localStorage - it's up to the developer how that is handled.

Therefore, the state API is more for exporting and importing savestates than actually attempting to persist the savestate in memory.

andymikulski commented 7 years ago

Digging into it a little bit, there is some weird casting that goes on in WebNES to export/import states. The data object is wrapped in a few Uint32/Uint8Arrays and then ran through a LZW string compression algo. Any attempt to switch how the data is exported or compressed results in a Source too large error when re-importing data.

andymikulski commented 7 years ago

Available as of 66bdf7fe52c48e743347ff3c9ef6e68b8ec15944