ZealOS/docs/Demo/Games/Digits.CC.html
TomAwezome dbf8647d59 Fixed non-writable drive throw on F5 and Ctrl-S.
Added top & right borders to RawDr.
Improved spacing in some debug and compiler reporting.
Fixed RawPutChar and EdLite tab width.
Fixed Ui missing '0x' prefix syntax highlighter bug.
Added 32BitPaint demo.
2021-07-14 18:38:02 -04:00

121 lines
9.8 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.08">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF2>//This loads a list of zero terminated</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>//strings into the sym table and</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>//gives a name to it. Strings like</span><span class=cF0>
<a name="l4"></a></span><span class=cF2>//this are known as Define entries.</span><span class=cF0>
<a name="l5"></a>
<a name="l6"></a></span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/Gr/GrPalette.CC.html#l4"><span class=cF4>ST_RAINBOW_10</span></a><span class=cF0>
<a name="l7"></a>
<a name="l8"></a></span><span class=cF1>U0</span><span class=cF0> PrintDigit(</span><span class=cF1>U8</span><span class=cF0> ch)
<a name="l9"></a>{
<a name="l10"></a></span><span class=cF2>//The %Z code displays a Define subentry</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'0'</span><span class=cF0> &lt;= ch &lt;= </span><span class=cF6>'9'</span><span class=cF0>)
<a name="l12"></a> </span><span class=cF6>&quot;$FG,%Z$%d$FG$&quot;</span><span class=cF0>, ch - </span><span class=cF6>'0'</span><span class=cF0>, </span><span class=cF6>&quot;ST_RAINBOW_10&quot;</span><span class=cF0>, ch - </span><span class=cF6>'0'</span><span class=cF0>;
<a name="l13"></a>}
<a name="l14"></a>
<a name="l15"></a></span><span class=cF1>U0</span><span class=cF0> PrintPattern(</span><span class=cF1>U8</span><span class=cF0> *st)
<a name="l16"></a>{
<a name="l17"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l18"></a>
<a name="l19"></a> </span><span class=cF1>while</span><span class=cF0> (ch = *st++)
<a name="l20"></a> PrintDigit(ch);
<a name="l21"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l22"></a>}
<a name="l23"></a>
<a name="l24"></a></span><span class=cF1>U0</span><span class=cF0> Digits()
<a name="l25"></a>{
<a name="l26"></a> </span><span class=cF9>I64</span><span class=cF0> num, ch, i;
<a name="l27"></a> </span><span class=cF1>U8</span><span class=cF0> answer[</span><span class=cFE>1024</span><span class=cF0>];
<a name="l28"></a>
<a name="l29"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l30"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr = </span><span class=cF3>DKGRAY</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l31"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l32"></a>
<a name="l33"></a> </span><span class=cF2>//Set default background and foreground</span><span class=cF0>
<a name="l34"></a> </span><span class=cF6>&quot;$WW,1$$BG,DKGRAY$$FD,WHITE$&quot;</span><span class=cF0>
<a name="l35"></a> </span><span class=cF6>&quot;\nThis is a memory game. &quot;</span><span class=cF0>
<a name="l36"></a> </span><span class=cF6>&quot;Try to remember the digits and enter them. &quot;</span><span class=cF0>
<a name="l37"></a> </span><span class=cF6>&quot;They are colored based on electrical &quot;</span><span class=cF0>
<a name="l38"></a> </span><span class=cF6>&quot;engineering color codes.\n&quot;</span><span class=cF0>;
<a name="l39"></a>
<a name="l40"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFE>10</span><span class=cF0>; i++)
<a name="l41"></a> </span><span class=cF6>&quot;$FG,%Z$%d: %Z\n&quot;</span><span class=cF0>, i, </span><span class=cF6>&quot;ST_RAINBOW_10&quot;</span><span class=cF0>, i, i, </span><span class=cF6>&quot;ST_RAINBOW_10&quot;</span><span class=cF0>;
<a name="l42"></a> </span><span class=cF6>&quot;$FG$\n&quot;</span><span class=cF0>; </span><span class=cF2>//set to default background</span><span class=cF0>
<a name="l43"></a> ch = </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF3>CH_ESC</span><span class=cF0> || ch == </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>)
<a name="l45"></a> </span><span class=cF1>goto</span><span class=cF0> dg_done;
<a name="l46"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l47"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l48"></a>restart:
<a name="l49"></a> num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l50"></a></span><span class=cF2>//Set to zeros so we have terminators</span><span class=cF0>
<a name="l51"></a> </span><span class=cF5>MemSet</span><span class=cF0>(answer, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>answer</span><span class=cF7>)</span><span class=cF0>);
<a name="l52"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l53"></a> {
<a name="l54"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l55"></a> </span><span class=cF6>&quot;$WW,1$$BG,DKGRAY$$FD,WHITE$\n&quot;</span><span class=cF0>;
<a name="l56"></a> </span><span class=cF6>&quot;Pattern\nLength:%d\n\n&quot;</span><span class=cF0>, num + </span><span class=cFE>1</span><span class=cF0>;
<a name="l57"></a> answer[num++] = </span><span class=cF5>RandU32</span><span class=cF0> % </span><span class=cFE>10</span><span class=cF0> + </span><span class=cF6>'0'</span><span class=cF0>;
<a name="l58"></a> PrintPattern(answer);
<a name="l59"></a> ch = </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF3>CH_ESC</span><span class=cF0> || ch == </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>)
<a name="l61"></a> </span><span class=cF1>goto</span><span class=cF0> dg_done;
<a name="l62"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l63"></a>
<a name="l64"></a> </span><span class=cF6>&quot;$WW,1$$BG,DKGRAY$$FD,WHITE$\n&quot;</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF6>&quot;Guess\nLength:%d\n\n&quot;</span><span class=cF0>, num;
<a name="l66"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; num; i++)
<a name="l67"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l68"></a> ch = </span><span class=cF5>CharGet</span><span class=cF0>(, </span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l69"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF3>CH_ESC</span><span class=cF0> || ch == </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>)
<a name="l70"></a> </span><span class=cF1>goto</span><span class=cF0> dg_done;
<a name="l71"></a> PrintDigit(ch);
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (ch != answer[i])
<a name="l73"></a> {
<a name="l74"></a> </span><span class=cF6>&quot;\nScore:%d\n&quot;</span><span class=cF0>, num;
<a name="l75"></a> PrintPattern(answer);
<a name="l76"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l77"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l78"></a> ch = </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF3>CH_ESC</span><span class=cF0> || ch == </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>)
<a name="l80"></a> </span><span class=cF1>goto</span><span class=cF0> dg_done;
<a name="l81"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>goto</span><span class=cF0> restart;
<a name="l83"></a> }
<a name="l84"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l85"></a> }
<a name="l86"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l87"></a>dg_done:
<a name="l88"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l89"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l90"></a>}
<a name="l91"></a>
<a name="l92"></a>Digits;
</span></pre></body>
</html>