Make sure all machines support JSON-encoded resources with either 'longs' or 'data' arrays

This commit is contained in:
Jeff Parsons 2017-02-28 16:20:49 -08:00 • committed by Jeff Parsons
commit 51274c1a30
9 changed files with 25 additions and 13 deletions

View file

@ -132,8 +132,8 @@ V.INIT=[[V.nc.INIT,V.ga.Cc|V.ga.Dc],[V.ua.sc,V.ua.tc],[V.Xa.vc,V.Xa.rc,V.Xa.uc,V
T.gb={2:S.prototype.qd,3:S.prototype.sd,4:S.prototype.rd,5:S.prototype.td,6:S.prototype.ud};V.fb={66:S.prototype.gd};V.gb={66:S.prototype.vd,98:S.prototype.yd,162:S.prototype.xd,194:S.prototype.wd};Va(function(){for(var a=y(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=u(c),d=new S(d);sa(d,c)}});
function Jc(a){p.call(this,"ROM",a);this.a=null;this.g=a.addr;this.b=a.size;this.f=a.alias;this.c=a.file;this.h=Ca(this.c);if(this.c){a=this.c;var b=Da(this.h);"json"!=b&&"hex"!=b&&(a=Fa()+"/api/v1/dump?file="+this.c+"&format=bytes&decimal=true");var c=this;La(a,null,!0,function(a,b,f){Kc(c,a,b,f)})}}l(Jc,p);Jc.prototype.qa=function(a,b,c,d){this.u=b;this.m=c;this.J=d;Lc(this)};Jc.prototype.ca=function(){this.sa&&(this.J&&this.J.a(this.id,this.g,this.b,this.sa),delete this.sa);return!0};
Jc.prototype.ba=function(){return!0};
function Kc(a,b,c,d){if(d)a.G("Unable to load system ROM (error "+d+": "+b+")");else{ka(a.Ka,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,g=e.data;if(f)a.a=f;else if(g)for(a.a=Array(4*g.length),d=c=0;c<g.length;c++)a.a[d++]=g[c]&255,a.a[d++]=g[c]>>8&255,a.a[d++]=g[c]>>16&255,a.a[d++]=g[c]>>24&255;else a.a=e;a.sa=e.symbols;if(!a.a.length){t("Empty ROM: "+b);return}if(1==a.a.length){t(a.a[0]);return}}catch(h){a.G("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.a=Array(b.length),e=0;e<b.length;e++)a.a[e]=Ba(b[e]);Lc(a)}}
function Kc(a,b,c,d){if(d)a.G("Unable to load system ROM (error "+d+": "+b+")");else{ka(a.Ka,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,g=e.longs||e.data;if(f)a.a=f;else if(g)for(a.a=Array(4*g.length),d=c=0;c<g.length;c++)a.a[d++]=g[c]&255,a.a[d++]=g[c]>>8&255,a.a[d++]=g[c]>>16&255,a.a[d++]=g[c]>>24&255;else a.a=e;a.sa=e.symbols;if(!a.a.length){t("Empty ROM: "+b);return}if(1==a.a.length){t(a.a[0]);return}}catch(h){a.G("ROM data error: "+h.message);return}else for(b=
c.replace(/\n/gm," ").replace(/ +$/,"").split(" "),a.a=Array(b.length),e=0;e<b.length;e++)a.a[e]=Ba(b[e]);Lc(a)}}
function Lc(a){if(!za(a))if(!a.c)A(a);else if(a.a&&a.u){a.b||(a.b=a.a.length);if(a.a.length!=a.b){var b="ROM size ("+B(a.a.length,8,!0)+") does not match specified size ("+B(a.b,8,!0)+")";a.i.error=!0;a.G(b)}else{b=a.g;if(kb(a.u,b,a.b,Cb)){var c;for(c=0;c<a.a.length;c++)sb(a.u,b+c,a.a[c]);b=!0}else b=!1;if(b){b=[];"number"==typeof a.f?b.push(a.f):null!=a.f&&a.f.length&&(b=a.f);for(c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.u,g=d.b,h=[],m=d.g>>>f.b;0<g&&m<f.a.length;)h.push(f.a[m++]),g-=f.c;f=d.u;
d=d.b;g=0;for(e>>>=f.b;0<d&&e<f.a.length;){m=h[g++];if(!m)break;f.a[e++]=m;d-=f.c}}delete a.a}}A(a)}}Va(function(){for(var a=y(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=u(c),d=new Jc(d);sa(d,c)}});
function Mc(a){p.call(this,"RAM",a);this.sa=this.b=null;this.f=a.addr;this.g=a.size;this.Aa=a.load;this.ta=a.exec;this.c=!1;this.a=a.file;this.h=Ca(this.a);if(this.a){a=this.a;var b=Da(this.h);"json"!=b&&"hex"!=b&&(a=Fa()+"/api/v1/dump?file="+this.a+"&format=bytes&decimal=true");var c=this;La(a,null,!0,function(a,b,f){f?c.G("Unable to load RAM resource (error "+f+": "+a+")"):(ka(c.Ka,a,b),(a=Ma(a,b))?(c.b=a.T,c.sa=a.sa,null==c.Aa&&(c.Aa=a.Aa),null==c.ta&&(c.ta=a.ta)):c.a=null,Nc(c))})}}l(Mc,p);