在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:bfirsh/jsnes开源软件地址:https://github.com/bfirsh/jsnes开源编程语言:JavaScript 99.7%开源软件介绍:JSNESA JavaScript NES emulator. It's a library that works in both the browser and Node.js. The browser UI is available at https://github.com/bfirsh/jsnes-web. InstallationFor Node.js or Webpack:
(Or In the browser, you can use unpkg: <script type="text/javascript" src="https://unpkg.com/jsnes/dist/jsnes.min.js"></script> Usage// Initialize and set up outputs
var nes = new jsnes.NES({
onFrame: function(frameBuffer) {
// ... write frameBuffer to screen
},
onAudioSample: function(left, right) {
// ... play audio sample
}
});
// Read ROM data from disk (using Node.js APIs, for the sake of this example)
const fs = require('fs');
var romData = fs.readFileSync('path/to/rom.nes', {encoding: 'binary'});
// Load ROM data as a string or byte array
nes.loadROM(romData);
// Run frames at 60 fps, or as fast as you can.
// You are responsible for reliable timing as best you can on your platform.
nes.frame();
nes.frame();
// ...
// Hook up whatever input device you have to the controller.
nes.buttonDown(1, jsnes.Controller.BUTTON_A);
nes.frame();
nes.buttonUp(1, jsnes.Controller.BUTTON_A);
nes.frame();
// ... BuildTo build a distribution:
This will create Running tests
Embedding JSNES in a web pageYou can use JSNES to embed a playable version of a ROM in a web page. This is handy if you are a homebrew ROM developer and want to put a playable version of your ROM on its web page. The best implementation is jsnes-web but unfortunately it is not trivial to reuse the code. You'll have to copy and paste the code from that repository, the use the A project for potential contributors (hello!): jsnes-web should be reusable and on NPM! It just needs compiling and bundling. A more basic example is in the Formatting codeAll code must conform to Prettier formatting. The test suite won't pass unless it does. To automatically format all your code, run:
MaintainersJSNES is based on James Sanders' vNES, and owes an awful lot to it. It also wouldn't have happened without Matt Wescott's JSSpeccy, which sparked the original idea. (Ben, circa 2008: "Hmm, I wonder what else could run in a browser?!") |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论