+++ /dev/null
- Compilation & misc\r
- ------------------\r
-\r
-\r
-init module ( -- )\r
- First module, control is passed to on startup. Contains\r
- initialization routines. Also it is the last core module.\r
- All new modules on top of it comes as result of executing\r
- external source files.\r
-\r
-head <name> ( -- ) compiles new dictionary entry without specifying\r
- new module type.\r
- ex: head myentry\r
-\r
-: <name> ( -- ) creates new code module\r
-; ( -- ) ends module (immideate)\r
- ex: : hello ." hi there" ;\r
-\r
-const <name> ( n -- ) defines new constant.\r
- ex: 2147483647 const max\r
-\r
-:i <name> ( -- ) same as ":" but this module will be executed\r
- immideately even in compile mode.\r
- ex: :i ( 41 scan ;\r
-\r
-create <name> ( -- ) same as "head" , but specify module type as data.\r
- ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,\r
-\r
-allot ( n -- ) allocate n bytes in dictionary.\r
- ex: create MyArray 100 allot\r
-\r
-" <string>" ( -- ) compile string and its size into core.\r
- ex: create Mystring " This is it's contects"\r
-\r
-str <name> <string>" ( -- ) just shorter way for defining strings.\r
- ex: str Mystring This is it's contenc"\r
-\r
-var <name> ( -- ) define new 32 bit variable.\r
- ex: var result\r
-\r
-' <module> ( -- n ) return memory address of given entry.\r
- ex: ' init\r
-\r
-forget <name> ( -- ) erases from RAM given entry and all entries what was\r
- defined after it.\r
- ex: forget myprog\r
-\r
-[ ( -- ) set interpret mode (immideate)\r
-] ( n -- ) set compile mode and compile top stack element\r
- in as literal. Together [ .... ] cobination provides good\r
- way to compute some values only once, at compile time,\r
- rather than every time while program is running.\r
- ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;\r
-\r
-defer <name> ( -- ) creates new module, with jump instruction.\r
- Later address where to jump can be modified by "is" command.\r
- This provides method of foward referencing. So you can use\r
- modules what not jet exist.\r
-is ( address1 address2 -- ) address1 - where to jump, address2 -\r
- address of module created by defer command.\r
- ex: defer dispver\r
- : run dispver ." running ..." ;\r
- ... whatever ...\r
- : (dispver ." Version 9.99 " ;\r
- ' (dispver ' dispver is\r
-\r
- Now if I type "run" on the screen appears:\r
- Version 9.99 running ...\r
-\r
-asc <char> ( -- ) reads char ascii code and treats it as literal.\r
- (immideate)\r
- ex: : BreakLine 30 do asc - emit loop ;\r
- same as:\r
- : BreakLine 30 do 45 emit loop ;\r
-\r
-dyninc ( handle -- ) execute code in dynamic memory handle.\r
- automatically deallocates it when done.\r
-\r
-include ( filenumber -- ) execute code in specified file.\r
-\r
-words ( -- ) display existing blocks in core.\r
-\r
-bye ( -- ) exit from Fifth\r
-\r
-fkey ( -- c )\r
- Read one byte from input stream.\r
-\r
-sadd ( c addr -- )\r
- Add one byte "c" to string located at "addr" and updates\r
- string length.\r
-\r
-scan ( c -- )\r
- Read input stream and store it to pad until it finds c .\r
- It ignores all "c" bytes until it finds any non "c" byte.\r
- in other words:\r
- c is: "\r
- input stream: """"This is test !"aoeu idh\r
- result: This is test !\r
-\r
- Is useful for breaking text lines into words.\r
-\r
-skey ( -- c )\r
- So called safe "fkey". Reads data from input stream\r
- but converts characters with ASCII codes: 9 13 10\r
- to spaces.\r
-\r
-str=str? ( adr1 adr2 -- result )\r
- Compares string at "adr1" with string at "adr2", returns\r
- true flag if they are equal or false if they are not.\r
- true = -1\r
- false = 0\r
-\r
-find ( -- addr )\r
- Searches whole dictionary for word in "pad". If found,\r
- returns it address, if not, returns 0.\r
-\r
-execute ( -- )\r
- Execute word located in "pad". Depending on "mode".\r
-\r
-dta ( addr -- DataAddr )\r
- Calculates address of dictionary entry data area, from\r
- entry point.\r
-\r
-2num ( -- num result )\r
- Attempt to convert string located in "pad" into numeric\r
- value. If succeed returns number and true as result.\r
- If not, returns whatever and false as result.\r
-\r
-dadd ( addr length -- )\r
- Add to dictionary data located at "addr", with specified\r
- length.\r
-\r
-lit ( n -- )\r
- Act with number depending on "mode". When interpreting,\r
- leaves it in stack.\r
-\r
-\r
-incmod ( addr -- )\r
- Add to dictionary data located at "addr"+1 , length is taken\r
- from "addr".\r
-\r
-here ( -- n )\r
- return "h" contents.\r
-\r
-mode var 8 bit\r
- Holds input stream parser operation mode.\r
- 0 = interpreting\r
- 1 = compiling\r
-\r
-pad var 128 bytes\r
- Holds temprorary strings.\r
-\r
-h var 32 bit\r
- Pointer to free byte in memory, always at the end of the\r
- dictionary. Each time when something is stored\r
- by "c," command, pointer is incareased.\r
-\r
-lp var 32 bit\r
- Pointer to last dictionary word. Each time when new word is\r
- compiled or erased by "forget", this pointer is updated.\r
-\r
-modulechk ( Dstr<filename> -- ) check if module is loaded, if not\r
- immideately load it.\r
-\r
-ne ( entrydata entrytype -- ) Compile new dictionary entry.\r
- It's name must be in "pad".\r
+++ /dev/null
- Conditionals & loops\r
- ------------------\r
-\r
-if ( flag -- ) (immideate)\r
- "if 1.. else 2.. then" or\r
- "if 1.. then" construction. Conditional execution.\r
- Performs "1.." if "flag" was true,\r
- elseway performs "2.." if exist. Execution continues after\r
- word "then".\r
- ex: 1 if ." nonzero" else ." zero" then\r
-\r
->= ( n1 n2 -- result ) true if (n1 = n2) or (n1 > n2)\r
- ex: 5 3 >= if ." first number is greater or equal" then\r
-\r
-<= ( n1 n2 -- result ) true if (n1 = n2) or (n1 < n2)\r
-= ( n1 n2 -- result ) true if n1 = n2\r
-\r
-do ( count -- ) (immideate)\r
- "do .. loop" construction. Performs ".." "count" times.\r
- In every step "count" is decareased until it is 0.\r
- ex: : test 5 do i .d loop ;\r
- result: 4 3 2 1 0\r
-\r
-doexit ( -- ) exit from "do .. loop"\r
-\r
-for ( count top -- ) (immideate)\r
- "for .. loop" construction. Performs ".." (top - count) times.\r
- In every step "count" is incareased until it reaches "top" .\r
- ex: : test 4 10 for i .d loop ;\r
- result: 4 5 6 7 8 9\r
-\r
-forexit ( -- ) exit from "for .. loop"\r
-\r
-until ( -- ) (immideate)\r
- "until .. loop" construction. Performs ".." until flag become\r
- true. False by default. Top of return stack holds flag.\r
-\r
-done ( -- ) exit from "until .. loop"\r
-\r
+++ /dev/null
- Disk & file access\r
- ------------------\r
-\r
-diskload ( FromDisk ToMem amount -- )\r
- Load specified abount of bytes from disk into memory.\r
-\r
-disksave ( FromMem ToDisk amount -- )\r
- save specified abount of bytes from memory into disk.\r
-\r
-format ( -- ) Erase all files.\r
-\r
-fsDfilesize@ ( handle -- size )\r
- Return size of opened file.\r
-\r
-fsDcurloc@ ( handle -- location )\r
- Return current location in file.\r
-\r
-fsDupdated@ ( handle -- updated? )\r
- Return true if file was updated,\r
- ie. write operations occured.\r
-\r
-fssave ( FromMem DestFileHandle amount -- )\r
- Save data to file.\r
-\r
-fsload ( SrcFileHandle ToMem amount -- )\r
- Load data from file.\r
-\r
-fseof ( handle -- bytesLeft )\r
- Return amount of bytes left till end of file.\r
- Useful before read operation.\r
-\r
-fsls ( -- ) List all files and lists (directories,folders)\r
- in current path.\r
-\r
-fslsr ( -- ) Same as "fsls" but recursively scans also sub lists.\r
-\r
-fscl ( DynStrHand -- )\r
- Change list (path)\r
-\r
-fscreate ( DynStrHand -- DescPnt )\r
- Create new file or list. Can create multiple lists at once.\r
- ex: when creating:\r
- "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"\r
- and only "\listGAMES\" already exist, then\r
- "listSTRATEGY" and "listSIMWORLD" lists will be created,\r
- and empty file "5th-runme" placed in there.\r
-\r
-fsDsave ( DynHand<data> DynStrHand<filename> -- )\r
- Create new file and save all data from dynamic memory\r
- block to it.\r
-\r
-fsDload ( DynStr<SrcFileName> DynHand<DataDest> -- )\r
- Load whole file into dynamic memory block.\r
-\r
-fsDloadnew ( DynStr<SrcFileName> -- DynHand<DataDest> )\r
- Load whole file into new dynamic memory block.\r
-\r
+++ /dev/null
- Dynamic memory\r
- --------------\r
-\r
-\r
-dynal ( size -- handle )\r
- Allocate dynamic memory block and return it's handle.\r
-\r
-dynde ( handle -- )\r
- Deallocate dynamic memory block.\r
-\r
-dynp ( handle -- addr )\r
- Returns pointer to memory where dynamic block\r
- data begins.\r
-\r
-dyns ( handle -- size )\r
- Returns size of dynamic block.\r
-\r
-dynresize ( NewSize handle -- )\r
- Nondestructively resize dynamic block.\r
-\r
-dync@ ( addr handle )\r
- Read one byte from dynamic block.\r
-\r
-dync! ( byte addr dynhandle )\r
- Write one byte to dynamic block.\r
-\r
-dyn@ ( addr handle )\r
- Read 32 bit number from dynamic block.\r
- Address will spacify, whitch number, not byte.\r
-\r
-dyn! ( 32BitNum addr dynhandle )\r
- Write 32 bit number to dynamic block.\r
- Address will spacify, whitch number, not byte.\r
-\r
-dyncon ( size "name" -- )\r
- Allocate dynamic block with specified size, and\r
- create constant honding its handle.\r
- ex: 100 dyncon MyNewBlock\r
-\r
-dyn. ( handle -- )\r
- Write contenc of dynamic memory block to screen.\r
-\r
-\r
+++ /dev/null
- Graphic & text\r
- --------------\r
-\r
-. ( n -- ) print number on screen\r
-\r
-d. ( n -- ) print number on screen in decimal\r
-\r
-? ( addr -- ) print 32 bit value located at addr.\r
-\r
-." <string>" ( -- ) print string into screen. Immideately\r
- compiles.\r
- ex: : greeting ." Hello, World" ;\r
-\r
-tab. ( -- ) print tabulator\r
-\r
-calccol ( b g r -- c ) calculate color what best matches given\r
- Blue Green & Red values. Values must be in range 0 - 255.\r
-\r
-imgalloc ( xsize ysize -- imgbuf ) allocate image buffer for\r
- specified size.\r
-\r
-imgsize ( imgbuf -- ) print on the screen X & Y size of image\r
- buffer.\r
-\r
-point ( x y imgbuf -- addr ) returns memory address for specified\r
- pixel.\r
-\r
-pset ( color x y imgbuf -- ) set graphic point\r
-\r
-boxf ( x1 x2 y1 y2 imgbuf color -- ) draw filled box\r
-\r
-cls ( imgbuf -- ) clear image buffer\r
-\r
-setpal ( b g r color -- ) set palette value for specified color.\r
- values bust be in size 0 - 63.\r
-\r
-putchar ( char color x y imgbuf -- ) put graphic character in\r
- imagebuffer to specified (x & y) location.\r
-\r
-scroll ( x y imgbuf -- ) scroll in imgbuf.\r
-\r
-scrollf ( color x y screen -- ) scroll and fill empty space with\r
- given color.\r
-\r
-at! ( x y -- ) set cursor location\r
-curc! ( color -- ) set text color\r
-curb! ( solor -- ) set backround color\r
-\r
-colnorm ( -- ) set text color to normal\r
-colneg ( -- ) set text color to negative (selected)\r
-\r
-dyntype ( dynhandle -- ) display contenc of dynamic memory on screen\r
-fsdisp ( file -- ) clear screen, display file, and wait for key\r
-\r
-type ( addr length -- )\r
- Types on the screen string, from memory at addr and\r
- specified length.\r
-\r
-write ( addr -- )\r
- Types on the screen string, from memory at "addr"+1\r
- length is taken from "addr" .\r
-\r
-screen const 32 bit\r
- Holds handle of screen buffer.\r
-\r
-copyscreen ( SrcImgHandle DestImgHandle -- ) copy contenc of source\r
- image to destination image. Source and destination images\r
- must have same size.\r
+++ /dev/null
-<html><head><title>FIFTH</title></head>\r
-<body>\r
-<pre>\r
-\r
- <h2>Fifth internal standard commands:</h2>\r
-\r
-\r
-<br><a href="math&mem.txt">Math & memory manipulation</a>\r
-<br><a href="dsk&file.txt">Disk & file access</a>\r
-<br><a href="conditio.txt">Conditionals and loops</a>\r
-<br><a href="graphic.txt">Graphic & text</a>\r
-<br><a href="dynmem.txt">Dynamic memory</a>\r
-<br><a href="string.txt">Dynamic & static strings</a>\r
-<br><a href="cmp&misc.txt">Compilation & miscellaneous</a>\r
-\r
-\r
-</pre>\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
- Math, memory & stack manipulation\r
- ---------------------------------\r
-\r
-\r
-off ( n -- ) writes 0 to given address, good for zeroing variable.\r
- ex: MyVariable off\r
-on ( n -- ) writes -1 (true flag) to given address.\r
- ex: MyVariable on\r
-\r
-2dup ( n1 n2 -- n1 n2 n1 n2 )\r
-2drop ( n1 n2 -- )\r
-nip ( n1 n2 -- n2 )\r
-neg ( n1 -- -n1 ) negotiate\r
-bit@ ( n bit -- result ) return specified bit from n.\r
- ex: 38 2 bit@ (result will be 1)\r
-to32bit ( n1 n2 n3 n4 -- n32 ) treat 4 last stack elements as bytes\r
- and unite them into 32 bit dword. Most significant byte\r
- on top.\r
- ex: 12 76 23 11 to32bit result: 186076172\r
-\r
-to8bit ( n32 -- n1 n2 n3 n4 ) break 32 bit number into 4 bytes.\r
- Useful if you need to send 32 bit numbers thru 8 bit COM\r
- port.\r
- ex: 186076172 to8bit result: 12 76 23 11\r
-\r
-mod ( n1 n2 -- reminder ) divide n1 by n2 and returns reminder.\r
- ex: 12 5 mod result: 2\r
-\r
-bound ( low n high -- n ) check if n is in given bounds,\r
- if not then incarease/decarease it to match bounds.\r
- ex: 5 80 15 bound result: 15\r
- 5 10 15 bound result: 10\r
- 5 -10 15 bound result: 5\r
-\r
-bound? ( low n high -- result ) returns true if n is in the\r
- given bounds.\r
-\r
-tab ( col -- spaces) calculate amount of spaces to add\r
- ta reach next tabulation from given column.\r
-\r
-count ( addr -- addr+1 n )\r
- Useful for returning bytes from constantly incareasing\r
- address. Module "type" is nice example.\r
-\r
-c, ( n -- )\r
- store one byte at memory specified by "h". And incarease\r
- "h" by 1.\r
-\r
-, ( n -- )\r
- store 32 bit number at memory specified by "h". And\r
- incarease "h" by 4.\r
-\r
-cmove ( addr1 addr2 n -- )\r
- copy "n" amount of bytes from memory at "addr1" to memory\r
- at "addr2".\r
-\r
-rnd ( limit -- result )\r
- generates random number in range 0 to "limit"-1.\r
-\r
-abs ( n -- |n| )\r
- returns absolute value of "n"\r
+++ /dev/null
- Dynamic & static strings \r
- ------------------------\r
-\r
-Fifth supports both static and dynamic strings.\r
-Static strings must have predefined space reserved,\r
-and string mustn't exceed this length. They manipulation is\r
-faster. But they use more memory. Static string memory address is used\r
-to refer to the string.\r
-\r
-Dynamic strings can have at any time length form 0 to 0FFh,\r
-They take up only memory they currently need. They are held\r
-in dynamic memory blocks, so dynamic block handle is used to refer\r
-to this string.\r
-\r
-Both types of strings are stored in the way, where first (0th)\r
-byte holds current string length, following bytes are string itself.\r
-\r
-Dynamic:\r
-\r
-Dstral ( -- handle )\r
- Allocate new string.\r
-\r
-Dstrlen ( handle -- length )\r
- Return string length.\r
-\r
-c+Dstr ( chr handle -- )\r
- Add one byte to end of the string.\r
-\r
-c+lDstr ( chr handle -- )\r
- Add one byte to left side (beginning) of the string.\r
-\r
-Dstr. ( handle -- )\r
- Write contec of string into screen.\r
-\r
-Dstrsure ( size Dstr -- )\r
- Makes sure that at least rquested\r
- "size" (amount of characters) is allocated for given\r
- dynamic string.\r
-\r
-Dstr2str ( handle address -- )\r
- Copy dyamic string into static memory space.\r
-\r
-str2Dstr ( address handle -- )\r
- Copy static string into dyamic string.\r
-\r
-Dstr+str ( Dstr addr -- )\r
- Add contenc of dynamic string to static string.\r
-\r
-D" any string" ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr".\r
-\r
-D> any_string ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr".\r
- Space marks end of string!\r
-\r
-D>2 any_string ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr2".\r
- Space marks end of string!\r
-\r
-Dstr+Dstr ( Dstr1 Dstr2 -- )\r
- Adds "Dstr1" to "Dstr2" and places result into "Dstr2". \r
-\r
-Dstrclear ( Dstr -- )\r
- Clears contenc of dynamic string.\r
-\r
-Dstr2Dstr ( Dstr1 Dstr2 -- )\r
- Moves "Dstr1" to "Dstr2".\r
-Dstr ( data" name -- )\r
- Creates new dynamic string and moves specified data into it.\r
- Then creates new constant with given "name" holding created\r
- dynamic string handle.\r
-\r
- ex: Dstr Hello, my name is Sven!" message \ creates it\r
- message Dstr. \ tests it\r
-\r
-Dstrlscan ( char Dstr -- loc )\r
- Searches dynamic string for "char", from left to right,\r
- returns first found "char" location in string, or 0,\r
- if not found.\r
-\r
-Dstrrscan ( char Dstr -- loc )\r
- Searches dynamic string for "char", from right to left,\r
- returns first found "char" location in string, or 0,\r
- if not found.\r
-\r
-Dstrlscane ( char Dstr -- loc )\r
- Same as "Dstrlscan" buf returns string length+1 as location.\r
-ÿ\r
-Dstrleft ( amo Dstr -- )\r
- Only specified amount of characters from left remains\r
- in dynamic string. ie. cut right part out.\r
-\r
-Dstrright ( amo Dstr -- )\r
- Only specified amount of characters from right remains\r
- in dynamic string. ie. cut left part out.\r
-\r
-Dstrcutl ( amo Dstr -- )\r
- Cut specified amount of characters from left of dynamic\r
- string out.\r
-\r
-Dstrsp ( char Dstr1 Dstr2 -- )\r
- Separate dynamic string in Dstr1 into two parts,\r
- using "char" as separator. First part will be stored in\r
- "Dstr2", second part in "Dstr1".\r
- ex: asc \ \ ..separator\r
- D> listF\listLIB\5TH_DRVMOUSE \ ..separate from\r
- defDstr2 \ ..place result in\r
- Dstrsp \ separation command\r
- defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE\r
- defDstr2 Dstr. \ will be: listF\r
-\r
-Dv ( addr -- )\r
- Allocates empty dynamic string, and places it's handle\r
- into given address.\r
-\r
-Df ( addr -- )\r
- Reads dynamic string handle from given address and\r
- deallocates (frees) it.\r
-\r
-ex: var mystring1\r
- : testmodule\r
- mystring1 Dv \ allocates string\r
-\r
- <whatever>\r
-\r
- mystring1 Df ; \ deallocates it again when no longer needed.\r
+++ /dev/null
-<html><head><title>FIFTH</title></head>\r
-<body>\r
-\r
-<pre>\r
-\r
- <h2>Emulator & virtual CPU</h2>\r
-\r
-\r
-\r
-Using CPU emulator slows it down but I shouldn't now\r
-think too mutch about, and waste my time on batteling with problems whitch\r
-results on complex design of PC hardware. Also it allows me to use existing DOS and\r
-resident drivers services in real mode. So I don't need to deal with\r
-hardware too mutch. It also allows me to use all free XMS for flat\r
-code & data storage.\r
-\r
-Current emulator emulates 1 CPU. It has 2 stacks,\r
-~50 instructions, and 4GB flat address space (theoretically).\r
-I'm not sure that DOS 6.22 that I currently prefer can handle more than\r
-64 MB of RAM. While I tried to keep instructionset simple,\r
-I was forced to put in lot of complex instructions to make it's performance\r
-acceptable on emulator. On actual silicon ~20 instructions is enaugh\r
-(I think).\r
-\r
-Maybe one day similar system will run directly on custom silicon chip :)\r
-\r
-\r
-CPU has following registers:\r
-\r
-IP - instruction pointer\r
-DSP - data stack pointer\r
-RSP - return stack pointer\r
-\r
-Virtual CPU, commands (most of them are avaiable as ordinary commands in\r
-programming lanquage):\r
-\r
-code mnemonic description\r
-\r
-0 nop does notheing\r
-1 halt halt CPU ( return to DOS on emulator )\r
-\r
-2 kbd@ ( -- c ) read scancode of pressed or released key.\r
- Returns 0, if no data avaiable. \r
-3 num <dword> ( -- n ) put immidiate number into datastack\r
-\r
-4 jmp <dword> jump to specified code\r
-5 call <dword>jump to specified code, save return address to\r
- return stack.\r
-\r
-6 1+ ( n -- n+1 )\r
-7 1- ( n -- n-1 )\r
-\r
-8 dup ( n -- n n ) duplicate top of data stack\r
-9 drop ( n -- ) drop last element in data stack\r
-\r
-10 if <dword> ( n -- ) jump to addr if top element was 0\r
-11 ret jump to code, specified in return stack.\r
-\r
-12 c@ ( addr -- n ) read byte from memory at specified address\r
-13 c! ( n addr -- ) store byte to specified memory\r
-\r
-14 push ( DSTK -> RSTK ) move top of datastack to returnstack\r
-15 pop ( RSTK -> DSTK ) move top of returnstack to datastack\r
-\r
-16 <unused>\r
-17 rot ( n1 n2 n3 -- n2 n3 n1) rotate stack elements\r
-\r
-18 disk@ ( FromDiskSect ToMem -- ) read 1KB from disk into RAM\r
-19 disk! ( FromMem ToDiskSect -- ) write 1KB to disk\r
-\r
-20 @ ( addr -- n ) read 32 bit number from memory\r
-21 ! ( n addr -- ) store 32 bit number to memory\r
-\r
-22 over ( n1 n2 -- n1 n2 n1 ) self explaining ...\r
-23 swap ( n1 n2 -- n2 n1 ) -,,-\r
-\r
-24 + ( n1 n2 -- n1+n2 ) -,,-\r
-25 - ( n1 n2 -- n1-n2 ) -,,-\r
-\r
-26 * ( n1 n2 -- n1*n2 ) -,,-\r
-27 / ( n1 n2 -- n1/n2 ) -,,-\r
-\r
-28 > ( n1 n2 -- result ) is true when n1 > n2\r
-29 < ( n1 n2 -- result ) is true when n1 < n2\r
-\r
-30 not ( n1 -- not_n1 ) logical not\r
-31 i ( -- n ) copies top of return stack into datastack\r
-\r
-32 cprt@ ( addr -- n ) read one byte from hardware port\r
-33 cprt! ( n addr -- ) store one byte to hardware port\r
-\r
-34 i2 ( -- n ) like "i" but takes socond top stack element.\r
-35 i3 ( -- n ) like "i" but takes third top stack element.\r
-\r
-36 shl ( n amount -- n ) left bit shift\r
-37 shr ( n amount -- n ) right bit shift\r
-\r
-38 or ( n1 n2 -- n ) logical or\r
-39 xor ( n1 n2 -- n ) exclusive logical or\r
- \r
-40 vidmap ( addr -- ) copy memory from "addr" to video memory.\r
-\r
-41 mouse@ ( -- x y button ) read mouse coordinates & buttons\r
-\r
-42 vidput ( addr1 addr2 x y -- ) put image1 into image2, at\r
- location x, y. Does clipping, so part of a big image\r
- can be mapped into smaller one.\r
-\r
-43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2\r
- if addr1 is greater than addr2 then count address\r
- foward while moving, elseway starts from end and\r
- counts backwards, so no data loss will occure on\r
- overlapping.\r
-\r
-44 cfill ( c addr amount -- ) fill memory starting at "addr"\r
- with "c" bytes.\r
-\r
-45 tvidput ( addr1 addr2 x y -- ) same as "vidput" but treats\r
- color 255 in source image as transparent.\r
-\r
-46 depth ( -- depth ) returns current depth of data stack.\r
-\r
-47 charput ( colorfg colorbg addrsrc addrdest x y )\r
- draw character to image buffer located at "addrdest"\r
- to specified x & y location. Decodes 8 bytes from\r
- source to bits, used to draw character.\r
-\r
-</pre>\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
- Fifth distribution directory tree description\r
- =============================================\r
-\r
-After downloading and unpacking the ZIP file you shoud get\r
-directory tree similar to this:\r
-\r
-\r
-[DOC] - Fifth documentation \r
- [commands] - documentation on Fifth built-in commands\r
- [modules] - documentation on additional commands, realized as loadable modules\r
- [shots] - Fifth screenshots\r
-\r
-[imageFile] - files contained within 'disk.raw', just an extracted form.\r
-\r
-[source] - source files\r
- [emulator] - emulator source\r
- [util] - utilites\r
-\r
-disk.raw - Virtual disk file, has filesystem inside.\r
-emulator.com - main executable.\r
-\r
-\r
-\r
-\r
<html lang="en">
<head>
<title>Fifth - virtual machine, operating system, programming language</title>
-<!-- 2017-11-29 Wed 23:48 -->
+<!-- 2018-01-01 Mon 23:29 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Org-mode">
inspired created my own system.
</p>
+<ul class="org-ul">
+<li><a href="5TH_ET.txt">Example Fifth source file - text editor</a>
+</li>
+</ul>
+</div>
+<div id="outline-container-sec-2-1" class="outline-3">
+<h3 id="sec-2-1"><span class="section-number-3">2.1</span> screenshots</h3>
+<div class="outline-text-3" id="text-2-1">
+<ul class="org-ul">
+<li><img src="screenshots/start.png" class="img-responsive" alt="start.png">
+<ul class="org-ul">
+<li>Startup screen diplaying Fifth logo and full file list.
+</li>
+</ul>
+</li>
-
-<p>
-<i>Screenshots</i>
-</p>
-
-<p>
-Read more about:
-</p>
+<li><img src="screenshots/dictionary.png" class="img-responsive" alt="dictionary.png">
<ul class="org-ul">
-<li><a href="emulator.html">Virtual CPU</a>
+<li>Sample words defined. Most of the words are commands that can be
+executed interactively from command line or from file. When
+executed they can be selectively compiled or interpreted.
</li>
-<li><a href="commands/index.html">Built-in commands</a>
+</ul>
</li>
-<li><a href="modules/index.html">Additional commands, realized as loadable modules</a>
+
+<li><img src="screenshots/text editor.png" class="img-responsive" alt="text editor.png">
+<ul class="org-ul">
+<li>Built in text editor.
</li>
-<li><a href="5TH_ET.txt">Example Fifth source file - text editor</a>
+</ul>
</li>
</ul>
</div>
</div>
+</div>
+
<div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Installation</h2>
<div class="outline-text-2" id="text-3">
</div>
</div>
<div id="outline-container-sec-4" class="outline-2">
-<h2 id="sec-4"><span class="section-number-2">4</span> Software/Hardware/Human requirements</h2>
+<h2 id="sec-4"><span class="section-number-2">4</span> Fifth distribution directory tree description</h2>
<div class="outline-text-2" id="text-4">
-</div><div id="outline-container-sec-4-1" class="outline-3">
-<h3 id="sec-4-1"><span class="section-number-3">4.1</span> Software:</h3>
-<div class="outline-text-3" id="text-4-1">
+<p>
+After downloading and unpacking the ZIP file you shoud get directory
+tree similar to this:
+</p>
+
+<p class="verse">
+[DOC] - Fifth documentation<br >
+  [commands] - documentation on Fifth built-in commands<br >
+  [modules] - documentation on additional commands, realized as loadable modules<br >
+  [shots] - Fifth screenshots<br >
+<br >
+[imageFile] - files contained within 'disk.raw', just an extracted form.<br >
+<br >
+[source] - source files<br >
+  [emulator] - emulator source<br >
+  [util] - utilites<br >
+<br >
+disk.raw - Virtual disk file, has filesystem inside.<br >
+emulator.com - main executable.<br >
+</p>
+</div>
+</div>
+
+<div id="outline-container-sec-5" class="outline-2">
+<h2 id="sec-5"><span class="section-number-2">5</span> Software/Hardware/Human requirements</h2>
+<div class="outline-text-2" id="text-5">
+</div><div id="outline-container-sec-5-1" class="outline-3">
+<h3 id="sec-5-1"><span class="section-number-3">5.1</span> Software</h3>
+<div class="outline-text-3" id="text-5-1">
<ul class="org-ul">
<li>MS-DOS 6.22, with HIMEM.SYS loaded.
</li>
</ul>
</div>
</div>
-<div id="outline-container-sec-4-2" class="outline-3">
-<h3 id="sec-4-2"><span class="section-number-3">4.2</span> Hardware:</h3>
-<div class="outline-text-3" id="text-4-2">
+<div id="outline-container-sec-5-2" class="outline-3">
+<h3 id="sec-5-2"><span class="section-number-3">5.2</span> Hardware</h3>
+<div class="outline-text-3" id="text-5-2">
<ul class="org-ul">
<li>Minimum CPU 386.
</li>
</ul>
</div>
</div>
-<div id="outline-container-sec-4-3" class="outline-3">
-<h3 id="sec-4-3"><span class="section-number-3">4.3</span> Human:</h3>
-<div class="outline-text-3" id="text-4-3">
+<div id="outline-container-sec-5-3" class="outline-3">
+<h3 id="sec-5-3"><span class="section-number-3">5.3</span> Human</h3>
+<div class="outline-text-3" id="text-5-3">
<ul class="org-ul">
<li>Beginner level Forth knowledge is recommended.
</li>
</div>
</div>
</div>
-<div id="outline-container-sec-5" class="outline-2">
-<h2 id="sec-5"><span class="section-number-2">5</span> Numbers representation</h2>
-<div class="outline-text-2" id="text-5">
+<div id="outline-container-sec-6" class="outline-2">
+<h2 id="sec-6"><span class="section-number-2">6</span> Numbers representation within Fifth</h2>
+<div class="outline-text-2" id="text-6">
<figure>
<p><a href="numbers.png"><img src="numbers.png" class="img-responsive" alt="numbers.png"></a>
</p>
</div>
</div>
-<div id="outline-container-sec-6" class="outline-2">
-<h2 id="sec-6"><span class="section-number-2">6</span> Disk file map, and it's data structures</h2>
-<div class="outline-text-2" id="text-6">
+<div id="outline-container-sec-7" class="outline-2">
+<h2 id="sec-7"><span class="section-number-2">7</span> Disk file map, and it's data structures</h2>
+<div class="outline-text-2" id="text-7">
<p>
Core and high-level boot code is stored outside of the filesystem to
allow easy access to it, at early booting time, when filesystem is not
yet initialized.
</p>
</div>
-<div id="outline-container-sec-6-1" class="outline-3">
-<h3 id="sec-6-1"><span class="section-number-3">6.1</span> disk allocation</h3>
-<div class="outline-text-3" id="text-6-1">
+<div id="outline-container-sec-7-1" class="outline-3">
+<h3 id="sec-7-1"><span class="section-number-3">7.1</span> disk allocation</h3>
+<div class="outline-text-3" id="text-7-1">
<table class="table table-striped table-bordered table-hover table-condensed">
</table>
</div>
</div>
-<div id="outline-container-sec-6-2" class="outline-3">
-<h3 id="sec-6-2"><span class="section-number-3">6.2</span> FAT entry format:</h3>
-<div class="outline-text-3" id="text-6-2">
+<div id="outline-container-sec-7-2" class="outline-3">
+<h3 id="sec-7-2"><span class="section-number-3">7.2</span> FAT entry format:</h3>
+<div class="outline-text-3" id="text-7-2">
<table class="table table-striped table-bordered table-hover table-condensed">
</table>
</div>
</div>
-<div id="outline-container-sec-6-3" class="outline-3">
-<h3 id="sec-6-3"><span class="section-number-3">6.3</span> file entry format</h3>
-<div class="outline-text-3" id="text-6-3">
+<div id="outline-container-sec-7-3" class="outline-3">
+<h3 id="sec-7-3"><span class="section-number-3">7.3</span> file entry format</h3>
+<div class="outline-text-3" id="text-7-3">
<table class="table table-striped table-bordered table-hover table-condensed">
</div>
</div>
</div>
-<div id="outline-container-sec-7" class="outline-2">
-<h2 id="sec-7"><span class="section-number-2">7</span> Core architecture</h2>
-<div class="outline-text-2" id="text-7">
+<div id="outline-container-sec-8" class="outline-2">
+<h2 id="sec-8"><span class="section-number-2">8</span> Core architecture</h2>
+<div class="outline-text-2" id="text-8">
<p>
Fifth core is simply some amount of already compiled into machine code
and linked together modules (entries in other words). In compilation
any time. Currently dictionary can contain at most 1000 entries.
</p>
</div>
-<div id="outline-container-sec-7-1" class="outline-3">
-<h3 id="sec-7-1"><span class="section-number-3">7.1</span> dictionary entry format</h3>
-<div class="outline-text-3" id="text-7-1">
+<div id="outline-container-sec-8-1" class="outline-3">
+<h3 id="sec-8-1"><span class="section-number-3">8.1</span> Dictionary entry format</h3>
+<div class="outline-text-3" id="text-8-1">
<table class="table table-striped table-bordered table-hover table-condensed">
</p>
</div>
</div>
-<div id="outline-container-sec-7-2" class="outline-3">
-<h3 id="sec-7-2"><span class="section-number-3">7.2</span> Possible module types</h3>
-<div class="outline-text-3" id="text-7-2">
+<div id="outline-container-sec-8-2" class="outline-3">
+<h3 id="sec-8-2"><span class="section-number-3">8.2</span> Possible module types</h3>
+<div class="outline-text-3" id="text-8-2">
<table class="table table-striped table-bordered table-hover table-condensed">
</table>
</div>
</div>
-<div id="outline-container-sec-7-3" class="outline-3">
-<h3 id="sec-7-3"><span class="section-number-3">7.3</span> Memory map: (average)</h3>
-<div class="outline-text-3" id="text-7-3">
+<div id="outline-container-sec-8-3" class="outline-3">
+<h3 id="sec-8-3"><span class="section-number-3">8.3</span> Memory map (average)</h3>
+<div class="outline-text-3" id="text-8-3">
<table class="table table-striped table-bordered table-hover table-condensed">
</div>
</div>
</div>
-<div id="outline-container-sec-8" class="outline-2">
-<h2 id="sec-8"><span class="section-number-2">8</span> Fifth source format</h2>
-<div class="outline-text-2" id="text-8">
+<div id="outline-container-sec-9" class="outline-2">
+<h2 id="sec-9"><span class="section-number-2">9</span> Virtual machine</h2>
+<div class="outline-text-2" id="text-9">
+<p>
+Using CPU emulator slows it down but I shouldn't now think too mutch
+about, and waste my time on batteling with problems whitch results on
+complex design of PC hardware. Also it allows me to use existing DOS
+and resident drivers services in real mode. So I don't need to deal
+with hardware too mutch. It also allows me to use all free XMS for
+flat code & data storage.
+</p>
+
+<p>
+Current emulator emulates 1 CPU. It has 2 stacks, ~50 instructions,
+and 4GB flat address space (theoretically). I'm not sure that DOS
+6.22 that I currently prefer can handle more than 64 MB of RAM. While
+I tried to keep instructionset simple, I was forced to put in lot of
+complex instructions to make it's performance acceptable on
+emulator. On actual silicon ~20 instructions is enaugh (I think).
+</p>
+
+<p>
+Maybe one day similar system will run directly on custom silicon chip :)
+</p>
+
+
+<p>
+CPU has following registers:
+</p>
+<table class="table table-striped table-bordered table-hover table-condensed">
+
+
+<colgroup>
+<col class="left">
+
+<col class="left">
+</colgroup>
+<tbody>
+<tr>
+<td class="text-left">IP</td>
+<td class="text-left">instruction pointer</td>
+</tr>
+
+<tr>
+<td class="text-left">DSP</td>
+<td class="text-left">data stack pointer</td>
+</tr>
+
+<tr>
+<td class="text-left">RSP</td>
+<td class="text-left">return stack pointer</td>
+</tr>
+</tbody>
+</table>
+
+<p>
+Virtual CPU, commands (most of them are avaiable as ordinary commands
+in programming lanquage):
+</p>
+
+<p class="verse">
+<br >
+code mnemonic description<br >
+<br >
+0 nop does notheing<br >
+1 halt halt CPU ( return to DOS on emulator )<br >
+<br >
+2 kbd@ ( – c ) read scancode of pressed or released key.<br >
+                                Returns 0, if no data avaiable.<br >
+3 num <dword> ( – n ) put immidiate number into datastack<br >
+<br >
+4 jmp <dword> jump to specified code<br >
+5 call <dword>jump to specified code, save return address to<br >
+                                return stack.<br >
+<br >
+6 1+ ( n – n+1 )<br >
+7 1- ( n – n-1 )<br >
+<br >
+8 dup ( n – n n ) duplicate top of data stack<br >
+9 drop ( n – ) drop last element in data stack<br >
+<br >
+10 if <dword> ( n – ) jump to addr if top element was 0<br >
+11 ret jump to code, specified in return stack.<br >
+<br >
+12 c@ ( addr – n ) read byte from memory at specified address<br >
+13 c! ( n addr – ) store byte to specified memory<br >
+<br >
+14 push ( DSTK -> RSTK ) move top of datastack to returnstack<br >
+15 pop ( RSTK -> DSTK ) move top of returnstack to datastack<br >
+<br >
+16 <unused><br >
+17 rot ( n1 n2 n3 – n2 n3 n1) rotate stack elements<br >
+<br >
+18 disk@ ( FromDiskSect ToMem – ) read 1KB from disk into RAM<br >
+19 disk! ( FromMem ToDiskSect – ) write 1KB to disk<br >
+<br >
+20 @ ( addr – n ) read 32 bit number from memory<br >
+21 ! ( n addr – ) store 32 bit number to memory<br >
+<br >
+22 over ( n1 n2 – n1 n2 n1 ) self explaining …<br >
+23 swap ( n1 n2 – n2 n1 ) -,,-<br >
+<br >
+24 + ( n1 n2 – n1+n2 ) -,,-<br >
+25 - ( n1 n2 – n1-n2 ) -,,-<br >
+<br >
+26 * ( n1 n2 – n1*n2 ) -,,-<br >
+27 / ( n1 n2 – n1/n2 ) -,,-<br >
+<br >
+28 > ( n1 n2 – result ) is true when n1 > n2<br >
+29 < ( n1 n2 – result ) is true when n1 < n2<br >
+<br >
+30 not ( n1 – not_n1 ) logical not<br >
+31 i ( – n ) copies top of return stack into datastack<br >
+<br >
+32 cprt@ ( addr – n ) read one byte from hardware port<br >
+33 cprt! ( n addr – ) store one byte to hardware port<br >
+<br >
+34 i2 ( – n ) like "i" but takes socond top stack element.<br >
+35 i3 ( – n ) like "i" but takes third top stack element.<br >
+<br >
+36 shl ( n amount – n ) left bit shift<br >
+37 shr ( n amount – n ) right bit shift<br >
+<br >
+38 or ( n1 n2 – n ) logical or<br >
+39 xor ( n1 n2 – n ) exclusive logical or<br >
+<br >
+40 vidmap ( addr – ) copy memory from "addr" to video memory.<br >
+<br >
+41 mouse@ ( – x y button ) read mouse coordinates & buttons<br >
+<br >
+42 vidput ( addr1 addr2 x y – ) put image1 into image2, at<br >
+                                location x, y. Does clipping, so part of a big image<br >
+                                can be mapped into smaller one.<br >
+<br >
+43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2<br >
+                                if addr1 is greater than addr2 then count address<br >
+                                foward while moving, elseway starts from end and<br >
+                                counts backwards, so no data loss will occure on<br >
+                                overlapping.<br >
+<br >
+44 cfill ( c addr amount – ) fill memory starting at "addr"<br >
+                                with "c" bytes.<br >
+<br >
+45 tvidput ( addr1 addr2 x y – ) same as "vidput" but treats<br >
+                                color 255 in source image as transparent.<br >
+<br >
+46 depth ( – depth ) returns current depth of data stack.<br >
+<br >
+47 charput ( colorfg colorbg addrsrc addrdest x y )<br >
+                                draw character to image buffer located at "addrdest"<br >
+                                to specified x & y location. Decodes 8 bytes from<br >
+                                source to bits, used to draw character.<br >
+</p>
+</div>
+</div>
+
+<div id="outline-container-sec-10" class="outline-2">
+<h2 id="sec-10"><span class="section-number-2">10</span> Fifth source format</h2>
+<div class="outline-text-2" id="text-10">
<p>
Fifth uses a different character table and codes than ASCII (still
almost similar). I call it FSCII (Fifth Standard Code for Information
like ordinary letters.
</p>
</div>
-<div id="outline-container-sec-8-1" class="outline-3">
-<h3 id="sec-8-1"><span class="section-number-3">8.1</span> FSCII:</h3>
-<div class="outline-text-3" id="text-8-1">
+<div id="outline-container-sec-10-1" class="outline-3">
+<h3 id="sec-10-1"><span class="section-number-3">10.1</span> FSCII</h3>
+<div class="outline-text-3" id="text-10-1">
<table class="table table-striped table-bordered table-hover table-condensed">
</div>
</div>
</div>
+<div id="outline-container-sec-11" class="outline-2">
+<h2 id="sec-11"><span class="section-number-2">11</span> Fifth commands</h2>
+<div class="outline-text-2" id="text-11">
+</div><div id="outline-container-sec-11-1" class="outline-3">
+<h3 id="sec-11-1"><span class="section-number-3">11.1</span> Compilation & miscellaneous</h3>
+<div class="outline-text-3" id="text-11-1">
+<p class="verse">
+init module ( – )<br >
+                First module, control is passed to on startup. Contains<br >
+                initialization routines. Also it is the last core module.<br >
+                All new modules on top of it comes as result of executing<br >
+                external source files.<br >
+<br >
+head <name> ( – ) compiles new dictionary entry without specifying<br >
+                new module type.<br >
+                ex: head myentry<br >
+<br >
+: <name> ( – ) creates new code module<br >
+; ( – ) ends module (immideate)<br >
+                ex: : hello ." hi there" ;<br >
+<br >
+const <name> ( n – ) defines new constant.<br >
+                ex: 2147483647 const max<br >
+<br >
+:i <name> ( – ) same as ":" but this module will be executed<br >
+                immideately even in compile mode.<br >
+                ex: :i ( 41 scan ;<br >
+<br >
+create <name> ( – ) same as "head" , but specify module type as data.<br >
+                ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br >
+<br >
+allot ( n – ) allocate n bytes in dictionary.<br >
+                ex: create MyArray 100 allot<br >
+<br >
+" <string>" ( – ) compile string and its size into core.<br >
+                ex: create Mystring " This is it's contects"<br >
+<br >
+str <name> <string>" ( – ) just shorter way for defining strings.<br >
+                ex: str Mystring This is it's contenc"<br >
+<br >
+var <name> ( – ) define new 32 bit variable.<br >
+                ex: var result<br >
+<br >
+' <module> ( – n ) return memory address of given entry.<br >
+                ex: ' init<br >
+<br >
+forget <name> ( – ) erases from RAM given entry and all entries what was<br >
+                defined after it.<br >
+                ex: forget myprog<br >
+<br >
+[ ( – ) set interpret mode (immideate)<br >
+] ( n – ) set compile mode and compile top stack element<br >
+                in as literal. Together [ …. ] cobination provides good<br >
+                way to compute some values only once, at compile time,<br >
+                rather than every time while program is running.<br >
+                ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br >
+<br >
+defer <name> ( – ) creates new module, with jump instruction.<br >
+                Later address where to jump can be modified by "is" command.<br >
+                This provides method of foward referencing. So you can use<br >
+                modules what not jet exist.<br >
+is ( address1 address2 – ) address1 - where to jump, address2 -<br >
+                address of module created by defer command.<br >
+                ex: defer dispver<br >
+                        : run dispver ." running …" ;<br >
+                               … whatever …<br >
+                        : (dispver ." Version 9.99 " ;<br >
+                        ' (dispver ' dispver is<br >
+<br >
+                Now if I type "run" on the screen appears:<br >
+                        Version 9.99 running …<br >
+<br >
+asc <char> ( – ) reads char ascii code and treats it as literal.<br >
+                (immideate)<br >
+                ex: : BreakLine 30 do asc - emit loop ;<br >
+                                 same as:<br >
+                    : BreakLine 30 do 45 emit loop ;<br >
+<br >
+dyninc ( handle – ) execute code in dynamic memory handle.<br >
+                automatically deallocates it when done.<br >
+<br >
+include ( filenumber – ) execute code in specified file.<br >
+<br >
+words ( – ) display existing blocks in core.<br >
+<br >
+bye ( – ) exit from Fifth<br >
+<br >
+fkey ( – c )<br >
+                Read one byte from input stream.<br >
+<br >
+sadd ( c addr – )<br >
+                Add one byte "c" to string located at "addr" and updates<br >
+                string length.<br >
+<br >
+scan ( c – )<br >
+                Read input stream and store it to pad until it finds c .<br >
+                It ignores all "c" bytes until it finds any non "c" byte.<br >
+                in other words:<br >
+                                c is: "<br >
+                         input stream: """"This is test !"aoeu idh<br >
+                               result: This is test !<br >
+<br >
+                Is useful for breaking text lines into words.<br >
+<br >
+skey ( – c )<br >
+                So called safe "fkey". Reads data from input stream<br >
+                but converts characters with ASCII codes: 9 13 10<br >
+                to spaces.<br >
+<br >
+str=str? ( adr1 adr2 – result )<br >
+                Compares string at "adr1" with string at "adr2", returns<br >
+                true flag if they are equal or false if they are not.<br >
+                true = -1<br >
+                false = 0<br >
+<br >
+find ( – addr )<br >
+                Searches whole dictionary for word in "pad". If found,<br >
+                returns it address, if not, returns 0.<br >
+<br >
+execute ( – )<br >
+                Execute word located in "pad". Depending on "mode".<br >
+<br >
+dta ( addr – DataAddr )<br >
+                Calculates address of dictionary entry data area, from<br >
+                entry point.<br >
+<br >
+2num ( – num result )<br >
+                Attempt to convert string located in "pad" into numeric<br >
+                value. If succeed returns number and true as result.<br >
+                If not, returns whatever and false as result.<br >
+<br >
+dadd ( addr length – )<br >
+                Add to dictionary data located at "addr", with specified<br >
+                length.<br >
+<br >
+lit ( n – )<br >
+                Act with number depending on "mode". When interpreting,<br >
+                leaves it in stack.<br >
+<br >
+<br >
+incmod ( addr – )<br >
+                Add to dictionary data located at "addr"+1 , length is taken<br >
+                from "addr".<br >
+<br >
+here ( – n )<br >
+                return "h" contents.<br >
+<br >
+mode var 8 bit<br >
+                Holds input stream parser operation mode.<br >
+                0 = interpreting<br >
+                1 = compiling<br >
+<br >
+pad var 128 bytes<br >
+                Holds temprorary strings.<br >
+<br >
+h var 32 bit<br >
+                Pointer to free byte in memory, always at the end of the<br >
+                dictionary. Each time when something is stored<br >
+                by "c," command, pointer is incareased.<br >
+<br >
+lp var 32 bit<br >
+                Pointer to last dictionary word. Each time when new word is<br >
+                compiled or erased by "forget", this pointer is updated.<br >
+<br >
+modulechk ( Dstr<filename> – ) check if module is loaded, if not<br >
+                immideately load it.<br >
+<br >
+ne ( entrydata entrytype – ) Compile new dictionary entry.<br >
+                It's name must be in "pad".<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-2" class="outline-3">
+<h3 id="sec-11-2"><span class="section-number-3">11.2</span> Conditionals & control flow</h3>
+<div class="outline-text-3" id="text-11-2">
+<p class="verse">
+if ( flag – ) (immideate)<br >
+                "if 1.. else 2.. then" or<br >
+                "if 1.. then" construction. Conditional execution.<br >
+                Performs "1.." if "flag" was true,<br >
+                elseway performs "2.." if exist. Execution continues after<br >
+                word "then".<br >
+                ex: 1 if ." nonzero" else ." zero" then<br >
+<br >
+>= ( n1 n2 – result ) true if (n1 = n2) or (n1 > n2)<br >
+                ex: 5 3 >= if ." first number is greater or equal" then<br >
+<br >
+<= ( n1 n2 – result ) true if (n1 = n2) or (n1 < n2)<br >
+= ( n1 n2 – result ) true if n1 = n2<br >
+<br >
+do ( count – ) (immideate)<br >
+                "do .. loop" construction. Performs ".." "count" times.<br >
+                In every step "count" is decareased until it is 0.<br >
+                ex: : test 5 do i .d loop ;<br >
+                result: 4 3 2 1 0<br >
+<br >
+doexit ( – ) exit from "do .. loop"<br >
+<br >
+for ( count top – ) (immideate)<br >
+                "for .. loop" construction. Performs ".." (top - count) times.<br >
+                In every step "count" is incareased until it reaches "top" .<br >
+                ex: : test 4 10 for i .d loop ;<br >
+                result: 4 5 6 7 8 9<br >
+<br >
+forexit ( – ) exit from "for .. loop"<br >
+<br >
+until ( – ) (immideate)<br >
+                "until .. loop" construction. Performs ".." until flag become<br >
+                true. False by default. Top of return stack holds flag.<br >
+<br >
+done ( – ) exit from "until .. loop"<br >
+<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-3" class="outline-3">
+<h3 id="sec-11-3"><span class="section-number-3">11.3</span> Disk & file access</h3>
+<div class="outline-text-3" id="text-11-3">
+<p class="verse">
+diskload ( FromDisk ToMem amount – )<br >
+                Load specified abount of bytes from disk into memory.<br >
+<br >
+disksave ( FromMem ToDisk amount – )<br >
+                save specified abount of bytes from memory into disk.<br >
+<br >
+format ( – ) Erase all files.<br >
+<br >
+fsDfilesize@ ( handle – size )<br >
+                Return size of opened file.<br >
+<br >
+fsDcurloc@ ( handle – location )<br >
+                Return current location in file.<br >
+<br >
+fsDupdated@ ( handle – updated? )<br >
+                Return true if file was updated,<br >
+                ie. write operations occured.<br >
+<br >
+fssave ( FromMem DestFileHandle amount – )<br >
+                Save data to file.<br >
+<br >
+fsload ( SrcFileHandle ToMem amount – )<br >
+                Load data from file.<br >
+<br >
+fseof ( handle – bytesLeft )<br >
+                Return amount of bytes left till end of file.<br >
+                Useful before read operation.<br >
+<br >
+fsls ( – ) List all files and lists (directories,folders)<br >
+                in current path.<br >
+<br >
+fslsr ( – ) Same as "fsls" but recursively scans also sub lists.<br >
+<br >
+fscl ( DynStrHand – )<br >
+                Change list (path)<br >
+<br >
+fscreate ( DynStrHand – DescPnt )<br >
+                Create new file or list. Can create multiple lists at once.<br >
+                ex: when creating:<br >
+                    "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"<br >
+                and only "\listGAMES\" already exist, then<br >
+                "listSTRATEGY" and "listSIMWORLD" lists will be created,<br >
+                and empty file "5th-runme" placed in there.<br >
+<br >
+fsDsave ( DynHand<data> DynStrHand<filename> – )<br >
+                Create new file and save all data from dynamic memory<br >
+                block to it.<br >
+<br >
+fsDload ( DynStr<SrcFileName> DynHand<DataDest> – )<br >
+                Load whole file into dynamic memory block.<br >
+<br >
+fsDloadnew ( DynStr<SrcFileName> – DynHand<DataDest> )<br >
+                Load whole file into new dynamic memory block.<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-4" class="outline-3">
+<h3 id="sec-11-4"><span class="section-number-3">11.4</span> Dynamic memory</h3>
+<div class="outline-text-3" id="text-11-4">
+<p class="verse">
+dynal ( size – handle )<br >
+                Allocate dynamic memory block and return it's handle.<br >
+<br >
+dynde ( handle – )<br >
+                Deallocate dynamic memory block.<br >
+<br >
+dynp ( handle – addr )<br >
+                Returns pointer to memory where dynamic block<br >
+                data begins.<br >
+<br >
+dyns ( handle – size )<br >
+                Returns size of dynamic block.<br >
+<br >
+dynresize ( NewSize handle – )<br >
+                Nondestructively resize dynamic block.<br >
+<br >
+dync@ ( addr handle )<br >
+                Read one byte from dynamic block.<br >
+<br >
+dync! ( byte addr dynhandle )<br >
+                Write one byte to dynamic block.<br >
+<br >
+dyn@ ( addr handle )<br >
+                Read 32 bit number from dynamic block.<br >
+                Address will spacify, whitch number, not byte.<br >
+<br >
+dyn! ( 32BitNum addr dynhandle )<br >
+                Write 32 bit number to dynamic block.<br >
+                Address will spacify, whitch number, not byte.<br >
+<br >
+dyncon ( size "name" – )<br >
+                Allocate dynamic block with specified size, and<br >
+                create constant honding its handle.<br >
+                ex: 100 dyncon MyNewBlock<br >
+<br >
+dyn. ( handle – )<br >
+                Write contenc of dynamic memory block to screen.<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-5" class="outline-3">
+<h3 id="sec-11-5"><span class="section-number-3">11.5</span> Graphics and text</h3>
+<div class="outline-text-3" id="text-11-5">
+<p class="verse">
+. ( n – ) print number on screen<br >
+<br >
+d. ( n – ) print number on screen in decimal<br >
+<br >
+? ( addr – ) print 32 bit value located at addr.<br >
+<br >
+." <string>" ( – ) print string into screen. Immideately<br >
+                compiles.<br >
+                ex: : greeting ." Hello, World" ;<br >
+<br >
+tab. ( – ) print tabulator<br >
+<br >
+calccol ( b g r – c ) calculate color what best matches given<br >
+                Blue Green & Red values. Values must be in range 0 - 255.<br >
+<br >
+imgalloc ( xsize ysize – imgbuf ) allocate image buffer for<br >
+                specified size.<br >
+<br >
+imgsize ( imgbuf – ) print on the screen X & Y size of image<br >
+                buffer.<br >
+<br >
+point ( x y imgbuf – addr ) returns memory address for specified<br >
+                pixel.<br >
+<br >
+pset ( color x y imgbuf – ) set graphic point<br >
+<br >
+boxf ( x1 x2 y1 y2 imgbuf color – ) draw filled box<br >
+<br >
+cls ( imgbuf – ) clear image buffer<br >
+<br >
+setpal ( b g r color – ) set palette value for specified color.<br >
+                values bust be in size 0 - 63.<br >
+<br >
+putchar ( char color x y imgbuf – ) put graphic character in<br >
+                imagebuffer to specified (x & y) location.<br >
+<br >
+scroll ( x y imgbuf – ) scroll in imgbuf.<br >
+<br >
+scrollf ( color x y screen – ) scroll and fill empty space with<br >
+                given color.<br >
+<br >
+at! ( x y – ) set cursor location<br >
+curc! ( color – ) set text color<br >
+curb! ( solor – ) set backround color<br >
+<br >
+colnorm ( – ) set text color to normal<br >
+colneg ( – ) set text color to negative (selected)<br >
+<br >
+dyntype ( dynhandle – ) display contenc of dynamic memory on screen<br >
+fsdisp ( file – ) clear screen, display file, and wait for key<br >
+<br >
+type ( addr length – )<br >
+                Types on the screen string, from memory at addr and<br >
+                specified length.<br >
+<br >
+write ( addr – )<br >
+                Types on the screen string, from memory at "addr"+1<br >
+                length is taken from "addr" .<br >
+<br >
+screen const 32 bit<br >
+                Holds handle of screen buffer.<br >
+<br >
+copyscreen ( SrcImgHandle DestImgHandle – ) copy contenc of source<br >
+                image to destination image. Source and destination images<br >
+                must have same size.<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-6" class="outline-3">
+<h3 id="sec-11-6"><span class="section-number-3">11.6</span> Math, memory & stack manipulation</h3>
+<div class="outline-text-3" id="text-11-6">
+<p class="verse">
+off ( n – ) writes 0 to given address, good for zeroing variable.<br >
+                ex: MyVariable off<br >
+on ( n – ) writes -1 (true flag) to given address.<br >
+                ex: MyVariable on<br >
+<br >
+2dup ( n1 n2 – n1 n2 n1 n2 )<br >
+2drop ( n1 n2 – )<br >
+nip ( n1 n2 – n2 )<br >
+neg ( n1 – -n1 ) negotiate<br >
+bit@ ( n bit – result ) return specified bit from n.<br >
+                ex: 38 2 bit@ (result will be 1)<br >
+to32bit ( n1 n2 n3 n4 – n32 ) treat 4 last stack elements as bytes<br >
+                and unite them into 32 bit dword. Most significant byte<br >
+                on top.<br >
+                ex: 12 76 23 11 to32bit result: 186076172<br >
+<br >
+to8bit ( n32 – n1 n2 n3 n4 ) break 32 bit number into 4 bytes.<br >
+                Useful if you need to send 32 bit numbers thru 8 bit COM<br >
+                port.<br >
+                ex: 186076172 to8bit result: 12 76 23 11<br >
+<br >
+mod ( n1 n2 – reminder ) divide n1 by n2 and returns reminder.<br >
+                ex: 12 5 mod result: 2<br >
+<br >
+bound ( low n high – n ) check if n is in given bounds,<br >
+                if not then incarease/decarease it to match bounds.<br >
+                ex: 5 80 15 bound result: 15<br >
+                    5 10 15 bound result: 10<br >
+                    5 -10 15 bound result: 5<br >
+<br >
+bound? ( low n high – result ) returns true if n is in the<br >
+                given bounds.<br >
+<br >
+tab ( col – spaces) calculate amount of spaces to add<br >
+                ta reach next tabulation from given column.<br >
+<br >
+count ( addr – addr+1 n )<br >
+                Useful for returning bytes from constantly incareasing<br >
+                address. Module "type" is nice example.<br >
+<br >
+c, ( n – )<br >
+                store one byte at memory specified by "h". And incarease<br >
+                "h" by 1.<br >
+<br >
+, ( n – )<br >
+                store 32 bit number at memory specified by "h". And<br >
+                incarease "h" by 4.<br >
+<br >
+cmove ( addr1 addr2 n – )<br >
+                copy "n" amount of bytes from memory at "addr1" to memory<br >
+                at "addr2".<br >
+<br >
+rnd ( limit – result )<br >
+                generates random number in range 0 to "limit"-1.<br >
+<br >
+abs ( n – |n| )<br >
+                returns absolute value of "n"<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-11-7" class="outline-3">
+<h3 id="sec-11-7"><span class="section-number-3">11.7</span> Dynamic & static strings</h3>
+<div class="outline-text-3" id="text-11-7">
+<p>
+Fifth supports both static and dynamic strings. Static strings must
+have predefined space reserved, and string mustn't exceed this
+length. They manipulation is faster. But they use more memory. Static
+string memory address is used to refer to the string.
+</p>
+
+<p>
+Dynamic strings can have at any time length form 0 to 0FFh, They take
+up only memory they currently need. They are held in dynamic memory
+blocks, so dynamic block handle is used to refer to this string.
+</p>
+
+<p>
+Both types of strings are stored in the way, where first (0th) byte
+holds current string length, following bytes are string itself.
+</p>
+
+
+<p class="verse">
+Dynamic:<br >
+<br >
+Dstral ( – handle )<br >
+                Allocate new string.<br >
+<br >
+Dstrlen ( handle – length )<br >
+                Return string length.<br >
+<br >
+c+Dstr ( chr handle – )<br >
+                Add one byte to end of the string.<br >
+<br >
+c+lDstr ( chr handle – )<br >
+                Add one byte to left side (beginning) of the string.<br >
+<br >
+Dstr. ( handle – )<br >
+                Write contec of string into screen.<br >
+<br >
+Dstrsure ( size Dstr – )<br >
+                Makes sure that at least rquested<br >
+                "size" (amount of characters) is allocated for given<br >
+                dynamic string.<br >
+<br >
+Dstr2str ( handle address – )<br >
+                Copy dyamic string into static memory space.<br >
+<br >
+str2Dstr ( address handle – )<br >
+                Copy static string into dyamic string.<br >
+<br >
+Dstr+str ( Dstr addr – )<br >
+                Add contenc of dynamic string to static string.<br >
+<br >
+D" any string" ( – Dstr )<br >
+                Moves specified string into dynamic string called "defDstr".<br >
+<br >
+D> any_string ( – Dstr )<br >
+                Moves specified string into dynamic string called "defDstr".<br >
+                Space marks end of string!<br >
+<br >
+D>2 any_string ( – Dstr )<br >
+                Moves specified string into dynamic string called "defDstr2".<br >
+                Space marks end of string!<br >
+<br >
+Dstr+Dstr ( Dstr1 Dstr2 – )<br >
+                Adds "Dstr1" to "Dstr2" and places result into "Dstr2".<br >
+<br >
+Dstrclear ( Dstr – )<br >
+                Clears contenc of dynamic string.<br >
+<br >
+Dstr2Dstr ( Dstr1 Dstr2 – )<br >
+                Moves "Dstr1" to "Dstr2".<br >
+Dstr ( data" name – )<br >
+                Creates new dynamic string and moves specified data into it.<br >
+                Then creates new constant with given "name" holding created<br >
+                dynamic string handle.<br >
+<br >
+                ex: Dstr Hello, my name is Sven!" message \ creates it<br >
+                    message Dstr. \ tests it<br >
+<br >
+Dstrlscan ( char Dstr – loc )<br >
+                Searches dynamic string for "char", from left to right,<br >
+                returns first found "char" location in string, or 0,<br >
+                if not found.<br >
+<br >
+Dstrrscan ( char Dstr – loc )<br >
+                Searches dynamic string for "char", from right to left,<br >
+                returns first found "char" location in string, or 0,<br >
+                if not found.<br >
+<br >
+Dstrlscane ( char Dstr – loc )<br >
+                Same as "Dstrlscan" buf returns string length+1 as location.<br >
+ÿ<br >
+Dstrleft ( amo Dstr – )<br >
+                Only specified amount of characters from left remains<br >
+                in dynamic string. ie. cut right part out.<br >
+<br >
+Dstrright ( amo Dstr – )<br >
+                Only specified amount of characters from right remains<br >
+                in dynamic string. ie. cut left part out.<br >
+<br >
+Dstrcutl ( amo Dstr – )<br >
+                Cut specified amount of characters from left of dynamic<br >
+                string out.<br >
+<br >
+Dstrsp ( char Dstr1 Dstr2 – )<br >
+                Separate dynamic string in Dstr1 into two parts,<br >
+                using "char" as separator. First part will be stored in<br >
+                "Dstr2", second part in "Dstr1".<br >
+                ex: asc \ \ ..separator<br >
+                    D> listF\listLIB\5TH_DRVMOUSE \ ..separate from<br >
+                    defDstr2 \ ..place result in<br >
+                    Dstrsp \ separation command<br >
+                    defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE<br >
+                    defDstr2 Dstr. \ will be: listF<br >
+<br >
+Dv ( addr – )<br >
+                Allocates empty dynamic string, and places it's handle<br >
+                into given address.<br >
+<br >
+Df ( addr – )<br >
+                Reads dynamic string handle from given address and<br >
+                deallocates (frees) it.<br >
+<br >
+ex: var mystring1<br >
+        : testmodule<br >
+        mystring1 Dv \ allocates string<br >
+<br >
+                <whatever><br >
+<br >
+        mystring1 Df ; \ deallocates it again when no longer needed.<br >
+</p>
+</div>
+</div>
+</div>
+<div id="outline-container-sec-12" class="outline-2">
+<h2 id="sec-12"><span class="section-number-2">12</span> Dynamically loadable modules</h2>
+<div class="outline-text-2" id="text-12">
+</div><div id="outline-container-sec-12-1" class="outline-3">
+<h3 id="sec-12-1"><span class="section-number-3">12.1</span> Keyboard driver</h3>
+<div class="outline-text-3" id="text-12-1">
+<p class="verse">
+<br >
+KBD_@ ( – code ) get scancodes for pressed keys from keyboard.<br >
+KBD_down? ( key – result ) check is key with specified scancode<br >
+                currently pressed down.<br >
+KBD_SC2FSCII ( code – FSCII ) convert key scancode into FSCII code,<br >
+                or in FSK (Fifth standard keycode).<br >
+KBD_F@ ( – FSCII ) read pressed key FSCII or FSK, returns -1 if no<br >
+                keys are pressed.<br >
+KBD_FW@ ( – FSCII ) read pressed key FSCII or FSK, if no keys is<br >
+                are pressed then waits until there is.<br >
+<br >
+                FSK<br >
+                —<br >
+In HEX.<br >
+<br >
+FC backspace<br >
+FD TAB<br >
+FE enter<br >
+FF space<br >
+<br >
+400 ESC<br >
+401 … F1 …<br >
+410 up<br >
+411 right<br >
+412 down<br >
+413 left<br >
+414 INS<br >
+415 DEL<br >
+416 home<br >
+417 end<br >
+418 PG/UP<br >
+419 PG/DN<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-12-2" class="outline-3">
+<h3 id="sec-12-2"><span class="section-number-3">12.2</span> Mouse driver</h3>
+<div class="outline-text-3" id="text-12-2">
+<p class="verse">
+mousex var Mouse x coordinate.<br >
+mousey var Mouse y coordinate.<br >
+mousekeyl var Mouse left key.<br >
+mousekeym var Mouse middle key.<br >
+mousekeyr var Mouse right key.<br >
+mousec var Display current mouse coordinates in top left part of screen,<br >
+                if true. (good for debugging)<br >
+mousepointer var Image buffer, holding current mouse pointer.<br >
+mouseadd ( ModuleAddr x1 x2 y1 y2 – ) Add specified area on screen,<br >
+                into mause click buffer. If any mouse button is clicked on<br >
+                that area, module at "ModuleAddr" will be executed.<br >
+mousebe var Amount of buffer elements.<br >
+mousedo ( – ) Updates mouse coordinates and keys. Parse mouse<br >
+                click buffer, and draw mouse cursor to "screen".<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-12-3" class="outline-3">
+<h3 id="sec-12-3"><span class="section-number-3">12.3</span> 2D graphic library</h3>
+<div class="outline-text-3" id="text-12-3">
+<p class="verse">
+lineh ( color len x y imgbuf – ) draws horisontal line<br >
+                from X,Y coordinates to right, with specified length.<br >
+linev ( color len x y imgbuf – ) draws vertical line<br >
+                down, from coordinates X,Y, with specified length.<br >
+box ( color x2 x1 y2 y1 imgbuf – ) draws rectangular<br >
+                box. x2 bust be >= x1, y2 must be >= y1.<br >
+                        x1,y1–———+<br >
+                          | |<br >
+                          | |<br >
+                          +–———x2,y2<br >
+<br >
+flipv ( imgbuf – ) flip image vertically.<br >
+imgcoltrans ( ImgBuf Color ToColor – ) Translate all pixels in<br >
+                specified image with "Color" into "ToColor".<br >
+imgfill ( color x y imgbuf – ) Fill image region starting at location<br >
+                X & Y with specified color.<br >
+</p>
+</div>
+</div>
+<div id="outline-container-sec-12-4" class="outline-3">
+<h3 id="sec-12-4"><span class="section-number-3">12.4</span> Trigonometry functions</h3>
+<div class="outline-text-3" id="text-12-4">
+<p class="verse">
+sin ( a – result ) return sinus from given angle "a",<br >
+                360ø is 2000. So 1000 represents 180ø angle.<br >
+                Result will be in range -10'000 to 10'000, instead of ñ1.<br >
+<br >
+cos ( a – result ) return cosinus from given angle.<br >
+                Parameters are like in "sin" function.<br >
+</p>
+</div>
+</div>
+</div>
</div><div class="col-md-3"><nav id="table-of-contents">
<div id="text-table-of-contents" class="bs-docs-sidebar">
<ul class="nav">
<li><a href="#sec-1">1. !Project deprecated!</a></li>
-<li><a href="#sec-2">2. Introduction</a></li>
+<li><a href="#sec-2">2. Introduction</a>
+<ul class="nav">
+<li><a href="#sec-2-1">2.1. screenshots</a></li>
+</ul>
+</li>
<li><a href="#sec-3">3. Installation</a></li>
-<li><a href="#sec-4">4. Software/Hardware/Human requirements</a>
+<li><a href="#sec-4">4. Fifth distribution directory tree description</a></li>
+<li><a href="#sec-5">5. Software/Hardware/Human requirements</a>
+<ul class="nav">
+<li><a href="#sec-5-1">5.1. Software</a></li>
+<li><a href="#sec-5-2">5.2. Hardware</a></li>
+<li><a href="#sec-5-3">5.3. Human</a></li>
+</ul>
+</li>
+<li><a href="#sec-6">6. Numbers representation within Fifth</a></li>
+<li><a href="#sec-7">7. Disk file map, and it's data structures</a>
+<ul class="nav">
+<li><a href="#sec-7-1">7.1. disk allocation</a></li>
+<li><a href="#sec-7-2">7.2. FAT entry format:</a></li>
+<li><a href="#sec-7-3">7.3. file entry format</a></li>
+</ul>
+</li>
+<li><a href="#sec-8">8. Core architecture</a>
<ul class="nav">
-<li><a href="#sec-4-1">4.1. Software:</a></li>
-<li><a href="#sec-4-2">4.2. Hardware:</a></li>
-<li><a href="#sec-4-3">4.3. Human:</a></li>
+<li><a href="#sec-8-1">8.1. Dictionary entry format</a></li>
+<li><a href="#sec-8-2">8.2. Possible module types</a></li>
+<li><a href="#sec-8-3">8.3. Memory map (average)</a></li>
</ul>
</li>
-<li><a href="#sec-5">5. Numbers representation</a></li>
-<li><a href="#sec-6">6. Disk file map, and it's data structures</a>
+<li><a href="#sec-9">9. Virtual machine</a></li>
+<li><a href="#sec-10">10. Fifth source format</a>
<ul class="nav">
-<li><a href="#sec-6-1">6.1. disk allocation</a></li>
-<li><a href="#sec-6-2">6.2. FAT entry format:</a></li>
-<li><a href="#sec-6-3">6.3. file entry format</a></li>
+<li><a href="#sec-10-1">10.1. FSCII</a></li>
</ul>
</li>
-<li><a href="#sec-7">7. Core architecture</a>
+<li><a href="#sec-11">11. Fifth commands</a>
<ul class="nav">
-<li><a href="#sec-7-1">7.1. dictionary entry format</a></li>
-<li><a href="#sec-7-2">7.2. Possible module types</a></li>
-<li><a href="#sec-7-3">7.3. Memory map: (average)</a></li>
+<li><a href="#sec-11-1">11.1. Compilation & miscellaneous</a></li>
+<li><a href="#sec-11-2">11.2. Conditionals & control flow</a></li>
+<li><a href="#sec-11-3">11.3. Disk & file access</a></li>
+<li><a href="#sec-11-4">11.4. Dynamic memory</a></li>
+<li><a href="#sec-11-5">11.5. Graphics and text</a></li>
+<li><a href="#sec-11-6">11.6. Math, memory & stack manipulation</a></li>
+<li><a href="#sec-11-7">11.7. Dynamic & static strings</a></li>
</ul>
</li>
-<li><a href="#sec-8">8. Fifth source format</a>
+<li><a href="#sec-12">12. Dynamically loadable modules</a>
<ul class="nav">
-<li><a href="#sec-8-1">8.1. FSCII:</a></li>
+<li><a href="#sec-12-1">12.1. Keyboard driver</a></li>
+<li><a href="#sec-12-2">12.2. Mouse driver</a></li>
+<li><a href="#sec-12-3">12.3. 2D graphic library</a></li>
+<li><a href="#sec-12-4">12.4. Trigonometry functions</a></li>
</ul>
</li>
</ul>
</div></div></div>
<footer id="postamble" class="">
<div><p class="author">Author: Svjatoslav Agejenko</p>
-<p class="date">Created: 2017-11-29 Wed 23:48</p>
+<p class="date">Created: 2018-01-01 Mon 23:29</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.1.1 (<a href="http://orgmode.org">Org-mode</a> 8.2.10)</p>
</div>
</footer>
similar. Basically I got familiar with concepts of Forth, and being
inspired created my own system.
+- [[file:5TH_ET.txt][Example Fifth source file - text editor]]
+** screenshots
+- [[file:screenshots/start.png]]
+ - Startup screen diplaying Fifth logo and full file list.
+- [[file:screenshots/dictionary.png]]
+ - Sample words defined. Most of the words are commands that can be
+ executed interactively from command line or from file. When
+ executed they can be selectively compiled or interpreted.
-[[shots/index.html][Screenshots]]
+- [[file:screenshots/text editor.png]]
+ - Built in text editor.
-Read more about:
-- [[file:emulator.html][Virtual CPU]]
-- [[file:commands/index.html][Built-in commands]]
-- [[file:modules/index.html][Additional commands, realized as loadable modules]]
-- [[file:5TH_ET.txt][Example Fifth source file - text editor]]
* Installation
Just unpack all files, witout altering original directory structure,
somewhere in your hard disk. For example: C:\MISC\FIFTH\.... To run
or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
Read more about [[files.txt][distribution directory layout]]
+* Fifth distribution directory tree description
+After downloading and unpacking the ZIP file you shoud get directory
+tree similar to this:
+
+#+BEGIN_VERSE
+[DOC] - Fifth documentation
+ [commands] - documentation on Fifth built-in commands
+ [modules] - documentation on additional commands, realized as loadable modules
+ [shots] - Fifth screenshots
+
+[imageFile] - files contained within 'disk.raw', just an extracted form.
+
+[source] - source files
+ [emulator] - emulator source
+ [util] - utilites
+
+disk.raw - Virtual disk file, has filesystem inside.
+emulator.com - main executable.
+#+END_VERSE
+
* Software/Hardware/Human requirements
-** Software:
+** Software
- MS-DOS 6.22, with HIMEM.SYS loaded.
- Mouse driver if you have a mouse.
- Does work only when CPU is in real mode.
- To recompile ASM sources I used FASM (Flat Assembler).
- I ran QBasic utilities on QB 4.5 .
- VESA support by BIOS, or external driver (UNIVBE).
-** Hardware:
+** Hardware
- Minimum CPU 386.
- 64 KB free RAM below 640KB,
- 2 MB of free XMS.
- VESA compatible video card.
-** Human:
+** Human
- Beginner level Forth knowledge is recommended.
- Lots of enthusiasm.
-* Numbers representation
+* Numbers representation within Fifth
[[file:numbers.png][file:numbers.png]]
shape is formed by dividing a square into four parts. And manipulating
their color (black or white).
* Disk file map, and it's data structures
-
-
Core and high-level boot code is stored outside of the filesystem to
allow easy access to it, at early booting time, when filesystem is not
yet initialized.
modules, variables etc. and they locations in core. Constants use
dictionary space only. Random word can be removed from dictionary at
any time. Currently dictionary can contain at most 1000 entries.
-** dictionary entry format
+** Dictionary entry format
| offset | length | description |
|--------+--------+-----------------------|
| 0 | 4 | 0 < previous entry |
| | | with address to module |
|------+----------------+----------------------------|
| 2 | imm. submodule | immediately call to module |
-** Memory map: (average)
+** Memory map (average)
| <loc> | <size> | <desc> |
|---------+--------+-----------------------------|
| 0 | ~4096 | core |
| 1500000 | ~32000 | highlevel Fifth boot code |
| 200000h | | core startup messages area |
| 5200000 | | end of dynamic memory space |
+* Virtual machine
+Using CPU emulator slows it down but I shouldn't now think too mutch
+about, and waste my time on batteling with problems whitch results on
+complex design of PC hardware. Also it allows me to use existing DOS
+and resident drivers services in real mode. So I don't need to deal
+with hardware too mutch. It also allows me to use all free XMS for
+flat code & data storage.
+
+Current emulator emulates 1 CPU. It has 2 stacks, ~50 instructions,
+and 4GB flat address space (theoretically). I'm not sure that DOS
+6.22 that I currently prefer can handle more than 64 MB of RAM. While
+I tried to keep instructionset simple, I was forced to put in lot of
+complex instructions to make it's performance acceptable on
+emulator. On actual silicon ~20 instructions is enaugh (I think).
+
+Maybe one day similar system will run directly on custom silicon chip :)
+
+
+CPU has following registers:
+| IP | instruction pointer |
+| DSP | data stack pointer |
+| RSP | return stack pointer |
+
+Virtual CPU, commands (most of them are avaiable as ordinary commands
+in programming lanquage):
+
+#+BEGIN_VERSE
+
+code mnemonic description
+
+0 nop does notheing
+1 halt halt CPU ( return to DOS on emulator )
+
+2 kbd@ ( -- c ) read scancode of pressed or released key.
+ Returns 0, if no data avaiable.
+3 num <dword> ( -- n ) put immidiate number into datastack
+
+4 jmp <dword> jump to specified code
+5 call <dword>jump to specified code, save return address to
+ return stack.
+
+6 1+ ( n -- n+1 )
+7 1- ( n -- n-1 )
+
+8 dup ( n -- n n ) duplicate top of data stack
+9 drop ( n -- ) drop last element in data stack
+
+10 if <dword> ( n -- ) jump to addr if top element was 0
+11 ret jump to code, specified in return stack.
+
+12 c@ ( addr -- n ) read byte from memory at specified address
+13 c! ( n addr -- ) store byte to specified memory
+
+14 push ( DSTK -> RSTK ) move top of datastack to returnstack
+15 pop ( RSTK -> DSTK ) move top of returnstack to datastack
+
+16 <unused>
+17 rot ( n1 n2 n3 -- n2 n3 n1) rotate stack elements
+
+18 disk@ ( FromDiskSect ToMem -- ) read 1KB from disk into RAM
+19 disk! ( FromMem ToDiskSect -- ) write 1KB to disk
+
+20 @ ( addr -- n ) read 32 bit number from memory
+21 ! ( n addr -- ) store 32 bit number to memory
+
+22 over ( n1 n2 -- n1 n2 n1 ) self explaining ...
+23 swap ( n1 n2 -- n2 n1 ) -,,-
+
+24 + ( n1 n2 -- n1+n2 ) -,,-
+25 - ( n1 n2 -- n1-n2 ) -,,-
+
+26 * ( n1 n2 -- n1*n2 ) -,,-
+27 / ( n1 n2 -- n1/n2 ) -,,-
+
+28 > ( n1 n2 -- result ) is true when n1 > n2
+29 < ( n1 n2 -- result ) is true when n1 < n2
+
+30 not ( n1 -- not_n1 ) logical not
+31 i ( -- n ) copies top of return stack into datastack
+
+32 cprt@ ( addr -- n ) read one byte from hardware port
+33 cprt! ( n addr -- ) store one byte to hardware port
+
+34 i2 ( -- n ) like "i" but takes socond top stack element.
+35 i3 ( -- n ) like "i" but takes third top stack element.
+
+36 shl ( n amount -- n ) left bit shift
+37 shr ( n amount -- n ) right bit shift
+
+38 or ( n1 n2 -- n ) logical or
+39 xor ( n1 n2 -- n ) exclusive logical or
+
+40 vidmap ( addr -- ) copy memory from "addr" to video memory.
+
+41 mouse@ ( -- x y button ) read mouse coordinates & buttons
+
+42 vidput ( addr1 addr2 x y -- ) put image1 into image2, at
+ location x, y. Does clipping, so part of a big image
+ can be mapped into smaller one.
+
+43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2
+ if addr1 is greater than addr2 then count address
+ foward while moving, elseway starts from end and
+ counts backwards, so no data loss will occure on
+ overlapping.
+
+44 cfill ( c addr amount -- ) fill memory starting at "addr"
+ with "c" bytes.
+
+45 tvidput ( addr1 addr2 x y -- ) same as "vidput" but treats
+ color 255 in source image as transparent.
+
+46 depth ( -- depth ) returns current depth of data stack.
+
+47 charput ( colorfg colorbg addrsrc addrdest x y )
+ draw character to image buffer located at "addrdest"
+ to specified x & y location. Decodes 8 bytes from
+ source to bits, used to draw character.
+#+END_VERSE
+
* Fifth source format
Fifth uses a different character table and codes than ASCII (still
almost similar). I call it FSCII (Fifth Standard Code for Information
plan to use mainly HEX numbers, and create new characters to represent
numeric values. So typical nemric characters "0123..." is treated
like ordinary letters.
-** FSCII:
+** FSCII
| DEC | HEX | function |
|--------+-------+----------------------------------------|
| 254 | FE | carriage return (CR) |
| 255 | FF | space |
| else | | ordinary characters, same as in ASCII. |
+* Fifth commands
+** Compilation & miscellaneous
+#+BEGIN_VERSE
+init module ( -- )
+ First module, control is passed to on startup. Contains
+ initialization routines. Also it is the last core module.
+ All new modules on top of it comes as result of executing
+ external source files.
+
+head <name> ( -- ) compiles new dictionary entry without specifying
+ new module type.
+ ex: head myentry
+
+: <name> ( -- ) creates new code module
+; ( -- ) ends module (immideate)
+ ex: : hello ." hi there" ;
+
+const <name> ( n -- ) defines new constant.
+ ex: 2147483647 const max
+
+:i <name> ( -- ) same as ":" but this module will be executed
+ immideately even in compile mode.
+ ex: :i ( 41 scan ;
+
+create <name> ( -- ) same as "head" , but specify module type as data.
+ ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,
+
+allot ( n -- ) allocate n bytes in dictionary.
+ ex: create MyArray 100 allot
+
+" <string>" ( -- ) compile string and its size into core.
+ ex: create Mystring " This is it's contects"
+
+str <name> <string>" ( -- ) just shorter way for defining strings.
+ ex: str Mystring This is it's contenc"
+
+var <name> ( -- ) define new 32 bit variable.
+ ex: var result
+
+' <module> ( -- n ) return memory address of given entry.
+ ex: ' init
+
+forget <name> ( -- ) erases from RAM given entry and all entries what was
+ defined after it.
+ ex: forget myprog
+
+[ ( -- ) set interpret mode (immideate)
+] ( n -- ) set compile mode and compile top stack element
+ in as literal. Together [ .... ] cobination provides good
+ way to compute some values only once, at compile time,
+ rather than every time while program is running.
+ ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;
+
+defer <name> ( -- ) creates new module, with jump instruction.
+ Later address where to jump can be modified by "is" command.
+ This provides method of foward referencing. So you can use
+ modules what not jet exist.
+is ( address1 address2 -- ) address1 - where to jump, address2 -
+ address of module created by defer command.
+ ex: defer dispver
+ : run dispver ." running ..." ;
+ ... whatever ...
+ : (dispver ." Version 9.99 " ;
+ ' (dispver ' dispver is
+
+ Now if I type "run" on the screen appears:
+ Version 9.99 running ...
+
+asc <char> ( -- ) reads char ascii code and treats it as literal.
+ (immideate)
+ ex: : BreakLine 30 do asc - emit loop ;
+ same as:
+ : BreakLine 30 do 45 emit loop ;
+
+dyninc ( handle -- ) execute code in dynamic memory handle.
+ automatically deallocates it when done.
+
+include ( filenumber -- ) execute code in specified file.
+
+words ( -- ) display existing blocks in core.
+
+bye ( -- ) exit from Fifth
+
+fkey ( -- c )
+ Read one byte from input stream.
+
+sadd ( c addr -- )
+ Add one byte "c" to string located at "addr" and updates
+ string length.
+
+scan ( c -- )
+ Read input stream and store it to pad until it finds c .
+ It ignores all "c" bytes until it finds any non "c" byte.
+ in other words:
+ c is: "
+ input stream: """"This is test !"aoeu idh
+ result: This is test !
+
+ Is useful for breaking text lines into words.
+
+skey ( -- c )
+ So called safe "fkey". Reads data from input stream
+ but converts characters with ASCII codes: 9 13 10
+ to spaces.
+
+str=str? ( adr1 adr2 -- result )
+ Compares string at "adr1" with string at "adr2", returns
+ true flag if they are equal or false if they are not.
+ true = -1
+ false = 0
+
+find ( -- addr )
+ Searches whole dictionary for word in "pad". If found,
+ returns it address, if not, returns 0.
+
+execute ( -- )
+ Execute word located in "pad". Depending on "mode".
+
+dta ( addr -- DataAddr )
+ Calculates address of dictionary entry data area, from
+ entry point.
+
+2num ( -- num result )
+ Attempt to convert string located in "pad" into numeric
+ value. If succeed returns number and true as result.
+ If not, returns whatever and false as result.
+
+dadd ( addr length -- )
+ Add to dictionary data located at "addr", with specified
+ length.
+
+lit ( n -- )
+ Act with number depending on "mode". When interpreting,
+ leaves it in stack.
+
+
+incmod ( addr -- )
+ Add to dictionary data located at "addr"+1 , length is taken
+ from "addr".
+
+here ( -- n )
+ return "h" contents.
+
+mode var 8 bit
+ Holds input stream parser operation mode.
+ 0 = interpreting
+ 1 = compiling
+
+pad var 128 bytes
+ Holds temprorary strings.
+
+h var 32 bit
+ Pointer to free byte in memory, always at the end of the
+ dictionary. Each time when something is stored
+ by "c," command, pointer is incareased.
+
+lp var 32 bit
+ Pointer to last dictionary word. Each time when new word is
+ compiled or erased by "forget", this pointer is updated.
+
+modulechk ( Dstr<filename> -- ) check if module is loaded, if not
+ immideately load it.
+
+ne ( entrydata entrytype -- ) Compile new dictionary entry.
+ It's name must be in "pad".
+#+END_VERSE
+** Conditionals & control flow
+#+BEGIN_VERSE
+if ( flag -- ) (immideate)
+ "if 1.. else 2.. then" or
+ "if 1.. then" construction. Conditional execution.
+ Performs "1.." if "flag" was true,
+ elseway performs "2.." if exist. Execution continues after
+ word "then".
+ ex: 1 if ." nonzero" else ." zero" then
+
+>= ( n1 n2 -- result ) true if (n1 = n2) or (n1 > n2)
+ ex: 5 3 >= if ." first number is greater or equal" then
+
+<= ( n1 n2 -- result ) true if (n1 = n2) or (n1 < n2)
+= ( n1 n2 -- result ) true if n1 = n2
+
+do ( count -- ) (immideate)
+ "do .. loop" construction. Performs ".." "count" times.
+ In every step "count" is decareased until it is 0.
+ ex: : test 5 do i .d loop ;
+ result: 4 3 2 1 0
+
+doexit ( -- ) exit from "do .. loop"
+
+for ( count top -- ) (immideate)
+ "for .. loop" construction. Performs ".." (top - count) times.
+ In every step "count" is incareased until it reaches "top" .
+ ex: : test 4 10 for i .d loop ;
+ result: 4 5 6 7 8 9
+
+forexit ( -- ) exit from "for .. loop"
+
+until ( -- ) (immideate)
+ "until .. loop" construction. Performs ".." until flag become
+ true. False by default. Top of return stack holds flag.
+
+done ( -- ) exit from "until .. loop"
+
+#+END_VERSE
+** Disk & file access
+#+BEGIN_VERSE
+diskload ( FromDisk ToMem amount -- )
+ Load specified abount of bytes from disk into memory.
+
+disksave ( FromMem ToDisk amount -- )
+ save specified abount of bytes from memory into disk.
+
+format ( -- ) Erase all files.
+
+fsDfilesize@ ( handle -- size )
+ Return size of opened file.
+
+fsDcurloc@ ( handle -- location )
+ Return current location in file.
+
+fsDupdated@ ( handle -- updated? )
+ Return true if file was updated,
+ ie. write operations occured.
+
+fssave ( FromMem DestFileHandle amount -- )
+ Save data to file.
+
+fsload ( SrcFileHandle ToMem amount -- )
+ Load data from file.
+
+fseof ( handle -- bytesLeft )
+ Return amount of bytes left till end of file.
+ Useful before read operation.
+
+fsls ( -- ) List all files and lists (directories,folders)
+ in current path.
+
+fslsr ( -- ) Same as "fsls" but recursively scans also sub lists.
+
+fscl ( DynStrHand -- )
+ Change list (path)
+
+fscreate ( DynStrHand -- DescPnt )
+ Create new file or list. Can create multiple lists at once.
+ ex: when creating:
+ "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"
+ and only "\listGAMES\" already exist, then
+ "listSTRATEGY" and "listSIMWORLD" lists will be created,
+ and empty file "5th-runme" placed in there.
+
+fsDsave ( DynHand<data> DynStrHand<filename> -- )
+ Create new file and save all data from dynamic memory
+ block to it.
+
+fsDload ( DynStr<SrcFileName> DynHand<DataDest> -- )
+ Load whole file into dynamic memory block.
+
+fsDloadnew ( DynStr<SrcFileName> -- DynHand<DataDest> )
+ Load whole file into new dynamic memory block.
+#+END_VERSE
+** Dynamic memory
+#+BEGIN_VERSE
+dynal ( size -- handle )
+ Allocate dynamic memory block and return it's handle.
+
+dynde ( handle -- )
+ Deallocate dynamic memory block.
+
+dynp ( handle -- addr )
+ Returns pointer to memory where dynamic block
+ data begins.
+
+dyns ( handle -- size )
+ Returns size of dynamic block.
+
+dynresize ( NewSize handle -- )
+ Nondestructively resize dynamic block.
+
+dync@ ( addr handle )
+ Read one byte from dynamic block.
+
+dync! ( byte addr dynhandle )
+ Write one byte to dynamic block.
+
+dyn@ ( addr handle )
+ Read 32 bit number from dynamic block.
+ Address will spacify, whitch number, not byte.
+
+dyn! ( 32BitNum addr dynhandle )
+ Write 32 bit number to dynamic block.
+ Address will spacify, whitch number, not byte.
+
+dyncon ( size "name" -- )
+ Allocate dynamic block with specified size, and
+ create constant honding its handle.
+ ex: 100 dyncon MyNewBlock
+
+dyn. ( handle -- )
+ Write contenc of dynamic memory block to screen.
+#+END_VERSE
+** Graphics and text
+#+BEGIN_VERSE
+. ( n -- ) print number on screen
+
+d. ( n -- ) print number on screen in decimal
+
+? ( addr -- ) print 32 bit value located at addr.
+
+." <string>" ( -- ) print string into screen. Immideately
+ compiles.
+ ex: : greeting ." Hello, World" ;
+
+tab. ( -- ) print tabulator
+
+calccol ( b g r -- c ) calculate color what best matches given
+ Blue Green & Red values. Values must be in range 0 - 255.
+
+imgalloc ( xsize ysize -- imgbuf ) allocate image buffer for
+ specified size.
+
+imgsize ( imgbuf -- ) print on the screen X & Y size of image
+ buffer.
+
+point ( x y imgbuf -- addr ) returns memory address for specified
+ pixel.
+
+pset ( color x y imgbuf -- ) set graphic point
+
+boxf ( x1 x2 y1 y2 imgbuf color -- ) draw filled box
+
+cls ( imgbuf -- ) clear image buffer
+
+setpal ( b g r color -- ) set palette value for specified color.
+ values bust be in size 0 - 63.
+
+putchar ( char color x y imgbuf -- ) put graphic character in
+ imagebuffer to specified (x & y) location.
+
+scroll ( x y imgbuf -- ) scroll in imgbuf.
+
+scrollf ( color x y screen -- ) scroll and fill empty space with
+ given color.
+
+at! ( x y -- ) set cursor location
+curc! ( color -- ) set text color
+curb! ( solor -- ) set backround color
+
+colnorm ( -- ) set text color to normal
+colneg ( -- ) set text color to negative (selected)
+
+dyntype ( dynhandle -- ) display contenc of dynamic memory on screen
+fsdisp ( file -- ) clear screen, display file, and wait for key
+
+type ( addr length -- )
+ Types on the screen string, from memory at addr and
+ specified length.
+
+write ( addr -- )
+ Types on the screen string, from memory at "addr"+1
+ length is taken from "addr" .
+
+screen const 32 bit
+ Holds handle of screen buffer.
+
+copyscreen ( SrcImgHandle DestImgHandle -- ) copy contenc of source
+ image to destination image. Source and destination images
+ must have same size.
+#+END_VERSE
+** Math, memory & stack manipulation
+#+BEGIN_VERSE
+off ( n -- ) writes 0 to given address, good for zeroing variable.
+ ex: MyVariable off
+on ( n -- ) writes -1 (true flag) to given address.
+ ex: MyVariable on
+
+2dup ( n1 n2 -- n1 n2 n1 n2 )
+2drop ( n1 n2 -- )
+nip ( n1 n2 -- n2 )
+neg ( n1 -- -n1 ) negotiate
+bit@ ( n bit -- result ) return specified bit from n.
+ ex: 38 2 bit@ (result will be 1)
+to32bit ( n1 n2 n3 n4 -- n32 ) treat 4 last stack elements as bytes
+ and unite them into 32 bit dword. Most significant byte
+ on top.
+ ex: 12 76 23 11 to32bit result: 186076172
+
+to8bit ( n32 -- n1 n2 n3 n4 ) break 32 bit number into 4 bytes.
+ Useful if you need to send 32 bit numbers thru 8 bit COM
+ port.
+ ex: 186076172 to8bit result: 12 76 23 11
+
+mod ( n1 n2 -- reminder ) divide n1 by n2 and returns reminder.
+ ex: 12 5 mod result: 2
+
+bound ( low n high -- n ) check if n is in given bounds,
+ if not then incarease/decarease it to match bounds.
+ ex: 5 80 15 bound result: 15
+ 5 10 15 bound result: 10
+ 5 -10 15 bound result: 5
+
+bound? ( low n high -- result ) returns true if n is in the
+ given bounds.
+
+tab ( col -- spaces) calculate amount of spaces to add
+ ta reach next tabulation from given column.
+
+count ( addr -- addr+1 n )
+ Useful for returning bytes from constantly incareasing
+ address. Module "type" is nice example.
+
+c, ( n -- )
+ store one byte at memory specified by "h". And incarease
+ "h" by 1.
+
+, ( n -- )
+ store 32 bit number at memory specified by "h". And
+ incarease "h" by 4.
+
+cmove ( addr1 addr2 n -- )
+ copy "n" amount of bytes from memory at "addr1" to memory
+ at "addr2".
+
+rnd ( limit -- result )
+ generates random number in range 0 to "limit"-1.
+
+abs ( n -- |n| )
+ returns absolute value of "n"
+#+END_VERSE
+** Dynamic & static strings
+Fifth supports both static and dynamic strings. Static strings must
+have predefined space reserved, and string mustn't exceed this
+length. They manipulation is faster. But they use more memory. Static
+string memory address is used to refer to the string.
+
+Dynamic strings can have at any time length form 0 to 0FFh, They take
+up only memory they currently need. They are held in dynamic memory
+blocks, so dynamic block handle is used to refer to this string.
+
+Both types of strings are stored in the way, where first (0th) byte
+holds current string length, following bytes are string itself.
+
+
+#+BEGIN_VERSE
+Dynamic:
+
+Dstral ( -- handle )
+ Allocate new string.
+
+Dstrlen ( handle -- length )
+ Return string length.
+
+c+Dstr ( chr handle -- )
+ Add one byte to end of the string.
+
+c+lDstr ( chr handle -- )
+ Add one byte to left side (beginning) of the string.
+
+Dstr. ( handle -- )
+ Write contec of string into screen.
+
+Dstrsure ( size Dstr -- )
+ Makes sure that at least rquested
+ "size" (amount of characters) is allocated for given
+ dynamic string.
+
+Dstr2str ( handle address -- )
+ Copy dyamic string into static memory space.
+
+str2Dstr ( address handle -- )
+ Copy static string into dyamic string.
+
+Dstr+str ( Dstr addr -- )
+ Add contenc of dynamic string to static string.
+
+D" any string" ( -- Dstr )
+ Moves specified string into dynamic string called "defDstr".
+
+D> any_string ( -- Dstr )
+ Moves specified string into dynamic string called "defDstr".
+ Space marks end of string!
+
+D>2 any_string ( -- Dstr )
+ Moves specified string into dynamic string called "defDstr2".
+ Space marks end of string!
+
+Dstr+Dstr ( Dstr1 Dstr2 -- )
+ Adds "Dstr1" to "Dstr2" and places result into "Dstr2".
+
+Dstrclear ( Dstr -- )
+ Clears contenc of dynamic string.
+
+Dstr2Dstr ( Dstr1 Dstr2 -- )
+ Moves "Dstr1" to "Dstr2".
+Dstr ( data" name -- )
+ Creates new dynamic string and moves specified data into it.
+ Then creates new constant with given "name" holding created
+ dynamic string handle.
+
+ ex: Dstr Hello, my name is Sven!" message \ creates it
+ message Dstr. \ tests it
+
+Dstrlscan ( char Dstr -- loc )
+ Searches dynamic string for "char", from left to right,
+ returns first found "char" location in string, or 0,
+ if not found.
+
+Dstrrscan ( char Dstr -- loc )
+ Searches dynamic string for "char", from right to left,
+ returns first found "char" location in string, or 0,
+ if not found.
+
+Dstrlscane ( char Dstr -- loc )
+ Same as "Dstrlscan" buf returns string length+1 as location.
+ÿ
+Dstrleft ( amo Dstr -- )
+ Only specified amount of characters from left remains
+ in dynamic string. ie. cut right part out.
+
+Dstrright ( amo Dstr -- )
+ Only specified amount of characters from right remains
+ in dynamic string. ie. cut left part out.
+
+Dstrcutl ( amo Dstr -- )
+ Cut specified amount of characters from left of dynamic
+ string out.
+
+Dstrsp ( char Dstr1 Dstr2 -- )
+ Separate dynamic string in Dstr1 into two parts,
+ using "char" as separator. First part will be stored in
+ "Dstr2", second part in "Dstr1".
+ ex: asc \ \ ..separator
+ D> listF\listLIB\5TH_DRVMOUSE \ ..separate from
+ defDstr2 \ ..place result in
+ Dstrsp \ separation command
+ defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE
+ defDstr2 Dstr. \ will be: listF
+
+Dv ( addr -- )
+ Allocates empty dynamic string, and places it's handle
+ into given address.
+
+Df ( addr -- )
+ Reads dynamic string handle from given address and
+ deallocates (frees) it.
+
+ex: var mystring1
+ : testmodule
+ mystring1 Dv \ allocates string
+
+ <whatever>
+
+ mystring1 Df ; \ deallocates it again when no longer needed.
+#+END_VERSE
+* Dynamically loadable modules
+** Keyboard driver
+#+BEGIN_VERSE
+
+KBD_@ ( -- code ) get scancodes for pressed keys from keyboard.
+KBD_down? ( key -- result ) check is key with specified scancode
+ currently pressed down.
+KBD_SC2FSCII ( code -- FSCII ) convert key scancode into FSCII code,
+ or in FSK (Fifth standard keycode).
+KBD_F@ ( -- FSCII ) read pressed key FSCII or FSK, returns -1 if no
+ keys are pressed.
+KBD_FW@ ( -- FSCII ) read pressed key FSCII or FSK, if no keys is
+ are pressed then waits until there is.
+
+ FSK
+ ---
+In HEX.
+
+FC backspace
+FD TAB
+FE enter
+FF space
+
+400 ESC
+401 ... F1 ...
+410 up
+411 right
+412 down
+413 left
+414 INS
+415 DEL
+416 home
+417 end
+418 PG/UP
+419 PG/DN
+#+END_VERSE
+** Mouse driver
+#+BEGIN_VERSE
+mousex var Mouse x coordinate.
+mousey var Mouse y coordinate.
+mousekeyl var Mouse left key.
+mousekeym var Mouse middle key.
+mousekeyr var Mouse right key.
+mousec var Display current mouse coordinates in top left part of screen,
+ if true. (good for debugging)
+mousepointer var Image buffer, holding current mouse pointer.
+mouseadd ( ModuleAddr x1 x2 y1 y2 -- ) Add specified area on screen,
+ into mause click buffer. If any mouse button is clicked on
+ that area, module at "ModuleAddr" will be executed.
+mousebe var Amount of buffer elements.
+mousedo ( -- ) Updates mouse coordinates and keys. Parse mouse
+ click buffer, and draw mouse cursor to "screen".
+#+END_VERSE
+** 2D graphic library
+#+BEGIN_VERSE
+lineh ( color len x y imgbuf -- ) draws horisontal line
+ from X,Y coordinates to right, with specified length.
+linev ( color len x y imgbuf -- ) draws vertical line
+ down, from coordinates X,Y, with specified length.
+box ( color x2 x1 y2 y1 imgbuf -- ) draws rectangular
+ box. x2 bust be >= x1, y2 must be >= y1.
+ x1,y1-----------+
+ | |
+ | |
+ +-----------x2,y2
+
+flipv ( imgbuf -- ) flip image vertically.
+imgcoltrans ( ImgBuf Color ToColor -- ) Translate all pixels in
+ specified image with "Color" into "ToColor".
+imgfill ( color x y imgbuf -- ) Fill image region starting at location
+ X & Y with specified color.
+#+END_VERSE
+** Trigonometry functions
+#+BEGIN_VERSE
+sin ( a -- result ) return sinus from given angle "a",
+ 360ø is 2000. So 1000 represents 180ø angle.
+ Result will be in range -10'000 to 10'000, instead of ñ1.
+
+cos ( a -- result ) return cosinus from given angle.
+ Parameters are like in "sin" function.
+#+END_VERSE
+++ /dev/null
- Keyboard driver\r
- ---------------\r
-\r
-KBD_@ ( -- code ) get scancodes for pressed keys from keyboard.\r
-KBD_down? ( key -- result ) check is key with specified scancode\r
- currently pressed down. \r
-KBD_SC2FSCII ( code -- FSCII ) convert key scancode into FSCII code,\r
- or in FSK (Fifth standard keycode). \r
-KBD_F@ ( -- FSCII ) read pressed key FSCII or FSK, returns -1 if no\r
- keys are pressed.\r
-KBD_FW@ ( -- FSCII ) read pressed key FSCII or FSK, if no keys is\r
- are pressed then waits until there is.\r
-\r
- FSK\r
- ---\r
-In HEX.\r
-\r
-FC backspace\r
-FD TAB\r
-FE enter\r
-FF space\r
-\r
-400 ESC\r
-401 ... F1 ...\r
-410 up\r
-411 right\r
-412 down\r
-413 left\r
-414 INS\r
-415 DEL\r
-416 home\r
-417 end\r
-418 PG/UP\r
-419 PG/DN\r
+++ /dev/null
- Mouse driver\r
- ------------\r
-\r
-mousex var Mouse x coordinate.\r
-mousey var Mouse y coordinate.\r
-mousekeyl var Mouse left key.\r
-mousekeym var Mouse middle key.\r
-mousekeyr var Mouse right key.\r
-mousec var Display current mouse coordinates in top left part of screen,\r
- if true. (good for debugging)\r
-mousepointer var Image buffer, holding current mouse pointer.\r
-mouseadd ( ModuleAddr x1 x2 y1 y2 -- ) Add specified area on screen,\r
- into mause click buffer. If any mouse button is clicked on\r
- that area, module at "ModuleAddr" will be executed.\r
-mousebe var Amount of buffer elements.\r
-mousedo ( -- ) Updates mouse coordinates and keys. Parse mouse\r
- click buffer, and draw mouse cursor to "screen".\r
+++ /dev/null
- 2D graphic library\r
- ------------------\r
-\r
-\r
-lineh ( color len x y imgbuf -- ) draws horisontal line\r
- from X,Y coordinates to right, with specified length.\r
-linev ( color len x y imgbuf -- ) draws vertical line\r
- down, from coordinates X,Y, with specified length.\r
-box ( color x2 x1 y2 y1 imgbuf -- ) draws rectangular\r
- box. x2 bust be >= x1, y2 must be >= y1.\r
- x1,y1-----------+\r
- | |\r
- | |\r
- +-----------x2,y2\r
-\r
-flipv ( imgbuf -- ) flip image vertically.\r
-imgcoltrans ( ImgBuf Color ToColor -- ) Translate all pixels in\r
- specified image with "Color" into "ToColor".\r
-imgfill ( color x y imgbuf -- ) Fill image region starting at location\r
- X & Y with specified color.\r
+++ /dev/null
-<html><head><title>FIFTH</title></head>\r
-<body>\r
-\r
-<pre>\r
-\r
- <h2>Loadable external modules</h2>\r
-\r
-\r
-<a href="drvkbd.txt">keyboard driver</a>\r
-<a href="drvmouse.txt">mouse driver</a>\r
-<a href="gfx2.txt">advanced graphic library</a>\r
-<a href="trig.txt">trigonometry module</a>\r
-\r
-</pre>\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
- Trigonometry functions\r
- ----------------------\r
-\r
-sin ( a -- result ) return sinus from given angle "a",\r
- 360ø is 2000. So 1000 represents 180ø angle.\r
- Result will be in range -10'000 to 10'000, instead of ñ1.\r
-\r
-cos ( a -- result ) return cosinus from given angle.\r
- Parameters are like in "sin" function.\r
--- /dev/null
+<html><head><title>FIFTH</title></head>
+<body>
+
+<pre>
+
+ <h2>Screen shots</h2>
+
+
+<img src="start.png">
+
+
+
+
+<img src="words.png">
+Sample words defined. Most of the words are commands that can be executed
+interactively from command line or from file. When executed they can be
+selectively compiled or interpreted.
+
+
+
+<img src="textEditor.png">
+Built in text editor.
+
+
+
+</pre>
+</html>
+++ /dev/null
-<html><head><title>FIFTH</title></head>\r
-<body>\r
-\r
-<pre>\r
-\r
- <h2>Screen shots</h2>\r
-\r
-\r
-<img src="start.png">\r
-Startup screen diplaying Fifth logo and full file list.\r
-\r
-\r
-\r
-<img src="words.png">\r
-Sample words defined. Most of the words are commands that can be executed\r
-interactively from command line or from file. When executed they can be\r
-selectively compiled or interpreted.\r
-\r
-\r
-\r
-<img src="textEditor.png">\r
-Built in text editor.\r
-\r
-\r
-\r
-</pre>\r
-</html>
\ No newline at end of file
--- /dev/null
+DECLARE SUB getline (a$)
+DECLARE SUB start ()
+DIM SHARED byte AS STRING * 1
+DIM SHARED endf
+
+start
+
+OPEN COMMAND$ + ".5th" FOR BINARY AS #1
+OPEN COMMAND$ + ".src" FOR OUTPUT AS #2
+
+1
+getline a$
+IF endf = 1 THEN GOTO 2
+PRINT #2, a$
+GOTO 1
+2
+
+CLOSE #2
+CLOSE #1
+
+SYSTEM
+
+SUB getline (a$)
+
+a$ = ""
+3
+IF EOF(1) <> 0 THEN endf = 1: GOTO 4
+GET #1, , byte
+IF ASC(byte) <= 9 THEN
+ byte = CHR$(48 + ASC(byte))
+END IF
+IF ASC(byte) <= 15 THEN
+ byte = CHR$(65 + ASC(byte) - 10)
+END IF
+IF ASC(byte) = 255 THEN
+ byte = " "
+END IF
+IF ASC(byte) = 253 THEN
+ byte = CHR$(9)
+END IF
+
+IF byte = CHR$(254) THEN GOTO 4
+a$ = a$ + byte
+GOTO 3
+4
+
+END SUB
+
+SUB start
+endf = 0
+IF COMMAND$ = "" THEN END
+END SUB
+
--- /dev/null
+' Disk file editor for FIFTH
+' Svjatoslav Agejenko: n0@hot.ee
+
+DECLARE SUB fdisp ()
+DECLARE SUB fopen (a$)
+DECLARE SUB ask (a$, b$)
+DECLARE SUB addk (a$)
+DECLARE SUB llen (a%, l%)
+DECLARE SUB save (a%)
+DECLARE SUB disp ()
+DEFINT A-Z
+
+DECLARE SUB load (a)
+DECLARE SUB start ()
+DECLARE SUB edit ()
+DIM SHARED buf(0 TO 31, 0 TO 31)
+DIM SHARED obuf(0 TO 31, 0 TO 31)
+DIM SHARED byte AS STRING * 1
+DIM SHARED font(0 TO 20, 0 TO 255)
+DIM SHARED eb
+DIM SHARED keys(0 TO 10000)
+DIM SHARED keyl, keyc
+DIM SHARED curx, cury
+DIM SHARED fil$(0 TO 1000)
+DIM SHARED fline, froll
+DIM SHARED filename$
+
+start
+
+OPEN "..\..\disk.raw" FOR BINARY AS #1
+
+edit
+
+CLOSE #1
+SYSTEM
+
+SUB addk (a$)
+keys(keyl) = ASC(a$)
+keyl = keyl + 1
+IF keyl > 10000 THEN keyl = 0
+END SUB
+
+SUB ask (a$, b$)
+LOCATE 16, 34
+PRINT SPACE$(46)
+LOCATE 16, 34
+COLOR 15
+PRINT a$
+COLOR 10
+LOCATE 16, 34 + LEN(a$)
+INPUT "", b$
+LOCATE 16, 34
+PRINT SPACE$(46)
+COLOR 15
+END SUB
+
+SUB disp
+
+FOR y = 0 TO 31
+FOR x = 0 TO 31
+c = buf(x, y)
+IF c <> obuf(x, y) THEN
+ PUT (x * 8, y * 8), font(0, c), PSET
+ obuf(x, y) = c
+END IF
+NEXT x
+NEXT y
+
+x1 = curx * 8
+y1 = cury * 8
+FOR y = y1 TO y1 + 7
+FOR x = x1 TO x1 + 7
+c = POINT(x, y)
+IF c = 15 THEN c = 0 ELSE c = 10
+PSET (x, y), c
+NEXT x
+NEXT y
+obuf(curx, cury) = -1
+
+LOCATE 1, 77
+PRINT " "
+LOCATE 1, 76
+PRINT buf(curx, cury)
+END SUB
+
+SUB edit
+fdisp
+leb = -1
+m = 0
+1
+IF eb <> leb THEN
+ IF m = 1 THEN
+ save leb
+ m = 0
+ END IF
+ load eb
+ leb = eb
+ LOCATE 1, 60
+ PRINT "page:"; eb; " "
+END IF
+disp
+2
+a$ = INKEY$
+bk = 0
+IF a$ = "" THEN
+ IF keyl = keyc THEN GOTO 2
+ a$ = CHR$(keys(keyc))
+ keyc = keyc + 1
+ IF keyc > 10000 THEN keyc = 0
+ bk = 1
+END IF
+
+IF a$ = CHR$(0) + CHR$(73) THEN eb = eb - 1
+IF a$ = CHR$(0) + CHR$(81) THEN eb = eb + 1
+IF a$ = CHR$(27) THEN GOTO 4
+IF a$ = CHR$(0) + "M" THEN curx = curx + 1
+IF a$ = CHR$(0) + "K" THEN curx = curx - 1
+IF a$ = CHR$(0) + "P" THEN cury = cury + 1
+IF a$ = CHR$(0) + "H" THEN cury = cury - 1
+IF a$ = CHR$(0) + "=" THEN ask "page: ", b$: eb = VAL(b$)
+IF a$ = CHR$(0) + "?" THEN ask "file: ", b$: fopen b$
+IF a$ = CHR$(0) + CHR$(132) THEN fline = fline - 1: fdisp
+IF a$ = CHR$(0) + CHR$(118) THEN fline = fline + 1: fdisp
+IF a$ = CHR$(0) + CHR$(64) THEN ' F6
+ d = 0
+ FOR b = 1 TO LEN(fil$(fline))
+ c$ = RIGHT$(LEFT$(fil$(fline), b), 1)
+ IF c$ = CHR$(9) THEN c$ = " "
+ IF c$ = " " OR c$ = CHR$(255) THEN d = d + 1 ELSE d = 0
+ IF d < 2 THEN addk c$
+ NEXT b
+END IF
+
+IF a$ = CHR$(0) + ";" THEN
+ FOR y = 0 TO 31
+ FOR x = 0 TO 31
+ buf(x, y) = 255
+ NEXT x
+ NEXT y
+ m = 1
+END IF
+
+IF a$ = CHR$(0) + CHR$(83) THEN
+ FOR b = curx TO 30
+ buf(b, cury) = buf(b + 1, cury)
+ NEXT b
+ buf(31, cury) = 255
+ m = 1
+END IF
+
+IF (a$ = CHR$(13)) AND (bk = 0) THEN
+a$ = ""
+IF cury < 31 THEN
+ FOR a = 31 TO cury + 2 STEP -1
+ FOR b = 0 TO 31
+ buf(b, a) = buf(b, a - 1)
+ NEXT b
+ NEXT a
+ FOR a = 0 TO 31
+ buf(a, cury + 1) = 255
+ NEXT a
+ FOR a = curx TO 31
+ SWAP buf(a, cury), buf(a - curx, cury + 1)
+ NEXT a
+ m = 1
+ cury = cury + 1
+ curx = 0
+END IF
+END IF
+
+IF LEN(a$) = 1 THEN
+ IF ASC(a$) = 32 THEN a$ = CHR$(255)
+ IF (a$ = CHR$(8)) AND (bk = 0) THEN
+ a$ = ""
+ IF curx > 0 THEN
+ FOR b = curx - 1 TO 30
+ buf(b, cury) = buf(b + 1, cury)
+ NEXT b
+ buf(31, cury) = 255
+ curx = curx - 1
+ m = 1
+ ELSE
+ IF cury > 0 THEN
+ llen cury - 1, a
+ curx = a
+ FOR b = a TO 31
+ buf(b, cury - 1) = buf(b - a, cury)
+ NEXT b
+ FOR a = cury TO 30
+ FOR b = 0 TO 31
+ buf(b, a) = buf(b, a + 1)
+ NEXT b
+ NEXT a
+ FOR b = 0 TO 31
+ buf(b, 31) = 255
+ NEXT b
+ m = 1
+ cury = cury - 1
+ END IF
+ END IF
+ END IF
+END IF
+
+IF a$ = CHR$(0) + "<" THEN
+ask "decimal number:", b$
+b$ = HEX$(VAL(b$))
+FOR a = 1 TO LEN(b$)
+ c = ASC(RIGHT$(LEFT$(b$, a), 1))
+ IF (c <= 57) AND (c >= 48) THEN d$ = CHR$(c - 48): addk d$
+ IF (c <= 70) AND (c >= 65) THEN d$ = CHR$(c - 55): addk d$
+NEXT a
+END IF
+
+IF a$ = CHR$(0) + CHR$(65) THEN
+FOR a = 999 TO fline STEP -1
+ fil$(a + 1) = fil$(a)
+NEXT a
+fil$(fline) = ""
+FOR a = curx TO 31
+ fil$(fline) = fil$(fline) + CHR$(buf(a, cury))
+NEXT a
+fdisp
+END IF
+
+IF a$ = CHR$(0) + ">" THEN
+ask "ascii code:", b$
+a$ = CHR$(VAL(b$))
+END IF
+
+IF LEN(a$) = 1 THEN
+ FOR b = 31 TO curx + 1 STEP -1
+ buf(b, cury) = buf(b - 1, cury)
+ NEXT b
+ buf(curx, cury) = ASC(a$)
+ curx = curx + 1
+ m = 1
+END IF
+
+IF eb < 0 THEN eb = 0
+IF curx < 0 THEN curx = 0
+IF cury < 0 THEN cury = 0
+IF curx > 31 THEN curx = 31
+IF cury > 31 THEN cury = 31
+GOTO 1
+4
+
+END SUB
+
+SUB fdisp
+IF fline < 0 THEN fline = 0
+IF fline > 1000 THEN fline = 1000
+IF fline - froll > 10 THEN froll = fline - 10
+IF fline - froll < 0 THEN froll = fline
+IF froll < 0 THEN froll = 0
+
+LOCATE 17, 1
+PRINT SPACE$(80)
+LOCATE 17, 1
+PRINT "file: " + filename$
+
+LOCATE 17, 20
+PRINT "line:"; fline
+
+FOR a = 0 TO 10
+ LOCATE a + 18, 1
+ IF a + froll = fline THEN
+ COLOR 10
+ IF fil$(a + froll) = SPACE$(LEN(fil$(a + froll))) THEN
+ FOR b = 1 TO 80
+ PRINT CHR$(219);
+ NEXT b
+ GOTO 7
+ END IF
+ ELSE
+ COLOR 12
+ END IF
+ PRINT fil$(a + froll) + SPACE$(80 - LEN(fil$(a + froll)));
+7
+NEXT a
+
+COLOR 15
+END SUB
+
+SUB fopen (a$)
+filename$ = a$
+FOR b = 0 TO 1000
+ fil$(b) = ""
+NEXT b
+
+b = 0
+OPEN filename$ FOR INPUT AS #2
+5
+IF EOF(2) <> 0 THEN GOTO 6
+LINE INPUT #2, c$
+fil$(b) = c$
+b = b + 1
+IF b > 1000 THEN GOTO 6
+GOTO 5
+6
+CLOSE #2
+
+fline = 0
+froll = 0
+fdisp
+END SUB
+
+SUB llen (a, l)
+FOR b = 31 TO 0 STEP -1
+IF buf(b, a) <> 255 THEN l = b + 1: GOTO 3
+NEXT b
+l = 0
+3
+END SUB
+
+SUB load (a)
+DIM c AS LONG
+DIM a1 AS LONG
+a1 = a
+c = a1 * 1024
+SEEK #1, c + 1
+FOR y = 0 TO 31
+ FOR x = 0 TO 31
+ GET #1, , byte
+ buf(x, y) = ASC(byte)
+ NEXT x
+NEXT y
+END SUB
+
+SUB save (a)
+DIM c AS LONG
+DIM a1 AS LONG
+a1 = a
+c = a1 * 1024
+SEEK #1, c + 1
+FOR y = 0 TO 31
+ FOR x = 0 TO 31
+ byte = CHR$(buf(x, y))
+ PUT #1, , byte
+ NEXT x
+NEXT y
+SOUND 5000, .1
+END SUB
+
+SUB start
+SCREEN 12
+COLOR 15
+eb = 7
+
+filename$ = "<noname>"
+fline = 0
+froll = 0
+keyl = 0
+keyc = 0
+
+OPEN "font.dat" FOR BINARY AS #1
+FOR f = 0 TO 255
+FOR y = 0 TO 7
+GET #1, , byte
+n = ASC(byte)
+b = 128
+FOR a = 0 TO 7
+IF n >= b THEN n = n - b: c = 15 ELSE c = 0
+b = b / 2
+PSET (a, y), c
+NEXT a
+NEXT y
+GET (0, 0)-(7, 7), font(0, f)
+NEXT f
+CLOSE #1
+
+FOR y = 0 TO 31
+FOR x = 0 TO 31
+obuf(x, y) = -1
+NEXT x
+NEXT y
+
+LOCATE 1, 34
+PRINT "F1 - clear page"
+LOCATE 2, 34
+PRINT "F2 - enter decimal number"
+LOCATE 3, 34
+PRINT "F3 - goto page"
+LOCATE 4, 34
+PRINT "F4 - enter character code"
+LOCATE 5, 34
+PRINT "F5 - load source file"
+LOCATE 6, 34
+PRINT "F6 - insert line from source file"
+LOCATE 7, 34
+PRINT "F7 - copy line to source file"
+
+LOCATE 1, 71
+PRINT "code:"
+END SUB
+
--- /dev/null
+DECLARE SUB bytew (fi&, d&, addr&)
+DECLARE SUB byter (fi&, addr&, d&)
+DECLARE SUB dwordw (fi&, b&, a&)
+DEFLNG A-Z
+
+DECLARE SUB savepath ()
+DECLARE SUB getson (a$)
+DECLARE SUB start ()
+
+DIM SHARED mitus, sona$(1 TO 50)
+DIM SHARED byte AS STRING * 1
+DIM SHARED length
+DIM SHARED srcfile$
+
+start
+
+OPEN "..\disk.raw" FOR BINARY AS #1
+savepath
+SEEK #1, 2000101
+OPEN srcfile$ FOR BINARY AS #2
+2
+IF EOF(2) <> 0 THEN GOTO 1
+GET #2, , byte
+length = length + 1
+PUT #1, , byte
+GOTO 2
+1
+CLOSE #2
+dwordw 1, length - 1, 2000000
+CLOSE #1
+
+SYSTEM
+
+SUB byter (fi, addr, d)
+SEEK #1, addr + 1
+GET fi, , byte
+d = ASC(byte)
+END SUB
+
+SUB bytew (fi, d, addr)
+SEEK #1, addr + 1
+byte = CHR$(d)
+PUT #1, , byte
+END SUB
+
+SUB dwordr (fi, a, f)
+byter fi, a, b
+byter fi, a + 1, c
+byter fi, a + 2, d
+byter fi, a + 3, e
+f = e * 16777216
+f = f + d * 65536 + c * 256 + b
+END SUB
+
+SUB dwordw (fi, b, a)
+c = b
+d = c \ 16777216
+c = c - (d * 16777216)
+
+e = c \ 65536
+c = c - (e * 65536)
+
+f = c \ 256
+c = c - (f * 256)
+
+bytew fi, c, a
+bytew fi, f, a + 1
+bytew fi, e, a + 2
+bytew fi, d, a + 3
+END SUB
+
+DEFSNG A-Z
+SUB getson (a$)
+mitus = 0
+
+d = 1
+FOR b = 1 TO LEN(a$)
+c$ = RIGHT$(LEFT$(a$, b), 1)
+IF c$ = " " THEN
+d = 1
+ELSE
+IF d = 1 THEN
+mitus = mitus + 1
+sona$(mitus) = ""
+d = 0
+END IF
+sona$(mitus) = sona$(mitus) + c$
+END IF
+NEXT b
+END SUB
+
+SUB savepath
+a$ = COMMAND$ + "\"
+f$ = ""
+ext$ = ""
+t$ = ""
+m = 0
+FOR b = 1 TO LEN(a$)
+ c$ = RIGHT$(LEFT$(a$, b), 1)
+ IF c$ = "." THEN m = 1: GOTO 3
+ IF c$ = "\" THEN
+ IF ext$ = "" THEN ext$ = "list"
+4 IF LEN(ext$) < 4 THEN ext$ = ext$ + "_": GOTO 4
+ t$ = t$ + ext$ + f$ + "\"
+ f$ = ""
+ ext$ = ""
+ GOTO 3
+ END IF
+ IF m = 0 THEN f$ = f$ + c$ ELSE ext$ = ext$ + c$
+3
+NEXT b
+t$ = LEFT$(t$, LEN(t$) - 1)
+
+' PRINT a$
+' PRINT t$
+
+t$ = t$ + CHR$(254)
+SEEK #1, 2000005
+PUT #1, , t$
+
+
+
+
+END SUB
+
+SUB start
+
+IF COMMAND$ = "" THEN END
+
+srcfile$ = COMMAND$
+
+
+END SUB
+
--- /dev/null
+DECLARE SUB getson (a$)
+DECLARE SUB start ()
+DIM SHARED mitus, sona$(1 TO 50)
+DIM SHARED byte AS STRING * 1
+
+start
+
+OPEN sona$(1) FOR BINARY AS #1
+PRINT "Seeking to:" + sona$(3)
+SEEK #1, VAL(sona$(3)) + 1
+OPEN sona$(2) FOR BINARY AS #2
+2
+IF EOF(2) <> 0 THEN GOTO 1
+GET #2, , byte
+PUT #1, , byte
+GOTO 2
+1
+CLOSE #2
+CLOSE #1
+
+SYSTEM
+
+SUB getson (a$)
+mitus = 0
+
+d = 1
+FOR b = 1 TO LEN(a$)
+c$ = RIGHT$(LEFT$(a$, b), 1)
+IF c$ = " " THEN
+d = 1
+ELSE
+IF d = 1 THEN
+mitus = mitus + 1
+sona$(mitus) = ""
+d = 0
+END IF
+sona$(mitus) = sona$(mitus) + c$
+END IF
+NEXT b
+END SUB
+
+SUB start
+
+IF COMMAND$ = "" THEN END
+
+getson COMMAND$
+
+
+END SUB
+
--- /dev/null
+DECLARE SUB chl (a$, b$)
+DECLARE SUB getline (a$)
+DECLARE SUB start ()
+DIM SHARED byte AS STRING * 1
+DIM SHARED er
+
+
+start
+
+OPEN COMMAND$ + ".src" FOR INPUT AS #1
+IF er = 0 THEN KILL COMMAND$ + ".5th"
+OPEN COMMAND$ + ".5th" FOR BINARY AS #2
+
+1
+IF EOF(1) <> 0 THEN GOTO 2
+LINE INPUT #1, a$
+
+c$ = ""
+e$ = ""
+FOR b = 1 TO LEN(a$)
+d$ = RIGHT$(LEFT$(a$, b), 1)
+IF d$ = " " THEN chl e$, c$: c$ = c$ + CHR$(255): GOTO 3
+IF d$ = CHR$(9) THEN chl e$, c$: c$ = c$ + CHR$(253): GOTO 3
+e$ = e$ + d$
+3
+NEXT b
+chl e$, c$
+c$ = c$ + CHR$(254)
+FOR b = 1 TO LEN(c$)
+ byte = RIGHT$(LEFT$(c$, b), 1)
+ PUT #2, , byte
+NEXT b
+GOTO 1
+2
+
+CLOSE #2
+CLOSE #1
+
+SYSTEM
+
+
+SUB chl (a$, b$)
+
+e$ = ""
+FOR c = 1 TO LEN(a$)
+d = ASC(RIGHT$(LEFT$(a$, c), 1))
+IF (d >= 48) AND (d <= 57) THEN d = d - 48: GOTO 4
+IF (d >= 65) AND (d <= 70) THEN d = d - 55: GOTO 4
+IF (d = 45) AND (c = 1) THEN GOTO 4
+GOTO 5
+4
+e$ = e$ + CHR$(d)
+NEXT c
+a$ = e$
+5
+
+b$ = b$ + a$
+a$ = ""
+END SUB
+
+SUB start
+IF COMMAND$ = "" THEN END
+er = 0
+END SUB
+
--- /dev/null
+#!/bin/bash
+
+cd "${0%/*}"
+
+cd ..
+
+rsync -avz --delete -e 'ssh -p 10006' doc/ n0@www3.svjatoslav.eu:/mnt/big/projects/fifth/
+++ /dev/null
-DECLARE SUB getline (a$)\r
-DECLARE SUB start ()\r
-DIM SHARED byte AS STRING * 1\r
-DIM SHARED endf\r
-\r
-start\r
-\r
-OPEN COMMAND$ + ".5th" FOR BINARY AS #1\r
-OPEN COMMAND$ + ".src" FOR OUTPUT AS #2\r
-\r
-1\r
-getline a$\r
-IF endf = 1 THEN GOTO 2\r
-PRINT #2, a$\r
-GOTO 1\r
-2\r
-\r
-CLOSE #2\r
-CLOSE #1\r
-\r
-SYSTEM\r
-\r
-SUB getline (a$)\r
-\r
-a$ = ""\r
-3\r
-IF EOF(1) <> 0 THEN endf = 1: GOTO 4\r
-GET #1, , byte\r
-IF ASC(byte) <= 9 THEN\r
- byte = CHR$(48 + ASC(byte))\r
-END IF\r
-IF ASC(byte) <= 15 THEN\r
- byte = CHR$(65 + ASC(byte) - 10)\r
-END IF\r
-IF ASC(byte) = 255 THEN\r
- byte = " "\r
-END IF\r
-IF ASC(byte) = 253 THEN\r
- byte = CHR$(9)\r
-END IF\r
-\r
-IF byte = CHR$(254) THEN GOTO 4\r
-a$ = a$ + byte\r
-GOTO 3\r
-4\r
-\r
-END SUB\r
-\r
-SUB start\r
-endf = 0\r
-IF COMMAND$ = "" THEN END\r
-END SUB\r
-\r
+++ /dev/null
-' Disk file editor for FIFTH\r
-' Svjatoslav Agejenko: n0@hot.ee\r
-\r
-DECLARE SUB fdisp ()\r
-DECLARE SUB fopen (a$)\r
-DECLARE SUB ask (a$, b$)\r
-DECLARE SUB addk (a$)\r
-DECLARE SUB llen (a%, l%)\r
-DECLARE SUB save (a%)\r
-DECLARE SUB disp ()\r
-DEFINT A-Z\r
-\r
-DECLARE SUB load (a)\r
-DECLARE SUB start ()\r
-DECLARE SUB edit ()\r
-DIM SHARED buf(0 TO 31, 0 TO 31)\r
-DIM SHARED obuf(0 TO 31, 0 TO 31)\r
-DIM SHARED byte AS STRING * 1\r
-DIM SHARED font(0 TO 20, 0 TO 255)\r
-DIM SHARED eb\r
-DIM SHARED keys(0 TO 10000)\r
-DIM SHARED keyl, keyc\r
-DIM SHARED curx, cury\r
-DIM SHARED fil$(0 TO 1000)\r
-DIM SHARED fline, froll\r
-DIM SHARED filename$\r
-\r
-start\r
-\r
-OPEN "..\..\disk.raw" FOR BINARY AS #1\r
-\r
-edit\r
-\r
-CLOSE #1\r
-SYSTEM\r
-\r
-SUB addk (a$)\r
-keys(keyl) = ASC(a$)\r
-keyl = keyl + 1\r
-IF keyl > 10000 THEN keyl = 0\r
-END SUB\r
-\r
-SUB ask (a$, b$)\r
-LOCATE 16, 34\r
-PRINT SPACE$(46)\r
-LOCATE 16, 34\r
-COLOR 15\r
-PRINT a$\r
-COLOR 10\r
-LOCATE 16, 34 + LEN(a$)\r
-INPUT "", b$\r
-LOCATE 16, 34\r
-PRINT SPACE$(46)\r
-COLOR 15\r
-END SUB\r
-\r
-SUB disp\r
-\r
-FOR y = 0 TO 31\r
-FOR x = 0 TO 31\r
-c = buf(x, y)\r
-IF c <> obuf(x, y) THEN\r
- PUT (x * 8, y * 8), font(0, c), PSET\r
- obuf(x, y) = c\r
-END IF\r
-NEXT x\r
-NEXT y\r
-\r
-x1 = curx * 8\r
-y1 = cury * 8\r
-FOR y = y1 TO y1 + 7\r
-FOR x = x1 TO x1 + 7\r
-c = POINT(x, y)\r
-IF c = 15 THEN c = 0 ELSE c = 10\r
-PSET (x, y), c\r
-NEXT x\r
-NEXT y\r
-obuf(curx, cury) = -1\r
-\r
-LOCATE 1, 77\r
-PRINT " "\r
-LOCATE 1, 76\r
-PRINT buf(curx, cury)\r
-END SUB\r
-\r
-SUB edit\r
-fdisp\r
-leb = -1\r
-m = 0\r
-1\r
-IF eb <> leb THEN\r
- IF m = 1 THEN\r
- save leb\r
- m = 0\r
- END IF\r
- load eb\r
- leb = eb\r
- LOCATE 1, 60\r
- PRINT "page:"; eb; " "\r
-END IF\r
-disp\r
-2\r
-a$ = INKEY$\r
-bk = 0\r
-IF a$ = "" THEN\r
- IF keyl = keyc THEN GOTO 2\r
- a$ = CHR$(keys(keyc))\r
- keyc = keyc + 1\r
- IF keyc > 10000 THEN keyc = 0\r
- bk = 1\r
-END IF\r
-\r
-IF a$ = CHR$(0) + CHR$(73) THEN eb = eb - 1\r
-IF a$ = CHR$(0) + CHR$(81) THEN eb = eb + 1\r
-IF a$ = CHR$(27) THEN GOTO 4\r
-IF a$ = CHR$(0) + "M" THEN curx = curx + 1\r
-IF a$ = CHR$(0) + "K" THEN curx = curx - 1\r
-IF a$ = CHR$(0) + "P" THEN cury = cury + 1\r
-IF a$ = CHR$(0) + "H" THEN cury = cury - 1\r
-IF a$ = CHR$(0) + "=" THEN ask "page: ", b$: eb = VAL(b$)\r
-IF a$ = CHR$(0) + "?" THEN ask "file: ", b$: fopen b$\r
-IF a$ = CHR$(0) + CHR$(132) THEN fline = fline - 1: fdisp\r
-IF a$ = CHR$(0) + CHR$(118) THEN fline = fline + 1: fdisp\r
-IF a$ = CHR$(0) + CHR$(64) THEN ' F6\r
- d = 0\r
- FOR b = 1 TO LEN(fil$(fline))\r
- c$ = RIGHT$(LEFT$(fil$(fline), b), 1)\r
- IF c$ = CHR$(9) THEN c$ = " "\r
- IF c$ = " " OR c$ = CHR$(255) THEN d = d + 1 ELSE d = 0\r
- IF d < 2 THEN addk c$\r
- NEXT b\r
-END IF\r
-\r
-IF a$ = CHR$(0) + ";" THEN\r
- FOR y = 0 TO 31\r
- FOR x = 0 TO 31\r
- buf(x, y) = 255\r
- NEXT x\r
- NEXT y\r
- m = 1\r
-END IF\r
-\r
-IF a$ = CHR$(0) + CHR$(83) THEN\r
- FOR b = curx TO 30\r
- buf(b, cury) = buf(b + 1, cury)\r
- NEXT b\r
- buf(31, cury) = 255\r
- m = 1\r
-END IF\r
-\r
-IF (a$ = CHR$(13)) AND (bk = 0) THEN\r
-a$ = ""\r
-IF cury < 31 THEN\r
- FOR a = 31 TO cury + 2 STEP -1\r
- FOR b = 0 TO 31\r
- buf(b, a) = buf(b, a - 1)\r
- NEXT b\r
- NEXT a\r
- FOR a = 0 TO 31\r
- buf(a, cury + 1) = 255\r
- NEXT a\r
- FOR a = curx TO 31\r
- SWAP buf(a, cury), buf(a - curx, cury + 1)\r
- NEXT a\r
- m = 1\r
- cury = cury + 1\r
- curx = 0\r
-END IF\r
-END IF\r
-\r
-IF LEN(a$) = 1 THEN\r
- IF ASC(a$) = 32 THEN a$ = CHR$(255)\r
- IF (a$ = CHR$(8)) AND (bk = 0) THEN\r
- a$ = ""\r
- IF curx > 0 THEN\r
- FOR b = curx - 1 TO 30\r
- buf(b, cury) = buf(b + 1, cury)\r
- NEXT b\r
- buf(31, cury) = 255\r
- curx = curx - 1\r
- m = 1\r
- ELSE\r
- IF cury > 0 THEN\r
- llen cury - 1, a\r
- curx = a\r
- FOR b = a TO 31\r
- buf(b, cury - 1) = buf(b - a, cury)\r
- NEXT b\r
- FOR a = cury TO 30\r
- FOR b = 0 TO 31\r
- buf(b, a) = buf(b, a + 1)\r
- NEXT b\r
- NEXT a\r
- FOR b = 0 TO 31\r
- buf(b, 31) = 255\r
- NEXT b\r
- m = 1\r
- cury = cury - 1\r
- END IF\r
- END IF\r
- END IF\r
-END IF\r
-\r
-IF a$ = CHR$(0) + "<" THEN\r
-ask "decimal number:", b$\r
-b$ = HEX$(VAL(b$))\r
-FOR a = 1 TO LEN(b$)\r
- c = ASC(RIGHT$(LEFT$(b$, a), 1))\r
- IF (c <= 57) AND (c >= 48) THEN d$ = CHR$(c - 48): addk d$\r
- IF (c <= 70) AND (c >= 65) THEN d$ = CHR$(c - 55): addk d$\r
-NEXT a\r
-END IF\r
-\r
-IF a$ = CHR$(0) + CHR$(65) THEN\r
-FOR a = 999 TO fline STEP -1\r
- fil$(a + 1) = fil$(a)\r
-NEXT a\r
-fil$(fline) = ""\r
-FOR a = curx TO 31\r
- fil$(fline) = fil$(fline) + CHR$(buf(a, cury))\r
-NEXT a\r
-fdisp\r
-END IF\r
-\r
-IF a$ = CHR$(0) + ">" THEN\r
-ask "ascii code:", b$\r
-a$ = CHR$(VAL(b$))\r
-END IF\r
-\r
-IF LEN(a$) = 1 THEN\r
- FOR b = 31 TO curx + 1 STEP -1\r
- buf(b, cury) = buf(b - 1, cury)\r
- NEXT b\r
- buf(curx, cury) = ASC(a$)\r
- curx = curx + 1\r
- m = 1\r
-END IF\r
-\r
-IF eb < 0 THEN eb = 0\r
-IF curx < 0 THEN curx = 0\r
-IF cury < 0 THEN cury = 0\r
-IF curx > 31 THEN curx = 31\r
-IF cury > 31 THEN cury = 31\r
-GOTO 1\r
-4\r
-\r
-END SUB\r
-\r
-SUB fdisp\r
-IF fline < 0 THEN fline = 0\r
-IF fline > 1000 THEN fline = 1000\r
-IF fline - froll > 10 THEN froll = fline - 10\r
-IF fline - froll < 0 THEN froll = fline\r
-IF froll < 0 THEN froll = 0\r
-\r
-LOCATE 17, 1\r
-PRINT SPACE$(80)\r
-LOCATE 17, 1\r
-PRINT "file: " + filename$\r
-\r
-LOCATE 17, 20\r
-PRINT "line:"; fline\r
-\r
-FOR a = 0 TO 10\r
- LOCATE a + 18, 1\r
- IF a + froll = fline THEN\r
- COLOR 10\r
- IF fil$(a + froll) = SPACE$(LEN(fil$(a + froll))) THEN\r
- FOR b = 1 TO 80\r
- PRINT CHR$(219);\r
- NEXT b\r
- GOTO 7\r
- END IF\r
- ELSE\r
- COLOR 12\r
- END IF\r
- PRINT fil$(a + froll) + SPACE$(80 - LEN(fil$(a + froll)));\r
-7\r
-NEXT a\r
-\r
-COLOR 15\r
-END SUB\r
-\r
-SUB fopen (a$)\r
-filename$ = a$\r
-FOR b = 0 TO 1000\r
- fil$(b) = ""\r
-NEXT b\r
-\r
-b = 0\r
-OPEN filename$ FOR INPUT AS #2\r
-5\r
-IF EOF(2) <> 0 THEN GOTO 6\r
-LINE INPUT #2, c$\r
-fil$(b) = c$\r
-b = b + 1\r
-IF b > 1000 THEN GOTO 6\r
-GOTO 5\r
-6\r
-CLOSE #2\r
-\r
-fline = 0\r
-froll = 0\r
-fdisp\r
-END SUB\r
-\r
-SUB llen (a, l)\r
-FOR b = 31 TO 0 STEP -1\r
-IF buf(b, a) <> 255 THEN l = b + 1: GOTO 3\r
-NEXT b\r
-l = 0\r
-3\r
-END SUB\r
-\r
-SUB load (a)\r
-DIM c AS LONG\r
-DIM a1 AS LONG\r
-a1 = a\r
-c = a1 * 1024\r
-SEEK #1, c + 1\r
-FOR y = 0 TO 31\r
- FOR x = 0 TO 31\r
- GET #1, , byte\r
- buf(x, y) = ASC(byte)\r
- NEXT x\r
-NEXT y\r
-END SUB\r
-\r
-SUB save (a)\r
-DIM c AS LONG\r
-DIM a1 AS LONG\r
-a1 = a\r
-c = a1 * 1024\r
-SEEK #1, c + 1\r
-FOR y = 0 TO 31\r
- FOR x = 0 TO 31\r
- byte = CHR$(buf(x, y))\r
- PUT #1, , byte\r
- NEXT x\r
-NEXT y\r
-SOUND 5000, .1\r
-END SUB\r
-\r
-SUB start\r
-SCREEN 12\r
-COLOR 15\r
-eb = 7\r
-\r
-filename$ = "<noname>"\r
-fline = 0\r
-froll = 0\r
-keyl = 0\r
-keyc = 0\r
-\r
-OPEN "font.dat" FOR BINARY AS #1\r
-FOR f = 0 TO 255\r
-FOR y = 0 TO 7\r
-GET #1, , byte\r
-n = ASC(byte)\r
-b = 128\r
-FOR a = 0 TO 7\r
-IF n >= b THEN n = n - b: c = 15 ELSE c = 0\r
-b = b / 2\r
-PSET (a, y), c\r
-NEXT a\r
-NEXT y\r
-GET (0, 0)-(7, 7), font(0, f)\r
-NEXT f\r
-CLOSE #1\r
-\r
-FOR y = 0 TO 31\r
-FOR x = 0 TO 31\r
-obuf(x, y) = -1\r
-NEXT x\r
-NEXT y\r
-\r
-LOCATE 1, 34\r
-PRINT "F1 - clear page"\r
-LOCATE 2, 34\r
-PRINT "F2 - enter decimal number"\r
-LOCATE 3, 34\r
-PRINT "F3 - goto page"\r
-LOCATE 4, 34\r
-PRINT "F4 - enter character code"\r
-LOCATE 5, 34\r
-PRINT "F5 - load source file"\r
-LOCATE 6, 34\r
-PRINT "F6 - insert line from source file"\r
-LOCATE 7, 34\r
-PRINT "F7 - copy line to source file"\r
-\r
-LOCATE 1, 71\r
-PRINT "code:"\r
-END SUB\r
-\r
+++ /dev/null
-DECLARE SUB bytew (fi&, d&, addr&)\r
-DECLARE SUB byter (fi&, addr&, d&)\r
-DECLARE SUB dwordw (fi&, b&, a&)\r
-DEFLNG A-Z\r
-\r
-DECLARE SUB savepath ()\r
-DECLARE SUB getson (a$)\r
-DECLARE SUB start ()\r
-\r
-DIM SHARED mitus, sona$(1 TO 50)\r
-DIM SHARED byte AS STRING * 1\r
-DIM SHARED length\r
-DIM SHARED srcfile$\r
-\r
-start\r
-\r
-OPEN "..\disk.raw" FOR BINARY AS #1\r
-savepath\r
-SEEK #1, 2000101\r
-OPEN srcfile$ FOR BINARY AS #2\r
-2\r
-IF EOF(2) <> 0 THEN GOTO 1\r
-GET #2, , byte\r
-length = length + 1\r
-PUT #1, , byte\r
-GOTO 2\r
-1\r
-CLOSE #2\r
-dwordw 1, length - 1, 2000000\r
-CLOSE #1\r
-\r
-SYSTEM\r
-\r
-SUB byter (fi, addr, d)\r
-SEEK #1, addr + 1\r
-GET fi, , byte\r
-d = ASC(byte)\r
-END SUB\r
-\r
-SUB bytew (fi, d, addr)\r
-SEEK #1, addr + 1\r
-byte = CHR$(d)\r
-PUT #1, , byte\r
-END SUB\r
-\r
-SUB dwordr (fi, a, f)\r
-byter fi, a, b\r
-byter fi, a + 1, c\r
-byter fi, a + 2, d\r
-byter fi, a + 3, e\r
-f = e * 16777216\r
-f = f + d * 65536 + c * 256 + b\r
-END SUB\r
-\r
-SUB dwordw (fi, b, a)\r
-c = b\r
-d = c \ 16777216\r
-c = c - (d * 16777216)\r
-\r
-e = c \ 65536\r
-c = c - (e * 65536)\r
-\r
-f = c \ 256\r
-c = c - (f * 256)\r
-\r
-bytew fi, c, a\r
-bytew fi, f, a + 1\r
-bytew fi, e, a + 2\r
-bytew fi, d, a + 3\r
-END SUB\r
-\r
-DEFSNG A-Z\r
-SUB getson (a$)\r
-mitus = 0\r
-\r
-d = 1\r
-FOR b = 1 TO LEN(a$)\r
-c$ = RIGHT$(LEFT$(a$, b), 1)\r
-IF c$ = " " THEN\r
-d = 1\r
-ELSE\r
-IF d = 1 THEN\r
-mitus = mitus + 1\r
-sona$(mitus) = ""\r
-d = 0\r
-END IF\r
-sona$(mitus) = sona$(mitus) + c$\r
-END IF\r
-NEXT b\r
-END SUB\r
-\r
-SUB savepath\r
-a$ = COMMAND$ + "\"\r
-f$ = ""\r
-ext$ = ""\r
-t$ = ""\r
-m = 0\r
-FOR b = 1 TO LEN(a$)\r
- c$ = RIGHT$(LEFT$(a$, b), 1)\r
- IF c$ = "." THEN m = 1: GOTO 3\r
- IF c$ = "\" THEN\r
- IF ext$ = "" THEN ext$ = "list"\r
-4 IF LEN(ext$) < 4 THEN ext$ = ext$ + "_": GOTO 4\r
- t$ = t$ + ext$ + f$ + "\"\r
- f$ = ""\r
- ext$ = ""\r
- GOTO 3\r
- END IF\r
- IF m = 0 THEN f$ = f$ + c$ ELSE ext$ = ext$ + c$\r
-3\r
-NEXT b\r
-t$ = LEFT$(t$, LEN(t$) - 1)\r
-\r
-' PRINT a$\r
-' PRINT t$\r
-\r
-t$ = t$ + CHR$(254)\r
-SEEK #1, 2000005\r
-PUT #1, , t$\r
-\r
-\r
-\r
-\r
-END SUB\r
-\r
-SUB start\r
-\r
-IF COMMAND$ = "" THEN END\r
-\r
-srcfile$ = COMMAND$\r
-\r
-\r
-END SUB\r
-\r
+++ /dev/null
-DECLARE SUB getson (a$)\r
-DECLARE SUB start ()\r
-DIM SHARED mitus, sona$(1 TO 50)\r
-DIM SHARED byte AS STRING * 1\r
-\r
-start\r
-\r
-OPEN sona$(1) FOR BINARY AS #1\r
-PRINT "Seeking to:" + sona$(3)\r
-SEEK #1, VAL(sona$(3)) + 1\r
-OPEN sona$(2) FOR BINARY AS #2\r
-2\r
-IF EOF(2) <> 0 THEN GOTO 1\r
-GET #2, , byte\r
-PUT #1, , byte\r
-GOTO 2\r
-1\r
-CLOSE #2\r
-CLOSE #1\r
-\r
-SYSTEM\r
-\r
-SUB getson (a$)\r
-mitus = 0\r
-\r
-d = 1\r
-FOR b = 1 TO LEN(a$)\r
-c$ = RIGHT$(LEFT$(a$, b), 1)\r
-IF c$ = " " THEN\r
-d = 1\r
-ELSE\r
-IF d = 1 THEN\r
-mitus = mitus + 1\r
-sona$(mitus) = ""\r
-d = 0\r
-END IF\r
-sona$(mitus) = sona$(mitus) + c$\r
-END IF\r
-NEXT b\r
-END SUB\r
-\r
-SUB start\r
-\r
-IF COMMAND$ = "" THEN END\r
-\r
-getson COMMAND$\r
-\r
-\r
-END SUB\r
-\r
+++ /dev/null
-DECLARE SUB chl (a$, b$)\r
-DECLARE SUB getline (a$)\r
-DECLARE SUB start ()\r
-DIM SHARED byte AS STRING * 1\r
-DIM SHARED er\r
-\r
-\r
-start\r
-\r
-OPEN COMMAND$ + ".src" FOR INPUT AS #1\r
-IF er = 0 THEN KILL COMMAND$ + ".5th"\r
-OPEN COMMAND$ + ".5th" FOR BINARY AS #2\r
-\r
-1\r
-IF EOF(1) <> 0 THEN GOTO 2\r
-LINE INPUT #1, a$\r
-\r
-c$ = ""\r
-e$ = ""\r
-FOR b = 1 TO LEN(a$)\r
-d$ = RIGHT$(LEFT$(a$, b), 1)\r
-IF d$ = " " THEN chl e$, c$: c$ = c$ + CHR$(255): GOTO 3\r
-IF d$ = CHR$(9) THEN chl e$, c$: c$ = c$ + CHR$(253): GOTO 3\r
-e$ = e$ + d$\r
-3\r
-NEXT b\r
-chl e$, c$\r
-c$ = c$ + CHR$(254)\r
-FOR b = 1 TO LEN(c$)\r
- byte = RIGHT$(LEFT$(c$, b), 1)\r
- PUT #2, , byte\r
-NEXT b\r
-GOTO 1\r
-2\r
-\r
-CLOSE #2\r
-CLOSE #1\r
-\r
-SYSTEM\r
-\r
-\r
-SUB chl (a$, b$)\r
-\r
-e$ = ""\r
-FOR c = 1 TO LEN(a$)\r
-d = ASC(RIGHT$(LEFT$(a$, c), 1))\r
-IF (d >= 48) AND (d <= 57) THEN d = d - 48: GOTO 4\r
-IF (d >= 65) AND (d <= 70) THEN d = d - 55: GOTO 4\r
-IF (d = 45) AND (c = 1) THEN GOTO 4\r
-GOTO 5\r
-4\r
-e$ = e$ + CHR$(d)\r
-NEXT c\r
-a$ = e$\r
-5\r
-\r
-b$ = b$ + a$\r
-a$ = ""\r
-END SUB\r
-\r
-SUB start\r
-IF COMMAND$ = "" THEN END\r
-er = 0\r
-END SUB\r
-\r