399 lines
44 KiB
Plaintext
399 lines
44 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>GridInit</span><span class=cF0>()
|
||
|
<a name="l2"></a>{</span><span class=cF2>//Init mouse grid struct. See </span><a href="/Wb/Demo/Graphics/Grid.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/Grid.HC</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l3"></a> </span><span class=cFB>ms_grid</span><span class=cF0>.x=</span><span class=cFB>ms_grid</span><span class=cF0>.y=</span><span class=cFB>ms_grid</span><span class=cF0>.z=8;
|
||
|
<a name="l4"></a> </span><span class=cFB>ms_grid</span><span class=cF0>.x_offset=</span><span class=cFB>ms_grid</span><span class=cF0>.y_offset=</span><span class=cFB>ms_grid</span><span class=cF0>.z_offset=0;
|
||
|
<a name="l5"></a> </span><span class=cFB>ms_grid</span><span class=cF0>.x_speed =</span><span class=cFB>ms_grid</span><span class=cF0>.y_speed =</span><span class=cFB>ms_grid</span><span class=cF0>.z_speed =1;
|
||
|
<a name="l6"></a> </span><span class=cFB>ms_grid</span><span class=cF0>.show=</span><span class=cFB>ms_grid</span><span class=cF0>.snap=</span><span class=cFB>ms_grid</span><span class=cF0>.coord=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l7"></a>}
|
||
|
<a name="l8"></a>
|
||
|
<a name="l9"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MsUpdate</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z,</span><span class=cF1>Bool</span><span class=cF0> l,</span><span class=cF1>Bool</span><span class=cF0> r)
|
||
|
<a name="l10"></a>{
|
||
|
<a name="l11"></a> </span><span class=cFB>ms</span><span class=cF0>.presnap.x=</span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.scale.x*x)+</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x;
|
||
|
<a name="l12"></a> </span><span class=cFB>ms</span><span class=cF0>.presnap.y=</span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.scale.y*y)+</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y;
|
||
|
<a name="l13"></a> </span><span class=cFB>ms</span><span class=cF0>.presnap.z=</span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.scale.z*z)+</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.z;
|
||
|
<a name="l14"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_grid</span><span class=cF0>.snap) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l15"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.x=</span><span class=cF5>Trunc</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.presnap.x/</span><span class=cFB>ms_grid</span><span class=cF0>.x)*</span><span class=cFB>ms_grid</span><span class=cF0>.x+</span><span class=cFB>ms_grid</span><span class=cF0>.x_offset;
|
||
|
<a name="l16"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.y=</span><span class=cF5>Trunc</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.presnap.y/</span><span class=cFB>ms_grid</span><span class=cF0>.y)*</span><span class=cFB>ms_grid</span><span class=cF0>.y+</span><span class=cFB>ms_grid</span><span class=cF0>.y_offset;
|
||
|
<a name="l17"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.z=</span><span class=cF5>Trunc</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.presnap.z/</span><span class=cFB>ms_grid</span><span class=cF0>.z)*</span><span class=cFB>ms_grid</span><span class=cF0>.z+</span><span class=cFB>ms_grid</span><span class=cF0>.z_offset;
|
||
|
<a name="l18"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l19"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.x=</span><span class=cFB>ms</span><span class=cF0>.presnap.x;
|
||
|
<a name="l20"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.y=</span><span class=cFB>ms</span><span class=cF0>.presnap.y;
|
||
|
<a name="l21"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.z=</span><span class=cFB>ms</span><span class=cF0>.presnap.z;
|
||
|
<a name="l22"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l23"></a>
|
||
|
<a name="l24"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.x=</span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.pos.x,0,</span><span class=cF3>GR_WIDTH</span><span class=cF0>-1);
|
||
|
<a name="l25"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.y=</span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.pos.y,0,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-1);
|
||
|
<a name="l26"></a> </span><span class=cFB>ms</span><span class=cF0>.pos_text.x=</span><span class=cFB>ms</span><span class=cF0>.pos.x/</span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
|
||
|
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms</span><span class=cF0>.pos_text.x>=</span><span class=cFB>text</span><span class=cF0>.cols) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l28"></a> </span><span class=cFB>ms</span><span class=cF0>.pos_text.x=</span><span class=cFB>text</span><span class=cF0>.cols-1;
|
||
|
<a name="l29"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.x=</span><span class=cFB>text</span><span class=cF0>.cols*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>-1;
|
||
|
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l31"></a> </span><span class=cFB>ms</span><span class=cF0>.pos_text.y=</span><span class=cFB>ms</span><span class=cF0>.pos.y/</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>;
|
||
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms</span><span class=cF0>.pos_text.y>=</span><span class=cFB>text</span><span class=cF0>.rows) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l33"></a> </span><span class=cFB>ms</span><span class=cF0>.pos_text.y=</span><span class=cFB>text</span><span class=cF0>.rows-1;
|
||
|
<a name="l34"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.y=</span><span class=cFB>text</span><span class=cF0>.rows*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>-1;
|
||
|
<a name="l35"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l36"></a> </span><span class=cFB>ms</span><span class=cF0>.lb=l;
|
||
|
<a name="l37"></a> </span><span class=cFB>ms</span><span class=cF0>.rb=r;
|
||
|
<a name="l38"></a> </span><span class=cF5>LBEqu</span><span class=cF0>(&</span><span class=cFB>kbd</span><span class=cF0>.scan_code,</span><span class=cF3>SCf_MS_L_DOWN</span><span class=cF0>,</span><span class=cFB>ms</span><span class=cF0>.lb);
|
||
|
<a name="l39"></a> </span><span class=cF5>LBEqu</span><span class=cF0>(&</span><span class=cFB>kbd</span><span class=cF0>.scan_code,</span><span class=cF3>SCf_MS_R_DOWN</span><span class=cF0>,</span><span class=cFB>ms</span><span class=cF0>.rb);
|
||
|
<a name="l40"></a>}
|
||
|
<a name="l41"></a>
|
||
|
<a name="l42"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MsSet</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> x=</span><span class=cF3>I64_MAX</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> y=</span><span class=cF3>I64_MAX</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> z=</span><span class=cF3>I64_MAX</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> l=</span><span class=cF3>I64_MAX</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> r=</span><span class=cF3>I64_MAX</span><span class=cF0>)
|
||
|
<a name="l43"></a>{</span><span class=cF2>//Note: Generates a message. See </span><a href="/Wb/Demo/Games/Zing.HC.HTML#l97"><span class=cF4>MsSet</span></a><span class=cF2>().</span><span class=cF0>
|
||
|
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<=x<</span><span class=cF3>GR_WIDTH</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l45"></a> x=</span><span class=cFB>ms</span><span class=cF0>.pos.x;
|
||
|
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<=y<</span><span class=cF3>GR_HEIGHT</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l47"></a> y=</span><span class=cFB>ms</span><span class=cF0>.pos.y;
|
||
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (z==</span><span class=cF3>I64_MAX</span><span class=cF0>)
|
||
|
<a name="l49"></a> z=</span><span class=cFB>ms</span><span class=cF0>.pos.z;
|
||
|
<a name="l50"></a>
|
||
|
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF3>FALSE</span><span class=cF0><=l<=</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l52"></a> l=</span><span class=cFB>ms</span><span class=cF0>.lb;
|
||
|
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF3>FALSE</span><span class=cF0><=r<=</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l54"></a> r=</span><span class=cFB>ms</span><span class=cF0>.rb;
|
||
|
<a name="l55"></a>
|
||
|
<a name="l56"></a> x=(x-</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x)/</span><span class=cFB>ms</span><span class=cF0>.scale.x;
|
||
|
<a name="l57"></a> y=(y-</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y)/</span><span class=cFB>ms</span><span class=cF0>.scale.y;
|
||
|
<a name="l58"></a> z=(z-</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.z)/</span><span class=cFB>ms</span><span class=cF0>.scale.z;
|
||
|
<a name="l59"></a> </span><span class=cF5>MsUpdate</span><span class=cF0>(x,y,z,l,r);
|
||
|
<a name="l60"></a> </span><span class=cFD>MsHardSet</span><span class=cF0>(x,y,z,l,r);
|
||
|
<a name="l61"></a>}
|
||
|
<a name="l62"></a>
|
||
|
<a name="l63"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MsInit</span><span class=cF0>()
|
||
|
<a name="l64"></a>{
|
||
|
<a name="l65"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&</span><span class=cFB>ms</span><span class=cF0>,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMsStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l66"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&</span><span class=cFB>ms_last</span><span class=cF0>,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMsStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l67"></a> </span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x=</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y=</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.z=0;
|
||
|
<a name="l68"></a> </span><span class=cFB>ms</span><span class=cF0>.scale.x=</span><span class=cFB>ms</span><span class=cF0>.scale.y=</span><span class=cFB>ms</span><span class=cF0>.scale.z=1.0;
|
||
|
<a name="l69"></a> </span><span class=cFB>ms</span><span class=cF0>.pos_text.x=</span><span class=cFB>ms</span><span class=cF0>.pos_text.y=</span><span class=cFB>ms</span><span class=cF0>.pos_text.z=0;
|
||
|
<a name="l70"></a> </span><span class=cFB>ms</span><span class=cF0>.has_wheel=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l71"></a> </span><span class=cFB>ms</span><span class=cF0>.show=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l72"></a> </span><span class=cFB>ms</span><span class=cF0>.speed=0;
|
||
|
<a name="l73"></a> </span><span class=cFB>ms</span><span class=cF0>.timestamp=</span><span class=cF5>GetTSC</span><span class=cF0>;
|
||
|
<a name="l74"></a> </span><span class=cFB>ms</span><span class=cF0>.dbl_time=0.350;
|
||
|
<a name="l75"></a> </span><span class=cF5>GridInit</span><span class=cF0>;
|
||
|
<a name="l76"></a>}
|
||
|
<a name="l77"></a>
|
||
|
<a name="l78"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardPktRead</span><span class=cF0>()
|
||
|
<a name="l79"></a>{
|
||
|
<a name="l80"></a> </span><span class=cF1>U8</span><span class=cF0> j;
|
||
|
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GetTSC</span><span class=cF0>></span><span class=cFB>ms_hard</span><span class=cF0>.timestamp+</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq>>3)
|
||
|
<a name="l82"></a> </span><span class=cF5>FifoU8Flush</span><span class=cF0>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo);
|
||
|
<a name="l83"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.timestamp=</span><span class=cF5>GetTSC</span><span class=cF0>;
|
||
|
<a name="l84"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo,</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>KBD_PORT</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FifoU8Cnt</span><span class=cF7>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo</span><span class=cF7>)</span><span class=cF0>==</span><span class=cFB>ms_hard</span><span class=cF0>.pkt_size)
|
||
|
<a name="l86"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoU8Rem</span><span class=cF7>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo,&j</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l87"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo2,j);
|
||
|
<a name="l88"></a>}
|
||
|
<a name="l89"></a>
|
||
|
<a name="l90"></a></span><span class=cF1>interrupt</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>IRQMsHard</span><span class=cF0>()
|
||
|
<a name="l91"></a>{
|
||
|
<a name="l92"></a> </span><span class=cF1>CLD</span><span class=cF0>
|
||
|
<a name="l93"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0xA0,0x20);
|
||
|
<a name="l94"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0x20,0x20);
|
||
|
<a name="l95"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.irqs_working=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.install_in_progress || !</span><span class=cFB>ms_hard</span><span class=cF0>.installed) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l97"></a> </span><span class=cFB>kbd</span><span class=cF0>.rst=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l98"></a> </span><span class=cF1>return</span><span class=cF0>;
|
||
|
<a name="l99"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l100"></a> </span><span class=cFD>MsHardPktRead</span><span class=cF0>;
|
||
|
<a name="l101"></a>}
|
||
|
<a name="l102"></a>
|
||
|
<a name="l103"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardGetType</span><span class=cF0>()
|
||
|
<a name="l104"></a>{
|
||
|
<a name="l105"></a> </span><span class=cF9>I64</span><span class=cF0> b;
|
||
|
<a name="l106"></a> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(0xF2);
|
||
|
<a name="l107"></a> b=</span><span class=cFD>KbdCmdRead</span><span class=cF0>;
|
||
|
<a name="l108"></a> </span><span class=cF1>if</span><span class=cF0> (b==3)
|
||
|
<a name="l109"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.has_wheel=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l110"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (b==4)
|
||
|
<a name="l111"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.has_ext_bttns=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l112"></a>}
|
||
|
<a name="l113"></a>
|
||
|
<a name="l114"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>MsHardRst</span><span class=cF0>()
|
||
|
<a name="l115"></a>{
|
||
|
<a name="l116"></a> </span><span class=cF1>U8</span><span class=cF0> b,*_b;
|
||
|
<a name="l117"></a> </span><span class=cF1>F64</span><span class=cF0> timeout;
|
||
|
<a name="l118"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l119"></a>
|
||
|
<a name="l120"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.has_wheel=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l121"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.has_ext_bttns=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l122"></a>
|
||
|
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (*0x40E</span><span class=cF7>(</span><span class=cF9>U16</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>==0x9FC0) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l124"></a> _b=0x9FC00+0x30;
|
||
|
<a name="l125"></a> *_b=1; </span><span class=cF2>//This enables my mouse. It might be for one machine.</span><span class=cF0>
|
||
|
<a name="l126"></a></span><span class=cF2>//USB DMA packets, set-up by BIOS to make legacy PS/2?</span><span class=cF0>
|
||
|
<a name="l127"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l128"></a>
|
||
|
<a name="l129"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l130"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
|
||
|
<a name="l131"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xAD); </span><span class=cF2>//Disable Kbd</span><span class=cF0>
|
||
|
<a name="l132"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xA8); </span><span class=cF2>//Enable Mouse</span><span class=cF0>
|
||
|
<a name="l133"></a>
|
||
|
<a name="l134"></a> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(0xFF); </span><span class=cF2>//Rst</span><span class=cF0>
|
||
|
<a name="l135"></a>
|
||
|
<a name="l136"></a> timeout=</span><span class=cF5>tS</span><span class=cF0>+10.0;
|
||
|
<a name="l137"></a> </span><span class=cF1>do</span><span class=cF0>
|
||
|
<a name="l138"></a> </span><span class=cF1>try</span><span class=cF0> {
|
||
|
<a name="l139"></a> </span><span class=cFD>KbdCmdRead</span><span class=cF0>;
|
||
|
<a name="l140"></a> timeout=0; </span><span class=cF2>//force exit</span><span class=cF0>
|
||
|
<a name="l141"></a> } </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l142"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l143"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0><timeout);
|
||
|
<a name="l144"></a>
|
||
|
<a name="l145"></a> </span><span class=cF1>try</span><span class=cF0>
|
||
|
<a name="l146"></a> </span><span class=cFD>KbdCmdRead</span><span class=cF0>;
|
||
|
<a name="l147"></a> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l148"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l149"></a>
|
||
|
<a name="l150"></a> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(0xF3,200,0xF3,100,0xF3,80);
|
||
|
<a name="l151"></a> </span><span class=cFD>MsHardGetType</span><span class=cF0>;
|
||
|
<a name="l152"></a> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(0xF3,10);
|
||
|
<a name="l153"></a> </span><span class=cFD>MsHardGetType</span><span class=cF0>;
|
||
|
<a name="l154"></a> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(0xE8,0x03,0xE6,0xF3,100,0xF4);
|
||
|
<a name="l155"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l156"></a>
|
||
|
<a name="l157"></a> </span><span class=cF2>//Enable IRQ 12</span><span class=cF0>
|
||
|
<a name="l158"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0x20);
|
||
|
<a name="l159"></a> b=</span><span class=cFD>KbdCmdRead</span><span class=cF0>;
|
||
|
<a name="l160"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0x60);
|
||
|
<a name="l161"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,</span><span class=cF7>(</span><span class=cF0>b|2</span><span class=cF7>)</span><span class=cF0>&~0x20);
|
||
|
<a name="l162"></a>
|
||
|
<a name="l163"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l164"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l165"></a>
|
||
|
<a name="l166"></a> </span><span class=cF2>//This is been added to override failure</span><span class=cF0>
|
||
|
<a name="l167"></a> </span><span class=cF2>//because the mouse sometimes still works.</span><span class=cF0>
|
||
|
<a name="l168"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l169"></a>
|
||
|
<a name="l170"></a> </span><span class=cF1>try</span><span class=cF0>
|
||
|
<a name="l171"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xAE); </span><span class=cF2>//Enable Keyboard</span><span class=cF0>
|
||
|
<a name="l172"></a> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l173"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l174"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.has_wheel || </span><span class=cFB>ms_hard</span><span class=cF0>.has_ext_bttns)
|
||
|
<a name="l175"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pkt_size=4;
|
||
|
<a name="l176"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l177"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pkt_size=3;
|
||
|
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (!res)
|
||
|
<a name="l179"></a> </span><span class=cF1>try</span><span class=cF0>
|
||
|
<a name="l180"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xA7); </span><span class=cF2>//Disable Mouse</span><span class=cF0>
|
||
|
<a name="l181"></a> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l182"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l183"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l184"></a>}
|
||
|
<a name="l185"></a>
|
||
|
<a name="l186"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardSpeedSet</span><span class=cF0>()
|
||
|
<a name="l187"></a>{
|
||
|
<a name="l188"></a> </span><span class=cF9>I64</span><span class=cF0> dd,tmp;
|
||
|
<a name="l189"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>dd=</span><span class=cF5>SqrI64</span><span class=cF0>(</span><span class=cFB>ms_hard_last</span><span class=cF0>.pos.x-</span><span class=cFB>ms_hard</span><span class=cF0>.pos.x)
|
||
|
<a name="l190"></a> +</span><span class=cF5>SqrI64</span><span class=cF0>(</span><span class=cFB>ms_hard_last</span><span class=cF0>.pos.y-</span><span class=cFB>ms_hard</span><span class=cF0>.pos.y)</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l191"></a> </span><span class=cF7>(</span><span class=cF0>tmp=</span><span class=cFB>ms_hard</span><span class=cF0>.timestamp-</span><span class=cFB>ms_hard_last</span><span class=cF0>.timestamp</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l192"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.speed=</span><span class=cF5>Sqrt</span><span class=cF0>(dd)*</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq/tmp;
|
||
|
<a name="l193"></a> </span><span class=cFB>ms_hard_last</span><span class=cF0>.timestamp=</span><span class=cFB>ms_hard</span><span class=cF0>.timestamp;
|
||
|
<a name="l194"></a>}
|
||
|
<a name="l195"></a>
|
||
|
<a name="l196"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardSetPre</span><span class=cF0>()
|
||
|
<a name="l197"></a>{
|
||
|
<a name="l198"></a> </span><span class=cF9>I64</span><span class=cF0> old_timestamp=</span><span class=cFB>ms_hard_last</span><span class=cF0>.timestamp;
|
||
|
<a name="l199"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&</span><span class=cFB>ms_hard_last</span><span class=cF0>,&</span><span class=cFB>ms_hard</span><span class=cF0>,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMsHardStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l200"></a> </span><span class=cFB>ms_hard_last</span><span class=cF0>.timestamp=old_timestamp;
|
||
|
<a name="l201"></a>}
|
||
|
<a name="l202"></a>
|
||
|
<a name="l203"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardSetPost</span><span class=cF0>()
|
||
|
<a name="l204"></a>{
|
||
|
<a name="l205"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l206"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.x=</span><span class=cFB>ms_hard</span><span class=cF0>.prescale.x*</span><span class=cFB>ms_hard</span><span class=cF0>.scale.x*</span><span class=cFB>ms_grid</span><span class=cF0>.x_speed;
|
||
|
<a name="l207"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.y=</span><span class=cFB>ms_hard</span><span class=cF0>.prescale.y*</span><span class=cFB>ms_hard</span><span class=cF0>.scale.y*</span><span class=cFB>ms_grid</span><span class=cF0>.y_speed;
|
||
|
<a name="l208"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.z=</span><span class=cFB>ms_hard</span><span class=cF0>.prescale.z*</span><span class=cFB>ms_hard</span><span class=cF0>.scale.z*</span><span class=cFB>ms_grid</span><span class=cF0>.z_speed;
|
||
|
<a name="l209"></a>
|
||
|
<a name="l210"></a> i=</span><span class=cF5>Trunc</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.scale.x*</span><span class=cFB>ms_hard</span><span class=cF0>.pos.x/</span><span class=cFB>ms_grid</span><span class=cF0>.x)*</span><span class=cFB>ms_grid</span><span class=cF0>.x+</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x;
|
||
|
<a name="l211"></a></span><span class=cF2>//TODO ms_grid.x_offset?</span><span class=cF0>
|
||
|
<a name="l212"></a> </span><span class=cF1>if</span><span class=cF0> (i<0)
|
||
|
<a name="l213"></a> </span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x-=i;
|
||
|
<a name="l214"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i>=</span><span class=cF3>GR_WIDTH</span><span class=cF0>)
|
||
|
<a name="l215"></a> </span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.x+=</span><span class=cF3>GR_WIDTH</span><span class=cF0>-1-i;
|
||
|
<a name="l216"></a>
|
||
|
<a name="l217"></a> i=</span><span class=cF5>Trunc</span><span class=cF0>(</span><span class=cFB>ms</span><span class=cF0>.scale.y*</span><span class=cFB>ms_hard</span><span class=cF0>.pos.y/</span><span class=cFB>ms_grid</span><span class=cF0>.y)*</span><span class=cFB>ms_grid</span><span class=cF0>.y+</span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y;
|
||
|
<a name="l218"></a> </span><span class=cF1>if</span><span class=cF0> (i<0)
|
||
|
<a name="l219"></a> </span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y-=i;
|
||
|
<a name="l220"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i>=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>)
|
||
|
<a name="l221"></a> </span><span class=cFB>ms</span><span class=cF0>.</span><span class=cF1>offset</span><span class=cF0>.y+=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-1-i;
|
||
|
<a name="l222"></a>
|
||
|
<a name="l223"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.pos.x!=</span><span class=cFB>ms_hard_last</span><span class=cF0>.pos.x || </span><span class=cFB>ms_hard</span><span class=cF0>.pos.y!=</span><span class=cFB>ms_hard_last</span><span class=cF0>.pos.y ||
|
||
|
<a name="l224"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.z!=</span><span class=cFB>ms_hard_last</span><span class=cF0>.pos.z) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l225"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.evt=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l226"></a> </span><span class=cFD>MsHardSpeedSet</span><span class=cF0>;
|
||
|
<a name="l227"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l228"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<5;i++)
|
||
|
<a name="l229"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.bttns[i]!=</span><span class=cFB>ms_hard_last</span><span class=cF0>.bttns[i]) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l230"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.evt=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l231"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l233"></a>}
|
||
|
<a name="l234"></a>
|
||
|
<a name="l235"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardHndlr</span><span class=cF0>()
|
||
|
<a name="l236"></a>{
|
||
|
<a name="l237"></a> </span><span class=cF9>I64</span><span class=cF0> i,dx,dy,dz;
|
||
|
<a name="l238"></a> </span><span class=cF1>U8</span><span class=cF0> ms_buf[4];
|
||
|
<a name="l239"></a>
|
||
|
<a name="l240"></a> </span><span class=cFD>MsHardSetPre</span><span class=cF0>;
|
||
|
<a name="l241"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<4;i++)
|
||
|
<a name="l242"></a> ms_buf[i]=0;
|
||
|
<a name="l243"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<</span><span class=cFB>ms_hard</span><span class=cF0>.pkt_size;i++)
|
||
|
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FifoU8Rem</span><span class=cF7>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo2,&ms_buf[i]</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l245"></a> ms_buf[i]=0;
|
||
|
<a name="l246"></a>
|
||
|
<a name="l247"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[0] = ms_buf[0] & 1;
|
||
|
<a name="l248"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[1] = (ms_buf[0] & 2) >> 1;
|
||
|
<a name="l249"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[2] = (ms_buf[0] & 4) >> 2;
|
||
|
<a name="l250"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[3] = (ms_buf[3] & 0x10) >> 4;
|
||
|
<a name="l251"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[4] = (ms_buf[3] & 0x20) >> 5;
|
||
|
<a name="l252"></a> </span><span class=cF1>if</span><span class=cF0> (ms_buf[0] & 0x10)
|
||
|
<a name="l253"></a> dx=ms_buf[1]-256;
|
||
|
<a name="l254"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l255"></a> dx=ms_buf[1];
|
||
|
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (ms_buf[0] & 0x20)
|
||
|
<a name="l257"></a> dy=256-ms_buf[2];
|
||
|
<a name="l258"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l259"></a> dy=-ms_buf[2];
|
||
|
<a name="l260"></a> </span><span class=cF1>if</span><span class=cF0> (ms_buf[3] & 0x08)
|
||
|
<a name="l261"></a> dz=ms_buf[3]&7-8;
|
||
|
<a name="l262"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l263"></a> dz=ms_buf[3]&7;
|
||
|
<a name="l264"></a>
|
||
|
<a name="l265"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.x+=dx;
|
||
|
<a name="l266"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.y+=dy;
|
||
|
<a name="l267"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.z+=dz;
|
||
|
<a name="l268"></a>
|
||
|
<a name="l269"></a> </span><span class=cFD>MsHardSetPost</span><span class=cF0>;
|
||
|
<a name="l270"></a>}
|
||
|
<a name="l271"></a>
|
||
|
<a name="l272"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MsHardSet</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z,</span><span class=cF9>I64</span><span class=cF0> l,</span><span class=cF9>I64</span><span class=cF0> r)
|
||
|
<a name="l273"></a>{
|
||
|
<a name="l274"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.timestamp=</span><span class=cF5>GetTSC</span><span class=cF0>;
|
||
|
<a name="l275"></a> </span><span class=cFD>MsHardSetPre</span><span class=cF0>;
|
||
|
<a name="l276"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.x=x/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.x/</span><span class=cFB>ms_grid</span><span class=cF0>.x_speed;
|
||
|
<a name="l277"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.y=y/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.y/</span><span class=cFB>ms_grid</span><span class=cF0>.y_speed;
|
||
|
<a name="l278"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.z=z/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.z/</span><span class=cFB>ms_grid</span><span class=cF0>.z_speed;
|
||
|
<a name="l279"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[0]=l;
|
||
|
<a name="l280"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[1]=r;
|
||
|
<a name="l281"></a> </span><span class=cFD>MsHardSetPost</span><span class=cF0>;
|
||
|
<a name="l282"></a>}
|
||
|
<a name="l283"></a>
|
||
|
<a name="l284"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdMsRst</span><span class=cF0>()
|
||
|
<a name="l285"></a>{
|
||
|
<a name="l286"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
|
||
|
<a name="l287"></a> </span><span class=cF5>FifoU8Flush</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2);
|
||
|
<a name="l288"></a> </span><span class=cF5>FifoU8Flush</span><span class=cF0>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo2);
|
||
|
<a name="l289"></a> </span><span class=cF5>FifoI64Flush</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.scan_code_fifo);
|
||
|
<a name="l290"></a> </span><span class=cFB>kbd</span><span class=cF0>.scan_code=0;
|
||
|
<a name="l291"></a> </span><span class=cFB>kbd</span><span class=cF0>.rst=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l292"></a>}
|
||
|
<a name="l293"></a>
|
||
|
<a name="l294"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>MsHardDrvrInstall</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> dummy=0) </span><span class=cF2>//can be spawned</span><span class=cF0>
|
||
|
<a name="l295"></a>{
|
||
|
<a name="l296"></a> </span><span class=cF1>no_warn</span><span class=cF0> dummy;
|
||
|
<a name="l297"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l298"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.install_in_progress=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l299"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0xA1,</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF0>0xA1</span><span class=cF7>)</span><span class=cF0>|0x10);
|
||
|
<a name="l300"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.installed=</span><span class=cFB>ms_hard</span><span class=cF0>.irqs_working=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l301"></a> </span><span class=cF5>IntEntrySet</span><span class=cF0>(0x2C,&</span><span class=cFD>IRQMsHard</span><span class=cF0>);
|
||
|
<a name="l302"></a> </span><span class=cF1>for</span><span class=cF0>(i=0;i<5;i++)
|
||
|
<a name="l303"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.bttns[i]=0;
|
||
|
<a name="l304"></a> </span><span class=cF1>if</span><span class=cF0> (i=</span><span class=cFD>MsHardRst</span><span class=cF0>)
|
||
|
<a name="l305"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0xA1,</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF0>0xA1</span><span class=cF7>)</span><span class=cF0>&~0x10);
|
||
|
<a name="l306"></a> </span><span class=cFD>KbdMsRst</span><span class=cF0>;
|
||
|
<a name="l307"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.install_attempts++;
|
||
|
<a name="l308"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.installed=</span><span class=cFB>ms_hard</span><span class=cF0>.evt=i;
|
||
|
<a name="l309"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.install_in_progress=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l310"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>ms_hard</span><span class=cF0>.installed;
|
||
|
<a name="l311"></a>}
|
||
|
<a name="l312"></a>
|
||
|
<a name="l313"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>KbdMsHndlr</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> poll_kbd,</span><span class=cF1>Bool</span><span class=cF0> poll_ms)
|
||
|
<a name="l314"></a>{
|
||
|
<a name="l315"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.install_in_progress) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l316"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
||
|
<a name="l317"></a> </span><span class=cF1>return</span><span class=cF0>;
|
||
|
<a name="l318"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l319"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>kbd</span><span class=cF0>.rst)
|
||
|
<a name="l320"></a> </span><span class=cFD>KbdMsRst</span><span class=cF0>;
|
||
|
<a name="l321"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (poll_ms && </span><span class=cFB>ms_hard</span><span class=cF0>.installed && !</span><span class=cFB>ms_hard</span><span class=cF0>.irqs_working) {
|
||
|
<a name="l323"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
||
|
<a name="l324"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
||
|
<a name="l325"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>KBD_CTRL</span><span class=cF7>)</span><span class=cF0>&1)
|
||
|
<a name="l326"></a> </span><span class=cFD>MsHardPktRead</span><span class=cF0>;
|
||
|
<a name="l327"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
||
|
<a name="l328"></a> }
|
||
|
<a name="l329"></a>
|
||
|
<a name="l330"></a> </span><span class=cF1>if</span><span class=cF0> (poll_kbd)
|
||
|
<a name="l331"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>KBD_CTRL</span><span class=cF7>)</span><span class=cF0>&1)
|
||
|
<a name="l332"></a> </span><span class=cFD>KbdPktRead</span><span class=cF0>;
|
||
|
<a name="l333"></a>
|
||
|
<a name="l334"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>kbd</span><span class=cF0>.rst)
|
||
|
<a name="l335"></a> </span><span class=cFD>KbdMsRst</span><span class=cF0>;
|
||
|
<a name="l336"></a> </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l337"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoU8Cnt</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l338"></a> </span><span class=cFD>KbdHndlr</span><span class=cF0>;
|
||
|
<a name="l339"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoU8Cnt</span><span class=cF7>(</span><span class=cFB>ms_hard</span><span class=cF0>.fifo2</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.installed)
|
||
|
<a name="l341"></a> </span><span class=cFD>MsHardHndlr</span><span class=cF0>;
|
||
|
<a name="l342"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l343"></a> </span><span class=cFD>KbdMsRst</span><span class=cF0>;
|
||
|
<a name="l344"></a> }
|
||
|
<a name="l345"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l346"></a>}
|
||
|
<a name="l347"></a>
|
||
|
<a name="l348"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>KbdMsInit</span><span class=cF0>()
|
||
|
<a name="l349"></a>{
|
||
|
<a name="l350"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&</span><span class=cFB>kbd</span><span class=cF0>,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CKbdStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l351"></a> </span><span class=cFB>kbd</span><span class=cF0>.fifo=</span><span class=cF5>FifoU8New</span><span class=cF0>(8);
|
||
|
<a name="l352"></a> </span><span class=cFB>kbd</span><span class=cF0>.fifo2=</span><span class=cF5>FifoU8New</span><span class=cF0>(0x1000);
|
||
|
<a name="l353"></a> </span><span class=cFB>kbd</span><span class=cF0>.scan_code_fifo=</span><span class=cF5>FifoI64New</span><span class=cF0>(0x1000);
|
||
|
<a name="l354"></a> </span><span class=cFB>kbd</span><span class=cF0>.irqs_working=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l355"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&</span><span class=cFB>ms_hard</span><span class=cF0>,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMsHardStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l356"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.fifo=</span><span class=cF5>FifoU8New</span><span class=cF0>(8);
|
||
|
<a name="l357"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.fifo2=</span><span class=cF5>FifoU8New</span><span class=cF0>(0x1000);
|
||
|
<a name="l358"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.scale.x=0.5;
|
||
|
<a name="l359"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.scale.y=0.5;
|
||
|
<a name="l360"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.scale.z=1.0;
|
||
|
<a name="l361"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.x=</span><span class=cF3>GR_WIDTH</span><span class=cF0>/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.x/2.0;
|
||
|
<a name="l362"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.y=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.y/2.0;
|
||
|
<a name="l363"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.prescale.z=0/</span><span class=cFB>ms_hard</span><span class=cF0>.scale.z;
|
||
|
<a name="l364"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.x=</span><span class=cF3>GR_WIDTH</span><span class=cF0>>>1;
|
||
|
<a name="l365"></a> </span><span class=cFB>ms_hard</span><span class=cF0>.pos.y=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>>>1;
|
||
|
<a name="l366"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&</span><span class=cFB>ms_hard_last</span><span class=cF0>,&</span><span class=cFB>ms_hard</span><span class=cF0>,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CMsHardStateGlbls</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l367"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|