templeos-info/public/Wb/Home/Src/Apps/Strut/Strut.HC.HTML

668 lines
60 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">
.c00{color:#000000;background-color:#000000;}
.c0A{color:#55ff55;background-color:#000000;}
.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=c0A>
<a name="l2"></a>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=c00>
<a name="l3"></a></span><span class=c0A>
<a name="l4"></a>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=c00>
<a name="l5"></a>
<a name="l6"></a></span><span class=c0A>
<a name="l7"></a>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=c00>
<a name="l8"></a>
<a name="l9"></a></span><span class=cF0>
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> STARS_NUM 8192
<a name="l11"></a></span><span class=cF9>I64</span><span class=cF0> stars_x[STARS_NUM],stars_y[STARS_NUM];
<a name="l12"></a>
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> RADIUS 7
<a name="l14"></a>
<a name="l15"></a></span><span class=cF1>class</span><span class=cF0> MyMass:</span><span class=cF9>CMass</span><span class=cF0>
<a name="l16"></a>{
<a name="l17"></a> </span><span class=cF1>U8</span><span class=cF0> *img;
<a name="l18"></a>};
<a name="l19"></a>
<a name="l20"></a></span><span class=cF1>class</span><span class=cF0> MySpring:</span><span class=cF9>CSpring</span><span class=cF0>
<a name="l21"></a>{
<a name="l22"></a> </span><span class=cF9>I64</span><span class=cF0> type,action_key;
<a name="l23"></a>};
<a name="l24"></a>
<a name="l25"></a></span><span class=cF2>//Main Modses</span><span class=cF0>
<a name="l26"></a>#</span><span class=cF1>define</span><span class=cF0> MMD_EDIT 0
<a name="l27"></a>#</span><span class=cF1>define</span><span class=cF0> MMD_PLAY 1
<a name="l28"></a>#</span><span class=cF1>define</span><span class=cF0> MMD_MODES_NUM 2
<a name="l29"></a></span><span class=cF9>CColorROPU32</span><span class=cF0> main_mode_colors[MMD_MODES_NUM]={</span><span class=cF3>LTRED</span><span class=cF0>,</span><span class=cF3>LTGREEN</span><span class=cF0>};
<a name="l30"></a></span><span class=cF5>DefineLstLoad</span><span class=cF0>(</span><span class=cF6>&quot;ST_MAIN_MODES&quot;</span><span class=cF0>,</span><span class=cF6>&quot;Edit\0Play\0&quot;</span><span class=cF0>);
<a name="l31"></a></span><span class=cF9>CCtrlBttnState</span><span class=cF0> main_mode_bttn;
<a name="l32"></a>
<a name="l33"></a></span><span class=cF2>//Edit Modes</span><span class=cF0>
<a name="l34"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_MASS 0
<a name="l35"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_SPRING 1
<a name="l36"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_CONNECTOR 2
<a name="l37"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_THRUSTER 3
<a name="l38"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_MOVE 4
<a name="l39"></a>#</span><span class=cF1>define</span><span class=cF0> EMD_MODES_NUM 5
<a name="l40"></a></span><span class=cF9>CColorROPU32</span><span class=cF0> edit_mode_colors[EMD_MODES_NUM]={</span><span class=cF3>LTGRAY</span><span class=cF0>,</span><span class=cF3>LTCYAN</span><span class=cF0>,</span><span class=cF3>CYAN</span><span class=cF0>,</span><span class=cF3>YELLOW</span><span class=cF0>,</span><span class=cF3>LTBLUE</span><span class=cF0>};
<a name="l41"></a></span><span class=cF5>DefineLstLoad</span><span class=cF0>(</span><span class=cF6>&quot;ST_EDIT_MODES&quot;</span><span class=cF0>,</span><span class=cF6>&quot;Mass\0Spring\0Connector\0Thruster\0Move\0&quot;</span><span class=cF0>);
<a name="l42"></a></span><span class=cF9>CCtrlBttnState</span><span class=cF0> edit_mode_bttn;
<a name="l43"></a>
<a name="l44"></a></span><span class=cF9>CTask</span><span class=cF0> *task;
<a name="l45"></a></span><span class=cF1>F64</span><span class=cF0> zoom;
<a name="l46"></a></span><span class=cF9>I64</span><span class=cF0> next_action_key,action_scan_codes[10];
<a name="l47"></a></span><span class=cF9>CMathODE</span><span class=cF0> *ode=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l48"></a>
<a name="l49"></a></span><span class=cF1>U0</span><span class=cF0> S2W(</span><span class=cF1>F64</span><span class=cF0> sx,</span><span class=cF1>F64</span><span class=cF0> sy,</span><span class=cF1>F64</span><span class=cF0> *_wx,</span><span class=cF1>F64</span><span class=cF0> *_wy)
<a name="l50"></a>{
<a name="l51"></a> sx-=task-&gt;pix_left+task-&gt;scroll_x;
<a name="l52"></a> sy-=task-&gt;pix_top +task-&gt;scroll_y;
<a name="l53"></a> *_wx=sx/zoom;
<a name="l54"></a> *_wy=sy/zoom;
<a name="l55"></a>}
<a name="l56"></a>
<a name="l57"></a></span><span class=cF1>U0</span><span class=cF0> W2S(</span><span class=cF1>F64</span><span class=cF0> wx,</span><span class=cF1>F64</span><span class=cF0> wy,</span><span class=cF1>F64</span><span class=cF0> *_sx,</span><span class=cF1>F64</span><span class=cF0> *_sy)
<a name="l58"></a>{
<a name="l59"></a> *_sx=wx*zoom; *_sy=wy*zoom;
<a name="l60"></a>}
<a name="l61"></a>
<a name="l62"></a>#</span><span class=cF1>define</span><span class=cF0> ZOOM_STEPS 20
<a name="l63"></a>
<a name="l64"></a></span><span class=cF1>U0</span><span class=cF0> Zoom(</span><span class=cF1>F64</span><span class=cF0> d)
<a name="l65"></a>{
<a name="l66"></a> </span><span class=cF1>F64</span><span class=cF0> sx,sy,wx,wy;
<a name="l67"></a> </span><span class=cF9>I64</span><span class=cF0> i,x=</span><span class=cFB>ms</span><span class=cF0>.pos.x,y=</span><span class=cFB>ms</span><span class=cF0>.pos.y;
<a name="l68"></a> d=</span><span class=cF5>Exp</span><span class=cF0>(</span><span class=cF5>Ln</span><span class=cF7>(</span><span class=cF0>d</span><span class=cF7>)</span><span class=cF0>/ZOOM_STEPS);
<a name="l69"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;ZOOM_STEPS;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l70"></a> S2W(x,y,&amp;wx,&amp;wy);
<a name="l71"></a> zoom=</span><span class=cF5>Clamp</span><span class=cF0>(zoom*d,0.02,50);
<a name="l72"></a> W2S(wx,wy,&amp;sx,&amp;sy);
<a name="l73"></a> task-&gt;scroll_x=</span><span class=cFB>ms</span><span class=cF0>.pos.x-sx-task-&gt;pix_left;
<a name="l74"></a> task-&gt;scroll_y=</span><span class=cFB>ms</span><span class=cF0>.pos.y-sy-task-&gt;pix_top;
<a name="l75"></a> </span><span class=cF5>Sleep</span><span class=cF0>(10);
<a name="l76"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l77"></a>}
<a name="l78"></a>
<a name="l79"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *,</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l80"></a>{
<a name="l81"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l82"></a> </span><span class=cF1>F64</span><span class=cF0> theta,d,x1,y1,x2,y2;
<a name="l83"></a> MyMass *tmpm;
<a name="l84"></a> MySpring *tmps;
<a name="l85"></a>
<a name="l86"></a> tmpm=ode-&gt;next_mass;
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm!=&amp;ode-&gt;next_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l88"></a> task-&gt;scroll_x=-tmpm-&gt;x*zoom+task-&gt;pix_width &gt;&gt;1;
<a name="l89"></a> task-&gt;scroll_y=-tmpm-&gt;y*zoom+task-&gt;pix_height&gt;&gt;1;
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l91"></a>
<a name="l92"></a> dc-&gt;flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l93"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(dc-&gt;r,zoom);
<a name="l94"></a>
<a name="l95"></a> </span><span class=cF1>switch</span><span class=cF0> (main_mode_bttn.state) </span><span class=cF7>{</span><span class=cF0>
<a name="l96"></a> </span><span class=cF1>case</span><span class=cF0> MMD_EDIT:
<a name="l97"></a> task-&gt;text_attr=</span><span class=cF3>DKGRAY</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l98"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l99"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l100"></a> </span><span class=cF1>case</span><span class=cF0> MMD_PLAY:
<a name="l101"></a> task-&gt;text_attr=</span><span class=cF3>BLACK</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l102"></a> dc-&gt;color=</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l103"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;STARS_NUM;i++)
<a name="l104"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,stars_x[i],stars_y[i],0);
<a name="l105"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l106"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l107"></a>
<a name="l108"></a> </span><span class=cF1>if</span><span class=cF0> (main_mode_bttn.state==MMD_EDIT) </span><span class=cF7>{</span><span class=cF0>
<a name="l109"></a> </span><span class=cF1>if</span><span class=cF0> (edit_mode_bttn.state==EMD_CONNECTOR) {
<a name="l110"></a> dc-&gt;color=</span><span class=cF3>CYAN</span><span class=cF0>;
<a name="l111"></a> S2W(</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*11,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>*7,&amp;x1,&amp;y1);
<a name="l112"></a> </span><span class=cF5>GrPutChar3</span><span class=cF0>(dc,x1,y1,0,next_action_key);
<a name="l113"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (edit_mode_bttn.state==EMD_THRUSTER) {
<a name="l114"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l115"></a> S2W(</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*11,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>*7,&amp;x1,&amp;y1);
<a name="l116"></a> </span><span class=cF5>GrPutChar3</span><span class=cF0>(dc,x1,y1,0,next_action_key);
<a name="l117"></a> }
<a name="l118"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l119"></a>
<a name="l120"></a> tmps=ode-&gt;next_spring;
<a name="l121"></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="l122"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;type==EMD_SPRING) {
<a name="l123"></a> dc-&gt;color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l124"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,tmps-&gt;end1-&gt;x,tmps-&gt;end1-&gt;y,0,
<a name="l125"></a> tmps-&gt;end2-&gt;x,tmps-&gt;end2-&gt;y,0);
<a name="l126"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;type==EMD_CONNECTOR) {
<a name="l127"></a> dc-&gt;color=</span><span class=cF3>CYAN</span><span class=cF0>;
<a name="l128"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,tmps-&gt;end1-&gt;x,tmps-&gt;end1-&gt;y,0,
<a name="l129"></a> tmps-&gt;end2-&gt;x,tmps-&gt;end2-&gt;y,0);
<a name="l130"></a> }
<a name="l131"></a> tmps=tmps-&gt;next;
<a name="l132"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l133"></a>
<a name="l134"></a> dc-&gt;color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l135"></a> tmpm=ode-&gt;next_mass;
<a name="l136"></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="l137"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpm-&gt;x,tmpm-&gt;y,0,tmpm-&gt;img);
<a name="l138"></a> tmpm=tmpm-&gt;next;
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l140"></a>
<a name="l141"></a> tmps=ode-&gt;next_spring;
<a name="l142"></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="l143"></a> x1=tmps-&gt;end1-&gt;x; y1=tmps-&gt;end1-&gt;y;
<a name="l144"></a> x2=tmps-&gt;end2-&gt;x; y2=tmps-&gt;end2-&gt;y;
<a name="l145"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;type==EMD_THRUSTER) {
<a name="l146"></a> theta=</span><span class=cF5>Arg</span><span class=cF0>(x2-x1,y2-y1);
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap,action_scan_codes[tmps-&gt;action_key-</span><span class=cF6>'0'</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l148"></a> dc-&gt;flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
<a name="l149"></a> </span><span class=cF5>DCSymmetry3Set</span><span class=cF0>(dc,x1,y1,256,x1,y1,0,x1-256*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,y1-256*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,0);
<a name="l150"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;8;i++) {
<a name="l151"></a> d=20*</span><span class=cF5>Rand</span><span class=cF0>+6;
<a name="l152"></a> </span><span class=cF1>if</span><span class=cF0> (d&lt;10)
<a name="l153"></a> dc-&gt;color=</span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l154"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (d&lt;16)
<a name="l155"></a> dc-&gt;color=</span><span class=cF3>LTBLUE</span><span class=cF0>;
<a name="l156"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l157"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l158"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,x1-3*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,y1-3*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,0,
<a name="l159"></a> x1-d*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>+0.5*d*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,
<a name="l160"></a> y1-d*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>-0.5*d*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,0);
<a name="l161"></a> </span><span class=cF5>GrLine3</span><span class=cF0>(dc,x1-2*d*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,y1-2*d*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,0,
<a name="l162"></a> x1-d*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>+0.5*d*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,
<a name="l163"></a> y1-d*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>-0.5*d*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,0);
<a name="l164"></a> }
<a name="l165"></a> dc-&gt;flags&amp;=~</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
<a name="l166"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l167"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc,x1,y1,0,</span><span class=cFA>&lt;3&gt;</span><span class=cF0>,theta);
<a name="l168"></a> </span><span class=cF1>if</span><span class=cF0> (zoom&gt;0.5) </span><span class=cF7>{</span><span class=cF0>
<a name="l169"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l170"></a> </span><span class=cF5>GrPutChar3</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>x1*7+x2</span><span class=cF7>)</span><span class=cF0>/8,</span><span class=cF7>(</span><span class=cF0>y1*7+y2</span><span class=cF7>)</span><span class=cF0>/8,0,tmps-&gt;action_key);
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l172"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;type==EMD_CONNECTOR) {
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (zoom&gt;0.5) </span><span class=cF7>{</span><span class=cF0>
<a name="l174"></a> dc-&gt;color=</span><span class=cF3>CYAN</span><span class=cF0>;
<a name="l175"></a> </span><span class=cF5>GrPutChar3</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>x1*7+x2</span><span class=cF7>)</span><span class=cF0>/8,</span><span class=cF7>(</span><span class=cF0>y1*7+y2</span><span class=cF7>)</span><span class=cF0>/8,0,tmps-&gt;action_key);
<a name="l176"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l177"></a> }
<a name="l178"></a> tmps=tmps-&gt;next;
<a name="l179"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l180"></a>}
<a name="l181"></a>
<a name="l182"></a></span><span class=cF1>U0</span><span class=cF0> MyDerivative(</span><span class=cF9>CMathODE</span><span class=cF0> *ode,</span><span class=cF1>F64</span><span class=cF0>,</span><span class=cF9>COrder2D3</span><span class=cF0> *,</span><span class=cF9>COrder2D3</span><span class=cF0> *)
<a name="l183"></a>{
<a name="l184"></a></span><span class=cF2>//The forces due to springs and drag are</span><span class=cF0>
<a name="l185"></a> </span><span class=cF2>//automatically handled by the</span><span class=cF0>
<a name="l186"></a> </span><span class=cF2>//ode code. We can add new forces</span><span class=cF0>
<a name="l187"></a> </span><span class=cF2>//here.</span><span class=cF0>
<a name="l188"></a> </span><span class=cF1>F64</span><span class=cF0> d,dd;
<a name="l189"></a> </span><span class=cF9>CD3</span><span class=cF0> p;
<a name="l190"></a> MyMass *tmpm1,*tmpm2;
<a name="l191"></a> MySpring *tmps;
<a name="l192"></a>
<a name="l193"></a> tmpm1=ode-&gt;next_mass;
<a name="l194"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm1!=&amp;ode-&gt;next_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l195"></a> tmpm2=tmpm1-&gt;next;
<a name="l196"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm2!=&amp;ode-&gt;next_mass) {
<a name="l197"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&amp;p,&amp;tmpm2-&gt;state-&gt;x,&amp;tmpm1-&gt;state-&gt;x);
<a name="l198"></a> dd=</span><span class=cF5>D3NormSqr</span><span class=cF0>(&amp;p);
<a name="l199"></a> </span><span class=cF1>if</span><span class=cF0> (dd&lt;=</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>2*RADIUS</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l200"></a> d=</span><span class=cF5>Sqrt</span><span class=cF0>(dd)+0.0001;
<a name="l201"></a> dd=10.0*</span><span class=cF5>Sqr</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(2*RADIUS)-dd</span><span class=cF7>)</span><span class=cF0>);
<a name="l202"></a> </span><span class=cF5>D3MulEqu</span><span class=cF0>(&amp;p,dd/d);
<a name="l203"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&amp;tmpm2-&gt;DstateDt-&gt;DxDt,&amp;p);
<a name="l204"></a> </span><span class=cF5>D3SubEqu</span><span class=cF0>(&amp;tmpm1-&gt;DstateDt-&gt;DxDt,&amp;p);
<a name="l205"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l206"></a> tmpm2=tmpm2-&gt;next;
<a name="l207"></a> }
<a name="l208"></a> tmpm1=tmpm1-&gt;next;
<a name="l209"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l210"></a>
<a name="l211"></a> tmps=ode-&gt;next_spring;
<a name="l212"></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="l213"></a> </span><span class=cF1>if</span><span class=cF0> (main_mode_bttn.state==MMD_PLAY &amp;&amp; tmps-&gt;type==EMD_THRUSTER &amp;&amp;
<a name="l214"></a> </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap,action_scan_codes[tmps-&gt;action_key-</span><span class=cF6>'0'</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0>) {
<a name="l215"></a> </span><span class=cF5>D3Sub</span><span class=cF0>(&amp;p,&amp;tmps-&gt;end2-&gt;state-&gt;x,&amp;tmps-&gt;end1-&gt;state-&gt;x);
<a name="l216"></a> </span><span class=cF5>D3Unit</span><span class=cF0>(&amp;p);
<a name="l217"></a> </span><span class=cF5>D3MulEqu</span><span class=cF0>(&amp;p,2000);
<a name="l218"></a> </span><span class=cF5>D3AddEqu</span><span class=cF0>(&amp;tmps-&gt;end1-&gt;DstateDt-&gt;DxDt,&amp;p);
<a name="l219"></a> }
<a name="l220"></a> tmps=tmps-&gt;next;
<a name="l221"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l222"></a>}
<a name="l223"></a>
<a name="l224"></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="l225"></a>{
<a name="l226"></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="l227"></a> tmpm-&gt;mass=1.0;
<a name="l228"></a> tmpm-&gt;drag_profile_factor=100.0;
<a name="l229"></a> tmpm-&gt;x=x;
<a name="l230"></a> tmpm-&gt;y=y;
<a name="l231"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpm,ode-&gt;last_mass);
<a name="l232"></a> </span><span class=cF1>return</span><span class=cF0> tmpm;
<a name="l233"></a>}
<a name="l234"></a>
<a name="l235"></a>MySpring *PlaceSpring(MyMass *tmpm1,MyMass *tmpm2,</span><span class=cF9>I64</span><span class=cF0> type)
<a name="l236"></a>{
<a name="l237"></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="l238"></a> </span><span class=cF1>F64</span><span class=cF0> d=</span><span class=cF5>D3Dist</span><span class=cF0>(&amp;tmpm1-&gt;x,&amp;tmpm2-&gt;x);
<a name="l239"></a> tmps-&gt;end1=tmpm1;
<a name="l240"></a> tmps-&gt;end2=tmpm2;
<a name="l241"></a> tmps-&gt;rest_len=d;
<a name="l242"></a> tmps-&gt;type=type;
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (type==EMD_THRUSTER)
<a name="l244"></a> tmps-&gt;const=0;
<a name="l245"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l246"></a> tmps-&gt;const=2500000/</span><span class=cF5>Sqr</span><span class=cF0>(d);
<a name="l247"></a> tmps-&gt;action_key=next_action_key;
<a name="l248"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,ode-&gt;last_spring);
<a name="l249"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
<a name="l250"></a>}
<a name="l251"></a>
<a name="l252"></a></span><span class=cF1>U0</span><span class=cF0> CenterMasses()
<a name="l253"></a>{
<a name="l254"></a> </span><span class=cF9>CD3</span><span class=cF0> p;
<a name="l255"></a> MyMass *tmpm1,*tmpm2;
<a name="l256"></a> tmpm1=ode-&gt;next_mass;
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1!=&amp;ode-&gt;next_mass) </span><span class=cF7>{</span><span class=cF0>
<a name="l258"></a> </span><span class=cF5>D3Copy</span><span class=cF0>(&amp;p,&amp;tmpm1-&gt;x);
<a name="l259"></a> tmpm2=ode-&gt;next_mass;
<a name="l260"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm2!=&amp;ode-&gt;next_mass) {
<a name="l261"></a> </span><span class=cF5>D3SubEqu</span><span class=cF0>(&amp;tmpm2-&gt;x,&amp;p);
<a name="l262"></a> tmpm2=tmpm2-&gt;next;
<a name="l263"></a> }
<a name="l264"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l265"></a>}
<a name="l266"></a>
<a name="l267"></a></span><span class=cF1>U0</span><span class=cF0> NullSprings()
<a name="l268"></a>{
<a name="l269"></a> MySpring *tmps=ode-&gt;next_spring;
<a name="l270"></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="l271"></a> tmps-&gt;rest_len=</span><span class=cF5>D3Dist</span><span class=cF0>(&amp;tmps-&gt;end1-&gt;x,&amp;tmps-&gt;end2-&gt;x);
<a name="l272"></a> tmps=tmps-&gt;next;
<a name="l273"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l274"></a>}
<a name="l275"></a>
<a name="l276"></a></span><span class=cF1>U0</span><span class=cF0> BreakConnectors()
<a name="l277"></a>{
<a name="l278"></a> MySpring *tmps=ode-&gt;next_spring,*tmps1;
<a name="l279"></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="l280"></a> tmps1=tmps-&gt;next;
<a name="l281"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;type==EMD_CONNECTOR &amp;&amp;
<a name="l282"></a> </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap,action_scan_codes[tmps-&gt;action_key-</span><span class=cF6>'0'</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0>) {
<a name="l283"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmps);
<a name="l284"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l285"></a> }
<a name="l286"></a> tmps=tmps1;
<a name="l287"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l288"></a>}
<a name="l289"></a>
<a name="l290"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l291"></a>{
<a name="l292"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l293"></a> task=</span><span class=cF5>Fs</span><span class=cF0>;
<a name="l294"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;=9;i++)
<a name="l295"></a> action_scan_codes[i]=</span><span class=cF5>Char2ScanCode</span><span class=cF0>(</span><span class=cF6>'0'</span><span class=cF0>+i);
<a name="l296"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;STARS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l297"></a> stars_x[i]=</span><span class=cF5>RandU32</span><span class=cF0>%8192-4096;
<a name="l298"></a> stars_y[i]=</span><span class=cF5>RandU32</span><span class=cF0>%8192-4096;
<a name="l299"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l300"></a> next_action_key=</span><span class=cF6>'1'</span><span class=cF0>;
<a name="l301"></a> zoom=1.0;
<a name="l302"></a> ode=</span><span class=cF5>ODENew</span><span class=cF0>(0,1e-4,</span><span class=cF3>ODEF_HAS_MASSES</span><span class=cF0>);
<a name="l303"></a> ode-&gt;derive=&amp;MyDerivative;
<a name="l304"></a> ode-&gt;acceleration_limit=5e3;
<a name="l305"></a> ode-&gt;drag_v2=0.000002;
<a name="l306"></a> ode-&gt;drag_v3=0.0000001;
<a name="l307"></a> </span><span class=cF5>QueIns</span><span class=cF0>(ode,</span><span class=cF5>Fs</span><span class=cF0>-&gt;last_ode);
<a name="l308"></a>}
<a name="l309"></a>
<a name="l310"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l311"></a>{
<a name="l312"></a> </span><span class=cF1>if</span><span class=cF0> (ode) </span><span class=cF7>{</span><span class=cF0>
<a name="l313"></a> </span><span class=cF5>QueRem</span><span class=cF0>(ode);
<a name="l314"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&amp;ode-&gt;next_mass,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l315"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&amp;ode-&gt;next_spring,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l316"></a> </span><span class=cF5>ODEDel</span><span class=cF0>(ode);
<a name="l317"></a> ode=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l318"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l319"></a>}
<a name="l320"></a>
<a name="l321"></a></span><span class=cF1>U0</span><span class=cF0> PlayShip()
<a name="l322"></a>{
<a name="l323"></a> </span><span class=cF9>I64</span><span class=cF0> arg1,arg2;
<a name="l324"></a> </span><span class=cF1>F64</span><span class=cF0> last_noise=0;
<a name="l325"></a> </span><span class=cF1>Bool</span><span class=cF0> okay;
<a name="l326"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode,</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l327"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l328"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l329"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l330"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l331"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l332"></a> </span><span class=cF6>&quot;Edit {&quot;</span><span class=cF0>
<a name="l333"></a> </span><span class=cF6>&quot; EditShip(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l334"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l335"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l336"></a> </span><span class=cF6>&quot; Center(,'c');&quot;</span><span class=cF0>
<a name="l337"></a> </span><span class=cF6>&quot; Damp(,'d');&quot;</span><span class=cF0>
<a name="l338"></a> </span><span class=cF6>&quot; Action0(,'0');&quot;</span><span class=cF0>
<a name="l339"></a> </span><span class=cF6>&quot; Action1(,'1');&quot;</span><span class=cF0>
<a name="l340"></a> </span><span class=cF6>&quot; Action2(,'2');&quot;</span><span class=cF0>
<a name="l341"></a> </span><span class=cF6>&quot; Action3(,'3');&quot;</span><span class=cF0>
<a name="l342"></a> </span><span class=cF6>&quot; Action4(,'4');&quot;</span><span class=cF0>
<a name="l343"></a> </span><span class=cF6>&quot; Action5(,'5');&quot;</span><span class=cF0>
<a name="l344"></a> </span><span class=cF6>&quot; Action6(,'6');&quot;</span><span class=cF0>
<a name="l345"></a> </span><span class=cF6>&quot; Action7(,'7');&quot;</span><span class=cF0>
<a name="l346"></a> </span><span class=cF6>&quot; Action8(,'8');&quot;</span><span class=cF0>
<a name="l347"></a> </span><span class=cF6>&quot; Action9(,'9');&quot;</span><span class=cF0>
<a name="l348"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l349"></a> </span><span class=cF6>&quot;View {&quot;</span><span class=cF0>
<a name="l350"></a> </span><span class=cF6>&quot; ZoomIn(,'z');&quot;</span><span class=cF0>
<a name="l351"></a> </span><span class=cF6>&quot; ZoomOut(,'Z');&quot;</span><span class=cF0>
<a name="l352"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l353"></a> );
<a name="l354"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l355"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l356"></a> </span><span class=cF1>while</span><span class=cF0> (main_mode_bttn.state==MMD_PLAY) {
<a name="l357"></a> BreakConnectors;
<a name="l358"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_KEY_UP</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l359"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l360"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l361"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>...</span><span class=cF6>'9'</span><span class=cF0>:
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&gt;last_noise+0.25) </span><span class=cF7>{</span><span class=cF0>
<a name="l363"></a> </span><span class=cF5>Noise</span><span class=cF0>(250,18,46);
<a name="l364"></a> last_noise=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l365"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l366"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l367"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'z'</span><span class=cF0>:
<a name="l368"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;Zoom,2.0</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
<a name="l369"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l370"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'Z'</span><span class=cF0>:
<a name="l371"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;Zoom,0.5</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
<a name="l372"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l373"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
<a name="l374"></a> CenterMasses;
<a name="l375"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l376"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l377"></a> ode-&gt;drag_v2=0.002;
<a name="l378"></a> ode-&gt;drag_v3=0.0001;
<a name="l379"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l380"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l381"></a> </span><span class=cF1>if</span><span class=cF0> (++main_mode_bttn.state==MMD_MODES_NUM)
<a name="l382"></a> main_mode_bttn.state=0;
<a name="l383"></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="l384"></a> </span><span class=cF1>goto</span><span class=cF0> ps_done;
<a name="l385"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l386"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l387"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l388"></a> }
<a name="l389"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l390"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_UP</span><span class=cF0>:
<a name="l391"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l392"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l393"></a> ode-&gt;drag_v2=0.000002;
<a name="l394"></a> ode-&gt;drag_v3=0.0000001;
<a name="l395"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l396"></a> }
<a name="l397"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l398"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l399"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l400"></a> }
<a name="l401"></a>ps_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
<a name="l402"></a> okay=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l403"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l404"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l405"></a> okay=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l406"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l407"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l408"></a> </span><span class=cF1>if</span><span class=cF0> (!okay)
<a name="l409"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l410"></a>}
<a name="l411"></a>
<a name="l412"></a></span><span class=cF1>U0</span><span class=cF0> EditShip()
<a name="l413"></a>{
<a name="l414"></a> </span><span class=cF9>I64</span><span class=cF0> arg1,arg2;
<a name="l415"></a> </span><span class=cF1>F64</span><span class=cF0> wx,wy;
<a name="l416"></a> </span><span class=cF1>Bool</span><span class=cF0> okay;
<a name="l417"></a> MyMass *tmpm1=</span><span class=cF3>NULL</span><span class=cF0>,*tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l418"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *bt_edit_mode=</span><span class=cF5>CtrlBttnNew</span><span class=cF0>(0,5*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>+4,80,,EMD_MODES_NUM,
<a name="l419"></a> </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_EDIT_MODES&quot;</span><span class=cF7>)</span><span class=cF0>,edit_mode_colors,&amp;edit_mode_bttn);
<a name="l420"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode);
<a name="l421"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l422"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l423"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l424"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l425"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l426"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l427"></a> </span><span class=cF6>&quot; PlayShip(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l428"></a> </span><span class=cF6>&quot; Center(,'c');&quot;</span><span class=cF0>
<a name="l429"></a> </span><span class=cF6>&quot; Damp(,'d');&quot;</span><span class=cF0>
<a name="l430"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l431"></a> </span><span class=cF6>&quot;Edit {&quot;</span><span class=cF0>
<a name="l432"></a> </span><span class=cF6>&quot; Move(,'v');&quot;</span><span class=cF0>
<a name="l433"></a> </span><span class=cF6>&quot; Mass(,'m');&quot;</span><span class=cF0>
<a name="l434"></a> </span><span class=cF6>&quot; Spring(,'s');&quot;</span><span class=cF0>
<a name="l435"></a> </span><span class=cF6>&quot; Connector(,'n');&quot;</span><span class=cF0>
<a name="l436"></a> </span><span class=cF6>&quot; Thruster(,'t');&quot;</span><span class=cF0>
<a name="l437"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l438"></a> </span><span class=cF6>&quot; Action0(,'0');&quot;</span><span class=cF0>
<a name="l439"></a> </span><span class=cF6>&quot; Action1(,'1');&quot;</span><span class=cF0>
<a name="l440"></a> </span><span class=cF6>&quot; Action2(,'2');&quot;</span><span class=cF0>
<a name="l441"></a> </span><span class=cF6>&quot; Action3(,'3');&quot;</span><span class=cF0>
<a name="l442"></a> </span><span class=cF6>&quot; Action4(,'4');&quot;</span><span class=cF0>
<a name="l443"></a> </span><span class=cF6>&quot; Action5(,'5');&quot;</span><span class=cF0>
<a name="l444"></a> </span><span class=cF6>&quot; Action6(,'6');&quot;</span><span class=cF0>
<a name="l445"></a> </span><span class=cF6>&quot; Action7(,'7');&quot;</span><span class=cF0>
<a name="l446"></a> </span><span class=cF6>&quot; Action8(,'8');&quot;</span><span class=cF0>
<a name="l447"></a> </span><span class=cF6>&quot; Action9(,'9');&quot;</span><span class=cF0>
<a name="l448"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l449"></a> </span><span class=cF6>&quot;View {&quot;</span><span class=cF0>
<a name="l450"></a> </span><span class=cF6>&quot; ZoomIn(,'z');&quot;</span><span class=cF0>
<a name="l451"></a> </span><span class=cF6>&quot; ZoomOut(,'Z');&quot;</span><span class=cF0>
<a name="l452"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l453"></a> );
<a name="l454"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l455"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l456"></a> </span><span class=cF1>while</span><span class=cF0> (main_mode_bttn.state==MMD_EDIT) {
<a name="l457"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&amp;arg1,&amp;arg2,
<a name="l458"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>|
<a name="l459"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_MOVE</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_KEY_UP</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l460"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l461"></a> </span><span class=cF1>switch</span><span class=cF0> (edit_mode_bttn.state) {
<a name="l462"></a> </span><span class=cF1>case</span><span class=cF0> EMD_MASS:
<a name="l463"></a> S2W(</span><span class=cFB>ms</span><span class=cF0>.pos.x,</span><span class=cFB>ms</span><span class=cF0>.pos.y,&amp;wx,&amp;wy);
<a name="l464"></a> tmpm1=PlaceMass(wx,wy);
<a name="l465"></a> </span><span class=cF1>if</span><span class=cF0> (ode-&gt;next_mass==tmpm1)
<a name="l466"></a> tmpm1-&gt;img=</span><span class=cFA>&lt;1&gt;</span><span class=cF0>;
<a name="l467"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l468"></a> tmpm1-&gt;img=</span><span class=cFA>&lt;2&gt;</span><span class=cF0>;
<a name="l469"></a> tmpm1=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l470"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l471"></a> </span><span class=cF1>case</span><span class=cF0> EMD_SPRING:
<a name="l472"></a> </span><span class=cF1>case</span><span class=cF0> EMD_CONNECTOR:
<a name="l473"></a> </span><span class=cF1>case</span><span class=cF0> EMD_THRUSTER:
<a name="l474"></a> </span><span class=cF1>case</span><span class=cF0> EMD_MOVE:
<a name="l475"></a> S2W(</span><span class=cFB>ms</span><span class=cF0>.pos.x,</span><span class=cFB>ms</span><span class=cF0>.pos.y,&amp;wx,&amp;wy);
<a name="l476"></a> tmpm1=</span><span class=cF5>MassFind</span><span class=cF0>(ode,wx,wy);
<a name="l477"></a> tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l478"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l479"></a> }
<a name="l480"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l481"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
<a name="l482"></a> </span><span class=cF1>switch</span><span class=cF0> (edit_mode_bttn.state) {
<a name="l483"></a> </span><span class=cF1>case</span><span class=cF0> EMD_MASS:
<a name="l484"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l485"></a> </span><span class=cF1>case</span><span class=cF0> EMD_SPRING:
<a name="l486"></a> </span><span class=cF1>case</span><span class=cF0> EMD_CONNECTOR:
<a name="l487"></a> </span><span class=cF1>case</span><span class=cF0> EMD_THRUSTER:
<a name="l488"></a> S2W(</span><span class=cFB>ms</span><span class=cF0>.pos.x,</span><span class=cFB>ms</span><span class=cF0>.pos.y,&amp;wx,&amp;wy);
<a name="l489"></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,wx,wy)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; tmpm1!=tmpm2)
<a name="l490"></a> PlaceSpring(tmpm1,tmpm2,edit_mode_bttn.state);
<a name="l491"></a> tmpm1=tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l492"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l493"></a> </span><span class=cF1>case</span><span class=cF0> EMD_MOVE:
<a name="l494"></a> S2W(</span><span class=cFB>ms</span><span class=cF0>.pos.x,</span><span class=cFB>ms</span><span class=cF0>.pos.y,&amp;wx,&amp;wy);
<a name="l495"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1) </span><span class=cF7>{</span><span class=cF0>
<a name="l496"></a> tmpm1-&gt;x=wx;
<a name="l497"></a> tmpm1-&gt;y=wy;
<a name="l498"></a> tmpm1-&gt;z=0;
<a name="l499"></a> NullSprings;
<a name="l500"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l501"></a> tmpm1=tmpm2=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l502"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l503"></a> }
<a name="l504"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l505"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>:
<a name="l506"></a> </span><span class=cF1>switch</span><span class=cF0> (edit_mode_bttn.state) {
<a name="l507"></a> </span><span class=cF1>case</span><span class=cF0> EMD_MOVE:
<a name="l508"></a> S2W(</span><span class=cFB>ms</span><span class=cF0>.pos.x,</span><span class=cFB>ms</span><span class=cF0>.pos.y,&amp;wx,&amp;wy);
<a name="l509"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1) </span><span class=cF7>{</span><span class=cF0>
<a name="l510"></a> tmpm1-&gt;x=wx;
<a name="l511"></a> tmpm1-&gt;y=wy;
<a name="l512"></a> tmpm1-&gt;z=0;
<a name="l513"></a> NullSprings;
<a name="l514"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l515"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l516"></a> }
<a name="l517"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l518"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>:
<a name="l519"></a> </span><span class=cF1>if</span><span class=cF0> (++edit_mode_bttn.state==EMD_MODES_NUM)
<a name="l520"></a> edit_mode_bttn.state=0;
<a name="l521"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l522"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>:
<a name="l523"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l524"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l525"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l526"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l527"></a> CleanUp;
<a name="l528"></a> Init;
<a name="l529"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l530"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>...</span><span class=cF6>'9'</span><span class=cF0>:
<a name="l531"></a> next_action_key=arg1;
<a name="l532"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l533"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
<a name="l534"></a> CenterMasses;
<a name="l535"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l536"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l537"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode,</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l538"></a> ode-&gt;drag_v2=0.002;
<a name="l539"></a> ode-&gt;drag_v3=0.0001;
<a name="l540"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l541"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'v'</span><span class=cF0>:
<a name="l542"></a> edit_mode_bttn.state=EMD_MOVE;
<a name="l543"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l544"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'m'</span><span class=cF0>:
<a name="l545"></a> edit_mode_bttn.state=EMD_MASS;
<a name="l546"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l547"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'n'</span><span class=cF0>:
<a name="l548"></a> edit_mode_bttn.state=EMD_CONNECTOR;
<a name="l549"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l550"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'s'</span><span class=cF0>:
<a name="l551"></a> edit_mode_bttn.state=EMD_SPRING;
<a name="l552"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l553"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'t'</span><span class=cF0>:
<a name="l554"></a> edit_mode_bttn.state=EMD_THRUSTER;
<a name="l555"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l556"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'z'</span><span class=cF0>:
<a name="l557"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;Zoom,2.0</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
<a name="l558"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l559"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'Z'</span><span class=cF0>:
<a name="l560"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&amp;Zoom,0.5</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
<a name="l561"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l562"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l563"></a> </span><span class=cF1>if</span><span class=cF0> (++main_mode_bttn.state==MMD_MODES_NUM)
<a name="l564"></a> main_mode_bttn.state=0;
<a name="l565"></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="l566"></a> </span><span class=cF1>goto</span><span class=cF0> es_done;
<a name="l567"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l568"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l569"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l570"></a> }
<a name="l571"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l572"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_UP</span><span class=cF0>:
<a name="l573"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l574"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l575"></a> </span><span class=cF5>ODEPause</span><span class=cF0>(ode);
<a name="l576"></a> ode-&gt;drag_v2=0.000002;
<a name="l577"></a> ode-&gt;drag_v3=0.0000001;
<a name="l578"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l579"></a> }
<a name="l580"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l581"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l582"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l583"></a> }
<a name="l584"></a>es_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
<a name="l585"></a> okay=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l586"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l587"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l588"></a> okay=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l589"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l590"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l591"></a> </span><span class=cF5>CtrlBttnDel</span><span class=cF0>(bt_edit_mode);
<a name="l592"></a> </span><span class=cF1>if</span><span class=cF0> (!okay)
<a name="l593"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l594"></a>}
<a name="l595"></a>
<a name="l596"></a></span><span class=cF1>U0</span><span class=cF0> Strut()
<a name="l597"></a>{
<a name="l598"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *bt_main_mode;
<a name="l599"></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="l600"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit|=</span><span class=cF3>WIF_SELF_MS_L</span><span class=cF0>|</span><span class=cF3>WIF_SELF_MS_R</span><span class=cF0>|</span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
<a name="l601"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l602"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l603"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l604"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l605"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l606"></a> </span><span class=cF6>&quot;\n$WW,1$$PURPLE$$TX+CX,\&quot;Build a ship.\&quot;$$FG$\n\n&quot;</span><span class=cF0>
<a name="l607"></a> </span><span class=cF6>&quot;Sel mass mode.\tLeft-click to place masses.\n&quot;</span><span class=cF0>
<a name="l608"></a> </span><span class=cF6>&quot;Sel spring mode.\tLeft-drag to make members.\n&quot;</span><span class=cF0>
<a name="l609"></a> </span><span class=cF6>&quot;Sel thruster mode.\tPress a digit, 0-9. Drag to make thruster.\n&quot;</span><span class=cF0>
<a name="l610"></a> </span><span class=cF6>&quot;Sel connector mode.\tPress a digit, 0-9. &quot;</span><span class=cF0>
<a name="l611"></a> </span><span class=cF6>&quot;Drag to make breakable connector.\n\n&quot;</span><span class=cF0>
<a name="l612"></a> </span><span class=cF6>&quot;Press $GREEN$&lt;SPACE&gt;$FG$ to run the game. Press digits to operate &quot;</span><span class=cF0>
<a name="l613"></a> </span><span class=cF6>&quot;thrusters and break connectors.\n\n&quot;</span><span class=cF0>
<a name="l614"></a> </span><span class=cF6>&quot;Press $GREEN$&lt;z&gt;$FG$ or $GREEN$&lt;SHIFT-Z&gt;$FG$ to zoom in/out.\n\n&quot;</span><span class=cF0>;
<a name="l615"></a>
<a name="l616"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l617"></a> bt_main_mode=</span><span class=cF5>CtrlBttnNew</span><span class=cF0>(
<a name="l618"></a> </span><span class=cF7>(</span><span class=cF3>GR_WIDTH</span><span class=cF0>-4*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>-16</span><span class=cF7>)</span><span class=cF0>&gt;&gt;1,1*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>+4,80,,MMD_MODES_NUM,
<a name="l619"></a> </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_MAIN_MODES&quot;</span><span class=cF7>)</span><span class=cF0>,main_mode_colors,&amp;main_mode_bttn);
<a name="l620"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l621"></a> Init;
<a name="l622"></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="l623"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l624"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l625"></a> EditShip;
<a name="l626"></a> PlayShip;
<a name="l627"></a> }
<a name="l628"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l629"></a> CleanUp;
<a name="l630"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l631"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l632"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l633"></a> </span><span class=cF5>CtrlBttnDel</span><span class=cF0>(bt_main_mode);
<a name="l634"></a>}
</span></pre></body>
</html>