Make PC8080's soft CAPS-LOCK control work

This commit is contained in:
Jeff Parsons 2017-01-30 15:44:43 -08:00 • committed by Jeff Parsons
commit 5a19249d28
3 changed files with 26 additions and 16 deletions

View file

@ -55,7 +55,7 @@ e[c]&255,d.ma[f++]=e[c]>>8&255,d.ma[f++]=e[c]>>16&255,d.ma[f++]=e[c]>>24&255;els
function Ia(){return"http://"+(window?window.location.host:"www.pcjs.org")}function Va(){return window?window.navigator.userAgent:""}function Wa(){if(null==Xa){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}Xa=a}return Xa}function Ya(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function bb(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function cb(a){if(window){var b=Va();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function db(a){if(!eb){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," "))}eb=c}return eb[a]}
function fb(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}function gb(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 hb(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}
function ib(a){jb.init.push(a)}function kb(a){if(mb)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){ha("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.",void 0,void 0)}}function nb(a){!mb&&a?(mb=!0,ob&&pb("init"),qb&&pb("show")):mb=a}function pb(a){jb[a]&&kb(jb[a])}var eb=null,jb={init:[],show:[],exit:[]},ob=!1,qb=!1,mb=!0,Xa=null;hb("onload",function(){ob=!0;kb(jb.init)});hb("onpageshow",function(){qb=!0;kb(jb.show)});
function ib(a){jb.init.push(a)}function kb(a){if(lb)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){ha("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.",void 0,void 0)}}function nb(a){!lb&&a?(lb=!0,ob&&pb("init"),qb&&pb("show")):lb=a}function pb(a){jb[a]&&kb(jb[a])}var eb=null,jb={init:[],show:[],exit:[]},ob=!1,qb=!1,lb=!0,Xa=null;hb("onload",function(){ob=!0;kb(jb.init)});hb("onpageshow",function(){qb=!0;kb(jb.show)});
hb(cb("Opera")||cb("iOS")?"onunload":"onbeforeunload",function(){kb(jb.exit)});
var rb="undefined"!==typeof ArrayBuffer,sb=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1],tb={cpu:1,bus:64,mem:128,port:256,nvr:16384,chipset:32768,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};function vb(a){n.call(this,"Panel",a)}aa(vb,n);
@ -146,7 +146,7 @@ r+=String.fromCharCode(v)}be(a,r);break;default:c=!1}c?Jd.call(d):e&&(a.i("\nCP/
function de(a){n.call(this,"Keyboard",a,65536);(a=a.model)&&!ee[a]&&ha("Unrecognized Keyboard8080 model: "+a);this.b=ee[a]||{};this.reset();ta(this)}aa(de,n);k=de.prototype;
k.ca=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.P[e]){if("led"==a&&this.b.fb[b])return this.P[e]=c,!0;switch(b){case "kbd":case "screen":return cb("iOS")?(c.onkeypress=function(a){var b=!1;if(a=d.b.sb[a.keyCode||a.charCode]){a&128&&(a&=127,b=!0);var c;a:{for(c in d.b.Sa)if(d.b.Sa[c]==a){c=+c;break a}c=0}c&&(b?fe(d,16,!0,!0):fe(d,16,!1),fe(d,c,!0,!0))}return!0},c.onkeydown=function(a){return ge(d,a,!0)},c.onkeyup=function(a){return ge(d,a,!1)}):(c.onkeydown=function(a){return he(d,a,!0)},
c.onkeyup=function(a){return he(d,a,!1)},c.onkeypress=function(a){a=a.keyCode||a.charCode;a>=m.ab&&a<=m.wb?d.g&(De|Ee)||(d.g|=Ee,fe(d,20,!0),Fe(d)):a>=m.yc&&a<=m.z&&d.g&Ee&&(d.g&=~Ee,fe(d,20,!1),Fe(d));return!0}),c.onpaste=function(a){a:{if(d.C&&d.C.Ra&&(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a=a.clipboardData||window.clipboardData)){Ge(d.C,a.getData("Text"));a=!1;break a}a=!0}return a},!0;default:if(this.b.Ua&&void 0!==this.b.Ua[b])return this.P[e]=c,c.onclick=
function(a,b){return function(d){d.preventDefault&&d.preventDefault();d=!0;var e=17!=b;if(!e){c.style.fontWeight="normal";if(d=!(a.g&He))c.style.fontWeight="bold";Ie(a,b,d)}fe(a,b,d,e);a.R&&a.R.Za()}}(this,this.b.Ua[b]),!0}}return!1};k.Ea=function(a,b,c,d){this.R=a;this.u=c;this.K=d;var e=this;this.L=Ic(this.u,function(){Je(e)});this.W=wb(a,"ChipSet");this.C=wb(a,"SerialPort");Ob(b,this,this.b.Bb);Sb(b,this,this.b.Cb)};
function(a,b){return function(d){d.preventDefault&&d.preventDefault();d=!0;var e=0;17==b?e=He:20==b&&(e=Ee);if(e){c.style.fontWeight="normal";if(d=!(a.g&e))c.style.fontWeight="bold";Ie(a,b,d)}fe(a,b,d,!e);a.R&&a.R.Za()}}(this,this.b.Ua[b]),!0}}return!1};k.Ea=function(a,b,c,d){this.R=a;this.u=c;this.K=d;var e=this;this.L=Ic(this.u,function(){Je(e)});this.W=wb(a,"ChipSet");this.C=wb(a,"SerialPort");Ob(b,this,this.b.Bb);Sb(b,this,this.b.Cb)};
k.va=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};k.ua=function(a){return a?this.save():!0};k.reset=function(){this.j=[];this.g=0;this.b.INIT&&!this.restore(this.b.INIT)&&this.aa("reset error")};k.save=function(){var a=new Vc(this);switch(this.b.pa){case K.pa:a.set(0,[this.D,this.B,this.A,this.F,-1])}return a.data()};
k.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.b.pa){case Ke.pa:return!0;case K.pa:return this.D=b[0],Fe(this,this.D&K.Ba.ec),this.B=b[1],this.A=b[2],this.F=b[3],this.w=b[4],!0}return!1};function Fe(a,b){var c;null!=b?a.I=b:b=a.I;for(var d in a.b.fb)if(c="led-"+d,c=a.P[c]){var e=a.b.fb[d],f=!!(b&e);e&e-1&&(f=!(b&~e));c.style.backgroundColor=f?"#"+t(16711680,6):"#000000"}if(c=a.P["led-caps-lock"])c.style.backgroundColor=a.g&Ee?"#"+t(65280,6):"#000000"}
function Ie(a,b,c,d){var e=0;switch(b){case 16:e=d?Le:Me;break;case 17:e=d?Ne:He;break;case 18:e=d?Oe:Pe;break;case 91:e=d?Qe:Re;break;case 20:e=Ee,c=!(a.g&e)}e&&(a.g=c?a.g|e:a.g&~e);return c}
@ -249,7 +249,7 @@ else{var dd=eg(a,Ag);if(dd)for(var ed=2;ed<f.length;ed++){var nc=Qf(a,f[ed]);if(
case "h":a:{var pe;if(a.G.ka)pe="halting",a.da();else{if(va(a,!0))break a;pe="already halted"}c||a.i(pe)}break;case "i":if("if"==f[0]){var qe;var oc=b.substr(2),oc=Oa(oc);Qf(a,oc)?(c||a.i("true: "+oc),qe=!0):(c||a.i("false: "+oc),qe=!1);qe||(d=!1);break}if("int"==f[0]){var fd;var ui=f[1];if(a.u.N&512){var re=Qf(a,ui);null==re?fd=!1:(a.i("requesting interrupt level "+re),Ed(a.u,re),fd=!0)}else a.i("interrupts disabled (use rif=1 to enable)"),fd=!1;fd||(d=!1);break}var se=f[1];if(se&&"?"!=se){var te=
Sf(a,se);if(void 0!==te){var vi=Pb(a.H,te);a.i(x(te)+": "+Ea(vi))}}else a.i("input commands:"),a.i("\ti [p]\tread port [p]"),a.i("warning: port accesses can affect hardware state");break;case "k":var wi=f[0];if("?"==f[1])a.i("stack trace commands:"),a.i("\tk\tshow frame addresses"),a.i("\tks\tshow symbol information");else{var ue=0,Cg=Zf(),pc=Zf(a.u.M);for(a.i("stack trace for "+kg(pc.J));10>ue;){for(var ub=null,xi=256;65536>pc.J>>>0;){Cg.J=a.Gb(pc,2);if(null==pc.J||!xi--)break;for(var yi=a,gd=Cg,
Dg=null,qc=gd.J,Eg=qc,ve=1;6>=ve&&qc;ve++){if(2<ve){gd.J=qc;var hd=lh(yi,gd);if(0<=hd.indexOf("CALL")){var Fg=hd.indexOf(" ");if(qc+(hd.indexOf(" ",Fg+1)-Fg-1)/2==Eg){Dg=hd;break}}}qc--}gd.J=Eg;if(ub=Dg)break}if(!ub||null==ub)break;var Gg=null;if("ks"==wi){var Hg=ub.match(/[0-9A-F]+$/);Hg&&(Gg=Jh(a,Hg[0]))}ub=La(ub,50)+" ;"+(Gg||"stack="+kg(pc.J));a.i(ub);ue++}ue||a.i("no return addresses found")}break;case "l":"ln"==f[0]&&Jh(a,f[1],!0);break;case "m":a:{var $a,ab=null,ba=f[1];"?"==ba&&(ba=void 0);
if(void 0!==ba){var lb=0;if("all"==ba)lb=1878917119,ba=null;else if("on"==ba)ab=!0,ba=null;else if("off"==ba)ab=!1,ba=null;else{"keys"==ba&&(ba="key");"kbd"==ba&&(ba="keyboard");for($a in tb)if(ba==$a){lb=tb[$a];ab=!!(a.ha&lb);break}if(!lb){a.i("unknown message category: "+ba);break a}}if(lb)if("on"==f[2])a.ha|=lb,ab=!0;else if("off"==f[2]&&(a.ha&=~lb,ab=!1,1073741824==lb)){for(var we=0;we<a.X.length;we++)a.i(a.X[we]);a.X=[]}}var zi=0,rc="";for($a in tb)if(!ba||ba==$a){var Ai=!!(a.ha&tb[$a]);if(null===
if(void 0!==ba){var mb=0;if("all"==ba)mb=1878917119,ba=null;else if("on"==ba)ab=!0,ba=null;else if("off"==ba)ab=!1,ba=null;else{"keys"==ba&&(ba="key");"kbd"==ba&&(ba="keyboard");for($a in tb)if(ba==$a){mb=tb[$a];ab=!!(a.ha&mb);break}if(!mb){a.i("unknown message category: "+ba);break a}}if(mb)if("on"==f[2])a.ha|=mb,ab=!0;else if("off"==f[2]&&(a.ha&=~mb,ab=!1,1073741824==mb)){for(var we=0;we<a.X.length;we++)a.i(a.X[we]);a.X=[]}}var zi=0,rc="";for($a in tb)if(!ba||ba==$a){var Ai=!!(a.ha&tb[$a]);if(null===
ab||ab==Ai)rc&&(rc+=","),++zi%10||(rc+="\n\t"),"key"==$a&&($a="keys"),rc+=$a}void 0===ba&&a.i("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.i((null!==ab?ab?"messages on: ":"messages off: ":"message categories:\n\t")+(rc||"none"));ag(a)}break;case "o":var xe=f[1],Bi=f[2];if(xe&&"?"!=xe){var ye=Sf(a,xe,"port #"),ze=Sf(a,Bi);void 0!==ye&&void 0!==ze&&(Tb(a.H,ye,ze),a.i(x(ye)+": "+Ea(ze)))}else a.i("output commands:"),a.i("\to [p] [b]\twrite byte [b] to port [p]"),a.i("warning: port accesses can affect hardware state");
break;case "p":if("print"==f[0]){Lh(a,b.substr(5));break}var Ig="pr"==f[0]?1:0,Ci=1+Ig;if(a.M)a.i("step in progress");else{var Ae=Zf(a.u.j);switch(a.Ga(Ae)){case 205:a.M=Ci,gg(Ae,3)}a.M?(a.Pa(a.j,Ae,!0),ch(a)||(a.R&&a.R.Za(),a.M=0)):Mh(a,Ig?"tr":"t")}break;case "r":if("reset"==b){a.R&&a.R.reset();break}eh(a,f);break;case "s":Kh(a,f);break;case "t":Mh(a,f[0],f[1]);break;case "u":fh(a,f[1],f[2],8);break;case "v":if("var"==f[0]){Ih(a,b.substr(3))||(d=!1);break}a.i("PC8080 version 1.32.2 ("+a.u.xb+",RELEASE"+
(rb?",TYPEDARRAYS":",LONGARRAYS")+")");a.i(Va());break;case "?":if(f[1]){Lh(a,b.substr(1));break}var Be="commands:",Ce;for(Ce in Oh)Be+="\n"+La(Ce,9)+Oh[Ce];Fd(a)||(Be+="\nnote: frequency/history disabled if no exec breakpoints");a.i(Be);break;default:a.i("unknown command: "+b),d=!1}}}catch(Kg){a.i("debugger error: "+(Kg.stack||Kg.message)),d=!1}return d}function Ac(a,b,c){b=a.Ab(b,c);for(var d in b)if(!kh(a,b[+d]))return!1;return!0}