templeos-info/public/Wb/Apps/ToTheFront/ToTheFront.HC.HTML

246 lines
20 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> AnimationDelaySet()
<a name="l2"></a>{
<a name="l3"></a> animation_delay=</span><span class=cF5>PopUpRangeF64</span><span class=cF0>(0,100,25,</span><span class=cF6>&quot;%3f% %%&quot;</span><span class=cF0>,</span><span class=cF6>&quot;Animation Delay\n&quot;</span><span class=cF0>)/100;
<a name="l4"></a>}
<a name="l5"></a>
<a name="l6"></a></span><span class=cF1>U0</span><span class=cF0> TurnNew()
<a name="l7"></a>{
<a name="l8"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l9"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;2;j++)
<a name="l10"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;UNITS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l11"></a> units[j][i].remaining_movement=units[j][i].movement;
<a name="l12"></a> units[j][i].fired=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l13"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l14"></a> phase=PHASE_START;
<a name="l15"></a> moving_unit=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l16"></a>
<a name="l17"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(msg_off_timeout);
<a name="l18"></a> msg_off_timeout=</span><span class=cFB>cnts</span><span class=cF0>.jiffies+</span><span class=cF3>JIFFY_FREQ</span><span class=cF0>*2*animation_delay+1;
<a name="l19"></a> </span><span class=cF5>Snd</span><span class=cF0>(74);
<a name="l20"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(msg_buf,</span><span class=cF6>&quot;Turn %d&quot;</span><span class=cF0>,++turn);
<a name="l21"></a> VRSetUp(0);
<a name="l22"></a> VRSetUp(1);
<a name="l23"></a> VisRecalc(VR_ALL_UNITS);
<a name="l24"></a> cur_player=(turn&amp;1)^1;
<a name="l25"></a> enemy_player=cur_player^1;
<a name="l26"></a>}
<a name="l27"></a>
<a name="l28"></a></span><span class=cF1>U0</span><span class=cF0> PhaseNew()
<a name="l29"></a>{
<a name="l30"></a> cur_player^=1;
<a name="l31"></a> enemy_player=cur_player^1;
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (++phase&gt;=PHASE_END) </span><span class=cF7>{</span><span class=cF0>
<a name="l33"></a> IndirectResolveAll;
<a name="l34"></a> TurnNew;
<a name="l35"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l36"></a>
<a name="l37"></a> </span><span class=cF5>SleepUntil</span><span class=cF0>(msg_off_timeout);
<a name="l38"></a> msg_off_timeout=</span><span class=cFB>cnts</span><span class=cF0>.jiffies+</span><span class=cF3>JIFFY_FREQ</span><span class=cF0>*2*animation_delay+1;
<a name="l39"></a> </span><span class=cF5>Snd</span><span class=cF0>(74);
<a name="l40"></a> </span><span class=cF1>switch</span><span class=cF0> (phase) </span><span class=cF7>{</span><span class=cF0>
<a name="l41"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_INDIRECT0:
<a name="l42"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_INDIRECT1:
<a name="l43"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(msg_buf,</span><span class=cF6>&quot;Player %d Artillery Plot&quot;</span><span class=cF0>,cur_player+1);
<a name="l44"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l45"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_MOVE0:
<a name="l46"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_MOVE1:
<a name="l47"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(msg_buf,</span><span class=cF6>&quot;Player %d Move&quot;</span><span class=cF0>,cur_player+1);
<a name="l48"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l49"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_DIRECT0:
<a name="l50"></a> </span><span class=cF1>case</span><span class=cF0> PHASE_DIRECT1:
<a name="l51"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(msg_buf,</span><span class=cF6>&quot;Player %d Fire&quot;</span><span class=cF0>,cur_player+1);
<a name="l52"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l53"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l54"></a>}
<a name="l55"></a>
<a name="l56"></a></span><span class=cF1>U0</span><span class=cF0> CharDo(</span><span class=cF1>U8</span><span class=cF0> ch)
<a name="l57"></a>{
<a name="l58"></a> </span><span class=cF9>I64</span><span class=cF0> old_inhibit,old_draw_it;
<a name="l59"></a> </span><span class=cF1>Bool</span><span class=cF0> old_cursor;
<a name="l60"></a> </span><span class=cF1>switch</span><span class=cF0> (ch) </span><span class=cF7>{</span><span class=cF0>
<a name="l61"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l62"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l63"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'ExitGame'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l64"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l65"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'PhaseOvr'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l66"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l67"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'NewGame'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l68"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'1'</span><span class=cF0>:
<a name="l69"></a> ViewPlayerSet(0);
<a name="l70"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l71"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'2'</span><span class=cF0>:
<a name="l72"></a> ViewPlayerSet(1);
<a name="l73"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
<a name="l75"></a> old_draw_it=</span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it;
<a name="l76"></a> old_inhibit=</span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit;
<a name="l77"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=</span><span class=cF5>Fs</span><span class=cF0>-&gt;next_settings-&gt;draw_it;
<a name="l78"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit=</span><span class=cF3>WIG_USER_TASK_DFT</span><span class=cF0>;
<a name="l79"></a> old_cursor=</span><span class=cF5>DocCursor</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
<a name="l80"></a> </span><span class=cF5>DocBottom</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF6>&quot;\n$GREEN$&lt;SHIFT-ESC&gt;$FG$ to return to game.\n&quot;</span><span class=cF0>;
<a name="l82"></a> </span><span class=cF5>View</span><span class=cF0>;
<a name="l83"></a> </span><span class=cF5>DocBottom</span><span class=cF0>;
<a name="l84"></a> </span><span class=cF5>DocCursor</span><span class=cF0>(old_cursor);
<a name="l85"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit=old_inhibit;
<a name="l86"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=old_draw_it;
<a name="l87"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
<a name="l89"></a> AnimationDelaySet;
<a name="l90"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l92"></a>}
<a name="l93"></a>
<a name="l94"></a></span><span class=cF1>U0</span><span class=cF0> UserChk()
<a name="l95"></a>{
<a name="l96"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (!alive_cnt[0] || !alive_cnt[1])
<a name="l98"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'GameOver'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l99"></a> </span><span class=cF1>if</span><span class=cF0> (ch=</span><span class=cF5>ScanChar</span><span class=cF0>)
<a name="l100"></a> CharDo(ch);
<a name="l101"></a>}
<a name="l102"></a>
<a name="l103"></a></span><span class=cF1>U0</span><span class=cF0> TaskEndCB()
<a name="l104"></a>{
<a name="l105"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l106"></a> </span><span class=cFB>progress4</span><span class=cF0>=</span><span class=cFB>progress4_max</span><span class=cF0>=</span><span class=cFB>progress1</span><span class=cF0>=</span><span class=cFB>progress1_max</span><span class=cF0>=0;
<a name="l107"></a> </span><span class=cF5>Exit</span><span class=cF0>;
<a name="l108"></a>}
<a name="l109"></a>
<a name="l110"></a></span><span class=cF9>I64</span><span class=cF0> PhaseDo()
<a name="l111"></a>{
<a name="l112"></a> </span><span class=cF9>I64</span><span class=cF0> res=</span><span class=cF6>'ExitGame'</span><span class=cF0>;
<a name="l113"></a> PhaseNew;
<a name="l114"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (phase&amp;~1==PHASE_INDIRECT)
<a name="l116"></a> </span><span class=cF5>Call</span><span class=cF0>(player_indirect[cur_player]);
<a name="l117"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (phase&amp;~1==PHASE_MOVE)
<a name="l118"></a> </span><span class=cF5>Call</span><span class=cF0>(player_move[cur_player]);
<a name="l119"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l120"></a> </span><span class=cF5>Call</span><span class=cF0>(player_direct[cur_player]);
<a name="l121"></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="l122"></a> res=</span><span class=cF5>Fs</span><span class=cF0>-&gt;except_ch;
<a name="l123"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l124"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l125"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l126"></a>}
<a name="l127"></a>
<a name="l128"></a></span><span class=cF1>U0</span><span class=cF0> ToTheFront()
<a name="l129"></a>{
<a name="l130"></a> </span><span class=cF9>I64</span><span class=cF0> res,ch;
<a name="l131"></a> map_dc=</span><span class=cF5>DCNew</span><span class=cF0>(MAP_WIDTH,MAP_HEIGHT);
<a name="l132"></a>
<a name="l133"></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="l134"></a> </span><span class=cF5>Cd</span><span class=cF0>(</span><span class=cF3>__DIR__</span><span class=cF0>);
<a name="l135"></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="l136"></a>
<a name="l137"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l138"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l139"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l140"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l141"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l142"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l143"></a> </span><span class=cF6>&quot; EndPhase(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l144"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l145"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l146"></a> </span><span class=cF6>&quot;View {&quot;</span><span class=cF0>
<a name="l147"></a> </span><span class=cF6>&quot; Player1(,'1');&quot;</span><span class=cF0>
<a name="l148"></a> </span><span class=cF6>&quot; Player2(,'2');&quot;</span><span class=cF0>
<a name="l149"></a> </span><span class=cF6>&quot; OddsCalculations(,'c');&quot;</span><span class=cF0>
<a name="l150"></a> </span><span class=cF6>&quot; LOS(,0,SCF_SHIFT);&quot;</span><span class=cF0>
<a name="l151"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l152"></a> </span><span class=cF6>&quot;Settings {&quot;</span><span class=cF0>
<a name="l153"></a> </span><span class=cF6>&quot; AnimationDelay(,'d');&quot;</span><span class=cF0>
<a name="l154"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l155"></a> );
<a name="l156"></a>
<a name="l157"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l158"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l159"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l160"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l161"></a> </span><span class=cF5>DocMax</span><span class=cF0>;
<a name="l162"></a> Init;
<a name="l163"></a> PlayerPick(</span><span class=cF6>&quot;AIs&quot;</span><span class=cF0>,0);
<a name="l164"></a> PlayerPick(</span><span class=cF6>&quot;AIs&quot;</span><span class=cF0>,1);
<a name="l165"></a>
<a name="l166"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;$PURPLE$$TX+CX,\&quot;ToTheFront\&quot;$$FG$\n\n&quot;</span><span class=cF0>
<a name="l167"></a> </span><span class=cF6>&quot;$GREEN${Left-click}$FG$ to move or fire units.\n&quot;</span><span class=cF0>
<a name="l168"></a> </span><span class=cF6>&quot;$GREEN$&lt;SPACE&gt;$FG$\tor $GREEN${Right-click}$FG$ to end phase.\n&quot;</span><span class=cF0>
<a name="l169"></a> </span><span class=cF6>&quot;$GREEN$&lt;SHIFT&gt;$FG$\tto show line-of-sight.\n&quot;</span><span class=cF0>
<a name="l170"></a> </span><span class=cF6>&quot;$GREEN$&lt;ENTER&gt;$FG$\tto start new game.\n&quot;</span><span class=cF0>
<a name="l171"></a> </span><span class=cF6>&quot;$GREEN$ 1$FG$\tPlayer 1 view.\n&quot;</span><span class=cF0>
<a name="l172"></a> </span><span class=cF6>&quot;$GREEN$ 2$FG$\tPlayer 2 view.\n&quot;</span><span class=cF0>
<a name="l173"></a> </span><span class=cF6>&quot;$GREEN$ c$FG$\tView odds calculations.\n&quot;</span><span class=cF0>
<a name="l174"></a> </span><span class=cF6>&quot;$GREEN$ d$FG$\tSet animation delay.&quot;</span><span class=cF0>);
<a name="l175"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_end_cb=&amp;TaskEndCB; </span><span class=cF2>//&lt;CTRL-ALT-x&gt;</span><span class=cF0>
<a name="l176"></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="l177"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l178"></a> </span><span class=cF1>do</span><span class=cF0> {
<a name="l179"></a> res=PhaseDo;
<a name="l180"></a> </span><span class=cF1>if</span><span class=cF0> (res==</span><span class=cF6>'GameOver'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l181"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l182"></a> msg_off_timeout=0;
<a name="l183"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(msg_buf,</span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l184"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l185"></a> ch=</span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'\n'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l187"></a> CleanUp;
<a name="l188"></a> Init;
<a name="l189"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l190"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF3>CH_ESC</span><span class=cF0> || ch==</span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l191"></a> res=</span><span class=cF6>'ExitGame'</span><span class=cF0>;
<a name="l192"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l193"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'1'</span><span class=cF0>)
<a name="l194"></a> ViewPlayerSet(0);
<a name="l195"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'2'</span><span class=cF0>)
<a name="l196"></a> ViewPlayerSet(1);
<a name="l197"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'d'</span><span class=cF0>)
<a name="l198"></a> AnimationDelaySet;
<a name="l199"></a> }
<a name="l200"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (res==</span><span class=cF6>'NewGame'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l201"></a> CleanUp;
<a name="l202"></a> Init;
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l204"></a> } </span><span class=cF1>while</span><span class=cF0> (res!=</span><span class=cF6>'ExitGame'</span><span class=cF0>);
<a name="l205"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l206"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l207"></a> </span><span class=cF5>ProgressBarsRst</span><span class=cF0>;
<a name="l208"></a>
<a name="l209"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l210"></a> </span><span class=cF5>DCDel</span><span class=cF0>(map_dc);
<a name="l211"></a> CleanUp;
<a name="l212"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l213"></a> </span><span class=cF5>Seed</span><span class=cF0>;
<a name="l214"></a>}
</span></pre></body>
</html>