v86 0.5.455 → 0.5.456
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 +5 -2
- package/build/libv86-debug.mjs +5 -2
- package/build/libv86.js +30 -30
- package/build/libv86.mjs +245 -244
- package/package.json +1 -1
package/build/libv86-debug.js
CHANGED
|
@@ -1690,9 +1690,12 @@ function $any_first_digit$$module$src$sb16$$($base$jscomp$3$$) {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
return $commands$jscomp$1$$;
|
|
1692
1692
|
}
|
|
1693
|
-
$register_dsp_command$$module$src$sb16$$([
|
|
1694
|
-
|
|
1693
|
+
$register_dsp_command$$module$src$sb16$$([4], 1);
|
|
1694
|
+
$register_dsp_command$$module$src$sb16$$([5], 2);
|
|
1695
|
+
$register_dsp_command$$module$src$sb16$$([8], 1, function() {
|
|
1696
|
+
3 === this.write_buffer.shift() && (this.read_buffer.clear(), this.read_buffer.push(255));
|
|
1695
1697
|
});
|
|
1698
|
+
$register_dsp_command$$module$src$sb16$$([14], 2);
|
|
1696
1699
|
$register_dsp_command$$module$src$sb16$$([15], 1, function() {
|
|
1697
1700
|
this.read_buffer.clear();
|
|
1698
1701
|
this.read_buffer.push(this.asp_registers[this.write_buffer.shift()]);
|
package/build/libv86-debug.mjs
CHANGED
|
@@ -1689,9 +1689,12 @@ function $any_first_digit$$module$src$sb16$$($base$jscomp$3$$) {
|
|
|
1689
1689
|
}
|
|
1690
1690
|
return $commands$jscomp$1$$;
|
|
1691
1691
|
}
|
|
1692
|
-
$register_dsp_command$$module$src$sb16$$([
|
|
1693
|
-
|
|
1692
|
+
$register_dsp_command$$module$src$sb16$$([4], 1);
|
|
1693
|
+
$register_dsp_command$$module$src$sb16$$([5], 2);
|
|
1694
|
+
$register_dsp_command$$module$src$sb16$$([8], 1, function() {
|
|
1695
|
+
3 === this.write_buffer.shift() && (this.read_buffer.clear(), this.read_buffer.push(255));
|
|
1694
1696
|
});
|
|
1697
|
+
$register_dsp_command$$module$src$sb16$$([14], 2);
|
|
1695
1698
|
$register_dsp_command$$module$src$sb16$$([15], 1, function() {
|
|
1696
1699
|
this.read_buffer.clear();
|
|
1697
1700
|
this.read_buffer.push(this.asp_registers[this.write_buffer.shift()]);
|
package/build/libv86.js
CHANGED
|
@@ -14,16 +14,16 @@ const qa={cp437:" \u263a\u263b\u2665\u2666\u2663\u2660\u2022\u25d8\u25cb\u25d9\u
|
|
|
14
14
|
qa.cp858=qa.cp437.slice(0,128)+qa.cp858;qa.ascii=qa.cp437.split("").map((a,b)=>31<b&&128>b?a:".").join("");function ra(a){return a&&qa[a]?qa[a]:qa.cp437};function sa(){}function ua(){};function va(a,b){function c(v){v=v.toString(16);return"#"+"0".repeat(6-v.length)+v}function d(v){var u=256*ja,J=8*U,L=Va?Va.canvas:null;L&&L.width===u&&L.height===J||(L?(L.width=u,L.height=J):(L=new OffscreenCanvas(u,J),Va=L.getContext("2d")),Qb=Va.createImageData(u,J));const V=Qb.data;let R=0,N;J=Rb?function(ba){N=N||ba;V[R+3]=ba;V[R+7]=ba;R+=8}:function(ba){N=N||ba;V[R+3]=ba;R+=4};L=32-U;const xa=u*(U-1)*4;u=4*(ja-u*U);const ya=1020*ja;for(let ba=0,za=0;2048>ba;++ba,za+=L,R+=u){const Ia=ba%256;
|
|
15
15
|
ba&&!Ia&&(R+=xa);N=!1;for(let Pa=0;Pa<U;++Pa,++za,R+=ya){const Qa=v[za];for(let ta=128;0<ta;ta>>=1)J(Qa&ta?255:0);Sb&&J(Tb&&192<=Ia&&223>=Ia&&Qa&1?255:0)}ic[ba]=N?1:0}Va.putImageData(Qb,0,0)}function e(v,u,J,L){if(u&&J){v.style.width="";v.style.height="";L&&(v.style.transform="");var V=v.getBoundingClientRect();L?v.style.transform=(1===u?"":" scaleX("+u+")")+(1===J?"":" scaleY("+J+")"):(0===u%1&&0===J%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"]=""),L=window.devicePixelRatio||1,0!==L%1&&(u/=L,J/=L));1!==u&&(v.style.width=V.width*u+"px");1!==J&&(v.style.height=V.height*J+"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 m=
|
|
17
|
-
f.getElementsByTagName("div")[0];m||(m=document.createElement("div"),f.appendChild(m));const l=document.createElement("div");var n,p,q=void 0!==a.scale?a.scale:1,r=void 0!==a.scale?a.scale:1,x=1,
|
|
17
|
+
f.getElementsByTagName("div")[0];m||(m=document.createElement("div"),f.appendChild(m));const l=document.createElement("div");var n,p,q=void 0!==a.scale?a.scale:1,r=void 0!==a.scale?a.scale:1,x=1,F,B,C,w,t,I,P,Va,Qb,ic=new Int8Array(2048),U,ja,Sb,Rb,Tb,vb=0,wb=0,xb,jc=0,yb,Ub,zb,Vb=ra(a.encoding),Ab=0,Wb=!1;this.init=function(){l.classList.add("cursor");l.style.position="absolute";l.style.backgroundColor="#ccc";l.style.width="7px";l.style.display="inline-block";this.set_mode(!1);this.set_size_text(80,
|
|
18
18
|
25);2===B&&this.set_size_graphical(720,400,720,400);this.set_scale(q,r);this.timer()};this.make_screenshot=function(){const v=new Image;if(1===B||2===B)v.src=g.toDataURL("image/png");else{const u=[9,16],J=document.createElement("canvas");J.width=w*u[0];J.height=t*u[1];const L=J.getContext("2d");L.imageSmoothingEnabled=!1;L.font=window.getComputedStyle(m).font;L.textBaseline="top";for(let V=0;V<t;V++)for(let R=0;R<w;R++){const N=4*(V*w+R),xa=C[N+0],ya=C[N+3];L.fillStyle=c(C[N+2]);L.fillRect(R*u[0],
|
|
19
|
-
V*u[1],u[0],u[1]);L.fillStyle=c(ya);L.fillText(Vb[xa],R*u[0],V*u[1])}"none"!==l.style.display&&n<t&&p<w&&(L.fillStyle=l.style.backgroundColor,L.fillRect(p*u[0],n*u[1]+parseInt(l.style.marginTop,10),parseInt(l.style.width,10),parseInt(l.style.height,10)));v.src=J.toDataURL("image/png")}return v};this.put_char=function(v,u,J,L,V,R){u=4*(v*w+u);C[u+0]=J;C[u+1]=L;C[u+2]=V;C[u+3]=R;
|
|
20
|
-
B?this.update_text():1===B?this.update_graphical():this.update_graphical_text());this.timer()};this.update_text=function(){for(var v=0;v<t;v++)
|
|
21
|
-
ja,xa=U;if(0===N)var L=0;else{v=0;for(let ya=0,ba=0,za=0;ya<t;++ya,ba+=U){if(!
|
|
22
|
-
0,N-Ia,U);P.globalCompositeOperation="destination-in";P.drawImage(J,0,xa,N,U,0,0,N,U);P.globalCompositeOperation="source-over";I.fillStyle=c(Pa);I.fillRect(Qa,ba,N-Qa,U);I.drawImage(J,0,0,N,U,0,ba,N,U)}v&&(xb&&zb&&
|
|
23
|
-
this.clear_text_state=function(){wb=vb=t=w=U=ja=null};this.set_mode=function(v){B=v?1:a.use_graphical_text?2:0;0===B?(m.style.display="block",g.style.display="none"):(m.style.display="none",g.style.display="block",2===B&&
|
|
24
|
-
|
|
25
|
-
t)if(
|
|
26
|
-
2:1;e(g,q*x,r*x,!1)};this.set_scale=function(v,u){q=v;r=u;e(m,q,r,!0);e(g,q*x,r*x,!1)};this.update_cursor_scanline=function(v,u,J){if(v!==yb||u!==Ub||J!==zb)0===B?J?(l.style.display="inline",l.style.height=u-v+"px",l.style.marginTop=v+"px"):l.style.display="none":2===B&&n<t&&(
|
|
19
|
+
V*u[1],u[0],u[1]);L.fillStyle=c(ya);L.fillText(Vb[xa],R*u[0],V*u[1])}"none"!==l.style.display&&n<t&&p<w&&(L.fillStyle=l.style.backgroundColor,L.fillRect(p*u[0],n*u[1]+parseInt(l.style.marginTop,10),parseInt(l.style.width,10),parseInt(l.style.height,10)));v.src=J.toDataURL("image/png")}return v};this.put_char=function(v,u,J,L,V,R){u=4*(v*w+u);C[u+0]=J;C[u+1]=L;C[u+2]=V;C[u+3]=R;F[v]=1};this.timer=function(){Ab=requestAnimationFrame(()=>this.update_screen())};this.update_screen=function(){Wb||(0===
|
|
20
|
+
B?this.update_text():1===B?this.update_graphical():this.update_graphical_text());this.timer()};this.update_text=function(){for(var v=0;v<t;v++)F[v]&&(this.text_update_row(v),F[v]=0)};this.update_graphical=function(){this.screen_fill_buffer()};this.update_graphical_text=function(){if(I){var v=performance.now();if(266<v-jc){xb=!xb;zb&&(F[n]=1);var u=4*w;for(let R=0,N=0;R<t;++R)if(F[R])N+=u;else for(var J=0;J<w;++J,N+=4)if(C[N+1]&1){F[R]=1;N+=u-4*J;break}jc=v}{u=Va.canvas;J=P.canvas;const R=4*w,N=w*
|
|
21
|
+
ja,xa=U;if(0===N)var L=0;else{v=0;for(let ya=0,ba=0,za=0;ya<t;++ya,ba+=U){if(!F[ya]){za+=R;continue}++v;P.clearRect(0,xa,N,U);let Ia,Pa,Qa;for(let ta=0;ta<N;ta+=ja,za+=4){const kc=C[za+0];var V=C[za+1];const lc=C[za+2],mc=C[za+3],nc=V&2?wb:vb;V=(!(V&1)||xb)&&ic[(nc<<8)+kc];Pa!==lc&&(void 0!==Pa&&(I.fillStyle=c(Pa),I.fillRect(Qa,ba,ta-Qa,U)),Pa=lc,Qa=ta);L!==mc&&(void 0!==L&&(P.fillStyle=c(L),P.fillRect(Ia,0,ta-Ia,U)),L=mc,Ia=ta);V&&P.drawImage(u,kc*ja,nc*U,ja,U,ta,xa,ja,U)}P.fillStyle=c(L);P.fillRect(Ia,
|
|
22
|
+
0,N-Ia,U);P.globalCompositeOperation="destination-in";P.drawImage(J,0,xa,N,U,0,0,N,U);P.globalCompositeOperation="source-over";I.fillStyle=c(Pa);I.fillRect(Qa,ba,N-Qa,U);I.drawImage(J,0,0,N,U,0,ba,N,U)}v&&(xb&&zb&&F[n]&&(I.fillStyle=c(C[4*(n*w+p)+3]),I.fillRect(p*ja,n*U+yb,ja,Ub-yb+1)),F.fill(0));L=v}}L&&h.drawImage(I.canvas,0,0)}};this.destroy=function(){Ab&&(cancelAnimationFrame(Ab),Ab=0)};this.pause=function(){Wb=!0;l.classList.remove("blinking-cursor")};this.continue=function(){Wb=!1;l.classList.add("blinking-cursor")};
|
|
23
|
+
this.clear_text_state=function(){wb=vb=t=w=U=ja=null};this.set_mode=function(v){B=v?1:a.use_graphical_text?2:0;0===B?(m.style.display="block",g.style.display="none"):(m.style.display="none",g.style.display="block",2===B&&F&&F.fill(1))};this.set_font_bitmap=function(v,u,J,L,V,R){const N=J?16:u?9:8;if(U!==v||ja!==N||Sb!==u||Rb!==J||Tb!==L||R)R=ja!==N||U!==v,U=v,ja=N,Sb=u,Rb=J,Tb=L,2===B&&(d(V),F.fill(1),R&&this.set_size_graphical_text())};this.set_font_page=function(v,u){if(vb!==v||wb!==u)vb=v,wb=u,
|
|
24
|
+
F.fill(1)};this.clear_screen=function(){h.fillStyle="#000";h.fillRect(0,0,g.width,g.height)};this.set_size_graphical_text=function(){if(Va){var v=ja*w,u=U*t,J=2*U;I&&I.canvas.width===v&&I.canvas.height===u&&P.canvas.height===J||(I?(I.canvas.width=v,I.canvas.height=u,P.canvas.width=v,P.canvas.height=J):(I=(new OffscreenCanvas(v,u)).getContext("2d",{alpha:!1}),P=(new OffscreenCanvas(v,J)).getContext("2d")),this.set_size_graphical(v,u,v,u),F.fill(1))}};this.set_size_text=function(v,u){if(v!==w||u!==
|
|
25
|
+
t)if(F=new Int8Array(u),F.fill(1),C=new Int32Array(v*u*4),w=v,t=u,0===B){for(;m.childNodes.length>u;)m.removeChild(m.firstChild);for(;m.childNodes.length<u;)m.appendChild(document.createElement("div"));for(v=0;v<u;v++)this.text_update_row(v);e(m,q,r,!0)}else 2===B&&this.set_size_graphical_text()};this.set_size_graphical=function(v,u){g.style.display="block";g.width=v;g.height=u;h.imageSmoothingEnabled=!1;x=640>=v&&2*v<window.innerWidth*window.devicePixelRatio&&2*u<window.innerHeight*window.devicePixelRatio?
|
|
26
|
+
2:1;e(g,q*x,r*x,!1)};this.set_scale=function(v,u){q=v;r=u;e(m,q,r,!0);e(g,q*x,r*x,!1)};this.update_cursor_scanline=function(v,u,J){if(v!==yb||u!==Ub||J!==zb)0===B?J?(l.style.display="inline",l.style.height=u-v+"px",l.style.marginTop=v+"px"):l.style.display="none":2===B&&n<t&&(F[n]=1),yb=v,Ub=u,zb=J};this.update_cursor=function(v,u){if(v!==n||u!==p)v<t&&(F[v]=1),n<t&&(F[n]=1),n=v,p=u};this.text_update_row=function(v){var u=4*v*w,J;var L=m.childNodes[v];var V=document.createElement("div");for(var R=
|
|
27
27
|
0;R<w;){var N=document.createElement("span");var xa=C[u+1]&1;var ya=C[u+2];var ba=C[u+3];xa&&N.classList.add("blink");N.style.backgroundColor=c(ya);N.style.color=c(ba);for(J="";R<w&&(C[u+1]&1)===xa&&C[u+2]===ya&&C[u+3]===ba;)if(J+=Vb[C[u+0]],R++,u+=4,v===n)if(R===p)break;else if(R===p+1){l.style.backgroundColor=N.style.color;V.appendChild(l);break}N.textContent=J;V.appendChild(N)}L.parentNode.replaceChild(V,L)};this.update_buffer=function(v){for(const u of v)h.putImageData(u.image_data,u.screen_x-
|
|
28
28
|
u.buffer_x,u.screen_y-u.buffer_y,u.buffer_x,u.buffer_y,u.buffer_width,u.buffer_height)};this.get_text_screen=function(){for(var v=[],u=0;u<t;u++)v.push(this.get_text_row(u));return v};this.get_text_row=function(v){var u=v*w*4;v=u+4*w;let J="";for(;u<v;u+=4)J+=Vb[C[u]];return J};this.init()};function z(a){this.buffer=a;this.byteLength=a.byteLength;this.onprogress=this.onload=void 0}z.prototype.load=function(){this.onload&&this.onload({buffer:this.buffer})};z.prototype.get=function(a,b,c){c(new Uint8Array(this.buffer,a,b))};z.prototype.get_and_cache=function(a,b,c){this.get(a,b,c)};z.prototype.get_from_cache=function(a,b){return new Uint8Array(this.buffer,a,b)};z.prototype.set=function(a,b,c){(new Uint8Array(this.buffer,a,b.byteLength)).set(b);c()};z.prototype.get_buffer=function(a){a(this.buffer)};
|
|
29
29
|
z.prototype.get_state=function(){const a=[];a[0]=this.byteLength;a[1]=new Uint8Array(this.buffer);return a};z.prototype.set_state=function(a){this.byteLength=a[0];this.buffer=a[1].slice().buffer};function wa(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}
|
|
@@ -92,15 +92,15 @@ D.prototype.port2x2_write=function(a){y(a);this.fm_current_address1=0};D.prototy
|
|
|
92
92
|
D.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)};D.prototype.port2x7_write=function(){};D.prototype.port2x8_write=function(){};D.prototype.port2x9_write=function(){};D.prototype.port2xA_write=function(){};D.prototype.port2xB_write=function(){};
|
|
93
93
|
D.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()};D.prototype.port2xD_write=function(){};D.prototype.port2xE_write=function(){};D.prototype.port2xF_write=function(){};
|
|
94
94
|
D.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};D.prototype.port3x0_write=function(a){y(a)};D.prototype.port3x1_read=function(){return 0|128*!this.mpu_read_buffer.length};D.prototype.port3x1_write=function(a){y(a);255===a&&(this.mpu_read_buffer.clear(),this.mpu_read_buffer.push(254))};
|
|
95
|
-
D.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()};D.prototype.dsp_default_handler=function(){y(this.command)};function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var Ta=new Uint8Array(256);Ta[14]=255;Ta[15]=7;Ta[55]=56;
|
|
95
|
+
D.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()};D.prototype.dsp_default_handler=function(){y(this.command)};function E(a,b,c){c||(c=D.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([4],1);E([5],2);E([8],1,function(){3===this.write_buffer.shift()&&(this.read_buffer.clear(),this.read_buffer.push(255))});
|
|
96
|
+
E([14],2);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);
|
|
97
|
+
E([23],2);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())});
|
|
98
|
+
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);
|
|
99
|
+
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()}});
|
|
100
|
+
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});
|
|
101
|
+
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())});
|
|
102
|
+
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)});
|
|
103
|
+
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])});D.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};D.prototype.mixer_write=function(a,b){var c=Ma[a];c?c.call(this,b):(y(a),y(b))};D.prototype.mixer_default_read=function(){y(this.mixer_current_address);return this.mixer_registers[this.mixer_current_address]};
|
|
104
104
|
D.prototype.mixer_default_write=function(a){y(this.mixer_current_address);y(a);this.mixer_registers[this.mixer_current_address]=a};
|
|
105
105
|
D.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]=
|
|
106
106
|
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()};D.prototype.mixer_full_update=function(){for(var a=1;a<this.mixer_registers.length;a++)Na[a]||this.mixer_write(a,this.mixer_registers[a])};
|
|
@@ -158,7 +158,7 @@ function nb(a,b,c){this.node_oscillator=b.createOscillator();this.node_oscillato
|
|
|
158
158
|
f=Math.max(f,0));this.node_oscillator.frequency.setValueAtTime(f,b.currentTime)},this)}nb.prototype.start=function(){this.node_oscillator.start()};
|
|
159
159
|
function kb(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=48E3;b=function(){function g(l){if(0===l)return 1;l*=Math.PI;return Math.sin(l)/l}function h(){var l=Reflect.construct(AudioWorkletProcessor,[],h);l.kernel_size=3;l.queue_data=Array(1024);l.queue_start=0;l.queue_end=0;l.queue_length=0;l.queue_size=l.queue_data.length;l.queued_samples=0;l.source_buffer_previous=m;l.source_buffer_current=m;l.source_samples_per_destination=1;l.source_block_start=0;l.source_time=0;l.source_offset=
|
|
160
160
|
0;l.port.onmessage=n=>{switch(n.data.type){case "queue":l.queue_push(n.data.value);break;case "sampling-rate":l.source_samples_per_destination=n.data.value/sampleRate}};return l}var m=[new Float32Array(256),new Float32Array(256)];Reflect.setPrototypeOf(h.prototype,AudioWorkletProcessor.prototype);Reflect.setPrototypeOf(h,AudioWorkletProcessor);h.prototype.process=h.prototype.process=function(l,n){for(l=0;l<n[0][0].length;l++){for(var p=0,q=0,r=this.source_offset+this.kernel_size,x=this.source_offset-
|
|
161
|
-
this.kernel_size+1;x<=r;x++){var
|
|
161
|
+
this.kernel_size+1;x<=r;x++){var F=this.source_block_start+x;p+=this.get_sample(F,0)*this.kernel(this.source_time-x);q+=this.get_sample(F,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][l]=p;n[0][1][l]=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;
|
|
162
162
|
this.source_offset=0;this.ensure_enough_data(n);return!0};h.prototype.kernel=function(l){return g(l)*g(l/this.kernel_size)};h.prototype.get_sample=function(l,n){return 0>l?(l+=this.source_buffer_previous[0].length,this.source_buffer_previous[n][l]):this.source_buffer_current[n][l]};h.prototype.ensure_enough_data=function(l){var n=this.source_buffer_current[0].length;n-this.source_block_start<l&&(this.prepare_next_buffer(),this.source_block_start-=n)};h.prototype.prepare_next_buffer=function(){256>
|
|
163
163
|
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 l=this.source_buffer_current[0].length;if(256>l){for(var n=this.queue_start,p=0;256>l&&p<this.queue_length;)l+=this.queue_data[n][0].length,n=n+1&this.queue_size-1,p++;l=Math.max(l,256);l=[new Float32Array(l),new Float32Array(l)];l[0].set(this.source_buffer_current[0]);l[1].set(this.source_buffer_current[1]);
|
|
164
164
|
n=this.source_buffer_current[0].length;for(var q=0;q<p;q++){var r=this.queue_shift();l[0].set(r[0],n);l[1].set(r[1],n);n+=r[0].length}this.source_buffer_current=l}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(l){this.queue_length<this.queue_size&&(this.queue_data[this.queue_end]=l,this.queue_end=this.queue_end+1&this.queue_size-1,this.queue_length++,this.queued_samples+=l[0].length,
|
|
@@ -179,7 +179,7 @@ function Eb(a=1500){const b=a-20,c=b-8,d=new Uint8Array(14+a+4),e=d.buffer,f=d.b
|
|
|
179
179
|
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}
|
|
180
180
|
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;
|
|
181
181
|
h.setUint8(0,b.icmp.type);h.setUint8(1,b.icmp.code);h.setUint16(2,0);var m=4+Fb(4,b.icmp.data,h,a);h.setUint16(2,Gb(m,0,h,a));g+=m}else if(b.udp){h=a.ipv4_payload_view;var l=8;if(b.dhcp){m=l;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,
|
|
182
|
-
b.dhcp.giaddr);Fb(28,b.dhcp.chaddr,n,a);n.setUint32(236,1669485411);l=240;for(var p of b.dhcp.options)l+=Fb(l,p,n,a);m+=l}else if(b.dns){p=l;l=a.udp_payload_view;l.setUint16(0,b.dns.id);l.setUint16(2,b.dns.flags);l.setUint16(4,b.dns.questions.length);l.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
|
|
182
|
+
b.dhcp.giaddr);Fb(28,b.dhcp.chaddr,n,a);n.setUint32(236,1669485411);l=240;for(var p of b.dhcp.options)l+=Fb(l,p,n,a);m+=l}else if(b.dns){p=l;l=a.udp_payload_view;l.setUint16(0,b.dns.id);l.setUint16(2,b.dns.flags);l.setUint16(4,b.dns.questions.length);l.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 F=a.text_encoder.encodeInto(n,a.eth_frame.subarray(l.byteOffset+(x+1))).written;l.setUint8(x,F);x+=1+F}l.setUint16(x,
|
|
183
183
|
r.type);x+=2;l.setUint16(x,r.class);x+=2}for(q=0;q<b.dns.answers.length;++q){n=b.dns.answers[q];for(m of n.name)r=a.text_encoder.encodeInto(m,a.eth_frame.subarray(l.byteOffset+(x+1))).written,l.setUint8(x,r),x+=1+r;l.setUint16(x,n.type);x+=2;l.setUint16(x,n.class);x+=2;l.setUint32(x,n.ttl);x+=4;l.setUint16(x,n.data.length);x+=2;x+=Fb(x,n.data,l,a)}m=p+x}else b.ntp?(m=l,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),
|
|
184
184
|
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),m+=48):m=l+Fb(0,b.udp.data,a.udp_payload_view,a);l=m;h.setUint16(0,b.udp.sport);h.setUint16(2,b.udp.dport);h.setUint16(4,l);h.setUint16(6,0);h.setUint16(6,Gb(l,
|
|
185
185
|
(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+l,h,a));g+=l}else b.tcp&&(h=a.ipv4_payload_view,m=0,n=b.tcp,n.fin&&(m|=1),n.syn&&(m|=2),n.rst&&(m|=4),n.psh&&(m|=8),n.ack&&(m|=16),n.urg&&(m|=32),n.ece&&(m|=64),n.cwr&&(m|=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),l=4*Math.ceil(p/4),n.options&&0<l-p&&a.eth_frame.fill(0,h.byteOffset+p,h.byteOffset+
|
|
@@ -236,16 +236,16 @@ $b.prototype.on_tcp_connection=function(a,b){a.stream_id=this.last_stream++;a.on
|
|
|
236
236
|
$b.prototype.send=function(a){Kb(a,this)};$b.prototype.receive=function(a){this.bus.send("net"+this.id+"-receive",new Uint8Array(a))};const ac="undefined"!==typeof window&&0<=window.navigator.platform.toString().toLowerCase().search("win");
|
|
237
237
|
function bc(a){function b(t){return t.shiftKey&&t.ctrlKey&&(73===t.keyCode||74===t.keyCode||75===t.keyCode)||!x.emu_enabled?!1:t.target?t.target.classList.contains("phone_keyboard")||"INPUT"!==t.target.nodeName&&"TEXTAREA"!==t.target.nodeName:!0}function c(t){!t.altKey&&n[56]&&m(56,!1);return g(t,!1)}function d(t){!t.altKey&&n[56]&&m(56,!1);return g(t,!0)}function e(){for(var t=Object.keys(n),I,P=0;P<t.length;P++)I=+t[P],n[I]&&m(I,!1);n={}}function f(t){if(x.bus&&b(t))switch(t.inputType){case "insertText":for(var I=
|
|
238
238
|
0;I<t.data.length;I++)x.simulate_char(t.data[I]);break;case "insertLineBreak":x.simulate_press(13);break;case "deleteContentBackward":x.simulate_press(8)}}function g(t,I){if(x.bus&&b(t)&&""!==t.code&&"Process"!==t.key&&"Unidentified"!==t.key&&229!==t.keyCode){t.preventDefault&&t.preventDefault();if(ac&&(p&&(clearTimeout(r),t.getModifierState&&t.getModifierState("AltGraph")&&q===I&&"ControlLeft"===p.code&&"AltRight"===t.code||h(p,q),p=null),"ControlLeft"===t.code))return p=t,q=I,r=setTimeout(()=>{h(p,
|
|
239
|
-
q);p=null},10),!1;h(t,I);return!1}}function h(t,I){a:{if(void 0!==t.code){var P=w[t.code];if(void 0!==P)break a}P=
|
|
239
|
+
q);p=null},10),!1;h(t,I);return!1}}function h(t,I){a:{if(void 0!==t.code){var P=w[t.code];if(void 0!==P)break a}P=F[t.keyCode]}P?m(P,I,t.repeat):console.log("Missing char in map: keyCode="+(t.keyCode||-1).toString(16)+" code="+t.code)}function m(t,I,P){if(I)n[t]&&!P&&m(t,!1);else if(!n[t])return;(n[t]=I)||(t|=128);255<t?(l(t>>8),l(t&255)):l(t)}function l(t){x.bus.send("keyboard-code",t)}var n={},p=null,q=!1,r=0,x=this;this.emu_enabled=!0;const F=new Uint16Array([0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,
|
|
240
240
|
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,
|
|
241
241
|
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]),B={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},C={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,
|
|
242
242
|
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 w={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,
|
|
243
243
|
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,
|
|
244
244
|
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,
|
|
245
245
|
!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(t){t={keyCode:t};g(t,!0);g(t,!1)};this.simulate_char=function(t){var I=t.charCodeAt(0);I in B?this.simulate_press(B[I]):I in C?(l(42),this.simulate_press(C[I]),l(170)):console.log("ascii -> keyCode not found: ",
|
|
246
|
-
I,t)}};function cc(a,b){function c(){C.bus.send("mouse-pointer-lock",!!document.pointerLockElement)}function d(w){e(w)&&w.preventDefault()}function e(w){if(!C.enabled||!C.emu_enabled)return!1;var t=b||document.body,I;if(!(I=document.pointerLockElement))a:{for(w=w.target;w.parentNode;){if(w===t){I=!0;break a}w=w.parentNode}I=!1}return I}function f(w){e(w)&&(w=w.changedTouches)&&w.length&&(w=w[w.length-1],
|
|
247
|
-
e(w)&&C.is_running){var t=0,I=0,P=w.changedTouches;P?P.length&&(P=P[P.length-1],t=P.clientX-
|
|
248
|
-
C.bus.send("mouse-absolute",[w.clientX-t.left,w.clientY-t.top,t.width,t.height]))}}function m(w){e(w)&&n(w,!0)}function l(w){e(w)&&n(w,!1)}function n(w,t){C.bus&&(1===w.which?q=t:2===w.which?x=t:3===w.which&&(r=t),C.bus.send("mouse-click",[q,x,r]),w.preventDefault())}function p(w){if(e(w)){var t=w.wheelDelta||-w.detail;0>t?t=-1:0<t&&(t=1);C.bus.send("mouse-wheel",[t,0]);w.preventDefault()}}var q=!1,r=!1,x=!1,
|
|
246
|
+
I,t)}};function cc(a,b){function c(){C.bus.send("mouse-pointer-lock",!!document.pointerLockElement)}function d(w){e(w)&&w.preventDefault()}function e(w){if(!C.enabled||!C.emu_enabled)return!1;var t=b||document.body,I;if(!(I=document.pointerLockElement))a:{for(w=w.target;w.parentNode;){if(w===t){I=!0;break a}w=w.parentNode}I=!1}return I}function f(w){e(w)&&(w=w.changedTouches)&&w.length&&(w=w[w.length-1],F=w.clientX,B=w.clientY)}function g(){if(q||x||r)C.bus.send("mouse-click",[!1,!1,!1]),q=x=r=!1}function h(w){if(C.bus&&
|
|
247
|
+
e(w)&&C.is_running){var t=0,I=0,P=w.changedTouches;P?P.length&&(P=P[P.length-1],t=P.clientX-F,I=P.clientY-B,F=P.clientX,B=P.clientY,w.preventDefault()):"number"===typeof w.movementX?(t=w.movementX,I=w.movementY):"number"===typeof w.webkitMovementX?(t=w.webkitMovementX,I=w.webkitMovementY):"number"===typeof w.mozMovementX?(t=w.mozMovementX,I=w.mozMovementY):(t=w.clientX-F,I=w.clientY-B,F=w.clientX,B=w.clientY);C.bus.send("mouse-delta",[1*t,-(1*I)]);b&&!document.pointerLockElement&&(t=b.getBoundingClientRect(),
|
|
248
|
+
C.bus.send("mouse-absolute",[w.clientX-t.left,w.clientY-t.top,t.width,t.height]))}}function m(w){e(w)&&n(w,!0)}function l(w){e(w)&&n(w,!1)}function n(w,t){C.bus&&(1===w.which?q=t:2===w.which?x=t:3===w.which&&(r=t),C.bus.send("mouse-click",[q,x,r]),w.preventDefault())}function p(w){if(e(w)){var t=w.wheelDelta||-w.detail;0>t?t=-1:0<t&&(t=1);C.bus.send("mouse-wheel",[t,0]);w.preventDefault()}}var q=!1,r=!1,x=!1,F=0,B=0,C=this;this.enabled=!1;this.emu_enabled=!0;this.absolute_mouse=!1;this.bus=a;this.bus.register("mouse-enable",
|
|
249
249
|
function(w){this.enabled=w;this.update_cursor()},this);this.bus.register("vmware-absolute-mouse",function(w){this.absolute_mouse=w;this.update_cursor()},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.update_cursor=function(){b&&(b.style.cursor=this.absolute_mouse&&this.enabled&&this.emu_enabled?"none":"")};this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("touchstart",
|
|
250
250
|
f,!1),window.removeEventListener("touchend",g,!1),window.removeEventListener("touchmove",h,!1),window.removeEventListener("mousemove",h,!1),window.removeEventListener("mousedown",m,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("wheel",p,{passive:!1}),window.removeEventListener("contextmenu",d,!1),document.removeEventListener("pointerlockchange",c,!1))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("touchstart",f,!1),window.addEventListener("touchend",
|
|
251
251
|
g,!1),window.addEventListener("touchmove",h,!1),window.addEventListener("mousemove",h,!1),window.addEventListener("mousedown",m,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("wheel",p,{passive:!1}),window.addEventListener("contextmenu",d,!1),document.addEventListener("pointerlockchange",c,!1))};this.init()};function dc(a){var b,c=0,d=0,e=ra(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=
|
|
@@ -341,7 +341,7 @@ h)},mmap_write32:function(g,h){c.mmap_write32(g,h)},mmap_write64:function(g,h,m)
|
|
|
341
341
|
g=>new Promise(h=>{let m="v86.wasm",l="v86-fallback.wasm";a.wasm_path?(m=a.wasm_path,l=m.replace("v86.wasm","v86-fallback.wasm")):"undefined"===typeof window&&"string"===typeof __dirname?(m=__dirname+"/"+m,l=__dirname+"/"+l):(m="build/"+m,l="build/"+l);na(m,{done:async n=>{try{const {instance:p}=await WebAssembly.instantiate(n,g);this.wasm_source=n;h(p.exports)}catch(p){na(l,{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",
|
|
342
342
|
{file_index:0,file_count:1,file_name:m,lengthComputable:n.lengthComputable,total:n.total,loaded:n.loaded})}})}));f({env:b}).then(g=>{d=g.memory;g.rust_init();g=this.v86=new G(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}
|
|
343
343
|
Q.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&&
|
|
344
|
-
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,
|
|
344
|
+
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,F]=await Promise.all([e.fs9p.read_file(r),e.fs9p.read_file(q)]);c.call(this,"initrd",new z(x.buffer));c.call(this,"bzimage",new z(F.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();
|
|
345
345
|
e.initial_state||(e.hda&&await new Promise(q=>e.hda.get_and_cache(0,512,q)),e.hdb&&await new Promise(q=>e.hdb.get_and_cache(0,512,q)));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=
|
|
346
346
|
!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,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.bootmenu=b.bootmenu||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=b.uart3;e.parallel1=
|
|
347
347
|
b.parallel1;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;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 Xb(this.bus,b.net_device):"inbrowser"===f?this.network_adapter=new rc(this.bus,b.net_device):f.startsWith("wisp://")||f.startsWith("wisps://")?this.network_adapter=
|
|
@@ -671,7 +671,7 @@ d.pop_request();const f=new Uint8Array(e.length_readable);e.get_next_blob(f);thi
|
|
|
671
671
|
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]=M(["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()}]},
|
|
672
672
|
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:()=>{}}]}})}jd.prototype.Inflate=function(a){this.num_pages+=a;this.virtio.notify_config_changes()};jd.prototype.Deflate=function(a){this.num_pages-=a;this.virtio.notify_config_changes()};
|
|
673
673
|
jd.prototype.Cleanup=function(a){this.fp_cmd=2;this.free_cb=a;this.zeroed=0;this.virtio.notify_config_changes()};jd.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.num_pages;a[2]=this.actual;return a};jd.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.num_pages=a[1];this.actual=a[2]};jd.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()};
|
|
674
|
-
jd.prototype.Reset=function(){};function kd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);var g=new Uint32Array(b),h=e[497]||4,m=f[255];if(43605!==m)y(m);else if(m=f[257]|f[258]<<16,1400005704!==m)y(m);else{m=f[259];var l=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=m?g[142]:255,
|
|
674
|
+
jd.prototype.Reset=function(){};function kd(a,b,c,d){var e=new Uint8Array(b);const f=new Uint16Array(b);var g=new Uint32Array(b),h=e[497]||4,m=f[255];if(43605!==m)y(m);else if(m=f[257]|f[258]<<16,1400005704!==m)y(m);else{m=f[259];var l=e[529],n=f[283],p=g[139],q=g[140],r=e[565],x=518<=m?g[142]:255,F=g[146],B=g[147],C=g[150],w=g[151],t=g[152];y(m);y(l);y(n);y(g[133]);y(p);y(q);y(r);y(x);y(F);y(B);y(w);y(C);y(t);e[528]=255;e[529]=l&-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+
|
|
675
675
|
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++]=
|
|
676
676
|
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 S(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);
|
|
677
677
|
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.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,b,640,1);this.sysenter_eip=k(Int32Array,
|
|
@@ -717,10 +717,10 @@ new Y(this,b,a.screen,a.vga_memory_size||8388608),this.devices.ps2=new Pc(this,b
|
|
|
717
717
|
new md(a.handle9p,this):a.proxy9p&&(this.devices.virtio_9p=new nd(a.proxy9p,this)),a.virtio_console&&(this.devices.virtio_console=new Nc(this,b)),a.virtio_balloon&&(this.devices.virtio_balloon=new jd(this,b)),this.devices.sb16=new D(this,b));a.multiboot&&(b=this.load_multiboot_option_rom(a.multiboot,a.initrd,a.cmdline))&&(this.bios.main?this.option_roms.push(b):this.reg32[0]=this.io.port_read32(244));this.debug_init()};
|
|
718
718
|
S.prototype.load_multiboot=function(a){this.load_multiboot_option_rom(a,void 0,"")&&(this.reg32[0]=this.io.port_read32(244))};
|
|
719
719
|
S.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;sa("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";
|
|
720
|
-
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
|
|
721
|
-
y(B,8);y(x,8);y(
|
|
722
|
-
C.ehsize,"Bad header size");console.assert(32===C.phentsize,"Bad program header size");console.assert(40===C.shentsize,"Bad section header size");[r]=Zc(new DataView(
|
|
723
|
-
|
|
720
|
+
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 F=!1;for(n=0;4294967296>n;n+=131072)F&&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,F=!1):F||void 0!==g.memory_map_read8[n>>>17]||(x=n,F=!0);g.write32(31788,r)}x=r=0;if(f&65536){n=d[e+12>>2];r=d[e+16>>2];var B=d[e+20>>2];x=d[e+24>>2];F=d[e+28>>2];y(n,8);y(r,8);
|
|
721
|
+
y(B,8);y(x,8);y(F,8);n=new Uint8Array(a,e-(n-r),0===B?void 0:B-r);g.write_blob(n,r);r=F|0;x=Math.max(B,x)}else if(1179403647===d[0]){F=new DataView(a);const [C,w]=Yc(F,Vc);console.assert(52===w);console.assert(1179403647===C.magic,"Bad magic");console.assert(1===C.class,"Unimplemented: 64 bit elf");console.assert(1===C.data,"Unimplemented: big endian");console.assert(1===C.version0,"Bad version0");console.assert(2===C.type,"Unimplemented type");console.assert(1===C.version1,"Bad version1");console.assert(52===
|
|
722
|
+
C.ehsize,"Bad header size");console.assert(32===C.phentsize,"Bad program header size");console.assert(40===C.shentsize,"Bad section header size");[r]=Zc(new DataView(F.buffer,F.byteOffset+C.phoff,C.phentsize*C.phnum),Wc,C.phnum);Zc(new DataView(F.buffer,F.byteOffset+C.shoff,C.shentsize*C.shnum),Xc,C.shnum);F=C;n=r;r=F.entry;for(B of n)0!==B.type&&(1===B.type?B.paddr+B.memsz<g.memory_size[0]?(B.filesz&&(n=new Uint8Array(a,B.offset,B.filesz),g.write_blob(n,B.paddr)),x=Math.max(x,B.paddr+B.memsz),r===
|
|
723
|
+
F.entry&&B.vaddr<=r&&B.vaddr+B.memsz>r&&(r=r-B.vaddr+B.paddr)):y(B.paddr):2===B.type||3===B.type||4===B.type||6===B.type||7===B.type||1685382480===B.type||1685382481===B.type||1685382482===B.type||1685382483===B.type||y(B.type))}b&&(q|=8,g.write32(31764,1),g.write32(31768,p),B=x,0!==(B&4095)&&(B=(B&-4096)+4096),x=B+b.byteLength,g.write32(p,B),g.write32(p+4,x),g.write32(p+8,0),g.write32(p+12,0),g.write_blob(new Uint8Array(b),B));g.write32(31744,q);g.reg32[3]=31744;g.cr[0]=1;g.protected_mode[0]=1;g.flags[0]=
|
|
724
724
|
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]=1===p?8:16;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):
|
|
725
725
|
this.device_lower_irq(n)}this.io.register_write(8192+n,this,p,p,p)}const m=new Uint8Array(512);(new Uint16Array(m.buffer))[0]=43605;m[2]=1;var h=3;m[h++]=102;m[h++]=229;m[h++]=244;let l=m[h]=0;for(let n=0;n<m.length;n++)l+=m[n];m[h]=-l;return{name:"genroms/multiboot.bin",data:m}}};
|
|
726
726
|
S.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,
|