templeos-info/public/Wb/Apps/Span/SpanMain.HC.HTML

500 lines
40 KiB
HTML
Executable File

<!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=cF1>F64</span><span class=cF0> SpanTime()
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF1>if</span><span class=cF0> (run_bttn.state)
<a name="l4"></a> </span><span class=cF1>return</span><span class=cF0> a.elapsed_t+</span><span class=cF5>tS</span><span class=cF0>-a.start_wall_t;
<a name="l5"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l6"></a> </span><span class=cF1>return</span><span class=cF0> a.elapsed_t;
<a name="l7"></a>}
<a name="l8"></a>
<a name="l9"></a></span><span class=cF1>F64</span><span class=cF0> Cost(</span><span class=cF9>CMathODE</span><span class=cF0> *ode)
<a name="l10"></a>{
<a name="l11"></a> MyMass *tmpm;
<a name="l12"></a> MySpring *tmps;
<a name="l13"></a> </span><span class=cF1>F64</span><span class=cF0> res=0;
<a name="l14"></a> tmpm=ode-&gt;next_mass;
<a name="l15"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm!=&amp;ode-&gt;next_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l16"></a> res+=tmpm-&gt;cost;
<a name="l17"></a> tmpm=tmpm-&gt;next;
<a name="l18"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l19"></a> tmps=ode-&gt;next_spring;
<a name="l20"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&amp;ode-&gt;next_spring) </span><span class=cF7>{</span><span class=cF0>
<a name="l21"></a> res+=tmps-&gt;cost;
<a name="l22"></a> tmps=tmps-&gt;next;
<a name="l23"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l24"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l25"></a>}
<a name="l26"></a>
<a name="l27"></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="l28"></a>{
<a name="l29"></a> MyMass *tmpm;
<a name="l30"></a> MySpring *tmps;
<a name="l31"></a>
<a name="l32"></a> tmps=ode-&gt;next_spring;
<a name="l33"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&amp;ode-&gt;next_spring) </span><span class=cF7>{</span><span class=cF0>
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmps-&gt;flags&amp;</span><span class=cF3>SSF_INACTIVE</span><span class=cF7>)</span><span class=cF0>) {
<a name="l35"></a> dc-&gt;color=tmps-&gt;color;
<a name="l36"></a> dc-&gt;thick=tmps-&gt;thick;
<a name="l37"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,tmps-&gt;end1-&gt;x,tmps-&gt;end1-&gt;y,0,
<a name="l38"></a> tmps-&gt;end2-&gt;x,tmps-&gt;end2-&gt;y,0);
<a name="l39"></a> }
<a name="l40"></a> tmps=tmps-&gt;next;
<a name="l41"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l42"></a>
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (cursor_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l44"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l45"></a> dc-&gt;thick=2;
<a name="l46"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,</span><span class=cFB>ms</span><span class=cF0>.pos.x-task-&gt;pix_left-task-&gt;scroll_x,
<a name="l47"></a> </span><span class=cFB>ms</span><span class=cF0>.pos.y-task-&gt;pix_top-task-&gt;scroll_y,0,
<a name="l48"></a> cursor_mass-&gt;x,cursor_mass-&gt;y,0);
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l50"></a>
<a name="l51"></a> tmpm=ode-&gt;next_mass;
<a name="l52"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm!=&amp;ode-&gt;next_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpm-&gt;flags&amp;</span><span class=cF3>MSF_INACTIVE</span><span class=cF7>)</span><span class=cF0>) {
<a name="l54"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l55"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,tmpm-&gt;radius);
<a name="l56"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l57"></a> dc-&gt;color=tmpm-&gt;color;
<a name="l58"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,tmpm-&gt;radius);
<a name="l59"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l60"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l61"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,tmpm-&gt;radius);
<a name="l62"></a> }
<a name="l63"></a> tmpm=tmpm-&gt;next;
<a name="l64"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l65"></a>
<a name="l66"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l67"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,90,0,</span><span class=cF6>&quot;Cost:%12.2,f&quot;</span><span class=cF0>,Cost</span><span class=cF7>(</span><span class=cF0>ode</span><span class=cF7>)</span><span class=cF0>);
<a name="l68"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,90,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,</span><span class=cF6>&quot;Time:%12.2f&quot;</span><span class=cF0>,SpanTime);
<a name="l69"></a>}
<a name="l70"></a>
<a name="l71"></a>MyMass *PlaceMass(</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
<a name="l72"></a>{
<a name="l73"></a> MyMass *tmpm=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MyMass</span><span class=cF7>)</span><span class=cF0>);
<a name="l74"></a> tmpm-&gt;drag_profile_factor=1.0;
<a name="l75"></a> tmpm-&gt;x=x;
<a name="l76"></a> tmpm-&gt;y=y;
<a name="l77"></a> tmpm-&gt;mass=MASS_MASS;
<a name="l78"></a> tmpm-&gt;radius=MASS_RADIUS;
<a name="l79"></a> tmpm-&gt;cost=25.0*COST_SCALE;
<a name="l80"></a> tmpm-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpm,ode-&gt;last_mass);
<a name="l82"></a> </span><span class=cF1>return</span><span class=cF0> tmpm;
<a name="l83"></a>}
<a name="l84"></a>
<a name="l85"></a></span><span class=cF1>U0</span><span class=cF0> NullSpring(MySpring *tmps,</span><span class=cF1>F64</span><span class=cF0> scale)
<a name="l86"></a>{
<a name="l87"></a> </span><span class=cF1>F64</span><span class=cF0> d=</span><span class=cF5>D3Dist</span><span class=cF0>(&amp;tmps-&gt;end1-&gt;x,&amp;tmps-&gt;end2-&gt;x);
<a name="l88"></a> tmps-&gt;rest_len=d*scale;
<a name="l89"></a> tmps-&gt;compression_strength=
<a name="l90"></a> tmps-&gt;base_compression_strength/(tmps-&gt;rest_len+1.0);
<a name="l91"></a> tmps-&gt;tensile_strength=tmps-&gt;base_tensile_strength/(tmps-&gt;rest_len+1.0);
<a name="l92"></a> tmps-&gt;const=tmps-&gt;base_const/(tmps-&gt;rest_len+1.0);
<a name="l93"></a> tmps-&gt;cost=tmps-&gt;base_cost*tmps-&gt;rest_len;
<a name="l94"></a>}
<a name="l95"></a>
<a name="l96"></a></span><span class=cF1>U0</span><span class=cF0> MoveMass(MyMass *tmpm,</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
<a name="l97"></a>{
<a name="l98"></a> MySpring *tmps;
<a name="l99"></a> tmpm-&gt;x=x;
<a name="l100"></a> tmpm-&gt;y=y;
<a name="l101"></a> tmpm-&gt;DxDt=0;
<a name="l102"></a> tmpm-&gt;DyDt=0;
<a name="l103"></a> tmps=ode-&gt;next_spring;
<a name="l104"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&amp;ode-&gt;next_spring) </span><span class=cF7>{</span><span class=cF0>
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;end1==tmpm || tmps-&gt;end2==tmpm) {
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;flags&amp;</span><span class=cF3>SSF_NO_COMPRESSION</span><span class=cF0>)
<a name="l107"></a> NullSpring(tmps,WIRE_PERCENT);
<a name="l108"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l109"></a> NullSpring(tmps,1.0);
<a name="l110"></a> }
<a name="l111"></a> tmps=tmps-&gt;next;
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l113"></a>}
<a name="l114"></a>
<a name="l115"></a></span><span class=cF1>U0</span><span class=cF0> DelSpring(MySpring *tmps)
<a name="l116"></a>{
<a name="l117"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmps);
<a name="l118"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l119"></a>}
<a name="l120"></a>
<a name="l121"></a></span><span class=cF1>U0</span><span class=cF0> DelMass(MyMass *tmpm)
<a name="l122"></a>{
<a name="l123"></a> MySpring *tmps,*tmps1;
<a name="l124"></a> tmps=ode-&gt;next_spring;
<a name="l125"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&amp;ode-&gt;next_spring) </span><span class=cF7>{</span><span class=cF0>
<a name="l126"></a> tmps1=tmps-&gt;next;
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;end1==tmpm || tmps-&gt;end2==tmpm)
<a name="l128"></a> DelSpring(tmps);
<a name="l129"></a> tmps=tmps1;
<a name="l130"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l131"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpm);
<a name="l132"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpm);
<a name="l133"></a>}
<a name="l134"></a>
<a name="l135"></a></span><span class=cF1>U0</span><span class=cF0> DrawSpring(</span><span class=cF9>CDC</span><span class=cF0> *dc,MyMass *tmpm,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y)
<a name="l136"></a>{
<a name="l137"></a> </span><span class=cF1>switch</span><span class=cF0> (mode_bttn.state) </span><span class=cF7>{</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>case</span><span class=cF0> MD_CONCRETE:
<a name="l139"></a> dc-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l140"></a> dc-&gt;thick=2;
<a name="l141"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l142"></a> </span><span class=cF1>case</span><span class=cF0> MD_STEEL:
<a name="l143"></a> dc-&gt;color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l144"></a> dc-&gt;thick=2;
<a name="l145"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l146"></a> </span><span class=cF1>case</span><span class=cF0> MD_WIRE:
<a name="l147"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l148"></a> dc-&gt;thick=1;
<a name="l149"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l150"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l151"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,0,x,y,0);
<a name="l152"></a>}
<a name="l153"></a>
<a name="l154"></a></span><span class=cF1>U0</span><span class=cF0> PlaceSpring(MyMass *tmpm1,MyMass *tmpm2)
<a name="l155"></a>{
<a name="l156"></a> MySpring *tmps=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MySpring</span><span class=cF7>)</span><span class=cF0>);
<a name="l157"></a> tmps-&gt;end1=tmpm1;
<a name="l158"></a> tmps-&gt;end2=tmpm2;
<a name="l159"></a> </span><span class=cF1>switch</span><span class=cF0> (mode_bttn.state) </span><span class=cF7>{</span><span class=cF0>
<a name="l160"></a> </span><span class=cF1>case</span><span class=cF0> MD_CONCRETE:
<a name="l161"></a> tmps-&gt;base_const = 3.00*SPRING_SCALE;
<a name="l162"></a> tmps-&gt;base_compression_strength=10.00*STRENGTH_SCALE;
<a name="l163"></a> tmps-&gt;base_tensile_strength = 0.35*STRENGTH_SCALE;
<a name="l164"></a> tmps-&gt;base_cost = 0.30*COST_SCALE;
<a name="l165"></a> NullSpring(tmps,1.0);
<a name="l166"></a> tmps-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l167"></a> tmps-&gt;thick=2;
<a name="l168"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l169"></a> </span><span class=cF1>case</span><span class=cF0> MD_STEEL:
<a name="l170"></a> tmps-&gt;base_const = 1.00*SPRING_SCALE;
<a name="l171"></a> tmps-&gt;base_compression_strength= 1.00*STRENGTH_SCALE;
<a name="l172"></a> tmps-&gt;base_tensile_strength = 1.00*STRENGTH_SCALE;
<a name="l173"></a> tmps-&gt;base_cost = 1.00*COST_SCALE;
<a name="l174"></a> NullSpring(tmps,1.0);
<a name="l175"></a> tmps-&gt;color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l176"></a> tmps-&gt;thick=2;
<a name="l177"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l178"></a> </span><span class=cF1>case</span><span class=cF0> MD_WIRE:
<a name="l179"></a> tmps-&gt;base_const = 0.25*SPRING_SCALE;
<a name="l180"></a> tmps-&gt;base_compression_strength= 0.00;
<a name="l181"></a> tmps-&gt;base_tensile_strength = 0.50*STRENGTH_SCALE;
<a name="l182"></a> tmps-&gt;base_cost = 0.10*COST_SCALE;
<a name="l183"></a> NullSpring(tmps,WIRE_PERCENT);
<a name="l184"></a> tmps-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l185"></a> tmps-&gt;thick=1;
<a name="l186"></a> tmps-&gt;flags|=</span><span class=cF3>SSF_NO_COMPRESSION</span><span class=cF0>;
<a name="l187"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l188"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l189"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,ode-&gt;last_spring);
<a name="l190"></a>}
<a name="l191"></a>
<a name="l192"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(SpanAnimateStruct *a)
<a name="l193"></a>{
<a name="l194"></a> MySpring *tmps,*tmps1;
<a name="l195"></a> </span><span class=cF1>Bool</span><span class=cF0> old_run=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l196"></a> </span><span class=cF1>F64</span><span class=cF0> f;
<a name="l197"></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="l198"></a> tmps=ode-&gt;next_spring;
<a name="l199"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&amp;ode-&gt;next_spring) {
<a name="l200"></a> tmps1=tmps-&gt;next;
<a name="l201"></a> f=tmps-&gt;f;
<a name="l202"></a> </span><span class=cF1>if</span><span class=cF0> (f&gt;0 &amp;&amp; f&gt;tmps-&gt;compression_strength &amp;&amp;
<a name="l203"></a> !</span><span class=cF7>(</span><span class=cF0>tmps-&gt;flags&amp;</span><span class=cF3>SSF_NO_COMPRESSION</span><span class=cF7>)</span><span class=cF0>||
<a name="l204"></a> f&lt;0 &amp;&amp; -f&gt;tmps-&gt;tensile_strength &amp;&amp;
<a name="l205"></a> !</span><span class=cF7>(</span><span class=cF0>tmps-&gt;flags&amp;</span><span class=cF3>SSF_NO_TENSION</span><span class=cF7>)</span><span class=cF0>)
<a name="l206"></a> tmps-&gt;flags|=</span><span class=cF3>SSF_INACTIVE</span><span class=cF0>;
<a name="l207"></a> tmps=tmps1;
<a name="l208"></a> }
<a name="l209"></a> AdjustLoads(ode);
<a name="l210"></a> </span><span class=cF5>Refresh</span><span class=cF0>; </span><span class=cF2>//CMathODE updated once per refresh.</span><span class=cF0>
<a name="l211"></a> </span><span class=cF1>if</span><span class=cF0> (old_run!=run_bttn.state) {
<a name="l212"></a> </span><span class=cF1>if</span><span class=cF0> (run_bttn.state) </span><span class=cF7>{</span><span class=cF0>
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (!a-&gt;elapsed_t || !a-&gt;saved_ode) {
<a name="l214"></a> </span><span class=cF5>Free</span><span class=cF0>(a-&gt;saved_ode);
<a name="l215"></a> a-&gt;saved_ode=SpanSave(ode);
<a name="l216"></a> }
<a name="l217"></a> a-&gt;start_wall_t=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l218"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode,</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l219"></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="l220"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode);
<a name="l221"></a> a-&gt;elapsed_t+=</span><span class=cF5>tS</span><span class=cF0>-a-&gt;start_wall_t;
<a name="l222"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l223"></a> old_run=run_bttn.state;
<a name="l224"></a> }
<a name="l225"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l226"></a>}
<a name="l227"></a>
<a name="l228"></a></span><span class=cF1>U0</span><span class=cF0> Init(SpanAnimateStruct *a)
<a name="l229"></a>{
<a name="l230"></a> SpanDel(ode);
<a name="l231"></a> ode=SpanNew;
<a name="l232"></a>
<a name="l233"></a> run_bttn.state=0;
<a name="l234"></a> </span><span class=cF5>Refresh</span><span class=cF0>(2); </span><span class=cF2>//Allow stop to reg in animate task.</span><span class=cF0>
<a name="l235"></a>
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (a-&gt;saved_ode)
<a name="l237"></a> SpanLoad(ode,a-&gt;saved_ode);
<a name="l238"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l239"></a> SpanBridge1Init(ode);
<a name="l240"></a> a-&gt;elapsed_t=0;
<a name="l241"></a> cursor_mass=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l242"></a>}
<a name="l243"></a>
<a name="l244"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l245"></a>{</span><span class=cF2>//Song by Terry A. Davis</span><span class=cF0>
<a name="l246"></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="l247"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
<a name="l248"></a> </span><span class=cFB>music</span><span class=cF0>.tempo= 3.636;
<a name="l249"></a> </span><span class=cFB>music</span><span class=cF0>.stacatto_factor= 0.902;
<a name="l250"></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="l251"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5q.EeDqED4G5DhE&quot;</span><span class=cF0>);
<a name="l252"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5q.EeDqED4G5DhE&quot;</span><span class=cF0>);
<a name="l253"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5q.FeEFEqF4G5EhF&quot;</span><span class=cF0>);
<a name="l254"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5q.FeEFEqF4G5EhF&quot;</span><span class=cF0>);
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l256"></a>}
<a name="l257"></a>
<a name="l258"></a></span><span class=cF1>U0</span><span class=cF0> Span()
<a name="l259"></a>{
<a name="l260"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,arg1,arg2;
<a name="l261"></a> MyMass *tmpm1=</span><span class=cF3>NULL</span><span class=cF0>,*tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l262"></a> MySpring *tmps;
<a name="l263"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *bt_run,*bt_mode;
<a name="l264"></a> </span><span class=cF1>U8</span><span class=cF0> *src;
<a name="l265"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCAlias</span><span class=cF0>;
<a name="l266"></a>
<a name="l267"></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="l268"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr=</span><span class=cF3>BROWN</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l269"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l270"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l271"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l272"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l273"></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="l274"></a>
<a name="l275"></a> bt_run =</span><span class=cF5>CtrlBttnNew</span><span class=cF0>(0,0, 80,,
<a name="l276"></a> 2,</span><span class=cF6>&quot;Stopped\0Running\0&quot;</span><span class=cF0>,run_colors,&amp;run_bttn);
<a name="l277"></a> bt_mode=</span><span class=cF5>CtrlBttnNew</span><span class=cF0>(0,3.0*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,80,,
<a name="l278"></a> MD_MODES_NUM,</span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_SPAN_MODES&quot;</span><span class=cF7>)</span><span class=cF0>,mode_colors,&amp;mode_bttn);
<a name="l279"></a> a.saved_ode=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l280"></a>
<a name="l281"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit|=</span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
<a name="l282"></a>
<a name="l283"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l284"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l285"></a> </span><span class=cF6>&quot; New(,CH_CTRLN);&quot;</span><span class=cF0>
<a name="l286"></a> </span><span class=cF6>&quot; Open(,CH_CTRLO);&quot;</span><span class=cF0>
<a name="l287"></a> </span><span class=cF6>&quot; SaveAs(,CH_CTRLA);&quot;</span><span class=cF0>
<a name="l288"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l289"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l290"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l291"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l292"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l293"></a> </span><span class=cF6>&quot; RunStop(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l294"></a> </span><span class=cF6>&quot; Mass(,'m');&quot;</span><span class=cF0>
<a name="l295"></a> </span><span class=cF6>&quot; Concrete(,'c');&quot;</span><span class=cF0>
<a name="l296"></a> </span><span class=cF6>&quot; Steel(,'s');&quot;</span><span class=cF0>
<a name="l297"></a> </span><span class=cF6>&quot; Wire(,'w');&quot;</span><span class=cF0>
<a name="l298"></a> </span><span class=cF6>&quot; Move(,'v');&quot;</span><span class=cF0>
<a name="l299"></a> </span><span class=cF6>&quot; Delete(,'d');&quot;</span><span class=cF0>
<a name="l300"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l301"></a> );
<a name="l302"></a>
<a name="l303"></a> ode=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l304"></a> Init(&amp;a);
<a name="l305"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task=</span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask,&amp;a,</span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
<a name="l306"></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="l307"></a>
<a name="l308"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(
<a name="l309"></a> </span><span class=cF6>&quot;Build a bridge to hold-up the\n&quot;</span><span class=cF0>
<a name="l310"></a> </span><span class=cF6>&quot;red masses. Test your design\n&quot;</span><span class=cF0>
<a name="l311"></a> </span><span class=cF6>&quot;by pressing run/stop.\n\n&quot;</span><span class=cF0>
<a name="l312"></a> </span><span class=cF6>&quot;The lowest cost bridge that\n&quot;</span><span class=cF0>
<a name="l313"></a> </span><span class=cF6>&quot;stays standing wins.\n\n&quot;</span><span class=cF0>
<a name="l314"></a> </span><span class=cF6>&quot;For a variation, try without\n&quot;</span><span class=cF0>
<a name="l315"></a> </span><span class=cF6>&quot;using the center base point.\n&quot;</span><span class=cF0>
<a name="l316"></a> </span><span class=cF6>&quot;\n&quot;</span><span class=cF0>
<a name="l317"></a> </span><span class=cF6>&quot;Use\n&quot;</span><span class=cF0>
<a name="l318"></a> </span><span class=cF6>&quot;\t$GREEN$'m'$FG$ass\n&quot;</span><span class=cF0>
<a name="l319"></a> </span><span class=cF6>&quot;\t$GREEN$'c'$FG$oncrete\n&quot;</span><span class=cF0>
<a name="l320"></a> </span><span class=cF6>&quot;\t$GREEN$'s'$FG$teel\n&quot;</span><span class=cF0>
<a name="l321"></a> </span><span class=cF6>&quot;\t$GREEN$'w'$FG$ire\n&quot;</span><span class=cF0>
<a name="l322"></a> </span><span class=cF6>&quot;\nto sel materials.\n&quot;</span><span class=cF0>);
<a name="l323"></a>
<a name="l324"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l325"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l326"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>|
<a name="l327"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>);
<a name="l328"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l329"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) </span><span class=cF7>{</span><span class=cF0>
<a name="l330"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l331"></a> cursor_mass=tmpm1=tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l332"></a> </span><span class=cF1>switch</span><span class=cF0> (mode_bttn.state) {
<a name="l333"></a> </span><span class=cF1>case</span><span class=cF0> MD_MASS:
<a name="l334"></a> PlaceMass(arg1,arg2);
<a name="l335"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l336"></a> </span><span class=cF1>case</span><span class=cF0> MD_CONCRETE:
<a name="l337"></a> </span><span class=cF1>case</span><span class=cF0> MD_STEEL:
<a name="l338"></a> </span><span class=cF1>case</span><span class=cF0> MD_WIRE:
<a name="l339"></a> tmpm1=</span><span class=cF5>MassFind</span><span class=cF0>(ode,arg1,arg2);
<a name="l340"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l341"></a> </span><span class=cF1>case</span><span class=cF0> MD_MOVE:
<a name="l342"></a> </span><span class=cF1>if</span><span class=cF0> (run_bttn.state)
<a name="l343"></a> cursor_mass=</span><span class=cF5>MassFind</span><span class=cF0>(ode,arg1,arg2);
<a name="l344"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l345"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1=</span><span class=cF5>MassFind</span><span class=cF7>(</span><span class=cF0>ode,arg1,arg2</span><span class=cF7>)</span><span class=cF0>)
<a name="l346"></a> MoveMass(tmpm1,arg1,arg2);
<a name="l347"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l348"></a> </span><span class=cF1>case</span><span class=cF0> MD_DELETE:
<a name="l349"></a> </span><span class=cF5>MassOrSpringFind</span><span class=cF0>(ode,&amp;tmpm1,&amp;tmps,arg1,arg2);
<a name="l350"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1)
<a name="l351"></a> DelMass(tmpm1);
<a name="l352"></a> </span><span class=cF1>if</span><span class=cF0> (tmps)
<a name="l353"></a> DelSpring(tmps);
<a name="l354"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l355"></a> }
<a name="l356"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l357"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
<a name="l358"></a> </span><span class=cF1>switch</span><span class=cF0> (mode_bttn.state) {
<a name="l359"></a> </span><span class=cF1>case</span><span class=cF0> MD_CONCRETE:
<a name="l360"></a> </span><span class=cF1>case</span><span class=cF0> MD_STEEL:
<a name="l361"></a> </span><span class=cF1>case</span><span class=cF0> MD_WIRE:
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1 &amp;&amp; </span><span class=cF7>(</span><span class=cF0>tmpm2=</span><span class=cF5>MassFind</span><span class=cF0>(ode,arg1,arg2)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; tmpm1!=tmpm2)
<a name="l363"></a> PlaceSpring(tmpm1,tmpm2);
<a name="l364"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l365"></a> </span><span class=cF1>case</span><span class=cF0> MD_MOVE:
<a name="l366"></a> </span><span class=cF1>if</span><span class=cF0> (!run_bttn.state &amp;&amp; tmpm1)
<a name="l367"></a> MoveMass(tmpm1,arg1,arg2);
<a name="l368"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l369"></a> }
<a name="l370"></a> cursor_mass=tmpm1=tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l371"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l372"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>:
<a name="l373"></a> </span><span class=cF1>switch</span><span class=cF0> (mode_bttn.state) {
<a name="l374"></a> </span><span class=cF1>case</span><span class=cF0> MD_MOVE:
<a name="l375"></a> </span><span class=cF1>if</span><span class=cF0> (!run_bttn.state &amp;&amp; tmpm1)
<a name="l376"></a> MoveMass(tmpm1,arg1,arg2);
<a name="l377"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l378"></a> </span><span class=cF1>case</span><span class=cF0> MD_CONCRETE:
<a name="l379"></a> </span><span class=cF1>case</span><span class=cF0> MD_STEEL:
<a name="l380"></a> </span><span class=cF1>case</span><span class=cF0> MD_WIRE:
<a name="l381"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1) </span><span class=cF7>{</span><span class=cF0>
<a name="l382"></a> DrawSpring(dc,tmpm1,arg1,arg2);
<a name="l383"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l384"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l385"></a> }
<a name="l386"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l387"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>:
<a name="l388"></a> mode_bttn.state++;
<a name="l389"></a> </span><span class=cF1>if</span><span class=cF0> (mode_bttn.state&gt;=MD_MODES_NUM)
<a name="l390"></a> mode_bttn.state=0;
<a name="l391"></a> cursor_mass=tmpm1=tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l392"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l393"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l394"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l395"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l396"></a> </span><span class=cF1>if</span><span class=cF0> (!SpanTime || !a.saved_ode) </span><span class=cF7>{</span><span class=cF0>
<a name="l397"></a> </span><span class=cF5>Free</span><span class=cF0>(a.saved_ode);
<a name="l398"></a> a.saved_ode=SpanSave(ode);
<a name="l399"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l400"></a> Init(&amp;a);
<a name="l401"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l402"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLN</span><span class=cF0>:
<a name="l403"></a> </span><span class=cF5>Free</span><span class=cF0>(a.saved_ode);
<a name="l404"></a> a.saved_ode=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l405"></a> Init(&amp;a);
<a name="l406"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l407"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLO</span><span class=cF0>:
<a name="l408"></a> </span><span class=cF1>if</span><span class=cF0> (src=SpanRead) </span><span class=cF7>{</span><span class=cF0>
<a name="l409"></a> </span><span class=cF5>Free</span><span class=cF0>(a.saved_ode);
<a name="l410"></a> a.saved_ode=src;
<a name="l411"></a> Init(&amp;a);
<a name="l412"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l413"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l414"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLA</span><span class=cF0>:
<a name="l415"></a> </span><span class=cF1>if</span><span class=cF0> (!SpanTime || !a.saved_ode) </span><span class=cF7>{</span><span class=cF0>
<a name="l416"></a> </span><span class=cF5>Free</span><span class=cF0>(a.saved_ode);
<a name="l417"></a> a.saved_ode=SpanSave(ode);
<a name="l418"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l419"></a> Init(&amp;a);
<a name="l420"></a> SpanWrite(ode);
<a name="l421"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l422"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l423"></a> run_bttn.state=!run_bttn.state;
<a name="l424"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l425"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
<a name="l426"></a> mode_bttn.state=MD_CONCRETE;
<a name="l427"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l428"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'s'</span><span class=cF0>:
<a name="l429"></a> mode_bttn.state=MD_STEEL;
<a name="l430"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l431"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'w'</span><span class=cF0>:
<a name="l432"></a> mode_bttn.state=MD_WIRE;
<a name="l433"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l434"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'m'</span><span class=cF0>:
<a name="l435"></a> mode_bttn.state=MD_MASS;
<a name="l436"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l437"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'v'</span><span class=cF0>:
<a name="l438"></a> mode_bttn.state=MD_MOVE;
<a name="l439"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l440"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l441"></a> mode_bttn.state=MD_DELETE;
<a name="l442"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l443"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l444"></a> </span><span class=cF1>if</span><span class=cF0> (!SpanTime || !a.saved_ode) </span><span class=cF7>{</span><span class=cF0>
<a name="l445"></a> </span><span class=cF5>Free</span><span class=cF0>(a.saved_ode);
<a name="l446"></a> a.saved_ode=SpanSave(ode);
<a name="l447"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l448"></a> Init(&amp;a);
<a name="l449"></a> SpanWrite(ode);
<a name="l450"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l451"></a> </span><span class=cF1>goto</span><span class=cF0> span_done;
<a name="l452"></a> }
<a name="l453"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l454"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l455"></a> }
<a name="l456"></a>span_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
<a name="l457"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(,,1&lt;&lt;</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
<a name="l458"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l459"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l460"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l461"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l462"></a> </span><span class=cF5>CtrlBttnDel</span><span class=cF0>(bt_run);
<a name="l463"></a> </span><span class=cF5>CtrlBttnDel</span><span class=cF0>(bt_mode);
<a name="l464"></a> SpanDel(ode);
<a name="l465"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l466"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l467"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l468"></a>}
</span></pre></body>
</html>