mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-31 17:56:30 +00:00
1b75d91002
Add arg to SATARep to specify drive types to show. Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
187 lines
19 KiB
HTML
Executable file
187 lines
19 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.13">
|
|
<style type="text/css">
|
|
body {background-color:#fef1f0;}
|
|
.cF0{color:#000000;background-color:#fef1f0;}
|
|
.cF1{color:#0148a4;background-color:#fef1f0;}
|
|
.cF2{color:#3b7901;background-color:#fef1f0;}
|
|
.cF3{color:#057c7e;background-color:#fef1f0;}
|
|
.cF4{color:#bb2020;background-color:#fef1f0;}
|
|
.cF5{color:#9e42ae;background-color:#fef1f0;}
|
|
.cF6{color:#b57901;background-color:#fef1f0;}
|
|
.cF7{color:#b2b6af;background-color:#fef1f0;}
|
|
.cF8{color:#555753;background-color:#fef1f0;}
|
|
.cF9{color:#678fbb;background-color:#fef1f0;}
|
|
.cFA{color:#82bc49;background-color:#fef1f0;}
|
|
.cFB{color:#0097a2;background-color:#fef1f0;}
|
|
.cFC{color:#e26a6a;background-color:#fef1f0;}
|
|
.cFD{color:#c671bc;background-color:#fef1f0;}
|
|
.cFE{color:#c7ab00;background-color:#fef1f0;}
|
|
.cFF{color:#fef1f0;background-color:#fef1f0;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF2>//Practice tracing circles</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a></span><span class=cF2>//Giotto, a famous artist, drew a freehand circle to get a job.</span><span class=cF0>
|
|
<a name="l4"></a>
|
|
<a name="l5"></a></span><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>"ZealOS/CircleTrace"</span><span class=cF0>, </span><span class=cF6>"F64 best_score=999;\n"</span><span class=cF0>);
|
|
<a name="l6"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>"ZealOS/CircleTrace"</span><span class=cF0>);
|
|
<a name="l7"></a>
|
|
<a name="l8"></a></span><span class=cF9>I64</span><span class=cF0> cx, cy;
|
|
<a name="l9"></a></span><span class=cF1>F64</span><span class=cF0> avg_error = </span><span class=cFE>0</span><span class=cF0>, elapsed_time = </span><span class=cFE>0</span><span class=cF0>, total_error = </span><span class=cFE>0</span><span class=cF0>, score = </span><span class=cFE>999</span><span class=cF0>;
|
|
<a name="l10"></a>
|
|
<a name="l11"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l12"></a>{
|
|
<a name="l13"></a> </span><span class=cF5>Fs</span><span class=cF0>->task_end_cb = &</span><span class=cF5>SoundTaskEndCB</span><span class=cF0>;
|
|
<a name="l14"></a> </span><span class=cF5>MusicSettingsReset</span><span class=cF0>;
|
|
<a name="l15"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l16"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5hEDC4A5RCDECR"</span><span class=cF0>);
|
|
<a name="l17"></a>}
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>CDC</span><span class=cF0> *dc)
|
|
<a name="l20"></a>{
|
|
<a name="l21"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f"</span><span class=cF0>, avg_error, elapsed_time, score, best_score);
|
|
<a name="l22"></a>}
|
|
<a name="l23"></a>
|
|
<a name="l24"></a>#</span><span class=cF1>define</span><span class=cF0> CIRCLE_RADIUS </span><span class=cFE>100</span><span class=cF0>
|
|
<a name="l25"></a>#</span><span class=cF1>define</span><span class=cF0> CIRCUMFERENCE (</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * CIRCLE_RADIUS)
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF1>Bool</span><span class=cF0> CTPlot(</span><span class=cF9>CDC</span><span class=cF0> *dc, </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>)
|
|
<a name="l28"></a>{
|
|
<a name="l29"></a> </span><span class=cF1>F64</span><span class=cF0> rad = </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>x - cx</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>y - cy</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l30"></a>
|
|
<a name="l31"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, x, y);
|
|
<a name="l32"></a> total_error += </span><span class=cF5>Abs</span><span class=cF0>(rad - CIRCLE_RADIUS);
|
|
<a name="l33"></a>
|
|
<a name="l34"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l35"></a>}
|
|
<a name="l36"></a>
|
|
<a name="l37"></a></span><span class=cF1>U0</span><span class=cF0> CircleTrace()
|
|
<a name="l38"></a>{
|
|
<a name="l39"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, arg1, arg2, x1, y1;
|
|
<a name="l40"></a> </span><span class=cF1>F64</span><span class=cF0> rad, t0, total_distance;
|
|
<a name="l41"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc = </span><span class=cF5>DCAlias</span><span class=cF0>;
|
|
<a name="l42"></a>
|
|
<a name="l43"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l44"></a> </span><span class=cF5>Fs</span><span class=cF0>->song_task = </span><span class=cF5>Spawn</span><span class=cF0>(&SongTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>"Song"</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l45"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l46"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l47"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l48"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l49"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l50"></a>
|
|
<a name="l51"></a> cx = </span><span class=cF5>Fs</span><span class=cF0>->pix_width / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l52"></a> cy = </span><span class=cF5>Fs</span><span class=cF0>->pix_height / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l53"></a>
|
|
<a name="l54"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit = </span><span class=cF3>WIG_TASK_DEFAULT</span><span class=cF0> - </span><span class=cF3>WIF_SELF_FOCUS</span><span class=cF0> - </span><span class=cF3>WIF_SELF_BORDER</span><span class=cF0>;
|
|
<a name="l55"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it = &</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l56"></a>
|
|
<a name="l57"></a> </span><span class=cF5>DCFill</span><span class=cF0>;
|
|
<a name="l58"></a> dc->color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + </span><span class=cF3>BLACK</span><span class=cF0> ^ </span><span class=cF3>TRANSPARENT</span><span class=cF0>;
|
|
<a name="l59"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc, cx, cy, CIRCLE_RADIUS);
|
|
<a name="l60"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l61"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l62"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&arg1, &arg2, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>);
|
|
<a name="l63"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
|
|
<a name="l64"></a> {
|
|
<a name="l65"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>:
|
|
<a name="l66"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l67"></a>
|
|
<a name="l68"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
|
|
<a name="l69"></a> </span><span class=cF5>DCFill</span><span class=cF0>;
|
|
<a name="l70"></a> dc->color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + </span><span class=cF3>BLACK</span><span class=cF0> ^ </span><span class=cF3>TRANSPARENT</span><span class=cF0>;
|
|
<a name="l71"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc, cx, cy, CIRCLE_RADIUS);
|
|
<a name="l72"></a> dc->color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + </span><span class=cF3>RED</span><span class=cF0> ^ </span><span class=cF3>TRANSPARENT</span><span class=cF0>;
|
|
<a name="l73"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l74"></a> total_distance = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>001</span><span class=cF0>;
|
|
<a name="l75"></a> total_error = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l76"></a> x1 = arg1;
|
|
<a name="l77"></a> y1 = arg2;
|
|
<a name="l78"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l80"></a> message_code = </span><span class=cF5>MessageScan</span><span class=cF0>(&arg1, &arg2, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF0>);
|
|
<a name="l81"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
|
|
<a name="l82"></a> {
|
|
<a name="l83"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>:
|
|
<a name="l84"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l85"></a>
|
|
<a name="l86"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF0>:
|
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (x1 != arg1 || y1 != arg2)
|
|
<a name="l88"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l89"></a> total_distance += </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>x1 - arg1</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>y1 - arg2</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l90"></a> </span><span class=cF5>Line</span><span class=cF0>(dc, x1, y1, </span><span class=cFE>0</span><span class=cF0>, arg1, arg2, </span><span class=cFE>0</span><span class=cF0>, &CTPlot);
|
|
<a name="l91"></a> x1 = arg1;
|
|
<a name="l92"></a> y1 = arg2;
|
|
<a name="l93"></a> </span><span class=cF2>//undo overlapping pixs on segments</span><span class=cF0>
|
|
<a name="l94"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, x1, y1);
|
|
<a name="l95"></a> rad = </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>x1 - cx</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>y1 - cy</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l96"></a> total_error -= </span><span class=cF5>Abs</span><span class=cF0>(rad - CIRCLE_RADIUS);
|
|
<a name="l97"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l98"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l99"></a> }
|
|
<a name="l100"></a> elapsed_time = </span><span class=cF5>tS</span><span class=cF0> - t0;
|
|
<a name="l101"></a> avg_error = total_error / total_distance;
|
|
<a name="l102"></a> score = elapsed_time * avg_error;
|
|
<a name="l103"></a>
|
|
<a name="l104"></a> </span><span class=cF2>//</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KMisc.CC.html#l105"><span class=cF4>Sleep</span></a><span class=cF2>()s until the next time the</span><span class=cF0>
|
|
<a name="l105"></a> </span><span class=cF2>//window mgr task runs. The</span><span class=cF0>
|
|
<a name="l106"></a> </span><span class=cF2>//window mgr calls the UpdateWin() routine</span><span class=cF0>
|
|
<a name="l107"></a> </span><span class=cF2>//and places messages in the que, so there's</span><span class=cF0>
|
|
<a name="l108"></a> </span><span class=cF2>//no need to do anything until the window mgr runs.</span><span class=cF0>
|
|
<a name="l109"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
|
|
<a name="l110"></a>
|
|
<a name="l111"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l112"></a> </span><span class=cF1>while</span><span class=cF0> (message_code != </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>);
|
|
<a name="l113"></a>
|
|
<a name="l114"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l115"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
|
|
<a name="l116"></a> </span><span class=cF1>if</span><span class=cF0> (total_distance > </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>95</span><span class=cF0> * CIRCUMFERENCE)
|
|
<a name="l117"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l118"></a> </span><span class=cF1>if</span><span class=cF0> (score < best_score)
|
|
<a name="l119"></a> {
|
|
<a name="l120"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l121"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l122"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l123"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l124"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l125"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l126"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l128"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l129"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l130"></a> best_score = score;
|
|
<a name="l131"></a> }
|
|
<a name="l132"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l133"></a> {
|
|
<a name="l134"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>62</span><span class=cF0>);
|
|
<a name="l135"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>50</span><span class=cF0>);
|
|
<a name="l136"></a> }
|
|
<a name="l137"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l139"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l140"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>34</span><span class=cF0>);
|
|
<a name="l141"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1000</span><span class=cF0>);
|
|
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l144"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
|
|
<a name="l145"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l146"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l147"></a> }
|
|
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF1>while</span><span class=cF0> (message_code != </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> || arg1 != </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0> && arg1 != </span><span class=cF3>CH_ESC</span><span class=cF0>);
|
|
<a name="l150"></a>
|
|
<a name="l151"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
|
|
<a name="l152"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l153"></a> </span><span class=cF5>DCFill</span><span class=cF0>;
|
|
<a name="l154"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
|
|
<a name="l155"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>"ZealOS/CircleTrace"</span><span class=cF0>, </span><span class=cF6>"F64 best_score=%5.4f;\n"</span><span class=cF0>, best_score);
|
|
<a name="l156"></a>}
|
|
<a name="l157"></a>
|
|
<a name="l158"></a>CircleTrace; </span><span class=cF2>//Execute when #included</span><span class=cF0>
|
|
</span></pre></body>
|
|
</html>
|