templeos-info/public/Wb/Demo/Graphics/WallPaperFish.HC.HTML

147 lines
10 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF2>/* You &quot;Adam include&quot; this because you want the wallpaper</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>routine to stay in mem even if this task is killed.</span><span class=cF0>
<a name="l3"></a>
<a name="l4"></a></span><span class=cF2> &lt;CTRL-t&gt; to see the hidden text needed for sprite elements.</span><span class=cF0>
<a name="l5"></a>
<a name="l6"></a></span><span class=cF2> &lt;CTRL-r&gt; to add a sprite to a document.</span><span class=cF0>
<a name="l7"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l8"></a></span><span class=cFA>
<a name="l9"></a>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l10"></a>
<a name="l11"></a></span><span class=cFA>
<a name="l12"></a>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l13"></a>
<a name="l14"></a></span><span class=cFA>
<a name="l15"></a>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l16"></a>
<a name="l17"></a></span><span class=cFA>
<a name="l18"></a>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a></span><span class=cFA>
<a name="l22"></a>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l23"></a>
<a name="l24"></a>
<a name="l25"></a></span><span class=cFA>
<a name="l26"></a>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a></span><span class=cFA>
<a name="l30"></a>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l31"></a>
<a name="l32"></a></span><span class=cFA>
<a name="l33"></a>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l34"></a>
<a name="l35"></a></span><span class=cFA>
<a name="l36"></a>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l37"></a>
<a name="l38"></a>
<a name="l39"></a>#</span><span class=cF1>define</span><span class=cF0> TYPES_OF_CRITTERS 3
<a name="l40"></a>#</span><span class=cF1>define</span><span class=cF0> FRAMES_PER_CRITTER 4
<a name="l41"></a>
<a name="l42"></a></span><span class=cF1>U8</span><span class=cF0> *imgs[TYPES_OF_CRITTERS][FRAMES_PER_CRITTER]={
<a name="l43"></a> </span><span class=cF7>{</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>,</span><span class=cFA>&lt;2&gt;</span><span class=cF7>}</span><span class=cF0>,
<a name="l44"></a> </span><span class=cF7>{</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>,</span><span class=cFA>&lt;5&gt;</span><span class=cF7>}</span><span class=cF0>,
<a name="l45"></a> </span><span class=cF7>{</span><span class=cFA>&lt;7&gt;</span><span class=cF0>,</span><span class=cFA>&lt;8&gt;</span><span class=cF0>,</span><span class=cFA>&lt;9&gt;</span><span class=cF0>,</span><span class=cFA>&lt;8&gt;</span><span class=cF7>}</span><span class=cF0>
<a name="l46"></a>};
<a name="l47"></a>
<a name="l48"></a>#</span><span class=cF1>define</span><span class=cF0> CRITTERS_NUM 16
<a name="l49"></a></span><span class=cF1>class</span><span class=cF0> Critter
<a name="l50"></a>{
<a name="l51"></a> </span><span class=cF9>I64</span><span class=cF0> x,y,dx,dy,type;
<a name="l52"></a> </span><span class=cF1>F64</span><span class=cF0> t_offset;
<a name="l53"></a>} wall_crits[CRITTERS_NUM];
<a name="l54"></a>
<a name="l55"></a></span><span class=cF1>U0</span><span class=cF0> (*old_wall_paper)(</span><span class=cF9>CTask</span><span class=cF0> *task);
<a name="l56"></a>
<a name="l57"></a></span><span class=cF1>U0</span><span class=cF0> WallPaperFish(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l58"></a>{
<a name="l59"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,x,y;
<a name="l60"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCAlias</span><span class=cF0>(</span><span class=cFB>gr</span><span class=cF0>.dc2,task);
<a name="l61"></a> Critter *c=wall_crits;
<a name="l62"></a>
<a name="l63"></a> task-&gt;text_attr=</span><span class=cF3>CYAN</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l64"></a> dc-&gt;color=</span><span class=cF3>BROWN</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>GR_HEIGHT</span><span class=cF0>;i+=20) </span><span class=cF7>{</span><span class=cF0>
<a name="l66"></a> j=16*</span><span class=cF5>Tri</span><span class=cF0>(</span><span class=cF5>tS</span><span class=cF0>*10,20);
<a name="l67"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,0,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-i-j,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-i-j,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>);
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;CRITTERS_NUM;i++,c++) </span><span class=cF7>{</span><span class=cF0>
<a name="l70"></a> j=(</span><span class=cF5>tS</span><span class=cF0>*4+c-&gt;t_offset)%FRAMES_PER_CRITTER;
<a name="l71"></a> x=c-&gt;x&gt;&gt;16%</span><span class=cF3>GR_WIDTH</span><span class=cF0>;
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (x&lt;0) x+=</span><span class=cF3>GR_WIDTH</span><span class=cF0>;
<a name="l73"></a> y=c-&gt;y&gt;&gt;16%</span><span class=cF3>GR_HEIGHT</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (y&lt;0) y+=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>;
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;dx&lt;0) {
<a name="l76"></a> dc-&gt;flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>;
<a name="l77"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc,x,y-1,x,y+1);
<a name="l78"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l79"></a> dc-&gt;flags&amp;=~(</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>);
<a name="l80"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,x,y,0,imgs[c-&gt;type][j]);
<a name="l81"></a> c-&gt;x+=c-&gt;dx; c-&gt;y+=c-&gt;dy;
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l83"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l84"></a>
<a name="l85"></a> </span><span class=cF2>//Uncomment the following if you wish.</span><span class=cF0>
<a name="l86"></a> </span><span class=cF2>//old_wall_paper(task);</span><span class=cF0>
<a name="l87"></a>}
<a name="l88"></a>
<a name="l89"></a></span><span class=cF1>U0</span><span class=cF0> WallInit()
<a name="l90"></a>{
<a name="l91"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l92"></a> Critter *c;
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>!=</span><span class=cFB>adam_task</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l94"></a> </span><span class=cF6>&quot;Must be Adam Included with SHIFT-F5.\n&quot;</span><span class=cF0>
<a name="l95"></a> </span><span class=cF6>&quot;(Would crash when code mem was freed.)\n&quot;</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l98"></a> old_wall_paper=</span><span class=cFB>gr</span><span class=cF0>.fp_wall_paper;
<a name="l99"></a> c=wall_crits;
<a name="l100"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;CRITTERS_NUM;i++,c++) </span><span class=cF7>{</span><span class=cF0>
<a name="l101"></a> c-&gt;x=(</span><span class=cF5>RandU16</span><span class=cF0>%</span><span class=cF3>GR_WIDTH</span><span class=cF0>)&lt;&lt;16;
<a name="l102"></a> c-&gt;y=(</span><span class=cF5>RandU16</span><span class=cF0>%</span><span class=cF3>GR_HEIGHT</span><span class=cF0>)&lt;&lt;16;
<a name="l103"></a> c-&gt;type=</span><span class=cF5>RandU16</span><span class=cF0>%TYPES_OF_CRITTERS;
<a name="l104"></a> c-&gt;dx=</span><span class=cF5>RandI16</span><span class=cF0>;
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;dx&lt;0)
<a name="l106"></a> c-&gt;dx-=0x4000;
<a name="l107"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l108"></a> c-&gt;dx+=0x4000;
<a name="l109"></a> c-&gt;dy=</span><span class=cF5>RandI16</span><span class=cF0>;
<a name="l110"></a> c-&gt;t_offset=</span><span class=cF5>Rand</span><span class=cF0>*FRAMES_PER_CRITTER;
<a name="l111"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l112"></a> </span><span class=cFB>gr</span><span class=cF0>.fp_wall_paper=&amp;WallPaperFish;
<a name="l113"></a>}
<a name="l114"></a>
<a name="l115"></a>WallInit;
</span></pre></body>
</html>