瀏覽代碼

NESBank can now import/export to a base64 string.

dev-bank
Bryan Miller 5 年之前
父節點
當前提交
e9b9f9eeff
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. +18
    -0
      app/js/models/NESBank.js

+ 18
- 0
app/js/models/NESBank.js 查看文件

@@ -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…
取消
儲存