Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -1,5 +1,6 @@
// Keyboard events are bound in the UI
JSNES.Keyboard = function() {
if (!(this instanceof JSNES.Keyboard)) return new JSNES.Keyboard()
var i;

this.keys = {
@@ -1,4 +1,5 @@
JSNES.PAPU = function(nes) {
if (!(this instanceof JSNES.PAPU)) return new JSNES.PAPU(nes)
this.nes = nes;

this.square1 = new JSNES.PAPU.ChannelSquare(this, true);
@@ -1,5 +1,6 @@

JSNES.PAPU.ChannelDM = function(papu) {
if (!(this instanceof JSNES.PAPU.ChannelDM)) return new JSNES.PAPU.ChannelDM(papu)
this.papu = papu;

this.MODE_NORMAL = 0;
@@ -1,4 +1,5 @@
JSNES.PAPU.ChannelNoise = function(papu) {
if (!(this instanceof JSNES.PAPU.ChannelNoise)) return new JSNES.PAPU.ChannelNoise(papu)
this.papu = papu;

this.isEnabled = null;
@@ -1,4 +1,5 @@
JSNES.PAPU.ChannelSquare = function(papu, square1) {
if (!(this instanceof JSNES.PAPU.ChannelSquare)) return new JSNES.PAPU.ChannelSquare(papu, square1)
this.papu = papu;

this.dutyLookup = [
@@ -1,4 +1,5 @@
JSNES.PAPU.ChannelTriangle = function(papu) {
if (!(this instanceof JSNES.PAPU.ChannelTriangle)) return new JSNES.PAPU.ChannelTriangle(papu)
this.papu = papu;

this.isEnabled = null;
@@ -1,22 +1,5 @@
/*
JSNES, based on Jamie Sanders' vNES
Copyright (C) 2010 Ben Firshman
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

JSNES.PPU = function(nes) {
if (!(this instanceof JSNES.PPU)) return new JSNES.PPU()
this.nes = nes;

// Keep Chrome happy
@@ -1,4 +1,5 @@
JSNES.PPU.NameTable = function(width, height, name) {
if (!(this instanceof JSNES.PPU.NameTable)) return new JSNES.PPU.NameTable(width, height, name)
this.width = width;
this.height = height;
this.name = name;
@@ -1,4 +1,5 @@
JSNES.PPU.PaletteTable = function() {
if (!(this instanceof JSNES.PPU.PaletteTable)) return new JSNES.PPU.PaletteTable()
this.curTable = new Array(64);
this.emphTable = new Array(8);
this.currentEmph = -1;
@@ -1,5 +1,5 @@

JSNES.PPU.Tile = function() {
if (!(this instanceof JSNES.PPU.Tile)) return new JSNES.PPU.Tile()
// Tile data:
this.pix = new Array(64);

@@ -1,26 +1,9 @@
/*
JSNES, based on Jamie Sanders' vNES
Copyright (C) 2010 Ben Firshman
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

JSNES.ROM = function(nes) {
if (!(this instanceof JSNES.ROM)) return new JSNES.ROM()
this.nes = nes;

this.mapperName = new Array(92);

for (var i=0;i<92;i++) {
this.mapperName[i] = "Unknown Mapper";
}
@@ -51,7 +34,7 @@ JSNES.ROM = function(nes) {
this.mapperName[32] = "Irem G-101 chip";
this.mapperName[33] = "Taito TC0190/TC0350";
this.mapperName[34] = "32kB ROM switch";

this.mapperName[64] = "Tengen RAMBO-1 chip";
this.mapperName[65] = "Irem H-3001 chip";
this.mapperName[66] = "GNROM switch";
@@ -73,12 +56,12 @@ JSNES.ROM.prototype = {
SINGLESCREEN_MIRRORING3: 5,
SINGLESCREEN_MIRRORING4: 6,
CHRROM_MIRRORING: 7,

header: null,
rom: null,
vrom: null,
vromTile: null,

romCount: null,
vromCount: null,
mirroring: null,
@@ -87,10 +70,10 @@ JSNES.ROM.prototype = {
fourScreen: null,
mapperType: null,
valid: false,

load: function(data) {
var i, j, v;

if (data.indexOf("NES\x1a") === -1) {
this.nes.ui.updateStatus("Not a valid NES ROM.");
return;
@@ -145,7 +128,7 @@ JSNES.ROM.prototype = {
}
offset += 4096;
}

// Create VROM tiles:
this.vromTile = new Array(this.vromCount);
for (i=0; i < this.vromCount; i++) {
@@ -154,7 +137,7 @@ JSNES.ROM.prototype = {
this.vromTile[i][j] = new JSNES.PPU.Tile();
}
}

// Convert CHR-ROM banks to tiles:
var tileIndex;
var leftOver;
@@ -178,10 +161,10 @@ JSNES.ROM.prototype = {
}
}
}

this.valid = true;
},

getMirroringType: function() {
if (this.fourScreen) {
return this.FOURSCREEN_MIRRORING;
@@ -191,18 +174,18 @@ JSNES.ROM.prototype = {
}
return this.VERTICAL_MIRRORING;
},

getMapperName: function() {
if (this.mapperType >= 0 && this.mapperType < this.mapperName.length) {
return this.mapperName[this.mapperType];
}
return "Unknown Mapper, "+this.mapperType;
},

mapperSupported: function() {
return typeof JSNES.Mappers[this.mapperType] !== 'undefined';
},

createMapper: function() {
if (this.mapperSupported()) {
return new JSNES.Mappers[this.mapperType](this.nes);
@@ -0,0 +1,4 @@
var nes = require('./exported_source/JSNES.js')({
ui: function(){}
})
console.log(Object.keys(nes))