bfirsh / jsnes

A JavaScript NES emulator.
https://jsnes.org
Apache License 2.0
6.12k stars 831 forks source link

Fix reset function / JSON serialization #405

Closed ninjadynamics closed 3 years ago

ninjadynamics commented 3 years ago

Hi!

I'm creating a mobile interface for this emulator and since I was forced to change some stuff on the source code, I guess I should create a pull request. :)

Fixed the error this.nes.stop is not a function when calling nes.reset():

Improved JSON serialization:

Save state

Load state

bfirsh commented 3 years ago

Brilliant, thank you!

I'm wonder if removing saving romData has any implications? Looks like resetting probably still works, but maybe reloadROM() doesn't work now. I don't think we were using that for anything anyway.

ninjadynamics commented 3 years ago

Thanks!! :) I can confirm that reloadROM() works without problems. ;)

You can check my NinjaPad project implementation, namely: https://github.com/ninjadynamics/nesdev/blob/main/ninjapad/menu.js https://github.com/ninjadynamics/nesdev/blob/main/ninjapad/interface.js

You can also try it live on mobile and desktop (ESC brings the menu). Link in the first post.

bfirsh commented 3 years ago

Super cool. Thanks for the contribution!