1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
6 <!-- 2023-09-19 Tue 18:07 -->
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8 <meta name="viewport" content="width=device-width, initial-scale=1" />
9 <title>Fifth - virtual machine, operating system, programming language</title>
10 <meta name="author" content="Svjatoslav Agejenko" />
11 <meta name="generator" content="Org Mode" />
13 #content { max-width: 60em; margin: auto; }
14 .title { text-align: center;
15 margin-bottom: .2em; }
16 .subtitle { text-align: center;
20 .todo { font-family: monospace; color: red; }
21 .done { font-family: monospace; color: green; }
22 .priority { font-family: monospace; color: orange; }
23 .tag { background-color: #eee; font-family: monospace;
24 padding: 2px; font-size: 80%; font-weight: normal; }
25 .timestamp { color: #bebebe; }
26 .timestamp-kwd { color: #5f9ea0; }
27 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
28 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
29 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
30 .underline { text-decoration: underline; }
31 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
32 p.verse { margin-left: 3%; }
34 border: 1px solid #e6e6e6;
36 background-color: #f2f2f2;
38 font-family: monospace;
53 background-color: #f2f2f299;
55 pre.src:hover:before { display: inline; margin-top: 14px;}
56 /* Languages per Org manual */
57 pre.src-asymptote:before { content: 'Asymptote'; }
58 pre.src-awk:before { content: 'Awk'; }
59 pre.src-authinfo::before { content: 'Authinfo'; }
60 pre.src-C:before { content: 'C'; }
61 /* pre.src-C++ doesn't work in CSS */
62 pre.src-clojure:before { content: 'Clojure'; }
63 pre.src-css:before { content: 'CSS'; }
64 pre.src-D:before { content: 'D'; }
65 pre.src-ditaa:before { content: 'ditaa'; }
66 pre.src-dot:before { content: 'Graphviz'; }
67 pre.src-calc:before { content: 'Emacs Calc'; }
68 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
69 pre.src-fortran:before { content: 'Fortran'; }
70 pre.src-gnuplot:before { content: 'gnuplot'; }
71 pre.src-haskell:before { content: 'Haskell'; }
72 pre.src-hledger:before { content: 'hledger'; }
73 pre.src-java:before { content: 'Java'; }
74 pre.src-js:before { content: 'Javascript'; }
75 pre.src-latex:before { content: 'LaTeX'; }
76 pre.src-ledger:before { content: 'Ledger'; }
77 pre.src-lisp:before { content: 'Lisp'; }
78 pre.src-lilypond:before { content: 'Lilypond'; }
79 pre.src-lua:before { content: 'Lua'; }
80 pre.src-matlab:before { content: 'MATLAB'; }
81 pre.src-mscgen:before { content: 'Mscgen'; }
82 pre.src-ocaml:before { content: 'Objective Caml'; }
83 pre.src-octave:before { content: 'Octave'; }
84 pre.src-org:before { content: 'Org mode'; }
85 pre.src-oz:before { content: 'OZ'; }
86 pre.src-plantuml:before { content: 'Plantuml'; }
87 pre.src-processing:before { content: 'Processing.js'; }
88 pre.src-python:before { content: 'Python'; }
89 pre.src-R:before { content: 'R'; }
90 pre.src-ruby:before { content: 'Ruby'; }
91 pre.src-sass:before { content: 'Sass'; }
92 pre.src-scheme:before { content: 'Scheme'; }
93 pre.src-screen:before { content: 'Gnu Screen'; }
94 pre.src-sed:before { content: 'Sed'; }
95 pre.src-sh:before { content: 'shell'; }
96 pre.src-sql:before { content: 'SQL'; }
97 pre.src-sqlite:before { content: 'SQLite'; }
98 /* additional languages in org.el's org-babel-load-languages alist */
99 pre.src-forth:before { content: 'Forth'; }
100 pre.src-io:before { content: 'IO'; }
101 pre.src-J:before { content: 'J'; }
102 pre.src-makefile:before { content: 'Makefile'; }
103 pre.src-maxima:before { content: 'Maxima'; }
104 pre.src-perl:before { content: 'Perl'; }
105 pre.src-picolisp:before { content: 'Pico Lisp'; }
106 pre.src-scala:before { content: 'Scala'; }
107 pre.src-shell:before { content: 'Shell Script'; }
108 pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
109 /* additional language identifiers per "defun org-babel-execute"
111 pre.src-cpp:before { content: 'C++'; }
112 pre.src-abc:before { content: 'ABC'; }
113 pre.src-coq:before { content: 'Coq'; }
114 pre.src-groovy:before { content: 'Groovy'; }
115 /* additional language identifiers from org-babel-shell-names in
116 ob-shell.el: ob-shell is the only babel language using a lambda to put
117 the execution function name together. */
118 pre.src-bash:before { content: 'bash'; }
119 pre.src-csh:before { content: 'csh'; }
120 pre.src-ash:before { content: 'ash'; }
121 pre.src-dash:before { content: 'dash'; }
122 pre.src-ksh:before { content: 'ksh'; }
123 pre.src-mksh:before { content: 'mksh'; }
124 pre.src-posh:before { content: 'posh'; }
125 /* Additional Emacs modes also supported by the LaTeX listings package */
126 pre.src-ada:before { content: 'Ada'; }
127 pre.src-asm:before { content: 'Assembler'; }
128 pre.src-caml:before { content: 'Caml'; }
129 pre.src-delphi:before { content: 'Delphi'; }
130 pre.src-html:before { content: 'HTML'; }
131 pre.src-idl:before { content: 'IDL'; }
132 pre.src-mercury:before { content: 'Mercury'; }
133 pre.src-metapost:before { content: 'MetaPost'; }
134 pre.src-modula-2:before { content: 'Modula-2'; }
135 pre.src-pascal:before { content: 'Pascal'; }
136 pre.src-ps:before { content: 'PostScript'; }
137 pre.src-prolog:before { content: 'Prolog'; }
138 pre.src-simula:before { content: 'Simula'; }
139 pre.src-tcl:before { content: 'tcl'; }
140 pre.src-tex:before { content: 'TeX'; }
141 pre.src-plain-tex:before { content: 'Plain TeX'; }
142 pre.src-verilog:before { content: 'Verilog'; }
143 pre.src-vhdl:before { content: 'VHDL'; }
144 pre.src-xml:before { content: 'XML'; }
145 pre.src-nxml:before { content: 'XML'; }
146 /* add a generic configuration mode; LaTeX export needs an additional
147 (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
148 pre.src-conf:before { content: 'Configuration File'; }
150 table { border-collapse:collapse; }
151 caption.t-above { caption-side: top; }
152 caption.t-bottom { caption-side: bottom; }
153 td, th { vertical-align:top; }
154 th.org-right { text-align: center; }
155 th.org-left { text-align: center; }
156 th.org-center { text-align: center; }
157 td.org-right { text-align: right; }
158 td.org-left { text-align: left; }
159 td.org-center { text-align: center; }
160 dt { font-weight: bold; }
161 .footpara { display: inline; }
162 .footdef { margin-bottom: 1em; }
163 .figure { padding: 1em; }
164 .figure p { text-align: center; }
165 .equation-container {
171 vertical-align: middle;
176 vertical-align: middle;
180 border: 2px solid gray;
185 { text-align: right; font-size: 70%; white-space: nowrap; }
186 textarea { overflow-x: auto; }
187 .linenr { font-size: smaller }
188 .code-highlighted { background-color: #ffff00; }
189 .org-info-js_info-navigation { border-style: none; }
190 #org-info-js_console-label
191 { font-size: 10px; font-weight: bold; white-space: nowrap; }
192 .org-info-js_search-highlight
193 { background-color: #ffff00; color: #000000; font-weight: bold; }
196 <link rel="stylesheet" type="text/css" href="https://thomasf.github.io/solarized-css/solarized-dark.min.css" />
199 <div id="content" class="content">
200 <h1 class="title">Fifth - virtual machine, operating system, programming language</h1>
201 <div id="table-of-contents" role="doc-toc">
202 <h2>Table of Contents</h2>
203 <div id="text-table-of-contents" role="doc-toc">
205 <li><a href="#orgdd8d5a0">1. General</a>
207 <li><a href="#org11b4b95">1.1. Source code</a></li>
210 <li><a href="#org0a3946b">2. !Project deprecated!</a></li>
211 <li><a href="#org74c9861">3. Introduction</a>
213 <li><a href="#orge8b459e">3.1. Screenshots</a></li>
216 <li><a href="#orga9dfaee">4. Installation</a></li>
217 <li><a href="#orgefa2f79">5. Fifth distribution directory tree description</a></li>
218 <li><a href="#org751040b">6. Requirements</a>
220 <li><a href="#org32f0917">6.1. Software</a></li>
221 <li><a href="#orgd6ecfe1">6.2. Hardware</a></li>
224 <li><a href="#orgeb3cbc2">7. Numbers representation within Fifth</a></li>
225 <li><a href="#orga8a8f37">8. Disk file map, and it's data structures</a>
227 <li><a href="#org4eb67fc">8.1. Disk allocation</a></li>
228 <li><a href="#org5fcae51">8.2. FAT entry format:</a></li>
229 <li><a href="#org811dc5b">8.3. File entry format</a></li>
232 <li><a href="#orga49dca9">9. Core architecture</a>
234 <li><a href="#org75e80d5">9.1. Dictionary entry format</a></li>
235 <li><a href="#org12381ef">9.2. Possible module types</a></li>
236 <li><a href="#org33be039">9.3. Memory map</a></li>
239 <li><a href="#org81fd544">10. Dynamically loadable modules</a>
241 <li><a href="#org79d1c84">10.1. Keyboard driver</a></li>
242 <li><a href="#org99b4378">10.2. Mouse driver</a></li>
243 <li><a href="#org0aa9e1f">10.3. 2D graphic library</a></li>
244 <li><a href="#orgff6cdef">10.4. Trigonometry functions</a>
246 <li><a href="#org868f7c6">10.4.1. sin ( a – result )</a></li>
247 <li><a href="#orgc3f161e">10.4.2. cos ( a – result )</a></li>
256 <div id="outline-container-orgdd8d5a0" class="outline-2">
257 <h2 id="orgdd8d5a0"><span class="section-number-2">1.</span> General</h2>
258 <div class="outline-text-2" id="text-1">
260 <li>This program is free software: released under Creative Commons Zero
265 <li>Svjatoslav Agejenko</li>
266 <li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a></li>
267 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a></li>
270 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a></li>
274 <div id="outline-container-org11b4b95" class="outline-3">
275 <h3 id="org11b4b95"><span class="section-number-3">1.1.</span> Source code</h3>
276 <div class="outline-text-3" id="text-1-1">
278 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=snapshot;h=HEAD;sf=tgz">Download latest snapshot in TAR GZ format</a></li>
280 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a></li>
283 Clone Git repository using command:
285 <pre class="example">
286 git clone https://www2.svjatoslav.eu/git/fifth.git
293 <div id="outline-container-org0a3946b" class="outline-2">
294 <h2 id="org0a3946b"><span class="section-number-2">2.</span> !Project deprecated!</h2>
295 <div class="outline-text-2" id="text-2">
297 Current implementation does not support object oriented
298 programming. While working on Fifth I got lots of cool new ideas that
299 require reimplementation of everything.
303 Currently I try to implement those new ideas in the project called
304 <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
308 System is built many years ago when I was still using DOS as a primary
313 <div id="outline-container-org74c9861" class="outline-2">
314 <h2 id="org74c9861"><span class="section-number-2">3.</span> Introduction</h2>
315 <div class="outline-text-2" id="text-3">
317 Fifth is a combination of:
320 <li><a href="language.html#ID-da7fff9b-0b67-4843-828a-52a404d7f401">Programming language</a> (inspired by Forth).</li>
321 <li>Operating system.</li>
322 <li><a href="virtual machine.html#ID-9b251eb9-aff6-4025-94bf-25e89e26d54a">Virtual machine</a> with custom instruction set.</li>
326 <div id="outline-container-orge8b459e" class="outline-3">
327 <h3 id="orge8b459e"><span class="section-number-3">3.1.</span> Screenshots</h3>
328 <div class="outline-text-3" id="text-3-1">
330 <div id="org76cf04c" class="figure">
331 <p><img src="screenshots/start.png" alt="start.png" />
336 Startup screen diplaying Fifth logo and full file list.
340 <div id="org7579242" class="figure">
341 <p><img src="screenshots/dictionary.png" alt="dictionary.png" />
346 Sample words defined. Most of the words are commands that can be
347 executed interactively from the command line or from a file. When
348 executed, they can be selectively compiled or interpreted.
353 <div id="org17f3e64" class="figure">
354 <p><img src="screenshots/text editor.png" alt="text editor.png" />
359 Built in text editor.
365 <div id="outline-container-orga9dfaee" class="outline-2">
366 <h2 id="orga9dfaee"><span class="section-number-2">4.</span> Installation</h2>
367 <div class="outline-text-2" id="text-4">
369 Just unpack all files, witout altering original directory structure,
370 somewhere in your hard disk. For example:
373 <pre class="example">
379 To run fifth you need minimally just 2 files:
382 <dt>EMULATOR.COM</dt><dd>Virtual CPU emulator</dd>
383 <dt>DISK.RAW</dt><dd>Virtual disk file</dd>
387 For more information, please refer to <a href="#orgefa2f79">Fifth distribution directory
388 tree description</a>.
393 <div id="outline-container-orgefa2f79" class="outline-2">
394 <h2 id="orgefa2f79"><span class="section-number-2">5.</span> Fifth distribution directory tree description</h2>
395 <div class="outline-text-2" id="text-5">
397 After downloading and unpacking the ZIP file you shoud get directory
398 tree similar to this:
402 <b>DOC</b> - Fifth documentation<br />
403   <b>commands</b> - documentation on Fifth built-in commands<br />
404   <b>modules</b> - documentation on additional commands, realized as loadable modules<br />
405   <b>shots</b> - Fifth screenshots<br />
407 <b>imageFile</b> - files contained within 'disk.raw', just an extracted form.<br />
409 <b>source</b> - source files<br />
410   <b>emulator</b> - emulator source<br />
411   <b>util</b> - utilites<br />
413 <b>disk.raw</b> - Virtual disk file, has filesystem inside.<br />
414 <b>emulator.com</b> - main executable.<br />
419 <div id="outline-container-org751040b" class="outline-2">
420 <h2 id="org751040b"><span class="section-number-2">6.</span> Requirements</h2>
421 <div class="outline-text-2" id="text-6">
423 <div id="outline-container-org32f0917" class="outline-3">
424 <h3 id="org32f0917"><span class="section-number-3">6.1.</span> Software</h3>
425 <div class="outline-text-3" id="text-6-1">
427 <li>MS-DOS 6.22 with HIMEM.SYS loaded.</li>
428 <li>Mouse driver (optional, if you have a mouse).</li>
429 <li>CPU is initialized into <a href="https://en.wikipedia.org/wiki/Unreal_mode">Unreal Mode</a> during operation.</li>
430 <li>To recompile ASM sources, you can use FASM (Flat Assembler).</li>
431 <li>To run Quick Basic utilities, use Microsoft Quick Basic 4.5.</li>
432 <li>VESA support through BIOS or external driver (UNIVBE).</li>
437 <div id="outline-container-orgd6ecfe1" class="outline-3">
438 <h3 id="orgd6ecfe1"><span class="section-number-3">6.2.</span> Hardware</h3>
439 <div class="outline-text-3" id="text-6-2">
441 <li>A minimum of a i386 CPU.</li>
442 <li>64 KB of free RAM below 640KB.</li>
443 <li>2 MB of free <a href="https://en.wikipedia.org/wiki/Extended_memory">extended memory</a>.</li>
444 <li>A VESA-compatible video card.</li>
450 <div id="outline-container-orgeb3cbc2" class="outline-2">
451 <h2 id="orgeb3cbc2"><span class="section-number-2">7.</span> Numbers representation within Fifth</h2>
452 <div class="outline-text-2" id="text-7">
454 Because we are in full experimentation mode here (no regard for
455 compatibility whatsoever), why not to try also alternative number
460 Here alternative hexadecimal number representation format is devised:
464 <div id="org67795e4" class="figure">
465 <p><a href="numbers.png"><img src="numbers.png" alt="numbers.png" /></a>
470 Essentially square is split into 4 triangles. Each triangle represents
475 Fifth uses this hexadecimal format as primary throughout entire
480 See also: <a href="https://en.wikipedia.org/wiki/Bibi-binary">Bibi-binary</a>.
485 <div id="outline-container-orga8a8f37" class="outline-2">
486 <h2 id="orga8a8f37"><span class="section-number-2">8.</span> Disk file map, and it's data structures</h2>
487 <div class="outline-text-2" id="text-8">
489 Core and high-level boot code is stored outside of the filesystem to
490 allow easy access to it, at early booting time, when filesystem is not
494 <div id="outline-container-org4eb67fc" class="outline-3">
495 <h3 id="org4eb67fc"><span class="section-number-3">8.1.</span> Disk allocation</h3>
496 <div class="outline-text-3" id="text-8-1">
497 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
501 <col class="org-left" />
503 <col class="org-left" />
505 <col class="org-left" />
509 <th scope="col" class="org-left">offset</th>
510 <th scope="col" class="org-left">length</th>
511 <th scope="col" class="org-left">description</th>
516 <td class="org-left">0</td>
517 <td class="org-left">~4 Kb</td>
518 <td class="org-left">Fifth core</td>
522 <td class="org-left">4 Kb</td>
523 <td class="org-left">~32 Kb</td>
524 <td class="org-left">high-level boot code</td>
528 <td class="org-left">37 Kb</td>
529 <td class="org-left">~65 Kb</td>
530 <td class="org-left">FAT</td>
534 <td class="org-left">101 Kb</td>
535 <td class="org-left">~16 MB</td>
536 <td class="org-left">filesystem data area</td>
542 <div id="outline-container-org5fcae51" class="outline-3">
543 <h3 id="org5fcae51"><span class="section-number-3">8.2.</span> FAT entry format:</h3>
544 <div class="outline-text-3" id="text-8-2">
545 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
549 <col class="org-right" />
551 <col class="org-left" />
555 <th scope="col" class="org-right">code</th>
556 <th scope="col" class="org-left">meaning</th>
561 <td class="org-right">-2</td>
562 <td class="org-left">last sector</td>
566 <td class="org-right">-1</td>
567 <td class="org-left">empty sector</td>
571 <td class="org-right">0 --</td>
572 <td class="org-left">.. pointer to next block</td>
578 <div id="outline-container-org811dc5b" class="outline-3">
579 <h3 id="org811dc5b"><span class="section-number-3">8.3.</span> File entry format</h3>
580 <div class="outline-text-3" id="text-8-3">
581 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
585 <col class="org-right" />
587 <col class="org-right" />
589 <col class="org-left" />
593 <th scope="col" class="org-right">offset</th>
594 <th scope="col" class="org-right">length</th>
595 <th scope="col" class="org-left">description</th>
600 <td class="org-right">0</td>
601 <td class="org-right">4</td>
602 <td class="org-left">extension</td>
606 <td class="org-right">4</td>
607 <td class="org-right">16</td>
608 <td class="org-left">name</td>
612 <td class="org-right">20</td>
613 <td class="org-right">4</td>
614 <td class="org-left">entry point</td>
618 <td class="org-right">24</td>
619 <td class="org-right">4</td>
620 <td class="org-left">size</td>
624 <td class="org-right">28</td>
625 <td class="org-right">4</td>
626 <td class="org-left">last modification time</td>
633 <div id="outline-container-orga49dca9" class="outline-2">
634 <h2 id="orga49dca9"><span class="section-number-2">9.</span> Core architecture</h2>
635 <div class="outline-text-2" id="text-9">
637 Fifth core is simply some amount of already compiled into machine code
638 and linked together modules (entries in other words). In compilation
639 process modules is compiled one by one and simply stored on top of
640 already existing and growing core. Separately from core is kept
641 dictionary, this is special list that contain names of compiled
642 modules, variables etc. and they locations in core. Constants use
643 dictionary space only. Random word can be removed from dictionary at
644 any time. Currently dictionary can contain at most 1000 entries.
647 <div id="outline-container-org75e80d5" class="outline-3">
648 <h3 id="org75e80d5"><span class="section-number-3">9.1.</span> Dictionary entry format</h3>
649 <div class="outline-text-3" id="text-9-1">
650 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
654 <col class="org-right" />
656 <col class="org-right" />
658 <col class="org-left" />
662 <th scope="col" class="org-right">offset</th>
663 <th scope="col" class="org-right">length</th>
664 <th scope="col" class="org-left">description</th>
669 <td class="org-right">0</td>
670 <td class="org-right">4</td>
671 <td class="org-left">0 &lt; previous entry</td>
675 <td class="org-right"> </td>
676 <td class="org-right"> </td>
677 <td class="org-left">0 = last</td>
681 <td class="org-right"> </td>
682 <td class="org-right"> </td>
683 <td class="org-left">-1 = empty</td>
688 <td class="org-right">4</td>
689 <td class="org-right">15</td>
690 <td class="org-left">module name string</td>
695 <td class="org-right">19</td>
696 <td class="org-right">1</td>
697 <td class="org-left">entry type</td>
702 <td class="org-right">20</td>
703 <td class="org-right">4</td>
704 <td class="org-left">entry data</td>
710 Core headers as linked list of module names make up something like
711 dictionary. When some entry address is needed compiler can quickly
712 run through headers backwards and find needed entry.
716 <div id="outline-container-org12381ef" class="outline-3">
717 <h3 id="org12381ef"><span class="section-number-3">9.2.</span> Possible module types</h3>
718 <div class="outline-text-3" id="text-9-2">
719 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
723 <col class="org-right" />
725 <col class="org-left" />
727 <col class="org-left" />
731 <th scope="col" class="org-right">type</th>
732 <th scope="col" class="org-left">description</th>
733 <th scope="col" class="org-left">"execute" action</th>
738 <td class="org-right">0</td>
739 <td class="org-left">data</td>
740 <td class="org-left">compile "num" instruction</td>
744 <td class="org-right"> </td>
745 <td class="org-left"> </td>
746 <td class="org-left">with address to module</td>
751 <td class="org-right">1</td>
752 <td class="org-left">submodule</td>
753 <td class="org-left">compile "call" instruction</td>
757 <td class="org-right"> </td>
758 <td class="org-left"> </td>
759 <td class="org-left">with address to module</td>
764 <td class="org-right">2</td>
765 <td class="org-left">imm. submodule</td>
766 <td class="org-left">immediately call to module</td>
772 <div id="outline-container-org33be039" class="outline-3">
773 <h3 id="org33be039"><span class="section-number-3">9.3.</span> Memory map</h3>
774 <div class="outline-text-3" id="text-9-3">
775 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
779 <col class="org-right" />
781 <col class="org-left" />
783 <col class="org-left" />
787 <th scope="col" class="org-right">location</th>
788 <th scope="col" class="org-left">size</th>
789 <th scope="col" class="org-left">description</th>
794 <td class="org-right">0</td>
795 <td class="org-left">~4096</td>
796 <td class="org-left">core</td>
800 <td class="org-right">1500000</td>
801 <td class="org-left">~32000</td>
802 <td class="org-left">highlevel Fifth boot code</td>
806 <td class="org-right">200000h</td>
807 <td class="org-left"> </td>
808 <td class="org-left">core startup messages area</td>
812 <td class="org-right">5200000</td>
813 <td class="org-left"> </td>
814 <td class="org-left">end of dynamic memory space</td>
821 <div id="outline-container-org81fd544" class="outline-2">
822 <h2 id="org81fd544"><span class="section-number-2">10.</span> Dynamically loadable modules</h2>
823 <div class="outline-text-2" id="text-10">
825 <div id="outline-container-org79d1c84" class="outline-3">
826 <h3 id="org79d1c84"><span class="section-number-3">10.1.</span> Keyboard driver</h3>
827 <div class="outline-text-3" id="text-10-1">
830 KBD_@ ( – code ) get scancodes for pressed keys from keyboard.<br />
831 KBD_down? ( key – result ) check is key with specified scancode<br />
832                 currently pressed down.<br />
833 KBD_SC2FSCII ( code – FSCII ) convert key scancode into FSCII code,<br />
834                 or in FSK (Fifth standard keycode).<br />
835 KBD_F@ ( – FSCII ) read pressed key FSCII or FSK, returns -1 if no<br />
836                 keys are pressed.<br />
837 KBD_FW@ ( – FSCII ) read pressed key FSCII or FSK, if no keys is<br />
838                 are pressed then waits until there is.<br />
840                 FSK<br />
841                 —<br />
850 401 … F1 …<br />
864 <div id="outline-container-org99b4378" class="outline-3">
865 <h3 id="org99b4378"><span class="section-number-3">10.2.</span> Mouse driver</h3>
866 <div class="outline-text-3" id="text-10-2">
868 mousex var Mouse x coordinate.<br />
869 mousey var Mouse y coordinate.<br />
870 mousekeyl var Mouse left key.<br />
871 mousekeym var Mouse middle key.<br />
872 mousekeyr var Mouse right key.<br />
873 mousec var Display current mouse coordinates in top left part of screen,<br />
874                 if true. (good for debugging)<br />
875 mousepointer var Image buffer, holding current mouse pointer.<br />
876 mouseadd ( ModuleAddr x1 x2 y1 y2 – ) Add specified area on screen,<br />
877                 into mause click buffer. If any mouse button is clicked on<br />
878                 that area, module at "ModuleAddr" will be executed.<br />
879 mousebe var Amount of buffer elements.<br />
880 mousedo ( – ) Updates mouse coordinates and keys. Parse mouse<br />
881                 click buffer, and draw mouse cursor to "screen".<br />
885 <div id="outline-container-org0aa9e1f" class="outline-3">
886 <h3 id="org0aa9e1f"><span class="section-number-3">10.3.</span> 2D graphic library</h3>
887 <div class="outline-text-3" id="text-10-3">
889 <dt>lineh ( color len x y imgbuf – )</dt><dd>draws horisontal line from X,Y
890 coordinates to right, with specified length.</dd>
892 <dt>linev ( color len x y imgbuf – )</dt><dd>draws vertical line down, from
893 coordinates X,Y, with specified length.</dd>
895 <dt>box ( color x2 x1 y2 y1 imgbuf – )</dt><dd><p>
896 draws rectangular box. x2
897 bust be >= x1, y2 must be >= y1.
900 <pre class="example" id="orgfea073c">
907 <dt>flipv ( imgbuf – )</dt><dd>flip image vertically.</dd>
909 <dt>imgcoltrans ( ImgBuf Color ToColor – )</dt><dd>Translate all pixels in
910 specified image with "Color" into "ToColor".</dd>
912 <dt>imgfill ( color x y imgbuf – )</dt><dd>Fill image region starting at
913 location X & Y with specified color.</dd>
918 <div id="outline-container-orgff6cdef" class="outline-3">
919 <h3 id="orgff6cdef"><span class="section-number-3">10.4.</span> Trigonometry functions</h3>
920 <div class="outline-text-3" id="text-10-4">
922 <div id="outline-container-org868f7c6" class="outline-4">
923 <h4 id="org868f7c6"><span class="section-number-4">10.4.1.</span> sin ( a – result )</h4>
924 <div class="outline-text-4" id="text-10-4-1">
926 Return sinus from given angle "a", 360ø is 2000. So 1000 represents
927 180ø angle. Result will be in range -10'000 to 10'000, instead of ñ1.
931 <div id="outline-container-orgc3f161e" class="outline-4">
932 <h4 id="orgc3f161e"><span class="section-number-4">10.4.2.</span> cos ( a – result )</h4>
933 <div class="outline-text-4" id="text-10-4-2">
935 Return cosinus from given angle. Parameters are like in <a href="#org868f7c6">sin</a> function.
942 <div id="postamble" class="status">
943 <p class="author">Author: Svjatoslav Agejenko</p>
944 <p class="date">Created: 2023-09-19 Tue 18:07</p>
945 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>