mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
d639cdcdf6
Rename 0000Kernel.BIN.C to Kernel.BIN.C.
747 lines
76 KiB
HTML
Executable file
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.09">
|
|
<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> <= x < bmp_width && </span><span class=cFE>0</span><span class=cF0> <= y < 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>, &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>&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>(&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->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>"Mem:0x%X %,dMeg Scale:%0.3f (%d,%d)-->(%d,%d)"</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->width, map->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>"PhotonCount:%d MirrorCount:%d SnellCount:%d SnellInhibit:%d ZeroNormal:%d"</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 < </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>&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 != &p_root[i])
|
|
<a name="l80"></a> {
|
|
<a name="l81"></a> dc->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->p.x - VECTOR * tmpp->v.x, tmpp->p.y - VECTOR * tmpp->v.y, tmpp->p.x, tmpp->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->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->p.x, tmpp->p.y, tmpp->p.x + VECTOR * tmpp->n.x, tmpp->p.y + VECTOR * tmpp->n.y);
|
|
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l88"></a> tmpp = tmpp->next;
|
|
<a name="l89"></a> }
|
|
<a name="l90"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&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> &&
|
|
<a name="l103"></a> BORDER + WING < x2 < map->width - BORDER - WING && BORDER + WING < y2 < map->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>(&p, x2, y2);
|
|
<a name="l106"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&v, x2 - x1, y2 - y1);
|
|
<a name="l107"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&v);
|
|
<a name="l108"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&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>(&tmpp->p, &p);
|
|
<a name="l112"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v, &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 <= 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>(&n2, i, &n);
|
|
<a name="l117"></a>
|
|
<a name="l118"></a> tmpp = PhotonNew;
|
|
<a name="l119"></a> </span><span class=cF5>D3Add</span><span class=cF0>(&tmpp->p, &p, &n2);
|
|
<a name="l120"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v, &v);
|
|
<a name="l121"></a>
|
|
<a name="l122"></a> tmpp = PhotonNew;
|
|
<a name="l123"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&tmpp->p, &p, &n2);
|
|
<a name="l124"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&tmpp->v, &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 < </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>(&tmpp->p, </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->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>->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>(&tmpp->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->v.x, tmpp->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>(&tmpp->p_normal_inhibit, &tmpp->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>(&tmpp->p, &tmpp->v);
|
|
<a name="l158"></a> </span><span class=cF5>D3Mul</span><span class=cF0>(&p, bmp_scale, &tmpp->p);
|
|
<a name="l159"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p1, &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> && </span><span class=cF5>D3DistSqr</span><span class=cF7>(</span><span class=cF0>&p, &p1</span><span class=cF7>)</span><span class=cF0> < find_normal_dist_sqr)
|
|
<a name="l161"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&p1, &tmpp->v);
|
|
<a name="l162"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&p, &p1);
|
|
<a name="l163"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&tmpp->p, &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 >= </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 <= </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 <= </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>(&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>(&p1, &tmpp->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 >= </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 <= </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 <= </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>(&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>(&p2, &tmpp->p);
|
|
<a name="l220"></a>
|
|
<a name="l221"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&p, &p1, &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>&p</span><span class=cF7>)</span><span class=cF0> < </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>(&tmpp->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>(&tmpp->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>&tmpp->n, &tmpp->v</span><span class=cF7>)</span><span class=cF0> < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l231"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->n, -p.y, p.x);
|
|
<a name="l232"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&tmpp->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><1>/* 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->v.x, tmpp->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->n.x, tmpp->n.y);
|
|
<a name="l255"></a>
|
|
<a name="l256"></a> </span><span class=cF5>D3Equ</span><span class=cF0>(&tmpp->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->v.x, tmpp->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->n.x, tmpp->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>&tmpp->n, &tmpp->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> >= </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>(&tmpp->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 >= 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 = &p_root[</span><span class=cF5>Gs</span><span class=cF0>->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>&p_root_locks, </span><span class=cF5>Gs</span><span class=cF0>->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->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 < 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->p.x, tmpp->p.y);
|
|
<a name="l321"></a> </span><span class=cF5>D3Div</span><span class=cF0>(&step, &tmpp->v, BABY_STEPS);
|
|
<a name="l322"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&tmpp->p, &step);
|
|
<a name="l323"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.x < BORDER)
|
|
<a name="l324"></a> {
|
|
<a name="l325"></a> tmpp->p.x = </span><span class=cFE>2</span><span class=cF0> * BORDER - tmpp->p.x;
|
|
<a name="l326"></a> tmpp->v.x = -tmpp->v.x;
|
|
<a name="l327"></a> }
|
|
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.x >= map->width-BORDER)
|
|
<a name="l329"></a> {
|
|
<a name="l330"></a> tmpp->p.x -= tmpp->p.x - map->width + BORDER;
|
|
<a name="l331"></a> tmpp->v.x = -tmpp->v.x;
|
|
<a name="l332"></a> }
|
|
<a name="l333"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.y < BORDER)
|
|
<a name="l334"></a> {
|
|
<a name="l335"></a> tmpp->p.y = </span><span class=cFE>2</span><span class=cF0> * BORDER - tmpp->p.y;
|
|
<a name="l336"></a> tmpp->v.y = -tmpp->v.y;
|
|
<a name="l337"></a> }
|
|
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->p.y >= map->height - BORDER)
|
|
<a name="l339"></a> {
|
|
<a name="l340"></a> tmpp->p.y -= tmpp->p.y - map->height + BORDER;
|
|
<a name="l341"></a> tmpp->v.y = -tmpp->v.y;
|
|
<a name="l342"></a> }
|
|
<a name="l343"></a> next = </span><span class=cF5>GrPeek</span><span class=cF0>(map, tmpp->p.x, tmpp->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>&tmpp->p_normal_inhibit, &tmpp->p</span><span class=cF7>)</span><span class=cF0> < </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> && next == LENS_COLOR</span><span class=cF7>)</span><span class=cF0> || </span><span class=cF7>(</span><span class=cF0>last == LENS_COLOR && 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> && 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>(&tmpp->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>(&tmpp->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->next;
|
|
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>counts</span><span class=cF0>.jiffies >= 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>(&p_root_locks, </span><span class=cF5>Gs</span><span class=cF0>->num);
|
|
<a name="l378"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>counts</span><span class=cF0>.jiffies >= 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>->pix_width, </span><span class=cF5>Fs</span><span class=cF0>->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 < </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>&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>(&p_root[i]);
|
|
<a name="l407"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&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>->pix_height / </span><span class=cF5>Fs</span><span class=cF0>->pix_width) / </span><span class=cF5>Fs</span><span class=cF0>->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>) <= BORDER
|
|
<a name="l419"></a>
|
|
<a name="l420"></a> bmp_width = bmp_scale * </span><span class=cF5>Fs</span><span class=cF0>->pix_width;
|
|
<a name="l421"></a> bmp_height = bmp_scale * </span><span class=cF5>Fs</span><span class=cF0>->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> <= 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 < </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>&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>(&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>(&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>->cur_menu, </span><span class=cF6>"View/ToggleNormals"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/ReflectLine"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/ReflectSpline"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/RefractLine"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/RefractSpline"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/RefractFloodFill"</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->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->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>->cur_menu, </span><span class=cF6>"Mode/TestRay"</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->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->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>"File {"</span><span class=cF0>
|
|
<a name="l500"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l501"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l502"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l503"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l504"></a> </span><span class=cF6>"Mode {"</span><span class=cF0>
|
|
<a name="l505"></a> </span><span class=cF6>" ReflectLine(,'0');"</span><span class=cF0>
|
|
<a name="l506"></a> </span><span class=cF6>" ReflectSpline(,'1');"</span><span class=cF0>
|
|
<a name="l507"></a> </span><span class=cF6>" RefractLine(,'2');"</span><span class=cF0>
|
|
<a name="l508"></a> </span><span class=cF6>" RefractSpline(,'3');"</span><span class=cF0>
|
|
<a name="l509"></a> </span><span class=cF6>" RefractFloodFill(,'4');"</span><span class=cF0>
|
|
<a name="l510"></a> </span><span class=cF6>" TestRay(,'5');"</span><span class=cF0>
|
|
<a name="l511"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l512"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l513"></a> </span><span class=cF6>" RandomBurst(,'r');"</span><span class=cF0>
|
|
<a name="l514"></a> </span><span class=cF6>" ElapseTime(,'e');"</span><span class=cF0>
|
|
<a name="l515"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l516"></a> </span><span class=cF6>"View {"</span><span class=cF0>
|
|
<a name="l517"></a> </span><span class=cF6>" ToggleNormals(,'n');"</span><span class=cF0>
|
|
<a name="l518"></a> </span><span class=cF6>"}"</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>"\n\n\nHow much memory for the high resolution\n"</span><span class=cF0>
|
|
<a name="l524"></a> </span><span class=cF6>"shadow bitmap that helps improve the\n"</span><span class=cF0>
|
|
<a name="l525"></a> </span><span class=cF6>"accuracy of the normal vector estimate?\n"</span><span class=cF0>
|
|
<a name="l526"></a> </span><span class=cF6>"You can choose up to the largest\n"</span><span class=cF0>
|
|
<a name="l527"></a> </span><span class=cF6>"contiguous chunk of physical memory.\n\n"</span><span class=cF0>
|
|
<a name="l528"></a> </span><span class=cF6>"Mem (0x%0X):"</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>->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>->text_attr = </span><span class=cF3>BLACK</span><span class=cF0> << </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>->draw_it = &</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l540"></a> </span><span class=cF5>Fs</span><span class=cF0>->animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&AnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>"Animate"</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 < </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>(&MPAnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>"MPAnimate"</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>(&arg1, &arg2,
|
|
<a name="l548"></a> </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </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->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->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->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>(&arg1, &arg2,
|
|
<a name="l588"></a> </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </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->color = MIRROR_COLOR;
|
|
<a name="l602"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l603"></a> map->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->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->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>(&arg1, &arg2, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </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> << </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </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 < PTS_NUM - </span><span class=cFE>1</span><span class=cF0> && 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->color = MIRROR_COLOR;
|
|
<a name="l639"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l640"></a> map->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 < 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, &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, &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>"Reflect Line\0Reflect Spline\0Refract Line\0"</span><span class=cF0>
|
|
<a name="l659"></a> </span><span class=cF6>"Refract Spline\0Refract Flood Fill\0TestRay\0"</span><span class=cF0>);
|
|
<a name="l660"></a> </span><span class=cF1>if</span><span class=cF0> (i >= </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> << </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 < </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>
|