pcjs/versions/pdpjs/1.34.0/pdp10.js

143 lines
46 KiB
JavaScript

(function(){/*
http://pcjs.org/modules/shared/lib/diskapi.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/dumpapi.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/reportapi.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/userapi.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/keys.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/strlib.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/weblib.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/messages.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/device.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/rom.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/ram.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/computer.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/state.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/embed.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/defines.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/int36.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/component.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/usrlib.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/defines.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/panel.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/bus.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/memory.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/cpu.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/cpustate.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/serial.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/shared/lib/debugger.js (C) Jeff Parsons 2012-2017
http://pcjs.org/modules/pdp10/lib/debugger.js (C) Jeff Parsons 2012-2017
*/
var k,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},q="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this;function ba(){ba=function(){};q.Symbol||(q.Symbol=ca)}var da=0;function ca(a){return"jscomp_symbol_"+(a||"")+da++}
function ea(){ba();var a=q.Symbol.iterator;a||(a=q.Symbol.iterator=q.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&aa(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return fa(this)}});ea=function(){}}function fa(a){var b=0;return ga(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})}function ga(a){ea();a={next:a};a[q.Symbol.iterator]=function(){return this};return a}
function r(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a;for(var d in b)if(Object.defineProperties){var e=Object.getOwnPropertyDescriptor(b,d);e&&Object.defineProperty(a,d,e)}else a[d]=b[d]}function ha(a,b){if(b){var c=q;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&aa(c,a,{configurable:!0,writable:!0,value:b})}}
ha("Math.trunc",function(a){return a?a:function(a){a=Number(a);if(isNaN(a)||Infinity===a||-Infinity===a||!a)return a;var b=Math.floor(Math.abs(a));return 0>a?-b:b}});ha("Math.log2",function(a){return a?a:function(a){return Math.log(a)/Math.LN2}});
var ia=Math.pow(2,36),ja=-Math.pow(2,35),t={Ab:0,Qa:1,Cb:2,Db:3,Eb:4,Fb:5,Gb:6,Hb:7,Fa:8,Ib:9,Ra:10,Jb:11,Kb:12,Sa:13,Lb:14,Mb:15,Nb:16,Ob:17,Pb:18,Qb:19,Rb:20,Sb:21,Tb:22,Ub:23,Vb:24,Wb:25,Xb:26," ":32,"!":33,'"':34,"#":35,$:36,"%":37,"&":38,"'":39,"(":40,")":41,"*":42,"+":43,",":44,"-":45,".":46,"/":47,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,":":58,";":59,"<":60,"=":61,">":62,"?":63,"@":64,Ea:65,zb:66,Bb:67,Yb:68,E:69,Zb:70,$b:71,ac:72,bc:73,cc:74,dc:75,ec:76,fc:77,gc:78,hc:79,ic:80,Q:81,
jc:82,kc:83,lc:84,mc:85,nc:86,oc:87,pc:88,qc:89,Wa:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,rc:97,sc:98,tc:99,d:100,e:101,uc:102,vc:103,wc:104,xc:105,yc:106,k:107,zc:108,Ac:109,n:110,Bc:111,p:112,q:113,r:114,Cc:115,t:116,Dc:117,Ec:118,Fc:119,x:120,y:121,z:122,"{":123,"|":124,"}":125,"~":126,Ta:127};
function u(a,b){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Ia=b.comment;this.Va=b;this.exports={};this.i=this.bindings={};a=this.id.indexOf(".");0>a?this.ha=this.id:(this.ia=this.id.substr(0,a),this.ha=this.id.substr(a+1));this.b={ready:!1,ma:!1,za:!1,w:!1,error:!1};this.pa=null;this.b.error=!1;this.o=this.c=this.j=this.m=this.Y=null;v.push(this)}function ka(a,b,c){la[a]&&b&&(la[a][b]=c)}function w(){return Date.now()||+new Date}
function x(a){window&&window.alert(a)}function ma(a){var b=!1;window&&(b=window.confirm(a));return b}function y(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<v.length;b++){var d=v[b];a&&d.id.indexOf(a)||c.push(d)}return c}function na(a){if(void 0!==a){var b;for(b=0;b<v.length;b++)if(v[b].id===a)return v[b]}return null}
function z(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<v.length;d++)if(c)c==v[d]&&(c=null);else if(!(a!=v[d].type||b&&v[d].id.indexOf(b)))return v[d]}return null}function A(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){x(c.message+" ("+a+")")}return b}
function B(a,b){var c=C;b=D(b.parentNode,c+"-control");for(var d=0;d<b.length;d++)for(var e=b[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var l=g.split(" "),m=0;m<l.length;m++)switch(g=l[m],g){case c+"-binding":(g=A(h))&&g.binding&&a.S(g.type,g.binding,h,g.value),m=l.length}}}}
function D(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
function oa(a){for(var b=!0,c=pa[a];c&&c.length;){var d=c.splice(0,1)[0],e=d[0],f=null;0<=qa.indexOf(e)&&(f=function(){return function(){oa(a)}}());var h=ra[e];if(h)if(!f)b=h(d[1],d[2],d[3]);else{if(!h(f,d[1],d[2],d[3]))break}else{var b=!1,g=z(d[1],a);if(g)if(h=sa[e])b=h(g,d[2],d[3]);else{var l=g.exports;if(l&&(h=l[e]))if(b=!0,!f)b=h.call(g,d[2],d[3]);else if(!h.call(g,f,d[2],d[3]))break}}if(!b){x("Script error: "+e+(h?" failed":" unrecognized"));break}}c&&!c.length&&delete pa[a];return b}k=u.prototype;
k.toString=function(){return this.name?this.name:this.id||this.type};
k.S=function(a,b,c){switch(b){case "clear":return this.i[b]||(this.i[b]=c,c.onclick=function(a){return function(){a.i.print&&(a.i.print.value="")}}(this)),!0;case "print":return this.i[b]||(this.Y=this.i[b]=c,c.value="",this.J=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),this.C=function(a){this.J(a,this.ha)}),!0;default:return!1}};k.log=function(){};k.J=function(){};
k.status=function(a){this.J(this.ha+": "+a)};k.C=function(a,b,c){c=c||this.type;b||x((c?c+": ":"")+a)};function ta(a,b){b&&(a.b.ready?b():a.pa=b);return a.b.ready}function E(a){if(!a.b.error&&(a.b.ready=!0,a.b.ready)){var b=a.pa;a.pa=null;b&&b()}}function ua(a,b){a.b.za?(a.b.ma=!1,a.b.za=!1):a.b.error?a.J(a.toString()+" error"):a.b.ma=b}k.T=function(){return this.b.w=!0};k.N=function(a,b){b&&(this.b.w=!1);return!0};
window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
var la=window?window.PCjs.Machines:{},v=window?window.PCjs.Components:[],pa=window?window.PCjs.Commands:{},qa=["hold","sleep","wait"],ra={alert:function(a){x(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},sa={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b<a.options.length;b++)if(a.options[b].textContent==c){a.selectedIndex!=b&&(a.selectedIndex=b);d=!0;break}return d}};
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});
function va(a,b){var c="";b?11<b&&(b=11):b=a&-16777216?11:a&-65536?8:6;if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;)c=String.fromCharCode((a&7)+48)+c,a>>=3;return""+c}function F(a,b,c){var d="";b?8<b&&(b=8):b=a&-65536?8:4;if(null==a||isNaN(a))for(;0<b--;)d="?"+d;else for(;0<b--;){var e=a&15,e=e+(0<=e&&9>=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d}function wa(a){var b=a,c=a.lastIndexOf("/");0<=c&&(b=a.substr(c+1));c=b.indexOf("&");0<c&&(b=b.substr(0,c));return b}
function xa(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}function ya(){var a=G();return-1!==a.indexOf("pcjs.org",a.length-8)}function za(a){return a.replace(/[&<>"']/g,function(a){return Aa[a]})}function Ba(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}var Aa={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};
function Ca(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
function H(a,b,c,d){c=void 0===c?!1:c;var e=0,f=null,h=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),d&&d(a,
f,e))});if(b&&"object"==typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");g.open("POST",a,c);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(l)}else g.open("GET",a,c),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();c||(f=g.responseText,200!=g.status&&(e=g.status||-1),d&&d(a,f,e),h=[f,e]);return h}
function Da(a,b){var c,d={D:null,I:null,R:null,P:null};if("["==b.charAt(0)||"{"==b.charAt(0))try{var e,f,h;if("<"==b.substr(0,1))throw Error(b);h=0>b.indexOf("0x")&&'["'!=b.substr(0,2)?JSON.parse(b.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+b+")");d.R=h.load;d.P=h.exec;if(e=h.bytes)d.D=e;else if(e=h.words)for(d.D=Array(2*e.length),f=c=0;c<e.length;c++)d.D[f++]=e[c]&255,d.D[f++]=e[c]>>8&255;else if(e=h.data)for(d.D=Array(4*e.length),f=c=0;c<e.length;c++)d.D[f++]=e[c]&255,d.D[f++]=
e[c]>>8&255,d.D[f++]=e[c]>>16&255,d.D[f++]=e[c]>>24&255;else d.D=h;d.I=h.symbols;d.D.length?1==d.D.length&&(x(d.D[0]),d=null):(x("Empty resource: "+a),d=null)}catch(g){x("Resource data error ("+a+"): "+g.message),d=null}else{e=[];b=b.replace(/\n/gm," ").replace(/ +$/,"").split(" ");for(c=0;c<b.length;c++){f=parseInt(b[c],16);if(isNaN(f)){x("Resource data error ("+a+"): invalid hex byte ("+b[c]+")");break}e.push(f&255)}c==b.length&&(d.D=e)}return d}
function G(){return"http://"+(window?window.location.host:"www.pcjs.org")}function Ea(){if(null==Fa){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Fa=a}return Fa}function Ga(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function Ha(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Ia(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}
function Ja(a){if(!Ka){var b,c={};if(window){b||(b=window.location.search.substr(1));for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g;d=f.exec(b);)c[decodeURIComponent(d[1].replace(e," "))]=decodeURIComponent(d[2].replace(e," "))}Ka=c}return Ka[a]}function La(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function I(a){J.init.push(a)}
function Ma(a){if(Na)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){x(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function K(a){!Na&&a?(Na=!0,Oa&&Pa("init"),Ra&&Pa("show")):Na=a}function Pa(a){J[a]&&Ma(J[a])}var Ka=null,J={init:[],show:[],exit:[]},Oa=!1,Ra=!1,Na=!0,Fa=null;La("onload",function(){Oa=!0;Ma(J.init)});La("onpageshow",function(){Ra=!0;Ma(J.show)});La(Ia("Opera")||Ia("iOS")?"onunload":"onbeforeunload",function(){Ma(J.exit)});
var C="pdp10",L="PDPjs",Sa=Math.pow(2,18),Ta=Math.pow(2,36),C="pdp10",L="PDPjs";
function Ua(a,b){u.call(this,"Panel",a);this.A=this.B=0;this.O=b;this.f=this.v=this.g=this.h=0;this.F=this.H=-1;this.K=this.L=this.s=!1;this.M=Va;this.l={};this.a={START:[1,1,!0,!1,this.gb],STEP:[1,1,!1,!1,this.hb],ENABLE:[1,1,!1,!1,this.ab],CONT:[1,1,!0,!1,this.Za],DEP:[0,0,!0,!1,this.$a],EXAM:[1,1,!0,!1,this.bb],LOAD:[1,1,!0,!1,this.eb],TEST:[0,0,!0,!1,this.cb]};for(a=0;22>a;a++)this.a["S"+a]=[0,0,!1,!1,this.fb,a];this.o=this.c=this.j=this.m=null;this.exports={hold:this.Ya,toggle:this.sb,reset:this.ob,
set:this.rb};E(this)}r(Ua,u);k=Ua.prototype;k.reset=function(a){this.stop();a&&M(this,this.h=0)};
k.S=function(a,b,c,d){if(this.m&&this.m.S(a,b,c,d)||this.c&&this.c.S(a,b,c,d))return!0;switch(b){case "R0":case "R1":case "R2":case "R3":case "R4":case "R5":case "R6":case "R7":case "NF":case "ZF":case "VF":case "CF":case "PS":return this.i[b]=c,this.B++,!0;default:return"led"==a||"rled"==a?(this.i[b]=c,this.l[b]=d?1:0,this.B++,!0):"switch"==a?(void 0===this.a[b]&&(this.a[b]=[d?1:0,d?1:0]),this.i[b]=c,a=c.parentElement||c,a=a.parentElement||a,a.onmousedown=function(a,b){return function(){Wa(a,b)}}(this,
b),a.onmouseup=a.onmouseout=function(a,b){return function(){N(a,b)}}(this,b),a.ontouchstart=function(a,b){return function(c){Wa(a,b);c.preventDefault()}}(this,b),a.ontouchend=function(a,b){return function(){N(a,b)}}(this,b),!0):u.prototype.S.call(this,a,b,c,d)}};k.U=function(a,b,c,d){this.m=a;this.j=b;this.c=c;this.o=d;Xa(this);Ya(this)};k.T=function(a,b){if(!b)if(this.O&&Za(),!a)this.reset(!0);else if(!this.restore(a))return!1;return!0};k.N=function(a){return a?this.save():!0};
k.save=function(){var a=new O(this);a.set(0,[this.f,this.h,this.g]);return a.data()};k.restore=function(a){if(a=a[0])P(this,this.f=a[0]),M(this,this.h=a[1]),$a(this,a[2]);return!0};k.ob=function(){for(var a in this.a){var b=this.a[a];b[1]=b[0]}Ya(this);return!0};function ab(a,b,c){if(a=a.i[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function Xa(a,b){for(var c in a.l)ab(a,c,null!=b?b:a.l[c])}
function bb(a,b,c){if(a=a.i[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"}function Ya(a){for(var b in a.a)bb(a,b,a.a[b][1])}k.Ya=function(a,b,c){if(Wa(this,b)){if(c){var d=this;setTimeout(function(){N(d,b);a&&a()},+c);return!1}N(this,b)}return!0};
k.rb=function(a,b){if("SR"==a){a=b;b=8;var c;if(a){b||(b=10);var d=a.charAt(0),e=0<a.indexOf(",");e&&(a=a.replace(/,/g,""));"#"==d?(b=8,d=null):"$"==d&&(b=16,d=null);null==d?a=a.substr(1):("0"==d&&(d=a.charAt(1),"b"==d&&e&&(b=2,d=null),"o"==d?(b=8,d=null):"x"==d&&(b=16,d=null)),null==d?a=a.substr(2):(d=a.charAt(a.length-1).toLowerCase(),"y"==d?(b=2,d=null):"."==d?(b=10,d=null):"h"==d&&(b=16,d=null),null==d&&(a=a.substr(0,a.length-1))));var f,d=a;((e=b)&&10!=e?16==e?d.match(/^[0-9a-f]+$/i):8==e?d.match(/^[0-7]+$/):
2==e&&d.match(/^[01]+$/):d.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(c=f|0)}return $a(this,c)}return(c=this.a[a])?(c[1]=+b?1:0,bb(this,a,c[1]),!0):!1};k.sb=function(a){return Wa(this,a)?(N(this,a),!0):!1};function Wa(a,b){var c=a.a[b];return c?(bb(a,b,c[1]=1-c[1]),c[3]=!0,c[4]&&c[4].call(a,c[1],c[5]),b!=cb&&(a.K=b==db,a.L=b==eb),!0):!1}function N(a,b){var c=a.a[b];c&&(c[2]&&c[3]&&(bb(a,b,c[1]=c[0]),c[4]&&c[4].call(a,c[1],c[5])),c[3]=!1)}
k.gb=function(a){a||this.c.b.u||(this.c.f=this.f%Sa,this.a[fb]&&this.a[fb][1]&&Q(this.c))};k.hb=function(){};k.ab=function(a){a||R(this.c)};k.Za=function(a){if(!a&&!this.c.b.u)if(this.a[fb]&&this.a[fb][1])Q(this.c);else{a=this.o;var b;if(b=a)a.b.ma&&(a.b.za=!0),b=!a.b.ma;if(b)ua(a,!0),a.f(0,null),ua(a,!1);else try{var c=this.c.ta(1);0<c&&(gb(this.c,c),hb(this.c,c,!0),ib(this.c,c))}catch(d){"number"!=typeof d&&(c=this.c,a=d.stack||d.message,c.b.error=!0,c.C(a))}this.stop();this.m&&S(this.m)}};
k.$a=function(a){a&&!this.c.b.u&&(this.K&&jb(this),a=M(this,this.h=this.g),this.M==Va?kb(this.j,this.f,a):this.c.ca(this.f,a))};k.bb=function(a){if(!a&&!this.c.b.u){this.L&&jb(this);if(this.M==Va){a=this.j;var b=this.f;a=a.a[(b&a.g)>>>a.f].Ba(b&16383,b)}else a=this.c.Z(this.f);M(this,this.h=a)}};k.eb=function(a){a||this.c.b.u||P(this,this.g)};k.cb=function(a){a?(this.s=!0,Xa(this,!0)):(this.s=!1,Xa(this),$a(this,0))};k.fb=function(a,b){this.g=a?this.g|1<<b:this.g&~(1<<b)};
function jb(a){var b=1,c=a.j.g;a.a[cb]&&a.a[cb][1]||(b=-b);P(a,a.f&~c|a.f+b&c)}function P(a,b){a.f=b&a.j.g;if(a.F!==a.f){a.F=a.f;b=a.F;for(var c=0;22>c;c++){var d=a,e="A"+c,f=b&1<<c;d.l[e]=f;d.s||ab(d,e,f)}}}function M(a,b){a.v=b%Ta;if(a.H!==a.v){a.H=a.v;b=a.H;for(var c=0;16>c;c++){var d=a,e="D"+c,f=b&1<<c;d.l[e]=f;d.s||ab(d,e,f)}}return a.v}function $a(a,b){a.g=b|0;for(b=0;22>b;b++)a.a["S"+b][1]=a.g&1<<b?1:0;Ya(a);return!0}k.stop=function(){P(this,this.c.f)};
function Za(){for(var a=D(document,C,"panel"),b=0;b<a.length;b++){var c=a[b],d=A(c),e=na(d.id);e||(e=new Ua(d,!0));B(e,c)}}var Va=7,db="DEP",fb="ENABLE",eb="EXAM",cb="STEP";I(Za);function lb(a,b,c){u.call(this,"Bus",a);this.c=b;this.o=c;this.s=+a.busWidth||18;this.l=1<<this.s;this.g=this.l-1;this.f=Math.log2(16384);this.h=this.l/16384|0;this.a=[];a=new T;mb(a);this.a=Array(this.h);for(b=0;b<this.h;b++)this.a[b]=a;E(this)}r(lb,u);k=lb.prototype;k.reset=function(){};
k.T=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};k.N=function(a){return a?this.save():!0};k.save=function(){var a=new O(this);a.set(0,nb(this));return a.data()};k.restore=function(a){a:{a=a[0];var b;for(b=0;b<a.length-1;b+=2){var c=a[b],d=a[b+1];if(d&&4096>d.length){for(var e=0,f=Array(4096),h=0;h<d.length-1;)for(var g=d[h++],l=d[h++];g--;)f[e++]=l;d=f}e=this.a[c];if(!e||!e.restore(d)){x("Unable to restore memory block "+c);a=!1;break a}}a=!0}return a};
function ob(a,b,c,d){for(var e=b,f=c,h=e>>>a.f;0<f&&h<a.a.length;){var g=a.a[h],l=16384*h,m=16384-(e-l);m>f&&(m=f);if(g&&g.size){if(g.type==d){if(e+f<=g.X)return g.ra+=g.X-e,g.X=e,!0;if(e>=g.X+g.ra){m=g.size-(e-l);m>f&&(m=f);g.ra=e-g.X+m;e=l+16384;f-=m;h++;continue}}return pb(qb,e,f)}e=new T(0,e,m,16384,d);mb(e,g);a.a[h++]=e;e=l+16384;f-=m}return 0>=f?(a.status("Added "+(c>>10)+"Kb "+rb[d]+" at "+va(b)),!0):pb(sb,b,c)}function kb(a,b,c){a.a[(b&a.g)>>>a.f].sa(b&16383,c&65535,b)}
function nb(a){for(var b=0,c=[],d=0;d<a.h;d++){var e=a.a[d];if(e.oa||e.Xa){c[b++]=d;var f=b++;if(e=e.save()){for(var h=0,g=0,l=[];h<e.length;){for(var m=e[h],p=h+1;p<e.length&&e[p]===m;)p++;l[g++]=p-h;l[g++]=m;h=p}l.length<e.length&&(e=l)}c[f]=e}}return c}function pb(a,b,c){x("Memory block error ("+a+": "+F(b)+","+F(c)+")");return!1}var qb=1,sb=2;function tb(a){u.call(this,"Device",a)}r(tb,u);k=tb.prototype;k.U=function(a,b,c,d){this.j=b;this.m=a;this.c=c;this.o=d;E(this)};
k.T=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};k.N=function(a){return a?this.save():!0};k.reset=function(){};k.save=function(){return(new O(this)).data()};k.restore=function(){return!0};I(function(){for(var a=D(document,C,"device"),b=0;b<a.length;b++){var c,d=a[b];c=A(d);switch(c.type){case "default":c=new tb(c),B(c,d)}}});
function T(a,b,c,d,e){this.id=ub+=2;this.X=b;this.ra=c;this.size=d||0;this.type=e||vb;this.m=e==wb;this.o=this.Oa;this.Z=this.Ba=this.Aa;this.a=this.Pa;this.ca=this.sa=this.Da;this.i=this.j=0;mb(this);this.oa=this.Xa=!1;if(this.size){a=this.c=Array(this.size);for(b=0;b<a.length;b++)a[b]=0;xb(this,yb)}else xb(this)}k=T.prototype;k.save=function(){return this.c};k.restore=function(a){return a&&this.size==a.length?(this.c=a,this.oa=!0):!1};function xb(a,b){b||(b=zb);Ab(a,b,void 0);Bb(a,b,void 0)}
function Ab(a,b,c){c&&a.i||(a.Z=b[2]||a.Aa);if(c||void 0===c)a.o=b[0]||a.Oa,a.Ba=b[2]||a.Aa}function Bb(a,b,c){c&&a.j||(a.ca=!a.m&&b[3]||a.Da);if(c||void 0===c)a.a=b[1]||a.Pa,a.sa=b[3]||a.Da}function mb(a,b){a.i=a.j=0;b&&((a.i=b.i)&&Ab(a,Cb,!1),(a.j=b.j)&&Bb(a,Cb,!1))}k.Oa=function(){return 0};k.Pa=function(){};k.Aa=function(a,b){return this.Z(a,b)};k.Da=function(a,b,c){this.ca(a,b,c)};k.jb=function(a,b,c){c=this.c[c];return c=32>=a+b?c>>a&(1<<b)-1:Math.trunc(c/Math.pow(2,a))%Math.pow(2,b)};
k.mb=function(a){return this.c[a]};k.vb=function(a,b,c,d){var e=this.c[d],f=Math.pow(2,a);c%=Math.pow(2,b);a=e%Math.pow(2,a+b);e=e-a+c*f+a%f;this.c[d]!=e&&(this.c[d]=e,this.oa=!0)};k.xb=function(a,b){this.c[b]=a;this.oa=!0};k.ib=function(a,b,c,d){return this.o(a,b,c,d)};k.kb=function(a,b){return this.Ba(a,b)};k.ub=function(a,b,c,d,e){this.m||this.a(a,b,c,d,e)};k.wb=function(a,b,c){this.m||this.sa(a,b,c)};
var vb=0,wb=2,rb=["NONE","RAM","ROM"],ub=0,zb=[],yb=[T.prototype.jb,T.prototype.vb,T.prototype.mb,T.prototype.xb],Cb=[T.prototype.ib,T.prototype.ub,T.prototype.kb,T.prototype.wb];
function U(a,b){u.call(this,"CPU",a);b=+a.cycles||b;var c=+a.multiplier||1;this.ua=0;this.xa=b;this.L=c;this.va=Math.round(this.xa/1E4)/100;this.H=this.va*this.L;this.wa=this.fa=this.M=this.la=0;this.b.u=this.b.Ca=!1;this.b.G=a.autoStart;"string"==typeof this.b.G&&(this.b.G="true"==this.b.G);this.b.na=!1;this.ja=this.K=0;this.ka=+a.csStart;this.da=+a.csInterval;this.ea=+a.csStop;this.l=[];this.Ja=this.pb.bind(this);this.B=this.h=this.v=this.A=this.g=this.ba=this.s=this.O=this.ya=this.F=0;this.ga=
null;E(this)}r(U,u);k=U.prototype;k.U=function(a,b,c,d){this.m=a;this.j=b;this.o=d;this.ga=a.g;for(a=0;a<Db.length;a++)(b=this.i[Db[a]])&&this.m.S(null,Db[a],b);E(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};
k.T=function(a,b){var c=V(this.m,"autoStart");null!=c?this.b.G="true"==c?!0:"false"==c?!1:!!c:null==this.b.G&&(this.b.G=void 0===this.i.run);if(!b){if(a){Eb(this);if(!this.restore(a))return!1;Fb(this)}else this.reset();this.status("No debugger detected");this.b.G||this.J("CPU will not be auto-started "+(this.ga?"(click Run to start)":"(type 'go' to start)"))}return!0};k.N=function(a){return a?this.save():!0};k.G=function(){return this.b.u?!0:this.b.G?(Q(this),!0):!1};k.Ma=function(){return 0};
function Fb(a){void 0===a.ka&&(a.ka=0);void 0===a.da&&(a.da=-1);void 0===a.ea&&(a.ea=-1);a.b.na=0<=a.ka&&0<a.da;a.b.na&&(a.ja=0,a.K=a.ka-a.B)}function ib(a,b){if(a.b.na){var c=!1;a.ja=a.ja+a.Ma()|0;a.K-=b;0>=a.K&&(a.K+=a.da,c=!0);0<=a.ea&&a.ea<=W(a)&&(a.da=a.ea=-1,Fb(a),R(a),c=!0);c&&a.J(W(a)+" cycles: checksum="+F(a.ja))}}
k.S=function(a,b,c){var d=this;switch(b){case "power":case "reset":return this.i[b]=c,!0;case "run":return this.i[b]=c,c.onclick=function(){var a;if(a=d.m)if(a=d.m,a.b.w)a=!0;else{var b=null,c,g=y(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.b.ready);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.b.w);c++);c==g.length&&(b=a);x("The "+b.type+" component ("+b.id+") is not "+(b.b.ready?"powered yet":"ready yet"+(b.pa?" (waiting for notification)":""))+".");a=!1}a&&(d.b.u?R(d):Q(d))},!0;case "speed":return this.i[b]=
c,!0;case "setSpeed":return this.i[b]=c,c.onclick=function(){X(d,d.L<<1,!0)},c.textContent=this.H.toFixed(2)+"Mhz",!0}return!1};function hb(a,b,c){a.B+=b;c&&(a.v=a.A=0)}function Hb(a,b){var c=1;b&&1<a.L&&a.F&&(c=a.F/a.va);a.wa=Math.round(1E3/Ib);a.fa=Math.floor(a.xa/Ib*c);b||(a.M=a.fa);a.la=0}function W(a){return a.B+a.h+a.v-a.A}function Eb(a){a.F=0;a.ya=0;a.B=a.h=a.v=a.A=0;Fb(a);X(a,1)}
function X(a,b,c){if(void 0!==b){.8>a.F/a.H&&(b=1);a.L=b;b=a.va*a.L;if(a.H!=b){a.H=b;b=a.H.toFixed(2)+"Mhz";var d=a.i.setSpeed;d&&(d.textContent=b);a.J("target speed: "+b)}c&&a.m&&(c=a.m,c.Y&&(d=b=0,window&&(b=window.scrollX,d=window.scrollY),c.Y.focus(),window&&window.scrollTo(b,d)))}hb(a,a.h);a.h=0;a.g=w();a.s=0;Hb(a)}function Jb(a){for(var b=[],c=0;c<a.l.length;c++)b.push(a.l[c][0]);return b}
function gb(a,b){for(var c=a.l.length-1;0<=c;c--){var d=a.l[c];0>d[0]||(d[0]-=b,0>=d[0]&&(d[0]=-1,d[1]()))}}function Kb(a,b){var c=a.v-=a.A;a.A=0;b&&(a.v=0);return c}
k.pb=function(){if(this.b.u){this.la>=this.xa&&Hb(this,!0);this.O=0;this.ba=w();if(this.s){var a=this.ba-this.s;a>this.wa&&(this.g+=a,this.g>this.ba&&(this.g=this.ba))}try{do{for(var b,c=this.b.na?1:this.fa,d=this.l.length-1;0<=d;d--){var e=this.l[d];0>e[0]||c>e[0]&&(c=e[0])}b=c;try{this.ta(b)}catch(f){if("number"!=typeof f)throw f;}b=Kb(this,!0);this.O+=b;this.h+=b;ib(this,b);gb(this,b);this.M-=b;if(0>=this.M){this.M+=this.fa;++this.ya>=Lb&&(this.m&&S(this.m,void 0),this.ya=0);break}}while(this.b.u)}catch(f){R(this);
this.m&&this.m.stop(w(),W(this));a=f.stack||f.message;this.b.error=!0;this.C(a);return}if(this.b.u){a=setTimeout;b=this.Ja;this.s=w();c=this.wa;this.O&&(c=Math.round(c*this.O/this.fa));c-=this.s-this.ba;if(d=this.s-this.g)this.F=Math.round(this.h/(10*d))/100,864E5<=d&&(this.B=0,X(this));if(0>c||this.F<this.H)-1E3>c&&(this.g-=c),c=0;this.la+=this.O;this.s+=c;a(b,c)}}};
function Q(a){var b;a.b.error?(a.J(a.toString()+" error"),b=!0):b=!1;if(!b)if(a.b.u)a.J(a.toString()+" busy");else{X(a);a.b.u=!0;a.b.Ca=!0;if(b=a.i.run)b.textContent="Halt";a.m&&a.m.start(a.g,W(a));a.o||a.status("Started");setTimeout(a.Ja,0)}}k.ta=function(){return 0};function R(a){var b=!1;if(a.b.u){Kb(a);hb(a,a.h);a.h=0;a.b.u=!1;if(b=a.i.run)b.textContent="Run";a.m&&a.m.stop(w(),W(a));b=!0;a.o||a.status("Stopped")}a.b.complete=void 0;return b}var Ib=30,Lb=15,Db=["power","reset"];
function Mb(a){var b=+a.model||1001;U.call(this,a,6666667);this.Ua=b;this.Ha=+a.addrReset||0;this.W=null;this.Ga=[];this.b.complete=!1}r(Mb,U);k=Mb.prototype;k.reset=function(){this.status("Model "+this.Ua);this.b.u&&R(this);this.V=this.f=this.Ka=this.Ha;this.a=0;this.Z=this.lb;this.ca=this.yb;this.W=null;Eb(this);this.b.error=!1;U.prototype.reset.call(this)};k.Ma=function(){return 0};
k.save=function(){var a=new O(this);a.set(0,[this.f,this.Ka,this.V,this.a]);a.set(1,[]);a.set(2,[this.B,this.L,this.b.G]);a.set(3,Nb(this));a.set(4,Jb(this));return a.data()};
k.restore=function(a){var b;b=a[0];ea();ba();ea();var c=b[Symbol.iterator];b=c?c.call(b):fa(b);this.f=b.next().value;this.Ka=b.next().value;this.V=b.next().value;this.a=b.next().value;b=a[2];this.B=b[0];X(this,b[1]);this.b.G=b[2];b=a[3];for(c=b.length-1;0<=c;c--){var d;a:{for(d=0;d<this.Ga.length;d++){var e=this.Ga[d];if(e.tb===b[c]){d=e;break a}}d=null}d&&(d.next=this.W,this.W=d)}a=a[4];for(b=0;b<this.l.length&&b<a.length;b++)this.l[b][0]=a[b];return!0};
function Nb(a){var b=[];for(a=a.W;a;)b.push(a.tb),a=a.next;return b}k.lb=function(a){var b=this.j;a=this.V=a;return b.a[(a&b.g)>>>b.f].Z(a&16383,a)};k.yb=function(a,b){var c=this.j;a=this.V=a;c.a[(a&c.g)>>>c.f].ca(a&16383,b,a)};
k.ta=function(a){this.b.complete=!0;var b=a?this.b.Ca?0:1:-1;this.b.Ca=!1;this.v=this.A=a;this.a=this.a&-5|0;do{if(a=this.a)if(a=this.a&11)this.a&2?this.W||(this.a&=-3):this.a&1&&this.a++,a=!1;if(a){if(this.a&4&&this.o.h(this.f,b)){R(this);break}if(0>b)break}this.a&=15;a=this.f;this.Z(a);this.f=(a+1)%Sa}while(0<this.A);return this.b.complete?this.v-this.A:!1===this.b.complete?-1:0};I(function(){for(var a=D(document,C,"cpu"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Mb(d);B(d,c)}});
function Ob(a){u.call(this,"ROM",a);this.I=this.a=null;this.l=+a.addr;this.g=+a.size;this.f=a.alias;"string"==typeof this.f&&(this.f=eval(this.f));this.h=a.file;this.s=wa(this.h);if(this.h){a=this.h;var b=xa(this.s);"json"!=b&&"hex"!=b&&(a=G()+"/api/v1/dump?file="+this.h+"&format=bytes&decimal=true");var c=this;H(a,null,!0,function(a,b,f){f?(c.C("Unable to load ROM resource (error "+f+": "+a+")"),c.h=null):(ka(c.ia,a,b),(a=Da(a,b))?(c.a=a.D,c.I=a.I):c.h=null);Pb(c)})}}r(Ob,u);
Ob.prototype.U=function(a,b,c,d){this.j=b;this.c=c;this.o=d;Pb(this)};Ob.prototype.T=function(){this.I&&(this.o&&this.o.a(this.id,this.l,this.g,this.I),delete this.I);return!0};Ob.prototype.N=function(){return!0};
function Pb(a){if(!ta(a)){if(a.h){if(!a.a||!a.j)return;a.g||(a.g=a.a.length);if(a.a.length!=a.g){var b="ROM size ("+F(a.a.length,8,!0)+") does not match specified size ("+F(a.g,8,!0)+")";a.b.error=!0;a.C(b)}else{b=a.l;if(ob(a.j,b,a.g,wb)){var c;for(c=0;c<a.a.length;c++)kb(a.j,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.j,h=d.g,g=[],l=d.l>>>f.f;0<h&&l<f.a.length;)g.push(f.a[l++]),h-=16384;f=d.j;
d=d.g;h=0;for(e>>>=f.f;0<d&&e<f.a.length;){l=g[h++];if(!l)break;f.a[e++]=l;d-=16384}}delete a.a}}}E(a)}}I(function(){for(var a=D(document,C,"rom"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Ob(d);B(d,c)}});
function Y(a){u.call(this,"RAM",a);this.I=this.f=null;this.g=+a.addr;this.h=+a.size;this.R=a.load;this.P=a.exec;null!=this.R&&(this.R=+this.R);null!=this.P&&(this.P=+this.P);this.l=!1;this.a=a.file;this.s=wa(this.a);if(this.a){a=this.a;var b=xa(this.s);"json"!=b&&"hex"!=b&&(a=G()+"/api/v1/dump?file="+this.a+"&format=bytes&decimal=true");var c=this;H(a,null,!0,function(a,b,f){f?(c.C("Unable to load RAM resource (error "+f+": "+a+")"),c.a=null):(ka(c.ia,a,b),(a=Da(a,b))?(c.f=a.D,c.I=a.I,null==c.R&&
(c.R=a.R),null==c.P&&(c.P=a.P)):c.a=null);Qb(c)})}}r(Y,u);Y.prototype.U=function(a,b,c,d){this.j=b;this.c=c;this.o=d;Qb(this)};Y.prototype.T=function(a,b){this.I&&(this.o&&this.o.a(this.id,this.g,this.h,this.I),delete this.I);b||this.reset();return!0};Y.prototype.N=function(){return!0};
function Qb(a){if(a.j&&(!a.l&&a.h&&(ob(a.j,a.g,a.h,1)?a.l=!0:a.h=0),!ta(a))){if(!a.l)x("No RAM allocated");else if(a.a){if(!a.f||!a.j)return;Rb(a,a.f,a.R,a.P,a.g)?a.status('Loaded image "'+a.s+'"'):a.C('Error loading image "'+a.s+'"')}E(a)}}
Y.prototype.reset=function(){if(this.l){for(var a=this.j,b=this.g,c=this.h,d=b&16383,b=b>>>a.f;0<c&&b<a.a.length;){var e=a.a[b],f=c,h=0,g,d=d||0,h=h||0;0>h&&h>=ja&&(h+=ia);h=Math.trunc(Math.abs(h))%ia;void 0===f&&(f=e.size);for(g=d;f--&&g<e.size;g++)e.sa(d,h,e.X+d);c-=16384;b++;d=0}this.f&&Rb(this,this.f,this.R,this.P,this.g,!this.o)}};
function Rb(a,b,c,d,e,f){var h=!1,g=!1;if(null==c)for(var l=0;l<b.length-1;){var m=b[l]&255|(b[l+1]&255)<<8;if(m)if(m&255){if(1!=m)break;if(l+6>=b.length)break;for(var l=l+2,p=b[l++]&255|(b[l++]&255)<<8,n=b[l++]&255|(b[l++]&255)<<8,m=m+((p&255)+(p>>8)+(n&255)+(n>>8)),Qa=l,Gb=p-=6;0<p&&l<b.length;)m+=b[l++]&255,p--;if(p||l>=b.length)break;m+=b[l++]&255;if(m&255)break;if(Gb)for(;Gb--;)kb(a.j,n++,b[Qa++]);else n&1?h=!0:null==d&&(d=n);g=!0}else l++;else l+=2}if(!g&&(null==c&&(c=e),null!=c)){for(g=0;g<
b.length;g++)kb(a.j,c+g,b[g]);g=!0}if(g){if(null==d||h)R(a.c),f=!1;null!=d&&(a=a.c,a.Ha=d,a.f=d%Sa,f?a.b.w?a.b.u||Q(a):a.b.G=!0:a.o&&a.b.w?R(a)||a.m.b.reset||(a.o.g(),S(a.m,-1)):!1===f&&R(a),!a.b.u&&a.ga&&a.ga.stop())}return g}I(function(){for(var a=D(document,C,"ram"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Y(d);B(d,c)}});
function Sb(a){u.call(this,"SerialPort",a);this.h=a.upperCase;"string"==typeof this.h&&(this.h="true"==this.h);this.g=!0;this.f=[];var b=a.binding;if("console"!=b){var c;a=Tb;b&&(void 0===c&&(c="Panel"),(c=z(c,this.id))&&(b=c.i[b])&&this.S(null,a,b))}this.a=this.l=null;this.exports={connect:this.Na,receiveData:this.qa,receiveStatus:this.nb,setConnection:this.qb}}r(Sb,u);k=Sb.prototype;
k.S=function(a,b,c){var d=this;switch(b){case Tb:return this.i[b]=c,c.onkeydown=function(a){a=a||window.event;var b=0,c=a.keyCode;8==c?b=a.altKey?t.Fa:t.Ta:46==c?b=t.Fa:a.ctrlKey&&c>=t.Ea&&c<=t.Wa&&(b=c-(t.Ea-t.Qa));b&&(a.preventDefault&&a.preventDefault(),d.qa(b));return!0},c.onkeypress=function(a){a=a||window.event;if(!a.metaKey){var b=a.which||a.keyCode;a.altKey&&b==t.Sa&&(b=t.Ra);d.qa(b);a.preventDefault&&a.preventDefault()}return!0},c.onpaste=function(a){a.stopPropagation&&a.stopPropagation();
a.preventDefault&&a.preventDefault();(a=a.clipboardData||window.clipboardData)&&d.qa(a.getData("Text"))},c.removeAttribute("readonly"),!0}return!1};k.U=function(a,b,c,d){this.m=a;this.j=b;this.c=c;this.o=d;E(this)};
k.Na=function(a){if(!this.a){var b=V(this.m,"connection");if(b){var c=b.split("->");if(2==c.length){var d=Ba(c[0]);if(d!=this.ha)return;c=Ba(c[1]);if(this.a=na(c)){var e=this.a.exports;if(e){var f=e.connect;f&&f.call(this.a,this.g);if(this.l=e.receiveData){this.g=a;this.status("Connected "+this.ia+"."+d+" to "+c);return}}}}this.status("Unable to establish connection: "+b)}}};k.T=function(a,b){if(!b)if(this.Na(this.g),!a)this.reset();else if(!this.restore(a))return!1;return!0};
k.N=function(a){return a?this.save():!0};k.reset=function(){};k.save=function(){var a=new O(this);a.set(0,[]);return a.data()};k.restore=function(){return!0};k.qa=function(a){if("number"==typeof a)this.f.push(a);else if("string"==typeof a)for(var b=0,c,d=0;d<a.length;d++){c=b;b=a.charCodeAt(d);if(10==b){if(13==c)continue;b=13}this.f.push(b)}else this.f=this.f.concat(a);return!0};k.nb=function(){};k.qb=function(a,b){return this.a?!1:(this.a=a,this.l=b,!0)};var Tb="buffer";
I(function(){for(var a=D(document,C,"serial"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Sb(d);B(d,c)}});
function Ub(a,b,c){u.call(this,"Computer",a);this.b.w=!1;this.L=null;Vb(this,b);this.H=V(this,"autoPower",a,6);this.h=0;this.V=+a.busWidth||+a.buswidth;this.B=this.s=this.F=null;this.A=this.O=!1;this.v=this.l=null;this.M=this.K=!1;this.W=V(this,"url")||"";(Math.random()+.1).toString(36);this.f=Wb(this);if(this.c=z("CPU",this.id)){this.o=z("Debugger",this.id);this.j=new lb({id:this.ia+".bus",busWidth:this.V},this.c,this.o);var d,e=y(this.id);if((this.g=z("Panel",this.id))&&this.g.Y)for(b=0;b<e.length;b++)d=
e[b],d.C=this.g.C,d.J=this.g.J,d.Y=this.g.Y;this.J(L+" v1.34.0\nCopyright \u00a9 2012-2017 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.U&&d.U(this,this.j,this.c,this.o);b=null;d=V(this,"resume",a);void 0!==d&&(1<d.length?b=this.s=d:this.a=parseInt(d,10));var f;if(a=V(this,"state")||(f=!0,a.state))this.F=b=a,f||(this.A=!0,this.a=Xb),this.a&&(this.v=new O(this,"1.34.0"),Z(this.v)?b=null:delete this.v);!b&&this.a&&
(b=Yb(this))&&(this.A=!0);if(b){var h=this;H(b,null,!0,function(a,b,c){c?(h.s=null,h.A=!1,h.C("Unable to load machine state from server (error "+c+(b?": "+Ba(b):"")+")")):(h.B=b,h.O=!0);E(h)})}else E(this);this.i.power||(this.H=!0);!c&&this.H&&Zb(this,this.aa)}else x("Unable to find CPU component")}r(Ub,u);function Vb(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){x(d.message+" ("+c+")")}}a.L=b}
function V(a,b,c,d){var e=b.toLowerCase(),e=Ja(b)||Ja(e);void 0===e&&a.L&&(e=a.L[b]);void 0===e&&c&&(e=c[b]);void 0===e&&"object"==typeof resources&&resources[b]&&(e=b);void 0===e&&(e=void 0);if("string"==typeof e&&d)switch(d){case 4:e=+e;isNaN(e)&&(e=0);break;case 6:e="true"==e}return e}function Zb(a,b,c){for(var d=y(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!ta(f)){ta(f,function(){Zb(a,b,c)});return}}b.call(a,c)}
function $b(a,b){var c=new O(a,"1.34.0",ac);if(Z(c)&&bc(c)){var d=c.get(cc),e=b?b.get(cc):"unknown";d!=e&&(a.C("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=Ub.prototype;
k.aa=function(a){void 0===a&&(a=this.a||(this.B?dc:Xb));if(!this.h){this.h++;var b=!1,c=!1;this.K=!1;var d=this.v||new O(this,"1.34.0");if(a==ec)b=!0;else if(a>Xb){if(Z(d,this.B)){this.l=new O(this,"1.34.0",fc);Z(this.l)&&(gc(this,d),a=hc,ic(this.l));this.l.set(cc,Ca());jc(this.l);var e=this.a&&!this.A;if(a==dc||ma("Click OK to restore the previous "+L+" machine state, or CANCEL to reset the machine.")){if(c=bc(d)){var f=d.get("code"),h=d.get("data");f&&("ok"==f?Z(d,h):("error"==f&&"no machine state"!=
h?(this.C("Error: "+h),"unable to verify user"==h&&(Ha(kc,""),this.f=null)):this.J(f+": "+h),ic(d),Z(d)?(c=bc(d),e=!0):c=!1))}e&&$b(this,c?d:null)}else a==hc&&d.clear()}else $b(this);delete this.B;delete this.v}e=y(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.c&&(c=lc(this,h,d,b,c));b=[d,a,c];a!=ec?Zb(this,this.La,b):this.La(b)}};
function lc(a,b,c,d,e){if(!b.b.w){b.b.w=!0;var f=null;try{if(e&&((f=c.get(b.id))||(f=c.get(b.id.replace(/[a-z0-9]\./i,".")))),"string"===typeof f&&(f=null),!b.T(f,d)&&f&&(x("Unable to restore state for "+b.type),a.F&&!a.O?(c.clear(),a.a=Xb,window&&window.location.reload()):a.K=!0,b.T(null),e=!1),!d&&b.Ia){var h=b.Ia.split("|");for(a=0;a<h.length;a++)b.status(h[a])}}catch(g){x("Error restoring state for "+b.type+" ("+g.message+")")}}return e}
k.La=function(a){var b=a[0],c=0>a[1];a=a[2];this.M=!0;this.b.w=!0;var d=this.i.power;d&&(d.textContent="Shutdown");this.c&&(lc(this,this.c,b,c,a),S(this,-2),this.c.G());this.K&&(gc(this,b),b.clear());!c&&this.l&&(this.l.clear(),delete this.l);this.h=0};
function gc(a,b){if(ma("There may be a problem with your "+L+" machine.\n\nTo help us diagnose it, click OK to send this "+L+" machine state to http://www.pcjs.org.")){var c=a.W;a=a.f||"";b=b.toString();var d={};d.app=L;d.ver="1.34.0";d.url=c;d.user=a;d.type="bug";d.data=b;H("http://www.pcjs.org/api/v1/report",d,!0)}}
function mc(a,b,c){var d,e="none";if(a.h)return null;a.h--;var f=new O(a,"1.34.0"),h=new O(a,"1.34.0",ac),g=Ca();h.set(cc,g);f.set(cc,g);f.set(nc,"1.34.0");f.set(oc,window?window.location.href:null);f.set(pc,window?window.navigator.userAgent:"");a.c&&a.c.N&&(c&&(b&&(a.c.b.G=a.c.b.u),R(a.c)),d=a.c.N(b,c),"object"===typeof d&&f.set(a.c.id,d),c&&(a.c.b.w=!1,!1===d&&(e=null)));for(var g=y(a.id),l=0;l<g.length;l++){var m=g[l];m.b.w&&(m.N&&(d=m.N(b,c),"object"===typeof d&&f.set(m.id,d)),c&&(m.b.w=!1,!1===
d&&(e=null)))}e&&(c?(g=d=!1,b?(a.f&&qc(a,a.f,f.toString()),jc(h)&&jc(f)||(e=null,d=g=!0)):a.a&&(d=!0,g=a.a==rc),d&&f.clear(g)):e=f.toString());c&&(a.b.w=!1,b=a.i.power)&&(b.textContent="Power");a.h=0;return e}k.reset=function(){this.b.reset=!0;this.j&&this.j.reset&&this.j.reset();this.c&&this.c.reset&&this.c.reset();for(var a=y(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.j&&c!==this.c&&c.reset&&c.reset()}this.b.reset=!1;S(this,-1)};
k.start=function(a,b){for(var c=y(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}S(this,-1)};k.stop=function(a,b){for(var c=y(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}S(this,-1)};
function S(a,b){if(a.c){var c=a.c,d=b||0,e=c.i.speed;e&&(0>=d||30<=(c.ua+=d))&&(e.textContent=c.b.u?c.F.toFixed(2)+"Mhz":"Stopped",c.ua=0)}if(a.g&&(a=a.g,b=b||0,a.B)){c=a.c.b.u;d=!!(a.c.a&8);if(0>=b||60<=(a.A+=b)){e=a.c.f;if(a.i.PC){var f=a.o&&a.o.l||8,e=e||0,e=8==f?va(e,void 0):F(e,void 0);a.i.PC.textContent!=e&&(a.i.PC.textContent=e)}a.A=0}-1>b?a.f=a.c.f:0<b&&c&&!d&&(a.f=a.c.V);P(a,a.f);M(a,a.h)}}
k.S=function(a,b,c){var d=this;switch(b){case "power":return this.i[b]=c,c.onclick=function(){d.h||(d.b.w?mc(d,!1,!0):Zb(d,d.aa))},!0;case "reset":return this.i[b]=c,c.onclick=function(){if(d.b.w&&!d.h)if(d.a&&!d.s){var a=ma("Click OK to save changes to this "+L+" machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");mc(d,a,!0);!a&&d.F?window&&window.location.reload():d.aa(Xb)}else d.reset(),d.c&&!d.o&&d.c.G()},!0;case "save":if(ya())c.parentNode.removeChild(c);else return this.i[b]=
c,c.onclick=function(){var a=Wb(d,!0);if(a){var b=!!(d.a&&!d.s||d.F),c=mc(d,b);b?qc(d,a,c):d.C("Resume disabled, machine state not saved")}},!0}return!1};function Wb(a,b){var c=a.f;c||((c=Ga(kc),void 0!==c)?!c&&b&&(b=null,window&&(b=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c=b)&&((c=sc(a,c))||a.C("The user ID is invalid.")):b&&a.C("Browser local storage is not available"));return c}
function sc(a,b){a.f=null;b=H(G()+"/api/v1/user?req=verify&user="+b);var c=b[1];if(!b[0]&&c)try{b=eval("("+c+")"),b.code&&"ok"==b.code&&(Ha(kc,b.data),a.f=b.data)}catch(d){x(d.message+" ("+c+")")}return a.f}function Yb(a){var b=null;a.f&&(b=G()+"/api/v1/user?req=load&user="+a.f+"&state="+tc(a,"1.34.0"));return b}
function qc(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=tc(a,"1.34.0");d.data=c;b=H(G()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.C("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.C(c),Ha(kc,""),a.f=null)}}
var fc="failsafe",ac="validate",cc="timestamp",nc="version",oc="url",pc="browser",kc="user",ec=-1,Xb=0,dc=1,hc=2,rc=3;I(function(){for(var a=D(document,C+"-machine"),b=0;b<a.length;b++)for(var c=a[b],d=A(c),c=D(c,C,"computer"),e=0;e<c.length;e++){var f=c[e],h=A(f),h=new Ub(h,d,!0);B(h,f);h.H&&Zb(h,h.aa)}});J.show.push(function(){for(var a=D(document,C,"computer"),b=0;b<a.length;b++){var c=A(a[b]);(c=z("Computer",c.id))&&c.M&&!c.b.w&&c.aa(ec)}});
J.exit.push(function(){for(var a=D(document,C,"computer"),b=0;b<a.length;b++){var c=A(a[b]);(c=z("Computer",c.id))&&c.b.w&&mc(c,!(!c.a||c.s),!0)}});function O(a,b,c){this.id=a.id;this.i="";this.c={};this.j=this.m=!1;this.key=tc(a,b,c);ic(this,a.Va)}k=O.prototype;k.set=function(a,b){try{this.c[a]=b}catch(c){}};k.get=function(a){return this.c[a]||null};k.data=function(){return this.c};function Z(a,b){return b?(a.i=b,a.j=!0,a.m=!1,!0):a.j?!0:Ea()&&(b=Ga(a.key))?(a.i=b,a.j=!0):!1}
function bc(a){var b=!0;if(!a.m)try{a.c=JSON.parse(a.i),a.m=!0}catch(c){x(c.message||c),b=!1}return b}function jc(a){var b=!0;if(Ea()){var c=JSON.stringify(a.c);Ha(a.key,c)||(x("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}k.toString=function(){return this.c?JSON.stringify(this.c):this.i};function ic(a,b){a.i="";a.c={};a.j=a.m=!1;b&&a.set("parms",b)}
k.clear=function(a){ic(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}};function tc(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}var uc=0;
function vc(a,b,c,d,e,f){e("Loading "+a+"...");H(a,null,!0,function(h,g,l){l?(g||(g="unable to load "+a+" ("+l+")"),f(g,null)):wc(g,a,b,c,d,e,f)})}
function wc(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{c&&(ka(c,b,a),(f=b)&&0>f.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{",d+='url:"'+f+'"}',"object"==typeof resources&&(f=null),a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/(<xsl:variable name="APPNAME">).*?(<\/xsl:variable>)/,"$1PDPjs$2"),
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pdp11$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(p){f=null,a=p.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,f)}}a?e?xc(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
function xc(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");H(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=g[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);g[0]!=l&&(h=h.replace(g[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],h);xc(a,b,c)}})}else c(a,null)}
function yc(a,b,c,d){function e(a){if(void 0===g){var b=h&&D(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=za(a))}function f(a){e("Error: "+a);l&&(--uc||K(!0));l=!1}var h,g,l=!0;uc++;la[a]={};try{if(h=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css";n.styleSheet?n.styleSheet.cssText=m:n.appendChild(document.createTextNode(m));p.appendChild(n)}c||
(c="/versions/pdpjs/1.34.0/components.xsl");m=function(d,g){g?vc(c,null,null,!1,e,function(d,l){l?(ka(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(l=g.transformNode(l))?(h.outerHTML=l,--uc||K(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(l),(l=d.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--uc||K(!0)):f("invalid machine element: "+a):
f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?vc(b,a,d,!0,e,m):wc(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(Qa){f(Qa.message)}return l}window.embedPDP11=function(a,b,c,d){K(!1);return yc(a,b,c,d)};window.findMachineComponent=function(a,b){return z(b,a+".machine")};
window.processMachineScript=function(a,b){var c=!1;a+=".machine";if("string"==typeof b&&!pa[a]){for(var c=!0,d=pa,e=a,f=b.length,h=[],g=[],l="",m=null,p=0;p<f;p++){var n=b[p];if('"'==n||"'"==n)m&&n!=m?l+=n:(m?m=null:m=n,l&&(g.push(l),l=""));else{if(!m){if("\r"==n||"\n"==n)n=";";if(" "==n||"\t"==n||";"==n){l&&(g.push(l),l="");";"==n&&g.length&&(h.push(g),g=[]);continue}}l+=n}}l&&g.push(l);g.length&&h.push(g);d[e]=h;oa(a)||(c=!1)}return c};window.enableEvents=K;window.sendEvent=Pa;})();//# sourceMappingURL=/tmp/pdpjs/1.34.0/pdp10.map