ZealOS/docs/Demo/Games/Varoom.CC.html
2021-09-21 23:45:45 -04:00

875 lines
81 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.01">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>
<a name="l2"></a>
<a name="l3"></a>
<a name="l4"></a>
<a name="l5"></a>
<a name="l6"></a> </span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a>
<a name="l10"></a> </span><span class=cFA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l11"></a>
<a name="l12"></a>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a>
<a name="l17"></a>
<a name="l18"></a> </span><span class=cFA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a>
<a name="l25"></a>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a>
<a name="l33"></a>
<a name="l34"></a>
<a name="l35"></a>
<a name="l36"></a>
<a name="l37"></a>
<a name="l38"></a>
<a name="l39"></a> </span><span class=cFA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l40"></a>
<a name="l41"></a>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a>
<a name="l46"></a>
<a name="l47"></a>
<a name="l48"></a>
<a name="l49"></a> </span><span class=cFA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l50"></a>
<a name="l51"></a>
<a name="l52"></a>
<a name="l53"></a>
<a name="l54"></a>
<a name="l55"></a>
<a name="l56"></a>
<a name="l57"></a>
<a name="l58"></a>
<a name="l59"></a>
<a name="l60"></a>
<a name="l61"></a>
<a name="l62"></a>
<a name="l63"></a>
<a name="l64"></a>
<a name="l65"></a>
<a name="l66"></a>
<a name="l67"></a>
<a name="l68"></a>
<a name="l69"></a>
<a name="l70"></a>
<a name="l71"></a>
<a name="l72"></a>
<a name="l73"></a>
<a name="l74"></a>
<a name="l75"></a>
<a name="l76"></a>
<a name="l77"></a> </span><span class=cFA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l78"></a>
<a name="l79"></a>
<a name="l80"></a>
<a name="l81"></a>
<a name="l82"></a>
<a name="l83"></a>
<a name="l84"></a>
<a name="l85"></a>
<a name="l86"></a>
<a name="l87"></a>
<a name="l88"></a>
<a name="l89"></a>
<a name="l90"></a></span><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Varoom&quot;</span><span class=cF0>, </span><span class=cF6>&quot;F64 best_score=9999;\n&quot;</span><span class=cF0>);
<a name="l91"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Varoom&quot;</span><span class=cF0>);
<a name="l92"></a>
<a name="l93"></a></span><span class=cF1>F64</span><span class=cF0> distance, t0, tf;
<a name="l94"></a></span><span class=cF1>Bool</span><span class=cF0> game_over;
<a name="l95"></a>
<a name="l96"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER </span><span class=cFE>7500</span><span class=cF0>
<a name="l97"></a>#</span><span class=cF1>define</span><span class=cF0> RADIUS </span><span class=cFE>10000</span><span class=cF0>
<a name="l98"></a>#</span><span class=cF1>define</span><span class=cF0> WIDTH </span><span class=cFE>2000</span><span class=cF0>
<a name="l99"></a>#</span><span class=cF1>define</span><span class=cF0> SHOULDER </span><span class=cFE>200</span><span class=cF0>
<a name="l100"></a>#</span><span class=cF1>define</span><span class=cF0> D_theta (</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>360</span><span class=cF0>) </span><span class=cF2>//Curve track slice is one degree.</span><span class=cF0>
<a name="l101"></a>#</span><span class=cF1>define</span><span class=cF0> D_S (</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * RADIUS / </span><span class=cFE>360</span><span class=cF0>) </span><span class=cF2>//Straight track is degree at 10000.</span><span class=cF0>
<a name="l102"></a>#</span><span class=cF1>define</span><span class=cF0> DIPS </span><span class=cFE>5</span><span class=cF0>
<a name="l103"></a>#</span><span class=cF1>define</span><span class=cF0> DIP_DEPTH </span><span class=cFE>50</span><span class=cF0>
<a name="l104"></a></span><span class=cF1>class</span><span class=cF0> Track
<a name="l105"></a>{
<a name="l106"></a> Track *next, *last;
<a name="l107"></a> </span><span class=cF9>I32</span><span class=cF0> num;
<a name="l108"></a> </span><span class=cF9>CColorROPU16</span><span class=cF0> c, pad;
<a name="l109"></a> </span><span class=cF9>I64</span><span class=cF0> x, z;
<a name="l110"></a> </span><span class=cF1>F64</span><span class=cF0> theta, d;
<a name="l111"></a> </span><span class=cF9>CD3I32</span><span class=cF0> left[</span><span class=cFE>4</span><span class=cF0>], center[</span><span class=cFE>4</span><span class=cF0>], right[</span><span class=cFE>4</span><span class=cF0>];
<a name="l112"></a>
<a name="l113"></a>} track_head, *track_start[</span><span class=cF3>MP_PROCESSORS_NUM</span><span class=cF0>], *track_end[</span><span class=cF3>MP_PROCESSORS_NUM</span><span class=cF0>];
<a name="l114"></a>
<a name="l115"></a></span><span class=cF9>CDC</span><span class=cF0> *track_map;
<a name="l116"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_BITS </span><span class=cFE>9</span><span class=cF0>
<a name="l117"></a></span><span class=cF9>I64</span><span class=cF0> t_minx, t_maxx, t_minz, t_maxz;
<a name="l118"></a>
<a name="l119"></a>#</span><span class=cF1>define</span><span class=cF0> BUSHES_NUM </span><span class=cFE>512</span><span class=cF0>
<a name="l120"></a></span><span class=cF1>class</span><span class=cF0> Bush
<a name="l121"></a>{
<a name="l122"></a> </span><span class=cF9>CD3I32</span><span class=cF0> p;
<a name="l123"></a> </span><span class=cF1>Bool</span><span class=cF0> sym, pad[</span><span class=cFE>3</span><span class=cF0>];
<a name="l124"></a> </span><span class=cF1>U8</span><span class=cF0> *img;
<a name="l125"></a>
<a name="l126"></a>} b[BUSHES_NUM];
<a name="l127"></a>
<a name="l128"></a>#</span><span class=cF1>define</span><span class=cF0> CARS_NUM </span><span class=cFE>8</span><span class=cF0>
<a name="l129"></a></span><span class=cF1>class</span><span class=cF0> Car
<a name="l130"></a>{
<a name="l131"></a> </span><span class=cF9>CD3I32</span><span class=cF0> p;
<a name="l132"></a> </span><span class=cF1>F64</span><span class=cF0> theta, dtheta, speed;
<a name="l133"></a> </span><span class=cF1>U8</span><span class=cF0> *img;
<a name="l134"></a> Track *t;
<a name="l135"></a>
<a name="l136"></a>} c[CARS_NUM];
<a name="l137"></a>
<a name="l138"></a></span><span class=cF9>I64</span><span class=cF0> DipY(</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> z)
<a name="l139"></a>{
<a name="l140"></a> </span><span class=cF1>F64</span><span class=cF0> m, a;
<a name="l141"></a>
<a name="l142"></a> </span><span class=cF5>R2P</span><span class=cF0>(&amp;m, &amp;a, x, z);
<a name="l143"></a>
<a name="l144"></a> </span><span class=cF1>return</span><span class=cF0> DIP_DEPTH * m * </span><span class=cF5>Cos</span><span class=cF0>(DIPS * a) / RADIUS;
<a name="l145"></a>}
<a name="l146"></a>
<a name="l147"></a>#</span><span class=cF1>define</span><span class=cF0> CAR_LENGTH </span><span class=cFE>400</span><span class=cF0>
<a name="l148"></a>
<a name="l149"></a></span><span class=cF1>F64</span><span class=cF0> Diptheta(</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> z, </span><span class=cF1>F64</span><span class=cF0> theta)
<a name="l150"></a>{
<a name="l151"></a> </span><span class=cF1>F64</span><span class=cF0> y_front, y_back;
<a name="l152"></a>
<a name="l153"></a> y_front = DipY(x - CAR_LENGTH / </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>, z - CAR_LENGTH / </span><span class=cFE>2</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="l154"></a> y_back = DipY(x + CAR_LENGTH / </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>, z + CAR_LENGTH / </span><span class=cFE>2</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="l155"></a>
<a name="l156"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ASin</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>y_front - y_back</span><span class=cF7>)</span><span class=cF0> / CAR_LENGTH);
<a name="l157"></a>}
<a name="l158"></a>
<a name="l159"></a>Track *TrackFind(Track *_tmpt, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> z)
<a name="l160"></a>{
<a name="l161"></a> Track *res = _tmpt, *tmpt;
<a name="l162"></a> </span><span class=cF9>I64</span><span class=cF0> dd, best = </span><span class=cF5>SqrI64</span><span class=cF0>(res-&gt;x - x) + </span><span class=cF5>SqrI64</span><span class=cF0>(res-&gt;z - z);
<a name="l163"></a>
<a name="l164"></a> tmpt = _tmpt;
<a name="l165"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l166"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l167"></a> tmpt = tmpt-&gt;next;
<a name="l168"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt == &amp;track_head)
<a name="l169"></a> tmpt = tmpt-&gt;next;
<a name="l170"></a> dd = </span><span class=cF5>SqrI64</span><span class=cF0>(tmpt-&gt;x - x) + </span><span class=cF5>SqrI64</span><span class=cF0>(tmpt-&gt;z - z);
<a name="l171"></a> </span><span class=cF1>if</span><span class=cF0> (dd &lt; best)
<a name="l172"></a> {
<a name="l173"></a> best = dd;
<a name="l174"></a> res = tmpt;
<a name="l175"></a> }
<a name="l176"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l177"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l179"></a> tmpt = _tmpt;
<a name="l180"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l181"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l182"></a> tmpt = tmpt-&gt;last;
<a name="l183"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt == &amp;track_head)
<a name="l184"></a> tmpt = tmpt-&gt;last;
<a name="l185"></a> dd = </span><span class=cF5>SqrI64</span><span class=cF0>(tmpt-&gt;x - x) + </span><span class=cF5>SqrI64</span><span class=cF0>(tmpt-&gt;z - z);
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (dd &lt; best)
<a name="l187"></a> {
<a name="l188"></a> best = dd;
<a name="l189"></a> res = tmpt;
<a name="l190"></a> }
<a name="l191"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l192"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l193"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l194"></a>
<a name="l195"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l196"></a>}
<a name="l197"></a>
<a name="l198"></a></span><span class=cF1>U0</span><span class=cF0> TrackSlice(</span><span class=cF1>F64</span><span class=cF0> *_x, </span><span class=cF1>F64</span><span class=cF0> *_z, </span><span class=cF1>F64</span><span class=cF0> theta, </span><span class=cF1>F64</span><span class=cF0> d)
<a name="l199"></a>{
<a name="l200"></a> </span><span class=cF1>F64</span><span class=cF0> x = *_x, z = *_z, c = </span><span class=cF5>Cos</span><span class=cF0>(theta), s = </span><span class=cF5>Sin</span><span class=cF0>(theta), dx = d * s, dz = -d * c;
<a name="l201"></a> Track *tmpt, *last = track_head.last;
<a name="l202"></a>
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (last == &amp;track_head)
<a name="l204"></a> last = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l205"></a>
<a name="l206"></a> tmpt =</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Track</span><span class=cF7>)</span><span class=cF0>);
<a name="l207"></a> </span><span class=cF1>if</span><span class=cF0> (last)
<a name="l208"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l209"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;center[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;center[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l210"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;center[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;center[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l211"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l212"></a> tmpt-&gt;center[</span><span class=cFE>2</span><span class=cF0>].x = x + (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * c + dx;
<a name="l213"></a> tmpt-&gt;center[</span><span class=cFE>2</span><span class=cF0>].z = z + (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * s + dz;
<a name="l214"></a> tmpt-&gt;center[</span><span class=cFE>2</span><span class=cF0>].y = DipY(tmpt-&gt;center[</span><span class=cFE>2</span><span class=cF0>].x, tmpt-&gt;center[</span><span class=cFE>2</span><span class=cF0>].z);
<a name="l215"></a> tmpt-&gt;center[</span><span class=cFE>3</span><span class=cF0>].x = x - (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * c + dx;
<a name="l216"></a> tmpt-&gt;center[</span><span class=cFE>3</span><span class=cF0>].z = z - (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * s + dz;
<a name="l217"></a> tmpt-&gt;center[</span><span class=cFE>3</span><span class=cF0>].y = DipY(tmpt-&gt;center[</span><span class=cFE>3</span><span class=cF0>].x, tmpt-&gt;center[</span><span class=cFE>3</span><span class=cF0>].z);
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (last)
<a name="l220"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l221"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;left[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;left[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l222"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;left[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;left[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l223"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l224"></a> tmpt-&gt;left[</span><span class=cFE>2</span><span class=cF0>].x = x - (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * c + dx;
<a name="l225"></a> tmpt-&gt;left[</span><span class=cFE>2</span><span class=cF0>].z = z - (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * s + dz;
<a name="l226"></a> tmpt-&gt;left[</span><span class=cFE>2</span><span class=cF0>].y = DipY(tmpt-&gt;left[</span><span class=cFE>2</span><span class=cF0>].x, tmpt-&gt;left[</span><span class=cFE>2</span><span class=cF0>].z);
<a name="l227"></a> tmpt-&gt;left[</span><span class=cFE>3</span><span class=cF0>].x = x - (WIDTH / </span><span class=cFE>2</span><span class=cF0> + SHOULDER) * c + dx;
<a name="l228"></a> tmpt-&gt;left[</span><span class=cFE>3</span><span class=cF0>].z = z - (WIDTH / </span><span class=cFE>2</span><span class=cF0> + SHOULDER) * s + dz;
<a name="l229"></a> tmpt-&gt;left[</span><span class=cFE>3</span><span class=cF0>].y = DipY(tmpt-&gt;left[</span><span class=cFE>3</span><span class=cF0>].x, tmpt-&gt;left[</span><span class=cFE>3</span><span class=cF0>].z);
<a name="l230"></a>
<a name="l231"></a> </span><span class=cF1>if</span><span class=cF0> (last)
<a name="l232"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l233"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;right[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;right[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l234"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpt-&gt;right[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;right[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l236"></a> tmpt-&gt;right[</span><span class=cFE>2</span><span class=cF0>].x = x + (WIDTH / </span><span class=cFE>2</span><span class=cF0> + SHOULDER) * c + dx;
<a name="l237"></a> tmpt-&gt;right[</span><span class=cFE>2</span><span class=cF0>].z = z + (WIDTH / </span><span class=cFE>2</span><span class=cF0> + SHOULDER) * s + dz;
<a name="l238"></a> tmpt-&gt;right[</span><span class=cFE>2</span><span class=cF0>].y = DipY(tmpt-&gt;right[</span><span class=cFE>2</span><span class=cF0>].x, tmpt-&gt;right[</span><span class=cFE>2</span><span class=cF0>].z);
<a name="l239"></a> tmpt-&gt;right[</span><span class=cFE>3</span><span class=cF0>].x = x + (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * c + dx;
<a name="l240"></a> tmpt-&gt;right[</span><span class=cFE>3</span><span class=cF0>].z = z + (WIDTH / </span><span class=cFE>2</span><span class=cF0>) * s + dz;
<a name="l241"></a> tmpt-&gt;right[</span><span class=cFE>3</span><span class=cF0>].y = DipY(tmpt-&gt;right[</span><span class=cFE>3</span><span class=cF0>].x, tmpt-&gt;right[</span><span class=cFE>3</span><span class=cF0>].z);
<a name="l242"></a>
<a name="l243"></a> tmpt-&gt;x = x;
<a name="l244"></a> tmpt-&gt;z = z;
<a name="l245"></a> tmpt-&gt;theta = theta;
<a name="l246"></a> tmpt-&gt;num = track_head.last-&gt;num + </span><span class=cFE>1</span><span class=cF0>;
<a name="l247"></a> tmpt-&gt;d = track_head.last-&gt;d + d;
<a name="l248"></a>
<a name="l249"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpt, track_head.last);
<a name="l250"></a>
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt-&gt;num &amp; </span><span class=cFE>1</span><span class=cF0>)
<a name="l252"></a> tmpt-&gt;c = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l253"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l254"></a> tmpt-&gt;c = </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l255"></a>
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; t_minx)
<a name="l257"></a> t_minx = x;
<a name="l258"></a>
<a name="l259"></a> </span><span class=cF1>if</span><span class=cF0> (x &gt; t_maxx)
<a name="l260"></a> t_maxx = x;
<a name="l261"></a>
<a name="l262"></a> </span><span class=cF1>if</span><span class=cF0> (z &lt; t_minz)
<a name="l263"></a> t_minz = z;
<a name="l264"></a>
<a name="l265"></a> </span><span class=cF1>if</span><span class=cF0> (z &gt; t_maxz)
<a name="l266"></a> t_maxz = z;
<a name="l267"></a>
<a name="l268"></a> x += dx;
<a name="l269"></a> *_x = x;
<a name="l270"></a> z += dz;
<a name="l271"></a> *_z = z;
<a name="l272"></a>
<a name="l273"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; t_minx)
<a name="l274"></a> t_minx = x;
<a name="l275"></a>
<a name="l276"></a> </span><span class=cF1>if</span><span class=cF0> (x &gt; t_maxx)
<a name="l277"></a> t_maxx = x;
<a name="l278"></a>
<a name="l279"></a> </span><span class=cF1>if</span><span class=cF0> (z &lt; t_minz)
<a name="l280"></a> t_minz = z;
<a name="l281"></a>
<a name="l282"></a> </span><span class=cF1>if</span><span class=cF0> (z &gt; t_maxz)
<a name="l283"></a> t_maxz = z;
<a name="l284"></a>}
<a name="l285"></a>
<a name="l286"></a></span><span class=cF1>U0</span><span class=cF0> CoupleEnds()
<a name="l287"></a>{
<a name="l288"></a> Track *first = track_head.next, *last = track_head.last;
<a name="l289"></a>
<a name="l290"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;center[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;center[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l291"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;center[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;center[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l292"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;left[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;left[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l293"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;left[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;left[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l294"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;right[</span><span class=cFE>0</span><span class=cF0>], &amp;last-&gt;right[</span><span class=cFE>3</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l295"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;first-&gt;right[</span><span class=cFE>1</span><span class=cF0>], &amp;last-&gt;right[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>);
<a name="l296"></a>}
<a name="l297"></a>
<a name="l298"></a></span><span class=cF1>U0</span><span class=cF0> InitTrack()
<a name="l299"></a>{
<a name="l300"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
<a name="l301"></a> Track *tmpt;
<a name="l302"></a> </span><span class=cF1>F64</span><span class=cF0> x, z, theta, d;
<a name="l303"></a>
<a name="l304"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;track_head, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Track</span><span class=cF7>)</span><span class=cF0>);
<a name="l305"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;track_head);
<a name="l306"></a>
<a name="l307"></a> t_minx = t_minz = </span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l308"></a> t_maxx = t_maxz = </span><span class=cF3>I64_MIN</span><span class=cF0>;
<a name="l309"></a>
<a name="l310"></a> x = </span><span class=cFE>0</span><span class=cF0>;
<a name="l311"></a> z = </span><span class=cFE>0</span><span class=cF0>;
<a name="l312"></a> theta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l313"></a> </span><span class=cF1>for</span><span class=cF0> (d = </span><span class=cFE>0</span><span class=cF0>; d &lt; </span><span class=cFE>6</span><span class=cF0> * RADIUS; d += D_S)
<a name="l314"></a> TrackSlice(&amp;x, &amp;z, theta, D_S);
<a name="l315"></a>
<a name="l316"></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>180</span><span class=cF0>; i++, theta += D_theta)
<a name="l317"></a> TrackSlice(&amp;x, &amp;z, theta, D_theta * RADIUS);
<a name="l318"></a>
<a name="l319"></a> </span><span class=cF1>for</span><span class=cF0> (d = </span><span class=cFE>0</span><span class=cF0>; d &lt; RADIUS; d += D_S)
<a name="l320"></a> TrackSlice(&amp;x, &amp;z, theta, D_S);
<a name="l321"></a>
<a name="l322"></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>90</span><span class=cF0>; i++, theta -= D_theta)
<a name="l323"></a> TrackSlice(&amp;x, &amp;z, theta, D_theta * RADIUS);
<a name="l324"></a>
<a name="l325"></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>180</span><span class=cF0>; i++, theta += D_theta)
<a name="l326"></a> TrackSlice(&amp;x, &amp;z, theta, D_theta * RADIUS);
<a name="l327"></a>
<a name="l328"></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>90</span><span class=cF0>; i++, theta -= D_theta)
<a name="l329"></a> TrackSlice(&amp;x, &amp;z, theta, D_theta * RADIUS);
<a name="l330"></a>
<a name="l331"></a> </span><span class=cF1>for</span><span class=cF0> (d = </span><span class=cFE>0</span><span class=cF0>; d &lt; RADIUS; d += D_S)
<a name="l332"></a> TrackSlice(&amp;x, &amp;z, theta, D_S);
<a name="l333"></a>
<a name="l334"></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>180</span><span class=cF0>; i++, theta += D_theta)
<a name="l335"></a> TrackSlice(&amp;x, &amp;z, theta, D_theta * RADIUS);
<a name="l336"></a>
<a name="l337"></a> CoupleEnds;
<a name="l338"></a>
<a name="l339"></a> tmpt = track_head.next;
<a name="l340"></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="l341"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l342"></a> j = (i + </span><span class=cFE>1</span><span class=cF0>) * track_head.last-&gt;num / </span><span class=cFB>mp_count</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>;
<a name="l343"></a> track_start[i] = tmpt;
<a name="l344"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != &amp;track_head &amp;&amp; tmpt-&gt;num != j)
<a name="l345"></a> tmpt = tmpt-&gt;next;
<a name="l346"></a> track_end[i] = tmpt;
<a name="l347"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l348"></a>
<a name="l349"></a> t_minx -= BORDER;
<a name="l350"></a> t_minz -= BORDER;
<a name="l351"></a> t_maxx += BORDER;
<a name="l352"></a> t_maxz += BORDER;
<a name="l353"></a> track_map = </span><span class=cF5>DCNew</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>t_maxx - t_minx + </span><span class=cFE>1</span><span class=cF0> &lt;&lt; MAP_BITS - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS, </span><span class=cF7>(</span><span class=cF0>t_maxz - t_minz + </span><span class=cFE>1</span><span class=cF0> &lt;&lt; MAP_BITS - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS);
<a name="l354"></a>
<a name="l355"></a> track_map-&gt;color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l356"></a> </span><span class=cF5>GrRect</span><span class=cF0>(track_map, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, track_map-&gt;width, track_map-&gt;height);
<a name="l357"></a> tmpt=track_head.next;
<a name="l358"></a> track_map-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l359"></a> track_map-&gt;thick = </span><span class=cFE>3</span><span class=cF0>;
<a name="l360"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != &amp;track_head)
<a name="l361"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l362"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(track_map, track_map-&gt;width - </span><span class=cF7>(</span><span class=cF0>tmpt-&gt;x - t_minx</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS, </span><span class=cF7>(</span><span class=cF0>tmpt-&gt;z - t_minz</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS, </span><span class=cFE>0</span><span class=cF0>);
<a name="l363"></a> tmpt = tmpt-&gt;next;
<a name="l364"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l365"></a>}
<a name="l366"></a>
<a name="l367"></a>#</span><span class=cF1>define</span><span class=cF0> HORIZON_DIP </span><span class=cFE>200</span><span class=cF0>
<a name="l368"></a>
<a name="l369"></a></span><span class=cF1>Bool</span><span class=cF0> PrepPoly(</span><span class=cF9>CD3I32</span><span class=cF0> *p, </span><span class=cF9>I64</span><span class=cF0> *r, </span><span class=cF9>I64</span><span class=cF0> cx, </span><span class=cF9>I64</span><span class=cF0> h, </span><span class=cF9>CD3I32</span><span class=cF0> *poly)
<a name="l370"></a>{
<a name="l371"></a> </span><span class=cF9>I64</span><span class=cF0> x, y, z, i;
<a name="l372"></a> </span><span class=cF1>F64</span><span class=cF0> s;
<a name="l373"></a>
<a name="l374"></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>4</span><span class=cF0>; i++)
<a name="l375"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l376"></a> x = p[i].x - c[</span><span class=cFE>0</span><span class=cF0>].p.x;
<a name="l377"></a> y = p[i].y - c[</span><span class=cFE>0</span><span class=cF0>].p.y;
<a name="l378"></a> z = p[i].z - c[</span><span class=cFE>0</span><span class=cF0>].p.z;
<a name="l379"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(r, &amp;x, &amp;y, &amp;z);
<a name="l380"></a> s = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>z</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>50</span><span class=cF0>);
<a name="l381"></a> poly[i].y = s * y + h;
<a name="l382"></a> </span><span class=cF1>if</span><span class=cF0> (z &lt; -</span><span class=cFE>200</span><span class=cF0> || !</span><span class=cF7>(</span><span class=cF0>-h &lt; poly[i].y &lt; </span><span class=cFE>2</span><span class=cF0> * h</span><span class=cF7>)</span><span class=cF0>)
<a name="l383"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l384"></a> poly[i].x = s * x + cx;
<a name="l385"></a> poly[i].z = z + </span><span class=cF3>GR_Z_ALL</span><span class=cF0>;
<a name="l386"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l387"></a>
<a name="l388"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l389"></a>}
<a name="l390"></a>
<a name="l391"></a></span><span class=cF9>I64</span><span class=cF0> mp_not_done_flags;
<a name="l392"></a>
<a name="l393"></a></span><span class=cF1>U0</span><span class=cF0> MPUpdateWin(</span><span class=cF9>CDC</span><span class=cF0> *dc2)
<a name="l394"></a>{
<a name="l395"></a> </span><span class=cF9>CTask</span><span class=cF0> *task = dc2-&gt;win_task;
<a name="l396"></a> </span><span class=cF9>I64</span><span class=cF0> i, x, y, z, w = task-&gt;pix_width, h = task-&gt;pix_height, r[</span><span class=cFE>16</span><span class=cF0>], cx = w &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l397"></a> </span><span class=cF1>F64</span><span class=cF0> s, dip_theta = Diptheta(c[</span><span class=cFE>0</span><span class=cF0>].p.x, c[</span><span class=cFE>0</span><span class=cF0>].p.z, c[</span><span class=cFE>0</span><span class=cF0>].theta);
<a name="l398"></a> Car *tmpc;
<a name="l399"></a> </span><span class=cF9>CD3I32</span><span class=cF0> poly[</span><span class=cFE>4</span><span class=cF0>];
<a name="l400"></a> Track *tmpt, *tmpt1;
<a name="l401"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc = </span><span class=cF5>DCAlias</span><span class=cF0>(</span><span class=cFB>gr</span><span class=cF0>.dc2, task);
<a name="l402"></a>
<a name="l403"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l404"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r, </span><span class=cF3>pi</span><span class=cF0> - c[</span><span class=cFE>0</span><span class=cF0>].theta);
<a name="l405"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r, </span><span class=cFE>75</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>180</span><span class=cF0> - dip_theta);
<a name="l406"></a>
<a name="l407"></a> dc-&gt;depth_buf = dc2-&gt;depth_buf;
<a name="l408"></a>
<a name="l409"></a> </span><span class=cF2>//Track</span><span class=cF0>
<a name="l410"></a> tmpt = track_start[</span><span class=cF5>Gs</span><span class=cF0>-&gt;num];
<a name="l411"></a> tmpt1 = track_end [</span><span class=cF5>Gs</span><span class=cF0>-&gt;num];
<a name="l412"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != tmpt1)
<a name="l413"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l414"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l415"></a> </span><span class=cF1>if</span><span class=cF0> (PrepPoly</span><span class=cF7>(</span><span class=cF0>&amp;tmpt-&gt;center, r, cx, h, poly</span><span class=cF7>)</span><span class=cF0>)
<a name="l416"></a> {
<a name="l417"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc, </span><span class=cFE>4</span><span class=cF0>, poly);
<a name="l418"></a> dc-&gt;color = tmpt-&gt;c;
<a name="l419"></a> </span><span class=cF1>if</span><span class=cF0> (PrepPoly</span><span class=cF7>(</span><span class=cF0>&amp;tmpt-&gt;left, r, cx, h, poly</span><span class=cF7>)</span><span class=cF0>)
<a name="l420"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc, </span><span class=cFE>4</span><span class=cF0>, poly);
<a name="l421"></a> </span><span class=cF1>if</span><span class=cF0> (PrepPoly</span><span class=cF7>(</span><span class=cF0>&amp;tmpt-&gt;right, r, cx, h, poly</span><span class=cF7>)</span><span class=cF0>)
<a name="l422"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc, </span><span class=cFE>4</span><span class=cF0>, poly);
<a name="l423"></a> }
<a name="l424"></a> tmpt = tmpt-&gt;next;
<a name="l425"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l426"></a>
<a name="l427"></a> dc-&gt;flags |= </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l428"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cF5>Gs</span><span class=cF0>-&gt;num; i &lt; BUSHES_NUM; i += </span><span class=cFB>mp_count</span><span class=cF0>)
<a name="l429"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l430"></a> x = b[i].p.x - c[</span><span class=cFE>0</span><span class=cF0>].p.x;
<a name="l431"></a> y = b[i].p.y - c[</span><span class=cFE>0</span><span class=cF0>].p.y;
<a name="l432"></a> z = b[i].p.z - c[</span><span class=cFE>0</span><span class=cF0>].p.z;
<a name="l433"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(r, &amp;x, &amp;y, &amp;z);
<a name="l434"></a> </span><span class=cF1>if</span><span class=cF0> (z &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l435"></a> {
<a name="l436"></a> s = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>z</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>50</span><span class=cF0>);
<a name="l437"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(dc-&gt;r);
<a name="l438"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(dc-&gt;r, s * </span><span class=cFE>2</span><span class=cF0>);
<a name="l439"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc, dc-&gt;r);
<a name="l440"></a> </span><span class=cF1>if</span><span class=cF0> (b[i].sym)
<a name="l441"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l442"></a> dc-&gt;flags |= </span><span class=cF3>DCF_SYMMETRY</span><span class=cF0> | </span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>;
<a name="l443"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc, s * x + cx, s * y + h, s * x + cx, s * y + h + </span><span class=cFE>10</span><span class=cF0>);
<a name="l444"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l445"></a> </span><span class=cF5>Sprite3B</span><span class=cF0>(dc, s * x + cx, s * y + h, z + </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, b[i].img);
<a name="l446"></a> dc-&gt;flags&amp;=~(</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0> | </span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>);
<a name="l447"></a> }
<a name="l448"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l449"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cF5>Gs</span><span class=cF0>-&gt;num + </span><span class=cFE>1</span><span class=cF0>; i &lt; CARS_NUM; i += </span><span class=cFB>mp_count</span><span class=cF0>)
<a name="l450"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l451"></a> tmpc = &amp;c[i];
<a name="l452"></a> x = tmpc-&gt;p.x - c[</span><span class=cFE>0</span><span class=cF0>].p.x;
<a name="l453"></a> y = tmpc-&gt;p.y - c[</span><span class=cFE>0</span><span class=cF0>].p.y;
<a name="l454"></a> z = tmpc-&gt;p.z - c[</span><span class=cFE>0</span><span class=cF0>].p.z;
<a name="l455"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(r, &amp;x, &amp;y, &amp;z);
<a name="l456"></a> </span><span class=cF1>if</span><span class=cF0> (z &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l457"></a> {
<a name="l458"></a> s = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>z</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>50</span><span class=cF0>);
<a name="l459"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(dc-&gt;r);
<a name="l460"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(dc-&gt;r, s * </span><span class=cFE>2</span><span class=cF0>);
<a name="l461"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(dc-&gt;r, Diptheta</span><span class=cF7>(</span><span class=cF0>tmpc-&gt;p.x, tmpc-&gt;p.z, -tmpc-&gt;theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l462"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(dc-&gt;r, tmpc-&gt;theta - c[</span><span class=cFE>0</span><span class=cF0>].theta);
<a name="l463"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc, dc-&gt;r);
<a name="l464"></a> </span><span class=cF5>Sprite3B</span><span class=cF0>(dc, s * x + cx, s * y + h, z + </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, tmpc-&gt;img);
<a name="l465"></a> }
<a name="l466"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l467"></a> dc-&gt;depth_buf = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l468"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l469"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;mp_not_done_flags, </span><span class=cF5>Gs</span><span class=cF0>-&gt;num);
<a name="l470"></a>}
<a name="l471"></a>
<a name="l472"></a></span><span class=cF1>U0</span><span class=cF0> VRTransform(</span><span class=cF9>CDC</span><span class=cF0> *dc, </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> *z)
<a name="l473"></a>{
<a name="l474"></a> </span><span class=cF9>I64</span><span class=cF0> zz;
<a name="l475"></a>
<a name="l476"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc-&gt;r, x, y, z);
<a name="l477"></a> zz = </span><span class=cFE>400</span><span class=cF0> + *z;
<a name="l478"></a> </span><span class=cF1>if</span><span class=cF0> (zz &lt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l479"></a> zz = </span><span class=cFE>1</span><span class=cF0>;
<a name="l480"></a> *x = </span><span class=cFE>400</span><span class=cF0> * *x / zz;
<a name="l481"></a> *y = </span><span class=cFE>400</span><span class=cF0> * *y / zz;
<a name="l482"></a> *x += dc-&gt;x;
<a name="l483"></a> *y += dc-&gt;y;
<a name="l484"></a> *z += dc-&gt;z;
<a name="l485"></a>}
<a name="l486"></a>
<a name="l487"></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> *task, </span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l488"></a>{
<a name="l489"></a> </span><span class=cF9>I64</span><span class=cF0> i, x, y, z,
<a name="l490"></a> w = task-&gt;pix_width,
<a name="l491"></a> h = task-&gt;pix_height, r[</span><span class=cFE>16</span><span class=cF0>],
<a name="l492"></a> cx = w &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l493"></a> </span><span class=cF1>F64</span><span class=cF0> s, dip_theta = Diptheta(c[</span><span class=cFE>0</span><span class=cF0>].p.x, c[</span><span class=cFE>0</span><span class=cF0>].p.z, c[</span><span class=cFE>0</span><span class=cF0>].theta);
<a name="l494"></a> Car *tmpc = &amp;c[</span><span class=cFE>0</span><span class=cF0>];
<a name="l495"></a>
<a name="l496"></a> dc-&gt;color = </span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l497"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, w, HORIZON_DIP * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>dip_theta</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>);
<a name="l498"></a>
<a name="l499"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l500"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r, </span><span class=cF3>pi</span><span class=cF0> - c[</span><span class=cFE>0</span><span class=cF0>].theta);
<a name="l501"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r, </span><span class=cFE>75</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>180</span><span class=cF0> - dip_theta);
<a name="l502"></a>
<a name="l503"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
<a name="l504"></a>
<a name="l505"></a> </span><span class=cF2>//Sun</span><span class=cF0>
<a name="l506"></a> x = c[</span><span class=cFE>0</span><span class=cF0>].p.x;
<a name="l507"></a> y = </span><span class=cFE>0</span><span class=cF0>;
<a name="l508"></a> z = </span><span class=cFE>1000000</span><span class=cF0> - c[</span><span class=cFE>0</span><span class=cF0>].p.z;
<a name="l509"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(r, &amp;x, &amp;y, &amp;z);
<a name="l510"></a> s = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>z</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>50</span><span class=cF0>);
<a name="l511"></a> </span><span class=cF1>if</span><span class=cF0> (y &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l512"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l513"></a> dc-&gt;color = </span><span class=cF3>BROWN</span><span class=cF0>;
<a name="l514"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc, s * x + cx, </span><span class=cFE>15</span><span class=cF0> + HORIZON_DIP * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>dip_theta</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>15</span><span class=cF0>);
<a name="l515"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l516"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc, s * x + cx, </span><span class=cFE>15</span><span class=cF0> + HORIZON_DIP * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>dip_theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l517"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l518"></a>
<a name="l519"></a> mp_not_done_flags = </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cFB>mp_count</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l520"></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="l521"></a> </span><span class=cF5>JobQueue</span><span class=cF0>(&amp;MPUpdateWin, dc, i);
<a name="l522"></a> </span><span class=cF1>while</span><span class=cF0> (mp_not_done_flags)
<a name="l523"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l524"></a>
<a name="l525"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l526"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r, tmpc-&gt;dtheta);
<a name="l527"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>4</span><span class=cF0> - </span><span class=cFE>8</span><span class=cF0> * dip_theta); </span><span class=cF2>//Made this up</span><span class=cF0>
<a name="l528"></a> dc-&gt;transform = &amp;VRTransform;
<a name="l529"></a> dc-&gt;x = task-&gt;pix_width &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l530"></a> dc-&gt;y = task-&gt;pix_height - </span><span class=cFE>150</span><span class=cF0>;
<a name="l531"></a> dc-&gt;z = </span><span class=cF3>GR_Z_ALL</span><span class=cF0>;
<a name="l532"></a> </span><span class=cF5>Sprite3Mat4x4B</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=cFE>100</span><span class=cF0>, c[</span><span class=cFE>0</span><span class=cF0>].img, r);
<a name="l533"></a>
<a name="l534"></a> </span><span class=cF2>//Map</span><span class=cF0>
<a name="l535"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc, w - track_map-&gt;width, h - track_map-&gt;height, track_map);
<a name="l536"></a>
<a name="l537"></a> dc-&gt;thick = </span><span class=cFE>2</span><span class=cF0>;
<a name="l538"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; CARS_NUM; i++)
<a name="l539"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l540"></a> </span><span class=cF1>if</span><span class=cF0> (i)
<a name="l541"></a> dc-&gt;color = </span><span class=cF3>LTPURPLE</span><span class=cF0>;
<a name="l542"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l543"></a> dc-&gt;color = </span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l544"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, w - </span><span class=cF7>(</span><span class=cF0>c[i].p.x - t_minx</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS, h - track_map-&gt;height + </span><span class=cF7>(</span><span class=cF0>c[i].p.z - t_minz</span><span class=cF7>)</span><span class=cF0> &gt;&gt; MAP_BITS, </span><span class=cFE>0</span><span class=cF0>);
<a name="l545"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l546"></a>
<a name="l547"></a> </span><span class=cF1>if</span><span class=cF0> (game_over)
<a name="l548"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l549"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l550"></a> </span><span class=cF1>if</span><span class=cF0> (tf)
<a name="l551"></a> {
<a name="l552"></a> s = tf - t0;
<a name="l553"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l554"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>w - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>14</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>h - </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF6>&quot;Game Completed&quot;</span><span class=cF0>);
<a name="l555"></a> }
<a name="l556"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l557"></a> {
<a name="l558"></a> s = </span><span class=cFE>99</span><span class=cF0>.</span><span class=cFE>9</span><span class=cF0>;
<a name="l559"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l560"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>w - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>9</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>h - </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l561"></a> }
<a name="l562"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l563"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l564"></a> s = </span><span class=cF5>tS</span><span class=cF0>-t0;
<a name="l565"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l566"></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;%0.1f%% Time:%0.2f Best:%0.2f&quot;</span><span class=cF0>, </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * distance / track_head.last-&gt;d, s, best_score);
<a name="l567"></a>}
<a name="l568"></a>
<a name="l569"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l570"></a>{
<a name="l571"></a> Car *tmpc;
<a name="l572"></a> </span><span class=cF9>I64</span><span class=cF0> i, x, z;
<a name="l573"></a> </span><span class=cF1>Bool</span><span class=cF0> on_track;
<a name="l574"></a> Track *tmpt, *tmpt2;
<a name="l575"></a>
<a name="l576"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l577"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l578"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l579"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>12</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Log2</span><span class=cF7>(</span><span class=cF0>c[</span><span class=cFE>0</span><span class=cF0>].speed / </span><span class=cFE>500</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>7</span><span class=cF7>)</span><span class=cF0>);
<a name="l580"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l581"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l582"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; CARS_NUM; i++)
<a name="l583"></a> {
<a name="l584"></a> tmpc = &amp;c[i];
<a name="l585"></a> tmpc-&gt;p.x -= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0> * tmpc-&gt;speed * </span><span class=cF5>Cos</span><span class=cF0>(tmpc-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l586"></a> tmpc-&gt;p.z += </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0> * tmpc-&gt;speed * </span><span class=cF5>Sin</span><span class=cF0>(tmpc-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l587"></a> tmpt = TrackFind(tmpc-&gt;t, tmpc-&gt;p.x, tmpc-&gt;p.z);
<a name="l588"></a> </span><span class=cF1>if</span><span class=cF0> (i)
<a name="l589"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l590"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt != tmpc-&gt;t)
<a name="l591"></a> {
<a name="l592"></a> tmpt2 = tmpt-&gt;next;
<a name="l593"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt2 == &amp;track_head)
<a name="l594"></a> tmpt2 = tmpt2-&gt;next;
<a name="l595"></a> tmpc-&gt;theta = </span><span class=cF5>Arg</span><span class=cF0>(-tmpt2-&gt;z + tmpc-&gt;p.z, -tmpt2-&gt;x + tmpc-&gt;p.x);
<a name="l596"></a> }
<a name="l597"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l598"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l599"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l600"></a> tmpc-&gt;theta += </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0> * tmpc-&gt;dtheta;
<a name="l601"></a> x =track_map-&gt;width - (tmpc-&gt;p.x - t_minx) &gt;&gt; MAP_BITS;
<a name="l602"></a> z = (tmpc-&gt;p.z - t_minz) &gt;&gt; MAP_BITS;
<a name="l603"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>track_map, x, z</span><span class=cF7>)</span><span class=cF0> != </span><span class=cF3>YELLOW</span><span class=cF0>)
<a name="l604"></a> {
<a name="l605"></a> on_track = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l606"></a> tmpc-&gt;speed -= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0> * tmpc-&gt;speed;
<a name="l607"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc-&gt;speed &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l608"></a> tmpc-&gt;speed = </span><span class=cFE>0</span><span class=cF0>;
<a name="l609"></a> }
<a name="l610"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l611"></a> on_track = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l612"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l613"></a> tmpc-&gt;t = tmpt;
<a name="l614"></a> tmpc-&gt;p.y = DipY(tmpc-&gt;p.x, tmpc-&gt;p.z);
<a name="l615"></a> }
<a name="l616"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over &amp;&amp; on_track)
<a name="l617"></a> {
<a name="l618"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt; CARS_NUM; i++)
<a name="l619"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3I32DistSqr</span><span class=cF7>(</span><span class=cF0>&amp;c[i].p, &amp;c[</span><span class=cFE>0</span><span class=cF0>].p</span><span class=cF7>)</span><span class=cF0> &lt; CAR_LENGTH &gt;&gt; </span><span class=cFE>1</span><span class=cF0> * CAR_LENGTH &gt;&gt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l620"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l621"></a> game_over = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l622"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>500</span><span class=cF0>, </span><span class=cFE>22</span><span class=cF0>, </span><span class=cFE>34</span><span class=cF0>);
<a name="l623"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>500</span><span class=cF0>);
<a name="l624"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l625"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l626"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l627"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l628"></a> distance += </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>01</span><span class=cF0> * c[</span><span class=cFE>0</span><span class=cF0>].speed;
<a name="l629"></a> </span><span class=cF1>if</span><span class=cF0> (distance &gt; track_head.last-&gt;d &amp;&amp; c[</span><span class=cFE>0</span><span class=cF0>].t-&gt;num &lt; track_head.last-&gt;num &gt;&gt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l630"></a> {
<a name="l631"></a> tf = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l632"></a> game_over = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l633"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l634"></a> </span><span class=cF1>if</span><span class=cF0> (tf - t0 &lt; best_score)
<a name="l635"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l636"></a> best_score = tf - t0;
<a name="l637"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l638"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l639"></a> }
<a name="l640"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l641"></a> }
<a name="l642"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>);
<a name="l643"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l644"></a>}
<a name="l645"></a>
<a name="l646"></a></span><span class=cF1>U8</span><span class=cF0> *imgs[</span><span class=cFE>8</span><span class=cF0>]={</span><span class=cFA>&lt;1&gt;</span><span class=cF0>, </span><span class=cFA>&lt;1&gt;</span><span class=cF0>, </span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;3&gt;</span><span class=cF0>, </span><span class=cFA>&lt;4&gt;</span><span class=cF0>, </span><span class=cFA>&lt;4&gt;</span><span class=cF0>, </span><span class=cFA>&lt;4&gt;</span><span class=cF0>};
<a name="l647"></a>
<a name="l648"></a>
<a name="l649"></a></span><span class=cF1>U0</span><span class=cF0> InitBushes()
<a name="l650"></a>{
<a name="l651"></a> Bush *tmpb;
<a name="l652"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, x, z;
<a name="l653"></a>
<a name="l654"></a> track_map-&gt;color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l655"></a> track_map-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l656"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; BUSHES_NUM; i++)
<a name="l657"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l658"></a> tmpb = &amp;b[i];
<a name="l659"></a>
<a name="l660"></a>ib_restart:
<a name="l661"></a> tmpb-&gt;p.x = </span><span class=cF5>Rand</span><span class=cF0> * (t_maxx - t_minx) + t_minx;
<a name="l662"></a> tmpb-&gt;p.z = </span><span class=cF5>Rand</span><span class=cF0> * (t_maxz - t_minz) + t_minz;
<a name="l663"></a> x = track_map-&gt;width - (tmpb-&gt;p.x - t_minx) &gt;&gt; MAP_BITS;
<a name="l664"></a> z = (tmpb-&gt;p.z - t_minz) &gt;&gt; MAP_BITS;
<a name="l665"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cFE>8</span><span class=cF0>; j++)
<a name="l666"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>track_map, x + </span><span class=cFB>gr_x_offsets</span><span class=cF0>[j], z + </span><span class=cFB>gr_y_offsets</span><span class=cF0>[j]</span><span class=cF7>)</span><span class=cF0> != </span><span class=cF3>LTGRAY</span><span class=cF0>)
<a name="l667"></a> </span><span class=cF1>goto</span><span class=cF0> ib_restart;
<a name="l668"></a>
<a name="l669"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(track_map, x, z);
<a name="l670"></a> tmpb-&gt;p.y = DipY(tmpb-&gt;p.x, tmpb-&gt;p.z);
<a name="l671"></a> tmpb-&gt;sym = </span><span class=cF5>RandU16</span><span class=cF0> &amp; </span><span class=cFE>1</span><span class=cF0>;
<a name="l672"></a> tmpb-&gt;img = imgs[i &amp; </span><span class=cFE>7</span><span class=cF0>];
<a name="l673"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l674"></a>}
<a name="l675"></a>
<a name="l676"></a>
<a name="l677"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l678"></a>{
<a name="l679"></a> Car *tmpc;
<a name="l680"></a> Track *tmpt;
<a name="l681"></a> </span><span class=cF1>F64</span><span class=cF0> d;
<a name="l682"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l683"></a>
<a name="l684"></a> InitTrack;
<a name="l685"></a> InitBushes;
<a name="l686"></a> tmpt = track_head.next;
<a name="l687"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; CARS_NUM; i++)
<a name="l688"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l689"></a> tmpc = &amp;c[i];
<a name="l690"></a> tmpc-&gt;t = tmpt;
<a name="l691"></a> tmpc-&gt;p.x = tmpt-&gt;x;
<a name="l692"></a> tmpc-&gt;p.z = tmpt-&gt;z;
<a name="l693"></a> tmpc-&gt;p.y = DipY(tmpc-&gt;p.x, tmpc-&gt;p.z);
<a name="l694"></a> tmpc-&gt;theta = -tmpt-&gt;theta;
<a name="l695"></a> tmpc-&gt;dtheta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l696"></a> </span><span class=cF1>if</span><span class=cF0> (!i)
<a name="l697"></a> {
<a name="l698"></a> tmpc-&gt;img = </span><span class=cFA>&lt;5&gt;</span><span class=cF0>;
<a name="l699"></a> tmpc-&gt;speed = </span><span class=cFE>0</span><span class=cF0>;
<a name="l700"></a> }
<a name="l701"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l702"></a> {
<a name="l703"></a> tmpc-&gt;img = </span><span class=cFA>&lt;6&gt;</span><span class=cF0>;
<a name="l704"></a> tmpc-&gt;speed = </span><span class=cFE>2500</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l705"></a> }
<a name="l706"></a> d = (i + </span><span class=cFE>1</span><span class=cF0>) * track_head.last-&gt;d / CARS_NUM;
<a name="l707"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt-&gt;next != &amp;track_head &amp;&amp; tmpt-&gt;d &lt; d)
<a name="l708"></a> tmpt = tmpt-&gt;next;
<a name="l709"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l710"></a> distance = </span><span class=cFE>0</span><span class=cF0>;
<a name="l711"></a> tf = </span><span class=cFE>0</span><span class=cF0>;
<a name="l712"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l713"></a> game_over = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l714"></a>}
<a name="l715"></a>
<a name="l716"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l717"></a>{
<a name="l718"></a> </span><span class=cF1>while</span><span class=cF0> (mp_not_done_flags)
<a name="l719"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l720"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;track_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l721"></a> </span><span class=cF5>DCDel</span><span class=cF0>(track_map);
<a name="l722"></a>}
<a name="l723"></a>
<a name="l724"></a></span><span class=cF1>U0</span><span class=cF0> Varoom()
<a name="l725"></a>{
<a name="l726"></a> </span><span class=cF9>I64</span><span class=cF0> sc, last = </span><span class=cFB>counts</span><span class=cF0>.timer;
<a name="l727"></a>
<a name="l728"></a> </span><span class=cF1>Bool</span><span class=cF0> is_up_pressed;
<a name="l729"></a> </span><span class=cF1>Bool</span><span class=cF0> is_down_pressed;
<a name="l730"></a> </span><span class=cF1>Bool</span><span class=cF0> is_left_pressed;
<a name="l731"></a> </span><span class=cF1>Bool</span><span class=cF0> is_right_pressed;
<a name="l732"></a> </span><span class=cF1>Bool</span><span class=cF0> is_nl_pressed;
<a name="l733"></a> </span><span class=cF1>Bool</span><span class=cF0> is_esc_pressed;
<a name="l734"></a>
<a name="l735"></a> </span><span class=cF1>Bool</span><span class=cF0> is_key_pressed;
<a name="l736"></a>
<a name="l737"></a> </span><span class=cF9>I64</span><span class=cF0> sc_nl = </span><span class=cF5>Char2ScanCode</span><span class=cF0>(</span><span class=cF6>'\n'</span><span class=cF0>); </span><span class=cF2>// scancode for typing newline</span><span class=cF0>
<a name="l738"></a>
<a name="l739"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l740"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l741"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l742"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l743"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l744"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l745"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l746"></a> </span><span class=cF6>&quot; Accelerator(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l747"></a> </span><span class=cF6>&quot; Brake(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l748"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l749"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l750"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l751"></a> );
<a name="l752"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l753"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l754"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l755"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr = </span><span class=cF3>YELLOW</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l756"></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_GRAB_SCROLL</span><span class=cF0> - </span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0>;
<a name="l757"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l758"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l759"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l760"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l761"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l762"></a> Init;
<a name="l763"></a> </span><span class=cF5>PaletteSetLight</span><span class=cF0>(</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l764"></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="l765"></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="l766"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l767"></a> {
<a name="l768"></a> is_up_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>);
<a name="l769"></a> is_down_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>);
<a name="l770"></a> is_left_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>);
<a name="l771"></a> is_right_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>);
<a name="l772"></a> is_nl_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, sc_nl);
<a name="l773"></a> is_esc_pressed = </span><span class=cF5>Bt</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap, </span><span class=cF3>SC_ESC</span><span class=cF0>);
<a name="l774"></a>
<a name="l775"></a> </span><span class=cF1>if</span><span class=cF0> (is_left_pressed) c[</span><span class=cFE>0</span><span class=cF0>].dtheta -= .</span><span class=cFE>000003</span><span class=cF0> * (</span><span class=cFB>counts</span><span class=cF0>.timer - last);
<a name="l776"></a> </span><span class=cF1>if</span><span class=cF0> (is_right_pressed) c[</span><span class=cFE>0</span><span class=cF0>].dtheta += .</span><span class=cFE>000003</span><span class=cF0> * (</span><span class=cFB>counts</span><span class=cF0>.timer - last);
<a name="l777"></a> </span><span class=cF1>if</span><span class=cF0> (is_up_pressed) c[</span><span class=cFE>0</span><span class=cF0>].speed += .</span><span class=cFE>01</span><span class=cF0> * (</span><span class=cFB>counts</span><span class=cF0>.timer - last);
<a name="l778"></a> </span><span class=cF1>if</span><span class=cF0> (is_down_pressed)
<a name="l779"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l780"></a> c[</span><span class=cFE>0</span><span class=cF0>].speed -= .</span><span class=cFE>03</span><span class=cF0> * (</span><span class=cFB>counts</span><span class=cF0>.timer - last);
<a name="l781"></a> </span><span class=cF1>if</span><span class=cF0> (c[</span><span class=cFE>0</span><span class=cF0>].speed &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l782"></a> c[</span><span class=cFE>0</span><span class=cF0>].speed = </span><span class=cFE>0</span><span class=cF0>;
<a name="l783"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l784"></a> </span><span class=cF1>if</span><span class=cF0> (is_nl_pressed)
<a name="l785"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l786"></a> CleanUp;
<a name="l787"></a> Init;
<a name="l788"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l789"></a> </span><span class=cF1>if</span><span class=cF0> (is_esc_pressed)
<a name="l790"></a> </span><span class=cF1>goto</span><span class=cF0> vr_done;
<a name="l791"></a>
<a name="l792"></a> last = </span><span class=cFB>counts</span><span class=cF0>.timer;
<a name="l793"></a>
<a name="l794"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l795"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l796"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l797"></a>
<a name="l798"></a>
<a name="l799"></a></span><span class=cF2>/*</span><span class=cF0> </span><span class=cF2>switch (KeyGet(&amp;sc))</span><span class=cF0>
<a name="l800"></a> </span><span class=cF2>{</span><span class=cF0>
<a name="l801"></a> </span><span class=cF2>case 0:</span><span class=cF0>
<a name="l802"></a> </span><span class=cF2>switch (sc.u8[0])</span><span class=cF0>
<a name="l803"></a> </span><span class=cF2>{</span><span class=cF0>
<a name="l804"></a>
<a name="l805"></a> </span><span class=cF2>case SC_CURSOR_LEFT:</span><span class=cF0>
<a name="l806"></a> </span><span class=cF2>c[0].dtheta -= pi / 60;</span><span class=cF0>
<a name="l807"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l808"></a>
<a name="l809"></a> </span><span class=cF2>case SC_CURSOR_RIGHT:</span><span class=cF0>
<a name="l810"></a> </span><span class=cF2>c[0].dtheta += pi / 60;</span><span class=cF0>
<a name="l811"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l812"></a>
<a name="l813"></a> </span><span class=cF2>case SC_CURSOR_UP:</span><span class=cF0>
<a name="l814"></a> </span><span class=cF2>c[0].speed += 300;</span><span class=cF0>
<a name="l815"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l816"></a>
<a name="l817"></a> </span><span class=cF2>case SC_CURSOR_DOWN:</span><span class=cF0>
<a name="l818"></a> </span><span class=cF2>c[0].speed -= 900;</span><span class=cF0>
<a name="l819"></a> </span><span class=cF2>if (c[0].speed &lt; 0)</span><span class=cF0>
<a name="l820"></a> </span><span class=cF2>c[0].speed = 0;</span><span class=cF0>
<a name="l821"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l822"></a> </span><span class=cF2>}</span><span class=cF0>
<a name="l823"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l824"></a> </span><span class=cF2>case '\n':</span><span class=cF0>
<a name="l825"></a> </span><span class=cF2>CleanUp;</span><span class=cF0>
<a name="l826"></a> </span><span class=cF2>Init;</span><span class=cF0>
<a name="l827"></a> </span><span class=cF2>break;</span><span class=cF0>
<a name="l828"></a> </span><span class=cF2>case CH_SHIFT_ESC:</span><span class=cF0>
<a name="l829"></a> </span><span class=cF2>case CH_ESC:</span><span class=cF0>
<a name="l830"></a> </span><span class=cF2>goto vr_done;</span><span class=cF0>
<a name="l831"></a> </span><span class=cF2>}</span><span class=cF0>
<a name="l832"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l833"></a> }
<a name="l834"></a>vr_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
<a name="l835"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l836"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l837"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l838"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l839"></a> </span><span class=cF5>FlushMessages</span><span class=cF0>; </span><span class=cF2>// if Varoom included in Cmd line, fixes SHIFT_ESC quitting current cmd line.</span><span class=cF0>
<a name="l840"></a> mp_not_done_flags = </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>// fix for CleanUp hanging on a Yield while loop ...</span><span class=cF0>
<a name="l841"></a> CleanUp;
<a name="l842"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l843"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Varoom&quot;</span><span class=cF0>, </span><span class=cF6>&quot;F64 best_score=%5.4f;\n&quot;</span><span class=cF0>, best_score);
<a name="l844"></a>}
<a name="l845"></a>
<a name="l846"></a>Varoom;
</span></pre></body>
</html>