ZealOS/docs/Demo/Graphics/Lattice.CC.html
TomAwezome 22e3d8f06e Clean up E1000 Driver.
Remove some palettes.
Add PaletteSetSlate.
Change all gr_palette_std to gr32_palette_std.
Change all CBGR48 to CBGR24.
2021-07-28 22:20:15 -04:00

332 lines
38 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.11">
<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=cF0>#</span><span class=cF1>define</span><span class=cF0> TURTLE_SIZE </span><span class=cFE>4</span><span class=cF0>
<a name="l2"></a>#</span><span class=cF1>define</span><span class=cF0> TURTLE_SPEED_STEP </span><span class=cFE>2</span><span class=cF0>
<a name="l3"></a>
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> ANGLES </span><span class=cFE>35</span><span class=cF0>
<a name="l5"></a></span><span class=cF1>F64</span><span class=cF0> angles[ANGLES] = {
<a name="l6"></a>
<a name="l7"></a> -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>1</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>5</span><span class=cF0>,
<a name="l8"></a> -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>6</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>8</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>9</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>10</span><span class=cF0>,
<a name="l9"></a> -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>12</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>15</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>18</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>20</span><span class=cF0>,
<a name="l10"></a> -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>24</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>30</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>36</span><span class=cF0>, -</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>40</span><span class=cF0>,
<a name="l11"></a> </span><span class=cFE>0</span><span class=cF0>,
<a name="l12"></a> </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>40</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>36</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>30</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>24</span><span class=cF0>,
<a name="l13"></a> </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>20</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>18</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>15</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>12</span><span class=cF0>,
<a name="l14"></a> </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>9</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>8</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>6</span><span class=cF0>,
<a name="l15"></a> </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>1</span><span class=cF0>
<a name="l16"></a>};
<a name="l17"></a>
<a name="l18"></a></span><span class=cF1>class</span><span class=cF0> Turtle
<a name="l19"></a>{
<a name="l20"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, z, speed, theta, w;
<a name="l21"></a> </span><span class=cF9>I64</span><span class=cF0> dtheta_idx;
<a name="l22"></a> </span><span class=cF9>CColorROPU16</span><span class=cF0> edge, middle;
<a name="l23"></a> </span><span class=cF1>Bool</span><span class=cF0> ends, first;
<a name="l24"></a>
<a name="l25"></a>} tt;
<a name="l26"></a>
<a name="l27"></a></span><span class=cF1>U0</span><span class=cF0> TurtlePlot(</span><span class=cF9>CDC</span><span class=cF0> *dc, Turtle *t, </span><span class=cF9>CColorROPU16</span><span class=cF0> edge, </span><span class=cF9>CColorROPU16</span><span class=cF0> middle)
<a name="l28"></a>{
<a name="l29"></a> </span><span class=cF1>F64</span><span class=cF0> w = t-&gt;w / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l30"></a>
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (w &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l32"></a> w = </span><span class=cFE>0</span><span class=cF0>;
<a name="l33"></a> dc-&gt;color = middle;
<a name="l34"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc, t-&gt;x + w * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;y + w * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;z,
<a name="l35"></a> t-&gt;x + w * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;y + w * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;z);
<a name="l36"></a> w = t-&gt;w / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l37"></a> dc-&gt;color = edge;
<a name="l38"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, t-&gt;x + w * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;y + w * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;z);
<a name="l39"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, t-&gt;x + w * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;y + w * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t-&gt;z);
<a name="l40"></a>}
<a name="l41"></a>
<a name="l42"></a></span><span class=cF1>U0</span><span class=cF0> TurtleMicroMove(Turtle *t, </span><span class=cF1>F64</span><span class=cF0> dt)
<a name="l43"></a>{
<a name="l44"></a> t-&gt;x += dt * t-&gt;speed * </span><span class=cF5>Cos</span><span class=cF0>(t-&gt;theta);
<a name="l45"></a> t-&gt;y += dt * t-&gt;speed * </span><span class=cF5>Sin</span><span class=cF0>(t-&gt;theta);
<a name="l46"></a> t-&gt;theta = </span><span class=cF5>Wrap</span><span class=cF0>(t-&gt;theta + dt * angles[t-&gt;dtheta_idx]);
<a name="l47"></a>}
<a name="l48"></a>
<a name="l49"></a></span><span class=cF1>U0</span><span class=cF0> TurtleEnd(</span><span class=cF9>CDC</span><span class=cF0> *dc, Turtle *t, </span><span class=cF9>CColorROPU16</span><span class=cF0> edge, </span><span class=cF9>CColorROPU16</span><span class=cF0> middle, </span><span class=cF1>F64</span><span class=cF0> theta)
<a name="l50"></a>{
<a name="l51"></a> </span><span class=cF1>F64</span><span class=cF0> r, x, y2;
<a name="l52"></a> Turtle t2;
<a name="l53"></a>
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (r = t-&gt;w)
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;t2, t, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Turtle</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>//Save</span><span class=cF0>
<a name="l57"></a> x = </span><span class=cFE>0</span><span class=cF0>;
<a name="l58"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l59"></a> {
<a name="l60"></a> t-&gt;x += </span><span class=cFE>1</span><span class=cF0> / r *</span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l61"></a> t-&gt;y += </span><span class=cFE>1</span><span class=cF0> / r * </span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l62"></a> x += </span><span class=cFE>1</span><span class=cF0> / r;
<a name="l63"></a> y2 = r * r - </span><span class=cFE>4</span><span class=cF0> * x * x;
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (y2 &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l65"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l66"></a> t-&gt;w = </span><span class=cF5>Sqrt</span><span class=cF0>(y2);
<a name="l67"></a> TurtlePlot(dc, t, edge, middle);
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l70"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l71"></a> }
<a name="l72"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(t, &amp;t2, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Turtle</span><span class=cF7>)</span><span class=cF0>);
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l74"></a>}
<a name="l75"></a>
<a name="l76"></a></span><span class=cF1>U0</span><span class=cF0> TurtleMove(</span><span class=cF9>CDC</span><span class=cF0> *dc, Turtle *t, </span><span class=cF9>CColorROPU16</span><span class=cF0> edge, </span><span class=cF9>CColorROPU16</span><span class=cF0> middle)
<a name="l77"></a>{
<a name="l78"></a> </span><span class=cF9>I64</span><span class=cF0> i, l = </span><span class=cFE>16</span><span class=cF0> * </span><span class=cF5>AbsI64</span><span class=cF0>(t-&gt;w + </span><span class=cFE>1</span><span class=cF0>) * </span><span class=cF5>AbsI64</span><span class=cF0>(t-&gt;speed + </span><span class=cFE>1</span><span class=cF0>);
<a name="l79"></a>
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (t-&gt;ends &amp;&amp; t-&gt;first)
<a name="l81"></a> TurtleEnd(dc, t, edge, middle, t-&gt;theta + </span><span class=cF3>pi</span><span class=cF0>);
<a name="l82"></a> t-&gt;first = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l83"></a>
<a name="l84"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; l; i++)
<a name="l85"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l86"></a> TurtleMicroMove(t, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / l);
<a name="l87"></a> TurtlePlot(dc, t, edge, middle);
<a name="l88"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l89"></a> </span><span class=cF1>if</span><span class=cF0> (t-&gt;ends)
<a name="l90"></a> TurtleEnd(dc, t, edge, middle, t-&gt;theta);
<a name="l91"></a>}
<a name="l92"></a>
<a name="l93"></a></span><span class=cF1>U0</span><span class=cF0> TurtleInit(Turtle *t)
<a name="l94"></a>{
<a name="l95"></a> </span><span class=cF5>MemSet</span><span class=cF0>(t, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Turtle</span><span class=cF7>)</span><span class=cF0>);
<a name="l96"></a> t-&gt;x = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l97"></a> t-&gt;y = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l98"></a> t-&gt;z = </span><span class=cFE>5</span><span class=cF0>;
<a name="l99"></a> t-&gt;edge = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l100"></a> t-&gt;middle = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l101"></a> t-&gt;dtheta_idx = ANGLES / </span><span class=cFE>2</span><span class=cF0>;
<a name="l102"></a> t-&gt;first = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l103"></a> t-&gt;ends = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l104"></a>}
<a name="l105"></a>
<a name="l106"></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> *, </span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l107"></a>{
<a name="l108"></a> Turtle t2;
<a name="l109"></a>
<a name="l110"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;t2, &amp;tt, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Turtle</span><span class=cF7>)</span><span class=cF0>);
<a name="l111"></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>&quot;Layer:%f Speed:%f theta:%5.1f dtheta:%5.1f Width:%f&quot;</span><span class=cF0>,
<a name="l112"></a> tt.z, tt.speed, tt.theta * </span><span class=cFE>180</span><span class=cF0> / </span><span class=cF3>pi</span><span class=cF0>, angles[tt.dtheta_idx] * </span><span class=cFE>180</span><span class=cF0> / </span><span class=cF3>pi</span><span class=cF0>, tt.w);
<a name="l113"></a>
<a name="l114"></a> TurtleMove(dc, &amp;t2, </span><span class=cF3>RED</span><span class=cF0>, </span><span class=cF3>LTRED</span><span class=cF0>);
<a name="l115"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l116"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>,
<a name="l117"></a> t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>);
<a name="l118"></a>
<a name="l119"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>,
<a name="l120"></a> t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>,
<a name="l123"></a> t2.x + TURTLE_SIZE * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>t2.theta</span><span class=cF7>)</span><span class=cF0>, t2.y + TURTLE_SIZE * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>t2.theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l124"></a>}
<a name="l125"></a>
<a name="l126"></a></span><span class=cF1>U0</span><span class=cF0> SetMenu()
<a name="l127"></a>{
<a name="l128"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l129"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cF3>STR_LEN</span><span class=cF0>];
<a name="l130"></a> </span><span class=cF9>CMenuEntry</span><span class=cF0> *tmpse;
<a name="l131"></a>
<a name="l132"></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>9</span><span class=cF0>; i++)
<a name="l133"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l134"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf, </span><span class=cF6>&quot;Settings/Layer%d&quot;</span><span class=cF0>, i);
<a name="l135"></a> </span><span class=cF1>if</span><span class=cF0> (tmpse = </span><span class=cF5>MenuEntryFind</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, buf</span><span class=cF7>)</span><span class=cF0>)
<a name="l136"></a> {
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (i == tt.z)
<a name="l138"></a> tmpse-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l139"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l140"></a> tmpse-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l141"></a> }
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>if</span><span class=cF0> (tmpse = </span><span class=cF5>MenuEntryFind</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Settings/Ends&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l144"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l145"></a> </span><span class=cF1>if</span><span class=cF0> (tt.ends)
<a name="l146"></a> tmpse-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l147"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l148"></a> tmpse-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l149"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l150"></a>}
<a name="l151"></a>
<a name="l152"></a></span><span class=cF1>U0</span><span class=cF0> Lattice()
<a name="l153"></a>{
<a name="l154"></a> </span><span class=cF1>Bool</span><span class=cF0> aim = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l155"></a> </span><span class=cF9>I64</span><span class=cF0> arg1, arg2;
<a name="l156"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc = </span><span class=cF5>DCAlias</span><span class=cF0>;
<a name="l157"></a>
<a name="l158"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
<a name="l159"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l160"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l161"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l162"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l163"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l164"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l165"></a> </span><span class=cF6>&quot; Step(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l166"></a> </span><span class=cF6>&quot; Accelerator(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l167"></a> </span><span class=cF6>&quot; Break(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l168"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l169"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l170"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l171"></a> </span><span class=cF6>&quot;Settings {&quot;</span><span class=cF0>
<a name="l172"></a> </span><span class=cF6>&quot; Color(,'c');&quot;</span><span class=cF0>
<a name="l173"></a> </span><span class=cF6>&quot; Wider(,'+');&quot;</span><span class=cF0>
<a name="l174"></a> </span><span class=cF6>&quot; Narrower(,'-');&quot;</span><span class=cF0>
<a name="l175"></a> </span><span class=cF6>&quot; Ends(,'e');&quot;</span><span class=cF0>
<a name="l176"></a> </span><span class=cF6>&quot; Layer0(,'0');&quot;</span><span class=cF0>
<a name="l177"></a> </span><span class=cF6>&quot; Layer1(,'1');&quot;</span><span class=cF0>
<a name="l178"></a> </span><span class=cF6>&quot; Layer2(,'2');&quot;</span><span class=cF0>
<a name="l179"></a> </span><span class=cF6>&quot; Layer3(,'3');&quot;</span><span class=cF0>
<a name="l180"></a> </span><span class=cF6>&quot; Layer4(,'4');&quot;</span><span class=cF0>
<a name="l181"></a> </span><span class=cF6>&quot; Layer5(,'5');&quot;</span><span class=cF0>
<a name="l182"></a> </span><span class=cF6>&quot; Layer6(,'6');&quot;</span><span class=cF0>
<a name="l183"></a> </span><span class=cF6>&quot; Layer7(,'7');&quot;</span><span class=cF0>
<a name="l184"></a> </span><span class=cF6>&quot; Layer8(,'8');&quot;</span><span class=cF0>
<a name="l185"></a> </span><span class=cF6>&quot; Layer9(,'9');&quot;</span><span class=cF0>
<a name="l186"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l187"></a> );
<a name="l188"></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="l189"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l190"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l191"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l192"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l193"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l194"></a> TurtleInit(&amp;tt);
<a name="l195"></a> SetMenu;
<a name="l196"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit = </span><span class=cF3>WIG_TASK_DEFAULT</span><span class=cF0> - </span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0> - </span><span class=cF3>WIF_SELF_FOCUS</span><span class=cF0> - </span><span class=cF3>WIF_SELF_GRAB_SCROLL</span><span class=cF0>;
<a name="l197"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it = &amp;</span><span class=cF5>DrawIt</span><span class=cF0>;
<a name="l198"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l199"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l200"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l201"></a> {
<a name="l202"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>MessageGet</span><span class=cF7>(</span><span class=cF0>&amp;arg1, &amp;arg2, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>|
<a name="l203"></a> </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF7>)</span><span class=cF0>)
<a name="l204"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l205"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
<a name="l206"></a> tt.first = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l207"></a> tt.x = arg1;
<a name="l208"></a> tt.y = arg2;
<a name="l209"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l210"></a>
<a name="l211"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>:
<a name="l212"></a> aim = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l213"></a> tt.theta = </span><span class=cF5>Arg</span><span class=cF0>(arg1 - tt.x, arg2 - tt.y);
<a name="l214"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l215"></a>
<a name="l216"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF0>:
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (aim)
<a name="l218"></a> tt.theta = </span><span class=cF5>Arg</span><span class=cF0>(arg1 - tt.x, arg2 - tt.y);
<a name="l219"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l220"></a>
<a name="l221"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0>:
<a name="l222"></a> tt.theta = </span><span class=cF5>Arg</span><span class=cF0>(arg1 - tt.x, arg2 - tt.y);
<a name="l223"></a> aim = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l224"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l225"></a>
<a name="l226"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
<a name="l227"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
<a name="l228"></a> {
<a name="l229"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l230"></a> </span><span class=cF1>switch</span><span class=cF0> (arg2.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l231"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l232"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (tt.dtheta_idx)
<a name="l234"></a> tt.dtheta_idx--;
<a name="l235"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l236"></a>
<a name="l237"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (tt.dtheta_idx &lt; ANGLES - </span><span class=cFE>1</span><span class=cF0>)
<a name="l239"></a> tt.dtheta_idx++;
<a name="l240"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l241"></a>
<a name="l242"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l243"></a> tt.speed += TURTLE_SPEED_STEP;
<a name="l244"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l245"></a>
<a name="l246"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (tt.speed &gt;= TURTLE_SPEED_STEP)
<a name="l248"></a> tt.speed -= TURTLE_SPEED_STEP;
<a name="l249"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l250"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l251"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l252"></a>
<a name="l253"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>...</span><span class=cF6>'9'</span><span class=cF0>:
<a name="l254"></a> tt.z = arg1 - </span><span class=cF6>'0'</span><span class=cF0>;
<a name="l255"></a> SetMenu;
<a name="l256"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l257"></a>
<a name="l258"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
<a name="l259"></a> tt.middle = </span><span class=cF5>PopUpColor</span><span class=cF0>(</span><span class=cF6>&quot;Mid Color\n\n&quot;</span><span class=cF0>);
<a name="l260"></a> tt.edge = </span><span class=cF5>PopUpColor</span><span class=cF0>(</span><span class=cF6>&quot;Edge Color\n\n&quot;</span><span class=cF0>);
<a name="l261"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l262"></a>
<a name="l263"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'e'</span><span class=cF0>:
<a name="l264"></a> tt.ends = !tt.ends;
<a name="l265"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l266"></a>
<a name="l267"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'+'</span><span class=cF0>:
<a name="l268"></a> tt.w++;
<a name="l269"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l270"></a>
<a name="l271"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'-'</span><span class=cF0>:
<a name="l272"></a> </span><span class=cF1>if</span><span class=cF0> (tt.w)
<a name="l273"></a> tt.w--;
<a name="l274"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l275"></a>
<a name="l276"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l277"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l278"></a> TurtleInit(&amp;tt);
<a name="l279"></a> SetMenu;
<a name="l280"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l281"></a>
<a name="l282"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l283"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l284"></a> </span><span class=cF1>goto</span><span class=cF0> lt_done;
<a name="l285"></a>
<a name="l286"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l287"></a> TurtleMove(dc, &amp;tt, tt.edge, tt.middle);
<a name="l288"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l289"></a> }
<a name="l290"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l291"></a> }
<a name="l292"></a>lt_done:
<a name="l293"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
<a name="l294"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l295"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l296"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l297"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l298"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l299"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l300"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l301"></a>}
<a name="l302"></a>
<a name="l303"></a>Lattice;
</span></pre></body>
</html>