Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed broken mapper inheritance

  • Loading branch information...
commit b606f81397be158f5547c570de8fc568f68b0237 1 parent 4fc5d57
@bfirsh authored
Showing with 13 additions and 9 deletions.
  1. +10 −8 js.2/mappers.js
  2. +3 −1 js.2/utils.js
View
18 js.2/mappers.js
@@ -512,8 +512,6 @@ NES.Mappers[1] = function(nes) {
this.nes = nes;
}
-NES.Utils.copyPrototype(NES.Mappers[1], NES.Mappers[0]);
-
NES.Mappers[1].prototype = {
reset: function() {
NES.Mappers[0].prototype.reset.apply(this);
@@ -542,7 +540,7 @@ NES.Mappers[1].prototype = {
write: function(address, value) {
// Writes to addresses other than MMC registers are handled by NoMapper.
if (address < 0x8000) {
- MapperDefault.prototype.write.apply(this, arguments);
+ NES.Mappers[0].prototype.write.apply(this, arguments);
return;
}
@@ -770,17 +768,18 @@ NES.Mappers[1].prototype = {
}
}
+NES.Utils.copyPrototype(NES.Mappers[1], NES.Mappers[0]);
+
+
NES.Mappers[2] = function(nes) {
this.nes = nes
}
-NES.Utils.copyPrototype(NES.Mappers[2], NES.Mappers[0]);
-
NES.Mappers[2].prototype = {
write: function(address, value) {
// Writes to addresses other than MMC registers are handled by NoMapper.
if (address < 0x8000) {
- MapperDefault.prototype.write.apply(this, arguments);
+ NES.Mappers[0].prototype.write.apply(this, arguments);
return;
}
@@ -811,6 +810,9 @@ NES.Mappers[2].prototype = {
}
}
+NES.Utils.copyPrototype(NES.Mappers[2], NES.Mappers[0]);
+
+
NES.Mappers[4] = function(nes) {
this.nes = nes
@@ -833,8 +835,6 @@ NES.Mappers[4] = function(nes) {
this.prgAddressChanged = false;
}
-NES.Utils.copyPrototype(NES.Mappers[4], NES.Mappers[0]);
-
NES.Mappers[4].prototype = {
write: function(address, value) {
// Writes to addresses other than MMC registers are handled by NoMapper.
@@ -1046,3 +1046,5 @@ NES.Mappers[4].prototype = {
this.nes.cpu.requestIrq(this.nes.cpu.IRQ_RESET);
}
}
+
+NES.Utils.copyPrototype(NES.Mappers[4], NES.Mappers[0]);
View
4 js.2/utils.js
@@ -12,7 +12,9 @@ NES.Utils = {
var aMatch = sConstructor.match( /\s*function (.*)\(/ );
if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
for (var m in parent.prototype) {
- descendant.prototype[m] = parent.prototype[m];
+ if (typeof descendant.prototype[m] == 'undefined') {
+ descendant.prototype[m] = parent.prototype[m];
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.