v86 0.5.366 → 0.5.367
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/libv86-debug.js +9 -2
- package/build/libv86-debug.mjs +9 -2
- package/build/libv86.js +88 -88
- package/build/libv86.mjs +384 -383
- package/package.json +1 -1
package/build/libv86.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
;(function(){'use strict';function ba(a,b){return(a||0===a?a+"":"").padEnd(b," ")}function k(a,b,c,d){return new Proxy({},{get:function(e,f){e=new a(b.buffer,c,d);const g=e[f];if("function"===typeof g)return g.bind(e);/^\d+$/.test(f);return g},set:function(e,f,g){/^\d+$/.test(f);(new a(b.buffer,c,d))[f]=g;return!0}})}function y(a,b){a=(a?a.toString(16):"").toUpperCase();return"0x"+(a||0===a?a+"":"").padStart(b||1,"0")}var ca;
|
|
2
2
|
if("undefined"!==typeof crypto&&crypto.getRandomValues){const a=new Int32Array(1);ca=function(){crypto.getRandomValues(a);return a[0]}}else if("undefined"!==typeof require){const a=require("crypto");ca=function(){return a.randomBytes(4).readInt32LE(0)}}else"undefined"!==typeof process&&import("node:crypto").then(a=>{ca=function(){return a.randomBytes(4).readInt32LE(0)}});var da;
|
|
3
3
|
if("function"===typeof Math.clz32)da=function(a){return 31-Math.clz32(a)};else{for(var ea=new Int8Array(256),fa=0,ia=-2;256>fa;fa++)fa&fa-1||ia++,ea[fa]=ia;da=function(a){a>>>=0;var b=a>>>16;if(b){var c=b>>>8;return c?24+ea[c]:16+ea[b]}return(c=a>>>8)?8+ea[c]:ea[a]}}function ja(a){return 1>=a?1:1<<1+da(a-1)}
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
4
|
+
function ma(a){var b=new Uint8Array(a),c,d;this.length=0;this.push=function(e){this.length!==a&&this.length++;b[d]=e;d=d+1&a-1};this.shift=function(){if(this.length){var e=b[c];c=c+1&a-1;this.length--;return e}return-1};this.peek=function(){return this.length?b[c]:-1};this.clear=function(){this.length=d=c=0};this.clear()}function na(a){this.size=a;this.data=new Float32Array(a);this.length=this.end=this.start=0}
|
|
5
|
+
na.prototype.push=function(a){this.length===this.size?this.start=this.start+1&this.size-1:this.length++;this.data[this.end]=a;this.end=this.end+1&this.size-1};na.prototype.shift=function(){if(this.length){var a=this.data[this.start];this.start=this.start+1&this.size-1;this.length--;return a}};
|
|
6
|
+
na.prototype.shift_block=function(a){var b=new Float32Array(a);a>this.length&&(a=this.length);var c=this.start+a,d=this.data.subarray(this.start,c);b.set(d);c>=this.size&&(c-=this.size,b.set(this.data.subarray(0,c),d.length));this.start=c;this.length-=a;return b};na.prototype.peek=function(){if(this.length)return this.data[this.start]};na.prototype.clear=function(){this.length=this.end=this.start=0};
|
|
7
|
+
function oa(a){"number"===typeof a?this.view=new Uint8Array(a+7>>3):a instanceof ArrayBuffer&&(this.view=new Uint8Array(a))}oa.prototype.set=function(a,b){const c=a>>3;a=1<<(a&7);this.view[c]=b?this.view[c]|a:this.view[c]&~a};oa.prototype.get=function(a){return this.view[a>>3]>>(a&7)&1};oa.prototype.get_buffer=function(){return this.view.buffer};var pa,qa;
|
|
8
8
|
if("undefined"===typeof XMLHttpRequest||"undefined"!==typeof process&&process.versions&&process.versions.node){let a;const b=async function(){return"undefined"!==typeof require?require("fs").promises:import("node:fs/promises")};pa=async function(c,d){a||(a=await b());if(d.range){c=await a.open(c,"r");const e=Buffer.allocUnsafe(d.range.length);try{await c.read({buffer:e,position:d.range.start})}finally{await c.close()}d.done&&d.done(new Uint8Array(e))}else c=await a.readFile(c,{encoding:d.as_json?
|
|
9
9
|
"utf-8":null}),c=d.as_json?JSON.parse(c):(new Uint8Array(c)).buffer,d.done(c)};qa=async function(c){a||(a=await b());return(await a.stat(c)).size}}else pa=async function(a,b,c){function d(){const m=c||0;setTimeout(()=>{pa(a,b,m+1)},1E3*([1,1,2,3,5,8,13,21][m]||34))}var e=new XMLHttpRequest;const f=()=>e.abort();if(b.signal){if(b.signal.aborted)return;b.signal.addEventListener("abort",f,{once:!0})}e.open(b.method||"get",a,!0);e.responseType=b.as_json?"json":"arraybuffer";if(b.headers)for(var g=Object.keys(b.headers),
|
|
10
10
|
h=0;h<g.length;h++){var l=g[h];e.setRequestHeader(l,b.headers[l])}b.range&&(g=b.range.start,e.setRequestHeader("Range","bytes="+g+"-"+(g+b.range.length-1)),e.setRequestHeader("X-Accept-Encoding","identity"),e.onreadystatechange=function(){200===e.status&&(console.error("Server sent full file in response to ranged request, aborting",{filename:a}),e.abort())});e.onload=function(){b.signal&&b.signal.removeEventListener("abort",f);if(4===e.readyState)if(200!==e.status&&206!==e.status)console.error("Loading the image "+
|
|
11
11
|
a+" failed (status %d)",e.status),500<=e.status&&600>e.status&&d();else if(e.response){if(b.range){const m=e.getResponseHeader("Content-Encoding");m&&"identity"!==m&&console.error("Server sent Content-Encoding in response to ranged request",{filename:a,enc:m})}b.done&&b.done(e.response,e)}};e.onerror=function(m){b.signal&&b.signal.removeEventListener("abort",f);console.error("Loading the image "+a+" failed",m);d()};b.progress&&(e.onprogress=function(m){b.progress(m)});e.send(null)},qa=async function(a){return new Promise((b,
|
|
12
12
|
c)=>{pa(a,{done:(d,e)=>{d=e.getResponseHeader("Content-Range")||"";(e=d.match(/\/(\d+)\s*$/))?b(+e[1]):c(Error("`Range: bytes=...` header not supported (Got `"+d+"`)"))},headers:{Range:"bytes=0-0","X-Accept-Encoding":"identity"}})})};function ra(a,b,c){return String.fromCharCode(...(new Uint8Array(a.buffer,b>>>0,c>>>0)))}
|
|
13
13
|
const sa={cp437:" \u263a\u263b\u2665\u2666\u2663\u2660\u2022\u25d8\u25cb\u25d9\u2642\u2640\u266a\u266b\u263c\u25ba\u25c4\u2195\u203c\u00b6\u00a7\u25ac\u21a8\u2191\u2193\u2192\u2190\u221f\u2194\u25b2\u25bc !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00a2\u00a3\u00a5\u20a7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u2310\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u00df\u0393\u03c0\u03a3\u03c3\u00b5\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u03c6\u03b5\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0 ",cp858:"\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u00c1\u00c2\u00c0\u00a9\u2563\u2551\u2557\u255d\u00a2\u00a5\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u00e3\u00c3\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u00a4\u00f0\u00d0\u00ca\u00cb\u00c8\u20ac\u00cd\u00ce\u00cf\u2518\u250c\u2588\u2584\u00a6\u00cc\u2580\u00d3\u00df\u00d4\u00d2\u00f5\u00d5\u00b5\u00fe\u00de\u00da\u00db\u00d9\u00fd\u00dd\u00af\u00b4\u00ad\u00b1\u2017\u00be\u00b6\u00a7\u00f7\u00b8\u00b0\u00a8\u00b7\u00b9\u00b3\u00b2\u25a0 "};
|
|
14
|
-
sa.cp858=sa.cp437.slice(0,128)+sa.cp858;sa.ascii=sa.cp437.split("").map((a,b)=>31<b&&128>b?a:".").join("");function ta(a){return a&&sa[a]?sa[a]:sa.cp437};function va(){}function wa(){};function xa(a,b){function c(w){w=w.toString(16);return"#"+"0".repeat(6-w.length)+w}function d(w){var t=256*
|
|
15
|
-
aa&&!Ga&&(P+=
|
|
14
|
+
sa.cp858=sa.cp437.slice(0,128)+sa.cp858;sa.ascii=sa.cp437.split("").map((a,b)=>31<b&&128>b?a:".").join("");function ta(a){return a&&sa[a]?sa[a]:sa.cp437};function va(){}function wa(){};function xa(a,b){function c(w){w=w.toString(16);return"#"+"0".repeat(6-w.length)+w}function d(w){var t=256*ka,I=8*S,M=Ua?Ua.canvas:null;M&&M.width===t&&M.height===I||(M?(M.width=t,M.height=I):(M=new OffscreenCanvas(t,I),Ua=M.getContext("2d")),Ob=Ua.createImageData(t,I));const Q=Ob.data;let P=0,T;I=Pb?function(aa){T=T||aa;Q[P+3]=aa;Q[P+7]=aa;P+=8}:function(aa){T=T||aa;Q[P+3]=aa;P+=4};M=32-S;const la=t*(S-1)*4;t=4*(ka-t*S);const ha=1020*ka;for(let aa=0,Fa=0;2048>aa;++aa,Fa+=M,P+=t){const Ga=aa%256;
|
|
15
|
+
aa&&!Ga&&(P+=la);T=!1;for(let Ma=0;Ma<S;++Ma,++Fa,P+=ha){const Na=w[Fa];for(let ua=128;0<ua;ua>>=1)I(Na&ua?255:0);Qb&&I(Rb&&192<=Ga&&223>=Ga&&Na&1?255:0)}hc[aa]=T?1:0}Ua.putImageData(Ob,0,0)}function e(w,t,I,M){if(t&&I){w.style.width="";w.style.height="";M&&(w.style.transform="");var Q=w.getBoundingClientRect();M?w.style.transform=(1===t?"":" scaleX("+t+")")+(1===I?"":" scaleY("+I+")"):(0===t%1&&0===I%1?(g.style.imageRendering="crisp-edges",g.style.imageRendering="pixelated",g.style["-ms-interpolation-mode"]=
|
|
16
16
|
"nearest-neighbor"):(g.style.imageRendering="",g.style["-ms-interpolation-mode"]=""),M=window.devicePixelRatio||1,0!==M%1&&(t/=M,I/=M));1!==t&&(w.style.width=Q.width*t+"px");1!==I&&(w.style.height=Q.height*I+"px")}}const f=a.container;this.screen_fill_buffer=b;console.assert(f,"options.container must be provided");this.FLAG_BLINKING=1;this.FLAG_FONT_PAGE_B=2;let g=f.getElementsByTagName("canvas")[0];g||(g=document.createElement("canvas"),f.appendChild(g));const h=g.getContext("2d",{alpha:!1});let l=
|
|
17
|
-
f.getElementsByTagName("div")[0];l||(l=document.createElement("div"),f.appendChild(l));const m=document.createElement("div");var n,p,q=void 0!==a.scale?a.scale:1,r=void 0!==a.scale?a.scale:1,x=1,
|
|
18
|
-
25);2===z&&this.set_size_graphical(720,400,720,400);this.set_scale(q,r);this.timer()};this.make_screenshot=function(){const w=new Image;if(1===z||2===z)w.src=g.toDataURL("image/png");else{const t=[9,16],I=document.createElement("canvas");I.width=K*t[0];I.height=v*t[1];const M=I.getContext("2d");M.imageSmoothingEnabled=!1;M.font=window.getComputedStyle(l).font;M.textBaseline="top";for(let Q=0;Q<v;Q++)for(let P=0;P<K;P++){const T=4*(Q*K+P),
|
|
19
|
-
Q*t[1],t[0],t[1]);M.fillStyle=c(ha);M.fillText(Tb[
|
|
20
|
-
z?this.update_text():1===z?this.update_graphical():this.update_graphical_text());this.timer()};this.update_text=function(){for(var w=0;w<v;w++)
|
|
21
|
-
K*
|
|
22
|
-
Ga,S);U.globalCompositeOperation="destination-in";U.drawImage(t,0,P,Q,S,0,0,Q,S);U.globalCompositeOperation="source-over";H.fillStyle=c(Ma);H.fillRect(Na,ha,Q-Na,S);H.drawImage(t,0,0,Q,S,0,ha,Q,S)}T&&(
|
|
23
|
-
this.set_mode=function(w){z=w?1:a.use_graphical_text?2:0;0===z?(l.style.display="block",g.style.display="none"):(l.style.display="none",g.style.display="block",2===z&&
|
|
24
|
-
h.fillRect(0,0,g.width,g.height)};this.set_size_graphical_text=function(){if(Ua){var w=
|
|
25
|
-
z){for(;l.childNodes.length>t;)l.removeChild(l.firstChild);for(;l.childNodes.length<t;)l.appendChild(document.createElement("div"));for(w=0;w<t;w++)this.text_update_row(w);e(l,q,r,!0)}else 2===z&&this.set_size_graphical_text()};this.set_size_graphical=function(w,t){g.style.display="block";g.width=w;g.height=t;h.imageSmoothingEnabled=!1;x=640>=w&&2*w<window.innerWidth*window.devicePixelRatio&&2*t<window.innerHeight*window.devicePixelRatio?
|
|
26
|
-
q,r,!0);e(g,q*x,r*x,!1)};this.update_cursor_scanline=function(w,t,I){if(w!==
|
|
27
|
-
var ha=u[t+2];var aa=u[t+3];
|
|
28
|
-
t.buffer_height)};this.get_text_screen=function(){for(var w=[],t=0;t<v;t++)w.push(this.get_text_row(t));return w};this.get_text_row=function(w){var t=w*K*4;w=t+4*K;let I="";for(;t<w;t+=4)I+=Tb[u[t]];return I};this.init()};function A(a){this.buffer=a;this.byteLength=a.byteLength;this.onprogress=this.onload=void 0}A.prototype.load=function(){this.onload&&this.onload({buffer:this.buffer})};A.prototype.get=function(a,b,c){c(new Uint8Array(this.buffer,a,b))};A.prototype.set=function(a,b,c){(new Uint8Array(this.buffer,a,b.byteLength)).set(b);c()};A.prototype.get_buffer=function(a){a(this.buffer)};A.prototype.get_state=function(){const a=[];a[0]=this.byteLength;a[1]=new Uint8Array(this.buffer);return a};
|
|
17
|
+
f.getElementsByTagName("div")[0];l||(l=document.createElement("div"),f.appendChild(l));const m=document.createElement("div");var n,p,q=void 0!==a.scale?a.scale:1,r=void 0!==a.scale?a.scale:1,x=1,D,z,u,K,v,H,U,Ua,Ob,hc=new Int8Array(2048),S,ka,Qb,Pb,Rb,ub=0,vb=0,wb,ic=0,xb,Sb,yb,Tb=ta(a.encoding),zb=0,Ub=!1;this.init=function(){m.classList.add("cursor");m.style.position="absolute";m.style.backgroundColor="#ccc";m.style.width="7px";m.style.display="inline-block";this.set_mode(!1);this.set_size_text(80,
|
|
18
|
+
25);2===z&&this.set_size_graphical(720,400,720,400);this.set_scale(q,r);this.timer()};this.make_screenshot=function(){const w=new Image;if(1===z||2===z)w.src=g.toDataURL("image/png");else{const t=[9,16],I=document.createElement("canvas");I.width=K*t[0];I.height=v*t[1];const M=I.getContext("2d");M.imageSmoothingEnabled=!1;M.font=window.getComputedStyle(l).font;M.textBaseline="top";for(let Q=0;Q<v;Q++)for(let P=0;P<K;P++){const T=4*(Q*K+P),la=u[T+0],ha=u[T+3];M.fillStyle=c(u[T+2]);M.fillRect(P*t[0],
|
|
19
|
+
Q*t[1],t[0],t[1]);M.fillStyle=c(ha);M.fillText(Tb[la],P*t[0],Q*t[1])}"none"!==m.style.display&&n<v&&p<K&&(M.fillStyle=m.style.backgroundColor,M.fillRect(p*t[0],n*t[1]+parseInt(m.style.marginTop,10),parseInt(m.style.width,10),parseInt(m.style.height,10)));w.src=I.toDataURL("image/png")}return w};this.put_char=function(w,t,I,M,Q,P){t=4*(w*K+t);u[t+0]=I;u[t+1]=M;u[t+2]=Q;u[t+3]=P;D[w]=1};this.timer=function(){zb=requestAnimationFrame(()=>this.update_screen())};this.update_screen=function(){Ub||(0===
|
|
20
|
+
z?this.update_text():1===z?this.update_graphical():this.update_graphical_text());this.timer()};this.update_text=function(){for(var w=0;w<v;w++)D[w]&&(this.text_update_row(w),D[w]=0)};this.update_graphical=function(){this.screen_fill_buffer()};this.update_graphical_text=function(){if(H){var w=performance.now();if(266<w-ic){wb=!wb;yb&&(D[n]=1);var t=4*K;for(let la=0,ha=0;la<v;++la)if(D[la])ha+=t;else for(var I=0;I<K;++I,ha+=4)if(u[ha+1]&1){D[la]=1;ha+=t-4*I;break}ic=w}w=Ua.canvas;t=U.canvas;I=4*K;const Q=
|
|
21
|
+
K*ka,P=S;let T=0;for(let la=0,ha=0,aa=0;la<v;++la,ha+=S){if(!D[la]){aa+=I;continue}++T;U.clearRect(0,P,Q,S);let Fa,Ga,Ma,Na;for(let ua=0;ua<Q;ua+=ka,aa+=4){const jc=u[aa+0];var M=u[aa+1];const kc=u[aa+2],lc=u[aa+3],mc=M&2?vb:ub;M=(!(M&1)||wb)&&hc[(mc<<8)+jc];Ma!==kc&&(void 0!==Ma&&(H.fillStyle=c(Ma),H.fillRect(Na,ha,ua-Na,S)),Ma=kc,Na=ua);Fa!==lc&&(void 0!==Fa&&(U.fillStyle=c(Fa),U.fillRect(Ga,0,ua-Ga,S)),Fa=lc,Ga=ua);M&&U.drawImage(w,jc*ka,mc*S,ka,S,ua,P,ka,S)}U.fillStyle=c(Fa);U.fillRect(Ga,0,Q-
|
|
22
|
+
Ga,S);U.globalCompositeOperation="destination-in";U.drawImage(t,0,P,Q,S,0,0,Q,S);U.globalCompositeOperation="source-over";H.fillStyle=c(Ma);H.fillRect(Na,ha,Q-Na,S);H.drawImage(t,0,0,Q,S,0,ha,Q,S)}T&&(wb&&yb&&D[n]&&(H.fillStyle=c(u[4*(n*K+p)+3]),H.fillRect(p*ka,n*S+xb,ka,Sb-xb+1)),D.fill(0));T&&h.drawImage(H.canvas,0,0)}};this.destroy=function(){zb&&(cancelAnimationFrame(zb),zb=0)};this.pause=function(){Ub=!0;m.classList.remove("blinking-cursor")};this.continue=function(){Ub=!1;m.classList.add("blinking-cursor")};
|
|
23
|
+
this.clear_text_state=function(){vb=ub=v=K=S=ka=null};this.set_mode=function(w){z=w?1:a.use_graphical_text?2:0;0===z?(l.style.display="block",g.style.display="none"):(l.style.display="none",g.style.display="block",2===z&&D&&D.fill(1))};this.set_font_bitmap=function(w,t,I,M,Q,P){const T=I?16:t?9:8;if(S!==w||ka!==T||Qb!==t||Pb!==I||Rb!==M||P)P=ka!==T||S!==w,S=w,ka=T,Qb=t,Pb=I,Rb=M,2===z&&(d(Q),D.fill(1),P&&this.set_size_graphical_text())};this.set_font_page=function(w,t){if(ub!==w||vb!==t)ub=w,vb=t,
|
|
24
|
+
D.fill(1)};this.clear_screen=function(){h.fillStyle="#000";h.fillRect(0,0,g.width,g.height)};this.set_size_graphical_text=function(){if(Ua){var w=ka*K,t=S*v,I=2*S;H&&H.canvas.width===w&&H.canvas.height===t&&U.canvas.height===I||(H?(H.canvas.width=w,H.canvas.height=t,U.canvas.width=w,U.canvas.height=I):(H=(new OffscreenCanvas(w,t)).getContext("2d",{alpha:!1}),U=(new OffscreenCanvas(w,I)).getContext("2d")),this.set_size_graphical(w,t,w,t),D.fill(1))}};this.set_size_text=function(w,t){if(w!==K||t!==
|
|
25
|
+
v)if(D=new Int8Array(t),D.fill(1),u=new Int32Array(w*t*4),K=w,v=t,0===z){for(;l.childNodes.length>t;)l.removeChild(l.firstChild);for(;l.childNodes.length<t;)l.appendChild(document.createElement("div"));for(w=0;w<t;w++)this.text_update_row(w);e(l,q,r,!0)}else 2===z&&this.set_size_graphical_text()};this.set_size_graphical=function(w,t){g.style.display="block";g.width=w;g.height=t;h.imageSmoothingEnabled=!1;x=640>=w&&2*w<window.innerWidth*window.devicePixelRatio&&2*t<window.innerHeight*window.devicePixelRatio?
|
|
26
|
+
2:1;e(g,q*x,r*x,!1)};this.set_scale=function(w,t){q=w;r=t;e(l,q,r,!0);e(g,q*x,r*x,!1)};this.update_cursor_scanline=function(w,t,I){if(w!==xb||t!==Sb||I!==yb)0===z?I?(m.style.display="inline",m.style.height=t-w+"px",m.style.marginTop=w+"px"):m.style.display="none":2===z&&n<v&&(D[n]=1),xb=w,Sb=t,yb=I};this.update_cursor=function(w,t){if(w!==n||t!==p)w<v&&(D[w]=1),n<v&&(D[n]=1),n=w,p=t};this.text_update_row=function(w){var t=4*w*K,I;var M=l.childNodes[w];var Q=document.createElement("div");for(var P=
|
|
27
|
+
0;P<K;){var T=document.createElement("span");var la=u[t+1]&1;var ha=u[t+2];var aa=u[t+3];la&&T.classList.add("blink");T.style.backgroundColor=c(ha);T.style.color=c(aa);for(I="";P<K&&(u[t+1]&1)===la&&u[t+2]===ha&&u[t+3]===aa;)if(I+=Tb[u[t+0]],P++,t+=4,w===n)if(P===p)break;else if(P===p+1){m.style.backgroundColor=T.style.color;Q.appendChild(m);break}T.textContent=I;Q.appendChild(T)}M.parentNode.replaceChild(Q,M)};this.update_buffer=function(w){for(const t of w)h.putImageData(t.image_data,t.screen_x-
|
|
28
|
+
t.buffer_x,t.screen_y-t.buffer_y,t.buffer_x,t.buffer_y,t.buffer_width,t.buffer_height)};this.get_text_screen=function(){for(var w=[],t=0;t<v;t++)w.push(this.get_text_row(t));return w};this.get_text_row=function(w){var t=w*K*4;w=t+4*K;let I="";for(;t<w;t+=4)I+=Tb[u[t]];return I};this.init()};function A(a){this.buffer=a;this.byteLength=a.byteLength;this.onprogress=this.onload=void 0}A.prototype.load=function(){this.onload&&this.onload({buffer:this.buffer})};A.prototype.get=function(a,b,c){c(new Uint8Array(this.buffer,a,b))};A.prototype.set=function(a,b,c){(new Uint8Array(this.buffer,a,b.byteLength)).set(b);c()};A.prototype.get_buffer=function(a){a(this.buffer)};A.prototype.get_state=function(){const a=[];a[0]=this.byteLength;a[1]=new Uint8Array(this.buffer);return a};
|
|
29
29
|
A.prototype.set_state=function(a){this.byteLength=a[0];this.buffer=a[1].slice().buffer};function ya(a,b,c){this.filename=a;this.byteLength=b;this.block_cache=new Map;this.block_cache_is_write=new Set;this.fixed_chunk_size=c;this.cache_reads=!!c;this.onprogress=this.onload=void 0}ya.prototype.load=async function(){void 0===this.byteLength&&(this.byteLength=await qa(this.filename));this.onload&&this.onload(Object.create(null))};
|
|
30
30
|
ya.prototype.get_from_cache=function(a,b){var c=b/256;a/=256;for(var d=0;d<c;d++)if(!this.block_cache.get(a+d))return;if(1===c)return this.block_cache.get(a);b=new Uint8Array(b);for(d=0;d<c;d++)b.set(this.block_cache.get(a+d),256*d);return b};
|
|
31
31
|
ya.prototype.get=function(a,b,c,d){var e=this.get_from_cache(a,b);if(e)c(e);else{var f=a,g=b;this.fixed_chunk_size&&(f=a-a%this.fixed_chunk_size,g=Math.ceil((a-f+b)/this.fixed_chunk_size)*this.fixed_chunk_size);pa(this.filename,{done:function(h){h=new Uint8Array(h);this.handle_read(f,g,h);f===a&&g===b?c(h):c(h.subarray(a-f,a-f+b))}.bind(this),range:{start:f,length:g},signal:d?.signal})}};
|
|
@@ -70,9 +70,9 @@ var Ea={4:"PORT_DMA_ADDR_2",5:"PORT_DMA_CNT_2",10:"PORT_DMA1_MASK_REG",11:"PORT_
|
|
|
70
70
|
212:"PORT_DMA2_MASK_REG",214:"PORT_DMA2_MODE_REG",218:"PORT_DMA2_MASTER_CLEAR",240:"PORT_MATH_CLEAR",368:"PORT_ATA2_CMD_BASE",496:"PORT_ATA1_CMD_BASE",632:"PORT_LPT2",744:"PORT_SERIAL4",760:"PORT_SERIAL2",884:"PORT_ATA2_CTRL_BASE",888:"PORT_LPT1",1E3:"PORT_SERIAL3",1008:"PORT_FD_BASE",1010:"PORT_FD_DOR",1012:"PORT_FD_STATUS",1013:"PORT_FD_DATA",1014:"PORT_HD_DATA",1015:"PORT_FD_DIR",1016:"PORT_SERIAL1",3320:"PORT_PCI_CMD",3321:"PORT_PCI_REBOOT",3324:"PORT_PCI_DATA",1026:"PORT_BIOS_DEBUG",1296:"PORT_QEMU_CFG_CTL",
|
|
71
71
|
1297:"PORT_QEMU_CFG_DATA",45056:"PORT_ACPI_PM_BASE",45312:"PORT_SMB_BASE",35072:"PORT_BIOS_APM"};Da.prototype.get_port_description=function(a){return Ea[a]?" ("+Ea[a]+")":""};var Ha={};function Ia(){this.listeners={};this.pair=void 0}Ia.prototype.register=function(a,b,c){var d=this.listeners[a];void 0===d&&(d=this.listeners[a]=[]);d.push({fn:b,this_value:c})};Ia.prototype.unregister=function(a,b){var c=this.listeners[a];void 0!==c&&(this.listeners[a]=c.filter(function(d){return d.fn!==b}))};Ia.prototype.send=function(a,b){if(this.pair&&(a=this.pair.listeners[a],void 0!==a))for(var c=0;c<a.length;c++){var d=a[c];d.fn.call(d.this_value,b)}};
|
|
72
72
|
Ia.prototype.send_async=function(a,b){setTimeout(this.send.bind(this,a,b),0)};Ha.create=function(){var a=new Ia,b=new Ia;a.pair=b;b.pair=a;return[a,b]};var Ja=new Uint8Array(256),Ka=[],La=[],Oa=[],Pa=new Uint8Array(256),Qa=[];
|
|
73
|
-
function C(a,b){this.cpu=a;this.bus=b;this.write_buffer=new
|
|
73
|
+
function C(a,b){this.cpu=a;this.bus=b;this.write_buffer=new ma(64);this.read_buffer=new ma(64);this.mixer_current_address=this.command_size=this.command=this.read_buffer_lastvalue=0;this.mixer_registers=new Uint8Array(256);this.mixer_reset();this.dummy_speaker_enabled=!1;this.test_register=0;this.dsp_signed=this.dsp_16bit=this.dsp_stereo=this.dsp_highspeed=!1;this.dac_buffers=[new na(65536),new na(65536)];this.dma=a.devices.dma;this.dma_channel=this.dma_irq=this.dma_bytes_block=this.dma_bytes_left=
|
|
74
74
|
this.dma_bytes_count=this.dma_sample_count=0;this.dma_channel_8bit=1;this.dma_channel_16bit=5;this.dma_autoinit=!1;this.dma_buffer=new ArrayBuffer(65536);this.dma_buffer_int8=new Int8Array(this.dma_buffer);this.dma_buffer_uint8=new Uint8Array(this.dma_buffer);this.dma_buffer_int16=new Int16Array(this.dma_buffer);this.dma_buffer_uint16=new Uint16Array(this.dma_buffer);this.dma_syncbuffer=new A(this.dma_buffer);this.dma_paused=this.dma_waiting_transfer=!1;this.sampling_rate=22050;b.send("dac-tell-sampling-rate",
|
|
75
|
-
this.sampling_rate);this.bytes_per_sample=1;this.e2_value=170;this.e2_count=0;this.asp_registers=new Uint8Array(256);this.mpu_read_buffer=new
|
|
75
|
+
this.sampling_rate);this.bytes_per_sample=1;this.e2_value=170;this.e2_count=0;this.asp_registers=new Uint8Array(256);this.mpu_read_buffer=new ma(64);this.fm_current_address1=this.fm_current_address0=this.mpu_read_buffer_lastvalue=0;this.fm_waveform_select_enable=!1;this.irq=5;this.irq_triggered=new Uint8Array(16);a.io.register_read_consecutive(544,this,this.port2x0_read,this.port2x1_read,this.port2x2_read,this.port2x3_read);a.io.register_read_consecutive(904,this,this.port2x0_read,this.port2x1_read);
|
|
76
76
|
a.io.register_read_consecutive(548,this,this.port2x4_read,this.port2x5_read);a.io.register_read(550,this,this.port2x6_read);a.io.register_read(551,this,this.port2x7_read);a.io.register_read(552,this,this.port2x8_read);a.io.register_read(553,this,this.port2x9_read);a.io.register_read(554,this,this.port2xA_read);a.io.register_read(555,this,this.port2xB_read);a.io.register_read(556,this,this.port2xC_read);a.io.register_read(557,this,this.port2xD_read);a.io.register_read_consecutive(558,this,this.port2xE_read,
|
|
77
77
|
this.port2xF_read);a.io.register_write_consecutive(544,this,this.port2x0_write,this.port2x1_write,this.port2x2_write,this.port2x3_write);a.io.register_write_consecutive(904,this,this.port2x0_write,this.port2x1_write);a.io.register_write_consecutive(548,this,this.port2x4_write,this.port2x5_write);a.io.register_write(550,this,this.port2x6_write);a.io.register_write(551,this,this.port2x7_write);a.io.register_write_consecutive(552,this,this.port2x8_write,this.port2x9_write);a.io.register_write(554,this,
|
|
78
78
|
this.port2xA_write);a.io.register_write(555,this,this.port2xB_write);a.io.register_write(556,this,this.port2xC_write);a.io.register_write(557,this,this.port2xD_write);a.io.register_write(558,this,this.port2xE_write);a.io.register_write(559,this,this.port2xF_write);a.io.register_read_consecutive(816,this,this.port3x0_read,this.port3x1_read);a.io.register_write_consecutive(816,this,this.port3x0_write,this.port3x1_write);this.dma.on_unmask(this.dma_on_unmask,this);b.register("dac-request-data",function(){this.dac_handle_request()},
|
|
@@ -90,15 +90,15 @@ C.prototype.port2x2_write=function(a){y(a);this.fm_current_address1=0};C.prototy
|
|
|
90
90
|
C.prototype.port2x6_write=function(a){y(a);this.dsp_highspeed?this.dsp_highspeed=!1:a&&this.dsp_reset();this.read_buffer.clear();this.read_buffer.push(170)};C.prototype.port2x7_write=function(){};C.prototype.port2x8_write=function(){};C.prototype.port2x9_write=function(){};C.prototype.port2xA_write=function(){};C.prototype.port2xB_write=function(){};
|
|
91
91
|
C.prototype.port2xC_write=function(a){0===this.command?(y(a),this.command=a,this.write_buffer.clear(),this.command_size=Ja[a]):(y(a),this.write_buffer.push(a));this.write_buffer.length>=this.command_size&&this.command_do()};C.prototype.port2xD_write=function(){};C.prototype.port2xE_write=function(){};C.prototype.port2xF_write=function(){};
|
|
92
92
|
C.prototype.port3x0_read=function(){this.mpu_read_buffer.length&&(this.mpu_read_buffer_lastvalue=this.mpu_read_buffer.shift());y(this.mpu_read_buffer_lastvalue);return this.mpu_read_buffer_lastvalue};C.prototype.port3x0_write=function(a){y(a)};C.prototype.port3x1_read=function(){return 0|128*!this.mpu_read_buffer.length};C.prototype.port3x1_write=function(a){y(a);255===a&&(this.mpu_read_buffer.clear(),this.mpu_read_buffer.push(254))};
|
|
93
|
-
C.prototype.command_do=function(){var a=Ka[this.command];a||(a=this.dsp_default_handler);a.call(this);this.command_size=this.command=0;this.write_buffer.clear()};C.prototype.dsp_default_handler=function(){y(this.command)};function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var Ta=new Uint8Array(256);Ta[14]=255;Ta[15]=7;Ta[55]=56;
|
|
93
|
+
C.prototype.command_do=function(){var a=Ka[this.command];a||(a=this.dsp_default_handler);a.call(this);this.command_size=this.command=0;this.write_buffer.clear()};C.prototype.dsp_default_handler=function(){y(this.command)};function E(a,b,c){c||(c=C.prototype.dsp_default_handler);for(var d=0;d<a.length;d++)Ja[a[d]]=b,Ka[a[d]]=c}function Ra(a){for(var b=[],c=0;16>c;c++)b.push(a+c);return b}E([14],2,function(){this.asp_registers[this.write_buffer.shift()]=this.write_buffer.shift()});
|
|
94
|
+
E([15],1,function(){this.read_buffer.clear();this.read_buffer.push(this.asp_registers[this.write_buffer.shift()])});E([16],1,function(){var a=this.write_buffer.shift();a=Sa(a/127.5+-1,-1,1);this.dac_buffers[0].push(a);this.dac_buffers[1].push(a);this.bus.send("dac-enable")});E([20,21],2,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dsp_highspeed=this.dsp_16bit=this.dsp_signed=this.dma_autoinit=!1;this.dma_transfer_size_set();this.dma_transfer_start()});E([22],2);E([23],2);
|
|
95
|
+
E([28],0,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!0;this.dsp_highspeed=this.dsp_16bit=this.dsp_signed=!1;this.dma_transfer_start()});E([31],0);E([32],0,function(){this.read_buffer.clear();this.read_buffer.push(127)});E([36],2);E([44],0);E([48],0);E([49],0);E([52],0);E([53],0);E([54],0);E([55],0);E([56],0);E([64],1,function(){this.sampling_rate_change(1E6/(256-this.write_buffer.shift())/this.get_channel_count())});
|
|
96
|
+
E([65,66],2,function(){this.sampling_rate_change(this.write_buffer.shift()<<8|this.write_buffer.shift())});E([72],2,function(){this.dma_transfer_size_set()});E([116],2);E([117],2);E([118],2);E([119],2);E([125],0);E([127],0);E([128],2);E([144],0,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!0;this.dsp_signed=!1;this.dsp_highspeed=!0;this.dsp_16bit=!1;this.dma_transfer_start()});E([145],0);E([152],0);E([153],0);E([160],0);E([168],0);
|
|
97
|
+
E(Ra(176),3,function(){if(this.command&8)this.dsp_default_handler();else{var a=this.write_buffer.shift();this.dma_irq=2;this.dma_channel=this.dma_channel_16bit;this.dma_autoinit=!!(this.command&4);this.dsp_signed=!!(a&16);this.dsp_stereo=!!(a&32);this.dsp_16bit=!0;this.dma_transfer_size_set();this.dma_transfer_start()}});
|
|
98
|
+
E(Ra(192),3,function(){if(this.command&8)this.dsp_default_handler();else{var a=this.write_buffer.shift();this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!!(this.command&4);this.dsp_signed=!!(a&16);this.dsp_stereo=!!(a&32);this.dsp_16bit=!1;this.dma_transfer_size_set();this.dma_transfer_start()}});E([208],0,function(){this.dma_paused=!0;this.bus.send("dac-disable")});E([209],0,function(){this.dummy_speaker_enabled=!0});E([211],0,function(){this.dummy_speaker_enabled=!1});
|
|
99
|
+
E([212],0,function(){this.dma_paused=!1;this.bus.send("dac-enable")});E([213],0,function(){this.dma_paused=!0;this.bus.send("dac-disable")});E([214],0,function(){this.dma_paused=!1;this.bus.send("dac-enable")});E([216],0,function(){this.read_buffer.clear();this.read_buffer.push(255*this.dummy_speaker_enabled)});E([217,218],0,function(){this.dma_autoinit=!1});E([224],1,function(){this.read_buffer.clear();this.read_buffer.push(~this.write_buffer.shift())});
|
|
100
|
+
E([225],0,function(){this.read_buffer.clear();this.read_buffer.push(4);this.read_buffer.push(5)});E([226],1);E([227],0,function(){this.read_buffer.clear();for(var a=0;44>a;a++)this.read_buffer.push("COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.".charCodeAt(a));this.read_buffer.push(0)});E([228],1,function(){this.test_register=this.write_buffer.shift()});E([232],0,function(){this.read_buffer.clear();this.read_buffer.push(this.test_register)});E([242],0,function(){this.raise_irq(1)});E([243],0,function(){this.raise_irq(2)});
|
|
101
|
+
var Ta=new Uint8Array(256);Ta[14]=255;Ta[15]=7;Ta[55]=56;E([249],1,function(){var a=this.write_buffer.shift();this.read_buffer.clear();this.read_buffer.push(Ta[a])});C.prototype.mixer_read=function(a){var b=La[a];b?b=b.call(this):(b=this.mixer_registers[a],y(a),y(b));return b};C.prototype.mixer_write=function(a,b){var c=Oa[a];c?c.call(this,b):(y(a),y(b))};C.prototype.mixer_default_read=function(){y(this.mixer_current_address);return this.mixer_registers[this.mixer_current_address]};
|
|
102
102
|
C.prototype.mixer_default_write=function(a){y(this.mixer_current_address);y(a);this.mixer_registers[this.mixer_current_address]=a};
|
|
103
103
|
C.prototype.mixer_reset=function(){this.mixer_registers[4]=204;this.mixer_registers[34]=204;this.mixer_registers[38]=204;this.mixer_registers[40]=0;this.mixer_registers[46]=0;this.mixer_registers[10]=0;this.mixer_registers[48]=192;this.mixer_registers[49]=192;this.mixer_registers[50]=192;this.mixer_registers[51]=192;this.mixer_registers[52]=192;this.mixer_registers[53]=192;this.mixer_registers[54]=0;this.mixer_registers[55]=0;this.mixer_registers[56]=0;this.mixer_registers[57]=0;this.mixer_registers[59]=
|
|
104
104
|
0;this.mixer_registers[60]=31;this.mixer_registers[61]=21;this.mixer_registers[62]=11;this.mixer_registers[63]=0;this.mixer_registers[64]=0;this.mixer_registers[65]=0;this.mixer_registers[66]=0;this.mixer_registers[67]=0;this.mixer_registers[68]=128;this.mixer_registers[69]=128;this.mixer_registers[70]=128;this.mixer_registers[71]=128;this.mixer_full_update()};C.prototype.mixer_full_update=function(){for(var a=1;a<this.mixer_registers.length;a++)Pa[a]||this.mixer_write(a,this.mixer_registers[a])};
|
|
@@ -156,7 +156,7 @@ function nb(a,b,c){this.node_oscillator=b.createOscillator();this.node_oscillato
|
|
|
156
156
|
f=Math.max(f,0));this.node_oscillator.frequency.setValueAtTime(f,b.currentTime)},this)}nb.prototype.start=function(){this.node_oscillator.start()};
|
|
157
157
|
function kb(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=48E3;b=function(){function g(m){if(0===m)return 1;m*=Math.PI;return Math.sin(m)/m}function h(){var m=Reflect.construct(AudioWorkletProcessor,[],h);m.kernel_size=3;m.queue_data=Array(1024);m.queue_start=0;m.queue_end=0;m.queue_length=0;m.queue_size=m.queue_data.length;m.queued_samples=0;m.source_buffer_previous=l;m.source_buffer_current=l;m.source_samples_per_destination=1;m.source_block_start=0;m.source_time=0;m.source_offset=
|
|
158
158
|
0;m.port.onmessage=n=>{switch(n.data.type){case "queue":m.queue_push(n.data.value);break;case "sampling-rate":m.source_samples_per_destination=n.data.value/sampleRate}};return m}var l=[new Float32Array(256),new Float32Array(256)];Reflect.setPrototypeOf(h.prototype,AudioWorkletProcessor.prototype);Reflect.setPrototypeOf(h,AudioWorkletProcessor);h.prototype.process=h.prototype.process=function(m,n){for(m=0;m<n[0][0].length;m++){for(var p=0,q=0,r=this.source_offset+this.kernel_size,x=this.source_offset-
|
|
159
|
-
this.kernel_size+1;x<=r;x++){var
|
|
159
|
+
this.kernel_size+1;x<=r;x++){var D=this.source_block_start+x;p+=this.get_sample(D,0)*this.kernel(this.source_time-x);q+=this.get_sample(D,1)*this.kernel(this.source_time-x)}if(isNaN(p)||isNaN(q))p=q=0,this.dbg_log("ERROR: NaN values! Ignoring for now.");n[0][0][m]=p;n[0][1][m]=q;this.source_time+=this.source_samples_per_destination;this.source_offset=Math.floor(this.source_time)}n=this.source_offset;n+=this.kernel_size+2;this.source_time-=this.source_offset;this.source_block_start+=this.source_offset;
|
|
160
160
|
this.source_offset=0;this.ensure_enough_data(n);return!0};h.prototype.kernel=function(m){return g(m)*g(m/this.kernel_size)};h.prototype.get_sample=function(m,n){return 0>m?(m+=this.source_buffer_previous[0].length,this.source_buffer_previous[n][m]):this.source_buffer_current[n][m]};h.prototype.ensure_enough_data=function(m){var n=this.source_buffer_current[0].length;n-this.source_block_start<m&&(this.prepare_next_buffer(),this.source_block_start-=n)};h.prototype.prepare_next_buffer=function(){256>
|
|
161
161
|
this.queued_samples&&this.queue_length&&this.dbg_log("Not enough samples - should not happen during midway of playback");this.source_buffer_previous=this.source_buffer_current;this.source_buffer_current=this.queue_shift();var m=this.source_buffer_current[0].length;if(256>m){for(var n=this.queue_start,p=0;256>m&&p<this.queue_length;)m+=this.queue_data[n][0].length,n=n+1&this.queue_size-1,p++;m=Math.max(m,256);m=[new Float32Array(m),new Float32Array(m)];m[0].set(this.source_buffer_current[0]);m[1].set(this.source_buffer_current[1]);
|
|
162
162
|
n=this.source_buffer_current[0].length;for(var q=0;q<p;q++){var r=this.queue_shift();m[0].set(r[0],n);m[1].set(r[1],n);n+=r[0].length}this.source_buffer_current=m}this.pump()};h.prototype.pump=function(){1024>this.queued_samples/this.source_samples_per_destination&&this.port.postMessage({type:"pump"})};h.prototype.queue_push=function(m){this.queue_length<this.queue_size&&(this.queue_data[this.queue_end]=m,this.queue_end=this.queue_end+1&this.queue_size-1,this.queue_length++,this.queued_samples+=m[0].length,
|
|
@@ -170,57 +170,57 @@ lb.prototype.queue=function(a){var b=a[0].length,c=b/this.sampling_rate;if(1<thi
|
|
|
170
170
|
a=this.audio_context.createBufferSource();a.buffer=d;a.connect(this.node_lowpass);a.addEventListener("ended",this.pump.bind(this));d=this.audio_context.currentTime;if(this.buffered_time<d)for(this.buffered_time=d,d=.2-c,b=0;b<=d;)b+=c,this.buffered_time+=c,setTimeout(()=>this.pump(),1E3*b);a.start(this.buffered_time);this.buffered_time+=c;setTimeout(()=>this.pump(),0)};lb.prototype.pump=function(){this.enabled&&(.2<this.buffered_time-this.audio_context.currentTime||this.bus.send("dac-request-data"))};function pb(a,b,c){this.bus=b;this.socket=void 0;this.id=c||0;this.send_queue=[];this.url=a;this.reconnect_interval=1E4;this.last_connect_attempt=Date.now()-this.reconnect_interval;this.send_queue_limit=64;this.destroyed=!1;this.bus.register("net"+this.id+"-send",function(d){this.send(d)},this)}pb.prototype.handle_message=function(a){this.bus&&this.bus.send("net"+this.id+"-receive",new Uint8Array(a.data))};
|
|
171
171
|
pb.prototype.handle_close=function(){this.destroyed||(this.connect(),setTimeout(this.connect.bind(this),this.reconnect_interval))};pb.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);this.send_queue=[]};pb.prototype.handle_error=function(){};pb.prototype.destroy=function(){this.destroyed=!0;this.socket&&this.socket.close()};
|
|
172
172
|
pb.prototype.connect=function(){if("undefined"!==typeof WebSocket){if(this.socket){var a=this.socket.readyState;if(0===a||1===a)return}a=Date.now();if(!(this.last_connect_attempt+this.reconnect_interval>a)){this.last_connect_attempt=Date.now();try{this.socket=new WebSocket(this.url)}catch(b){console.error(b);return}this.socket.binaryType="arraybuffer";this.socket.onopen=this.handle_open.bind(this);this.socket.onmessage=this.handle_message.bind(this);this.socket.onclose=this.handle_close.bind(this);
|
|
173
|
-
this.socket.onerror=this.handle_error.bind(this)}}};pb.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),this.send_queue.length>2*this.send_queue_limit&&(this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};pb.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};const qb=(new Date("1970-01-01T00:00:00Z")).getTime(),rb=(new Date("1900-01-01T00:00:00Z")).getTime(),sb=qb-rb,tb=Math.pow(2,32),
|
|
174
|
-
class
|
|
173
|
+
this.socket.onerror=this.handle_error.bind(this)}}};pb.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),this.send_queue.length>2*this.send_queue_limit&&(this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};pb.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};const qb=(new Date("1970-01-01T00:00:00Z")).getTime(),rb=(new Date("1900-01-01T00:00:00Z")).getTime(),sb=qb-rb,tb=Math.pow(2,32),Ab=[118,56,54];function Bb(a){return[0,1,2,3,4,5].map(b=>a[b].toString(16)).map(b=>1===b.length?"0"+b:b).join(":")}function Cb(a){return a[0]<<24|a[1]<<16|a[2]<<8|a[3]}
|
|
174
|
+
class Db{constructor(a,b){a=Math.min(a,16);this.maximum_capacity=b?Math.max(b,a):0;this.length=this.head=this.tail=0;this.buffer=new Uint8Array(a)}write(a){const b=a.length;var c=this.length+b;let d=this.buffer.length;if(d<c){for(;d<c;)d*=2;if(this.maximum_capacity&&d>this.maximum_capacity)throw Error("stream capacity overflow in GrowableRingbuffer.write(), package dropped");c=new Uint8Array(d);this.peek(c);this.tail=0;this.head=this.length;this.buffer=c}c=this.buffer;const e=this.head+b;if(e>d){const f=
|
|
175
175
|
d-this.head;c.set(a.subarray(0,f),this.head);c.set(a.subarray(f))}else c.set(a,this.head);this.head=e%d;this.length+=b}peek(a){const b=Math.min(this.length,a.length);if(b){const e=this.buffer;var c=e.length,d=this.tail+b;d>c?(d%=c,c-=this.tail,a.set(e.subarray(this.tail)),a.set(e.subarray(0,d),c)):a.set(e.subarray(this.tail,d))}return b}remove(a){a>this.length&&(a=this.length);a&&(this.tail=(this.tail+a)%this.buffer.length,this.length-=a);return a}}
|
|
176
|
-
function
|
|
177
|
-
function
|
|
178
|
-
function
|
|
179
|
-
h.setUint8(0,b.icmp.type);h.setUint8(1,b.icmp.code);h.setUint16(2,0);var l=4+
|
|
180
|
-
b.dhcp.giaddr);
|
|
181
|
-
r.type);x+=2;m.setUint16(x,r.class);x+=2}for(q=0;q<b.dns.answers.length;++q){n=b.dns.answers[q];for(l of n.name)r=a.text_encoder.encodeInto(l,a.eth_frame.subarray(m.byteOffset+(x+1))).written,m.setUint8(x,r),x+=1+r;m.setUint16(x,n.type);x+=2;m.setUint16(x,n.class);x+=2;m.setUint32(x,n.ttl);x+=4;m.setUint16(x,n.data.length);x+=2;x+=
|
|
182
|
-
n.setUint32(4,b.ntp.root_delay),n.setUint32(8,b.ntp.root_disp),n.setUint32(12,b.ntp.ref_id),n.setUint32(16,b.ntp.ref_ts_i),n.setUint32(20,b.ntp.ref_ts_f),n.setUint32(24,b.ntp.ori_ts_i),n.setUint32(28,b.ntp.ori_ts_f),n.setUint32(32,b.ntp.rec_ts_i),n.setUint32(36,b.ntp.rec_ts_f),n.setUint32(40,b.ntp.trans_ts_i),n.setUint32(44,b.ntp.trans_ts_f),l+=48):l=m+
|
|
176
|
+
function Eb(a=1500){const b=a-20,c=b-8,d=new Uint8Array(14+a+4),e=d.buffer,f=d.byteOffset;return{eth_frame:d,eth_frame_view:new DataView(e),eth_payload_view:new DataView(e,f+14,a),ipv4_payload_view:new DataView(e,f+34,b),udp_payload_view:new DataView(e,f+42,c),text_encoder:new TextEncoder}}function Fb(a,b,c,d){d.eth_frame.set(b,c.byteOffset+a);return b.length}
|
|
177
|
+
function Gb(a,b,c,d){const e=c.byteOffset+(a&-2);d=d.eth_frame;for(c=c.byteOffset;c<e;c+=2)b+=d[c]<<8|d[c+1];for(a&1&&(b+=d[e]<<8);b>>>16;)b=(b&65535)+(b>>>16);return~b&65535}
|
|
178
|
+
function Hb(a,b){a.eth_frame.fill(0);var c=a.eth_frame,d=c.subarray,e=a.eth_frame_view;Fb(0,b.eth.dest,e,a);Fb(6,b.eth.src,e,a);e.setUint16(12,b.eth.ethertype);e=14;if(b.arp){var f=a.eth_payload_view;f.setUint16(0,b.arp.htype);f.setUint16(2,b.arp.ptype);f.setUint8(4,b.arp.sha.length);f.setUint8(5,b.arp.spa.length);f.setUint16(6,b.arp.oper);Fb(8,b.arp.sha,f,a);Fb(14,b.arp.spa,f,a);Fb(18,b.arp.tha,f,a);Fb(24,b.arp.tpa,f,a);e+=28}else if(b.ipv4){f=a.eth_payload_view;var g=20;if(b.icmp){var h=a.ipv4_payload_view;
|
|
179
|
+
h.setUint8(0,b.icmp.type);h.setUint8(1,b.icmp.code);h.setUint16(2,0);var l=4+Fb(4,b.icmp.data,h,a);h.setUint16(2,Gb(l,0,h,a));g+=l}else if(b.udp){h=a.ipv4_payload_view;var m=8;if(b.dhcp){l=m;var n=a.udp_payload_view;n.setUint8(0,b.dhcp.op);n.setUint8(1,b.dhcp.htype);n.setUint8(2,b.dhcp.hlen);n.setUint8(3,b.dhcp.hops);n.setUint32(4,b.dhcp.xid);n.setUint16(8,b.dhcp.secs);n.setUint16(10,b.dhcp.flags);n.setUint32(12,b.dhcp.ciaddr);n.setUint32(16,b.dhcp.yiaddr);n.setUint32(20,b.dhcp.siaddr);n.setUint32(24,
|
|
180
|
+
b.dhcp.giaddr);Fb(28,b.dhcp.chaddr,n,a);n.setUint32(236,1669485411);m=240;for(var p of b.dhcp.options)m+=Fb(m,p,n,a);l+=m}else if(b.dns){p=m;m=a.udp_payload_view;m.setUint16(0,b.dns.id);m.setUint16(2,b.dns.flags);m.setUint16(4,b.dns.questions.length);m.setUint16(6,b.dns.answers.length);let x=12;for(var q=0;q<b.dns.questions.length;++q){var r=b.dns.questions[q];for(n of r.name){const D=a.text_encoder.encodeInto(n,a.eth_frame.subarray(m.byteOffset+(x+1))).written;m.setUint8(x,D);x+=1+D}m.setUint16(x,
|
|
181
|
+
r.type);x+=2;m.setUint16(x,r.class);x+=2}for(q=0;q<b.dns.answers.length;++q){n=b.dns.answers[q];for(l of n.name)r=a.text_encoder.encodeInto(l,a.eth_frame.subarray(m.byteOffset+(x+1))).written,m.setUint8(x,r),x+=1+r;m.setUint16(x,n.type);x+=2;m.setUint16(x,n.class);x+=2;m.setUint32(x,n.ttl);x+=4;m.setUint16(x,n.data.length);x+=2;x+=Fb(x,n.data,m,a)}l=p+x}else b.ntp?(l=m,n=a.udp_payload_view,n.setUint8(0,b.ntp.flags),n.setUint8(1,b.ntp.stratum),n.setUint8(2,b.ntp.poll),n.setUint8(3,b.ntp.precision),
|
|
182
|
+
n.setUint32(4,b.ntp.root_delay),n.setUint32(8,b.ntp.root_disp),n.setUint32(12,b.ntp.ref_id),n.setUint32(16,b.ntp.ref_ts_i),n.setUint32(20,b.ntp.ref_ts_f),n.setUint32(24,b.ntp.ori_ts_i),n.setUint32(28,b.ntp.ori_ts_f),n.setUint32(32,b.ntp.rec_ts_i),n.setUint32(36,b.ntp.rec_ts_f),n.setUint32(40,b.ntp.trans_ts_i),n.setUint32(44,b.ntp.trans_ts_f),l+=48):l=m+Fb(0,b.udp.data,a.udp_payload_view,a);m=l;h.setUint16(0,b.udp.sport);h.setUint16(2,b.udp.dport);h.setUint16(4,m);h.setUint16(6,0);h.setUint16(6,Gb(m,
|
|
183
183
|
(b.ipv4.src[0]<<8|b.ipv4.src[1])+(b.ipv4.src[2]<<8|b.ipv4.src[3])+(b.ipv4.dest[0]<<8|b.ipv4.dest[1])+(b.ipv4.dest[2]<<8|b.ipv4.dest[3])+17+m,h,a));g+=m}else b.tcp&&(h=a.ipv4_payload_view,l=0,n=b.tcp,n.fin&&(l|=1),n.syn&&(l|=2),n.rst&&(l|=4),n.psh&&(l|=8),n.ack&&(l|=16),n.urg&&(l|=32),n.ece&&(l|=64),n.cwr&&(l|=128),p=20,n.options&&n.options.mss&&(h.setUint8(p,2),h.setUint8(p+1,4),h.setUint16(p+2,n.options.mss),p+=4),m=4*Math.ceil(p/4),n.options&&0<m-p&&a.eth_frame.fill(0,h.byteOffset+p,h.byteOffset+
|
|
184
|
-
p+(m-p)),h.setUint16(0,n.sport),h.setUint16(2,n.dport),h.setUint32(4,n.seq),h.setUint32(8,n.ackn),h.setUint8(12,m>>2<<4),h.setUint8(13,l),h.setUint16(14,n.winsize),h.setUint16(16,0),h.setUint16(18,n.urgent||0),b.tcp_data&&(m+=
|
|
185
|
-
0);f.setUint8(6,64);f.setUint8(8,b.ipv4.ttl||32);f.setUint8(9,b.ipv4.proto);f.setUint16(10,0);
|
|
186
|
-
function
|
|
187
|
-
function
|
|
188
|
-
1,5])),d.push(new Uint8Array([51,4,8,0,0,0])));a=[b.router_ip[0],b.router_ip[1],b.router_ip[2],b.router_ip[3]];d.push(new Uint8Array([1,4,255,255,255,0]));b.masquerade&&(d.push(new Uint8Array([3,4].concat(a))),d.push(new Uint8Array([6,4].concat(a))));d.push(new Uint8Array([54,4].concat(a)));d.push(new Uint8Array([60,3].concat(
|
|
189
|
-
function
|
|
184
|
+
p+(m-p)),h.setUint16(0,n.sport),h.setUint16(2,n.dport),h.setUint32(4,n.seq),h.setUint32(8,n.ackn),h.setUint8(12,m>>2<<4),h.setUint8(13,l),h.setUint16(14,n.winsize),h.setUint16(16,0),h.setUint16(18,n.urgent||0),b.tcp_data&&(m+=Fb(20,b.tcp_data,h,a)),h.setUint16(16,Gb(m,(b.ipv4.src[0]<<8|b.ipv4.src[1])+(b.ipv4.src[2]<<8|b.ipv4.src[3])+(b.ipv4.dest[0]<<8|b.ipv4.dest[1])+(b.ipv4.dest[2]<<8|b.ipv4.dest[3])+6+m,h,a)),g+=m);f.setUint8(0,69);f.setUint8(1,b.ipv4.tos||0);f.setUint16(2,g);f.setUint16(4,b.ipv4.id||
|
|
185
|
+
0);f.setUint8(6,64);f.setUint8(8,b.ipv4.ttl||32);f.setUint8(9,b.ipv4.proto);f.setUint16(10,0);Fb(12,b.ipv4.src,f,a);Fb(16,b.ipv4.dest,f,a);f.setUint16(10,Gb(20,0,f,a));e+=g}return d.call(c,0,e)}
|
|
186
|
+
function Ib(a,b){fetch(`https://${b.doh_server||"cloudflare-dns.com"}/dns-query`,{method:"POST",headers:[["content-type","application/dns-message"]],body:a.udp.data}).then(async c=>{c={eth:{ethertype:2048,src:b.router_mac,dest:a.eth.src},ipv4:{proto:17,src:b.router_ip,dest:a.ipv4.src},udp:{sport:53,dport:a.udp.sport,data:new Uint8Array(await c.arrayBuffer())}};b.receive(Hb(b.eth_encoder_buf,c))});return!0}
|
|
187
|
+
function Jb(a,b){let c={};c.eth={ethertype:2048,src:b.router_mac,dest:a.eth.src};c.ipv4={proto:17,src:b.router_ip,dest:b.vm_ip};c.udp={sport:67,dport:68};c.dhcp={htype:1,hlen:6,hops:0,xid:a.dhcp.xid,secs:0,flags:0,ciaddr:0,yiaddr:Cb(b.vm_ip),siaddr:Cb(b.router_ip),giaddr:Cb(b.router_ip),chaddr:a.dhcp.chaddr};let d=[],e=a.dhcp.options.find(function(f){return 53===f[0]});e&&3===e[2]&&(a.dhcp.op=3);1===a.dhcp.op&&(c.dhcp.op=2,d.push(new Uint8Array([53,1,2])));3===a.dhcp.op&&(c.dhcp.op=2,d.push(new Uint8Array([53,
|
|
188
|
+
1,5])),d.push(new Uint8Array([51,4,8,0,0,0])));a=[b.router_ip[0],b.router_ip[1],b.router_ip[2],b.router_ip[3]];d.push(new Uint8Array([1,4,255,255,255,0]));b.masquerade&&(d.push(new Uint8Array([3,4].concat(a))),d.push(new Uint8Array([6,4].concat(a))));d.push(new Uint8Array([54,4].concat(a)));d.push(new Uint8Array([60,3].concat(Ab)));d.push(new Uint8Array([255,0]));c.dhcp.options=d;b.receive(Hb(b.eth_encoder_buf,c))}
|
|
189
|
+
function Kb(a,b){let c={};var d=(new DataView(a.buffer,a.byteOffset,a.byteLength)).getUint16(12),e={ethertype:d,dest:a.subarray(0,6),dest_s:Bb(a.subarray(0,6)),src:a.subarray(6,12),src_s:Bb(a.subarray(6,12))};c.eth=e;a=a.subarray(14,a.length);if(2048===d){var f=new DataView(a.buffer,a.byteOffset,a.byteLength),g=a[0]>>4&15;e=a[0]&15;var h=f.getUint8(1),l=f.getUint16(2);let m=f.getUint8(8);d=f.getUint8(9);f=f.getUint16(10);g={version:g,ihl:e,tos:h,len:l,ttl:m,proto:d,ip_checksum:f,src:a.subarray(12,
|
|
190
190
|
16),dest:a.subarray(16,20)};c.ipv4=g;e=a.subarray(4*e,l);if(1===d)a=new DataView(e.buffer,e.byteOffset,e.byteLength),a={type:a.getUint8(0),code:a.getUint8(1),checksum:a.getUint16(2),data:e.subarray(4)},c.icmp=a;else if(6===d)d=new DataView(e.buffer,e.byteOffset,e.byteLength),a={sport:d.getUint16(0),dport:d.getUint16(2),seq:d.getUint32(4),ackn:d.getUint32(8),doff:d.getUint8(12)>>4,winsize:d.getUint16(14),checksum:d.getUint16(16),urgent:d.getUint16(18)},d=d.getUint8(13),a.fin=!!(d&1),a.syn=!!(d&2),
|
|
191
191
|
a.rst=!!(d&4),a.psh=!!(d&8),a.ack=!!(d&16),a.urg=!!(d&32),a.ece=!!(d&64),a.cwr=!!(d&128),c.tcp=a,c.tcp_data=e.subarray(4*a.doff);else if(17===d){a=new DataView(e.buffer,e.byteOffset,e.byteLength);a={sport:a.getUint16(0),dport:a.getUint16(2),len:a.getUint16(4),checksum:a.getUint16(6),data:e.subarray(8),data_s:(new TextDecoder).decode(e.subarray(8))};if(67===a.dport||67===a.sport){e=e.subarray(8);d=new DataView(e.buffer,e.byteOffset,e.byteLength);e.subarray(44,236);d={op:d.getUint8(0),htype:d.getUint8(1),
|
|
192
|
-
hlen:d.getUint8(2),hops:d.getUint8(3),xid:d.getUint32(4),secs:d.getUint16(8),flags:d.getUint16(10),ciaddr:d.getUint32(12),yiaddr:d.getUint32(16),siaddr:d.getUint32(20),giaddr:d.getUint32(24),chaddr:e.subarray(28,44),magic:d.getUint32(236),options:[]};e=e.subarray(240);for(l=0;l<e.length;++l)g=l,0!==e[l]&&(++l,h=e[l],l+=h,d.options.push(e.subarray(g,g+h+2)));c.dhcp=d;c.dhcp_options=d.options}else 53===a.dport||53===a.sport?
|
|
192
|
+
hlen:d.getUint8(2),hops:d.getUint8(3),xid:d.getUint32(4),secs:d.getUint16(8),flags:d.getUint16(10),ciaddr:d.getUint32(12),yiaddr:d.getUint32(16),siaddr:d.getUint32(20),giaddr:d.getUint32(24),chaddr:e.subarray(28,44),magic:d.getUint32(236),options:[]};e=e.subarray(240);for(l=0;l<e.length;++l)g=l,0!==e[l]&&(++l,h=e[l],l+=h,d.options.push(e.subarray(g,g+h+2)));c.dhcp=d;c.dhcp_options=d.options}else 53===a.dport||53===a.sport?Lb(e.subarray(8),c):123===a.dport&&(d=e.subarray(8),d=new DataView(d.buffer,
|
|
193
193
|
d.byteOffset,d.byteLength),c.ntp={flags:d.getUint8(0),stratum:d.getUint8(1),poll:d.getUint8(2),precision:d.getUint8(3),root_delay:d.getUint32(4),root_disp:d.getUint32(8),ref_id:d.getUint32(12),ref_ts_i:d.getUint32(16),ref_ts_f:d.getUint32(20),ori_ts_i:d.getUint32(24),ori_ts_f:d.getUint32(28),rec_ts_i:d.getUint32(32),rec_ts_f:d.getUint32(36),trans_ts_i:d.getUint32(40),trans_ts_f:d.getUint32(44)});c.udp=a}}else 2054===d?(d=new DataView(a.buffer,a.byteOffset,a.byteLength),a={htype:d.getUint16(0),ptype:d.getUint16(2),
|
|
194
|
-
oper:d.getUint16(6),sha:a.subarray(8,14),spa:a.subarray(14,18),tha:a.subarray(18,24),tpa:a.subarray(24,28)},c.arp=a):34525!==d&&y(d);if(c.ipv4)if(c.tcp)a:{a=`${c.ipv4.src.join(".")}:${c.tcp.sport}:${c.ipv4.dest.join(".")}:${c.tcp.dport}`;if(c.tcp.syn&&!c.tcp.ack){b.tcp_conn[a]&&delete b.tcp_conn[a];d=new
|
|
195
|
-
new Uint8Array(c.ipv4.src);b.bus.pair.send("tcp-connection",d);if(b.on_tcp_connection)b.on_tcp_connection(d,c);if(b.tcp_conn[a])break a}if(b.tcp_conn[a])b.tcp_conn[a].process(c);else{a=c.tcp.ackn;if(c.tcp.fin||c.tcp.syn)a+=1;d={};d.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src};d.ipv4={proto:6,src:c.ipv4.dest,dest:c.ipv4.src};d.tcp={sport:c.tcp.dport,dport:c.tcp.sport,seq:a,ackn:c.tcp.seq+(c.tcp.syn?1:0),winsize:c.tcp.winsize,rst:!0,ack:c.tcp.syn};b.receive(
|
|
196
|
-
b.dns_method){a={};a.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src};a.ipv4={proto:17,src:b.router_ip,dest:c.ipv4.src};a.udp={sport:53,dport:c.udp.sport};d=[];for(e=0;e<c.dns.questions.length;++e)switch(l=c.dns.questions[e],l.type){case 1:d.push({name:l.name,type:l.type,class:l.class,ttl:600,data:[192,168,87,1]})}a.dns={id:c.dns.id,flags:33152,questions:c.dns.questions,answers:d};b.receive(
|
|
197
|
-
{ethertype:2048,src:b.router_mac,dest:c.eth.src},e.ipv4={proto:17,src:c.ipv4.dest,dest:c.ipv4.src},e.udp={sport:123,dport:c.udp.sport},e.ntp=Object.assign({},c.ntp),e.ntp.flags=36,e.ntp.poll=10,e.ntp.ori_ts_i=c.ntp.trans_ts_i,e.ntp.ori_ts_f=c.ntp.trans_ts_f,e.ntp.rec_ts_i=a/1E3,e.ntp.rec_ts_f=d,e.ntp.trans_ts_i=a/1E3,e.ntp.trans_ts_f=d,e.ntp.stratum=2,b.receive(
|
|
198
|
-
dest:c.ipv4.src},a.udp={sport:c.udp.dport,dport:c.udp.sport,data:(new TextEncoder).encode(c.udp.data_s)},b.receive(
|
|
199
|
-
99<c.arp.tpa[3]||(a={},a.eth={ethertype:2054,src:b.router_mac,dest:c.eth.src},a.arp={htype:1,ptype:2048,oper:2,sha:b.router_mac,spa:c.arp.tpa,tha:c.eth.src,tpa:c.arp.spa},b.receive(
|
|
200
|
-
function
|
|
194
|
+
oper:d.getUint16(6),sha:a.subarray(8,14),spa:a.subarray(14,18),tha:a.subarray(18,24),tpa:a.subarray(24,28)},c.arp=a):34525!==d&&y(d);if(c.ipv4)if(c.tcp)a:{a=`${c.ipv4.src.join(".")}:${c.tcp.sport}:${c.ipv4.dest.join(".")}:${c.tcp.dport}`;if(c.tcp.syn&&!c.tcp.ack){b.tcp_conn[a]&&delete b.tcp_conn[a];d=new Mb(b);d.state="syn-received";d.tuple=a;d.last=c;d.hsrc=new Uint8Array(c.eth.dest);d.psrc=new Uint8Array(c.ipv4.dest);d.sport=c.tcp.dport;d.hdest=new Uint8Array(c.eth.src);d.dport=c.tcp.sport;d.pdest=
|
|
195
|
+
new Uint8Array(c.ipv4.src);b.bus.pair.send("tcp-connection",d);if(b.on_tcp_connection)b.on_tcp_connection(d,c);if(b.tcp_conn[a])break a}if(b.tcp_conn[a])b.tcp_conn[a].process(c);else{a=c.tcp.ackn;if(c.tcp.fin||c.tcp.syn)a+=1;d={};d.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src};d.ipv4={proto:6,src:c.ipv4.dest,dest:c.ipv4.src};d.tcp={sport:c.tcp.dport,dport:c.tcp.sport,seq:a,ackn:c.tcp.seq+(c.tcp.syn?1:0),winsize:c.tcp.winsize,rst:!0,ack:c.tcp.syn};b.receive(Hb(b.eth_encoder_buf,d))}}else if(c.udp)if(c.dns)if("static"===
|
|
196
|
+
b.dns_method){a={};a.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src};a.ipv4={proto:17,src:b.router_ip,dest:c.ipv4.src};a.udp={sport:53,dport:c.udp.sport};d=[];for(e=0;e<c.dns.questions.length;++e)switch(l=c.dns.questions[e],l.type){case 1:d.push({name:l.name,type:l.type,class:l.class,ttl:600,data:[192,168,87,1]})}a.dns={id:c.dns.id,flags:33152,questions:c.dns.questions,answers:d};b.receive(Hb(b.eth_encoder_buf,a))}else Ib(c,b);else c.dhcp?Jb(c,b):c.ntp?(a=Date.now()+sb,d=a%1E3/1E3*tb,e={},e.eth=
|
|
197
|
+
{ethertype:2048,src:b.router_mac,dest:c.eth.src},e.ipv4={proto:17,src:c.ipv4.dest,dest:c.ipv4.src},e.udp={sport:123,dport:c.udp.sport},e.ntp=Object.assign({},c.ntp),e.ntp.flags=36,e.ntp.poll=10,e.ntp.ori_ts_i=c.ntp.trans_ts_i,e.ntp.ori_ts_f=c.ntp.trans_ts_f,e.ntp.rec_ts_i=a/1E3,e.ntp.rec_ts_f=d,e.ntp.trans_ts_i=a/1E3,e.ntp.trans_ts_f=d,e.ntp.stratum=2,b.receive(Hb(b.eth_encoder_buf,e))):8===c.udp.dport&&(a={},a.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src},a.ipv4={proto:17,src:c.ipv4.dest,
|
|
198
|
+
dest:c.ipv4.src},a.udp={sport:c.udp.dport,dport:c.udp.sport,data:(new TextEncoder).encode(c.udp.data_s)},b.receive(Hb(b.eth_encoder_buf,a)));else c.icmp&&8===c.icmp.type&&(a={},a.eth={ethertype:2048,src:b.router_mac,dest:c.eth.src},a.ipv4={proto:1,src:c.ipv4.dest,dest:c.ipv4.src},a.icmp={type:0,code:c.icmp.code,data:c.icmp.data},b.receive(Hb(b.eth_encoder_buf,a)));else c.arp&&1===c.arp.oper&&2048===c.arp.ptype&&(a=Cb(c.arp.tpa)&4294967040,d=Cb(b.router_ip)&4294967040,!b.masquerade&&a!==d||a===d&&
|
|
199
|
+
99<c.arp.tpa[3]||(a={},a.eth={ethertype:2054,src:b.router_mac,dest:c.eth.src},a.arp={htype:1,ptype:2048,oper:2,sha:b.router_mac,spa:c.arp.tpa,tha:c.eth.src,tpa:c.arp.spa},b.receive(Hb(b.eth_encoder_buf,a))))}
|
|
200
|
+
function Lb(a,b){function c(){let m=[],n;do n=d.getUint8(h),m.push((new TextDecoder).decode(a.subarray(h+1,h+1+n))),h+=n+1;while(0<n);return m}let d=new DataView(a.buffer,a.byteOffset,a.byteLength),e={id:d.getUint16(0),flags:d.getUint16(2),questions:[],answers:[]};var f=d.getUint16(4);let g=d.getUint16(6);d.getUint16(8);d.getUint16(10);let h=12;for(var l=0;l<f;l++)e.questions.push({name:c(),type:d.getInt16(h),class:d.getInt16(h+2)}),h+=4;for(f=0;f<g;f++){l={name:c(),type:d.getInt16(h),class:d.getUint16(h+
|
|
201
201
|
2),ttl:d.getUint32(h+4)};h+=8;let m=d.getUint16(h);h+=2;l.data=a.subarray(h,h+m);h+=m;e.answers.push(l)}b.dns=e}
|
|
202
|
-
function
|
|
203
|
-
function Vb(a,b){return new Promise(c=>{let d=
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"syn-probe"===this.state&&a.tcp.ack&&(this.emit("probe",!0),a=this.packet_reply(a,{rst:!0}),this.net.receive(
|
|
209
|
-
b){if(this.last_received_ackn=a.tcp.ackn,this.send_buffer.remove(b),this.seq+=b,this.pending=!1,this.delayed_send_fin&&!this.send_buffer.length){this.delayed_send_fin=!1;this.state=this.delayed_state;a=this.ipv4_reply();a.tcp.fin=!0;this.net.receive(
|
|
210
|
-
!0,this.state="close-wait",this.on_shutdown()):"fin-wait-1"===this.state?(a.tcp.ack?this.release():this.state="closing",b.tcp.ack=!0):"fin-wait-2"===this.state?(this.release(),b.tcp.ack=!0):(this.release(),this.on_close(),b.tcp.rst=!0),this.net.receive(
|
|
211
|
-
b)),this.emit("data",a.tcp_data));this.pump()}};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this.doh_server=b.doh_server;this.tcp_conn={};this.mtu=b.mtu;this.eth_encoder_buf=
|
|
215
|
-
Wb.prototype.connect=function(a){return
|
|
202
|
+
function Nb(a,b){var c=b.vm_ip.join(".");const d=b.router_ip.join("."),e=16383*Math.random()|0;let f,g,h=0;do f=49152+(e+h)%16383,g=`${c}:${a}:${d}:${f}`;while(16383>++h&&b.tcp_conn[g]);if(b.tcp_conn[g])throw Error("pool of dynamic TCP port numbers exhausted, connection aborted");c=new Mb(b);c.tuple=g;c.hsrc=b.router_mac;c.psrc=b.router_ip;c.sport=f;c.hdest=b.vm_mac;c.dport=a;c.pdest=b.vm_ip;b.tcp_conn[g]=c;c.connect();return c}
|
|
203
|
+
function Vb(a,b){return new Promise(c=>{let d=Nb(a,b);d.state="syn-probe";d.on("probe",c)})}function Mb(a){this.mtu=a.mtu||1500;const b=this.mtu-20-20;this.state="closed";this.net=a;this.send_buffer=new Db(2048,0);this.send_chunk_buf=new Uint8Array(b);this.delayed_send_fin=this.in_active_close=!1;this.delayed_state=void 0;this.events_handlers={}}Mb.prototype.on=function(a,b){this.events_handlers[a]=b};Mb.prototype.emit=function(a,...b){this.events_handlers[a]&&this.events_handlers[a].apply(this,b)};
|
|
204
|
+
Mb.prototype.ipv4_reply=function(){let a={};a.eth={ethertype:2048,src:this.hsrc,dest:this.hdest};a.ipv4={proto:6,src:this.psrc,dest:this.pdest};a.tcp={sport:this.sport,dport:this.dport,winsize:this.winsize,ackn:this.ack,seq:this.seq,ack:!0};return a};Mb.prototype.packet_reply=function(a,b){a={sport:a.tcp.dport,dport:a.tcp.sport,winsize:a.tcp.winsize,ackn:this.ack,seq:this.seq};if(b)for(const c in b)a[c]=b[c];b=this.ipv4_reply();b.tcp=a;return b};
|
|
205
|
+
Mb.prototype.connect=function(){this.seq=1338;this.ack=1;this.start_seq=0;this.winsize=64240;"syn-probe"!==this.state&&(this.state="syn-sent");let a=this.ipv4_reply();a.ipv4.id=2345;a.tcp={sport:this.sport,dport:this.dport,seq:1337,ackn:0,winsize:0,syn:!0};this.net.receive(Hb(this.net.eth_encoder_buf,a))};
|
|
206
|
+
Mb.prototype.accept=function(a){a=a||this.last;this.net.tcp_conn[this.tuple]=this;this.seq=1338;this.ack=a.tcp.seq+1;this.start_seq=a.tcp.seq;this.winsize=a.tcp.winsize;let b=this.ipv4_reply();b.tcp={sport:this.sport,dport:this.dport,seq:1337,ackn:this.ack,winsize:a.tcp.winsize,syn:!0,ack:!0,options:{mss:this.mtu-20-20}};this.state="established";this.net.receive(Hb(this.net.eth_encoder_buf,b))};
|
|
207
|
+
Mb.prototype.process=function(a){this.last=a;if("closed"===this.state)a=this.packet_reply(a,{rst:!0}),this.net.receive(Hb(this.net.eth_encoder_buf,a));else if(a.tcp.rst){if("syn-probe"===this.state)this.emit("probe",!1);else this.on_close();this.release()}else if(a.tcp.syn)"syn-sent"===this.state&&a.tcp.ack?(this.ack=a.tcp.seq+1,this.start_seq=a.tcp.seq,this.last_received_ackn=a.tcp.ackn,a=this.ipv4_reply(),this.net.receive(Hb(this.net.eth_encoder_buf,a)),this.state="established",this.emit("connect")):
|
|
208
|
+
"syn-probe"===this.state&&a.tcp.ack&&(this.emit("probe",!0),a=this.packet_reply(a,{rst:!0}),this.net.receive(Hb(this.net.eth_encoder_buf,a)),this.release());else{if(a.tcp.ack)if("syn-received"===this.state)this.state="established";else if("fin-wait-1"===this.state)a.tcp.fin||(this.state="fin-wait-2");else if("closing"===this.state||"last-ack"===this.state){this.release();return}if(void 0===this.last_received_ackn)this.last_received_ackn=a.tcp.ackn;else{var b=a.tcp.ackn-this.last_received_ackn;if(0<
|
|
209
|
+
b){if(this.last_received_ackn=a.tcp.ackn,this.send_buffer.remove(b),this.seq+=b,this.pending=!1,this.delayed_send_fin&&!this.send_buffer.length){this.delayed_send_fin=!1;this.state=this.delayed_state;a=this.ipv4_reply();a.tcp.fin=!0;this.net.receive(Hb(this.net.eth_encoder_buf,a));return}}else if(0>b){a=this.packet_reply(a,{rst:!0});this.net.receive(Hb(this.net.eth_encoder_buf,a));this.on_close();this.release();return}}a.tcp.fin?(++this.ack,b=this.packet_reply(a,{}),"established"===this.state?(b.tcp.ack=
|
|
210
|
+
!0,this.state="close-wait",this.on_shutdown()):"fin-wait-1"===this.state?(a.tcp.ack?this.release():this.state="closing",b.tcp.ack=!0):"fin-wait-2"===this.state?(this.release(),b.tcp.ack=!0):(this.release(),this.on_close(),b.tcp.rst=!0),this.net.receive(Hb(this.net.eth_encoder_buf,b))):this.ack!==a.tcp.seq?(a=this.packet_reply(a,{ack:!0}),this.net.receive(Hb(this.net.eth_encoder_buf,a))):a.tcp.ack&&0<a.tcp_data.length&&(this.ack+=a.tcp_data.length,b=this.ipv4_reply(),this.net.receive(Hb(this.net.eth_encoder_buf,
|
|
211
|
+
b)),this.emit("data",a.tcp_data));this.pump()}};Mb.prototype.write=function(a){this.in_active_close||this.send_buffer.write(a);this.pump()};Mb.prototype.writev=function(a){if(!this.in_active_close)for(const b of a)this.send_buffer.write(b);this.pump()};
|
|
212
|
+
Mb.prototype.close=function(){if(!this.in_active_close){this.in_active_close=!0;if("established"===this.state||"syn-received"===this.state)var a="fin-wait-1";else if("close-wait"===this.state)a="last-ack";else{this.release();return}this.send_buffer.length||this.pending?(this.delayed_send_fin=!0,this.delayed_state=a):(this.state=a,a=this.ipv4_reply(),a.tcp.fin=!0,this.net.receive(Hb(this.net.eth_encoder_buf,a)))}this.pump()};Mb.prototype.on_shutdown=function(){this.emit("shutdown")};
|
|
213
|
+
Mb.prototype.on_close=function(){this.emit("close")};Mb.prototype.release=function(){this.net.tcp_conn[this.tuple]&&(this.state="closed",delete this.net.tcp_conn[this.tuple])};Mb.prototype.pump=function(){if(this.send_buffer.length&&!this.pending){const a=this.send_chunk_buf,b=this.send_buffer.peek(a),c=this.ipv4_reply();c.tcp.psh=!0;c.tcp_data=a.subarray(0,b);this.net.receive(Hb(this.net.eth_encoder_buf,c));this.pending=!0}};function Wb(a,b){b=b||{};this.bus=a;this.id=b.id||0;this.router_mac=new Uint8Array((b.router_mac||"52:54:0:1:2:3").split(":").map(function(c){return parseInt(c,16)}));this.router_ip=new Uint8Array((b.router_ip||"192.168.86.1").split(".").map(function(c){return parseInt(c,10)}));this.vm_ip=new Uint8Array((b.vm_ip||"192.168.86.100").split(".").map(function(c){return parseInt(c,10)}));this.masquerade=void 0===b.masquerade||!!b.masquerade;this.vm_mac=new Uint8Array(6);this.dns_method=b.dns_method||"static";
|
|
214
|
+
this.doh_server=b.doh_server;this.tcp_conn={};this.mtu=b.mtu;this.eth_encoder_buf=Eb(this.mtu);this.fetch=(...c)=>fetch(...c);this.cors_proxy=b.cors_proxy;this.bus.register("net"+this.id+"-mac",function(c){this.vm_mac=new Uint8Array(c.split(":").map(function(d){return parseInt(d,16)}))},this);this.bus.register("net"+this.id+"-send",function(c){this.send(c)},this);this.bus.register("tcp-connection",c=>{80===c.sport&&(c.on("data",Xb),c.accept())},this)}Wb.prototype.destroy=function(){};
|
|
215
|
+
Wb.prototype.connect=function(a){return Nb(a,this)};Wb.prototype.tcp_probe=function(a){return Vb(a,this)};
|
|
216
216
|
async function Xb(a){this.read=this.read||"";if((this.read+=(new TextDecoder).decode(a))&&-1!==this.read.indexOf("\r\n\r\n")){a=this.read.indexOf("\r\n\r\n");var b=this.read.substring(0,a).split(/\r\n/);a=this.read.substring(a+4);this.read="";let c=b[0].split(" "),d;d=/^https?:/.test(c[1])?new URL(c[1]):new URL("http://host"+c[1]);"undefined"!==typeof window&&"http:"===d.protocol&&"https:"===window.location.protocol&&(d.protocol="https:");let e=new Headers;for(let h=1;h<b.length;++h){const l=this.net.parse_http_header(b[h]);
|
|
217
217
|
if(!l){console.warn('The request contains an invalid header: "%s"',b[h]);this.net.respond_text_and_close(this,400,"Bad Request",`Invalid header in request: ${b[h]}`);return}"host"===l.key.toLowerCase()?d.host=l.value:e.append(l.key,l.value)}if(!this.net.cors_proxy&&/^\d+\.external$/.test(d.hostname))if(b=parseInt(d.hostname.split(".")[0],10),!isNaN(b)&&0<b&&65536>b)d.protocol="http:",d.hostname="localhost",d.port=b.toString(10);else{console.warn('Unknown port for localhost: "%s"',d.href);this.net.respond_text_and_close(this,
|
|
218
218
|
400,"Bad Request",`Unknown port for localhost: ${d.href}`);return}this.name=d.href;b={method:c[0],headers:e};-1!==["put","post"].indexOf(b.method.toLowerCase())&&(b.body=a);const f=this.net.cors_proxy?this.net.cors_proxy+encodeURIComponent(d.href):d.href;new TextEncoder;let g=!1;this.net.fetch(f,b).then(h=>{let l=new Headers(h.headers);l.delete("content-encoding");l.delete("keep-alive");l.delete("content-length");l.delete("transfer-encoding");l.set("x-was-fetch-redirected",`${!!h.redirected}`);l.set("x-fetch-resp-url",
|
|
219
219
|
h.url);l.set("connection","close");this.write(this.net.form_response_head(h.status,h.statusText,l));g=!0;if(h.body&&h.body.getReader){const m=h.body.getReader(),n=({value:p,done:q})=>{p&&this.write(p);if(q)this.close();else return m.read().then(n)};m.read().then(n)}else h.arrayBuffer().then(m=>{this.write(new Uint8Array(m));this.close()})}).catch(h=>{console.warn("Fetch Failed: "+f+"\n"+h);g||this.net.respond_text_and_close(this,502,"Fetch Error",`Fetch ${f} failed:\n\n${h.stack||h.message}`);this.close()})}}
|
|
220
220
|
Wb.prototype.fetch=async function(a,b){this.cors_proxy&&(a=this.cors_proxy+encodeURIComponent(a));try{const c=await fetch(a,b),d=await c.arrayBuffer();return[c,d]}catch(c){return console.warn("Fetch Failed: "+a+"\n"+c),[{status:502,statusText:"Fetch Error",headers:new Headers({"Content-Type":"text/plain"})},(new TextEncoder).encode(`Fetch ${a} failed:\n\n${c.stack}`).buffer]}};
|
|
221
221
|
Wb.prototype.form_response_head=function(a,b,c){a=[`HTTP/1.1 ${a} ${b}`];for(const [d,e]of c.entries())a.push(`${d}: ${e}`);return(new TextEncoder).encode(a.join("\r\n")+"\r\n\r\n")};Wb.prototype.respond_text_and_close=function(a,b,c,d){const e=new Headers({"content-type":"text/plain","content-length":d.length.toString(10),connection:"close"});a.writev([this.form_response_head(b,c,e),(new TextEncoder).encode(d)]);a.close()};
|
|
222
|
-
Wb.prototype.parse_http_header=function(a){var b=a.match(/^([^:]*):(.*)$/);if(b&&(a=b[1],b=b[2].trim(),0!==a.length&&0!==b.length&&/^[\w-]+$/.test(a)&&/^[\x20-\x7E]+$/.test(b)))return{key:a,value:b}};Wb.prototype.send=function(a){
|
|
223
|
-
void 0===c.masquerade||!!c.masquerade;this.vm_mac=new Uint8Array(6);this.dns_method=c.dns_method||"doh";this.doh_server=c.doh_server;this.tcp_conn={};this.mtu=c.mtu;this.eth_encoder_buf=
|
|
222
|
+
Wb.prototype.parse_http_header=function(a){var b=a.match(/^([^:]*):(.*)$/);if(b&&(a=b[1],b=b[2].trim(),0!==a.length&&0!==b.length&&/^[\w-]+$/.test(a)&&/^[\x20-\x7E]+$/.test(b)))return{key:a,value:b}};Wb.prototype.send=function(a){Kb(a,this)};Wb.prototype.receive=function(a){this.bus.send("net"+this.id+"-receive",new Uint8Array(a))};function Yb(a,b,c){this.register_ws(a);this.last_stream=1;this.connections={0:{congestion:0}};this.congested_buffer=[];c=c||{};this.bus=b;this.id=c.id||0;this.router_mac=new Uint8Array((c.router_mac||"52:54:0:1:2:3").split(":").map(function(d){return parseInt(d,16)}));this.router_ip=new Uint8Array((c.router_ip||"192.168.86.1").split(".").map(function(d){return parseInt(d,10)}));this.vm_ip=new Uint8Array((c.vm_ip||"192.168.86.100").split(".").map(function(d){return parseInt(d,10)}));this.masquerade=
|
|
223
|
+
void 0===c.masquerade||!!c.masquerade;this.vm_mac=new Uint8Array(6);this.dns_method=c.dns_method||"doh";this.doh_server=c.doh_server;this.tcp_conn={};this.mtu=c.mtu;this.eth_encoder_buf=Eb(this.mtu);this.bus.register("net"+this.id+"-mac",function(d){this.vm_mac=new Uint8Array(d.split(":").map(function(e){return parseInt(e,16)}))},this);this.bus.register("net"+this.id+"-send",function(d){this.send(d)},this)}
|
|
224
224
|
Yb.prototype.register_ws=function(a){this.wispws=new WebSocket(a.replace("wisp://","ws://").replace("wisps://","wss://"));this.wispws.binaryType="arraybuffer";this.wispws.onmessage=b=>{this.process_incoming_wisp_frame(new Uint8Array(b.data))};this.wispws.onclose=()=>{setTimeout(()=>{this.register_ws(a)},1E4)}};
|
|
225
225
|
Yb.prototype.send_packet=function(a,b,c){this.connections[c]&&(0<this.connections[c].congestion?("DATA"===b&&this.connections[c].congestion--,this.wispws.send(a)):(this.connections[c].congested=!0,this.congested_buffer.push({data:a,type:b})))};
|
|
226
226
|
Yb.prototype.process_incoming_wisp_frame=function(a){const b=new DataView(a.buffer),c=b.getUint32(1,!0);switch(a[0]){case 2:if(this.connections[c])this.connections[c].data_callback(a.slice(5));else throw Error("Got a DATA packet but stream not registered. ID: "+c);break;case 3:this.connections[c]&&(this.connections[c].congestion=b.getUint32(5,!0));if(this.connections[c].congested){a=this.congested_buffer.slice(0);this.congested_buffer.length=0;this.connections[c].congested=!1;for(const d of a)this.send_packet(d.data,
|
|
@@ -228,23 +228,23 @@ d.type,c)}break;case 4:this.connections[c]&&this.connections[c].close_callback(b
|
|
|
228
228
|
Yb.prototype.send_wisp_frame=function(a){let b,c;switch(a.type){case "CONNECT":const d=(new TextEncoder).encode(a.hostname);b=new Uint8Array(8+d.length);c=new DataView(b.buffer);c.setUint8(0,1);c.setUint32(1,a.stream_id,!0);c.setUint8(5,1);c.setUint16(6,a.port,!0);b.set(d,8);this.connections[a.stream_id]={data_callback:a.data_callback,close_callback:a.close_callback,congestion:this.connections[0].congestion};break;case "DATA":b=new Uint8Array(5+a.data.length);c=new DataView(b.buffer);c.setUint8(0,
|
|
229
229
|
2);c.setUint32(1,a.stream_id,!0);b.set(a.data,5);break;case "CLOSE":b=new Uint8Array(6),c=new DataView(b.buffer),c.setUint8(0,4),c.setUint32(1,a.stream_id,!0),c.setUint8(5,a.reason)}this.send_packet(b,a.type,a.stream_id)};Yb.prototype.destroy=function(){this.wispws&&(this.wispws.onmessage=null,this.wispws.onclose=null,this.wispws.close(),this.wispws=null)};
|
|
230
230
|
Yb.prototype.on_tcp_connection=function(a,b){a.stream_id=this.last_stream++;a.on("data",c=>{0!==c.length&&this.send_wisp_frame({type:"DATA",stream_id:a.stream_id,data:c})});a.on_close=()=>{this.send_wisp_frame({type:"CLOSE",stream_id:a.stream_id,reason:2})};a.on_shutdown=a.on_close;this.send_wisp_frame({type:"CONNECT",stream_id:a.stream_id,hostname:b.ipv4.dest.join("."),port:a.sport,data_callback:c=>{a.write(c)},close_callback:()=>{a.close()}});a.accept();return!0};
|
|
231
|
-
Yb.prototype.send=function(a){
|
|
231
|
+
Yb.prototype.send=function(a){Kb(a,this)};Yb.prototype.receive=function(a){this.bus.send("net"+this.id+"-receive",new Uint8Array(a))};const Zb="undefined"!==typeof window&&0<=window.navigator.platform.toString().toLowerCase().search("win");
|
|
232
232
|
function $b(a){function b(v){return v.shiftKey&&v.ctrlKey&&(73===v.keyCode||74===v.keyCode||75===v.keyCode)||!x.emu_enabled?!1:v.target?v.target.classList.contains("phone_keyboard")||"INPUT"!==v.target.nodeName&&"TEXTAREA"!==v.target.nodeName:!0}function c(v){!v.altKey&&n[56]&&l(56,!1);return g(v,!1)}function d(v){!v.altKey&&n[56]&&l(56,!1);return g(v,!0)}function e(){for(var v=Object.keys(n),H,U=0;U<v.length;U++)H=+v[U],n[H]&&l(H,!1);n={}}function f(v){if(x.bus&&b(v))switch(v.inputType){case "insertText":for(var H=
|
|
233
233
|
0;H<v.data.length;H++)x.simulate_char(v.data[H]);break;case "insertLineBreak":x.simulate_press(13);break;case "deleteContentBackward":x.simulate_press(8)}}function g(v,H){if(x.bus&&b(v)&&""!==v.code&&"Process"!==v.key&&"Unidentified"!==v.key&&229!==v.keyCode){v.preventDefault&&v.preventDefault();if(Zb&&(p&&(clearTimeout(r),v.getModifierState&&v.getModifierState("AltGraph")&&q===H&&"ControlLeft"===p.code&&"AltRight"===v.code||h(p,q),p=null),"ControlLeft"===v.code))return p=v,q=H,r=setTimeout(()=>{h(p,
|
|
234
|
-
q);p=null},10),!1;h(v,H);return!1}}function h(v,H){a:{if(void 0!==v.code){var U=K[v.code];if(void 0!==U)break a}U=
|
|
234
|
+
q);p=null},10),!1;h(v,H);return!1}}function h(v,H){a:{if(void 0!==v.code){var U=K[v.code];if(void 0!==U)break a}U=D[v.keyCode]}U?l(U,H,v.repeat):console.log("Missing char in map: keyCode="+(v.keyCode||-1).toString(16)+" code="+v.code)}function l(v,H,U){if(H)n[v]&&!U&&l(v,!1);else if(!n[v])return;(n[v]=H)||(v|=128);255<v?(m(v>>8),m(v&255)):m(v)}function m(v){x.bus.send("keyboard-code",v)}var n={},p=null,q=!1,r=0,x=this;this.emu_enabled=!0;const D=new Uint16Array([0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,
|
|
235
235
|
42,29,56,0,58,0,0,0,0,0,0,1,0,0,0,0,57,57417,57425,57423,57415,57419,57416,57421,80,0,0,0,0,82,83,0,11,2,3,4,5,6,7,8,9,10,0,39,0,13,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44,57435,57436,57437,0,0,82,79,80,81,75,76,77,71,72,73,0,0,0,0,0,0,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
236
236
|
0,0,0,0,0,0,0,26,43,27,40,0,57435,57400,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),z={8:8,10:13,32:32,39:222,44:188,45:189,46:190,47:191,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,59:186,61:187,91:219,92:220,93:221,96:192,97:65,98:66,99:67,100:68,101:69,102:70,103:71,104:72,105:73,106:74,107:75,108:76,109:77,110:78,111:79,112:80,113:81,114:82,115:83,116:84,117:85,118:86,119:87,120:88,121:89,122:90},u={33:49,34:222,35:51,36:52,37:53,38:55,40:57,41:48,42:56,43:187,58:186,60:188,62:190,63:191,64:50,
|
|
237
237
|
65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,94:54,95:189,123:219,124:220,125:221,126:192};var K={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,
|
|
238
238
|
KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,IntlRo:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,
|
|
239
239
|
IntlBackslash:86,F11:87,F12:88,NumpadEnter:57372,ControlRight:57373,NumpadDivide:57397,AltRight:57400,Home:57415,ArrowUp:57416,PageUp:57417,ArrowLeft:57419,ArrowRight:57421,End:57423,ArrowDown:57424,PageDown:57425,Insert:57426,Delete:57427,MetaLeft:57435,OSLeft:57435,MetaRight:57436,OSRight:57436,ContextMenu:57437};this.bus=a;this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("keyup",c,!1),window.removeEventListener("keydown",d,!1),window.removeEventListener("blur",e,
|
|
240
240
|
!1),window.removeEventListener("input",f,!1))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("keyup",c,!1),window.addEventListener("keydown",d,!1),window.addEventListener("blur",e,!1),window.addEventListener("input",f,!1))};this.init();this.simulate_press=function(v){v={keyCode:v};g(v,!0);g(v,!1)};this.simulate_char=function(v){var H=v.charCodeAt(0);H in z?this.simulate_press(z[H]):H in u?(m(42),this.simulate_press(u[H]),m(170)):console.log("ascii -> keyCode not found: ",
|
|
241
|
-
H,v)}};function ac(a,b){function c(){z.bus.send("mouse-pointer-lock",!!document.pointerLockElement)}function d(u){if(!z.enabled||!z.emu_enabled)return!1;var K=b||document.body,v;if(!(v=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===K){v=!0;break a}u=u.parentNode}v=!1}return v}function e(u){d(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-1],x=u.clientX,
|
|
242
|
-
0,v=0,H=u.changedTouches;H?H.length&&(H=H[H.length-1],K=H.clientX-x,v=H.clientY-
|
|
243
|
-
u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function h(u){d(u)&&m(u,!0)}function l(u){d(u)&&m(u,!1)}function m(u,K){z.bus&&(1===u.which?p=K:2===u.which?r=K:3===u.which&&(q=K),z.bus.send("mouse-click",[p,r,q]),u.preventDefault())}function n(u){if(d(u)){var K=u.wheelDelta||-u.detail;0>K?K=-1:0<K&&(K=1);z.bus.send("mouse-wheel",[K,0]);u.preventDefault()}}var p=!1,q=!1,r=!1,x=0,
|
|
241
|
+
H,v)}};function ac(a,b){function c(){z.bus.send("mouse-pointer-lock",!!document.pointerLockElement)}function d(u){if(!z.enabled||!z.emu_enabled)return!1;var K=b||document.body,v;if(!(v=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===K){v=!0;break a}u=u.parentNode}v=!1}return v}function e(u){d(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-1],x=u.clientX,D=u.clientY)}function f(){if(p||r||q)z.bus.send("mouse-click",[!1,!1,!1]),p=r=q=!1}function g(u){if(z.bus&&d(u)&&z.is_running){var K=
|
|
242
|
+
0,v=0,H=u.changedTouches;H?H.length&&(H=H[H.length-1],K=H.clientX-x,v=H.clientY-D,x=H.clientX,D=H.clientY,u.preventDefault()):"number"===typeof u.movementX?(K=u.movementX,v=u.movementY):"number"===typeof u.webkitMovementX?(K=u.webkitMovementX,v=u.webkitMovementY):"number"===typeof u.mozMovementX?(K=u.mozMovementX,v=u.mozMovementY):(K=u.clientX-x,v=u.clientY-D,x=u.clientX,D=u.clientY);z.bus.send("mouse-delta",[1*K,-(1*v)]);b&&!document.pointerLockElement&&z.bus.send("mouse-absolute",[u.pageX-b.offsetLeft,
|
|
243
|
+
u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function h(u){d(u)&&m(u,!0)}function l(u){d(u)&&m(u,!1)}function m(u,K){z.bus&&(1===u.which?p=K:2===u.which?r=K:3===u.which&&(q=K),z.bus.send("mouse-click",[p,r,q]),u.preventDefault())}function n(u){if(d(u)){var K=u.wheelDelta||-u.detail;0>K?K=-1:0<K&&(K=1);z.bus.send("mouse-wheel",[K,0]);u.preventDefault()}}var p=!1,q=!1,r=!1,x=0,D=0,z=this;this.enabled=!1;this.emu_enabled=!0;this.bus=a;this.bus.register("mouse-enable",function(u){this.enabled=
|
|
244
244
|
u},this);this.is_running=!1;this.bus.register("emulator-stopped",function(){this.is_running=!1},this);this.bus.register("emulator-started",function(){this.is_running=!0},this);this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("touchstart",e,!1),window.removeEventListener("touchend",f,!1),window.removeEventListener("touchmove",g,!1),window.removeEventListener("mousemove",g,!1),window.removeEventListener("mousedown",h,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("wheel",
|
|
245
245
|
n,{passive:!1}),document.removeEventListener("pointerlockchange",c,!1))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("touchstart",e,!1),window.addEventListener("touchend",f,!1),window.addEventListener("touchmove",g,!1),window.addEventListener("mousemove",g,!1),window.addEventListener("mousedown",h,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("wheel",n,{passive:!1}),document.addEventListener("pointerlockchange",c,!1))};this.init()}
|
|
246
|
-
;function bc(a){var b,c=0,d=0,e=ta(a?.encoding);this.put_char=function(f,g,h){b[f*c+g]=h};this.destroy=function(){};this.pause=function(){};this.continue=function(){};this.set_mode=function(){};this.set_font_bitmap=function(){};this.set_font_page=function(){};this.clear_screen=function(){};this.set_size_text=function(f,g){if(f!==c||g!==d)b=new Uint8Array(f*g),c=f,d=g};this.set_size_graphical=function(){};this.set_scale=function(){};this.update_cursor_scanline=
|
|
247
|
-
this.update_buffer=function(){};this.get_text_screen=function(){for(var f=[],g=0;g<d;g++)f.push(this.get_text_row(g));return f};this.get_text_row=function(f){f*=c;return Array.from(b.subarray(f,f+c),g=>e[g]).join("")};this.set_size_text(80,25)};function cc(a){var b,c=0,d=0,e=ta(a?.encoding);this.put_char=function(f,g,h,l,m,n){f=3*(f*c+g);b[f+0]=h;b[f+1]=m;b[f+2]=n};this.destroy=function(){};this.pause=function(){};this.continue=function(){};this.set_mode=function(){};this.set_font_bitmap=function(){};this.set_font_page=function(){};this.clear_screen=function(){};this.set_size_text=function(f,g){if(f!==c||g!==d)b=new Int32Array(f*g*3),c=f,d=g};this.set_size_graphical=function(){};this.set_scale=function(){};this.update_cursor_scanline=function(){};
|
|
246
|
+
;function bc(a){var b,c=0,d=0,e=ta(a?.encoding);this.put_char=function(f,g,h){b[f*c+g]=h};this.destroy=function(){};this.pause=function(){};this.continue=function(){};this.clear_text_state=function(){d=c=null};this.set_mode=function(){};this.set_font_bitmap=function(){};this.set_font_page=function(){};this.clear_screen=function(){};this.set_size_text=function(f,g){if(f!==c||g!==d)b=new Uint8Array(f*g),c=f,d=g};this.set_size_graphical=function(){};this.set_scale=function(){};this.update_cursor_scanline=
|
|
247
|
+
function(){};this.update_cursor=function(){};this.update_buffer=function(){};this.get_text_screen=function(){for(var f=[],g=0;g<d;g++)f.push(this.get_text_row(g));return f};this.get_text_row=function(f){f*=c;return Array.from(b.subarray(f,f+c),g=>e[g]).join("")};this.set_size_text(80,25)};function cc(a){var b,c=0,d=0,e=ta(a?.encoding);this.put_char=function(f,g,h,l,m,n){f=3*(f*c+g);b[f+0]=h;b[f+1]=m;b[f+2]=n};this.destroy=function(){};this.pause=function(){};this.continue=function(){};this.set_mode=function(){};this.set_font_bitmap=function(){};this.set_font_page=function(){};this.clear_screen=function(){};this.set_size_text=function(f,g){if(f!==c||g!==d)b=new Int32Array(f*g*3),c=f,d=g};this.set_size_graphical=function(){};this.set_scale=function(){};this.update_cursor_scanline=function(){};
|
|
248
248
|
this.update_cursor=function(){};this.update_buffer=function(){};this.get_text_screen=function(){for(var f=[],g=0;g<d;g++)f.push(this.get_text_row(g));return f};this.get_text_row=function(f){var g=f*c*3;f=g+3*c;let h=null,l=null,m="";for(;g<f;g+=3){const n=e[b[g]],p=b[g+1],q=b[g+2];let r="";h!==p&&(r+=`\x1B[48;${`2;${(p&16711680)>>16};${(p&65280)>>8};${p&255}`}m`,h=p);l!==q&&(r+=`\x1B[38;${`2;${(q&16711680)>>16};${(q&65280)>>8};${q&255}`}m`,l=q);m+=r+n}return m+"\u001b[0m"};this.set_size_text(80,25)}
|
|
249
249
|
;function dc(a){function b(g){f.enabled&&(f.send_char(g.which),g.preventDefault())}function c(g){var h=g.which;8===h?(f.send_char(127),g.preventDefault()):9===h&&(f.send_char(9),g.preventDefault())}function d(g){if(f.enabled){for(var h=g.clipboardData.getData("text/plain"),l=0;l<h.length;l++)f.send_char(h.charCodeAt(l));g.preventDefault()}}function e(g){g.target!==a&&a.blur()}var f=this;this.enabled=!0;this.text="";this.text_new_line=!1;this.last_update=0;this.destroy=function(){this.enabled=!1;a.removeEventListener("keypress",
|
|
250
250
|
b,!1);a.removeEventListener("keydown",c,!1);a.removeEventListener("paste",d,!1);window.removeEventListener("mousedown",e,!1)};this.init=function(){this.destroy();this.enabled=!0;a.style.display="block";a.addEventListener("keypress",b,!1);a.addEventListener("keydown",c,!1);a.addEventListener("paste",d,!1);window.addEventListener("mousedown",e,!1)};this.init();this.show_char=function(g){"\b"===g?(this.text=this.text.slice(0,-1),this.update()):"\r"!==g&&(this.text+=g,"\n"===g&&(this.text_new_line=!0),
|
|
@@ -336,7 +336,7 @@ h)},mmap_write32:function(g,h){c.mmap_write32(g,h)},mmap_write64:function(g,h,l)
|
|
|
336
336
|
g=>new Promise(h=>{let l="v86.wasm",m="v86-fallback.wasm";a.wasm_path?(l=a.wasm_path,m=l.replace("v86.wasm","v86-fallback.wasm")):"undefined"===typeof window&&"string"===typeof __dirname?(l=__dirname+"/"+l,m=__dirname+"/"+m):(l="build/"+l,m="build/"+m);pa(l,{done:async n=>{try{const {instance:p}=await WebAssembly.instantiate(n,g);this.wasm_source=n;h(p.exports)}catch(p){pa(m,{done:async q=>{const {instance:r}=await WebAssembly.instantiate(q,g);this.wasm_source=q;h(r.exports)}})}},progress:n=>{this.emulator_bus.send("download-progress",
|
|
337
337
|
{file_index:0,file_count:1,file_name:l,lengthComputable:n.lengthComputable,total:n.total,loaded:n.loaded})}})}));f({env:b}).then(g=>{d=g.memory;g.rust_init();g=this.v86=new F(this.emulator_bus,{exports:g,wasm_table:e});c=g.cpu;this.continue_init(g,a)});this.zstd_worker=null;this.zstd_worker_request_id=0}
|
|
338
338
|
O.prototype.continue_init=async function(a,b){function c(q,r){switch(q){case "hda":e.hda=r;break;case "hdb":e.hdb=r;break;case "cdrom":e.cdrom=r;break;case "fda":e.fda=r;break;case "fdb":e.fdb=r;break;case "multiboot":e.multiboot=r.buffer;break;case "bzimage":e.bzimage=r.buffer;break;case "initrd":e.initrd=r.buffer;break;case "bios":e.bios=r.buffer;break;case "vga_bios":e.vga_bios=r.buffer;break;case "initial_state":e.initial_state=r.buffer;break;case "fs9p_json":e.fs9p_json=r}}async function d(){if(e.fs9p&&
|
|
339
|
-
e.fs9p_json&&!e.initial_state&&(e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem)){const {bzimage_path:q,initrd_path:r}=this.get_bzimage_initrd_from_filesystem(e.fs9p),[x,
|
|
339
|
+
e.fs9p_json&&!e.initial_state&&(e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem)){const {bzimage_path:q,initrd_path:r}=this.get_bzimage_initrd_from_filesystem(e.fs9p),[x,D]=await Promise.all([e.fs9p.read_file(r),e.fs9p.read_file(q)]);c.call(this,"initrd",new A(x.buffer));c.call(this,"bzimage",new A(D.buffer))}this.serial_adapter&&this.serial_adapter.show&&this.serial_adapter.show();this.virtio_console_adapter&&this.virtio_console_adapter.show&&this.virtio_console_adapter.show();
|
|
340
340
|
this.v86.init(e);this.modem&&this.modem.initialize();e.initial_state&&(a.restore_state(e.initial_state),e.initial_state=void 0);b.autostart&&this.v86.run();this.emulator_bus.send("emulator-loaded")}this.bus.register("emulator-stopped",function(){this.cpu_is_running=!1;this.screen_adapter.pause()},this);this.bus.register("emulator-started",function(){this.cpu_is_running=!0;this.screen_adapter.continue()},this);var e={},f=b.boot_order?b.boot_order:b.fda?801:b.hda?786:291;if(b.modem)switch(e.modem=b.modem,
|
|
341
341
|
b.modem.uart){case 1:b.uart1=!0;break;case 2:b.uart2=!0;break;case 3:b.uart3=!0}e.acpi=b.acpi;e.disable_jit=b.disable_jit;e.load_devices=!0;e.memory_size=b.memory_size||67108864;e.vga_memory_size=b.vga_memory_size||8388608;e.boot_order=f;e.fastboot=b.fastboot||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=b.uart3;e.cmdline=b.cmdline;e.preserve_mac_from_state_image=b.preserve_mac_from_state_image;e.mac_address_translation=b.mac_address_translation;e.cpuid_level=b.cpuid_level;
|
|
342
342
|
e.virtio_balloon=b.virtio_balloon;e.virtio_console=!!b.virtio_console;if(f=b.network_relay_url||b.net_device&&b.net_device.relay_url)"fetch"===f?this.network_adapter=new Wb(this.bus,b.net_device):"inbrowser"===f?this.network_adapter=new pc(this.bus,b.net_device):f.startsWith("wisp://")||f.startsWith("wisps://")?this.network_adapter=new Yb(f,this.bus,b.net_device):this.network_adapter=new pb(f,this.bus);e.net_device=b.net_device||{type:"ne2k"};f=b.screen||{};b.screen_container&&(f.container=b.screen_container);
|
|
@@ -430,8 +430,8 @@ Kc.prototype.SendWindowSize=function(a,b,c){c=c||this.rows;b=b||this.cols;const
|
|
|
430
430
|
Kc.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.rows;a[2]=this.cols;a[3]=this.ports;return a};Kc.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.rows=a[1];this.cols=a[2];this.ports=a[3]};Kc.prototype.reset=function(){this.virtio.reset()};Kc.prototype.SendEvent=function(a,b,c){const d=this.virtio.queues[2].pop_request(),e=new Uint8Array(8);J(["w","h","h"],[a,b,c],e,0);this.Send(2,d,e)};
|
|
431
431
|
Kc.prototype.Send=function(a,b,c){b.set_next_blob(c);this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};Kc.prototype.Ack=function(a,b){b.set_next_blob(new Uint8Array(0));this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};function Mc(a,b){this.cpu=a;this.bus=b;this.reset();this.bus.register("keyboard-code",function(c){this.kbd_send_code(c)},this);this.bus.register("mouse-click",function(c){this.mouse_send_click(c[0],c[1],c[2])},this);this.bus.register("mouse-delta",function(c){this.mouse_send_delta(c[0],c[1])},this);this.bus.register("mouse-wheel",function(c){this.wheel_movement-=c[0];this.wheel_movement-=2*c[1];this.wheel_movement=Math.min(7,Math.max(-8,this.wheel_movement));this.send_mouse_packet(0,0)},this);a.io.register_read(96,
|
|
432
432
|
this,this.port60_read);a.io.register_read(100,this,this.port64_read);a.io.register_write(96,this,this.port60_write);a.io.register_write(100,this,this.port64_write)}
|
|
433
|
-
Mc.prototype.reset=function(){this.use_mouse=this.enable_mouse_stream=!1;this.have_mouse=!0;this.mouse_clicks=this.mouse_delta_y=this.mouse_delta_x=0;this.have_keyboard=!0;this.next_read_resolution=this.next_read_rate=this.next_handle_scan_code_set=this.next_read_led=this.next_read_sample=this.next_is_mouse_command=this.enable_keyboard_stream=!1;this.kbd_buffer=new
|
|
434
|
-
0;this.resolution=4;this.scaling2=!1;this.last_mouse_packet=-1;this.mouse_buffer=new
|
|
433
|
+
Mc.prototype.reset=function(){this.use_mouse=this.enable_mouse_stream=!1;this.have_mouse=!0;this.mouse_clicks=this.mouse_delta_y=this.mouse_delta_x=0;this.have_keyboard=!0;this.next_read_resolution=this.next_read_rate=this.next_handle_scan_code_set=this.next_read_led=this.next_read_sample=this.next_is_mouse_command=this.enable_keyboard_stream=!1;this.kbd_buffer=new ma(1024);this.last_port60_byte=0;this.sample_rate=100;this.mouse_id=this.mouse_detect_state=0;this.mouse_reset_workaround=!1;this.wheel_movement=
|
|
434
|
+
0;this.resolution=4;this.scaling2=!1;this.last_mouse_packet=-1;this.mouse_buffer=new ma(1024);this.next_byte_is_aux=this.next_byte_is_ready=!1;this.command_register=5;this.controller_output_port=0;this.read_controller_output_port=this.read_command_register=this.read_output_register=!1};
|
|
435
435
|
Mc.prototype.get_state=function(){var a=[];a[0]=this.enable_mouse_stream;a[1]=this.use_mouse;a[2]=this.have_mouse;a[3]=this.mouse_delta_x;a[4]=this.mouse_delta_y;a[5]=this.mouse_clicks;a[6]=this.have_keyboard;a[7]=this.enable_keyboard_stream;a[8]=this.next_is_mouse_command;a[9]=this.next_read_sample;a[10]=this.next_read_led;a[11]=this.next_handle_scan_code_set;a[12]=this.next_read_rate;a[13]=this.next_read_resolution;a[15]=this.last_port60_byte;a[16]=this.sample_rate;a[17]=this.resolution;a[18]=this.scaling2;
|
|
436
436
|
a[20]=this.command_register;a[21]=this.read_output_register;a[22]=this.read_command_register;a[23]=this.controller_output_port;a[24]=this.read_controller_output_port;a[25]=this.mouse_id;a[26]=this.mouse_detect_state;a[27]=this.mouse_reset_workaround;return a};
|
|
437
437
|
Mc.prototype.set_state=function(a){this.enable_mouse_stream=a[0];this.use_mouse=a[1];this.have_mouse=a[2];this.mouse_delta_x=a[3];this.mouse_delta_y=a[4];this.mouse_clicks=a[5];this.have_keyboard=a[6];this.enable_keyboard_stream=a[7];this.next_is_mouse_command=a[8];this.next_read_sample=a[9];this.next_read_led=a[10];this.next_handle_scan_code_set=a[11];this.next_read_rate=a[12];this.next_read_resolution=a[13];this.last_port60_byte=a[15];this.sample_rate=a[16];this.resolution=a[17];this.scaling2=a[18];
|
|
@@ -588,8 +588,8 @@ a[56]=this.color_plane_enable;a[57]=this.horizontal_panning;a[58]=this.color_sel
|
|
|
588
588
|
Y.prototype.set_state=function(a){this.vga_memory_size=a[0];this.cursor_address=a[1];this.cursor_scanline_start=a[2];this.cursor_scanline_end=a[3];this.max_cols=a[4];this.max_rows=a[5];a[6]&&this.vga_memory.set(a[6]);this.dac_state=a[7];this.start_address=a[8];this.graphical_mode=a[9];this.vga256_palette=a[10];this.latch_dword=a[11];this.color_compare=a[12];this.color_dont_care=a[13];this.miscellaneous_graphics_register=a[14];this.svga_width=a[15];this.svga_height=a[16];this.crtc_mode=a[17];this.svga_enabled=
|
|
589
589
|
a[18];this.svga_bpp=a[19];this.svga_bank_offset=a[20];this.svga_offset=a[21];this.index_crtc=a[22];this.dac_color_index_write=a[23];this.dac_color_index_read=a[24];this.dac_map=a[25];this.sequencer_index=a[26];this.plane_write_bm=a[27];this.sequencer_memory_mode=a[28];this.graphics_index=a[29];this.plane_read=a[30];this.planar_mode=a[31];this.planar_rotate_reg=a[32];this.planar_bitmap=a[33];this.max_scan_line=a[34];this.miscellaneous_output_register=a[35];this.port_3DA_value=a[36];this.dispi_index=
|
|
590
590
|
a[37];this.dispi_enable_value=a[38];this.svga_memory.set(a[39]);this.attribute_controller_index=a[41];this.offset_register=a[42];this.planar_setreset=a[43];this.planar_setreset_enable=a[44];this.start_address_latched=a[45];this.crtc.set(a[46]);this.horizontal_display_enable_end=a[47];this.horizontal_blank_start=a[48];this.vertical_display_enable_end=a[49];this.vertical_blank_start=a[50];this.underline_location_register=a[51];this.preset_row_scan=a[52];this.offset_register=a[53];this.palette_source=
|
|
591
|
-
a[54];this.attribute_mode=a[55];this.color_plane_enable=a[56];this.horizontal_panning=a[57];this.color_select=a[58];this.clocking_mode=a[59];this.line_compare=a[60];a[61]&&this.pixel_buffer.set(a[61]);this.dac_mask=void 0===a[62]?255:a[62];this.character_map_select=void 0===a[63]?0:a[63];this.font_page_ab_enabled=void 0===a[64]?0:a[64];this.screen.set_mode(this.graphical_mode);this.
|
|
592
|
-
this.svga_width,this.svga_height,this.svga_bpp),this.update_layers()):(this.update_vga_size(),this.update_layers(),this.complete_replot())
|
|
591
|
+
a[54];this.attribute_mode=a[55];this.color_plane_enable=a[56];this.horizontal_panning=a[57];this.color_select=a[58];this.clocking_mode=a[59];this.line_compare=a[60];a[61]&&this.pixel_buffer.set(a[61]);this.dac_mask=void 0===a[62]?255:a[62];this.character_map_select=void 0===a[63]?0:a[63];this.font_page_ab_enabled=void 0===a[64]?0:a[64];this.screen.set_mode(this.graphical_mode);this.screen_height=this.screen_width=0;this.graphical_mode?this.svga_enabled?(this.set_size_graphical(this.svga_width,this.svga_height,
|
|
592
|
+
this.svga_width,this.svga_height,this.svga_bpp),this.update_layers()):(this.update_vga_size(),this.update_layers(),this.complete_replot()):(this.screen.clear_text_state(),this.set_font_bitmap(!0),this.set_size_text(this.max_cols,this.max_rows),this.set_font_page(),this.update_cursor_scanline(),this.update_cursor());this.complete_redraw()};
|
|
593
593
|
Y.prototype.vga_memory_read=function(a){if(this.svga_enabled)return this.cpu.read8((a-655360|this.svga_bank_offset)+3758096384|0);var b=this.miscellaneous_graphics_register>>2&3;a-=dd[b];if(0>a||a>=ed[b])return y(a>>>0),0;this.latch_dword=this.plane0[a];this.latch_dword|=this.plane1[a]<<8;this.latch_dword|=this.plane2[a]<<16;this.latch_dword|=this.plane3[a]<<24;if(this.planar_mode&8)return b=255,this.color_dont_care&1&&(b&=this.plane0[a]^~(this.color_compare&1?255:0)),this.color_dont_care&2&&(b&=
|
|
594
594
|
this.plane1[a]^~(this.color_compare&2?255:0)),this.color_dont_care&4&&(b&=this.plane2[a]^~(this.color_compare&4?255:0)),this.color_dont_care&8&&(b&=this.plane3[a]^~(this.color_compare&8?255:0)),b;b=this.plane_read;this.graphical_mode?this.sequencer_memory_mode&8?(b=a&3,a&=-4):this.planar_mode&16&&(b=a&1,a&=-2):b&=3;return this.vga_memory[b<<16|a]};
|
|
595
595
|
Y.prototype.vga_memory_write=function(a,b){if(this.svga_enabled)this.cpu.write8((a-655360|this.svga_bank_offset)+3758096384|0,b);else{var c=this.miscellaneous_graphics_register>>2&3;a-=dd[c];0>a||a>=ed[c]?(y(a>>>0),y(b)):this.graphical_mode?this.vga_memory_write_graphical(a,b):this.plane_write_bm&3?this.vga_memory_write_text_mode(a,b):this.plane_write_bm&4&&(this.plane2[a]=b)}};
|
|
@@ -656,7 +656,7 @@ d.pop_request();const f=new Uint8Array(e.length_readable);e.get_next_blob(f);thi
|
|
|
656
656
|
this.virtio.queues[c];for(;d.has_request();){const f=d.pop_request();if(0<f.length_readable){var e=new Uint8Array(f.length_readable);f.get_next_blob(e);[e]=L(["w"],e,{offset:0});0===e&&(this.free_cb&&this.free_cb(this.zeroed),1<this.fp_cmd&&(this.fp_cmd=1),this.virtio.notify_config_changes())}if(0<f.length_writable)for(new Uint8Array(0),e=0;e<f.write_buffers.length;++e){let g=f.write_buffers[e];this.zeroed+=g.len;this.virtio.cpu.zero_memory(g.addr_low,g.len)}this.virtio.queues[c].push_reply(f)}this.virtio.queues[c].flush_replies()}]},
|
|
657
657
|
isr_status:{initial_port:55040},device_specific:{initial_port:54784,struct:[{bytes:4,name:"num_pages",read:()=>this.num_pages,write:()=>{}},{bytes:4,name:"actual",read:()=>this.actual,write:()=>{}},{bytes:4,name:"free_page_hint_cmd_id",read:()=>this.fp_cmd,write:()=>{}}]}})}gd.prototype.Inflate=function(a){this.num_pages+=a;this.virtio.notify_config_changes()};gd.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};
|
|
658
658
|
gd.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=a;this.zeroed=0;this.virtio.notify_config_changes()};gd.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};gd.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};gd.prototype.GetStats=function(a){this.stats_cb=a;for(a=this.virtio.queues[2];a.has_request();){const b=a.pop_request();this.virtio.queues[2].push_reply(b)}this.virtio.queues[2].flush_replies()};
|
|
659
|
-
gd.prototype.Reset=function(){};function hd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);var g=new Uint32Array(b),h=e[497]||4,l=f[255];if(43605!==l)y(l);else if(l=f[257]|f[258]<<16,1400005704!==l)y(l);else{l=f[259];var m=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=l?g[142]:255,
|
|
659
|
+
gd.prototype.Reset=function(){};function hd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);var g=new Uint32Array(b),h=e[497]||4,l=f[255];if(43605!==l)y(l);else if(l=f[257]|f[258]<<16,1400005704!==l)y(l);else{l=f[259];var m=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=l?g[142]:255,D=g[146],z=g[147],u=g[150],K=g[151],v=g[152];y(l);y(m);y(n);y(g[133]);y(p);y(q);y(r);y(x);y(D);y(z);y(K);y(u);y(v);e[528]=255;e[529]=m&-97|128;f[274]=56832;f[253]=65535;y(56832);d+="\x00";y(581632);g[138]=581632;for(e=0;e<d.length;e++)a[581632+
|
|
660
660
|
e]=d.charCodeAt(e);h=512*(h+1);y(h);d=new Uint8Array(b,0,h);b=new Uint8Array(b,h);e=h=0;c&&(h=67108864,e=c.byteLength,a.set(new Uint8Array(c),h));g[134]=h;g[135]=e;a.set(d,524288);a.set(b,1048576);a=new Uint8Array(512);(new Uint16Array(a.buffer))[0]=43605;a[2]=1;c=3;a[c++]=250;a[c++]=184;a[c++]=32768;a[c++]=128;a[c++]=142;a[c++]=192;a[c++]=142;a[c++]=216;a[c++]=142;a[c++]=224;a[c++]=142;a[c++]=232;a[c++]=142;a[c++]=208;a[c++]=188;a[c++]=57344;a[c++]=224;a[c++]=234;a[c++]=0;a[c++]=0;a[c++]=32800;a[c++]=
|
|
661
661
|
128;g=a[c]=0;for(b=0;b<a.length;b++)g+=a[b];a[c]=-g;return{name:"genroms/kernel.bin",data:a}}};function R(a,b,c){this.stop_idling=c;this.wm=b;this.wasm_patch();this.create_jit_imports();this.wasm_memory=b=this.wm.exports.memory;this.memory_size=k(Uint32Array,b,812,1);this.mem8=new Uint8Array(0);this.mem32s=new Int32Array(this.mem8.buffer);this.segment_is_null=k(Uint8Array,b,724,8);this.segment_offsets=k(Int32Array,b,736,8);this.segment_limits=k(Uint32Array,b,768,8);this.segment_access_bytes=k(Uint8Array,b,512,8);this.protected_mode=k(Int32Array,b,800,1);this.idtr_size=k(Int32Array,b,564,1);
|
|
662
662
|
this.idtr_offset=k(Int32Array,b,568,1);this.gdtr_size=k(Int32Array,b,572,1);this.gdtr_offset=k(Int32Array,b,576,1);this.tss_size_32=k(Int32Array,b,1128,1);this.page_fault=k(Uint32Array,b,540,8);this.cr=k(Int32Array,b,580,8);this.cpl=k(Uint8Array,b,612,1);this.is_32=k(Int32Array,b,804,1);this.stack_size_32=k(Int32Array,b,808,1);this.in_hlt=k(Uint8Array,b,616,1);this.last_virt_eip=k(Int32Array,b,620,1);this.eip_phys=k(Int32Array,b,624,1);this.sysenter_cs=k(Int32Array,b,636,1);this.sysenter_esp=k(Int32Array,
|
|
@@ -684,11 +684,11 @@ a[37];this.previous_ip[0]=a[38];this.reg32.set(a[39]);this.sreg.set(a[40]);this.
|
|
|
684
684
|
this.devices.uart0&&this.devices.uart0.set_state(a[54]);this.devices.fdc&&this.devices.fdc.set_state(a[55]);if(a[56]||a[57]){var b=[[void 0,void 0],[void 0,void 0]];b[0][0]=a[56]?{is_cdrom:!0,buffer:this.devices.cdrom.buffer}:{is_cdrom:!1,buffer:this.devices.ide.primary.master.buffer};this.devices.ide=new ad(this,this.devices.ide.bus,b);this.devices.cdrom=a[56]?this.devices.ide.primary.master:void 0;this.devices.ide.primary.set_state(a[56]||a[57])}else a[85]&&this.devices.ide.set_state(a[85]);this.devices.pci&&
|
|
685
685
|
this.devices.pci.set_state(a[48]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);this.set_state_pic(a[60]);this.devices.sb16&&this.devices.sb16.set_state(a[61]);this.devices.uart1&&this.devices.uart1.set_state(a[79]);this.devices.uart2&&this.devices.uart2.set_state(a[80]);this.devices.uart3&&this.devices.uart3.set_state(a[81]);this.devices.virtio_console&&this.devices.virtio_console.set_state(a[82]);this.devices.virtio_net&&this.devices.virtio_net.set_state(a[83]);
|
|
686
686
|
this.devices.virtio_balloon&&this.devices.virtio_balloon.set_state(a[84]);this.devices.vmware&&a[89]&&this.devices.vmware.set_state(a[89]);this.fw_value=a[62];a[63]&&this.set_state_ioapic(a[63]);this.tss_size_32[0]=a[64];this.reg_xmm32s.set(a[66]);this.fpu_st.set(a[67]);this.fpu_stack_empty[0]=a[68];this.fpu_stack_ptr[0]=a[69];this.fpu_control_word[0]=a[70];this.fpu_ip[0]=a[71];this.fpu_ip_selector[0]=a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=a[75];void 0!==a[86]&&
|
|
687
|
-
(this.last_result=a[86]);void 0!==a[87]&&(this.fpu_status_word=a[87]);void 0!==a[88]&&(this.mxcsr=a[88]);b=new
|
|
687
|
+
(this.last_result=a[86]);void 0!==a[87]&&(this.fpu_status_word=a[87]);void 0!==a[88]&&(this.mxcsr=a[88]);b=new oa(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();this.jit_clear_cache()};
|
|
688
688
|
R.prototype.set_state_pic=function(a){const b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),c=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];const d=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]};
|
|
689
689
|
R.prototype.set_state_apic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_apic_addr(),46);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[8]=a[6];b[9]=a[7];b[10]=a[8];b[11]=a[9];b[12]=a[10];b[13]=a[11];b[14]=a[12];b[15]=a[13];b.set(a[15],16);b.set(a[15],24);b.set(a[16],32);b[40]=a[17];b[41]=a[18];b[42]=a[19];b[43]=a[20];b[44]=a[21];b[45]=a[22]||65536}else(new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)).set(a)};
|
|
690
690
|
R.prototype.set_state_ioapic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_ioapic_addr(),52);b.set(a[0],0);b.set(a[1],24);b[48]=a[2];b[49]=a[3];b[50]=a[4];b[51]=a[5]}else(new Uint8Array(this.wasm_memory.buffer,this.get_ioapic_addr(),208)).set(a)};
|
|
691
|
-
R.prototype.pack_memory=function(){var a=this.mem8.length>>12,b=[];for(var c=0;c<a;c++)this.is_memory_zeroed(c<<12,4096)||b.push(c);a=new
|
|
691
|
+
R.prototype.pack_memory=function(){var a=this.mem8.length>>12,b=[];for(var c=0;c<a;c++)this.is_memory_zeroed(c<<12,4096)||b.push(c);a=new oa(a);c=new Uint8Array(b.length<<12);for(const [d,e]of b.entries())a.set(e,1),b=e<<12,b=this.mem8.subarray(b,b+4096),c.set(b,d<<12);return{bitmap:a,packed_memory:c}};
|
|
692
692
|
R.prototype.unpack_memory=function(a,b){this.zero_memory(0,this.memory_size[0]);const c=this.memory_size[0]>>12;let d=0;for(let f=0;f<c;f++)if(a.get(f)){var e=d<<12;e=b.subarray(e,e+4096);this.mem8.set(e,f<<12);d++}};
|
|
693
693
|
R.prototype.reboot_internal=function(){this.reset_cpu();this.fw_value=[];this.devices.virtio_9p&&this.devices.virtio_9p.reset();this.devices.virtio_console&&this.devices.virtio_console.reset();this.devices.virtio_net&&this.devices.virtio_net.reset();this.devices.ps2&&this.devices.ps2.reset();this.load_bios()};R.prototype.reset_memory=function(){this.mem8.fill(0)};
|
|
694
694
|
R.prototype.create_memory=function(a,b){a<b?a=b:0>(a|0)&&(a=Math.pow(2,31)-131072);a=(a-1|131071)+1|0;console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;b=this.allocate_memory(a);this.mem8=k(Uint8Array,this.wasm_memory,b,a);this.mem32s=k(Uint32Array,this.wasm_memory,b,a>>2)};
|
|
@@ -700,10 +700,10 @@ b),this.devices.vmware=new Nc(this,b),this.devices.uart0=new Fc(this,1016,b),a.u
|
|
|
700
700
|
b),"ne2k"===a.net_device.type?this.devices.net=new Jc(this,b,a.preserve_mac_from_state_image,a.mac_address_translation):"virtio"===a.net_device.type&&(this.devices.virtio_net=new cd(this,b,a.preserve_mac_from_state_image,a.net_device.mtu)),a.fs9p?this.devices.virtio_9p=new id(a.fs9p,this,b):a.handle9p?this.devices.virtio_9p=new jd(a.handle9p,this):a.proxy9p&&(this.devices.virtio_9p=new kd(a.proxy9p,this)),a.virtio_console&&(this.devices.virtio_console=new Kc(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=
|
|
701
701
|
new gd(this,b)),this.devices.sb16=new C(this,b));a.multiboot&&(a=this.load_multiboot_option_rom(a.multiboot,a.initrd,a.cmdline))&&(this.bios.main?this.option_roms.push(a):this.reg32[0]=this.io.port_read32(244));this.debug_init()};R.prototype.load_multiboot=function(a){this.load_multiboot_option_rom(a,void 0,"")&&(this.reg32[0]=this.io.port_read32(244))};
|
|
702
702
|
R.prototype.load_multiboot_option_rom=function(a,b,c){if(8192>a.byteLength){var d=new Int32Array(2048);(new Uint8Array(d.buffer)).set(new Uint8Array(a))}else d=new Int32Array(a,0,2048);for(var e=0;8192>e;e+=4){if(464367618===d[e>>2]){var f=d[e+4>>2];if(464367618+f+d[e+8>>2]|0)continue}else continue;va("Multiboot magic found, flags: "+y(f>>>0,8),2);var g=this;this.io.register_read(244,this,function(){return 0},function(){return 0},function(){var n,p=31860;let q=0;if(c){q|=4;g.write32(31760,p);c+="\x00";
|
|
703
|
-
var r=(new TextEncoder).encode(c);g.write_blob(r,p);p+=r.length}if(f&2){q|=64;r=0;g.write32(31788,0);g.write32(31792,p);var x=0;var
|
|
704
|
-
y(z,8);y(x,8);y(
|
|
705
|
-
u.ehsize,"Bad header size");console.assert(32===u.phentsize,"Bad program header size");console.assert(40===u.shentsize,"Bad section header size");[r]=Wc(new DataView(
|
|
706
|
-
|
|
703
|
+
var r=(new TextEncoder).encode(c);g.write_blob(r,p);p+=r.length}if(f&2){q|=64;r=0;g.write32(31788,0);g.write32(31792,p);var x=0;var D=!1;for(n=0;4294967296>n;n+=131072)D&&void 0!==g.memory_map_read8[n>>>17]?(g.write32(p,20),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,n-x),g.write32(p+16,0),g.write32(p+20,1),p+=24,r+=24,D=!1):D||void 0!==g.memory_map_read8[n>>>17]||(x=n,D=!0);g.write32(31788,r)}x=r=0;if(f&65536){n=d[e+12>>2];r=d[e+16>>2];var z=d[e+20>>2];x=d[e+24>>2];D=d[e+28>>2];y(n,8);y(r,8);
|
|
704
|
+
y(z,8);y(x,8);y(D,8);n=new Uint8Array(a,e-(n-r),0===z?void 0:z-r);g.write_blob(n,r);r=D|0;x=Math.max(z,x)}else if(1179403647===d[0]){D=new DataView(a);const [u,K]=Vc(D,Sc);console.assert(52===K);console.assert(1179403647===u.magic,"Bad magic");console.assert(1===u.class,"Unimplemented: 64 bit elf");console.assert(1===u.data,"Unimplemented: big endian");console.assert(1===u.version0,"Bad version0");console.assert(2===u.type,"Unimplemented type");console.assert(1===u.version1,"Bad version1");console.assert(52===
|
|
705
|
+
u.ehsize,"Bad header size");console.assert(32===u.phentsize,"Bad program header size");console.assert(40===u.shentsize,"Bad section header size");[r]=Wc(new DataView(D.buffer,D.byteOffset+u.phoff,u.phentsize*u.phnum),Tc,u.phnum);Wc(new DataView(D.buffer,D.byteOffset+u.shoff,u.shentsize*u.shnum),Uc,u.shnum);D=u;n=r;r=D.entry;for(z of n)0!==z.type&&(1===z.type?z.paddr+z.memsz<g.memory_size[0]?(z.filesz&&(n=new Uint8Array(a,z.offset,z.filesz),g.write_blob(n,z.paddr)),x=Math.max(x,z.paddr+z.memsz),r===
|
|
706
|
+
D.entry&&z.vaddr<=r&&z.vaddr+z.memsz>r&&(r=r-z.vaddr+z.paddr)):y(z.paddr):2===z.type||3===z.type||4===z.type||6===z.type||7===z.type||1685382480===z.type||1685382481===z.type||1685382482===z.type||1685382483===z.type||y(z.type))}b&&(q|=8,g.write32(31764,1),g.write32(31768,p),z=x,0!==(z&4095)&&(z=(z&-4096)+4096),x=z+b.byteLength,g.write32(p,z),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,0),g.write_blob(new Uint8Array(b),z));g.write32(31744,q);g.reg32[3]=31744;g.cr[0]=1;g.protected_mode[0]=1;g.flags[0]=
|
|
707
707
|
2;g.is_32[0]=1;g.stack_size_32[0]=1;for(p=0;6>p;p++)g.segment_is_null[p]=0,g.segment_offsets[p]=0,g.segment_limits[p]=4294967295,g.sreg[p]=45058;g.instruction_pointer[0]=g.get_seg_cs()+r|0;g.update_state_flags();g.dump_state();g.dump_regs_short();return 732803074});this.io.register_write_consecutive(244,this,function(n){console.log("Test exited with code "+y(n,2));throw"HALT";},function(){},function(){},function(){});for(let n=0;15>=n;n++){function p(q){y(n);y(q,2);q?this.device_raise_irq(n):this.device_lower_irq(n)}
|
|
708
708
|
this.io.register_write(8192+n,this,p,p,p)}const l=new Uint8Array(512);(new Uint16Array(l.buffer))[0]=43605;l[2]=1;var h=3;l[h++]=102;l[h++]=229;l[h++]=244;let m=l[h]=0;for(let n=0;n<l.length;n++)m+=l[n];l[h]=-m;return{name:"genroms/multiboot.bin",data:l}}};
|
|
709
709
|
R.prototype.fill_cmos=function(a,b){var c=b.boot_order||291;a.cmos_write(56,1|c>>4&240);a.cmos_write(61,c&255);a.cmos_write(21,128);a.cmos_write(22,2);c=0;1048576<=this.memory_size[0]&&(c=this.memory_size[0]-1048576>>10,c=Math.min(c,65535));a.cmos_write(23,c&255);a.cmos_write(24,c>>8&255);a.cmos_write(48,c&255);a.cmos_write(49,c>>8&255);c=0;16777216<=this.memory_size[0]&&(c=this.memory_size[0]-16777216>>16,c=Math.min(c,65535));a.cmos_write(52,c&255);a.cmos_write(53,c>>8&255);a.cmos_write(91,0);a.cmos_write(92,
|