ZealOS/docs/Apps/Span/SpanNew.CC.html
TomAwezome 22e3d8f06e Clean up E1000 Driver.
Remove some palettes.
Add PaletteSetSlate.
Change all gr_palette_std to gr32_palette_std.
Change all CBGR48 to CBGR24.
2021-07-28 22:20:15 -04:00

172 lines
13 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.11">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF9>CMathODE</span><span class=cF0> *SpanNew()
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF9>CMathODE</span><span class=cF0> *ode = </span><span class=cF5>ODENew</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>e-</span><span class=cFE>4</span><span class=cF0>, </span><span class=cF3>ODEF_HAS_MASSES</span><span class=cF0> | </span><span class=cF3>ODEF_PAUSED</span><span class=cF0>);
<a name="l4"></a>
<a name="l5"></a> ode-&gt;derive = &amp;MyDerivative;
<a name="l6"></a> ode-&gt;drag_v2 = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>002</span><span class=cF0>;
<a name="l7"></a> ode-&gt;drag_v3 = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>00001</span><span class=cF0>;
<a name="l8"></a> ode-&gt;acceleration_limit = </span><span class=cFE>5</span><span class=cF0>e3;
<a name="l9"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(ode, </span><span class=cF5>Fs</span><span class=cF0>-&gt;last_ode);
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF1>return</span><span class=cF0> ode;
<a name="l12"></a>}
<a name="l13"></a>
<a name="l14"></a></span><span class=cF1>U0</span><span class=cF0> SpanDel(</span><span class=cF9>CMathODE</span><span class=cF0> *ode)
<a name="l15"></a>{
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (ode)
<a name="l17"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(ode);
<a name="l19"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;ode-&gt;next_mass, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l20"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;ode-&gt;next_spring, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l21"></a> </span><span class=cF5>ODEDel</span><span class=cF0>(ode);
<a name="l22"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l23"></a>}
<a name="l24"></a>
<a name="l25"></a>#</span><span class=cF1>define</span><span class=cF0> M_SIZE (</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MyMass</span><span class=cF7>)</span><span class=cF0> - </span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CMass</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF7>)</span><span class=cF0>)
<a name="l26"></a>#</span><span class=cF1>define</span><span class=cF0> S_SIZE (</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MySpring</span><span class=cF7>)</span><span class=cF0> - </span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CSpring</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF7>)</span><span class=cF0>)
<a name="l27"></a>
<a name="l28"></a></span><span class=cF1>U8</span><span class=cF0> *SpanSave(</span><span class=cF9>CMathODE</span><span class=cF0> *ode, </span><span class=cF9>I64</span><span class=cF0> *_size=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l29"></a>{
<a name="l30"></a> </span><span class=cF9>I64</span><span class=cF0> count;
<a name="l31"></a> </span><span class=cF1>U8</span><span class=cF0> *res, *ptr;
<a name="l32"></a> MyMass *tmpm;
<a name="l33"></a> MySpring *tmps;
<a name="l34"></a> SpanHeader h;
<a name="l35"></a>
<a name="l36"></a> </span><span class=cF5>ODERenum</span><span class=cF0>(ode);
<a name="l37"></a> h.version = SPAN_VERSION;
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (ode-&gt;next_mass != &amp;ode-&gt;next_mass)
<a name="l39"></a> h.num_masses = ode-&gt;last_mass-&gt;num + </span><span class=cFE>1</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l41"></a> h.num_masses = </span><span class=cFE>0</span><span class=cF0>;
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (ode-&gt;next_spring != &amp;ode-&gt;next_spring)
<a name="l43"></a> h.num_springs = ode-&gt;last_spring-&gt;num + </span><span class=cFE>1</span><span class=cF0>;
<a name="l44"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l45"></a> h.num_springs = </span><span class=cFE>0</span><span class=cF0>;
<a name="l46"></a>
<a name="l47"></a> count = </span><span class=cF1>sizeof</span><span class=cF0>(SpanHeader) + h.num_masses * M_SIZE + h.num_springs * S_SIZE;
<a name="l48"></a>
<a name="l49"></a> ptr = res = </span><span class=cF5>MAlloc</span><span class=cF0>(count);
<a name="l50"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(ptr, &amp;h, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>SpanHeader</span><span class=cF7>)</span><span class=cF0>);
<a name="l51"></a> ptr += </span><span class=cF1>sizeof</span><span class=cF0>(SpanHeader);
<a name="l52"></a>
<a name="l53"></a> tmpm = ode-&gt;next_mass;
<a name="l54"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm != &amp;ode-&gt;next_mass)
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(ptr, &amp;tmpm-&gt;</span><span class=cF1>start</span><span class=cF0>, M_SIZE);
<a name="l57"></a> ptr += M_SIZE;
<a name="l58"></a> tmpm = tmpm-&gt;next;
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a>
<a name="l61"></a> tmps = ode-&gt;next_spring;
<a name="l62"></a> </span><span class=cF1>while</span><span class=cF0> (tmps != &amp;ode-&gt;next_spring)
<a name="l63"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l64"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(ptr, &amp;tmps-&gt;</span><span class=cF1>start</span><span class=cF0>, S_SIZE);
<a name="l65"></a> ptr += S_SIZE;
<a name="l66"></a> tmps = tmps-&gt;next;
<a name="l67"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (_size)
<a name="l69"></a> *_size = count;
<a name="l70"></a>
<a name="l71"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l72"></a>}
<a name="l73"></a>
<a name="l74"></a></span><span class=cF1>Bool</span><span class=cF0> SpanWrite(</span><span class=cF9>CMathODE</span><span class=cF0> *ode)
<a name="l75"></a>{
<a name="l76"></a> </span><span class=cF1>U8</span><span class=cF0> *name, *buf;
<a name="l77"></a> </span><span class=cF9>I64</span><span class=cF0> size;
<a name="l78"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>, old_silent = </span><span class=cF5>Silent</span><span class=cF0>;
<a name="l79"></a>
<a name="l80"></a> </span><span class=cF5>DirMake</span><span class=cF0>(</span><span class=cF6>&quot;~/Span&quot;</span><span class=cF0>);
<a name="l81"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (name = </span><span class=cF5>PopUpFileName</span><span class=cF7>(</span><span class=cF6>&quot;~/Span/Game.DATA&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l83"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (buf = SpanSave</span><span class=cF7>(</span><span class=cF0>ode, &amp;size</span><span class=cF7>)</span><span class=cF0>)
<a name="l85"></a> {
<a name="l86"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(name, buf, size);
<a name="l87"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l88"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l89"></a> }
<a name="l90"></a> </span><span class=cF5>Free</span><span class=cF0>(name);
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l92"></a>
<a name="l93"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l94"></a>}
<a name="l95"></a>
<a name="l96"></a></span><span class=cF1>U0</span><span class=cF0> SpanLoad(</span><span class=cF9>CMathODE</span><span class=cF0> *ode, </span><span class=cF1>U8</span><span class=cF0> *src)
<a name="l97"></a>{
<a name="l98"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l99"></a> MyMass *tmpm;
<a name="l100"></a> MySpring *tmps;
<a name="l101"></a> SpanHeader h;
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>if</span><span class=cF0> (!src)
<a name="l104"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l105"></a>
<a name="l106"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;h, src, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>SpanHeader</span><span class=cF7>)</span><span class=cF0>);
<a name="l107"></a> src += </span><span class=cF1>sizeof</span><span class=cF0>(SpanHeader);
<a name="l108"></a>
<a name="l109"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; h.num_masses; i++)
<a name="l110"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l111"></a> 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="l112"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmpm-&gt;</span><span class=cF1>start</span><span class=cF0>, src, M_SIZE);
<a name="l113"></a> src += M_SIZE;
<a name="l114"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpm, ode-&gt;last_mass);
<a name="l115"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l116"></a>
<a name="l117"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; h.num_springs; i++)
<a name="l118"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l119"></a> 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="l120"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;tmps-&gt;</span><span class=cF1>start</span><span class=cF0>, src, S_SIZE);
<a name="l121"></a> src += S_SIZE;
<a name="l122"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, ode-&gt;last_spring);
<a name="l123"></a> tmps-&gt;end1 = </span><span class=cF5>MassFindNum</span><span class=cF0>(ode, tmps-&gt;end1_num);
<a name="l124"></a> tmps-&gt;end2 = </span><span class=cF5>MassFindNum</span><span class=cF0>(ode, tmps-&gt;end2_num);
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l126"></a>}
<a name="l127"></a>
<a name="l128"></a></span><span class=cF1>U8</span><span class=cF0> *SpanRead()
<a name="l129"></a>{
<a name="l130"></a> </span><span class=cF1>U8</span><span class=cF0> *src = </span><span class=cF3>NULL</span><span class=cF0>, *name;
<a name="l131"></a> </span><span class=cF1>Bool</span><span class=cF0> old_silent = </span><span class=cF5>Silent</span><span class=cF0>;
<a name="l132"></a>
<a name="l133"></a> </span><span class=cF5>DirMake</span><span class=cF0>(</span><span class=cF6>&quot;~/Span&quot;</span><span class=cF0>);
<a name="l134"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
<a name="l135"></a> </span><span class=cF1>if</span><span class=cF0> (name = </span><span class=cF5>PopUpPickFile</span><span class=cF7>(</span><span class=cF6>&quot;~/Span&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l136"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l137"></a> src = </span><span class=cF5>FileRead</span><span class=cF0>(name);
<a name="l138"></a> </span><span class=cF5>Free</span><span class=cF0>(name);
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l140"></a>
<a name="l141"></a> </span><span class=cF1>return</span><span class=cF0> src;
<a name="l142"></a>}
<a name="l143"></a>
</span></pre></body>
</html>