最近很火的小霸王游戏机模拟开源项目--JSNES

    选择打赏方式

开源地址:https://github.com/bfirsh/jsnes


一、简介:

Jsnes是一个用 JavaScript 实现的 NES 模拟器;这是一个可以在浏览器和 Node.js 中使用的库,浏览器的用户界面可以在 https://github.com/bfirsh/jsnes-web 中找到。


二、Installation 安装
1.  对于 Node.js Webpack:

$ npm install jsnes

或者使用

$ yarn add jsnes


2.在浏览器中,你可以使用 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();

// ...


四、Build 构建

如果想要构建好一个发布版,可以执行:

$ yarn run build

(这会在目录下创建 dist/jsnes.min.js  文件)


五、Running tests 运行测试

$ yarn test


六、以下是演示链接,兼容PC端、移动端:

http://fc.255615.cn/


版权声明:若无特殊注明,本文为《Chin》原创,转载请保留文章出处。
本文链接:https://www.qinor.cn/post-65.html
正文到此结束

热门推荐

发表吐槽

匿名评论 请叫我雷锋~

你还可以输入 250 / 250 个字

嘻嘻 大笑 可怜 吃惊 害羞 调皮 鄙视 示爱 大哭 开心 偷笑 嘘 奸笑 委屈 抱抱 愤怒 思考 日了狗 胜利 不高兴 阴险 乖 酷 滑稽

评论信息框
可使用QQ号实时获取昵称+头像

私密评论

吃奶的力气提交吐槽中...

已有2条吐槽

Chin

2021-05-27 11:36
签到成功!签到时间:上午11:35:52,每日打卡,生活更精彩哦~

西西

2021-05-27 11:26 广东省惠州市电信
签到成功!签到时间:上午11:25:52,每日打卡,生活更精彩哦~
 Windows 10 x64   Google Chrome 86.0.4240.198