ZealOS/docs/Demo/Graphics/FontEd.CC.html
2021-07-25 04:07:40 -04:00

206 lines
21 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.10">
<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=cF2>/*After making a font...</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF2>You can save it as a binary file with:</span><span class=cF0>
<a name="l4"></a>
<a name="l5"></a> </span><span class=cF2>FileWrite(&quot;filename.BIN&quot;, text.font, 256 * FONT_HEIGHT);</span><span class=cF0>
<a name="l6"></a>
<a name="l7"></a></span><span class=cF2>You can load it with:</span><span class=cF0>
<a name="l8"></a>
<a name="l9"></a> </span><span class=cF2>U64 *my_font = FileRead(&quot;filename.BIN&quot;);</span><span class=cF0>
<a name="l10"></a> </span><span class=cF2>text.aux_font = my_font;</span><span class=cF0>
<a name="l11"></a>
<a name="l12"></a></span><span class=cF2>&lt;CTRL-ALT-f&gt; will toggle main font and aux_font.</span><span class=cF0>
<a name="l13"></a>
<a name="l14"></a></span><span class=cF2>If you want to change the system font permanently,</span><span class=cF0>
<a name="l15"></a></span><span class=cF2>save to a file with this font editor program</span><span class=cF0>
<a name="l16"></a></span><span class=cF2>and cut and paste the code into </span><a href="https://tomawezome.github.io/ZealOS/Kernel/FontStd.CC.html#l1"><span class=cF4>::/Kernel/FontStd.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l17"></a></span><span class=cF2>You will need to recompile Kernel by calling </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHDIns.CC.html#l25"><span class=cF4>BootHDIns</span></a><span class=cF2>().</span><span class=cF0>
<a name="l18"></a>
<a name="l19"></a></span><span class=cF2>See </span><a href="https://tomawezome.github.io/ZealOS/Demo/ExtChars.CC.html#l1"><span class=cF4>::/Demo/ExtChars.CC</span></a><span class=cF2>, </span><a href="https://tomawezome.github.io/ZealOS/Demo/Games/CharDemo.CC.html#l1"><span class=cF4>::/Demo/Games/CharDemo.CC</span></a><span class=cF2>,</span><span class=cF4>
<a name="l20"></a></span><a href="https://tomawezome.github.io/ZealOS/Demo/Graphics/CharAnimation.CC.html#l1"><span class=cF4>::/Demo/Graphics/CharAnimation.CC</span></a><span class=cF2> and </span><a href="https://tomawezome.github.io/ZealOS/Demo/ScreenCodes.CC.html#l1"><span class=cF4>::/Demo/ScreenCodes.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l21"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l22"></a>
<a name="l23"></a>#</span><span class=cF1>define</span><span class=cF0> BLOW_UP_CHAR_X (</span><span class=cFE>18</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF0>)
<a name="l24"></a>#</span><span class=cF1>define</span><span class=cF0> BLOW_UP_CHAR_Y (</span><span class=cFE>4</span><span class=cF0> * </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
<a name="l25"></a>
<a name="l26"></a></span><span class=cF1>U8</span><span class=cF0> cur_ch;
<a name="l27"></a>
<a name="l28"></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="l29"></a>{
<a name="l30"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, k, c;
<a name="l31"></a>
<a name="l32"></a> </span><span class=cF5>TextPrint</span><span class=cF0>(task, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>BLUE</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF6>&quot;Press &lt;CTRL-ALT-f&gt; to Toggle Aux Font.&quot;</span><span class=cF0>);
<a name="l33"></a> k = </span><span class=cFE>0</span><span class=cF0>;
<a name="l34"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFE>16</span><span class=cF0>; i++)
<a name="l35"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cFE>16</span><span class=cF0>; j++)
<a name="l36"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (k == cur_ch)
<a name="l38"></a> {
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l40"></a> c = (</span><span class=cF3>BLUE</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>YELLOW</span><span class=cF0>) &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + k++;
<a name="l41"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l42"></a> c = (</span><span class=cF3>YELLOW</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>BLUE</span><span class=cF0>) &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + k++;
<a name="l43"></a> }
<a name="l44"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l45"></a> c = (</span><span class=cF3>BLUE</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>WHITE</span><span class=cF0>) &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + k++;
<a name="l46"></a> </span><span class=cF5>TextChar</span><span class=cF0>(task,, j, i + </span><span class=cFE>2</span><span class=cF0>, c);
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l48"></a>
<a name="l49"></a> k = </span><span class=cFE>0</span><span class=cF0>;
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>; i++)
<a name="l51"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cF3>FONT_WIDTH</span><span class=cF0>; j++)
<a name="l52"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch], k++</span><span class=cF7>)</span><span class=cF0>)
<a name="l54"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l55"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l56"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l57"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, BLOW_UP_CHAR_X + j * </span><span class=cF3>FONT_WIDTH</span><span class=cF0>,
<a name="l58"></a> BLOW_UP_CHAR_Y + i * </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,
<a name="l59"></a> </span><span class=cF3>FONT_WIDTH</span><span class=cF0>, </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>);
<a name="l60"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l61"></a>}
<a name="l62"></a>
<a name="l63"></a></span><span class=cF1>U0</span><span class=cF0> FESave(</span><span class=cF1>Bool</span><span class=cF0> prompt)
<a name="l64"></a>{
<a name="l65"></a> </span><span class=cF1>U8</span><span class=cF0> old_draw_it = </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it;
<a name="l66"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocNew</span><span class=cF0>;
<a name="l67"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l68"></a>
<a name="l69"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFE>256</span><span class=cF0>; i++)
<a name="l70"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;0x%016X,&quot;</span><span class=cF0>, </span><span class=cFB>text</span><span class=cF0>.font[i]);
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_safe_dollar</span><span class=cF0>, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l73"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;//%c&quot;</span><span class=cF0>, i);
<a name="l74"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i == </span><span class=cF6>'$'</span><span class=cF0>)
<a name="l75"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;//$$&quot;</span><span class=cF0>, i);
<a name="l76"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\n&quot;</span><span class=cF0>);
<a name="l77"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l78"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc, prompt);
<a name="l80"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it = old_draw_it;
<a name="l81"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l82"></a>}
<a name="l83"></a>
<a name="l84"></a></span><span class=cF1>U0</span><span class=cF0> FontEd()
<a name="l85"></a>{
<a name="l86"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, arg1, arg2, k;
<a name="l87"></a>
<a name="l88"></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="l89"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l90"></a> </span><span class=cF6>&quot; SaveAs(,CH_CTRLA);&quot;</span><span class=cF0>
<a name="l91"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l92"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l93"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>);
<a name="l94"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l95"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit |= </span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
<a name="l98"></a> cur_ch = </span><span class=cFE>0</span><span class=cF0>;
<a name="l99"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l100"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l101"></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="l102"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l103"></a> {
<a name="l104"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code = </span><span class=cF5>MessageGet</span><span class=cF7>(</span><span class=cF0>&amp;arg1, &amp;arg2, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0> |
<a name="l105"></a> </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF7>)</span><span class=cF0>)
<a name="l106"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l107"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
<a name="l108"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
<a name="l109"></a> {
<a name="l110"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l111"></a> </span><span class=cF1>switch</span><span class=cF0> (arg2.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l112"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l113"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l114"></a> cur_ch--;
<a name="l115"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l116"></a>
<a name="l117"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l118"></a> cur_ch++;
<a name="l119"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l120"></a>
<a name="l121"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l122"></a> cur_ch -= </span><span class=cFE>16</span><span class=cF0>;
<a name="l123"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l124"></a>
<a name="l125"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l126"></a> cur_ch += </span><span class=cFE>16</span><span class=cF0>;
<a name="l127"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l128"></a>
<a name="l129"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l130"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l131"></a> </span><span class=cF1>goto</span><span class=cF0> fe_done;
<a name="l132"></a>
<a name="l133"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLA</span><span class=cF0>:
<a name="l134"></a> FESave(</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l135"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l136"></a>
<a name="l137"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l138"></a> FESave(</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l139"></a>
<a name="l140"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l141"></a> </span><span class=cF1>goto</span><span class=cF0> fe_done;
<a name="l142"></a>
<a name="l143"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l144"></a> cur_ch = arg1;
<a name="l145"></a> }
<a name="l146"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l147"></a>
<a name="l148"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
<a name="l149"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>:
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> &lt;= arg1 &lt; </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>16</span><span class=cF0> &amp;&amp; </span><span class=cFE>0</span><span class=cF0> &lt;= arg2 - </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> &lt; </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> * </span><span class=cFE>16</span><span class=cF0>)
<a name="l151"></a> {
<a name="l152"></a> cur_ch = (arg2 / </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>) * </span><span class=cFE>16</span><span class=cF0> + arg1 / </span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l153"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l154"></a> }
<a name="l155"></a> </span><span class=cF2>//fall through</span><span class=cF0>
<a name="l156"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_MOVE</span><span class=cF0>:
<a name="l157"></a> k = (</span><span class=cF7>(</span><span class=cF0>arg2 - BLOW_UP_CHAR_Y</span><span class=cF7>)</span><span class=cF0> / </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>) * </span><span class=cF3>FONT_WIDTH</span><span class=cF0> + (arg1 - BLOW_UP_CHAR_X) / </span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l158"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> &lt;= k &lt; </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
<a name="l159"></a> {
<a name="l160"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mouse</span><span class=cF0>.lb || message_code == </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>)
<a name="l161"></a> </span><span class=cF5>Bts</span><span class=cF0>(&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch], k);
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mouse</span><span class=cF0>.rb || message_code == </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>)
<a name="l163"></a> </span><span class=cF5>Btr</span><span class=cF0>(&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch], k);
<a name="l164"></a> }
<a name="l165"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l166"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l167"></a> }
<a name="l168"></a>fe_done:
<a name="l169"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
<a name="l170"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l171"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l172"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l173"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l174"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l175"></a>}
<a name="l176"></a>
<a name="l177"></a>FontEd;
</span></pre></body>
</html>