ZealOS/docs/Demo/Graphics/LightTable.CC.html
TomAwezome 2ea6956433 Implement IntEntryAlloc, IntEntryFree for dynamic user IRQ acquisition.
Restructure network stack to use new Interrupt methods instead of hard-coded IRQ numbers.
Add line count update into build process.
Add progress bars to HTML generation and DoDistro.
Clear Network Log border_doc.
Fix font chars.
Clean up some lingering unconverted variable and directory names.
Remove word-wrap DolDoc tag from Clementine bible because of CPU spikes.
2021-07-11 17:47:19 -04:00

747 lines
76 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.07">
<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>/*</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>There is a coarse and a fine-grained.</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>The coarse gets flood-filled but the</span><span class=cF0>
<a name="l4"></a></span><span class=cF2>fine grained is only outlines.</span><span class=cF0>
<a name="l5"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>class</span><span class=cF0> Photon
<a name="l8"></a>{
<a name="l9"></a> Photon *next, *last;
<a name="l10"></a> </span><span class=cF9>CD3</span><span class=cF0> p, v, n, p_normal_inhibit;
<a name="l11"></a>
<a name="l12"></a>} p_root[</span><span class=cFB>mp_count</span><span class=cF0>];
<a name="l13"></a></span><span class=cF9>I64</span><span class=cF0> p_root_locks;
<a name="l14"></a>
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMATE_JIFFIES (</span><span class=cF3>JIFFY_FREQ</span><span class=cF0> * </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0>)
<a name="l16"></a></span><span class=cF9>I64</span><span class=cF0> master_sleep_jiffy;
<a name="l17"></a></span><span class=cF9>CTask</span><span class=cF0> *animate_tasks[</span><span class=cFB>mp_count</span><span class=cF0>];
<a name="l18"></a>
<a name="l19"></a>#</span><span class=cF1>define</span><span class=cF0> LENS_COLOR </span><span class=cF3>WHITE</span><span class=cF0>
<a name="l20"></a>#</span><span class=cF1>define</span><span class=cF0> MIRROR_COLOR </span><span class=cF3>DKGRAY</span><span class=cF0>
<a name="l21"></a></span><span class=cF9>CDC</span><span class=cF0> *map;
<a name="l22"></a>
<a name="l23"></a></span><span class=cF9>I64</span><span class=cF0> photon_count, mirror_count, snell_count, normal_inhibit, zero_normal;
<a name="l24"></a></span><span class=cF1>Bool</span><span class=cF0> full_speed, show_normals;
<a name="l25"></a>
<a name="l26"></a></span><span class=cF1>U8</span><span class=cF0> *bmp_refract, *bmp_reflect;
<a name="l27"></a></span><span class=cF1>F64</span><span class=cF0> bmp_scale, find_normal_dist_sqr;
<a name="l28"></a></span><span class=cF9>I64</span><span class=cF0> bmp_mem, bmp_width, bmp_height, bmp_norm_radius;
<a name="l29"></a>
<a name="l30"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER </span><span class=cFE>10</span><span class=cF0>
<a name="l31"></a></span><span class=cF9>I64</span><span class=cF0> BmpPeek(</span><span class=cF1>U8</span><span class=cF0> *bmp, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
<a name="l32"></a>{
<a name="l33"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(bmp, y * bmp_width + x);
<a name="l34"></a>}
<a name="l35"></a>
<a name="l36"></a></span><span class=cF1>U0</span><span class=cF0> BmpPlot(</span><span class=cF1>U8</span><span class=cF0> *bmp, </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="l37"></a>{
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> &lt;= x &lt; bmp_width &amp;&amp; </span><span class=cFE>0</span><span class=cF0> &lt;= y &lt; bmp_height)
<a name="l39"></a> </span><span class=cF5>Bts</span><span class=cF0>(bmp, y * bmp_width + x);
<a name="l40"></a>}
<a name="l41"></a>
<a name="l42"></a></span><span class=cF1>U0</span><span class=cF0> BmpLine(</span><span class=cF1>U8</span><span class=cF0> *bmp, </span><span class=cF1>F64</span><span class=cF0> x1, </span><span class=cF1>F64</span><span class=cF0> y1, </span><span class=cF1>F64</span><span class=cF0> x2, </span><span class=cF1>F64</span><span class=cF0> y2)
<a name="l43"></a>{
<a name="l44"></a> </span><span class=cF5>Line</span><span class=cF0>(bmp, x1 * bmp_scale, y1 * bmp_scale, </span><span class=cFE>0</span><span class=cF0>, x2 * bmp_scale, y2 * bmp_scale, </span><span class=cFE>0</span><span class=cF0>, &amp;BmpPlot);
<a name="l45"></a>}
<a name="l46"></a>
<a name="l47"></a>Photon *PhotonNew()
<a name="l48"></a>{
<a name="l49"></a> </span><span class=cF9>I64</span><span class=cF0> num = photon_count++ % </span><span class=cFB>mp_count</span><span class=cF0>;
<a name="l50"></a> Photon *res = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Photon</span><span class=cF7>)</span><span class=cF0>);
<a name="l51"></a>
<a name="l52"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;p_root_locks, num</span><span class=cF7>)</span><span class=cF0>)
<a name="l53"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l54"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(res, p_root[num].last);
<a name="l55"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;p_root_locks, num);
<a name="l56"></a>
<a name="l57"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l58"></a>}
<a name="l59"></a>
<a name="l60"></a>#</span><span class=cF1>define</span><span class=cF0> VECTOR </span><span class=cFE>20</span><span class=cF0>
<a name="l61"></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="l62"></a>{
<a name="l63"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l64"></a> Photon *tmpp;
<a name="l65"></a>
<a name="l66"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, map);
<a name="l67"></a> dc-&gt;color = </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l68"></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;Mem:0x%X %,dMeg Scale:%0.3f (%d,%d)--&gt;(%d,%d)&quot;</span><span class=cF0>,
<a name="l69"></a> bmp_mem, bmp_mem / </span><span class=cFE>1024</span><span class=cF0> / </span><span class=cFE>1024</span><span class=cF0>, bmp_scale,
<a name="l70"></a> map-&gt;width, map-&gt;height, bmp_width, bmp_height);
<a name="l71"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,
<a name="l72"></a> </span><span class=cF6>&quot;PhotonCount:%d MirrorCount:%d SnellCount:%d SnellInhibit:%d ZeroNormal:%d&quot;</span><span class=cF0>,
<a name="l73"></a> photon_count, mirror_count, snell_count, normal_inhibit, zero_normal);
<a name="l74"></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=cFB>mp_count</span><span class=cF0>; i++)
<a name="l75"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;p_root_locks, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l77"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l78"></a> tmpp = p_root[i].next;
<a name="l79"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp != &amp;p_root[i])
<a name="l80"></a> {
<a name="l81"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l82"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpp-&gt;p.x - VECTOR * tmpp-&gt;v.x, tmpp-&gt;p.y - VECTOR * tmpp-&gt;v.y, tmpp-&gt;p.x, tmpp-&gt;p.y);
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (show_normals)
<a name="l84"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l85"></a> dc-&gt;color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l86"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpp-&gt;p.x, tmpp-&gt;p.y, tmpp-&gt;p.x + VECTOR * tmpp-&gt;n.x, tmpp-&gt;p.y + VECTOR * tmpp-&gt;n.y);
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l88"></a> tmpp = tmpp-&gt;next;
<a name="l89"></a> }
<a name="l90"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;p_root_locks, i);
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l92"></a>}
<a name="l93"></a>
<a name="l94"></a>#</span><span class=cF1>define</span><span class=cF0> WING </span><span class=cFE>9</span><span class=cF0>
<a name="l95"></a>
<a name="l96"></a></span><span class=cF1>U0</span><span class=cF0> RayBurst(</span><span class=cF9>I64</span><span class=cF0> x1, </span><span class=cF9>I64</span><span class=cF0> y1, </span><span class=cF9>I64</span><span class=cF0> x2, </span><span class=cF9>I64</span><span class=cF0> y2)
<a name="l97"></a>{
<a name="l98"></a> </span><span class=cF9>CD3</span><span class=cF0> p, v, n, n2;
<a name="l99"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l100"></a> Photon *tmpp;
<a name="l101"></a>
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>x1 != x2 || y1 != y2</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l103"></a> BORDER + WING &lt; x2 &lt; map-&gt;width - BORDER - WING &amp;&amp; BORDER + WING &lt; y2 &lt; map-&gt;height - BORDER-WING)
<a name="l104"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l105"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;p, x2, y2);
<a name="l106"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;v, x2 - x1, y2 - y1);
<a name="l107"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&amp;v);
<a name="l108"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;n, v.y, -v.x);
<a name="l109"></a>
<a name="l110"></a> tmpp = PhotonNew;
<a name="l111"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;p);
<a name="l112"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;tmpp-&gt;v, &amp;v);
<a name="l113"></a>
<a name="l114"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>2</span><span class=cF0>; i &lt;= WING; i += </span><span class=cFE>3</span><span class=cF0>)
<a name="l115"></a> {
<a name="l116"></a> </span><span class=cF5>D3Mul</span><span class=cF0>(&amp;n2, i, &amp;n);
<a name="l117"></a>
<a name="l118"></a> tmpp = PhotonNew;
<a name="l119"></a> </span><span class=cF5>D3Add</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;p, &amp;n2);
<a name="l120"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;tmpp-&gt;v, &amp;v);
<a name="l121"></a>
<a name="l122"></a> tmpp = PhotonNew;
<a name="l123"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;p, &amp;n2);
<a name="l124"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;tmpp-&gt;v, &amp;v);
<a name="l125"></a> }
<a name="l126"></a> </span><span class=cF7>}</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> RandomBurst()
<a name="l130"></a>{
<a name="l131"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l132"></a> </span><span class=cF1>F64</span><span class=cF0> theta;
<a name="l133"></a> Photon *tmpp;
<a name="l134"></a>
<a name="l135"></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>256</span><span class=cF0>; i++)
<a name="l136"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l137"></a> tmpp = PhotonNew;
<a name="l138"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;p, </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width - BORDER * </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + BORDER, </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height - BORDER * </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + BORDER);
<a name="l139"></a> theta = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0>;
<a name="l140"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;v, </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l141"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l142"></a>}
<a name="l143"></a>
<a name="l144"></a></span><span class=cF1>U0</span><span class=cF0> FindNormal(</span><span class=cF1>U8</span><span class=cF0> *bmp, Photon *tmpp)
<a name="l145"></a>{
<a name="l146"></a> </span><span class=cF9>CD3</span><span class=cF0> p, p1, p2;
<a name="l147"></a> </span><span class=cF1>F64</span><span class=cF0> step, x, y, theta = </span><span class=cF5>Arg</span><span class=cF0>(tmpp-&gt;v.x, tmpp-&gt;v.y), phi;
<a name="l148"></a> </span><span class=cF9>I64</span><span class=cF0> state;
<a name="l149"></a>
<a name="l150"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;tmpp-&gt;p_normal_inhibit, &amp;tmpp-&gt;p);
<a name="l151"></a>
<a name="l152"></a> </span><span class=cF2>//Coarse grains has black and white filled-in BSplines.</span><span class=cF0>
<a name="l153"></a> </span><span class=cF2>//Fine grained has only white outline without being filled-in.</span><span class=cF0>
<a name="l154"></a>
<a name="l155"></a> </span><span class=cF2>//Back-up a step and move forward to get a fined-grained value</span><span class=cF0>
<a name="l156"></a> </span><span class=cF2>//for the point of contact.</span><span class=cF0>
<a name="l157"></a> </span><span class=cF5>D3SubEqu</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;tmpp-&gt;v);
<a name="l158"></a> </span><span class=cF5>D3Mul</span><span class=cF0>(&amp;p, bmp_scale, &amp;tmpp-&gt;p);
<a name="l159"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;p1, &amp;p);
<a name="l160"></a> </span><span class=cF1>while</span><span class=cF0> (BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, p1.x, p1.y</span><span class=cF7>)</span><span class=cF0> == </span><span class=cF3>BLACK</span><span class=cF0> &amp;&amp; </span><span class=cF5>D3DistSqr</span><span class=cF7>(</span><span class=cF0>&amp;p, &amp;p1</span><span class=cF7>)</span><span class=cF0> &lt; find_normal_dist_sqr)
<a name="l161"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&amp;p1, &amp;tmpp-&gt;v);
<a name="l162"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;p, &amp;p1);
<a name="l163"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;p, bmp_scale);
<a name="l164"></a>
<a name="l165"></a> </span><span class=cF2>//Draw an arc one direction, finding point of contact.</span><span class=cF0>
<a name="l166"></a> </span><span class=cF1>for</span><span class=cF0> (step = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; step &gt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0>; step /= </span><span class=cFE>4</span><span class=cF0>)
<a name="l167"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l168"></a> </span><span class=cF1>for</span><span class=cF0> (phi = </span><span class=cFE>0</span><span class=cF0>; phi &lt;= </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>; phi += step * </span><span class=cF3>pi</span><span class=cF0> / bmp_norm_radius)
<a name="l169"></a> {
<a name="l170"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi);
<a name="l171"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi);
<a name="l172"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l173"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
<a name="l174"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l175"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l176"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l177"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
<a name="l178"></a> }
<a name="l179"></a> </span><span class=cF1>for</span><span class=cF0> (; phi &lt;= </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>; phi += step * </span><span class=cF3>pi</span><span class=cF0> / bmp_norm_radius)
<a name="l180"></a> {
<a name="l181"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi);
<a name="l182"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi);
<a name="l183"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l184"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p1;
<a name="l185"></a> }
<a name="l186"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l187"></a>fn_p1:
<a name="l188"></a> </span><span class=cF1>if</span><span class=cF0> (state)
<a name="l189"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;p1, x, y);
<a name="l190"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l191"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;p1, &amp;tmpp-&gt;p);
<a name="l192"></a>
<a name="l193"></a> </span><span class=cF2>//Draw an arc other direction, finding point of contact.</span><span class=cF0>
<a name="l194"></a> </span><span class=cF1>for</span><span class=cF0> (step = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; step &gt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0>; step /= </span><span class=cFE>4</span><span class=cF0>)
<a name="l195"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l196"></a> </span><span class=cF1>for</span><span class=cF0> (phi = </span><span class=cFE>0</span><span class=cF0>; phi &lt;= </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>; phi += step * </span><span class=cF3>pi</span><span class=cF0> / bmp_norm_radius)
<a name="l197"></a> {
<a name="l198"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l199"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l200"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l201"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
<a name="l202"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi);
<a name="l203"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> - phi) ;
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l205"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
<a name="l206"></a> }
<a name="l207"></a> </span><span class=cF1>for</span><span class=cF0> (; phi &lt;= </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0>; phi += step * </span><span class=cF3>pi</span><span class=cF0> / bmp_norm_radius)
<a name="l208"></a> {
<a name="l209"></a> x = p.x + bmp_norm_radius * </span><span class=cF5>Cos</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l210"></a> y = p.y + bmp_norm_radius * </span><span class=cF5>Sin</span><span class=cF0>(theta + </span><span class=cF3>pi</span><span class=cF0> + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>4</span><span class=cF0> + phi);
<a name="l211"></a> </span><span class=cF1>if</span><span class=cF0> (state = BmpPeek</span><span class=cF7>(</span><span class=cF0>bmp, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l212"></a> </span><span class=cF1>goto</span><span class=cF0> fn_p2;
<a name="l213"></a> }
<a name="l214"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l215"></a>fn_p2:
<a name="l216"></a> </span><span class=cF1>if</span><span class=cF0> (state)
<a name="l217"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;p2, x, y);
<a name="l218"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l219"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;p2, &amp;tmpp-&gt;p);
<a name="l220"></a>
<a name="l221"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&amp;p, &amp;p1, &amp;p2);
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3NormSqr</span><span class=cF7>(</span><span class=cF0>&amp;p</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0>)
<a name="l223"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l224"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;n, </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l225"></a> </span><span class=cF1>lock</span><span class=cF0> {zero_normal++;}
<a name="l226"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l227"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l228"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l229"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;n, p.y, -p.x);
<a name="l230"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3Dot</span><span class=cF7>(</span><span class=cF0>&amp;tmpp-&gt;n, &amp;tmpp-&gt;v</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l231"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;n, -p.y, p.x);
<a name="l232"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&amp;tmpp-&gt;n);
<a name="l233"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l234"></a>}
<a name="l235"></a>
<a name="l236"></a></span><span class=cF1>U0</span><span class=cF0> Mirror(Photon *tmpp)
<a name="l237"></a>{</span><span class=cF2>/*</span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l238"></a>
<a name="l239"></a>
<a name="l240"></a>
<a name="l241"></a>
<a name="l242"></a>
<a name="l243"></a>
<a name="l244"></a>
<a name="l245"></a>
<a name="l246"></a>
<a name="l247"></a>
<a name="l248"></a></span><span class=cF2>thetaout = pi+thetan - (thetain-thetan)</span><span class=cF0>
<a name="l249"></a>
<a name="l250"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l251"></a> </span><span class=cF1>F64</span><span class=cF0> theta = </span><span class=cF5>Arg</span><span class=cF0>(tmpp-&gt;v.x, tmpp-&gt;v.y), thetan;
<a name="l252"></a>
<a name="l253"></a> FindNormal(bmp_reflect, tmpp);
<a name="l254"></a> thetan = </span><span class=cF5>Arg</span><span class=cF0>(tmpp-&gt;n.x, tmpp-&gt;n.y);
<a name="l255"></a>
<a name="l256"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;v, </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cFE>2</span><span class=cF0> * thetan + </span><span class=cF3>pi</span><span class=cF0> - theta</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cFE>2</span><span class=cF0> * thetan + </span><span class=cF3>pi</span><span class=cF0> - theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l257"></a> </span><span class=cF1>lock</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>mirror_count++;</span><span class=cF7>}</span><span class=cF0>
<a name="l258"></a>}
<a name="l259"></a>
<a name="l260"></a></span><span class=cF1>U0</span><span class=cF0> SnellsLaw(Photon *tmpp, </span><span class=cF9>I64</span><span class=cF0> last, </span><span class=cF9>I64</span><span class=cF0> next)
<a name="l261"></a>{
<a name="l262"></a></span><span class=cF2>//n1 and n2 are refraction index.</span><span class=cF0>
<a name="l263"></a></span><span class=cF2>//n1 Sin(theta1) == n2 Sin(theta2)</span><span class=cF0>
<a name="l264"></a> </span><span class=cF1>F64</span><span class=cF0> theta = </span><span class=cF5>Arg</span><span class=cF0>(tmpp-&gt;v.x, tmpp-&gt;v.y), thetan, n1, n2, theta1, theta2;
<a name="l265"></a>
<a name="l266"></a> </span><span class=cF1>if</span><span class=cF0> (last == LENS_COLOR)
<a name="l267"></a> n1 = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l268"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l269"></a> n1 = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l270"></a> </span><span class=cF1>if</span><span class=cF0> (next == LENS_COLOR)
<a name="l271"></a> n2 = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l272"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l273"></a> n2 = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l274"></a> FindNormal(bmp_refract, tmpp);
<a name="l275"></a> thetan = </span><span class=cF5>Arg</span><span class=cF0>(tmpp-&gt;n.x, tmpp-&gt;n.y);
<a name="l276"></a>
<a name="l277"></a> </span><span class=cF2>//Dot=m1m2Cos(theta);</span><span class=cF0>
<a name="l278"></a> theta1 = </span><span class=cF5>ACos</span><span class=cF0>(</span><span class=cF5>D3Dot</span><span class=cF7>(</span><span class=cF0>&amp;tmpp-&gt;n, &amp;tmpp-&gt;v</span><span class=cF7>)</span><span class=cF0>);
<a name="l279"></a> theta2 = </span><span class=cF5>ASin</span><span class=cF0>(n1 * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta1</span><span class=cF7>)</span><span class=cF0> / n2);
<a name="l280"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>theta - thetan</span><span class=cF7>)</span><span class=cF0> &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l281"></a> theta = thetan + theta2;
<a name="l282"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l283"></a> theta = thetan - theta2;
<a name="l284"></a>
<a name="l285"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&amp;tmpp-&gt;v, </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l286"></a> </span><span class=cF1>lock</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>snell_count++;</span><span class=cF7>}</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> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l290"></a>{
<a name="l291"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l292"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l293"></a> master_sleep_jiffy += ANIMATE_JIFFIES;
<a name="l294"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>counts</span><span class=cF0>.jiffies &gt;= master_sleep_jiffy)
<a name="l295"></a> master_sleep_jiffy = </span><span class=cFB>counts</span><span class=cF0>.jiffies + ANIMATE_JIFFIES;
<a name="l296"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(master_sleep_jiffy);
<a name="l297"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l298"></a>}
<a name="l299"></a>
<a name="l300"></a>#</span><span class=cF1>define</span><span class=cF0> BABY_STEPS </span><span class=cFE>4</span><span class=cF0>
<a name="l301"></a>
<a name="l302"></a></span><span class=cF1>U0</span><span class=cF0> MPAnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l303"></a>{
<a name="l304"></a> </span><span class=cF9>I64</span><span class=cF0> i, last_master_jiffy = </span><span class=cFE>0</span><span class=cF0>,
<a name="l305"></a> timeout_jiffy = master_sleep_jiffy + ANIMATE_JIFFIES,
<a name="l306"></a> last, next;
<a name="l307"></a> </span><span class=cF1>Bool</span><span class=cF0> inhibit;
<a name="l308"></a> </span><span class=cF9>CD3</span><span class=cF0> step;
<a name="l309"></a> Photon *tmpp, *root = &amp;p_root[</span><span class=cF5>Gs</span><span class=cF0>-&gt;num];
<a name="l310"></a>
<a name="l311"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l312"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l313"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;p_root_locks, </span><span class=cF5>Gs</span><span class=cF0>-&gt;num</span><span class=cF7>)</span><span class=cF0>)
<a name="l314"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l315"></a> tmpp = root-&gt;next;
<a name="l316"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp != root)
<a name="l317"></a> {
<a name="l318"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; BABY_STEPS; i++)
<a name="l319"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l320"></a> last = </span><span class=cF5>GrPeek</span><span class=cF0>(map, tmpp-&gt;p.x, tmpp-&gt;p.y);
<a name="l321"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&amp;step, &amp;tmpp-&gt;v, BABY_STEPS);
<a name="l322"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&amp;tmpp-&gt;p, &amp;step);
<a name="l323"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;p.x &lt; BORDER)
<a name="l324"></a> {
<a name="l325"></a> tmpp-&gt;p.x = </span><span class=cFE>2</span><span class=cF0> * BORDER - tmpp-&gt;p.x;
<a name="l326"></a> tmpp-&gt;v.x = -tmpp-&gt;v.x;
<a name="l327"></a> }
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;p.x &gt;= map-&gt;width-BORDER)
<a name="l329"></a> {
<a name="l330"></a> tmpp-&gt;p.x -= tmpp-&gt;p.x - map-&gt;width + BORDER;
<a name="l331"></a> tmpp-&gt;v.x = -tmpp-&gt;v.x;
<a name="l332"></a> }
<a name="l333"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;p.y &lt; BORDER)
<a name="l334"></a> {
<a name="l335"></a> tmpp-&gt;p.y = </span><span class=cFE>2</span><span class=cF0> * BORDER - tmpp-&gt;p.y;
<a name="l336"></a> tmpp-&gt;v.y = -tmpp-&gt;v.y;
<a name="l337"></a> }
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;p.y &gt;= map-&gt;height - BORDER)
<a name="l339"></a> {
<a name="l340"></a> tmpp-&gt;p.y -= tmpp-&gt;p.y - map-&gt;height + BORDER;
<a name="l341"></a> tmpp-&gt;v.y = -tmpp-&gt;v.y;
<a name="l342"></a> }
<a name="l343"></a> next = </span><span class=cF5>GrPeek</span><span class=cF0>(map, tmpp-&gt;p.x, tmpp-&gt;p.y);
<a name="l344"></a>
<a name="l345"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3DistSqr</span><span class=cF7>(</span><span class=cF0>&amp;tmpp-&gt;p_normal_inhibit, &amp;tmpp-&gt;p</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>4</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l346"></a> inhibit = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l347"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l348"></a> inhibit = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l349"></a>
<a name="l350"></a> </span><span class=cF1>if</span><span class=cF0> (last != next)
<a name="l351"></a> {
<a name="l352"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>last == </span><span class=cF3>BLACK</span><span class=cF0> &amp;&amp; next == LENS_COLOR</span><span class=cF7>)</span><span class=cF0> || </span><span class=cF7>(</span><span class=cF0>last == LENS_COLOR &amp;&amp; next == </span><span class=cF3>BLACK</span><span class=cF7>)</span><span class=cF0>)
<a name="l353"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l354"></a> </span><span class=cF1>if</span><span class=cF0> (inhibit)
<a name="l355"></a> </span><span class=cF1>lock</span><span class=cF0> {normal_inhibit++;}
<a name="l356"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l357"></a> SnellsLaw(tmpp, last, next);
<a name="l358"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l359"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (last == </span><span class=cF3>BLACK</span><span class=cF0> &amp;&amp; next == MIRROR_COLOR)
<a name="l360"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l361"></a> </span><span class=cF1>if</span><span class=cF0> (inhibit)
<a name="l362"></a> </span><span class=cF1>lock</span><span class=cF0> {normal_inhibit++;}
<a name="l363"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l364"></a> Mirror(tmpp);
<a name="l365"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l366"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!inhibit)
<a name="l367"></a> </span><span class=cF5>D3Zero</span><span class=cF0>(&amp;tmpp-&gt;p_normal_inhibit);
<a name="l368"></a> }
<a name="l369"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!inhibit)
<a name="l370"></a> </span><span class=cF5>D3Zero</span><span class=cF0>(&amp;tmpp-&gt;p_normal_inhibit);
<a name="l371"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l372"></a>
<a name="l373"></a> tmpp = tmpp-&gt;next;
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>counts</span><span class=cF0>.jiffies &gt;= timeout_jiffy)
<a name="l375"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l376"></a> }
<a name="l377"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;p_root_locks, </span><span class=cF5>Gs</span><span class=cF0>-&gt;num);
<a name="l378"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>counts</span><span class=cF0>.jiffies &gt;= timeout_jiffy)
<a name="l379"></a> {
<a name="l380"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l381"></a> timeout_jiffy = master_sleep_jiffy + ANIMATE_JIFFIES;
<a name="l382"></a> }
<a name="l383"></a> </span><span class=cF1>if</span><span class=cF0> (!full_speed)
<a name="l384"></a> {
<a name="l385"></a> </span><span class=cF1>while</span><span class=cF0> (master_sleep_jiffy == last_master_jiffy)
<a name="l386"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l387"></a> last_master_jiffy = master_sleep_jiffy;
<a name="l388"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(master_sleep_jiffy);
<a name="l389"></a> timeout_jiffy = master_sleep_jiffy + ANIMATE_JIFFIES;
<a name="l390"></a> }
<a name="l391"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l392"></a>}
<a name="l393"></a>
<a name="l394"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l395"></a>{
<a name="l396"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l397"></a>
<a name="l398"></a> master_sleep_jiffy = </span><span class=cFB>counts</span><span class=cF0>.jiffies;
<a name="l399"></a> full_speed = show_normals = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l400"></a> photon_count = mirror_count = snell_count = normal_inhibit = zero_normal = </span><span class=cFE>0</span><span class=cF0>;
<a name="l401"></a> map = </span><span class=cF5>DCNew</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height);
<a name="l402"></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=cFB>mp_count</span><span class=cF0>; i++)
<a name="l403"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l404"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;p_root_locks, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l405"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l406"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;p_root[i]);
<a name="l407"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;p_root_locks, i);
<a name="l408"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l409"></a> </span><span class=cF2>//x*y=bmp_mem*8</span><span class=cF0>
<a name="l410"></a> </span><span class=cF2>//x/y=640/480</span><span class=cF0>
<a name="l411"></a> </span><span class=cF2>//x=640/480*y</span><span class=cF0>
<a name="l412"></a> </span><span class=cF2>//640/480*y^2=bmp_mem*8</span><span class=cF0>
<a name="l413"></a> </span><span class=cF2>//y=Sqrt(bmp_mem*8*480/640)</span><span class=cF0>
<a name="l414"></a> </span><span class=cF2>//bmp_scale=Sqrt(bmp_mem*8*480/640)/480</span><span class=cF0>
<a name="l415"></a> bmp_scale = </span><span class=cF5>Sqrt</span><span class=cF0>(bmp_mem / </span><span class=cFE>2</span><span class=cF0> * </span><span class=cFE>8</span><span class=cF0> * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height / </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width) / </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l416"></a>
<a name="l417"></a> find_normal_dist_sqr = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Sqr</span><span class=cF0>(bmp_scale);
<a name="l418"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0>) &lt;= BORDER
<a name="l419"></a>
<a name="l420"></a> bmp_width = bmp_scale * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width;
<a name="l421"></a> bmp_height = bmp_scale * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l422"></a> bmp_refract = </span><span class=cF5>CAlloc</span><span class=cF0>(bmp_width * bmp_height / </span><span class=cFE>8</span><span class=cF0>);
<a name="l423"></a> bmp_reflect = </span><span class=cF5>CAlloc</span><span class=cF0>(bmp_width * bmp_height / </span><span class=cFE>8</span><span class=cF0>);
<a name="l424"></a> bmp_norm_radius = </span><span class=cF5>Min</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0> * bmp_scale, </span><span class=cFE>250</span><span class=cF0>);
<a name="l425"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cFE>10</span><span class=cF0> &lt;= BORDER
<a name="l426"></a>}
<a name="l427"></a>
<a name="l428"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l429"></a>{
<a name="l430"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l431"></a>
<a name="l432"></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=cFB>mp_count</span><span class=cF0>; i++)
<a name="l433"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l434"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;p_root_locks, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l435"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l436"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;p_root[i], </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l437"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;p_root_locks, i);
<a name="l438"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l439"></a> </span><span class=cF5>DCDel</span><span class=cF0>(map);
<a name="l440"></a> </span><span class=cF5>Free</span><span class=cF0>(bmp_refract);
<a name="l441"></a> </span><span class=cF5>Free</span><span class=cF0>(bmp_reflect);
<a name="l442"></a>}
<a name="l443"></a>
<a name="l444"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFLECT_LINE </span><span class=cFE>0</span><span class=cF0>
<a name="l445"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFLECT_SPLINE </span><span class=cFE>1</span><span class=cF0>
<a name="l446"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_LINE </span><span class=cFE>2</span><span class=cF0>
<a name="l447"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_SPLINE </span><span class=cFE>3</span><span class=cF0>
<a name="l448"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_REFRACT_FLOOD_FILL </span><span class=cFE>4</span><span class=cF0>
<a name="l449"></a>#</span><span class=cF1>define</span><span class=cF0> LTM_TEST_RAY </span><span class=cFE>5</span><span class=cF0>
<a name="l450"></a>
<a name="l451"></a></span><span class=cF1>U0</span><span class=cF0> LTMenuSet(</span><span class=cF9>I64</span><span class=cF0> mode)
<a name="l452"></a>{
<a name="l453"></a> </span><span class=cF9>CMenuEntry</span><span class=cF0> *entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;View/ToggleNormals&quot;</span><span class=cF0>);
<a name="l454"></a>
<a name="l455"></a> </span><span class=cF1>if</span><span class=cF0> (show_normals)
<a name="l456"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l457"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l458"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l459"></a>
<a name="l460"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/ReflectLine&quot;</span><span class=cF0>);
<a name="l461"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_LINE)
<a name="l462"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l463"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l464"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l465"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/ReflectSpline&quot;</span><span class=cF0>);
<a name="l466"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_SPLINE)
<a name="l467"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l468"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l469"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l470"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/RefractLine&quot;</span><span class=cF0>);
<a name="l471"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFRACT_LINE)
<a name="l472"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l473"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l474"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l475"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/RefractSpline&quot;</span><span class=cF0>);
<a name="l476"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFRACT_SPLINE)
<a name="l477"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l478"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l479"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l480"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/RefractFloodFill&quot;</span><span class=cF0>);
<a name="l481"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFRACT_FLOOD_FILL)
<a name="l482"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l483"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l484"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l485"></a> entry = </span><span class=cF5>MenuEntryFind</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_menu, </span><span class=cF6>&quot;Mode/TestRay&quot;</span><span class=cF0>);
<a name="l486"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_TEST_RAY)
<a name="l487"></a> entry-&gt;checked = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l488"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l489"></a> entry-&gt;checked = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l490"></a>}
<a name="l491"></a>
<a name="l492"></a>#</span><span class=cF1>define</span><span class=cF0> PTS_NUM </span><span class=cFE>1024</span><span class=cF0>
<a name="l493"></a></span><span class=cF1>U0</span><span class=cF0> LightTable()
<a name="l494"></a>{
<a name="l495"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, mode = LTM_REFLECT_LINE, i, count, arg1, arg2, x1, y1, x2, y2;
<a name="l496"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c = </span><span class=cF5>MAlloc</span><span class=cF0>(PTS_NUM * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l497"></a>
<a name="l498"></a> p_root_locks = </span><span class=cFE>0</span><span class=cF0>;
<a name="l499"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l500"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l501"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l502"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l503"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l504"></a> </span><span class=cF6>&quot;Mode {&quot;</span><span class=cF0>
<a name="l505"></a> </span><span class=cF6>&quot; ReflectLine(,'0');&quot;</span><span class=cF0>
<a name="l506"></a> </span><span class=cF6>&quot; ReflectSpline(,'1');&quot;</span><span class=cF0>
<a name="l507"></a> </span><span class=cF6>&quot; RefractLine(,'2');&quot;</span><span class=cF0>
<a name="l508"></a> </span><span class=cF6>&quot; RefractSpline(,'3');&quot;</span><span class=cF0>
<a name="l509"></a> </span><span class=cF6>&quot; RefractFloodFill(,'4');&quot;</span><span class=cF0>
<a name="l510"></a> </span><span class=cF6>&quot; TestRay(,'5');&quot;</span><span class=cF0>
<a name="l511"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l512"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l513"></a> </span><span class=cF6>&quot; RandomBurst(,'r');&quot;</span><span class=cF0>
<a name="l514"></a> </span><span class=cF6>&quot; ElapseTime(,'e');&quot;</span><span class=cF0>
<a name="l515"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l516"></a> </span><span class=cF6>&quot;View {&quot;</span><span class=cF0>
<a name="l517"></a> </span><span class=cF6>&quot; ToggleNormals(,'n');&quot;</span><span class=cF0>
<a name="l518"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l519"></a> );
<a name="l520"></a> LTMenuSet(mode);
<a name="l521"></a>
<a name="l522"></a> </span><span class=cF5>MemBIOSRep</span><span class=cF0>;
<a name="l523"></a> bmp_mem = </span><span class=cF5>I64Get</span><span class=cF0>(</span><span class=cF6>&quot;\n\n\nHow much memory for the high resolution\n&quot;</span><span class=cF0>
<a name="l524"></a> </span><span class=cF6>&quot;shadow bitmap that helps improve the\n&quot;</span><span class=cF0>
<a name="l525"></a> </span><span class=cF6>&quot;accuracy of the normal vector estimate?\n&quot;</span><span class=cF0>
<a name="l526"></a> </span><span class=cF6>&quot;You can choose up to the largest\n&quot;</span><span class=cF0>
<a name="l527"></a> </span><span class=cF6>&quot;contiguous chunk of physical memory.\n\n&quot;</span><span class=cF0>
<a name="l528"></a> </span><span class=cF6>&quot;Mem (0x%0X):&quot;</span><span class=cF0>, </span><span class=cFE>1024</span><span class=cF0> * </span><span class=cFE>1024</span><span class=cF0> * </span><span class=cFE>16</span><span class=cF0>);
<a name="l529"></a>
<a name="l530"></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="l531"></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_SELF_FOCUS</span><span class=cF0> - </span><span class=cF3>WIF_SELF_BORDER</span><span class=cF0> - </span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0>;
<a name="l532"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr = </span><span class=cF3>BLACK</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>WHITE</span><span class=cF0>; </span><span class=cF2>//Current </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3941"><span class=cF4>CTask</span></a><span class=cF2> is Fs segment register.</span><span class=cF0>
<a name="l533"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l534"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l535"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l536"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l537"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l538"></a> Init;
<a name="l539"></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="l540"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l541"></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=cFB>mp_count</span><span class=cF0>; i++)
<a name="l542"></a> animate_tasks[i] = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;MPAnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;MPAnimate&quot;</span><span class=cF0>, i);
<a name="l543"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l544"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l545"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l546"></a> {
<a name="l547"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&amp;arg1, &amp;arg2,
<a name="l548"></a> </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> + </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_L_UP</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>);
<a name="l549"></a>lt_restart:
<a name="l550"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
<a name="l551"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l552"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>:
<a name="l553"></a> </span><span class=cF5>Sweep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>, </span><span class=cFE>90</span><span class=cF0>, </span><span class=cFE>100</span><span class=cF0>);
<a name="l554"></a> x2 = arg1;
<a name="l555"></a> y2 = arg2;
<a name="l556"></a> </span><span class=cF1>switch</span><span class=cF0> (mode)
<a name="l557"></a> {
<a name="l558"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_FLOOD_FILL:
<a name="l559"></a> map-&gt;color = LENS_COLOR;
<a name="l560"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(map, x2, y2);
<a name="l561"></a> mode = LTM_REFLECT_LINE;
<a name="l562"></a> LTMenuSet(mode);
<a name="l563"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l564"></a>
<a name="l565"></a> </span><span class=cF1>case</span><span class=cF0> LTM_TEST_RAY:
<a name="l566"></a> RayBurst(x1, y1, x2, y2);
<a name="l567"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l568"></a> }
<a name="l569"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l570"></a>
<a name="l571"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
<a name="l572"></a> x1 = arg1;
<a name="l573"></a> y1 = arg2;
<a name="l574"></a> </span><span class=cF1>switch</span><span class=cF0> (mode)
<a name="l575"></a> {
<a name="l576"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFLECT_LINE:
<a name="l577"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_LINE:
<a name="l578"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_LINE)
<a name="l579"></a> map-&gt;color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + MIRROR_COLOR;
<a name="l580"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l581"></a> map-&gt;color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + LENS_COLOR;
<a name="l582"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l583"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l584"></a> x2 = arg1;
<a name="l585"></a> y2 = arg2;
<a name="l586"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map, x1, y1, x2, y2);
<a name="l587"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&amp;arg1, &amp;arg2,
<a name="l588"></a> </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_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=cF0>);
<a name="l589"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map, x1, y1, x2, y2);
<a name="l590"></a> </span><span class=cF1>if</span><span class=cF0> (message_code == </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>)
<a name="l591"></a> </span><span class=cF1>goto</span><span class=cF0> lt_restart;
<a name="l592"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (message_code == </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>)
<a name="l593"></a> {
<a name="l594"></a> </span><span class=cF5>Sweep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>, </span><span class=cFE>90</span><span class=cF0>, </span><span class=cFE>100</span><span class=cF0>);
<a name="l595"></a> x2 = arg1;
<a name="l596"></a> y2 = arg2;
<a name="l597"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l598"></a> }
<a name="l599"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l600"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_LINE)
<a name="l601"></a> map-&gt;color = MIRROR_COLOR;
<a name="l602"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l603"></a> map-&gt;color = LENS_COLOR;
<a name="l604"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map, x1, y1, x2, y2);
<a name="l605"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_LINE)
<a name="l606"></a> BmpLine(bmp_reflect, x1, y1, x2, y2);
<a name="l607"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l608"></a> BmpLine(bmp_refract, x1, y1, x2, y2);
<a name="l609"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l610"></a>
<a name="l611"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFLECT_SPLINE:
<a name="l612"></a> </span><span class=cF1>case</span><span class=cF0> LTM_REFRACT_SPLINE:
<a name="l613"></a> count = </span><span class=cFE>0</span><span class=cF0>;
<a name="l614"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_SPLINE)
<a name="l615"></a> map-&gt;color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + MIRROR_COLOR;
<a name="l616"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l617"></a> map-&gt;color = </span><span class=cF3>ROP_XOR</span><span class=cF0> + LENS_COLOR;
<a name="l618"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l619"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l620"></a> c[count].x = arg1;
<a name="l621"></a> c[count].y = arg2;
<a name="l622"></a> c[count].z = </span><span class=cFE>0</span><span class=cF0>;
<a name="l623"></a> </span><span class=cF5>Gr2BSpline</span><span class=cF0>(map, c, count + </span><span class=cFE>1</span><span class=cF0>);
<a name="l624"></a> message_code = </span><span class=cF5>MessageGet</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_UP</span><span class=cF0> +
<a name="l625"></a> </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_MOVE</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>);
<a name="l626"></a> </span><span class=cF5>Gr2BSpline</span><span class=cF0>(map, c, count + </span><span class=cFE>1</span><span class=cF0>);
<a name="l627"></a> </span><span class=cF1>if</span><span class=cF0> (message_code == </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>)
<a name="l628"></a> </span><span class=cF1>goto</span><span class=cF0> lt_restart;
<a name="l629"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (message_code == </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>)
<a name="l630"></a> {
<a name="l631"></a> </span><span class=cF5>Sweep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>, </span><span class=cFE>90</span><span class=cF0>, </span><span class=cFE>100</span><span class=cF0>);
<a name="l632"></a> count++;
<a name="l633"></a> }
<a name="l634"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l635"></a> </span><span class=cF1>while</span><span class=cF0> (count &lt; PTS_NUM - </span><span class=cFE>1</span><span class=cF0> &amp;&amp; message_code != </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0>);
<a name="l636"></a>
<a name="l637"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_SPLINE)
<a name="l638"></a> map-&gt;color = MIRROR_COLOR;
<a name="l639"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l640"></a> map-&gt;color = LENS_COLOR;
<a name="l641"></a> </span><span class=cF5>Gr2BSpline3</span><span class=cF0>(map, c, count);
<a name="l642"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; count; i++)
<a name="l643"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l644"></a> c[i].x *= bmp_scale;
<a name="l645"></a> c[i].y *= bmp_scale;
<a name="l646"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l647"></a> </span><span class=cF1>if</span><span class=cF0> (mode == LTM_REFLECT_SPLINE)
<a name="l648"></a> </span><span class=cF5>BSpline2</span><span class=cF0>(bmp_reflect, c, count, &amp;BmpPlot);
<a name="l649"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l650"></a> </span><span class=cF5>BSpline2</span><span class=cF0>(bmp_refract, c, count, &amp;BmpPlot);
<a name="l651"></a> mode = LTM_REFLECT_LINE;
<a name="l652"></a> LTMenuSet(mode);
<a name="l653"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l654"></a> }
<a name="l655"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l656"></a>
<a name="l657"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0>:
<a name="l658"></a> i = </span><span class=cF5>PopUpPickList</span><span class=cF0>(</span><span class=cF6>&quot;Reflect Line\0Reflect Spline\0Refract Line\0&quot;</span><span class=cF0>
<a name="l659"></a> </span><span class=cF6>&quot;Refract Spline\0Refract Flood Fill\0TestRay\0&quot;</span><span class=cF0>);
<a name="l660"></a> </span><span class=cF1>if</span><span class=cF0> (i &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l661"></a> {
<a name="l662"></a> mode = i;
<a name="l663"></a> LTMenuSet(mode);
<a name="l664"></a> }
<a name="l665"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l666"></a>
<a name="l667"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
<a name="l668"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
<a name="l669"></a> {
<a name="l670"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l671"></a> CleanUp;
<a name="l672"></a> Init;
<a name="l673"></a> mode = LTM_REFLECT_LINE;
<a name="l674"></a> LTMenuSet(mode);
<a name="l675"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l676"></a>
<a name="l677"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'r'</span><span class=cF0>:
<a name="l678"></a> RandomBurst;
<a name="l679"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l680"></a>
<a name="l681"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'e'</span><span class=cF0>:
<a name="l682"></a> full_speed = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l683"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1500</span><span class=cF0>);
<a name="l684"></a> </span><span class=cF5>FlushMessages</span><span class=cF0>;
<a name="l685"></a> full_speed = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l686"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l687"></a>
<a name="l688"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'n'</span><span class=cF0>:
<a name="l689"></a> show_normals = !show_normals;
<a name="l690"></a> LTMenuSet(mode);
<a name="l691"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l692"></a>
<a name="l693"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>...</span><span class=cF6>'5'</span><span class=cF0>:
<a name="l694"></a> mode = arg1-</span><span class=cF6>'0'</span><span class=cF0>;
<a name="l695"></a> LTMenuSet(mode);
<a name="l696"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l697"></a>
<a name="l698"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l699"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l700"></a> </span><span class=cF1>goto</span><span class=cF0> lt_done;
<a name="l701"></a> }
<a name="l702"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l703"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l704"></a> }
<a name="l705"></a>lt_done:
<a name="l706"></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="l707"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l708"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l709"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l710"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l711"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l712"></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=cFB>mp_count</span><span class=cF0>; i++)
<a name="l713"></a> </span><span class=cF5>Kill</span><span class=cF0>(animate_tasks[i]);
<a name="l714"></a> CleanUp;
<a name="l715"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l716"></a>}
<a name="l717"></a>
<a name="l718"></a>LightTable;
</span></pre></body>
</html>