-
Notifications
You must be signed in to change notification settings - Fork 833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save state #16
Comments
@bfirsh, I may be able to add this feature given a few hints on which parts of the code need to be changed. Any ideas? |
I've got this working over in my repo at https://github.com/josephlewis42/jsnes |
@josephlewis42 can you open a pull request then? :) |
No problem, just did it! The save is localstorage though rather than remotestorage. |
@josephlewis42
|
I've moved the web emulator to a different repository and created an issue for it. Thanks all for your input! bfirsh/jsnes-web#18 |
how to save and load state? any snippet here? @bfirsh |
I have done this by localStorage, hope this helps you. @oknoorap try{
var saveData = JSON.stringify(nes.toJSON());
localStorage.setItem(romName, saveData);
}catch(oException){
if(oException.name == 'QuotaExceededError'){
console.log('localStorage out of memory');
localStorage.clear();
localStorage.setItem(calcMD5(rompath), saveData);
}
} load: var saveData = localStorage.getItem(romName);
if( saveData == null ) {
console.log("nothing to load");
return;
}
var decodedData = JSON.parse(saveData);
nes.fromJSON(decodedData); |
I just did that but doesn't works with jsnes-web, load state doesn't overwrite existing canvas |
Maybe you forgot to run Or perhaps bfirsh removed some related code from Anyway, I successed to do this with the old versions of |
okay, will try, I'll post again when succeed |
@MeteorKL: great, it's succeed (without |
I don't quite understand |
Did you mean that |
yep, after load state there was glitchy graphics in the game |
Maybe you can stop the frame interval brefore save state, and continue it after load. I guess it is just because you still run the game after saving state. |
I do this.stop() or
before save to local storage, it's still has glitch |
It seems that the second graphics happens after the first graphics. It is pretty confusing and I have no idea about this. |
Pacman doesn't have any trouble with graphics, but after load state, sounds are muted... 😄 |
Interesting bug :) |
I've modify |
may be it's related with Tile or ppu issue? can you help me 😭 @MeteorKL, I want to submit PR but I'm too dumb to understand jsnes's code... |
I'm also on the way to understanding jsnes's code. |
This is probably because |
@bfirsh personally as developer I want to submit PR but it's too complicated to me to read low level code like yours, I'm sorry I just support you here, good luck, hope this issue will be solved 😄 |
any news related to glitch issue? |
@bfirsh is this issue still can't be fixed? 😃 |
I don’t have the time to look at it at the moment, but others are very welcome to tackle it! The main issue tracking is here: bfirsh/jsnes-web#18 |
I want to save data by save the nes.cpu.mem.(So this game state can lower from 1.9MB to 187KB) but in this way. when I load the mem, the frame's background is before background. Is there any method can refresh the background? I try to save the nes.ppu.bgbuffer, nes.ppu.vramMem, do nes.ppu.updatePalettes(), but not work, mayby I have sth wrong. Can anyone help me?
|
@bfirsh, @Skypow2012, @oknoorap, @lazyxu, @josephlewis42, @jancborchardt I have fixed the load via |
To be able to actually play the games properly rather than just fiddle around, the game state should be saved. Not sure if internal game save functions can be accessed or if it’s feasible to just always have the latest state changed. The Gameboy Emulator by Grant Galitz seems to do both.
It’s probably best to always automatically save in localStorage/IndexedDB so that people can return to their game. Maybe even use remotestorage so you can change browsers.
The text was updated successfully, but these errors were encountered: