112 lines
8.7 KiB
HTML
Executable File
112 lines
8.7 KiB
HTML
Executable File
<!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=cF2>//This loads a lst 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="/Wb/Adam/Gr/GrPalette.HC.HTML#l5"><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><=ch<=</span><span class=cF6>'9'</span><span class=cF0>)
|
|
<a name="l12"></a> </span><span class=cF6>"$FG,%Z$%d$FG$"</span><span class=cF0>,ch-</span><span class=cF6>'0'</span><span class=cF0>,</span><span class=cF6>"ST_RAINBOW_10"</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> </span><span class=cF1>while</span><span class=cF0> (ch=*st++)
|
|
<a name="l19"></a> PrintDigit(ch);
|
|
<a name="l20"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l21"></a>}
|
|
<a name="l22"></a>
|
|
<a name="l23"></a></span><span class=cF1>U0</span><span class=cF0> Digits()
|
|
<a name="l24"></a>{
|
|
<a name="l25"></a> </span><span class=cF9>I64</span><span class=cF0> num,ch,i;
|
|
<a name="l26"></a> </span><span class=cF1>U8</span><span class=cF0> answer[1024];
|
|
<a name="l27"></a>
|
|
<a name="l28"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l29"></a> </span><span class=cF5>Fs</span><span class=cF0>->text_attr=</span><span class=cF3>DKGRAY</span><span class=cF0><<4+</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l30"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l31"></a></span><span class=cF2>//Set default background and foreground</span><span class=cF0>
|
|
<a name="l32"></a> </span><span class=cF6>"$WW,1$$BG,DKGRAY$$FD,WHITE$"</span><span class=cF0>
|
|
<a name="l33"></a> </span><span class=cF6>"\nThis is a memory game. "</span><span class=cF0>
|
|
<a name="l34"></a> </span><span class=cF6>"Try to remember the digits and enter them. "</span><span class=cF0>
|
|
<a name="l35"></a> </span><span class=cF6>"They are colored based on electrical "</span><span class=cF0>
|
|
<a name="l36"></a> </span><span class=cF6>"engineering color codes.\n"</span><span class=cF0>;
|
|
<a name="l37"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<10;i++)
|
|
<a name="l38"></a> </span><span class=cF6>"$FG,%Z$%d: %Z\n"</span><span class=cF0>,i,</span><span class=cF6>"ST_RAINBOW_10"</span><span class=cF0>,i,i,</span><span class=cF6>"ST_RAINBOW_10"</span><span class=cF0>;
|
|
<a name="l39"></a> </span><span class=cF6>"$FG$\n"</span><span class=cF0>; </span><span class=cF2>//set to default background</span><span class=cF0>
|
|
<a name="l40"></a> ch=</span><span class=cF5>PressAKey</span><span class=cF0>;
|
|
<a name="l41"></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>) </span><span class=cF1>goto</span><span class=cF0> dg_done;
|
|
<a name="l42"></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="l43"></a>restart:
|
|
<a name="l44"></a> num=0;
|
|
<a name="l45"></a></span><span class=cF2>//Set to zeros so we have terminators</span><span class=cF0>
|
|
<a name="l46"></a> </span><span class=cF5>MemSet</span><span class=cF0>(answer,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>answer</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l47"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l48"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l49"></a> </span><span class=cF6>"$WW,1$$BG,DKGRAY$$FD,WHITE$\n"</span><span class=cF0>;
|
|
<a name="l50"></a> </span><span class=cF6>"Pattern\nLength:%d\n\n"</span><span class=cF0>,num+1;
|
|
<a name="l51"></a> answer[num++]=</span><span class=cF5>RandU32</span><span class=cF0>%10+</span><span class=cF6>'0'</span><span class=cF0>;
|
|
<a name="l52"></a> PrintPattern(answer);
|
|
<a name="l53"></a> ch=</span><span class=cF5>PressAKey</span><span class=cF0>;
|
|
<a name="l54"></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>) </span><span class=cF1>goto</span><span class=cF0> dg_done;
|
|
<a name="l55"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l56"></a> </span><span class=cF6>"$WW,1$$BG,DKGRAY$$FD,WHITE$\n"</span><span class=cF0>;
|
|
<a name="l57"></a> </span><span class=cF6>"Guess\nLength:%d\n\n"</span><span class=cF0>,num;
|
|
<a name="l58"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<num;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l59"></a> ch=</span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</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>) </span><span class=cF1>goto</span><span class=cF0> dg_done;
|
|
<a name="l61"></a> PrintDigit(ch);
|
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=answer[i]) {
|
|
<a name="l63"></a> </span><span class=cF6>"\nScore:%d\n"</span><span class=cF0>,num;
|
|
<a name="l64"></a> PrintPattern(answer);
|
|
<a name="l65"></a> </span><span class=cF5>Beep</span><span class=cF0>; </span><span class=cF5>Beep</span><span class=cF0>;
|
|
<a name="l66"></a> ch=</span><span class=cF5>PressAKey</span><span class=cF0>;
|
|
<a name="l67"></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="l68"></a> </span><span class=cF1>goto</span><span class=cF0> dg_done;
|
|
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l70"></a> </span><span class=cF1>goto</span><span class=cF0> restart;
|
|
<a name="l71"></a> }
|
|
<a name="l72"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l73"></a> }
|
|
<a name="l74"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l75"></a>dg_done:
|
|
<a name="l76"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l77"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l78"></a>}
|
|
<a name="l79"></a>
|
|
<a name="l80"></a>Digits;
|
|
</span></pre></body>
|
|
</html>
|