templeos-info/public/Wb/Demo/Games/Talons.HC.HTML

1265 lines
99 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF2>//Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF5>RegDft</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/Talons&quot;</span><span class=cF0>,</span><span class=cF6>&quot;F64 best_score=9999;\n&quot;</span><span class=cF0>);
<a name="l4"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/Talons&quot;</span><span class=cF0>);
<a name="l5"></a>
<a name="l6"></a></span><span class=cF2>//Keep these power of two so shift is used instead of multiply</span><span class=cF0>
<a name="l7"></a></span><span class=cF2>//to index arrays.</span><span class=cF0>
<a name="l8"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_WIDTH 1024
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_HEIGHT 1024
<a name="l10"></a>
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_SCALE 150
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> DISPLAY_SCALE 100
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> CTRLS_SCALE 0.05
<a name="l14"></a>
<a name="l15"></a></span><span class=cF2>//I think I did these so the heads-up showed intelligable numbers.</span><span class=cF0>
<a name="l16"></a></span><span class=cF2>//Scaling is a mess.</span><span class=cF0>
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> COORDINATE_SCALE 256
<a name="l18"></a>#</span><span class=cF1>define</span><span class=cF0> COORDINATE_BITS 8
<a name="l19"></a>
<a name="l20"></a>#</span><span class=cF1>define</span><span class=cF0> WATER_ELEVATION 15
<a name="l21"></a>#</span><span class=cF1>define</span><span class=cF0> BIRD_ELEVATION 10
<a name="l22"></a>#</span><span class=cF1>define</span><span class=cF0> ROCK_ELEVATION 45
<a name="l23"></a>#</span><span class=cF1>define</span><span class=cF0> SNOW_ELEVATION 55
<a name="l24"></a>
<a name="l25"></a></span><span class=cF2>//Too big makes off-scrn draws take place.</span><span class=cF0>
<a name="l26"></a>#</span><span class=cF1>define</span><span class=cF0> PANEL_SIZE_MAX 16
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a> </span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<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>
<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>
<a name="l50"></a>
<a name="l51"></a>
<a name="l52"></a> </span><span class=cFA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<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>
<a name="l78"></a> </span><span class=cFA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<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>
<a name="l91"></a>
<a name="l92"></a>
<a name="l93"></a>
<a name="l94"></a>
<a name="l95"></a>
<a name="l96"></a>
<a name="l97"></a>
<a name="l98"></a>
<a name="l99"></a>
<a name="l100"></a> </span><span class=cFA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l101"></a>
<a name="l102"></a>
<a name="l103"></a>
<a name="l104"></a>
<a name="l105"></a>
<a name="l106"></a>
<a name="l107"></a>
<a name="l108"></a>
<a name="l109"></a>
<a name="l110"></a>
<a name="l111"></a>
<a name="l112"></a>
<a name="l113"></a>
<a name="l114"></a>
<a name="l115"></a>
<a name="l116"></a> </span><span class=cFA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l117"></a>
<a name="l118"></a>
<a name="l119"></a>
<a name="l120"></a>
<a name="l121"></a>
<a name="l122"></a>
<a name="l123"></a>
<a name="l124"></a>
<a name="l125"></a>
<a name="l126"></a>
<a name="l127"></a>
<a name="l128"></a>
<a name="l129"></a>
<a name="l130"></a>
<a name="l131"></a>
<a name="l132"></a> </span><span class=cFA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l133"></a>
<a name="l134"></a>
<a name="l135"></a>
<a name="l136"></a>
<a name="l137"></a>
<a name="l138"></a>
<a name="l139"></a>
<a name="l140"></a>
<a name="l141"></a>#</span><span class=cF1>define</span><span class=cF0> LS_TYPES 3
<a name="l142"></a></span><span class=cF1>U8</span><span class=cF0> *landscape_small_imgs[LS_TYPES]={</span><span class=cFA>&lt;4&gt;</span><span class=cF0>,</span><span class=cFA>&lt;5&gt;</span><span class=cF0>,</span><span class=cFA>&lt;6&gt;</span><span class=cF0>},
<a name="l143"></a> *landscape_large_imgs[LS_TYPES];
<a name="l144"></a>
<a name="l145"></a>#</span><span class=cF1>define</span><span class=cF0> B_NUM 256
<a name="l146"></a></span><span class=cF1>class</span><span class=cF0> Bird
<a name="l147"></a>{
<a name="l148"></a> Bird *next,*last;
<a name="l149"></a> </span><span class=cF9>CD3I64</span><span class=cF0> p;
<a name="l150"></a> </span><span class=cF1>F64</span><span class=cF0> theta;
<a name="l151"></a>} b_head[</span><span class=cFB>mp_cnt</span><span class=cF0>];
<a name="l152"></a>
<a name="l153"></a></span><span class=cF1>class</span><span class=cF0> Obj
<a name="l154"></a>{
<a name="l155"></a> Obj *next,*last;
<a name="l156"></a> </span><span class=cF9>CD3I64</span><span class=cF0> p;
<a name="l157"></a> </span><span class=cF1>U8</span><span class=cF0> *img;
<a name="l158"></a> </span><span class=cF1>Bool</span><span class=cF0> fish;
<a name="l159"></a>};
<a name="l160"></a>
<a name="l161"></a></span><span class=cF1>class</span><span class=cF0> Panel
<a name="l162"></a>{</span><span class=cF2>//Polygon or Obj</span><span class=cF0>
<a name="l163"></a> Panel *next;
<a name="l164"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *pts;
<a name="l165"></a> </span><span class=cF9>I64</span><span class=cF0> cnt;
<a name="l166"></a> </span><span class=cF9>U16</span><span class=cF0> update,num_sides;
<a name="l167"></a> </span><span class=cF9>CColorROPU32</span><span class=cF0> color;
<a name="l168"></a> Obj *next_obj,*last_obj;
<a name="l169"></a>} *panel_head,*panels[MAP_HEIGHT][MAP_WIDTH];
<a name="l170"></a>
<a name="l171"></a></span><span class=cF9>I64</span><span class=cF0> critical_section_flag;
<a name="l172"></a></span><span class=cF9>I16</span><span class=cF0> elevations[MAP_HEIGHT][MAP_WIDTH];
<a name="l173"></a></span><span class=cF9>CD3</span><span class=cF0> normals[MAP_HEIGHT][MAP_WIDTH];
<a name="l174"></a>
<a name="l175"></a></span><span class=cF1>class</span><span class=cF0> MPCtrl {
<a name="l176"></a> </span><span class=cF9>I64</span><span class=cF0> init_not_done_flags,update_not_done_flags,app_not_done_flags;
<a name="l177"></a> </span><span class=cF9>I64</span><span class=cF0> strip_width[</span><span class=cF3>MP_PROCESSORS_NUM</span><span class=cF0>];
<a name="l178"></a> </span><span class=cF1>Bool</span><span class=cF0> app_done;
<a name="l179"></a>} mp;
<a name="l180"></a>
<a name="l181"></a></span><span class=cF1>F64</span><span class=cF0> game_t0,game_tf,pitch,roll,heading,phi,speed;
<a name="l182"></a></span><span class=cF1>Bool</span><span class=cF0> invert_pitch,rolled_over;
<a name="l183"></a></span><span class=cF9>I64</span><span class=cF0> strip_height,x,y,z,fish_left;
<a name="l184"></a></span><span class=cF9>CD3</span><span class=cF0> v;
<a name="l185"></a>
<a name="l186"></a></span><span class=cF1>U0</span><span class=cF0> WrapAngles()
<a name="l187"></a>{
<a name="l188"></a> </span><span class=cF9>I64</span><span class=cF0> r[4][4],x,y,z;
<a name="l189"></a>
<a name="l190"></a> phi=</span><span class=cF5>Wrap</span><span class=cF0>(phi);
<a name="l191"></a> pitch=</span><span class=cF5>Wrap</span><span class=cF0>(-phi-</span><span class=cF3>pi</span><span class=cF0>/2);
<a name="l192"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Abs</span><span class=cF7>(</span><span class=cF0>pitch</span><span class=cF7>)</span><span class=cF0>&gt;</span><span class=cF3>pi</span><span class=cF0>/2) </span><span class=cF7>{</span><span class=cF0>
<a name="l193"></a> invert_pitch=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l194"></a> pitch=</span><span class=cF5>Wrap</span><span class=cF0>(</span><span class=cF3>pi</span><span class=cF0>-pitch);
<a name="l195"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l196"></a> invert_pitch=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l197"></a> roll=</span><span class=cF5>Wrap</span><span class=cF0>(roll);
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (invert_pitch ^^ -</span><span class=cF3>pi</span><span class=cF0>/2&lt;=roll&lt;</span><span class=cF3>pi</span><span class=cF0>/2)
<a name="l199"></a> rolled_over=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l200"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l201"></a> rolled_over=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l202"></a> heading=</span><span class=cF5>Wrap</span><span class=cF0>(heading,0);
<a name="l203"></a>
<a name="l204"></a> </span><span class=cF2>//World to scrn coordinates</span><span class=cF0>
<a name="l205"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l206"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r,heading);
<a name="l207"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r,phi);
<a name="l208"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r,roll);
<a name="l209"></a>
<a name="l210"></a> </span><span class=cF2>//We use velocity vector for dog-fighting.</span><span class=cF0>
<a name="l211"></a> x=0x100000000*speed; y=0; z=0;
<a name="l212"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(r,&amp;x,&amp;y,&amp;z);
<a name="l213"></a> v.x=x/</span><span class=cF5>ToF64</span><span class=cF0>(0x100000000); v.y=y/</span><span class=cF5>ToF64</span><span class=cF0>(0x100000000); v.z=z/</span><span class=cF5>ToF64</span><span class=cF0>(0x100000000);
<a name="l214"></a>}
<a name="l215"></a>
<a name="l216"></a></span><span class=cF1>U0</span><span class=cF0> EDTransform(</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="l217"></a>{
<a name="l218"></a> </span><span class=cF9>I64</span><span class=cF0> zz;
<a name="l219"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc-&gt;r,x,y,z);
<a name="l220"></a> *z=zz=-*z;
<a name="l221"></a> </span><span class=cF1>if</span><span class=cF0> (zz&gt;0) </span><span class=cF7>{</span><span class=cF0>
<a name="l222"></a> *x = dc-&gt;x + *x * DISPLAY_SCALE/zz; </span><span class=cF2>//Foreshortening</span><span class=cF0>
<a name="l223"></a> *y = dc-&gt;y - *y * DISPLAY_SCALE/zz;
<a name="l224"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l225"></a> *x = dc-&gt;x + *x;
<a name="l226"></a> *y = dc-&gt;y - *y;
<a name="l227"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l228"></a>}
<a name="l229"></a>
<a name="l230"></a></span><span class=cF1>U0</span><span class=cF0> CalcNormals()
<a name="l231"></a>{</span><span class=cF2>/*Find the normal vect with a curl.</span><span class=cF0>
<a name="l232"></a>
<a name="l233"></a></span><span class=cF2>i,j and k are the axis unit vectors,</span><span class=cF0>
<a name="l234"></a></span><span class=cF2>not to be confused with my local index variables.</span><span class=cF0>
<a name="l235"></a>
<a name="l236"></a></span><span class=cF2>i j k</span><span class=cF0>
<a name="l237"></a></span><span class=cF2>0 1 dz2</span><span class=cF0>
<a name="l238"></a></span><span class=cF2>1 0 dz1</span><span class=cF0>
<a name="l239"></a>
<a name="l240"></a></span><span class=cF2>Normal: dz1*i + dz2*j - k</span><span class=cF0>
<a name="l241"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l242"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l243"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;MAP_HEIGHT-1;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l244"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;MAP_WIDTH-1;i++) {
<a name="l245"></a> normals[j][i].x=elevations[j][i+1]-elevations[j][i];
<a name="l246"></a> normals[j][i].y=elevations[j+1][i]-elevations[j][i];
<a name="l247"></a> normals[j][i].z=-1;
<a name="l248"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&amp;normals[j][i]);
<a name="l249"></a> }
<a name="l250"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;normals[j][i],0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3</span><span class=cF7>)</span><span class=cF0>);
<a name="l251"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l252"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;MAP_WIDTH-1;i++)
<a name="l253"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;normals[j][i],0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3</span><span class=cF7>)</span><span class=cF0>);
<a name="l254"></a>}
<a name="l255"></a>
<a name="l256"></a></span><span class=cF1>Bool</span><span class=cF0> TestSameSlope(</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> w,</span><span class=cF9>I64</span><span class=cF0> h)
<a name="l257"></a>{
<a name="l258"></a> </span><span class=cF9>CD3</span><span class=cF0> p,*s;
<a name="l259"></a> </span><span class=cF9>I64</span><span class=cF0> k1,k2;
<a name="l260"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0&lt;=x &amp;&amp; x+w&lt;MAP_WIDTH &amp;&amp; 0&lt;=y &amp;&amp; y+h&lt;MAP_HEIGHT</span><span class=cF7>)</span><span class=cF0>)
<a name="l261"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l262"></a> s=&amp;normals[y][x];
<a name="l263"></a> </span><span class=cF1>for</span><span class=cF0> (k2=0;k2&lt;h;k2++)
<a name="l264"></a> </span><span class=cF1>for</span><span class=cF0> (k1=0;k1&lt;w;k1++)
<a name="l265"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>D3NormSqr</span><span class=cF7>(</span><span class=cF5>D3Sub</span><span class=cF0>(&amp;p,&amp;normals[y+k2][x+k1],s)</span><span class=cF7>)</span><span class=cF0>&gt;.10)
<a name="l266"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l267"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l268"></a>}
<a name="l269"></a>
<a name="l270"></a></span><span class=cF1>U0</span><span class=cF0> MPDoPanels(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l271"></a>{
<a name="l272"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,l,k1,k2,w,h,threshold,lo,hi;
<a name="l273"></a> </span><span class=cF1>Bool</span><span class=cF0> cont;
<a name="l274"></a> Panel *tmpp,*start_ptr=</span><span class=cF3>NULL</span><span class=cF0>,*end_ptr=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l275"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *poly;
<a name="l276"></a> Obj *tmpo;
<a name="l277"></a> lo=</span><span class=cF5>Gs</span><span class=cF0>-&gt;num*(MAP_HEIGHT-1)/</span><span class=cFB>mp_cnt</span><span class=cF0>;
<a name="l278"></a> hi=(</span><span class=cF5>Gs</span><span class=cF0>-&gt;num+1)*(MAP_HEIGHT-1)/</span><span class=cFB>mp_cnt</span><span class=cF0>;
<a name="l279"></a> </span><span class=cF1>for</span><span class=cF0> (threshold=8;threshold&gt;=1;threshold--)
<a name="l280"></a> </span><span class=cF1>for</span><span class=cF0> (j=lo;j&lt;hi;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l281"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;MAP_WIDTH-1;i++) {
<a name="l282"></a> </span><span class=cF1>if</span><span class=cF0> (!panels[j][i]) </span><span class=cF7>{</span><span class=cF0>
<a name="l283"></a> w=1;
<a name="l284"></a> h=1;
<a name="l285"></a> </span><span class=cF1>do</span><span class=cF0> {
<a name="l286"></a> cont=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l287"></a> </span><span class=cF1>if</span><span class=cF0> (w&lt;PANEL_SIZE_MAX &amp;&amp; TestSameSlope</span><span class=cF7>(</span><span class=cF0>i,j,w+1,h</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l288"></a> w++;
<a name="l289"></a> cont=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l290"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l291"></a> </span><span class=cF1>if</span><span class=cF0> (h&lt;PANEL_SIZE_MAX &amp;&amp; TestSameSlope</span><span class=cF7>(</span><span class=cF0>i,j,w,h+1</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l292"></a> h++;
<a name="l293"></a> cont=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l294"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l295"></a> } </span><span class=cF1>while</span><span class=cF0> (cont);
<a name="l296"></a> </span><span class=cF1>if</span><span class=cF0> (w&gt;=threshold || h&gt;=threshold) {
<a name="l297"></a> tmpp=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Panel</span><span class=cF7>)</span><span class=cF0>,task);
<a name="l298"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;tmpp-&gt;next_obj);
<a name="l299"></a> l=elevations[j][i];
<a name="l300"></a> </span><span class=cF1>if</span><span class=cF0> (l&lt;=WATER_ELEVATION*MAP_SCALE &amp;&amp;
<a name="l301"></a> elevations[j][i+w-1]&lt;=WATER_ELEVATION*MAP_SCALE &amp;&amp;
<a name="l302"></a> elevations[j+h-1][i]&lt;=WATER_ELEVATION*MAP_SCALE &amp;&amp;
<a name="l303"></a> elevations[j+h-1][i+w-1]&lt;=WATER_ELEVATION*MAP_SCALE) </span><span class=cF7>{</span><span class=cF0>
<a name="l304"></a> tmpp-&gt;color=</span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l305"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0>&lt;0.05) {
<a name="l306"></a> tmpo=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj</span><span class=cF7>)</span><span class=cF0>,task);
<a name="l307"></a> tmpo-&gt;p.x=(i+w/2)*MAP_SCALE;
<a name="l308"></a> tmpo-&gt;p.y=(j+h/2)*MAP_SCALE;
<a name="l309"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0>&lt;0.1) </span><span class=cF7>{</span><span class=cF0>
<a name="l310"></a> tmpo-&gt;fish=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l311"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l312"></a> tmpo-&gt;img=landscape_large_imgs[0]; </span><span class=cF2>//Boat</span><span class=cF0>
<a name="l313"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l314"></a> tmpo-&gt;img=landscape_large_imgs[1]; </span><span class=cF2>//Boat</span><span class=cF0>
<a name="l315"></a> tmpo-&gt;p.z=(WATER_ELEVATION+2)*MAP_SCALE;
<a name="l316"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l317"></a> tmpo-&gt;fish=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l318"></a> tmpo-&gt;img=</span><span class=cFA>&lt;1&gt;</span><span class=cF0>; </span><span class=cF2>//Fish</span><span class=cF0>
<a name="l319"></a> tmpo-&gt;p.z=WATER_ELEVATION*MAP_SCALE;
<a name="l320"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l321"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpo,tmpp-&gt;last_obj);
<a name="l322"></a> }
<a name="l323"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l324"></a> </span><span class=cF1>if</span><span class=cF0> (l&lt;ROCK_ELEVATION*MAP_SCALE) {
<a name="l325"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l326"></a> tmpp-&gt;color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l327"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l328"></a> tmpp-&gt;color=</span><span class=cF3>GREEN</span><span class=cF0>+</span><span class=cF3>LTGREEN</span><span class=cF0>&lt;&lt;16+</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
<a name="l329"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0>&lt;0.03) </span><span class=cF7>{</span><span class=cF0>
<a name="l330"></a> tmpo=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj</span><span class=cF7>)</span><span class=cF0>,task);
<a name="l331"></a> tmpo-&gt;p.x=(i+w/2)*MAP_SCALE;
<a name="l332"></a> tmpo-&gt;p.y=(j+h/2)*MAP_SCALE;
<a name="l333"></a> tmpo-&gt;p.z=l;
<a name="l334"></a> tmpo-&gt;img=landscape_large_imgs[2]; </span><span class=cF2>//Tree</span><span class=cF0>
<a name="l335"></a> tmpo-&gt;fish=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l336"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpo,tmpp-&gt;last_obj);
<a name="l337"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l338"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (l&lt;SNOW_ELEVATION*MAP_SCALE) {
<a name="l339"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF5>RandU16</span><span class=cF0>&amp;3</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l341"></a> tmpp-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l342"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l343"></a> tmpp-&gt;color=</span><span class=cF3>DKGRAY</span><span class=cF0>+</span><span class=cF3>LTGRAY</span><span class=cF0>&lt;&lt;16+</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
<a name="l344"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l345"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l346"></a> tmpp-&gt;color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l347"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l348"></a> tmpp-&gt;color=</span><span class=cF3>GREEN</span><span class=cF0>+</span><span class=cF3>LTGREEN</span><span class=cF0>&lt;&lt;16+</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
<a name="l349"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l350"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l351"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF5>RandU16</span><span class=cF0>&amp;3</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l352"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l353"></a> tmpp-&gt;color=</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l354"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l355"></a> tmpp-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l356"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l357"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandI16</span><span class=cF0>&amp;1)
<a name="l358"></a> tmpp-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>+</span><span class=cF3>WHITE</span><span class=cF0>&lt;&lt;16+</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
<a name="l359"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l360"></a> tmpp-&gt;color=</span><span class=cF3>DKGRAY</span><span class=cF0>+</span><span class=cF3>LTGRAY</span><span class=cF0>&lt;&lt;16+</span><span class=cF3>ROPF_DITHER</span><span class=cF0>;
<a name="l361"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l362"></a> }
<a name="l363"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l364"></a> tmpp-&gt;num_sides=4;
<a name="l365"></a> poly=tmpp-&gt;pts=</span><span class=cF5>MAlloc</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>*tmpp-&gt;num_sides,task);
<a name="l366"></a> poly[0].x=MAP_SCALE*i;
<a name="l367"></a> poly[0].y=MAP_SCALE*j;
<a name="l368"></a> poly[0].z=elevations[j][i];
<a name="l369"></a> poly[1].x=MAP_SCALE*(i+w);
<a name="l370"></a> poly[1].y=MAP_SCALE*j;
<a name="l371"></a> poly[1].z=elevations[j][i+w];
<a name="l372"></a> poly[2].x=MAP_SCALE*(i+w);
<a name="l373"></a> poly[2].y=MAP_SCALE*(j+h);
<a name="l374"></a> poly[2].z=elevations[j+h][i+w];
<a name="l375"></a> poly[3].x=MAP_SCALE*i;
<a name="l376"></a> poly[3].y=MAP_SCALE*(j+h);
<a name="l377"></a> poly[3].z=elevations[j+h][i];
<a name="l378"></a> tmpp-&gt;next=start_ptr;
<a name="l379"></a> start_ptr=tmpp;
<a name="l380"></a> </span><span class=cF1>if</span><span class=cF0> (!end_ptr)
<a name="l381"></a> end_ptr=tmpp;
<a name="l382"></a> </span><span class=cF1>for</span><span class=cF0> (k2=0;k2&lt;h;k2++)
<a name="l383"></a> </span><span class=cF1>for</span><span class=cF0> (k1=0;k1&lt;w;k1++)
<a name="l384"></a> panels[j+k2][i+k1]=tmpp;
<a name="l385"></a> }
<a name="l386"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l387"></a> }
<a name="l388"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l389"></a> </span><span class=cF1>if</span><span class=cF0> (end_ptr) </span><span class=cF7>{</span><span class=cF0>
<a name="l390"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;critical_section_flag,0</span><span class=cF7>)</span><span class=cF0>)
<a name="l391"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l392"></a> </span><span class=cF1>if</span><span class=cF0> (end_ptr)
<a name="l393"></a> end_ptr-&gt;next=panel_head;
<a name="l394"></a> panel_head=start_ptr;
<a name="l395"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;critical_section_flag,0);
<a name="l396"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l397"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;mp.init_not_done_flags,</span><span class=cF5>Gs</span><span class=cF0>-&gt;num);
<a name="l398"></a>}
<a name="l399"></a>
<a name="l400"></a></span><span class=cF1>U0</span><span class=cF0> InitElevations()
<a name="l401"></a>{
<a name="l402"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,l,x,y,xx,yy,x1,y1,x2,y2;
<a name="l403"></a> </span><span class=cF5>MemSet</span><span class=cF0>(elevations,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>elevations</span><span class=cF7>)</span><span class=cF0>);
<a name="l404"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;MAP_WIDTH*MAP_HEIGHT/128;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l405"></a> x=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_WIDTH;
<a name="l406"></a> y=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_HEIGHT;
<a name="l407"></a> j=1&lt;&lt;(</span><span class=cF5>RandU32</span><span class=cF0>%6);
<a name="l408"></a> l=0;
<a name="l409"></a> </span><span class=cF1>while</span><span class=cF0> (j--) {
<a name="l410"></a> </span><span class=cF1>if</span><span class=cF0> (!l &amp;&amp; </span><span class=cF5>RandU16</span><span class=cF0>&lt;</span><span class=cF3>U16_MAX</span><span class=cF0>/4)
<a name="l411"></a> l=</span><span class=cF5>RandU16</span><span class=cF0>%(j+1);
<a name="l412"></a> </span><span class=cF1>if</span><span class=cF0> (l) </span><span class=cF7>{</span><span class=cF0>
<a name="l413"></a> x1=</span><span class=cF5>ClampI64</span><span class=cF0>(x-j,0,MAP_WIDTH-1);
<a name="l414"></a> x2=</span><span class=cF5>ClampI64</span><span class=cF0>(x+j,0,MAP_WIDTH-1);
<a name="l415"></a> y1=</span><span class=cF5>ClampI64</span><span class=cF0>(y-j,0,MAP_HEIGHT-1);
<a name="l416"></a> y2=</span><span class=cF5>ClampI64</span><span class=cF0>(y+j,0,MAP_HEIGHT-1);
<a name="l417"></a> </span><span class=cF1>for</span><span class=cF0> (yy=y1;yy&lt;y2;yy++)
<a name="l418"></a> </span><span class=cF1>for</span><span class=cF0> (xx=x1;xx&lt;x2;xx++)
<a name="l419"></a> elevations[yy][xx]+=MAP_SCALE/2;
<a name="l420"></a> l--;
<a name="l421"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l422"></a> }
<a name="l423"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l424"></a>
<a name="l425"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;MAP_HEIGHT;j++)
<a name="l426"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;MAP_WIDTH;i++)
<a name="l427"></a> </span><span class=cF1>if</span><span class=cF0> (elevations[j][i]&lt;WATER_ELEVATION*MAP_SCALE)
<a name="l428"></a> elevations[j][i]=WATER_ELEVATION*MAP_SCALE;
<a name="l429"></a>}
<a name="l430"></a>
<a name="l431"></a></span><span class=cF1>U0</span><span class=cF0> InitMap()
<a name="l432"></a>{</span><span class=cF2>/*We make a topographic data structure &quot;elevations[][]&quot;</span><span class=cF0>
<a name="l433"></a></span><span class=cF2>and convert it to panels. &quot;panels[][]&quot; holds the panels</span><span class=cF0>
<a name="l434"></a></span><span class=cF2>for each spot.</span><span class=cF0>
<a name="l435"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l436"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l437"></a> InitElevations;
<a name="l438"></a> </span><span class=cF5>MemSet</span><span class=cF0>(panels,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>panels</span><span class=cF7>)</span><span class=cF0>);
<a name="l439"></a> CalcNormals;
<a name="l440"></a> panel_head=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l441"></a> mp.init_not_done_flags=1&lt;&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>-1;
<a name="l442"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
<a name="l443"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;MPDoPanels,</span><span class=cF5>Fs</span><span class=cF0>,</span><span class=cF6>&quot;Do Panels&quot;</span><span class=cF0>,i);
<a name="l444"></a> </span><span class=cF1>while</span><span class=cF0> (mp.init_not_done_flags)
<a name="l445"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l446"></a>}
<a name="l447"></a>
<a name="l448"></a></span><span class=cF1>F64</span><span class=cF0> claws_down;
<a name="l449"></a>
<a name="l450"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_X (1.0-claws_down)*(0.3*w)+claws_down*(0.4*w)
<a name="l451"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_Y (1.0-claws_down)*(h-125)+claws_down*h
<a name="l452"></a>
<a name="l453"></a>
<a name="l454"></a>
<a name="l455"></a></span><span class=cFA>
<a name="l456"></a>&lt;7&gt;/* Graphics Not Rendered in HTML */
<a name="l457"></a>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l458"></a>
<a name="l459"></a>
<a name="l460"></a>
<a name="l461"></a></span><span class=cF1>U0</span><span class=cF0> ClawDraw(</span><span class=cF9>CDC</span><span class=cF0> *dc,</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,</span><span class=cF9>I64</span><span class=cF0> w,</span><span class=cF9>I64</span><span class=cF0> segments,</span><span class=cF1>Bool</span><span class=cF0> talon)
<a name="l462"></a>{
<a name="l463"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l464"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,j=segments;i&lt;segments;i++,j--) </span><span class=cF7>{</span><span class=cF0>
<a name="l465"></a> dc-&gt;thick=w;
<a name="l466"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l467"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,
<a name="l468"></a> j*x1/segments+i*x2/segments,
<a name="l469"></a> j*y1/segments+i*y2/segments,0,
<a name="l470"></a> </span><span class=cF7>(</span><span class=cF0>j-1</span><span class=cF7>)</span><span class=cF0>*x1/segments+</span><span class=cF7>(</span><span class=cF0>i+1</span><span class=cF7>)</span><span class=cF0>*x2/segments,
<a name="l471"></a> </span><span class=cF7>(</span><span class=cF0>j-1</span><span class=cF7>)</span><span class=cF0>*y1/segments+</span><span class=cF7>(</span><span class=cF0>i+1</span><span class=cF7>)</span><span class=cF0>*y2/segments,0);
<a name="l472"></a> dc-&gt;thick=w-2;
<a name="l473"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l474"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,
<a name="l475"></a> j*x1/segments+i*x2/segments,
<a name="l476"></a> j*y1/segments+i*y2/segments,0,
<a name="l477"></a> </span><span class=cF7>(</span><span class=cF0>j-1</span><span class=cF7>)</span><span class=cF0>*x1/segments+</span><span class=cF7>(</span><span class=cF0>i+1</span><span class=cF7>)</span><span class=cF0>*x2/segments,
<a name="l478"></a> </span><span class=cF7>(</span><span class=cF0>j-1</span><span class=cF7>)</span><span class=cF0>*y1/segments+</span><span class=cF7>(</span><span class=cF0>i+1</span><span class=cF7>)</span><span class=cF0>*y2/segments,0);
<a name="l479"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l480"></a> </span><span class=cF1>if</span><span class=cF0> (talon) </span><span class=cF7>{</span><span class=cF0>
<a name="l481"></a> </span><span class=cF1>if</span><span class=cF0> (y1&lt;y2)
<a name="l482"></a> </span><span class=cF5>Sprite3B</span><span class=cF0>(dc,x1,y1,0,</span><span class=cFA>&lt;7&gt;</span><span class=cF0>);
<a name="l483"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l484"></a> </span><span class=cF5>Sprite3B</span><span class=cF0>(dc,x1,y1,0,</span><span class=cFA>&lt;8&gt;</span><span class=cF0>);
<a name="l485"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l486"></a>}
<a name="l487"></a>
<a name="l488"></a></span><span class=cF1>U0</span><span class=cF0> ClawsDraw(</span><span class=cF9>CTask</span><span class=cF0> *task,</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l489"></a>{
<a name="l490"></a> </span><span class=cF1>F64</span><span class=cF0> claws_up=1.0-claws_down;
<a name="l491"></a> </span><span class=cF9>I64</span><span class=cF0> w=task-&gt;pix_width,h=task-&gt;pix_height;
<a name="l492"></a> dc-&gt;flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
<a name="l493"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc,w&gt;&gt;1,0,w&gt;&gt;1,1);
<a name="l494"></a>
<a name="l495"></a> ClawDraw(dc,HAND_X-30,HAND_Y-50*claws_up,HAND_X-5,HAND_Y, 22,4,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l496"></a> ClawDraw(dc,HAND_X-10,HAND_Y-60*claws_up,HAND_X,HAND_Y, 22,4,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l497"></a> ClawDraw(dc,HAND_X+10,HAND_Y-60*claws_up,HAND_X,HAND_Y, 22,4,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l498"></a> ClawDraw(dc,HAND_X+30,HAND_Y-50*claws_up,HAND_X+5,HAND_Y, 22,4,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l499"></a> ClawDraw(dc,HAND_X+25,HAND_Y+40*claws_up,HAND_X+5,HAND_Y, 22,4,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l500"></a>
<a name="l501"></a> ClawDraw(dc,HAND_X,HAND_Y,6*w/20,h,38,5,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l502"></a>}
<a name="l503"></a>
<a name="l504"></a></span><span class=cF9>CDC</span><span class=cF0> *main_dc;
<a name="l505"></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="l506"></a>{
<a name="l507"></a> main_dc-&gt;flags|=</span><span class=cF3>DCF_NO_TRANSPARENTS</span><span class=cF0>;
<a name="l508"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,0,0,main_dc);
<a name="l509"></a> </span><span class=cF1>if</span><span class=cF0> (claws_down)
<a name="l510"></a> ClawsDraw(task,dc);
<a name="l511"></a>}
<a name="l512"></a>
<a name="l513"></a></span><span class=cF2>/*</span><span class=cFA>
<a name="l514"></a>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l515"></a>
<a name="l516"></a>
<a name="l517"></a>
<a name="l518"></a>
<a name="l519"></a>
<a name="l520"></a>
<a name="l521"></a>
<a name="l522"></a>
<a name="l523"></a>
<a name="l524"></a>
<a name="l525"></a>
<a name="l526"></a>
<a name="l527"></a>
<a name="l528"></a>
<a name="l529"></a>
<a name="l530"></a>
<a name="l531"></a>
<a name="l532"></a></span><span class=cFA>
<a name="l533"></a>&lt;10&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l534"></a>
<a name="l535"></a>
<a name="l536"></a>
<a name="l537"></a>
<a name="l538"></a>
<a name="l539"></a>
<a name="l540"></a>
<a name="l541"></a>
<a name="l542"></a>
<a name="l543"></a>
<a name="l544"></a>
<a name="l545"></a>
<a name="l546"></a>
<a name="l547"></a>
<a name="l548"></a>
<a name="l549"></a>
<a name="l550"></a>
<a name="l551"></a>
<a name="l552"></a>
<a name="l553"></a>
<a name="l554"></a>
<a name="l555"></a>
<a name="l556"></a>
<a name="l557"></a>
<a name="l558"></a>
<a name="l559"></a>
<a name="l560"></a>
<a name="l561"></a>
<a name="l562"></a>
<a name="l563"></a>
<a name="l564"></a>
<a name="l565"></a>
<a name="l566"></a></span><span class=cF2>Cores render strips that +/- 15%. The cores check the panel map array</span><span class=cF0>
<a name="l567"></a></span><span class=cF2>and render the panel for each square, marking-it done.</span><span class=cF0>
<a name="l568"></a>
<a name="l569"></a></span><span class=cF2>The depth buf is not locked in the graphic routines</span><span class=cF0>
<a name="l570"></a></span><span class=cF2>so we get some glitches.</span><span class=cF0>
<a name="l571"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l572"></a>
<a name="l573"></a></span><span class=cF9>I64</span><span class=cF0> update_jiffy_limit;
<a name="l574"></a>
<a name="l575"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MPDrawIt</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="l576"></a>{
<a name="l577"></a> </span><span class=cF9>I64</span><span class=cF0> j,update=</span><span class=cFB>winmgr</span><span class=cF0>.updates&amp;65535,strip_width,*s2w,x1,y1,z1,xx,yy,
<a name="l578"></a> xh,yh,zh,yh2,xh2,x1h,y1h,x1wa,y1wa,x1wb,y1wb,x3,y3,z3,dd,dd_old,
<a name="l579"></a> cx=task-&gt;pix_width&gt;&gt;1,cy=task-&gt;pix_height&gt;&gt;1,r[16],*elems1,*elems_hard;
<a name="l580"></a> Panel </span><span class=cF1>reg</span><span class=cF0> *tmpp;
<a name="l581"></a> Bird *tmpb;
<a name="l582"></a> Obj *tmpo;
<a name="l583"></a> </span><span class=cF1>Bool</span><span class=cF0> w_on_map,h_on_map;
<a name="l584"></a>
<a name="l585"></a> xx=x/(MAP_SCALE*COORDINATE_SCALE);
<a name="l586"></a> yy=y/(MAP_SCALE*COORDINATE_SCALE);
<a name="l587"></a>
<a name="l588"></a> </span><span class=cF2>//World to scrn coordinates</span><span class=cF0>
<a name="l589"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(dc-&gt;r);
<a name="l590"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc-&gt;r,heading);
<a name="l591"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(dc-&gt;r,phi);
<a name="l592"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc-&gt;r,roll);
<a name="l593"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,dc-&gt;r);
<a name="l594"></a>
<a name="l595"></a> </span><span class=cF2>//Scrn to world coordinates</span><span class=cF0>
<a name="l596"></a>
<a name="l597"></a> </span><span class=cF2>//This gives us the vects for stepping through the grid in</span><span class=cF0>
<a name="l598"></a> </span><span class=cF2>//the direction the plane is facing. we step horizontally and vertically</span><span class=cF0>
<a name="l599"></a> </span><span class=cF2>//and use the reciprocal slope principle</span><span class=cF0>
<a name="l600"></a> </span><span class=cF2>//y=mx+b and y=(-1/m)x+b are perpendicular.</span><span class=cF0>
<a name="l601"></a>
<a name="l602"></a> s2w=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>;
<a name="l603"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-roll);
<a name="l604"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(s2w,-phi);
<a name="l605"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-heading);
<a name="l606"></a>
<a name="l607"></a> xh=0;
<a name="l608"></a> yh=0;
<a name="l609"></a> zh=-256;
<a name="l610"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(s2w,&amp;xh,&amp;yh,&amp;zh);
<a name="l611"></a>
<a name="l612"></a> </span><span class=cF2>//The layer for core1 is not cleared automatically</span><span class=cF0>
<a name="l613"></a> </span><span class=cF2>//it is persistent. I have carefully syncronized to the update</span><span class=cF0>
<a name="l614"></a> </span><span class=cF2>//cycle initiated by Core0 to prevent flicker.</span><span class=cF0>
<a name="l615"></a>
<a name="l616"></a> dc-&gt;flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l617"></a> dc-&gt;transform=&amp;EDTransform;
<a name="l618"></a> dc-&gt;x=cx;
<a name="l619"></a> dc-&gt;y=cy;
<a name="l620"></a>
<a name="l621"></a> </span><span class=cF2>//dc-&gt;x and the translation part of dc-&gt;r are ident in effect,</span><span class=cF0>
<a name="l622"></a> </span><span class=cF2>//but we use both to show-off.</span><span class=cF0> </span><span class=cF2>We could add offsets together and</span><span class=cF0>
<a name="l623"></a> </span><span class=cF2>//use one or the other.</span><span class=cF0>
<a name="l624"></a>
<a name="l625"></a> x1=-x&gt;&gt;COORDINATE_BITS;
<a name="l626"></a> y1=-y&gt;&gt;COORDINATE_BITS;
<a name="l627"></a> z1=-z&gt;&gt;COORDINATE_BITS;
<a name="l628"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc-&gt;r,&amp;x1,&amp;y1,&amp;z1);
<a name="l629"></a> </span><span class=cF5>Mat4x4TranslationEqu</span><span class=cF0>(dc-&gt;r,x1,y1,z1);
<a name="l630"></a>
<a name="l631"></a> </span><span class=cF2>//This is a refinement.</span><span class=cF0>
<a name="l632"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Abs</span><span class=cF7>(</span><span class=cF0>phi*180/</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>&gt;90) </span><span class=cF7>{</span><span class=cF0>
<a name="l633"></a> x3=0;
<a name="l634"></a> y3=-cy;
<a name="l635"></a> z3=0;
<a name="l636"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(s2w,&amp;x3,&amp;y3,&amp;z3);
<a name="l637"></a> xx+=x3;
<a name="l638"></a> yy+=y3;
<a name="l639"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l640"></a>
<a name="l641"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Gs</span><span class=cF0>-&gt;num&amp;1) </span><span class=cF7>{</span><span class=cF2>//alt left-right,right-left</span><span class=cF0>
<a name="l642"></a> yh2=-yh;
<a name="l643"></a> xh2=-xh;
<a name="l644"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l645"></a> yh2=yh;
<a name="l646"></a> xh2=xh;
<a name="l647"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l648"></a>
<a name="l649"></a> </span><span class=cF2>//Calc starting point.</span><span class=cF0>
<a name="l650"></a> x1wa=xx&lt;&lt;8+xh*strip_height&gt;&gt;1/1.3*(</span><span class=cF5>Gs</span><span class=cF0>-&gt;num+1.15);
<a name="l651"></a> y1wa=yy&lt;&lt;8+yh*strip_height&gt;&gt;1/1.3*(</span><span class=cF5>Gs</span><span class=cF0>-&gt;num+1.15);
<a name="l652"></a> x1wb=0;
<a name="l653"></a> y1wb=0;
<a name="l654"></a>
<a name="l655"></a> xh=-xh; </span><span class=cF2>//Back to front to help with depth.</span><span class=cF0>
<a name="l656"></a> yh=-yh;
<a name="l657"></a>
<a name="l658"></a> </span><span class=cF2>//Take half steps to cover whole grid.</span><span class=cF0>
<a name="l659"></a> xh&gt;&gt;=1; yh&gt;&gt;=1;
<a name="l660"></a> xh2&gt;&gt;=1; yh2&gt;&gt;=1;
<a name="l661"></a> w_on_map=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l662"></a> dd_old=</span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l663"></a> </span><span class=cF1>for</span><span class=cF0> (strip_width=0;</span><span class=cFB>cnts</span><span class=cF0>.jiffies&lt;update_jiffy_limit;strip_width++) </span><span class=cF7>{</span><span class=cF0>
<a name="l664"></a> x1h=x1wa;
<a name="l665"></a> y1h=y1wa;
<a name="l666"></a> h_on_map=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l667"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;strip_height &amp;&amp; </span><span class=cFB>cnts</span><span class=cF0>.jiffies&lt;update_jiffy_limit;j++) {
<a name="l668"></a> x1=x1h&gt;&gt;8; y1=y1h&gt;&gt;8;
<a name="l669"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=x1&lt;MAP_WIDTH &amp;&amp; 0&lt;=y1&lt;MAP_HEIGHT) </span><span class=cF7>{</span><span class=cF0>
<a name="l670"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>tmpp=panels[y1][x1]</span><span class=cF7>)</span><span class=cF0> &amp;&amp; tmpp-&gt;update!=update) {
<a name="l671"></a> tmpp-&gt;update=update;
<a name="l672"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;cnt&gt;8*</span><span class=cF7>(</span><span class=cF0>1.1-</span><span class=cF5>Gs</span><span class=cF0>-&gt;idle_factor</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l673"></a> dc-&gt;color=tmpp-&gt;color;
<a name="l674"></a> tmpp-&gt;cnt=</span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,tmpp-&gt;num_sides,tmpp-&gt;pts);
<a name="l675"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l676"></a> tmpp-&gt;cnt++;
<a name="l677"></a> tmpo=tmpp-&gt;next_obj;
<a name="l678"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo!=&amp;tmpp-&gt;next_obj) </span><span class=cF7>{</span><span class=cF0>
<a name="l679"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpo-&gt;p.x,tmpo-&gt;p.y,tmpo-&gt;p.z,tmpo-&gt;img);
<a name="l680"></a> tmpo=tmpo-&gt;next;
<a name="l681"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l682"></a> }
<a name="l683"></a> h_on_map=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l684"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (h_on_map)
<a name="l685"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l686"></a> x1h+=xh;
<a name="l687"></a> y1h+=yh;
<a name="l688"></a> }
<a name="l689"></a> </span><span class=cF1>if</span><span class=cF0> (h_on_map)
<a name="l690"></a> w_on_map=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l691"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (w_on_map) {
<a name="l692"></a> strip_width=</span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l693"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l694"></a> }
<a name="l695"></a> x1wb-=yh2;
<a name="l696"></a> y1wb+=xh2;
<a name="l697"></a> </span><span class=cF1>if</span><span class=cF0> (strip_width&amp;1) {
<a name="l698"></a> x1wa-=x1wb;
<a name="l699"></a> y1wa-=y1wb;
<a name="l700"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l701"></a> x1wa+=x1wb;
<a name="l702"></a> y1wa+=y1wb;
<a name="l703"></a> }
<a name="l704"></a> </span><span class=cF1>if</span><span class=cF0> (!w_on_map) {
<a name="l705"></a> dd=</span><span class=cF5>SqrI64</span><span class=cF0>(x1wa&gt;&gt;8-MAP_WIDTH&gt;&gt;1)+</span><span class=cF5>SqrI64</span><span class=cF0>(y1wa&gt;&gt;8-MAP_HEIGHT&gt;&gt;1);
<a name="l706"></a> </span><span class=cF1>if</span><span class=cF0> (dd&gt;dd_old)
<a name="l707"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l708"></a> dd_old=dd;
<a name="l709"></a> }
<a name="l710"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l711"></a>
<a name="l712"></a> tmpb=b_head[</span><span class=cF5>Gs</span><span class=cF0>-&gt;num].next;
<a name="l713"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&amp;b_head[</span><span class=cF5>Gs</span><span class=cF0>-&gt;num]) </span><span class=cF7>{</span><span class=cF0>
<a name="l714"></a> elems1=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF5>Tri</span><span class=cF7>(</span><span class=cF5>tS</span><span class=cF0>,0.2</span><span class=cF7>)</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>);
<a name="l715"></a>
<a name="l716"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l717"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r,tmpb-&gt;theta);
<a name="l718"></a> elems_hard=</span><span class=cF5>SpriteTransform</span><span class=cF0>(elems1,r);
<a name="l719"></a>
<a name="l720"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpb-&gt;p.x,tmpb-&gt;p.y,tmpb-&gt;p.z,elems_hard);
<a name="l721"></a> </span><span class=cF5>Free</span><span class=cF0>(elems_hard);
<a name="l722"></a> </span><span class=cF5>Free</span><span class=cF0>(elems1);
<a name="l723"></a>
<a name="l724"></a> tmpb=tmpb-&gt;next;
<a name="l725"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l726"></a>
<a name="l727"></a> </span><span class=cF5>Free</span><span class=cF0>(s2w);
<a name="l728"></a> mp.strip_width[</span><span class=cF5>Gs</span><span class=cF0>-&gt;num]=strip_width;
<a name="l729"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;mp.update_not_done_flags,</span><span class=cF5>Gs</span><span class=cF0>-&gt;num);
<a name="l730"></a>}
<a name="l731"></a>
<a name="l732"></a></span><span class=cF1>U0</span><span class=cF0> CoreAPTalonsTask(</span><span class=cF9>CTask</span><span class=cF0> *master_task)
<a name="l733"></a>{
<a name="l734"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCAlias</span><span class=cF0>(main_dc,master_task);
<a name="l735"></a> </span><span class=cF1>while</span><span class=cF0> (!mp.app_done) </span><span class=cF7>{</span><span class=cF0>
<a name="l736"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;mp.update_not_done_flags,</span><span class=cF5>Gs</span><span class=cF0>-&gt;num</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !mp.app_done)
<a name="l737"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l738"></a> </span><span class=cF1>if</span><span class=cF0> (!mp.app_done)
<a name="l739"></a> </span><span class=cF5>MPDrawIt</span><span class=cF0>(master_task,dc);
<a name="l740"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l741"></a>
<a name="l742"></a> </span><span class=cF2>//We made an alias of this we don't want freed.</span><span class=cF0>
<a name="l743"></a> dc-&gt;depth_buf=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l744"></a>
<a name="l745"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l746"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;mp.app_not_done_flags,</span><span class=cF5>Gs</span><span class=cF0>-&gt;num);
<a name="l747"></a>}
<a name="l748"></a>
<a name="l749"></a></span><span class=cF1>U0</span><span class=cF0> DrawHorizon(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l750"></a>{
<a name="l751"></a> </span><span class=cF9>I64</span><span class=cF0> x1,y1,z1,x2,y2,z2,xh,yh,zh,*s2w=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>,
<a name="l752"></a> cx=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width&gt;&gt;1,
<a name="l753"></a> cy=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height&gt;&gt;1;
<a name="l754"></a> </span><span class=cF9>CD3I32</span><span class=cF0> p[4];
<a name="l755"></a> </span><span class=cF9>I32</span><span class=cF0> *old_db=dc-&gt;depth_buf;
<a name="l756"></a> dc-&gt;depth_buf=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l757"></a> </span><span class=cF9>CColorROPU32</span><span class=cF0> ground_color;
<a name="l758"></a>
<a name="l759"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf &amp;&amp; fish_left)
<a name="l760"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc,</span><span class=cF3>BLACK</span><span class=cF0>);
<a name="l761"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (-</span><span class=cF3>pi</span><span class=cF0>/4&lt;=</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>phi-</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>&lt;</span><span class=cF3>pi</span><span class=cF0>/4)
<a name="l762"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc,</span><span class=cF3>LTCYAN</span><span class=cF0>);
<a name="l763"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l764"></a> </span><span class=cF1>if</span><span class=cF0> (z/COORDINATE_SCALE&lt;</span><span class=cF7>(</span><span class=cF0>WATER_ELEVATION+3</span><span class=cF7>)</span><span class=cF0>*MAP_SCALE)
<a name="l765"></a> ground_color=</span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l766"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l767"></a> ground_color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l768"></a>
<a name="l769"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(dc-&gt;r);
<a name="l770"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc-&gt;r,heading);
<a name="l771"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(dc-&gt;r,phi);
<a name="l772"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc-&gt;r,roll);
<a name="l773"></a>
<a name="l774"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,dc-&gt;r);
<a name="l775"></a> dc-&gt;flags&amp;=~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l776"></a> dc-&gt;transform=&amp;EDTransform;
<a name="l777"></a> dc-&gt;x=cx;
<a name="l778"></a> dc-&gt;y=cy;
<a name="l779"></a>
<a name="l780"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-roll);
<a name="l781"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(s2w,-phi);
<a name="l782"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-heading);
<a name="l783"></a>
<a name="l784"></a> xh=0;
<a name="l785"></a> yh=0;
<a name="l786"></a> zh=-256;
<a name="l787"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(s2w,&amp;xh,&amp;yh,&amp;zh);
<a name="l788"></a> </span><span class=cF5>Free</span><span class=cF0>(s2w);
<a name="l789"></a>
<a name="l790"></a> x1=xh+yh*32; y1=yh-xh*32; z1=0;
<a name="l791"></a> (*dc-&gt;transform)(dc,&amp;x1,&amp;y1,&amp;z1);
<a name="l792"></a> x2=xh-yh*32; y2=yh+xh*32; z2=0;
<a name="l793"></a> (*dc-&gt;transform)(dc,&amp;x2,&amp;y2,&amp;z2);
<a name="l794"></a> </span><span class=cF5>DCClipLine</span><span class=cF0>(dc,&amp;x1,&amp;y1,&amp;x2,&amp;y2);
<a name="l795"></a>
<a name="l796"></a> </span><span class=cF5>MemSet</span><span class=cF0>(p,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>p</span><span class=cF7>)</span><span class=cF0>);
<a name="l797"></a> </span><span class=cF1>if</span><span class=cF0> (x2&lt;x1) {
<a name="l798"></a> </span><span class=cF5>SwapI64</span><span class=cF0>(&amp;x1,&amp;x2);
<a name="l799"></a> </span><span class=cF5>SwapI64</span><span class=cF0>(&amp;y1,&amp;y2);
<a name="l800"></a> }
<a name="l801"></a> </span><span class=cF1>if</span><span class=cF0> (!x1 &amp;&amp; x2==dc-&gt;width-1) {
<a name="l802"></a> p[0].x=0;
<a name="l803"></a> p[0].y=0;
<a name="l804"></a> p[1].x=dc-&gt;width-1;
<a name="l805"></a> p[1].y=0;
<a name="l806"></a> p[2].x=dc-&gt;width-1;
<a name="l807"></a> p[2].y=y2;
<a name="l808"></a> p[3].x=0;
<a name="l809"></a> p[3].y=y1;
<a name="l810"></a> </span><span class=cF1>if</span><span class=cF0> (rolled_over)
<a name="l811"></a> dc-&gt;color=ground_color;
<a name="l812"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l813"></a> dc-&gt;color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l814"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,p);
<a name="l815"></a> p[0].y=dc-&gt;height-1;
<a name="l816"></a> p[1].y=dc-&gt;height-1;
<a name="l817"></a> </span><span class=cF1>if</span><span class=cF0> (rolled_over)
<a name="l818"></a> dc-&gt;color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l819"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l820"></a> dc-&gt;color=ground_color;
<a name="l821"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,p);
<a name="l822"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l823"></a> </span><span class=cF1>if</span><span class=cF0> (y2&lt;y1) </span><span class=cF7>{</span><span class=cF0>
<a name="l824"></a> </span><span class=cF5>SwapI64</span><span class=cF0>(&amp;x1,&amp;x2);
<a name="l825"></a> </span><span class=cF5>SwapI64</span><span class=cF0>(&amp;y1,&amp;y2);
<a name="l826"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l827"></a> </span><span class=cF1>if</span><span class=cF0> (!y1 &amp;&amp; y2==dc-&gt;height-1) </span><span class=cF7>{</span><span class=cF0>
<a name="l828"></a> p[0].x=0;
<a name="l829"></a> p[0].y=0;
<a name="l830"></a> p[1].x=0;
<a name="l831"></a> p[1].y=dc-&gt;height-1;
<a name="l832"></a> p[2].x=x2;
<a name="l833"></a> p[2].y=dc-&gt;height-1;
<a name="l834"></a> p[3].x=x1;
<a name="l835"></a> p[3].y=0;
<a name="l836"></a> </span><span class=cF1>if</span><span class=cF0> (x1&lt;x2 ^^ rolled_over)
<a name="l837"></a> dc-&gt;color=ground_color;
<a name="l838"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l839"></a> dc-&gt;color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l840"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,p);
<a name="l841"></a> p[0].x=dc-&gt;width-1;
<a name="l842"></a> p[1].x=dc-&gt;width-1;
<a name="l843"></a> </span><span class=cF1>if</span><span class=cF0> (x1&lt;x2 ^^ rolled_over)
<a name="l844"></a> dc-&gt;color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l845"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l846"></a> dc-&gt;color=ground_color;
<a name="l847"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,p);
<a name="l848"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l849"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc,</span><span class=cF3>LTCYAN</span><span class=cF0>); </span><span class=cF2>//Not correct.</span><span class=cF0>
<a name="l850"></a> }
<a name="l851"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l852"></a>
<a name="l853"></a> dc-&gt;depth_buf=old_db;
<a name="l854"></a>}
<a name="l855"></a>
<a name="l856"></a></span><span class=cF1>U0</span><span class=cF0> Core0Talons()
<a name="l857"></a>{
<a name="l858"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCAlias</span><span class=cF0>(main_dc,</span><span class=cF5>Fs</span><span class=cF0>);
<a name="l859"></a> </span><span class=cF9>I64</span><span class=cF0> i,xx,yy,elev,height,cx=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width&gt;&gt;1,cy=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height&gt;&gt;1;
<a name="l860"></a> </span><span class=cF1>F64</span><span class=cF0> min_strip_width,tt;
<a name="l861"></a>
<a name="l862"></a> update_jiffy_limit=</span><span class=cFB>cnts</span><span class=cF0>.jiffies+</span><span class=cF3>JIFFY_FREQ</span><span class=cF0>/40;
<a name="l863"></a>
<a name="l864"></a> xx=x/(MAP_SCALE*COORDINATE_SCALE);
<a name="l865"></a> yy=y/(MAP_SCALE*COORDINATE_SCALE);
<a name="l866"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=xx&lt;MAP_WIDTH &amp;&amp; 0&lt;=yy&lt;MAP_HEIGHT)
<a name="l867"></a> elev=elevations[yy][xx];
<a name="l868"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l869"></a> elev=</span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l870"></a>
<a name="l871"></a> height=z/COORDINATE_SCALE-elev;
<a name="l872"></a> </span><span class=cF1>if</span><span class=cF0> (height&lt;0 &amp;&amp; elev&gt;WATER_ELEVATION*MAP_SCALE &amp;&amp; !game_tf) </span><span class=cF7>{</span><span class=cF0>
<a name="l873"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l874"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l875"></a> game_tf=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l876"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l877"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l878"></a>
<a name="l879"></a> DrawHorizon(dc);
<a name="l880"></a>
<a name="l881"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf) </span><span class=cF7>{</span><span class=cF0>
<a name="l882"></a> tt=game_tf-game_t0;
<a name="l883"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>) {
<a name="l884"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l885"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width-9*</span><span class=cF3>FONT_WIDTH</span><span class=cF7>)</span><span class=cF0>/2,
<a name="l886"></a> </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,</span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l887"></a> }
<a name="l888"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l889"></a> </span><span class=cF5>DCDepthBufRst</span><span class=cF0>(dc);
<a name="l890"></a> mp.update_not_done_flags=1&lt;&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>-1;
<a name="l891"></a> </span><span class=cF5>MPDrawIt</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>,dc);
<a name="l892"></a> </span><span class=cF1>while</span><span class=cF0> (mp.update_not_done_flags)
<a name="l893"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l894"></a>
<a name="l895"></a> min_strip_width=</span><span class=cF3>F64_MAX</span><span class=cF0>;
<a name="l896"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
<a name="l897"></a> min_strip_width=</span><span class=cF5>Min</span><span class=cF0>(min_strip_width,32.0*mp.strip_width[i]/</span><span class=cF7>(</span><span class=cF0>i+32.0</span><span class=cF7>)</span><span class=cF0>);
<a name="l898"></a> strip_height=</span><span class=cF5>ClampI64</span><span class=cF0>(
<a name="l899"></a> strip_height*</span><span class=cF5>Clamp</span><span class=cF7>(</span><span class=cF0>0.25*min_strip_width/strip_height,0.9,1.1</span><span class=cF7>)</span><span class=cF0>,
<a name="l900"></a> 64,1024);
<a name="l901"></a>
<a name="l902"></a> tt=</span><span class=cF5>tS</span><span class=cF0>-game_t0;
<a name="l903"></a> </span><span class=cF1>if</span><span class=cF0> (tt&lt;5.0 &amp;&amp; </span><span class=cF5>Blink</span><span class=cF0>) {
<a name="l904"></a> dc-&gt;color=</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l905"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width-13*</span><span class=cF3>FONT_WIDTH</span><span class=cF7>)</span><span class=cF0>/2,
<a name="l906"></a> </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2-4*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,</span><span class=cF6>&quot;Catch 10 Fish&quot;</span><span class=cF0>);
<a name="l907"></a> }
<a name="l908"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l909"></a>
<a name="l910"></a> dc-&gt;thick=2;
<a name="l911"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf &amp;&amp; fish_left)
<a name="l912"></a> dc-&gt;color=</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l913"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l914"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l915"></a> dc-&gt;flags&amp;=~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l916"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,cx+5,cy,0,cx-5,cy,0);
<a name="l917"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,cx,cy+5,0,cx,cy-5,0);
<a name="l918"></a> </span><span class=cF1>if</span><span class=cF0> (invert_pitch)
<a name="l919"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>&quot;Pitch:%5.1f Roll:%5.1f Heading:%5.1f &quot;</span><span class=cF0>
<a name="l920"></a> </span><span class=cF6>&quot;Height:%5d [Core Strip:%3d]&quot;</span><span class=cF0>,
<a name="l921"></a> pitch*180/</span><span class=cF3>pi</span><span class=cF0>,</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>roll+</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>*180/</span><span class=cF3>pi</span><span class=cF0>,</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>heading+</span><span class=cF3>pi</span><span class=cF0>,0</span><span class=cF7>)</span><span class=cF0>*180/</span><span class=cF3>pi</span><span class=cF0>,
<a name="l922"></a> height,strip_height);
<a name="l923"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l924"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>&quot;Pitch:%5.1f Roll:%5.1f Heading:%5.1f &quot;</span><span class=cF0>
<a name="l925"></a> </span><span class=cF6>&quot;Height:%5d [Core Strip:%3d]&quot;</span><span class=cF0>,
<a name="l926"></a> pitch*180/</span><span class=cF3>pi</span><span class=cF0>,roll*180/</span><span class=cF3>pi</span><span class=cF0>,heading*180/</span><span class=cF3>pi</span><span class=cF0>,height,strip_height);
<a name="l927"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,</span><span class=cF6>&quot;Fish Remaining:%d Time:%3.2f Best:%3.2f&quot;</span><span class=cF0>,
<a name="l928"></a> fish_left,tt,best_score);
<a name="l929"></a>
<a name="l930"></a> </span><span class=cF2>//We made an alias of this we don't want freed.</span><span class=cF0>
<a name="l931"></a> dc-&gt;depth_buf=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l932"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l933"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l934"></a>}
<a name="l935"></a>
<a name="l936"></a>
<a name="l937"></a>Obj *FishFind(</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> *_dd)
<a name="l938"></a>{
<a name="l939"></a> </span><span class=cF9>I64</span><span class=cF0> dd,best_dd=</span><span class=cF3>I64_MAX</span><span class=cF0>;
<a name="l940"></a> Obj *res=</span><span class=cF3>NULL</span><span class=cF0>,*tmpo;
<a name="l941"></a> Panel *tmpp=panel_head;
<a name="l942"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp) </span><span class=cF7>{</span><span class=cF0>
<a name="l943"></a> tmpo=tmpp-&gt;next_obj;
<a name="l944"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo!=&amp;tmpp-&gt;next_obj) {
<a name="l945"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;fish) </span><span class=cF7>{</span><span class=cF0>
<a name="l946"></a> dd=</span><span class=cF5>SqrI64</span><span class=cF0>(tmpo-&gt;p.x-x1)+</span><span class=cF5>SqrI64</span><span class=cF0>(tmpo-&gt;p.y-y1);
<a name="l947"></a> </span><span class=cF1>if</span><span class=cF0> (dd&lt;best_dd) {
<a name="l948"></a> best_dd=dd;
<a name="l949"></a> res=tmpo;
<a name="l950"></a> }
<a name="l951"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l952"></a> tmpo=tmpo-&gt;next;
<a name="l953"></a> }
<a name="l954"></a> tmpp=tmpp-&gt;next;
<a name="l955"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l956"></a> *_dd=best_dd;
<a name="l957"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l958"></a>}
<a name="l959"></a>
<a name="l960"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMATE_MS 10
<a name="l961"></a>
<a name="l962"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l963"></a>{</span><span class=cF2>//Steadily moves the airplane fwd.</span><span class=cF0>
<a name="l964"></a> </span><span class=cF9>I64</span><span class=cF0> i,*s2w,x1,y1,z1,dx,dy,dz,dd;
<a name="l965"></a> </span><span class=cF1>F64</span><span class=cF0> t0=</span><span class=cF5>tS</span><span class=cF0>,</span><span class=cFB>ms</span><span class=cF0>,theta,d;
<a name="l966"></a> Obj *tmpo;
<a name="l967"></a> Bird *tmpb;
<a name="l968"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l969"></a> </span><span class=cFB>ms</span><span class=cF0>=1000*(</span><span class=cF5>tS</span><span class=cF0>-t0);
<a name="l970"></a> t0=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l971"></a> </span><span class=cF1>if</span><span class=cF0> (!game_tf) {
<a name="l972"></a></span><span class=cF2>//Scrn to world coordinates</span><span class=cF0>
<a name="l973"></a> s2w=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>;
<a name="l974"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-roll);
<a name="l975"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(s2w,-phi);
<a name="l976"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-heading);
<a name="l977"></a>
<a name="l978"></a> dx=0;dy=0;dz=1&lt;&lt;16;
<a name="l979"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(s2w,&amp;dx,&amp;dy,&amp;dz);
<a name="l980"></a> x-=speed*</span><span class=cFB>ms</span><span class=cF0>*COORDINATE_SCALE*dx/1&lt;&lt;16;
<a name="l981"></a> y-=speed*</span><span class=cFB>ms</span><span class=cF0>*COORDINATE_SCALE*dy/1&lt;&lt;16;
<a name="l982"></a> z-=speed*</span><span class=cFB>ms</span><span class=cF0>*COORDINATE_SCALE*dz/1&lt;&lt;16;
<a name="l983"></a> </span><span class=cF5>Free</span><span class=cF0>(s2w);
<a name="l984"></a> x1=x/COORDINATE_SCALE; y1=y/COORDINATE_SCALE; z1=z/COORDINATE_SCALE;
<a name="l985"></a> </span><span class=cF1>if</span><span class=cF0> (z1&lt;</span><span class=cF7>(</span><span class=cF0>WATER_ELEVATION+3</span><span class=cF7>)</span><span class=cF0>*MAP_SCALE) </span><span class=cF7>{</span><span class=cF0>
<a name="l986"></a> </span><span class=cF1>if</span><span class=cF0> (z1&lt;WATER_ELEVATION*MAP_SCALE) {
<a name="l987"></a> z=WATER_ELEVATION*MAP_SCALE*COORDINATE_SCALE;
<a name="l988"></a> </span><span class=cF1>if</span><span class=cF0> (invert_pitch) </span><span class=cF7>{</span><span class=cF0>
<a name="l989"></a> </span><span class=cF1>if</span><span class=cF0> (pitch&lt;-</span><span class=cF3>pi</span><span class=cF0>/8)
<a name="l990"></a> phi+=</span><span class=cFB>ms</span><span class=cF0>/1000.0*</span><span class=cF5>Sign</span><span class=cF0>(3*</span><span class=cF3>pi</span><span class=cF0>/8-phi);
<a name="l991"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (pitch&lt;-</span><span class=cF3>pi</span><span class=cF0>/8)
<a name="l992"></a> phi+=</span><span class=cFB>ms</span><span class=cF0>/1000.0*</span><span class=cF5>Sign</span><span class=cF0>(-3*</span><span class=cF3>pi</span><span class=cF0>/8-phi);
<a name="l993"></a> WrapAngles;
<a name="l994"></a> }
<a name="l995"></a> speed=1.0;
<a name="l996"></a> </span><span class=cF1>if</span><span class=cF0> (rolled_over || !</span><span class=cF7>(</span><span class=cF0>tmpo=FishFind(x1,y1,&amp;dd)</span><span class=cF7>)</span><span class=cF0>)
<a name="l997"></a> claws_down=0;
<a name="l998"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l999"></a> d=</span><span class=cF5>Sqrt</span><span class=cF0>(dd);
<a name="l1000"></a> x1-=tmpo-&gt;p.x;
<a name="l1001"></a> y1-=tmpo-&gt;p.y;
<a name="l1002"></a> theta=</span><span class=cF5>ACos</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>dx*x1+dy*y1</span><span class=cF7>)</span><span class=cF0>/</span><span class=cF7>(</span><span class=cF0>d*1&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>);
<a name="l1003"></a> </span><span class=cF1>if</span><span class=cF0> (theta&gt;0 &amp;&amp; d&lt;MAP_SCALE*4)
<a name="l1004"></a> claws_down=</span><span class=cF5>Saw</span><span class=cF0>(d,MAP_SCALE*4);
<a name="l1005"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l1006"></a> claws_down=0.01;
<a name="l1007"></a> </span><span class=cF1>if</span><span class=cF0> (d&lt;MAP_SCALE*2) </span><span class=cF7>{</span><span class=cF0>
<a name="l1008"></a> </span><span class=cF1>if</span><span class=cF0> (!--fish_left) {
<a name="l1009"></a> game_tf=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l1010"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf-game_t0&lt;best_score)
<a name="l1011"></a> best_score=game_tf-game_t0;
<a name="l1012"></a> }
<a name="l1013"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpo);
<a name="l1014"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpo);
<a name="l1015"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l1016"></a> </span><span class=cF5>Snd</span><span class=cF0>(74); </span><span class=cF5>Sleep</span><span class=cF0>(200); </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l1017"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l1018"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1019"></a> }
<a name="l1020"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l1021"></a> claws_down=0;
<a name="l1022"></a> </span><span class=cF1>if</span><span class=cF0> (-</span><span class=cF3>pi</span><span class=cF0>/4&lt;=phi&lt;=</span><span class=cF3>pi</span><span class=cF0>/4)
<a name="l1023"></a> speed+=0.0005;
<a name="l1024"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (-3*</span><span class=cF3>pi</span><span class=cF0>/4&lt;=phi&lt;=3*</span><span class=cF3>pi</span><span class=cF0>/4)
<a name="l1025"></a> speed+=0.0001;
<a name="l1026"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l1027"></a> speed-=0.0001;
<a name="l1028"></a> speed=</span><span class=cF5>Clamp</span><span class=cF0>(speed+</span><span class=cF7>(</span><span class=cF0>0.0005-0.0002*</span><span class=cF5>Abs</span><span class=cF0>(phi)/(</span><span class=cF3>pi</span><span class=cF0>/4)</span><span class=cF7>)</span><span class=cF0>,0.1,5.0);
<a name="l1029"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1030"></a>
<a name="l1031"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l1032"></a> tmpb=b_head[i].next;
<a name="l1033"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&amp;b_head[i]) {
<a name="l1034"></a> tmpb-&gt;p.x+=10*</span><span class=cFB>ms</span><span class=cF0>/1000*MAP_SCALE*</span><span class=cF5>Cos</span><span class=cF0>(tmpb-&gt;theta);
<a name="l1035"></a> tmpb-&gt;p.y+=10*</span><span class=cFB>ms</span><span class=cF0>/1000*MAP_SCALE*</span><span class=cF5>Sin</span><span class=cF0>(tmpb-&gt;theta);
<a name="l1036"></a> tmpb-&gt;p.z=BIRD_ELEVATION*MAP_SCALE+
<a name="l1037"></a> elevations[tmpb-&gt;p.y/MAP_SCALE][tmpb-&gt;p.x/MAP_SCALE];
<a name="l1038"></a> tmpb-&gt;theta+=2*</span><span class=cF3>pi</span><span class=cF0>*</span><span class=cFB>ms</span><span class=cF0>/1000/10;
<a name="l1039"></a> tmpb=tmpb-&gt;next;
<a name="l1040"></a> }
<a name="l1041"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1042"></a> }
<a name="l1043"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l1044"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1045"></a>}
<a name="l1046"></a>
<a name="l1047"></a></span><span class=cF1>U0</span><span class=cF0> MPEnd()
<a name="l1048"></a>{
<a name="l1049"></a> update_jiffy_limit=0;
<a name="l1050"></a> mp.app_not_done_flags=1&lt;&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>-1-1;
<a name="l1051"></a> mp.app_done=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l1052"></a></span><span class=cF2>//Wait for all cores to exit</span><span class=cF0>
<a name="l1053"></a> </span><span class=cF1>while</span><span class=cF0> (mp.app_not_done_flags)
<a name="l1054"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l1055"></a>}
<a name="l1056"></a>
<a name="l1057"></a></span><span class=cF1>U0</span><span class=cF0> TaskEndCB()
<a name="l1058"></a>{
<a name="l1059"></a> MPEnd;
<a name="l1060"></a> </span><span class=cF5>Exit</span><span class=cF0>;
<a name="l1061"></a>}
<a name="l1062"></a>
<a name="l1063"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l1064"></a>{
<a name="l1065"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_end_cb=&amp;</span><span class=cF5>SndTaskEndCB</span><span class=cF0>;
<a name="l1066"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
<a name="l1067"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l1068"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eCGFsD4A5e.C4sG5eGDqCDeGsGG4qG&quot;</span><span class=cF0>);
<a name="l1069"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eCGFsD4A5e.C4sG5eGDqCDeGsGG4qG&quot;</span><span class=cF0>);
<a name="l1070"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eGECGC4A5FCsC4B5C4B5e.GsG4qGB&quot;</span><span class=cF0>);
<a name="l1071"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eGECGC4A5FCsC4B5C4B5e.GsG4qGB&quot;</span><span class=cF0>);
<a name="l1072"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1073"></a>}
<a name="l1074"></a>
<a name="l1075"></a></span><span class=cF1>U0</span><span class=cF0> PreInit()
<a name="l1076"></a>{
<a name="l1077"></a> </span><span class=cF9>I64</span><span class=cF0> i,*r=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>;
<a name="l1078"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(r,10.0);
<a name="l1079"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;LS_TYPES;i++)
<a name="l1080"></a> landscape_large_imgs[i]=</span><span class=cF5>SpriteTransform</span><span class=cF0>(landscape_small_imgs[i],r);
<a name="l1081"></a> </span><span class=cF5>Free</span><span class=cF0>(r);
<a name="l1082"></a>}
<a name="l1083"></a>
<a name="l1084"></a></span><span class=cF1>U0</span><span class=cF0> PostCleanUp()
<a name="l1085"></a>{
<a name="l1086"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l1087"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;LS_TYPES;i++)
<a name="l1088"></a> </span><span class=cF5>Free</span><span class=cF0>(landscape_large_imgs[i]);
<a name="l1089"></a>}
<a name="l1090"></a>
<a name="l1091"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l1092"></a>{
<a name="l1093"></a> </span><span class=cF9>I64</span><span class=cF0> i,xx,yy;
<a name="l1094"></a> Bird *tmpb;
<a name="l1095"></a>
<a name="l1096"></a> main_dc=</span><span class=cF5>DCNew</span><span class=cF0>(</span><span class=cF3>GR_WIDTH</span><span class=cF0>,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>);
<a name="l1097"></a> critical_section_flag=0;
<a name="l1098"></a> game_tf=0;
<a name="l1099"></a> fish_left=10;
<a name="l1100"></a>
<a name="l1101"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;mp,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MPCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l1102"></a> InitMap;
<a name="l1103"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(main_dc);
<a name="l1104"></a>
<a name="l1105"></a> strip_height=128;
<a name="l1106"></a>
<a name="l1107"></a> phi =-90.0*</span><span class=cF3>pi</span><span class=cF0>/180.0;
<a name="l1108"></a> roll =0;
<a name="l1109"></a> heading=0;
<a name="l1110"></a> speed =2.5;
<a name="l1111"></a> claws_down=0;
<a name="l1112"></a> WrapAngles;
<a name="l1113"></a>
<a name="l1114"></a> x=MAP_WIDTH&gt;&gt;1 *COORDINATE_SCALE*MAP_SCALE;
<a name="l1115"></a> y=MAP_HEIGHT&gt;&gt;1*COORDINATE_SCALE*MAP_SCALE;
<a name="l1116"></a> z=64 *COORDINATE_SCALE*MAP_SCALE;
<a name="l1117"></a>
<a name="l1118"></a> xx=x/(MAP_SCALE*COORDINATE_SCALE);
<a name="l1119"></a> yy=y/(MAP_SCALE*COORDINATE_SCALE);
<a name="l1120"></a> z+=elevations[yy][xx]*COORDINATE_SCALE;
<a name="l1121"></a>
<a name="l1122"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
<a name="l1123"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;b_head[i]);
<a name="l1124"></a>
<a name="l1125"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;B_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l1126"></a> tmpb=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Bird</span><span class=cF7>)</span><span class=cF0>);
<a name="l1127"></a> tmpb-&gt;p.x=</span><span class=cF5>Rand</span><span class=cF0>*MAP_WIDTH*MAP_SCALE;
<a name="l1128"></a> tmpb-&gt;p.y=</span><span class=cF5>Rand</span><span class=cF0>*MAP_HEIGHT*MAP_SCALE;
<a name="l1129"></a> tmpb-&gt;p.z=BIRD_ELEVATION*MAP_SCALE+
<a name="l1130"></a> elevations[tmpb-&gt;p.y/MAP_SCALE][tmpb-&gt;p.x/MAP_SCALE];
<a name="l1131"></a> tmpb-&gt;theta=2*</span><span class=cF3>pi</span><span class=cF0>*</span><span class=cF5>Rand</span><span class=cF0>;
<a name="l1132"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,b_head[i%</span><span class=cFB>mp_cnt</span><span class=cF0>].last);
<a name="l1133"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1134"></a>
<a name="l1135"></a> </span><span class=cF1>for</span><span class=cF0> (i=1;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++)
<a name="l1136"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;CoreAPTalonsTask,</span><span class=cF5>Fs</span><span class=cF0>,</span><span class=cF6>&quot;AP Talons&quot;</span><span class=cF0>,i);
<a name="l1137"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_end_cb=&amp;TaskEndCB;
<a name="l1138"></a> game_t0=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l1139"></a>}
<a name="l1140"></a>
<a name="l1141"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l1142"></a>{
<a name="l1143"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l1144"></a> Panel *tmpp=panel_head,*tmpp1;
<a name="l1145"></a> MPEnd;
<a name="l1146"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp) </span><span class=cF7>{</span><span class=cF0>
<a name="l1147"></a> tmpp1=tmpp-&gt;next;
<a name="l1148"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&amp;tmpp-&gt;next_obj);
<a name="l1149"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpp-&gt;pts);
<a name="l1150"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpp);
<a name="l1151"></a> tmpp=tmpp1;
<a name="l1152"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1153"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cFB>mp_cnt</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l1154"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&amp;b_head[i]);
<a name="l1155"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;b_head[i]);
<a name="l1156"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1157"></a> </span><span class=cF5>DCDel</span><span class=cF0>(main_dc);
<a name="l1158"></a>}
<a name="l1159"></a>
<a name="l1160"></a></span><span class=cF1>U0</span><span class=cF0> Talons()
<a name="l1161"></a>{
<a name="l1162"></a> </span><span class=cF9>I64</span><span class=cF0> ch,sc;
<a name="l1163"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l1164"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l1165"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l1166"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l1167"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l1168"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l1169"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l1170"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l1171"></a> </span><span class=cF6>&quot; Down(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l1172"></a> </span><span class=cF6>&quot; Up(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l1173"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l1174"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l1175"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l1176"></a> );
<a name="l1177"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l1178"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l1179"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l1180"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l1181"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l1182"></a> </span><span class=cF6>&quot;Initializing...\n&quot;</span><span class=cF0>;
<a name="l1183"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;song_task=</span><span class=cF5>Spawn</span><span class=cF0>(&amp;SongTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>&quot;Song&quot;</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
<a name="l1184"></a> PreInit;
<a name="l1185"></a> Init;
<a name="l1186"></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="l1187"></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="l1188"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF2>//in case &lt;CTRL-ALT-c&gt; is pressed.</span><span class=cF0>
<a name="l1189"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l1190"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ScanKey</span><span class=cF7>(</span><span class=cF0>&amp;ch,&amp;sc</span><span class=cF7>)</span><span class=cF0>) {
<a name="l1191"></a> </span><span class=cF1>switch</span><span class=cF0> (ch) </span><span class=cF7>{</span><span class=cF0>
<a name="l1192"></a> </span><span class=cF1>case</span><span class=cF0> 0:
<a name="l1193"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) {
<a name="l1194"></a> </span><span class=cF1>start</span><span class=cF0>:
<a name="l1195"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l1196"></a> phi-=CTRLS_SCALE*</span><span class=cF5>Cos</span><span class=cF0>(roll);
<a name="l1197"></a> heading-=CTRLS_SCALE*</span><span class=cF5>Sin</span><span class=cF0>(roll)*</span><span class=cF5>Sin</span><span class=cF0>(phi);
<a name="l1198"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1199"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l1200"></a> phi+=CTRLS_SCALE*</span><span class=cF5>Cos</span><span class=cF0>(roll);
<a name="l1201"></a> heading+=CTRLS_SCALE*</span><span class=cF5>Sin</span><span class=cF0>(roll)*</span><span class=cF5>Sin</span><span class=cF0>(phi);
<a name="l1202"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1203"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l1204"></a> roll+=CTRLS_SCALE;
<a name="l1205"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1206"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l1207"></a> roll-=CTRLS_SCALE;
<a name="l1208"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1209"></a> </span><span class=cF1>end</span><span class=cF0>:
<a name="l1210"></a> WrapAngles;
<a name="l1211"></a> }
<a name="l1212"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1213"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l1214"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l1215"></a> CleanUp;
<a name="l1216"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l1217"></a> Init;
<a name="l1218"></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="l1219"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l1220"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l1221"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l1222"></a> Core0Talons;
<a name="l1223"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (ch!=</span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0> &amp;&amp; ch!=</span><span class=cF3>CH_ESC</span><span class=cF0>);
<a name="l1224"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l1225"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l1226"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l1227"></a> CleanUp;
<a name="l1228"></a> PostCleanUp;
<a name="l1229"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l1230"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/Talons&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="l1231"></a>}
<a name="l1232"></a>
<a name="l1233"></a>Talons;
</span></pre></body>
</html>