Cleaned up PC8080 cross-browser full-screen support (matches PCx86 now)

This commit is contained in:
Jeff Parsons 2017-08-03 08:42:29 -07:00 committed by Jeff Parsons
commit 13b0c23b0a
19 changed files with 500 additions and 524 deletions

View file

@ -62,7 +62,7 @@ function Ea(a,b){var c;if(Array.prototype.indexOf)return a.indexOf(b,c);c=c||0;0
function Ha(a,b,c,d,e){c=void 0===c?!1:c;var f=0,g=null,h=null;if("object"==typeof resources&&(g=resources[a]))return d&&d(a,g,f),[g,f];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var k=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(k.onreadystatechange=function(){4!==k.readyState?e&&e(1):(g=k.responseText,200==k.status||!k.status&&g.length&&"file:"==(window?window.location.protocol:"file:")||(f=k.status||-1),
e&&e(2),d&&d(a,g,f))});e&&e(0);if(b&&"object"==typeof b){var m="",p;for(p in b)b.hasOwnProperty(p)&&(m&&(m+="&"),m+=p+"="+encodeURIComponent(b[p]));m=m.replace(/%20/g,"+");k.open("POST",a,c);k.setRequestHeader("Content-type","application/x-www-form-urlencoded");k.send(m)}else k.open("GET",a,c),"bytes"==b&&k.overrideMimeType("text/plain; charset=x-user-defined"),k.send();c||(g=k.responseText,200!=k.status&&(f=k.status||-1),d&&d(a,g,f),h=[g,f]);return h}
function Ia(){return"http://"+(window?window.location.host:"www.pcjs.org")}function Ja(){return window?window.navigator.userAgent:""}function Ka(){if(null==La){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}La=a}return La}function Ma(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function Na(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Pa(a){if(window){var b=Ja();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Qa(a,b,c){if(a)for(var d=0;d<Sa.length;d++){var e=Sa[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0].toLowerCase(),e+=b.substr(1),e in a)return e}return null}
function Na(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Pa(a){if(window){var b=Ja();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Qa(a,b,c){if(a)for(var d=0;d<Sa.length;d++){var e=Sa[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0],e+=b.substr(1),e in a)return e}return null}
function Ta(a){if(!Ua){var b,c={};if(window){b||(b=window.location.search.substr(1));for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g;d=f.exec(b);)c[decodeURIComponent(d[1].replace(e," "))]=decodeURIComponent(d[2].replace(e," "))}Ua=c}return Ua[a]||Ua[a.toLowerCase()]}
function Va(a,b,c,d){var e=null;b="data:application/"+b+(c?";base64":"")+",";b=Pa("Firefox")?b+(c?a:encodeURIComponent(a)):b+(c?a:encodeURI(a));d&&(e=document.createElement("a"),"string"!=typeof e.download&&(e=null));e?(e.href=b,e.download=d,document.body.appendChild(e),e.click(),document.body.removeChild(e),a="Check your Downloads folder for "+d+"."):(window.open(b),a="Check your browser for a new window/tab containing the requested data"+(d?" ("+d+")":"")+".");return a}
function Wa(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}function Xa(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,f=!1;a.onmousedown=function(){f||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}function Ya(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}
@ -548,8 +548,8 @@ $r[98]=function(a,b){a+=this.H;b=ws[b&15];b&=this.controller.wb;b=b&this.control
$r[226]=function(a,b){a+=this.H;b=ws[b&15];b^=this.controller.wb;b=b&this.controller.Db|this.controller.wb&~this.controller.Db;b=b&this.controller.kb|this.W[a]&~this.controller.kb;this.W[a]!=b&&(this.W[a]=b,this.Na=!0)};$r[3]=function(a,b){a+=this.H;b=b>>this.controller.Qc|b<<8-this.controller.Qc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.Db;b=this.controller.Kf&b|this.controller.wb&~b;b=b&this.controller.kb|this.W[a]&~this.controller.kb;this.W[a]!=b&&(this.W[a]=b,this.Na=!0)};
function Q(a,b,c,d,e){nb.call(this,"Video",a,262144);var f=this,g;this.Vc=Pa("Gecko/");this.da=a.model;var h=xs[this.da]||xs.mda;this.La=h[0];this.wd=a.memory||0;this.od=a.switches;this.ea=a.mode;if(null==this.ea||null==ys[this.ea])this.ea=h[1];this.Rb=a.charCols;this.wc=a.charRows;if(void 0===this.Rb||void 0===this.wc)this.Rb=ys[this.ea][0],this.wc=ys[this.ea][1];this.Z=a.screenWidth;this.ka=a.screenHeight;this.bd=a.scale;this.Rd=12<=Math.round(this.Z/this.Rb);this.N=b;this.L=c;this.F=(this.ug=d)||
b||null;this.gc=a.screenColor||"black";this.nd=(1-(Ta("flicker")||a.flicker||0)).toString();this.Gb=!1;b&&(b.style.backgroundColor=this.gc);e&&(e.style.backgroundColor=this.gc);b=a.smoothing;(c=Ta("smoothing"))&&(b="true"==c);null!=b&&(g=Qa(this.L,"imageSmoothingEnabled"))&&(this.L[g]=b);this.pd=a.touchScreen;this.Ac=zs;this.G=null;this.Hd=a.autoLock;this.fb=this.Sb=0;this.ra=[];this.ha=Array(this.La==pq?256:16);this.Ia=!1;if(this.P=e)if(g=Qa(e,"requestFullscreen")||Qa(e,"requestFullScreen")){this.P.A=
e[g];if(e=Qa(document,"on","fullscreenchange")){var k=Qa(document,"fullscreenElement")||Qa(document,"fullScreenElement");document.addEventListener(e,function(){As(f,!!k)},!1)}(e=Qa(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){As(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Gg(!0)},this.F.onblur=function(){return f.Gg(!1)},this.F.se=(g=Qa(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Qa(this.F,"exitPointerLock"))&&this.F[g],this.F.se)){var m=Qa(document,
"pointerLockElement");(e=Qa(document,"on","pointerlockchange"))&&document.addEventListener(e,function(){f.Mf(!(!m||document[m]!==f.F))},!1)}(this.Aa=a.fontROM)&&"json"!=ra(this.Aa)&&(this.Aa=Ia()+"/api/v1/dump?file="+this.Aa+"&format=bytes")}ba(Q,nb);l=Q.prototype;
e[g];if(e=Qa(document,"on","fullscreenchange")){var k=Qa(document,"fullscreenElement")||Qa(document,"fullScreenElement");document.addEventListener(e,function(){As(f,!!k)},!1)}(e=Qa(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){As(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Gg(!0)},this.F.onblur=function(){return f.Gg(!1)},this.F.se=(g=Qa(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Qa(this.F,"exitPointerLock"))&&this.F[g],this.F.se&&(e=Qa(document,
"on","pointerlockchange")))){var m=Qa(document,"pointerLockElement");document.addEventListener(e,function(){f.Mf(!(!m||document[m]!==f.F))},!1)}(this.Aa=a.fontROM)&&"json"!=ra(this.Aa)&&(this.Aa=Ia()+"/api/v1/dump?file="+this.Aa+"&format=bytes")}ba(Q,nb);l=Q.prototype;
l.uc=function(a,b,c,d){var e=this;this.na=b;this.H=c;this.ca=d;c=(c=xs[this.da])&&c[0];c!==Bs&&(Rc(b,this,Cs),Vc(b,this,Ds));c!==Es&&(Rc(b,this,Fs),Vc(b,this,Gs));this.La>=nq&&(Rc(b,this,Hs),Vc(b,this,Is));this.La==pq&&(Rc(b,this,Js),Vc(b,this,Ks));d&&Kl(d,262144,function(a){if(e.B)if(a[0]){var b=e.B;if(b.gd){var c,d,f,g=!1,h=8,J=8,H=-1,I=b.video.D>>3;for(c=0;c<a.length;c++){var P=a[c];if(c){var L=P.charAt(0);d=ia(P.substr(1),16);switch(L){case "l":h=d;break;case "n":1<=d&&8>=d&&(J=d,g=!0);break;
case "p":0<=d&&3>=d&&(H=d);break;case "w":d<I&&(I=d);break;default:b.ca.O("unrecognized argument: "+P)}}else f=ia(P,16)}void 0===f?f=b.B||0:f>=b.fb&&(f-=b.fb);a="";for(c=0;c<h;c++){P=q(b.fb+f)+":";for(d=0;d<J&&f<b.gd.length;d++)L=b.gd[f++],P+=" "+(0>H?q(L):la(L>>(H<<3),8));g&&(f+=I-J);a&&(a+="\n");a+=P}a&&b.ca.O(a);b.B=f}else b.ca.O("no buffer")}else e.ca.O("BIOSMODE: "+na(e.la)),b=e.B,Xr(b,"CRTC",b.hc,b.$a,b.jg),b.La>=nq&&(Xr(b," GRC",b.Ed,b.Dd,b.$g),Xr(b," SEQ",b.Fd,b.de,b.ah),Xr(b," ATC",b.Cd,
b.Dc,b.Zg),Xr(b," ATCINDX",b.Cd),b.ca.O(" ATCDATA: "+b.Pe),Xr(b," FEAT",b.Sf),Xr(b," MISC",b.ef),Xr(b," STATUS0",b.Ng)),Xr(b," STATUS1",b.ga),b.La!=Es&&b.La!=Bs||Xr(b," MODEREG",b.Wc),b.La==Bs&&Xr(b," COLOR",b.cf),b.La>=nq&&(b.ca.O(" LATCHES: "+q(b.wb)),b.ca.O(" ACCESS: "+q(b.yg,4)),b.ca.O("Use 'dump video [addr]' to dump video memory"));else e.ca.O("no active video card")});if((this.C=$b(a,"Keyboard"))&&this.N){for(var f in this.ma)0<f.indexOf("lock")&&this.C.Eb("led",f,this.ma[f]);this.C.Eb(this.ug?

View file

@ -61,7 +61,7 @@ var ra="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),sa=
function xa(a,b,c,d,e){c=void 0===c?!1:c;var f=0,g=null,h=null;if("object"==typeof resources&&(g=resources[a]))return d&&d(a,g,f),[g,f];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var k=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(k.onreadystatechange=function(){4!==k.readyState?e&&e(1):(g=k.responseText,200==k.status||!k.status&&g.length&&"file:"==(window?window.location.protocol:"file:")||(f=k.status||-1),
e&&e(2),d&&d(a,g,f))});e&&e(0);if(b&&"object"==typeof b){var m="",r;for(r in b)b.hasOwnProperty(r)&&(m&&(m+="&"),m+=r+"="+encodeURIComponent(b[r]));m=m.replace(/%20/g,"+");k.open("POST",a,c);k.setRequestHeader("Content-type","application/x-www-form-urlencoded");k.send(m)}else k.open("GET",a,c),"bytes"==b&&k.overrideMimeType("text/plain; charset=x-user-defined"),k.send();c||(g=k.responseText,200!=k.status&&(f=k.status||-1),d&&d(a,g,f),h=[g,f]);return h}
function za(){return"http://"+(window?window.location.host:"www.pcjs.org")}function Aa(){return window?window.navigator.userAgent:""}function Ba(){if(null==Ca){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Ca=a}return Ca}function Da(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function Ea(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Fa(a){if(window){var b=Aa();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Ga(a,b,c){if(a)for(var d=0;d<Ia.length;d++){var e=Ia[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0].toLowerCase(),e+=b.substr(1),e in a)return e}return null}
function Ea(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Fa(a){if(window){var b=Aa();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Ga(a,b,c){if(a)for(var d=0;d<Ia.length;d++){var e=Ia[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0],e+=b.substr(1),e in a)return e}return null}
function Ja(a){if(!Ka){var b,c={};if(window){b||(b=window.location.search.substr(1));for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g;d=f.exec(b);)c[decodeURIComponent(d[1].replace(e," "))]=decodeURIComponent(d[2].replace(e," "))}Ka=c}return Ka[a]||Ka[a.toLowerCase()]}
function La(a,b,c,d){var e=null;b="data:application/"+b+(c?";base64":"")+",";b=Fa("Firefox")?b+(c?a:encodeURIComponent(a)):b+(c?a:encodeURI(a));d&&(e=document.createElement("a"),"string"!=typeof e.download&&(e=null));e?(e.href=b,e.download=d,document.body.appendChild(e),e.click(),document.body.removeChild(e),a="Check your Downloads folder for "+d+"."):(window.open(b),a="Check your browser for a new window/tab containing the requested data"+(d?" ("+d+")":"")+".");return a}
function Ma(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Na(a){Oa.init.push(a)}function Pa(a){if(Qa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){q(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Ra(a){!Qa&&a?(Qa=!0,Sa&&Ta("init"),Ua&&Ta("show")):Qa=a}function Ta(a){Oa[a]&&Pa(Oa[a])}
@ -516,8 +516,8 @@ Cp[98]=function(a,b){a+=this.G;b=$p[b&15];b&=this.controller.pb;b=b&this.control
Cp[226]=function(a,b){a+=this.G;b=$p[b&15];b^=this.controller.pb;b=b&this.controller.sb|this.controller.pb&~this.controller.sb;b=b&this.controller.Wa|this.T[a]&~this.controller.Wa;this.T[a]!=b&&(this.T[a]=b,this.Ea=!0)};Cp[3]=function(a,b){a+=this.G;b=b>>this.controller.Bc|b<<8-this.controller.Bc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.sb;b=this.controller.af&b|this.controller.pb&~b;b=b&this.controller.Wa|this.T[a]&~this.controller.Wa;this.T[a]!=b&&(this.T[a]=b,this.Ea=!0)};
function W(a,b,c,d,e){u.call(this,"Video",a);var f=this,g;this.Oc=Fa("Gecko/");this.ca=a.model;var h=aq[this.ca]||aq.mda;this.Na=h[0];this.Yc=a.memory||0;this.Uc=a.switches;this.ba=a.mode;if(null==this.ba||null==bq[this.ba])this.ba=h[1];this.Gb=a.charCols;this.lc=a.charRows;if(void 0===this.Gb||void 0===this.lc)this.Gb=bq[this.ba][0],this.lc=bq[this.ba][1];this.X=a.screenWidth;this.ja=a.screenHeight;this.Pc=a.scale;this.pd=12<=Math.round(this.X/this.Gb);this.M=b;this.J=c;this.F=(this.Lf=d)||b||null;
this.Xb=a.screenColor||"black";this.Tc=(1-(Ja("flicker")||a.flicker||0)).toString();this.Db=!1;b&&(b.style.backgroundColor=this.Xb);e&&(e.style.backgroundColor=this.Xb);b=a.smoothing;(c=Ja("smoothing"))&&(b="true"==c);null!=b&&(g=Ga(this.J,"imageSmoothingEnabled"))&&(this.J[g]=b);this.Vc=a.touchScreen;this.mc=cq;this.K=null;this.od=a.autoLock;this.bb=this.Hb=0;this.qa=[];this.fa=Array(this.Na==Zn?256:16);this.Ga=!1;if(this.N=e)if(g=Ga(e,"requestFullscreen")||Ga(e,"requestFullScreen")){this.N.A=e[g];
if(e=Ga(document,"on","fullscreenchange")){var k=Ga(document,"fullscreenElement")||Ga(document,"fullScreenElement");document.addEventListener(e,function(){dq(f,!!k)},!1)}(e=Ga(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){dq(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Xf(!0)},this.F.onblur=function(){return f.Xf(!1)},this.F.Nd=(g=Ga(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Ga(this.F,"exitPointerLock"))&&this.F[g],this.F.Nd)){var m=Ga(document,
"pointerLockElement");(e=Ga(document,"on","pointerlockchange"))&&document.addEventListener(e,function(){f.cf(!(!m||document[m]!==f.F))},!1)}(this.xa=a.fontROM)&&"json"!=ka(this.xa)&&(this.xa=za()+"/api/v1/dump?file="+this.xa+"&format=bytes")}ba(W,u);l=W.prototype;
if(e=Ga(document,"on","fullscreenchange")){var k=Ga(document,"fullscreenElement")||Ga(document,"fullScreenElement");document.addEventListener(e,function(){dq(f,!!k)},!1)}(e=Ga(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){dq(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Xf(!0)},this.F.onblur=function(){return f.Xf(!1)},this.F.Nd=(g=Ga(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Ga(this.F,"exitPointerLock"))&&this.F[g],this.F.Nd&&(e=Ga(document,"on",
"pointerlockchange")))){var m=Ga(document,"pointerLockElement");document.addEventListener(e,function(){f.cf(!(!m||document[m]!==f.F))},!1)}(this.xa=a.fontROM)&&"json"!=ka(this.xa)&&(this.xa=za()+"/api/v1/dump?file="+this.xa+"&format=bytes")}ba(W,u);l=W.prototype;
l.kc=function(a,b,c,d){var e=this;this.ma=b;this.S=c;this.Da=d;c=(c=aq[this.ca])&&c[0];c!==eq&&(mc(b,this,fq),oc(b,this,gq));c!==hq&&(mc(b,this,iq),oc(b,this,jq));this.Na>=Xn&&(mc(b,this,kq),oc(b,this,lq));this.Na==Zn&&(mc(b,this,mq),oc(b,this,nq));if((this.C=yb(a,"Keyboard"))&&this.M){for(var f in this.ia)0<f.indexOf("lock")&&this.C.Ab("led",f,this.ia[f]);this.C.Ab(this.Lf?"textarea":"canvas","screen",this.F)}this.vb=9;(this.V=yb(a,"ChipSet"))&&this.Uc&&this.Na==Xn&&(this.vb=Aj(this.Uc,this.vb));
"mouse"==this.Vc?(this.K=yb(a,"Mouse"))&&oq(this,pq):"keygrid"==this.Vc&&this.C&&oq(this,qq);if(this.xa){var g="Loading "+this.xa+"...";xa(this.xa,null,!0,function(a,b,c){rq(e,a,b,c)},function(){e.tb(g,nb.ce)})}};
l.Ab=function(a,b,c){var d=this;if(!this.ia[b])switch(this.ia[b]=c,b){case "fullScreen":return this.N&&this.N.A?c.onclick=function(){if(d.N){if(d.N.A){var a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=d.X/d.ja;b>c&&(a=Math.round(c/b*100)+"%")}d.Oc?(d.M.style.width=a,d.M.style.width=a,d.M.style.display="block",d.M.style.margin="auto"):(d.N.style.width=a,d.N.style.height="auto");d.N.style.backgroundColor=d.Xb;d.N.A()}d.F&&d.F.focus()}}:c.parentNode.removeChild(c),