ZealOS/docs/Demo/Games/Wenceslas.CC.html
TomAwezome dbf8647d59 Fixed non-writable drive throw on F5 and Ctrl-S.
Added top & right borders to RawDr.
Improved spacing in some debug and compiler reporting.
Fixed RawPutChar and EdLite tab width.
Fixed Ui missing '0x' prefix syntax highlighter bug.
Added 32BitPaint demo.
2021-07-14 18:38:02 -04:00

682 lines
64 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.08">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Wenceslas&quot;</span><span class=cF0>, </span><span class=cF6>&quot;F64 best_score=9999;\n&quot;</span><span class=cF0>);
<a name="l2"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Wenceslas&quot;</span><span class=cF0>);
<a name="l3"></a>
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER </span><span class=cFE>5</span><span class=cF0>
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> KING_STEP </span><span class=cFE>6</span><span class=cF0>
<a name="l6"></a>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a> </span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cF2>//See </span><span class=cF9><u>::/Apps/GrModels</u></span><span class=cF2> for making 3D men.</span><span class=cF0>
<a name="l12"></a>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a> </span><span class=cFA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l17"></a>
<a name="l18"></a>
<a name="l19"></a>
<a name="l20"></a> </span><span class=cFA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l21"></a>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a> </span><span class=cFA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l25"></a>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a> </span><span class=cFA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a> </span><span class=cFA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l33"></a>
<a name="l34"></a>
<a name="l35"></a>
<a name="l36"></a>
<a name="l37"></a>
<a name="l38"></a>
<a name="l39"></a>
<a name="l40"></a>
<a name="l41"></a>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a> </span><span class=cFA>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l46"></a>
<a name="l47"></a>
<a name="l48"></a>
<a name="l49"></a>
<a name="l50"></a> </span><span class=cFA>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l51"></a>
<a name="l52"></a>
<a name="l53"></a>
<a name="l54"></a>
<a name="l55"></a>
<a name="l56"></a>
<a name="l57"></a> </span><span class=cFA>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l58"></a>
<a name="l59"></a>
<a name="l60"></a>
<a name="l61"></a>
<a name="l62"></a>
<a name="l63"></a>
<a name="l64"></a>
<a name="l65"></a>
<a name="l66"></a>
<a name="l67"></a>
<a name="l68"></a>
<a name="l69"></a>
<a name="l70"></a>
<a name="l71"></a>
<a name="l72"></a>
<a name="l73"></a>
<a name="l74"></a>
<a name="l75"></a>
<a name="l76"></a> </span><span class=cFA>&lt;10&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l77"></a>
<a name="l78"></a>
<a name="l79"></a>
<a name="l80"></a>
<a name="l81"></a>
<a name="l82"></a>
<a name="l83"></a> </span><span class=cFA>&lt;11&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l84"></a>
<a name="l85"></a>
<a name="l86"></a></span><span class=cF1>U8</span><span class=cF0> *king_imgs[</span><span class=cFE>4</span><span class=cF0>] = {</span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;1&gt;</span><span class=cF0>, </span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;3&gt;</span><span class=cF0>};
<a name="l87"></a></span><span class=cF1>U8</span><span class=cF0> *peasant_imgs[</span><span class=cFE>4</span><span class=cF0>] = {</span><span class=cFA>&lt;5&gt;</span><span class=cF0>, </span><span class=cFA>&lt;4&gt;</span><span class=cF0>, </span><span class=cFA>&lt;5&gt;</span><span class=cF0>, </span><span class=cFA>&lt;6&gt;</span><span class=cF0>};
<a name="l88"></a>
<a name="l89"></a>
<a name="l90"></a>#</span><span class=cF1>define</span><span class=cF0> TREES_NUM </span><span class=cFE>8</span><span class=cF0>
<a name="l91"></a></span><span class=cF1>class</span><span class=cF0> Tree
<a name="l92"></a>{
<a name="l93"></a> </span><span class=cF9>U16</span><span class=cF0> x, y;
<a name="l94"></a> </span><span class=cF9>I64</span><span class=cF0> fire_frame_idx;
<a name="l95"></a>
<a name="l96"></a>} trees[TREES_NUM];
<a name="l97"></a>
<a name="l98"></a></span><span class=cF9>U64</span><span class=cF0> snow_x, snow_y, new_snow_mS;
<a name="l99"></a>#</span><span class=cF1>define</span><span class=cF0> SNOW_TILE_SIZE </span><span class=cFE>128</span><span class=cF0>
<a name="l100"></a></span><span class=cF9>CDC</span><span class=cF0> *snow_tile;
<a name="l101"></a>
<a name="l102"></a></span><span class=cF9>I64</span><span class=cF0> king_x, king_y, king_mS, king_phase, not_stopped_count;
<a name="l103"></a></span><span class=cF1>F64</span><span class=cF0> king_timeout, king_theta, t0, tf, door_open_t0;
<a name="l104"></a></span><span class=cF9>I64</span><span class=cF0> animate_mS, animate_phase;
<a name="l105"></a>
<a name="l106"></a>#</span><span class=cF1>define</span><span class=cF0> PEASANTS_NUM </span><span class=cFE>10</span><span class=cF0>
<a name="l107"></a></span><span class=cF1>class</span><span class=cF0> Peasant
<a name="l108"></a>{
<a name="l109"></a> Peasant *next, *last;
<a name="l110"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, theta, door_opened_t0;
<a name="l111"></a> </span><span class=cF1>Bool</span><span class=cF0> stopped;
<a name="l112"></a>
<a name="l113"></a>} peasant_head;
<a name="l114"></a>
<a name="l115"></a></span><span class=cF1>class</span><span class=cF0> Step
<a name="l116"></a>{
<a name="l117"></a> Step *next, *last;
<a name="l118"></a> </span><span class=cF9>U16</span><span class=cF0> x, y;
<a name="l119"></a> </span><span class=cF1>F64</span><span class=cF0> t0;
<a name="l120"></a>
<a name="l121"></a>} step_head, king_step_head;
<a name="l122"></a>
<a name="l123"></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="l124"></a>{
<a name="l125"></a> </span><span class=cF9>I64</span><span class=cF0> r[</span><span class=cFE>16</span><span class=cF0>], i, w = task-&gt;pix_width, h = task-&gt;pix_height, x, y;
<a name="l126"></a> </span><span class=cF1>U8</span><span class=cF0> *img, *tmps;
<a name="l127"></a> Step *tmpst;
<a name="l128"></a> Peasant *tmpp;
<a name="l129"></a> </span><span class=cF1>F64</span><span class=cF0> tt;
<a name="l130"></a>
<a name="l131"></a> dc-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l132"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; TREES_NUM; i++)
<a name="l133"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].y &lt;= h / </span><span class=cFE>2</span><span class=cF0>)
<a name="l135"></a> {</span><span class=cF2>//Draw trees behind house</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx)
<a name="l137"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx++ &amp; </span><span class=cFE>1</span><span class=cF0>)
<a name="l139"></a> img = </span><span class=cFA>&lt;8&gt;</span><span class=cF0>;
<a name="l140"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l141"></a> img = </span><span class=cFA>&lt;9&gt;</span><span class=cF0>;
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l144"></a> img = </span><span class=cFA>&lt;7&gt;</span><span class=cF0>;
<a name="l145"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, trees[i].x, trees[i].y, </span><span class=cFE>0</span><span class=cF0>, img);
<a name="l146"></a> }
<a name="l147"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l148"></a>
<a name="l149"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;10&gt;</span><span class=cF0>);
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &lt; door_open_t0 + </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l151"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;11&gt;</span><span class=cF0>);
<a name="l152"></a>
<a name="l153"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; TREES_NUM; i++)
<a name="l154"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l155"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].y &gt; h / </span><span class=cFE>2</span><span class=cF0>)
<a name="l156"></a> {</span><span class=cF2>//Draw trees in front of house</span><span class=cF0>
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx)
<a name="l158"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l159"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx++ &amp; </span><span class=cFE>1</span><span class=cF0>)
<a name="l160"></a> img = </span><span class=cFA>&lt;8&gt;</span><span class=cF0>;
<a name="l161"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l162"></a> img = </span><span class=cFA>&lt;9&gt;</span><span class=cF0>;
<a name="l163"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l164"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l165"></a> img = </span><span class=cFA>&lt;7&gt;</span><span class=cF0>;
<a name="l166"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, trees[i].x, trees[i].y, </span><span class=cFE>0</span><span class=cF0>, img);
<a name="l167"></a> }
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l169"></a>
<a name="l170"></a> tmpst = step_head.next;
<a name="l171"></a> </span><span class=cF1>while</span><span class=cF0> (tmpst != &amp;step_head)
<a name="l172"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> - tmpst-&gt;t0 &lt; </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l174"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l175"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l176"></a> dc-&gt;color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l177"></a> dc-&gt;thick = </span><span class=cFE>4</span><span class=cF0>;
<a name="l178"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, tmpst-&gt;x, tmpst-&gt;y, </span><span class=cFE>0</span><span class=cF0>);
<a name="l179"></a> tmpst = tmpst-&gt;next;
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l181"></a>
<a name="l182"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
<a name="l183"></a> dc-&gt;flags |= </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l184"></a> dc-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l185"></a> tmpp = peasant_head.next;
<a name="l186"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp != &amp;peasant_head)
<a name="l187"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l188"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l189"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r, tmpp-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l190"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r, </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>6</span><span class=cF0>);
<a name="l191"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;stopped)
<a name="l192"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc, tmpp-&gt;x, tmpp-&gt;y, </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, peasant_imgs[</span><span class=cFE>0</span><span class=cF0>], r);
<a name="l193"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l194"></a> {
<a name="l195"></a> tmps = </span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>animate_mS / </span><span class=cFE>250</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>,
<a name="l196"></a> peasant_imgs[ animate_phase &amp; </span><span class=cFE>3</span><span class=cF0>],
<a name="l197"></a> peasant_imgs[</span><span class=cF7>(</span><span class=cF0>animate_phase + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> &amp; </span><span class=cFE>3</span><span class=cF0>]);
<a name="l198"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc, tmpp-&gt;x, tmpp-&gt;y, </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, tmps, r);
<a name="l199"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l200"></a> }
<a name="l201"></a> tmpp = tmpp-&gt;next;
<a name="l202"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l203"></a>
<a name="l204"></a> dc-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l205"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
<a name="l206"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r, king_theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l207"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r, </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>6</span><span class=cF0>);
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&gt;king_timeout)
<a name="l209"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc, king_x, king_y, </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, king_imgs[</span><span class=cFE>0</span><span class=cF0>], r);
<a name="l210"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l211"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l212"></a> tmps = </span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>king_mS / </span><span class=cFE>250</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>,
<a name="l213"></a> king_imgs[ king_phase &amp; </span><span class=cFE>3</span><span class=cF0>],
<a name="l214"></a> king_imgs[</span><span class=cF7>(</span><span class=cF0>king_phase + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> &amp; </span><span class=cFE>3</span><span class=cF0>]);
<a name="l215"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc, king_x, king_y, </span><span class=cF3>GR_Z_ALL</span><span class=cF0>, tmps, r);
<a name="l216"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l217"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l218"></a>
<a name="l219"></a> dc-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l220"></a> dc-&gt;color = </span><span class=cF3>ROP_MONO</span><span class=cF0> | </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l221"></a> </span><span class=cF1>for</span><span class=cF0> (y = snow_y % SNOW_TILE_SIZE - SNOW_TILE_SIZE; y &lt;= h; y += SNOW_TILE_SIZE)
<a name="l222"></a> </span><span class=cF1>for</span><span class=cF0> (x = snow_x % SNOW_TILE_SIZE - SNOW_TILE_SIZE; x &lt;= w; x += SNOW_TILE_SIZE)
<a name="l223"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc, x, y, snow_tile);
<a name="l224"></a>
<a name="l225"></a> </span><span class=cF1>if</span><span class=cF0> (tf)
<a name="l226"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l227"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l228"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l229"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> - </span><span class=cF7>(</span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>14</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>, </span><span class=cF6>&quot;Game Completed&quot;</span><span class=cF0>);
<a name="l230"></a> tt = tf;
<a name="l231"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l232"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l233"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l234"></a> tt = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l236"></a> dc-&gt;color = </span><span class=cF3>LTBLUE</span><span class=cF0>;
<a name="l237"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;Freezing Peasants:%d Time:%3.2f Best:%3.2f&quot;</span><span class=cF0>, not_stopped_count, tt - t0, best_score);
<a name="l238"></a>}
<a name="l239"></a>
<a name="l240"></a></span><span class=cF1>U0</span><span class=cF0> StepNew(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF1>F64</span><span class=cF0> theta, </span><span class=cF1>Bool</span><span class=cF0> left_right, </span><span class=cF1>Bool</span><span class=cF0> king)
<a name="l241"></a>{
<a name="l242"></a> Step *tmps;
<a name="l243"></a>
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (king)
<a name="l245"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l246"></a> tmps = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l247"></a> tmps-&gt;x = x;
<a name="l248"></a> tmps-&gt;y = y;
<a name="l249"></a> tmps-&gt;t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l250"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, king_step_head.last);
<a name="l251"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l252"></a>
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (left_right)
<a name="l254"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l255"></a> tmps = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l256"></a> tmps-&gt;x = x - </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta) + </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l257"></a> tmps-&gt;y = y + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta) + </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l258"></a> tmps-&gt;t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l259"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, step_head.last);
<a name="l260"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l261"></a> tmps-&gt;x = x - </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta) + </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l262"></a> tmps-&gt;y = y + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta) + </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l263"></a> tmps-&gt;t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l264"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, step_head.last);
<a name="l265"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l266"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l267"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l268"></a> tmps = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l269"></a> tmps-&gt;x = x + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta) + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l270"></a> tmps-&gt;y = y - </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta) + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l271"></a> tmps-&gt;t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l272"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, step_head.last);
<a name="l273"></a> tmps = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l274"></a> tmps-&gt;x = x + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta) + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l275"></a> tmps-&gt;y = y - </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(theta) + </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l276"></a> tmps-&gt;t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l277"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmps, step_head.last);
<a name="l278"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l279"></a>}
<a name="l280"></a>
<a name="l281"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l282"></a>{
<a name="l283"></a> </span><span class=cF9>I64</span><span class=cF0> i, min_x, max_x, min_y, max_y, w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l284"></a> Peasant *tmpp;
<a name="l285"></a>
<a name="l286"></a> snow_x = snow_y = </span><span class=cFE>0</span><span class=cF0>;
<a name="l287"></a> new_snow_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l288"></a> snow_tile = </span><span class=cF5>DCNew</span><span class=cF0>(SNOW_TILE_SIZE, SNOW_TILE_SIZE);
<a name="l289"></a>
<a name="l290"></a> </span><span class=cF5>SpriteExtents</span><span class=cF0>(</span><span class=cFA>&lt;7&gt;</span><span class=cF0>, &amp;min_x, &amp;max_x, &amp;min_y, &amp;max_y);
<a name="l291"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; TREES_NUM; i++)
<a name="l292"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l293"></a> trees[i].x = </span><span class=cF5>RandU16</span><span class=cF0> % (w - </span><span class=cFE>2</span><span class=cF0> * BORDER - </span><span class=cF7>(</span><span class=cF0>max_x - min_x + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>) + BORDER - min_x;
<a name="l294"></a> trees[i].y = </span><span class=cF5>RandU16</span><span class=cF0> % (h - </span><span class=cFE>2</span><span class=cF0> * BORDER - </span><span class=cF7>(</span><span class=cF0>max_y - min_y + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>) + BORDER - min_y;
<a name="l295"></a> trees[i].fire_frame_idx = </span><span class=cFE>0</span><span class=cF0>;
<a name="l296"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l297"></a>
<a name="l298"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;step_head);
<a name="l299"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;king_step_head);
<a name="l300"></a>
<a name="l301"></a> </span><span class=cF5>SpriteExtents</span><span class=cF0>(</span><span class=cFA>&lt;12&gt;</span><span class=cF0>, &amp;min_x, &amp;max_x, &amp;min_y, &amp;max_y);
<a name="l302"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;peasant_head);
<a name="l303"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; PEASANTS_NUM; i++)
<a name="l304"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l305"></a> tmpp = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Peasant</span><span class=cF7>)</span><span class=cF0>);
<a name="l306"></a> tmpp-&gt;x = </span><span class=cF5>RandU16</span><span class=cF0> % (w - </span><span class=cFE>2</span><span class=cF0> * BORDER - </span><span class=cF7>(</span><span class=cF0>max_x - min_x + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>) + BORDER - min_x;
<a name="l307"></a> tmpp-&gt;y = </span><span class=cF5>RandU16</span><span class=cF0> % (h - </span><span class=cFE>2</span><span class=cF0> * BORDER - </span><span class=cF7>(</span><span class=cF0>max_y - min_y + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>) + BORDER - min_y;
<a name="l308"></a> tmpp-&gt;theta = </span><span class=cF3>pi</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0>;
<a name="l309"></a> tmpp-&gt;door_opened_t0 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l310"></a> tmpp-&gt;stopped = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l311"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpp, peasant_head.last);
<a name="l312"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l313"></a> animate_phase = </span><span class=cFE>0</span><span class=cF0>;
<a name="l314"></a> animate_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l315"></a> king_phase = </span><span class=cFE>0</span><span class=cF0>;
<a name="l316"></a> king_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l317"></a> king_timeout = </span><span class=cFE>0</span><span class=cF0>;
<a name="l318"></a> king_x = w / </span><span class=cFE>2</span><span class=cF0>;
<a name="l319"></a> king_y = h / </span><span class=cFE>2</span><span class=cF0>;
<a name="l320"></a> king_theta = -</span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l321"></a> door_open_t0 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l322"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l323"></a> tf = </span><span class=cFE>0</span><span class=cF0>;
<a name="l324"></a>}
<a name="l325"></a>
<a name="l326"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l327"></a>{
<a name="l328"></a> </span><span class=cF5>DCDel</span><span class=cF0>(snow_tile);
<a name="l329"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;peasant_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l330"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;step_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l331"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;king_step_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l332"></a>}
<a name="l333"></a>
<a name="l334"></a></span><span class=cF1>U0</span><span class=cF0> Follow(</span><span class=cF9>CTask</span><span class=cF0> *, Peasant *tmpp)
<a name="l335"></a>{
<a name="l336"></a> Step *tmps = king_step_head.next;
<a name="l337"></a> </span><span class=cF1>F64</span><span class=cF0> d, best_d = </span><span class=cF3>F64_MAX</span><span class=cF0>;
<a name="l338"></a>
<a name="l339"></a> </span><span class=cF1>while</span><span class=cF0> (tmps != &amp;king_step_head)
<a name="l340"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l341"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>d = </span><span class=cF5>Sqr</span><span class=cF0>(tmps-&gt;x - tmpp-&gt;x) + </span><span class=cF5>Sqr</span><span class=cF0>(tmps-&gt;y - tmpp-&gt;y)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; d &lt; </span><span class=cFE>15</span><span class=cF0> * </span><span class=cFE>15</span><span class=cF0>)
<a name="l342"></a> {
<a name="l343"></a> d += </span><span class=cFE>1000</span><span class=cF0> * </span><span class=cF5>Sqr</span><span class=cF0>(</span><span class=cF5>tS</span><span class=cF0> - tmps-&gt;t0);
<a name="l344"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; best_d)
<a name="l345"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l346"></a> best_d = d;
<a name="l347"></a> tmpp-&gt;theta = </span><span class=cF5>Arg</span><span class=cF0>(tmps-&gt;x - tmpp-&gt;x, tmps-&gt;y - tmpp-&gt;y);
<a name="l348"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l349"></a> }
<a name="l350"></a> tmps = tmps-&gt;next;
<a name="l351"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l352"></a>}
<a name="l353"></a>
<a name="l354"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l355"></a>{
<a name="l356"></a> Step *tmps, *tmps1;
<a name="l357"></a> Peasant *tmpp;
<a name="l358"></a> </span><span class=cF9>I64</span><span class=cF0> i, w, h;
<a name="l359"></a>
<a name="l360"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l361"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l362"></a> w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task-&gt;pix_width;
<a name="l363"></a> h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task-&gt;pix_height;
<a name="l364"></a>
<a name="l365"></a> tmps = step_head.next;
<a name="l366"></a> </span><span class=cF1>while</span><span class=cF0> (tmps != &amp;step_head)
<a name="l367"></a> {
<a name="l368"></a> tmps1 = tmps-&gt;next;
<a name="l369"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> - tmps-&gt;t0 &gt; </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l370"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l371"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmps);
<a name="l372"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l373"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l374"></a> tmps = tmps1;
<a name="l375"></a> }
<a name="l376"></a>
<a name="l377"></a> tmps = king_step_head.next;
<a name="l378"></a> </span><span class=cF1>while</span><span class=cF0> (tmps != &amp;king_step_head)
<a name="l379"></a> {
<a name="l380"></a> tmps1 = tmps-&gt;next;
<a name="l381"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> - tmps-&gt;t0 &gt; </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l382"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l383"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmps);
<a name="l384"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l385"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l386"></a> tmps = tmps1;
<a name="l387"></a> }
<a name="l388"></a>
<a name="l389"></a> not_stopped_count = </span><span class=cFE>0</span><span class=cF0>;
<a name="l390"></a> tmpp = peasant_head.next;
<a name="l391"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp != &amp;peasant_head)
<a name="l392"></a> {
<a name="l393"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;stopped)
<a name="l394"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l395"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp-&gt;door_opened_t0 &amp;&amp; </span><span class=cF5>tS</span><span class=cF0> &gt; tmpp-&gt;door_opened_t0 + </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l396"></a> {
<a name="l397"></a> tmpp-&gt;door_opened_t0 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l398"></a> tmpp-&gt;y = tmpp-&gt;x = -</span><span class=cFE>9999</span><span class=cF0>;
<a name="l399"></a> }
<a name="l400"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l401"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l402"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l403"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp-&gt;x - w / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp-&gt;y - h / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>20</span><span class=cF0> * </span><span class=cFE>20</span><span class=cF0>)
<a name="l404"></a> {
<a name="l405"></a> tmpp-&gt;stopped = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l406"></a> tmpp-&gt;door_opened_t0 = door_open_t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l407"></a> }
<a name="l408"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; TREES_NUM; i++) </span><span class=cF2>//Hang-out by fire</span><span class=cF0>
<a name="l409"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx &amp;&amp; </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp-&gt;x - trees[i].x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp-&gt;y - trees[i].y</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>20</span><span class=cF0> * </span><span class=cFE>20</span><span class=cF0>)
<a name="l410"></a> {
<a name="l411"></a> tmpp-&gt;stopped = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l412"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l413"></a> }
<a name="l414"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpp-&gt;stopped)
<a name="l415"></a> {
<a name="l416"></a> Follow(</span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task, tmpp);
<a name="l417"></a> tmpp-&gt;x += </span><span class=cF5>Cos</span><span class=cF0>(tmpp-&gt;theta) / </span><span class=cFE>100</span><span class=cF0>;
<a name="l418"></a> tmpp-&gt;y += </span><span class=cF5>Sin</span><span class=cF0>(tmpp-&gt;theta) / </span><span class=cFE>100</span><span class=cF0>;
<a name="l419"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>BORDER / </span><span class=cFE>2</span><span class=cF0> &lt;= tmpp-&gt;x &lt; w - BORDER / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> || !</span><span class=cF7>(</span><span class=cF0>BORDER / </span><span class=cFE>2</span><span class=cF0> &lt;= tmpp-&gt;y &lt; h - BORDER / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>)
<a name="l420"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l421"></a> tmpp-&gt;theta += </span><span class=cF3>pi</span><span class=cF0>;
<a name="l422"></a> tmpp-&gt;x += </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(tmpp-&gt;theta) / </span><span class=cFE>100</span><span class=cF0>;
<a name="l423"></a> tmpp-&gt;y += </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(tmpp-&gt;theta) / </span><span class=cFE>100</span><span class=cF0>;
<a name="l424"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l425"></a> </span><span class=cF1>if</span><span class=cF0> (!animate_mS &amp;&amp; animate_phase &amp; </span><span class=cFE>1</span><span class=cF0>)
<a name="l426"></a> StepNew(</span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task, tmpp-&gt;x, tmpp-&gt;y, tmpp-&gt;theta, animate_phase &amp; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l427"></a> not_stopped_count++;
<a name="l428"></a> }
<a name="l429"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l430"></a> tmpp = tmpp-&gt;next;
<a name="l431"></a> }
<a name="l432"></a> </span><span class=cF1>if</span><span class=cF0> (!not_stopped_count &amp;&amp; !tf)
<a name="l433"></a> {
<a name="l434"></a> tf = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l435"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l436"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
<a name="l437"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
<a name="l438"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l439"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l440"></a> </span><span class=cF1>if</span><span class=cF0> (tf - t0 &lt; best_score)
<a name="l441"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l442"></a> best_score = tf - t0;
<a name="l443"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
<a name="l444"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
<a name="l445"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l446"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l447"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l448"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l449"></a> }
<a name="l450"></a>
<a name="l451"></a> snow_x += </span><span class=cF5>RandU16</span><span class=cF0> % </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l452"></a> snow_y += </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF5>SignI64</span><span class=cF0>(</span><span class=cF5>RandU16</span><span class=cF0> &amp; </span><span class=cFE>3</span><span class=cF0>);
<a name="l453"></a> </span><span class=cF1>if</span><span class=cF0> (new_snow_mS++ &gt; </span><span class=cFE>8</span><span class=cF0>)
<a name="l454"></a> {
<a name="l455"></a> new_snow_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l456"></a> snow_tile-&gt;color = </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l457"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(snow_tile, </span><span class=cF5>RandU16</span><span class=cF0> &amp; </span><span class=cF7>(</span><span class=cF0>SNOW_TILE_SIZE - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>RandU16</span><span class=cF0> &amp; </span><span class=cF7>(</span><span class=cF0>SNOW_TILE_SIZE - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>);
<a name="l458"></a> }
<a name="l459"></a>
<a name="l460"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l461"></a> </span><span class=cF1>if</span><span class=cF0> (animate_mS++ &gt;= </span><span class=cFE>250</span><span class=cF0>)
<a name="l462"></a> {
<a name="l463"></a> animate_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l464"></a> animate_phase = (animate_phase + </span><span class=cFE>1</span><span class=cF0>) &amp; </span><span class=cFE>3</span><span class=cF0>;
<a name="l465"></a> }
<a name="l466"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &lt; king_timeout)
<a name="l467"></a> {
<a name="l468"></a> </span><span class=cF1>if</span><span class=cF0> (king_mS++ &gt;= </span><span class=cFE>250</span><span class=cF0>)
<a name="l469"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l470"></a> king_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l471"></a> king_phase |= </span><span class=cFE>1</span><span class=cF0>;
<a name="l472"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l473"></a> }
<a name="l474"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l475"></a>}
<a name="l476"></a>
<a name="l477"></a></span><span class=cF1>U0</span><span class=cF0> BurnTrees()
<a name="l478"></a>{
<a name="l479"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l480"></a>
<a name="l481"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; TREES_NUM; i++)
<a name="l482"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>king_x - trees[i].x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>king_y - trees[i].y</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cFE>10</span><span class=cF0> * </span><span class=cFE>10</span><span class=cF0>)
<a name="l483"></a> trees[i].fire_frame_idx = </span><span class=cFE>1</span><span class=cF0>;
<a name="l484"></a>}
<a name="l485"></a>
<a name="l486"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l487"></a>{
<a name="l488"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_end_cb = &amp;</span><span class=cF5>SoundTaskEndCB</span><span class=cF0>;
<a name="l489"></a> </span><span class=cF5>MusicSettingsReset</span><span class=cF0>;
<a name="l490"></a> </span><span class=cFB>music</span><span class=cF0>.tempo = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>480</span><span class=cF0>;
<a name="l491"></a> </span><span class=cFB>music</span><span class=cF0>.stacatto_factor = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>902</span><span class=cF0>;
<a name="l492"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l493"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l494"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eCCCDCC4qGeAGAB5qCC&quot;</span><span class=cF0>);
<a name="l495"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eCCCDCC4qGeAGAB5qCC&quot;</span><span class=cF0>);
<a name="l496"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5eGFEDEDqC4eAGAB5qCC&quot;</span><span class=cF0>);
<a name="l497"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l498"></a>}
<a name="l499"></a>
<a name="l500"></a></span><span class=cF1>U0</span><span class=cF0> Wenceslas()
<a name="l501"></a>{
<a name="l502"></a> </span><span class=cF9>I64</span><span class=cF0> sc;
<a name="l503"></a>
<a name="l504"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l505"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l506"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l507"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l508"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l509"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l510"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l511"></a> </span><span class=cF6>&quot; BurnTree(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l512"></a> </span><span class=cF6>&quot; Up(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l513"></a> </span><span class=cF6>&quot; Down(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l514"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l515"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l516"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l517"></a> );
<a name="l518"></a>
<a name="l519"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l520"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l521"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l522"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l523"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l524"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l525"></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="l526"></a>
<a name="l527"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;</span><span class=cF0>
<a name="l528"></a></span><span class=cF6>Good King Wenceslas looked out</span><span class=cF0>
<a name="l529"></a></span><span class=cF6>On the feast of Stephen</span><span class=cF0>
<a name="l530"></a></span><span class=cF6>When the snow lay round about</span><span class=cF0>
<a name="l531"></a></span><span class=cF6>Deep and crisp and even</span><span class=cF0>
<a name="l532"></a></span><span class=cF6>Brightly shone the moon that night</span><span class=cF0>
<a name="l533"></a></span><span class=cF6>Though the frost was cruel</span><span class=cF0>
<a name="l534"></a></span><span class=cF6>When a poor man came in sight</span><span class=cF0>
<a name="l535"></a></span><span class=cF6>Gath'ring winter fuel</span><span class=cF0>
<a name="l536"></a>
<a name="l537"></a></span><span class=cF6>\&quot;Hither, page, and stand by me</span><span class=cF0>
<a name="l538"></a></span><span class=cF6>If thou know'st it, telling</span><span class=cF0>
<a name="l539"></a></span><span class=cF6>Yonder peasant, who is he?</span><span class=cF0>
<a name="l540"></a></span><span class=cF6>Where and what his dwelling?\&quot;</span><span class=cF0>
<a name="l541"></a></span><span class=cF6>\&quot;Sire, he lives a good league hence</span><span class=cF0>
<a name="l542"></a></span><span class=cF6>Underneath the mountain</span><span class=cF0>
<a name="l543"></a></span><span class=cF6>Right against the forest fence</span><span class=cF0>
<a name="l544"></a></span><span class=cF6>By Saint Agnes' fountain.\&quot;</span><span class=cF0>
<a name="l545"></a>
<a name="l546"></a></span><span class=cF6>\&quot;Bring me flesh and bring me wine</span><span class=cF0>
<a name="l547"></a></span><span class=cF6>Bring me pine logs hither</span><span class=cF0>
<a name="l548"></a></span><span class=cF6>Thou and I will see him dine</span><span class=cF0>
<a name="l549"></a></span><span class=cF6>When we bear him thither.\&quot;</span><span class=cF0>
<a name="l550"></a></span><span class=cF6>Page and monarch forth they went</span><span class=cF0>
<a name="l551"></a></span><span class=cF6>Forth they went together</span><span class=cF0>
<a name="l552"></a></span><span class=cF6>Through the rude wind's wild lament</span><span class=cF0>
<a name="l553"></a></span><span class=cF6>And the bitter weather</span><span class=cF0>
<a name="l554"></a>
<a name="l555"></a></span><span class=cF6>&quot;</span><span class=cF0>);
<a name="l556"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;</span><span class=cF0>
<a name="l557"></a></span><span class=cF6>\&quot;Sire, the night is darker now</span><span class=cF0>
<a name="l558"></a></span><span class=cF6>And the wind blows stronger</span><span class=cF0>
<a name="l559"></a></span><span class=cF6>Fails my heart, I know not how,</span><span class=cF0>
<a name="l560"></a></span><span class=cF6>I can go no longer.\&quot;</span><span class=cF0>
<a name="l561"></a></span><span class=cF6>\&quot;Mark my footsteps, my good page</span><span class=cF0>
<a name="l562"></a></span><span class=cF6>Tread thou in them boldly</span><span class=cF0>
<a name="l563"></a></span><span class=cF6>Thou shalt find the winter's rage</span><span class=cF0>
<a name="l564"></a></span><span class=cF6>Freeze thy blood less coldly.\&quot;</span><span class=cF0>
<a name="l565"></a>
<a name="l566"></a></span><span class=cF6>In his master's steps he trod</span><span class=cF0>
<a name="l567"></a></span><span class=cF6>Where the snow lay dinted</span><span class=cF0>
<a name="l568"></a></span><span class=cF6>Heat was in the very sod</span><span class=cF0>
<a name="l569"></a></span><span class=cF6>Which the Saint had printed</span><span class=cF0>
<a name="l570"></a></span><span class=cF6>Therefore, Christian men, be sure</span><span class=cF0>
<a name="l571"></a></span><span class=cF6>Wealth or rank possessing</span><span class=cF0>
<a name="l572"></a></span><span class=cF6>Ye who now will bless the poor</span><span class=cF0>
<a name="l573"></a></span><span class=cF6>Shall yourselves find blessing</span><span class=cF0>
<a name="l574"></a>
<a name="l575"></a></span><span class=cF6>&quot;</span><span class=cF0>);
<a name="l576"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;</span><span class=cF0>
<a name="l577"></a></span><span class=cF6>$PURPLE$$TX+CX,\&quot;Winceslas Game\&quot;$$FG$</span><span class=cF0>
<a name="l578"></a>
<a name="l579"></a></span><span class=cF6>Start fires by pressing $GREEN$&lt;SPACE&gt;$FG$</span><span class=cF0>
<a name="l580"></a></span><span class=cF6>on trees. (Yule logs)</span><span class=cF0>
<a name="l581"></a>
<a name="l582"></a></span><span class=cF6>Lead peasants to fires.</span><span class=cF0>
<a name="l583"></a></span><span class=cF6>&quot;</span><span class=cF0>);
<a name="l584"></a>
<a name="l585"></a> Init;
<a name="l586"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l587"></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="l588"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l589"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l590"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l591"></a> {
<a name="l592"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>KeyGet</span><span class=cF7>(</span><span class=cF0>&amp;sc</span><span class=cF7>)</span><span class=cF0>)
<a name="l593"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l594"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l595"></a> CleanUp;
<a name="l596"></a> Init;
<a name="l597"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l598"></a>
<a name="l599"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l600"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l601"></a> </span><span class=cF1>goto</span><span class=cF0> ws_done;
<a name="l602"></a>
<a name="l603"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l604"></a> BurnTrees;
<a name="l605"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l606"></a>
<a name="l607"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l608"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l609"></a> {
<a name="l610"></a> </span><span class=cF1>start</span><span class=cF0>:
<a name="l611"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l612"></a> </span><span class=cF1>if</span><span class=cF0> (king_x + KING_STEP &lt; </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width - BORDER)
<a name="l613"></a> king_x += KING_STEP;
<a name="l614"></a> king_theta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l615"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l616"></a>
<a name="l617"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l618"></a> </span><span class=cF1>if</span><span class=cF0> (king_x - KING_STEP &gt;= BORDER)
<a name="l619"></a> king_x -= KING_STEP;
<a name="l620"></a> king_theta = </span><span class=cF3>pi</span><span class=cF0>;
<a name="l621"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l622"></a>
<a name="l623"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l624"></a> </span><span class=cF1>if</span><span class=cF0> (king_y + KING_STEP &lt; </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height - BORDER)
<a name="l625"></a> king_y += KING_STEP;
<a name="l626"></a> king_theta = -</span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l627"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l628"></a>
<a name="l629"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l630"></a> </span><span class=cF1>if</span><span class=cF0> (king_y - KING_STEP &gt;= BORDER)
<a name="l631"></a> king_y -= KING_STEP;
<a name="l632"></a> king_theta = </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l633"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l634"></a> </span><span class=cF1>end</span><span class=cF0>:
<a name="l635"></a> king_mS = </span><span class=cFE>0</span><span class=cF0>;
<a name="l636"></a> king_phase = (king_phase + </span><span class=cFE>2</span><span class=cF0>) &amp; </span><span class=cFE>2</span><span class=cF0>;
<a name="l637"></a> StepNew(</span><span class=cF5>Fs</span><span class=cF0>, king_x, king_y, king_theta, king_phase &amp; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l638"></a> king_timeout = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l639"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l640"></a> }
<a name="l641"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l642"></a> }
<a name="l643"></a>ws_done:
<a name="l644"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l645"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l646"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l647"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l648"></a> CleanUp;
<a name="l649"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l650"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/Wenceslas&quot;</span><span class=cF0>, </span><span class=cF6>&quot;F64 best_score=%5.4f;\n&quot;</span><span class=cF0>, best_score);
<a name="l651"></a>}
<a name="l652"></a>
<a name="l653"></a>Wenceslas;
</span></pre></body>
</html>