Skip to content

Commit

Permalink
feat: nes emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Nov 6, 2024
1 parent 06241c6 commit c42b9ef
Show file tree
Hide file tree
Showing 10 changed files with 7,513 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/nes_emulator/emu/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var Controller = function () {
this.state = new Array(8);
for (var i = 0; i < this.state.length; i++) {
this.state[i] = 0x40;
}
};

Controller.BUTTON_A = 0;
Controller.BUTTON_B = 1;
Controller.BUTTON_SELECT = 2;
Controller.BUTTON_START = 3;
Controller.BUTTON_UP = 4;
Controller.BUTTON_DOWN = 5;
Controller.BUTTON_LEFT = 6;
Controller.BUTTON_RIGHT = 7;

Controller.prototype = {
buttonDown: function (key) {
this.state[key] = 0x41;
},

buttonUp: function (key) {
this.state[key] = 0x40;
}
};
Loading

0 comments on commit c42b9ef

Please sign in to comment.