208 lines
16 KiB
Plaintext
208 lines
16 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=cF0>#</span><span class=cF1>define</span><span class=cF0> M_DASH_THRESHOLD 0.140
|
||
|
<a name="l2"></a>#</span><span class=cF1>define</span><span class=cF0> M_SPACE_THRESHOLD 0.300
|
||
|
<a name="l3"></a>
|
||
|
<a name="l4"></a></span><span class=cF1>U8</span><span class=cF0> *morse_lst=
|
||
|
<a name="l5"></a>
|
||
|
<a name="l6"></a></span><span class=cF6>"A.-\0"</span><span class=cF0>
|
||
|
<a name="l7"></a></span><span class=cF6>"B-...\0"</span><span class=cF0>
|
||
|
<a name="l8"></a></span><span class=cF6>"C-.-.\0"</span><span class=cF0>
|
||
|
<a name="l9"></a></span><span class=cF6>"D-..\0"</span><span class=cF0>
|
||
|
<a name="l10"></a></span><span class=cF6>"E.\0"</span><span class=cF0>
|
||
|
<a name="l11"></a></span><span class=cF6>"F..-.\0"</span><span class=cF0>
|
||
|
<a name="l12"></a></span><span class=cF6>"G--.\0"</span><span class=cF0>
|
||
|
<a name="l13"></a></span><span class=cF6>"H....\0"</span><span class=cF0>
|
||
|
<a name="l14"></a></span><span class=cF6>"I..\0"</span><span class=cF0>
|
||
|
<a name="l15"></a></span><span class=cF6>"J.---\0"</span><span class=cF0>
|
||
|
<a name="l16"></a></span><span class=cF6>"K-.-\0"</span><span class=cF0>
|
||
|
<a name="l17"></a></span><span class=cF6>"L.-..\0"</span><span class=cF0>
|
||
|
<a name="l18"></a></span><span class=cF6>"M--\0"</span><span class=cF0>
|
||
|
<a name="l19"></a></span><span class=cF6>"N-.\0"</span><span class=cF0>
|
||
|
<a name="l20"></a></span><span class=cF6>"O---\0"</span><span class=cF0>
|
||
|
<a name="l21"></a></span><span class=cF6>"P.--.\0"</span><span class=cF0>
|
||
|
<a name="l22"></a></span><span class=cF6>"Q--.-\0"</span><span class=cF0>
|
||
|
<a name="l23"></a></span><span class=cF6>"R.-.\0"</span><span class=cF0>
|
||
|
<a name="l24"></a></span><span class=cF6>"S...\0"</span><span class=cF0>
|
||
|
<a name="l25"></a></span><span class=cF6>"T-\0"</span><span class=cF0>
|
||
|
<a name="l26"></a></span><span class=cF6>"U..-\0"</span><span class=cF0>
|
||
|
<a name="l27"></a></span><span class=cF6>"V...-\0"</span><span class=cF0>
|
||
|
<a name="l28"></a></span><span class=cF6>"W.--\0"</span><span class=cF0>
|
||
|
<a name="l29"></a></span><span class=cF6>"X-..-\0"</span><span class=cF0>
|
||
|
<a name="l30"></a></span><span class=cF6>"Y-.--\0"</span><span class=cF0>
|
||
|
<a name="l31"></a></span><span class=cF6>"Z--..\0"</span><span class=cF0>
|
||
|
<a name="l32"></a>
|
||
|
<a name="l33"></a></span><span class=cF6>"1.----\0"</span><span class=cF0>
|
||
|
<a name="l34"></a></span><span class=cF6>"2..---\0"</span><span class=cF0>
|
||
|
<a name="l35"></a></span><span class=cF6>"3...--\0"</span><span class=cF0>
|
||
|
<a name="l36"></a></span><span class=cF6>"4....-\0"</span><span class=cF0>
|
||
|
<a name="l37"></a></span><span class=cF6>"5.....\0"</span><span class=cF0>
|
||
|
<a name="l38"></a></span><span class=cF6>"6-....\0"</span><span class=cF0>
|
||
|
<a name="l39"></a></span><span class=cF6>"7--...\0"</span><span class=cF0>
|
||
|
<a name="l40"></a></span><span class=cF6>"8---..\0"</span><span class=cF0>
|
||
|
<a name="l41"></a></span><span class=cF6>"9----.\0"</span><span class=cF0>
|
||
|
<a name="l42"></a></span><span class=cF6>"0-----\0"</span><span class=cF0>
|
||
|
<a name="l43"></a>
|
||
|
<a name="l44"></a></span><span class=cF6>"/-..-.\0"</span><span class=cF0>
|
||
|
<a name="l45"></a></span><span class=cF6>"+.-.-.\0"</span><span class=cF0>
|
||
|
<a name="l46"></a></span><span class=cF6>"..-.-.-\0"</span><span class=cF0>
|
||
|
<a name="l47"></a></span><span class=cF6>",--..--\0"</span><span class=cF0>
|
||
|
<a name="l48"></a></span><span class=cF6>"?..--..\0"</span><span class=cF0>
|
||
|
<a name="l49"></a></span><span class=cF6>"(-.--.\0"</span><span class=cF0>
|
||
|
<a name="l50"></a></span><span class=cF6>")-.--.-\0"</span><span class=cF0>
|
||
|
<a name="l51"></a></span><span class=cF6>"--....-\0"</span><span class=cF0>
|
||
|
<a name="l52"></a></span><span class=cF6>"\".-..-.\0"</span><span class=cF0>
|
||
|
<a name="l53"></a></span><span class=cF6>"_..--.-\0"</span><span class=cF0>
|
||
|
<a name="l54"></a></span><span class=cF6>"'.----.\0"</span><span class=cF0>
|
||
|
<a name="l55"></a></span><span class=cF6>":---...\0"</span><span class=cF0>
|
||
|
<a name="l56"></a></span><span class=cF6>";-.-.-.\0"</span><span class=cF0>
|
||
|
<a name="l57"></a></span><span class=cF6>"=-...-\0"</span><span class=cF0>;
|
||
|
<a name="l58"></a>
|
||
|
<a name="l59"></a></span><span class=cF1>U0</span><span class=cF0> MorseTable()
|
||
|
<a name="l60"></a>{
|
||
|
<a name="l61"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
||
|
<a name="l62"></a> </span><span class=cF9>I64</span><span class=cF0> i=0;
|
||
|
<a name="l63"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<13;i++ ) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (st=</span><span class=cF5>LstSub</span><span class=cF7>(</span><span class=cF0>i,morse_lst</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l65"></a> </span><span class=cF6>"$RED$%C$FG$ %-7s "</span><span class=cF0>,*st,st+1;
|
||
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (st=</span><span class=cF5>LstSub</span><span class=cF7>(</span><span class=cF0>i+13,morse_lst</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l67"></a> </span><span class=cF6>"$RED$%C$FG$ %-7s "</span><span class=cF0>,*st,st+1;
|
||
|
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (st=</span><span class=cF5>LstSub</span><span class=cF7>(</span><span class=cF0>i+26,morse_lst</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l69"></a> </span><span class=cF6>"$RED$%C$FG$ %-7s "</span><span class=cF0>,*st,st+1;
|
||
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (st=</span><span class=cF5>LstSub</span><span class=cF7>(</span><span class=cF0>i+39,morse_lst</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l71"></a> </span><span class=cF6>"$RED$%C$FG$ %-7s "</span><span class=cF0>,*st,st+1;
|
||
|
<a name="l72"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
||
|
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l74"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
||
|
<a name="l75"></a>}
|
||
|
<a name="l76"></a>
|
||
|
<a name="l77"></a></span><span class=cF1>F64</span><span class=cF0> m_start,m_end,dt_down,dt_up;
|
||
|
<a name="l78"></a></span><span class=cF1>Bool</span><span class=cF0> space_sent;
|
||
|
<a name="l79"></a>
|
||
|
<a name="l80"></a></span><span class=cF1>U8</span><span class=cF0> *MorseTimes(</span><span class=cF9>CDoc</span><span class=cF0> *,</span><span class=cF9>CDocEntry</span><span class=cF0> *,</span><span class=cF9>CTask</span><span class=cF0> *mem_task)
|
||
|
<a name="l81"></a>{
|
||
|
<a name="l82"></a> </span><span class=cF1>U8</span><span class=cF0> *st=</span><span class=cF5>MAlloc</span><span class=cF0>(64,mem_task);
|
||
|
<a name="l83"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(st,</span><span class=cF6>"Down:%10.6f Up:%10.6f"</span><span class=cF0>,dt_down,dt_up);
|
||
|
<a name="l84"></a> </span><span class=cF1>return</span><span class=cF0> st;
|
||
|
<a name="l85"></a>}
|
||
|
<a name="l86"></a>
|
||
|
<a name="l87"></a></span><span class=cF9>I64</span><span class=cF0> MorseWaitKey()
|
||
|
<a name="l88"></a>{
|
||
|
<a name="l89"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
||
|
<a name="l90"></a> </span><span class=cF1>F64</span><span class=cF0> dt;
|
||
|
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l92"></a> </span><span class=cF1>if</span><span class=cF0> (m_start) {
|
||
|
<a name="l93"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF3>NULL</span><span class=cF0>,1<<</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
|
||
|
<a name="l94"></a> m_end=</span><span class=cF5>tS</span><span class=cF0>;
|
||
|
<a name="l95"></a> </span><span class=cF5>Snd</span><span class=cF0>;
|
||
|
<a name="l96"></a> dt_down=m_end-m_start;
|
||
|
<a name="l97"></a> m_start=0;
|
||
|
<a name="l98"></a> space_sent=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l99"></a> </span><span class=cF1>if</span><span class=cF0> (dt_down<M_DASH_THRESHOLD)
|
||
|
<a name="l100"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF6>'.'</span><span class=cF0>;
|
||
|
<a name="l101"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l102"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF6>'-'</span><span class=cF0>;
|
||
|
<a name="l103"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (!space_sent) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l105"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&ch,</span><span class=cF3>NULL</span><span class=cF0>,1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l106"></a> dt=</span><span class=cF5>tS</span><span class=cF0>-m_end;
|
||
|
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (dt>=M_SPACE_THRESHOLD) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l108"></a> space_sent=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l109"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
||
|
<a name="l110"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l111"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
||
|
<a name="l112"></a> }
|
||
|
<a name="l113"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l114"></a> ch=</span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l115"></a> m_start=</span><span class=cF5>tS</span><span class=cF0>;
|
||
|
<a name="l116"></a> </span><span class=cF5>Snd</span><span class=cF0>(74);
|
||
|
<a name="l117"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0> || ch==</span><span class=cF3>CH_ESC</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l118"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
||
|
<a name="l119"></a> </span><span class=cF5>Snd</span><span class=cF0>;
|
||
|
<a name="l120"></a> </span><span class=cF5>throw</span><span class=cF0>; </span><span class=cF2>//exit program</span><span class=cF0>
|
||
|
<a name="l121"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l122"></a> dt_up=m_start-m_end;
|
||
|
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (!space_sent && dt_up>=M_SPACE_THRESHOLD) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l124"></a> space_sent=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l125"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
||
|
<a name="l126"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l127"></a> }
|
||
|
<a name="l128"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l129"></a>}
|
||
|
<a name="l130"></a>
|
||
|
<a name="l131"></a></span><span class=cF1>U0</span><span class=cF0> Morse()
|
||
|
<a name="l132"></a>{
|
||
|
<a name="l133"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e;
|
||
|
<a name="l134"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
||
|
<a name="l135"></a> </span><span class=cF1>U8</span><span class=cF0> buf[8],*dst,*src;
|
||
|
<a name="l136"></a>
|
||
|
<a name="l137"></a> MorseTable;
|
||
|
<a name="l138"></a> m_start=0;
|
||
|
<a name="l139"></a> m_end=</span><span class=cF5>tS</span><span class=cF0>;
|
||
|
<a name="l140"></a> dt_down=0;
|
||
|
<a name="l141"></a> dt_up=0;
|
||
|
<a name="l142"></a> space_sent=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l143"></a>
|
||
|
<a name="l144"></a> </span><span class=cF6>"$GREEN$"</span><span class=cF0>;
|
||
|
<a name="l145"></a>
|
||
|
<a name="l146"></a> doc_e=</span><span class=cF5>DocPrint</span><span class=cF0>(</span><span class=cF5>DocPut</span><span class=cF0>,</span><span class=cF6>"$TX+TC,\" \"$"</span><span class=cF0>);
|
||
|
<a name="l147"></a> doc_e->tag_cb=&MorseTimes;
|
||
|
<a name="l148"></a>
|
||
|
<a name="l149"></a> </span><span class=cF6>"$FG$\n"</span><span class=cF0>;
|
||
|
<a name="l150"></a>
|
||
|
<a name="l151"></a> dst=buf;
|
||
|
<a name="l152"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l153"></a> ch=MorseWaitKey;
|
||
|
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF3>CH_SPACE</span><span class=cF0>) {
|
||
|
<a name="l155"></a> *dst=0;
|
||
|
<a name="l156"></a> src=morse_lst;
|
||
|
<a name="l157"></a> </span><span class=cF1>while</span><span class=cF0> (*src) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l158"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>src+1,buf</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l159"></a> </span><span class=cF6>"$GREEN$%C$FG$"</span><span class=cF0>,*src;
|
||
|
<a name="l160"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l161"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l162"></a> src+=</span><span class=cF5>StrLen</span><span class=cF0>(src)+1;
|
||
|
<a name="l163"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l164"></a> </span><span class=cF6>''</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
||
|
<a name="l165"></a> dst=buf;
|
||
|
<a name="l166"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (dst-buf<</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>buf</span><span class=cF7>)</span><span class=cF0>-1) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l168"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
||
|
<a name="l169"></a> *dst++=ch;
|
||
|
<a name="l170"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l171"></a> }
|
||
|
<a name="l172"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l173"></a> </span><span class=cF5>Snd</span><span class=cF0>;
|
||
|
<a name="l174"></a>}
|
||
|
<a name="l175"></a>
|
||
|
<a name="l176"></a>Morse;
|
||
|
</span></pre></body>
|
||
|
</html>
|