ZealOS/docs/Kernel/KMisc.CC.html
TomAwezome 1b75d91002 Fix Mount AHCI Port selection.
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.
2021-08-02 16:40:05 -04:00

322 lines
36 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=cF1>U0</span><span class=cF0> </span><span class=cF5>PortNop</span><span class=cF0>()
<a name="l2"></a>{</span><span class=cF2>//Innoculous (reads IRQ Mask) which should take fixed time</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>//because it's an ISA-bus standard. It takes 1.0uS-2.0uS.</span><span class=cF0>
<a name="l4"></a> </span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>PIC_1_DATA</span><span class=cF0>);
<a name="l5"></a>}
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>IntCore0TimerHandler</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *)
<a name="l8"></a>{</span><span class=cF2>//Called from </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KInterrupts.CC.html#l55"><span class=cF4>IntCore0TimerHandler</span></a><span class=cF0>
<a name="l9"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mp_count</span><span class=cF0> &gt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l12"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SYS_TIMER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l13"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l14"></a> </span><span class=cF1>lock</span><span class=cF0> </span><span class=cFB>counts</span><span class=cF0>.jiffies++;
<a name="l15"></a> </span><span class=cFB>counts</span><span class=cF0>.timer += </span><span class=cF3>SYS_TIMER0_PERIOD</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>;
<a name="l16"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SYS_TIMER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l17"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt; </span><span class=cFB>mp_count</span><span class=cF0>; i++)
<a name="l18"></a> </span><span class=cF5>MPInt</span><span class=cF0>(</span><span class=cF3>I_TIMER</span><span class=cF0>, i);
<a name="l19"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PIC_1</span><span class=cF0>, </span><span class=cF3>PIC_EOI</span><span class=cF0>); </span><span class=cF2>//Acknowledge PIC Interrupt</span><span class=cF0>
<a name="l20"></a>}
<a name="l21"></a>
<a name="l22"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>SysTimerRead</span><span class=cF0>()
<a name="l23"></a>{</span><span class=cF2>//System timer count with overflow already handled.</span><span class=cF0>
<a name="l24"></a> </span><span class=cF9>I64</span><span class=cF0> i, res;
<a name="l25"></a>
<a name="l26"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l27"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mp_count</span><span class=cF0> &gt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l29"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SYS_TIMER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l30"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l31"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PIT_CMD</span><span class=cF0>, </span><span class=cF3>PIT_CMDF_CHANNEL0</span><span class=cF0>); </span><span class=cF2>//Latch Timer0</span><span class=cF0>
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>i = </span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>PIT_0</span><span class=cF0>) + </span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>PIT_0</span><span class=cF0>) &lt;&lt; </span><span class=cFE>8</span><span class=cF7>)</span><span class=cF0> == </span><span class=cF3>SYS_TIMER0_PERIOD</span><span class=cF0>)
<a name="l33"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>PIC_1</span><span class=cF7>)</span><span class=cF0> &amp; </span><span class=cFE>1</span><span class=cF0>)
<a name="l35"></a> i = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l36"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l37"></a> res = </span><span class=cFB>counts</span><span class=cF0>.timer + </span><span class=cF3>SYS_TIMER0_PERIOD</span><span class=cF0> - i;
<a name="l38"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SYS_TIMER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l39"></a>
<a name="l40"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l41"></a>
<a name="l42"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l43"></a>}
<a name="l44"></a>
<a name="l45"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>TimeCal</span><span class=cF0>()
<a name="l46"></a>{
<a name="l47"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> time_stamp_start = </span><span class=cFE>0</span><span class=cF0>, timer_start = </span><span class=cFE>0</span><span class=cF0>;
<a name="l48"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l49"></a>
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (time_stamp_start)
<a name="l51"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l53"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l54"></a> </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq = </span><span class=cF3>SYS_TIMER_FREQ</span><span class=cF0> * (</span><span class=cF5>TSCGet</span><span class=cF0> - time_stamp_start);
<a name="l55"></a> i = </span><span class=cF5>SysTimerRead</span><span class=cF0> - timer_start;
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (!i)
<a name="l57"></a> </span><span class=cF5>SysErr</span><span class=cF0>(</span><span class=cF6>&quot;Timer Cal Error&quot;</span><span class=cF0>);
<a name="l58"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l59"></a> {
<a name="l60"></a> </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq /= i;
<a name="l61"></a> </span><span class=cFB>counts</span><span class=cF0>.time_stamp_kHz_freq = </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq / </span><span class=cFE>1000</span><span class=cF0>;
<a name="l62"></a> </span><span class=cFB>counts</span><span class=cF0>.time_stamp_calibrated = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l63"></a> }
<a name="l64"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l67"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l68"></a> timer_start = </span><span class=cF5>SysTimerRead</span><span class=cF0>;
<a name="l69"></a> time_stamp_start = </span><span class=cF5>TSCGet</span><span class=cF0>;
<a name="l70"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l71"></a>
<a name="l72"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq;
<a name="l73"></a>}
<a name="l74"></a>
<a name="l75"></a></span><span class=cF1>F64</span><span class=cF0> </span><span class=cF5>tS</span><span class=cF0>()
<a name="l76"></a>{</span><span class=cF2>//Time since boot in seconds as a float.</span><span class=cF0>
<a name="l77"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SysTimerRead</span><span class=cF0> / </span><span class=cF5>ToF64</span><span class=cF0>(</span><span class=cF3>SYS_TIMER_FREQ</span><span class=cF0>);
<a name="l78"></a>}
<a name="l79"></a>
<a name="l80"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Blink</span><span class=cF0>(</span><span class=cF1>F64</span><span class=cF0> Hz=</span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>)
<a name="l81"></a>{</span><span class=cF2>//Return TRUE, then FALSE, then TRUE at given frequency.</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (!Hz)
<a name="l83"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l84"></a>
<a name="l85"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cFB>counts</span><span class=cF0>.jiffies * </span><span class=cFE>2</span><span class=cF0> * Hz / </span><span class=cF3>JIFFY_FREQ</span><span class=cF0>) &amp; </span><span class=cFE>1</span><span class=cF0>;
<a name="l86"></a>}
<a name="l87"></a>
<a name="l88"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Busy</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> uS)
<a name="l89"></a>{</span><span class=cF2>//Loosely timed.</span><span class=cF0>
<a name="l90"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l91"></a>
<a name="l92"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; uS; i++)
<a name="l93"></a> </span><span class=cF5>PortNop</span><span class=cF0>;
<a name="l94"></a>}
<a name="l95"></a>
<a name="l96"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SleepUntil</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> wake_jiffy)
<a name="l97"></a>{</span><span class=cF2>//Not for power-saving. It is to make a program pause without hogging the CPU.</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>Bool</span><span class=cF0> old_idle = </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l99"></a>
<a name="l100"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;wake_jiffy = wake_jiffy;
<a name="l101"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>, old_idle);
<a name="l103"></a>}
<a name="l104"></a>
<a name="l105"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> mS)
<a name="l106"></a>{</span><span class=cF2>//Not for power-saving. It is to make a program pause without hogging the CPU.</span><span class=cF0>
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (!mS)
<a name="l108"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l109"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l110"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(</span><span class=cFB>counts</span><span class=cF0>.jiffies + mS * </span><span class=cF3>JIFFY_FREQ</span><span class=cF0> / </span><span class=cFE>1000</span><span class=cF0>);
<a name="l111"></a>}
<a name="l112"></a>
<a name="l113"></a></span><span class=cF1>F64</span><span class=cF0> </span><span class=cF5>Ona2Freq</span><span class=cF0>(</span><span class=cF1>I8</span><span class=cF0> ona)
<a name="l114"></a>{</span><span class=cF2>//Ona to freq. Ona=60 is 432.0Hz.</span><span class=cF0>
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (!ona)
<a name="l116"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l117"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l118"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>432</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / </span><span class=cFE>32</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> ` (ona / </span><span class=cFE>12</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l119"></a>}
<a name="l120"></a>
<a name="l121"></a></span><span class=cF1>I8</span><span class=cF0> </span><span class=cF5>Freq2Ona</span><span class=cF0>(</span><span class=cF1>F64</span><span class=cF0> freq)
<a name="l122"></a>{</span><span class=cF2>//Freq to Ona. 432.0Hz is Ona=60.</span><span class=cF0>
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (freq &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l124"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cFE>12</span><span class=cF0> * </span><span class=cF5>Log2</span><span class=cF7>(</span><span class=cFE>32</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / </span><span class=cFE>432</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * freq</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF3>I8_MAX</span><span class=cF0>);
<a name="l125"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l126"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l127"></a>}
<a name="l128"></a>
<a name="l129"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cF1>I8</span><span class=cF0> ona=</span><span class=cFE>0</span><span class=cF0>)
<a name="l130"></a>{</span><span class=cF2>//Play ona, a piano key num. 0 means rest.</span><span class=cF0>
<a name="l131"></a> </span><span class=cF9>I64</span><span class=cF0> period;
<a name="l132"></a> </span><span class=cF9>CSoundData</span><span class=cF0> *d;
<a name="l133"></a>
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_MUTE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SOUND</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l135"></a> </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Mutex. Just throw-out if in use</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (!ona)
<a name="l137"></a> {
<a name="l138"></a> </span><span class=cFB>screencast</span><span class=cF0>.ona = ona;
<a name="l139"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PCSPKR</span><span class=cF0>, </span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>PCSPKR</span><span class=cF7>)</span><span class=cF0> &amp; ~</span><span class=cFE>3</span><span class=cF0>);
<a name="l140"></a> }
<a name="l141"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ona != </span><span class=cFB>screencast</span><span class=cF0>.ona)
<a name="l142"></a> {
<a name="l143"></a> </span><span class=cFB>screencast</span><span class=cF0>.ona = ona;
<a name="l144"></a> period = </span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cF3>SYS_TIMER_FREQ</span><span class=cF0> / </span><span class=cF5>Ona2Freq</span><span class=cF7>(</span><span class=cF0>ona</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF3>U16_MAX</span><span class=cF0>);
<a name="l145"></a> </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/PIT.DD.html#l1"><span class=cF4>::/Doc/PIT.DD</span></a><span class=cF2>.</span><span class=cF0>
<a name="l146"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PIT_CMD</span><span class=cF0>, </span><span class=cF3>PIT_CMDF_CHANNEL2</span><span class=cF0> | </span><span class=cF3>PIT_CMDF_OPMODE_SQUARE_WAVE</span><span class=cF0> | </span><span class=cF3>PIT_CMDF_ACCESS_WORD</span><span class=cF0>);
<a name="l147"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PIT_2</span><span class=cF0>, period);
<a name="l148"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PIT_2</span><span class=cF0>, period.u8[</span><span class=cFE>1</span><span class=cF0>]);
<a name="l149"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>PCSPKR</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0> | </span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>PCSPKR</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>//enable speaker</span><span class=cF0>
<a name="l150"></a> }
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsDebugMode</span><span class=cF0> &amp;&amp; </span><span class=cFB>screencast</span><span class=cF0>.record)
<a name="l152"></a> {
<a name="l153"></a> d = </span><span class=cF5>SysCAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CSoundData</span><span class=cF7>)</span><span class=cF0>);
<a name="l154"></a> d-&gt;ona = ona;
<a name="l155"></a> d-&gt;</span><span class=cF5>tS</span><span class=cF0> = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l156"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(d, </span><span class=cFB>screencast</span><span class=cF0>.sound_head.last);
<a name="l157"></a> }
<a name="l158"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SOUND</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l159"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l160"></a>}
<a name="l161"></a>
<a name="l162"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>ScreenCast</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val=</span><span class=cF3>ON</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> just_audio=</span><span class=cF3>FALSE</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *print_format=</span><span class=cF6>&quot;B:/Tmp/%X.GR&quot;</span><span class=cF0>)
<a name="l163"></a>{</span><span class=cF2>//WinMgr saves GR files to a dir.</span><span class=cF0>
<a name="l164"></a> </span><span class=cF1>Bool</span><span class=cF0> old_val;
<a name="l165"></a>
<a name="l166"></a> </span><span class=cFB>screencast</span><span class=cF0>.just_audio = just_audio;
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (val)
<a name="l168"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l169"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>old_val = </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>screencast</span><span class=cF0>.record, </span><span class=cFE>0</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l170"></a> {
<a name="l171"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>screencast</span><span class=cF0>.print_format);
<a name="l172"></a> </span><span class=cFB>screencast</span><span class=cF0>.print_format = </span><span class=cF5>SysStrNew</span><span class=cF0>(print_format);
<a name="l173"></a> </span><span class=cFB>screencast</span><span class=cF0>.t0_now = </span><span class=cF5>Now</span><span class=cF0>;
<a name="l174"></a> </span><span class=cFB>screencast</span><span class=cF0>.sound_head.</span><span class=cF5>tS</span><span class=cF0> = </span><span class=cFB>screencast</span><span class=cF0>.t0_tS = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l175"></a> </span><span class=cFB>screencast</span><span class=cF0>.sound_head.ona = </span><span class=cFB>screencast</span><span class=cF0>.ona;
<a name="l176"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>screencast</span><span class=cF0>.record, </span><span class=cFE>0</span><span class=cF0>);
<a name="l177"></a> }
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l179"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l180"></a> old_val = </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>screencast</span><span class=cF0>.record, </span><span class=cFE>0</span><span class=cF0>);
<a name="l181"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l182"></a>
<a name="l183"></a> </span><span class=cF1>return</span><span class=cF0> old_val;
<a name="l184"></a>}
<a name="l185"></a>
<a name="l186"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SoundReset</span><span class=cF0>()
<a name="l187"></a>{</span><span class=cF2>//Fix stuck sound.</span><span class=cF0>
<a name="l188"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SOUND</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l189"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l190"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l191"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SOUND</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l192"></a> {
<a name="l193"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l194"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SOUND</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l195"></a> }
<a name="l196"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l197"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l198"></a>}
<a name="l199"></a>
<a name="l200"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Beep</span><span class=cF0>(</span><span class=cF1>I8</span><span class=cF0> ona=</span><span class=cFE>62</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> busy=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l201"></a>{</span><span class=cF2>//Make beep at given ona freq.</span><span class=cF0>
<a name="l202"></a> </span><span class=cF5>Sound</span><span class=cF0>(ona);
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (busy)
<a name="l204"></a> </span><span class=cF5>Busy</span><span class=cF0>(</span><span class=cFE>500000</span><span class=cF0>);
<a name="l205"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l206"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>500</span><span class=cF0>);
<a name="l207"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (busy)
<a name="l209"></a> </span><span class=cF5>Busy</span><span class=cF0>(</span><span class=cFE>200000</span><span class=cF0>);
<a name="l210"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l211"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
<a name="l212"></a>}
<a name="l213"></a>
<a name="l214"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Mute</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val)
<a name="l215"></a>{</span><span class=cF2>//Turn-off sound.</span><span class=cF0>
<a name="l216"></a> </span><span class=cF1>Bool</span><span class=cF0> res;
<a name="l217"></a>
<a name="l218"></a> </span><span class=cF1>if</span><span class=cF0> (val)
<a name="l219"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l220"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l221"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l222"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l223"></a> res = </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_MUTE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l224"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l225"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l226"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l227"></a> res = </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_MUTE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l228"></a>
<a name="l229"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l230"></a>}
<a name="l231"></a>
<a name="l232"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsMute</span><span class=cF0>()
<a name="l233"></a>{</span><span class=cF2>//Return is-mute flag.</span><span class=cF0>
<a name="l234"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_MUTE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l235"></a>}
<a name="l236"></a>
<a name="l237"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Silent</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val=</span><span class=cF3>ON</span><span class=cF0>)
<a name="l238"></a>{</span><span class=cF2>//Turn-off StdOut console text. (Not sound.)</span><span class=cF0>
<a name="l239"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;display_flags, </span><span class=cF3>DISPLAYf_SILENT</span><span class=cF0>, val);
<a name="l240"></a>}
<a name="l241"></a>
<a name="l242"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsSilent</span><span class=cF0>()
<a name="l243"></a>{</span><span class=cF2>//Return StdOut turned-off?</span><span class=cF0>
<a name="l244"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;display_flags, </span><span class=cF3>DISPLAYf_SILENT</span><span class=cF0>);
<a name="l245"></a>}
<a name="l246"></a>
<a name="l247"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>SysDebug</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val)
<a name="l248"></a>{</span><span class=cF2>//Set SysDebug bit you can use while debugging.</span><span class=cF0>
<a name="l249"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_DEBUG</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>, val);
<a name="l250"></a>}
<a name="l251"></a>
<a name="l252"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsSysDebug</span><span class=cF0>()
<a name="l253"></a>{</span><span class=cF2>//Return SysDebug bit.</span><span class=cF0>
<a name="l254"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_DEBUG</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l255"></a>}
<a name="l256"></a>
<a name="l257"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val)
<a name="l258"></a>{</span><span class=cF2>//Set to direct screen, BLACK &amp; WHITE, non-windowed output mode.</span><span class=cF0>
<a name="l259"></a> </span><span class=cF1>if</span><span class=cF0> (!val)
<a name="l260"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
<a name="l261"></a> </span><span class=cF1>return</span><span class=cF0> !</span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;display_flags, </span><span class=cF3>DISPLAYf_NOT_RAW</span><span class=cF0>, !val);
<a name="l262"></a>}
<a name="l263"></a>
<a name="l264"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsRaw</span><span class=cF0>()
<a name="l265"></a>{</span><span class=cF2>//Are we in BLACK &amp; WHITE raw screen mode?</span><span class=cF0>
<a name="l266"></a> </span><span class=cF1>return</span><span class=cF0> !</span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;display_flags, </span><span class=cF3>DISPLAYf_NOT_RAW</span><span class=cF0>);
<a name="l267"></a>}
<a name="l268"></a>
<a name="l269"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val)
<a name="l270"></a>{</span><span class=cF2>//Set single-user mode.</span><span class=cF0>
<a name="l271"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SINGLE_USER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>, val);
<a name="l272"></a>}
<a name="l273"></a>
<a name="l274"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsSingleUser</span><span class=cF0>()
<a name="l275"></a>{</span><span class=cF2>//Return single-user mode.</span><span class=cF0>
<a name="l276"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_SINGLE_USER</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l277"></a>}
<a name="l278"></a>
<a name="l279"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DebugMode</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> val)
<a name="l280"></a>{</span><span class=cF2>//Set debug-mode.</span><span class=cF0>
<a name="l281"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_DEBUG_MODE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>, val);
<a name="l282"></a>}
<a name="l283"></a>
<a name="l284"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsDebugMode</span><span class=cF0>()
<a name="l285"></a>{</span><span class=cF2>//Return debug-mode.</span><span class=cF0>
<a name="l286"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_DEBUG_MODE</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l287"></a>}
<a name="l288"></a>
<a name="l289"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ProgressBarsReset</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *path=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l290"></a>{</span><span class=cF2>//Reset all progress bars to zero.</span><span class=cF0>
<a name="l291"></a> </span><span class=cF5>CallExtStr</span><span class=cF0>(</span><span class=cF6>&quot;ProgressBarsRegTf&quot;</span><span class=cF0>, path);
<a name="l292"></a> </span><span class=cF5>MemSet</span><span class=cF0>(</span><span class=cFB>sys_progresses</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cFB>sys_progresses</span><span class=cF7>)</span><span class=cF0>);
<a name="l293"></a>}
</span></pre></body>
</html>