Browse Source

NESBank can now import/export to a base64 string.

dev-bank
Bryan Miller 5 years ago
parent
commit
e9b9f9eeff
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      app/js/models/NESBank.js

+ 18
- 0
app/js/models/NESBank.js View File

@@ -106,6 +106,24 @@ 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);
}

set base64(s){
var b = window.atob(s);
var len = b.length;
if (b.length !== 8192){
throw new Error("Base64 string contains invalid byte count.");
}
this.chr = b;
}

get palette(){return this.__palette;}
set palette(p){
if (p !== null && !(p instanceof NESPalette))

Loading…
Cancel
Save