Browse Source

NESBank now has a getBase64() method that can get the base64 string of the bank at any size without interrupting the access_mode and access_offset settings. Also now has a eq() method which will return true if the given object is a NESBank containing the same data.

dev
Bryan Miller 5 years ago
parent
commit
d3451420d0
1 changed files with 24 additions and 6 deletions
  1. +24
    -6
      app/js/models/NESBank.js

+ 24
- 6
app/js/models/NESBank.js View File

@@ -349,12 +349,13 @@ export default class NESBank extends ISurface{
}

get base64(){
var b = "";
var data = this.chr;
for (var i = 0; i < data.length; i++) {
b += String.fromCharCode(data[i]);
}
return window.btoa(b);
return this.getBase64(this.__AccessMode, this.__AccessOffset);
//var b = "";
//var data = this.chr;
//for (var i = 0; i < data.length; i++) {
// b += String.fromCharCode(data[i]);
//}
//return window.btoa(b);
}

set base64(s){
@@ -514,6 +515,15 @@ export default class NESBank extends ISurface{
}


getBase64(mode, offset){
var b = "";
var data = this.getCHR(mode, offset);
for (var i = 0; i < data.length; i++) {
b += String.fromCharCode(data[i]);
}
return window.btoa(b);
}

getCHR(mode, offset){
this.__emitsEnabled = false;
var oam = this.access_mode;
@@ -816,6 +826,14 @@ export default class NESBank extends ISurface{
comp(this.__RP, 256, ignoreTileZero);
return this;
}

eq(b){
if (b instanceof NESBank){
if (this.getBase64(NESBank.ACCESSMODE_8K, 0) === b.getBase64(NESBank.ACCESSMODE_8K, 0))
return true;
}
return false;
}
}



Loading…
Cancel
Save