From: Svjatoslav Agejenko Date: Mon, 1 Jan 2018 21:39:14 +0000 (+0200) Subject: Updated documentation. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=7ad7475c2abf891a92b457339aaa0c20c40634d1;p=fifth.git Updated documentation. --- diff --git a/doc/commands/cmp&misc.txt b/doc/commands/cmp&misc.txt deleted file mode 100644 index 97446fb..0000000 --- a/doc/commands/cmp&misc.txt +++ /dev/null @@ -1,166 +0,0 @@ - Compilation & misc - ------------------ - - -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 ( -- ) compiles new dictionary entry without specifying - new module type. - ex: head myentry - -: ( -- ) creates new code module -; ( -- ) ends module (immideate) - ex: : hello ." hi there" ; - -const ( n -- ) defines new constant. - ex: 2147483647 const max - -:i ( -- ) same as ":" but this module will be executed - immideately even in compile mode. - ex: :i ( 41 scan ; - -create ( -- ) 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 - -" " ( -- ) compile string and its size into core. - ex: create Mystring " This is it's contects" - -str " ( -- ) just shorter way for defining strings. - ex: str Mystring This is it's contenc" - -var ( -- ) define new 32 bit variable. - ex: var result - -' ( -- n ) return memory address of given entry. - ex: ' init - -forget ( -- ) 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 ( -- ) 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 ( -- ) 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 -- ) check if module is loaded, if not - immideately load it. - -ne ( entrydata entrytype -- ) Compile new dictionary entry. - It's name must be in "pad". diff --git a/doc/commands/conditio.txt b/doc/commands/conditio.txt deleted file mode 100644 index 1828272..0000000 --- a/doc/commands/conditio.txt +++ /dev/null @@ -1,39 +0,0 @@ - Conditionals & loops - ------------------ - -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" - diff --git a/doc/commands/dsk&file.txt b/doc/commands/dsk&file.txt deleted file mode 100644 index b36870f..0000000 --- a/doc/commands/dsk&file.txt +++ /dev/null @@ -1,57 +0,0 @@ - Disk & file access - ------------------ - -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 DynStrHand -- ) - Create new file and save all data from dynamic memory - block to it. - -fsDload ( DynStr DynHand -- ) - Load whole file into dynamic memory block. - -fsDloadnew ( DynStr -- DynHand ) - Load whole file into new dynamic memory block. - diff --git a/doc/commands/dynmem.txt b/doc/commands/dynmem.txt deleted file mode 100644 index eb3ff6f..0000000 --- a/doc/commands/dynmem.txt +++ /dev/null @@ -1,43 +0,0 @@ - Dynamic memory - -------------- - - -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. - - diff --git a/doc/commands/graphic.txt b/doc/commands/graphic.txt deleted file mode 100644 index cb8ec9d..0000000 --- a/doc/commands/graphic.txt +++ /dev/null @@ -1,68 +0,0 @@ - Graphic & text - -------------- - -. ( n -- ) print number on screen - -d. ( n -- ) print number on screen in decimal - -? ( addr -- ) print 32 bit value located at addr. - -." " ( -- ) 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. diff --git a/doc/commands/index.html b/doc/commands/index.html deleted file mode 100644 index 5b88a3b..0000000 --- a/doc/commands/index.html +++ /dev/null @@ -1,19 +0,0 @@ -FIFTH - -
-
-    

Fifth internal standard commands:

- - -
Math & memory manipulation -
Disk & file access -
Conditionals and loops -
Graphic & text -
Dynamic memory -
Dynamic & static strings -
Compilation & miscellaneous - - -
- - \ No newline at end of file diff --git a/doc/commands/math&mem.txt b/doc/commands/math&mem.txt deleted file mode 100644 index 9e68523..0000000 --- a/doc/commands/math&mem.txt +++ /dev/null @@ -1,61 +0,0 @@ - Math, memory & stack manipulation - --------------------------------- - - -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" diff --git a/doc/commands/string.txt b/doc/commands/string.txt deleted file mode 100644 index c254206..0000000 --- a/doc/commands/string.txt +++ /dev/null @@ -1,126 +0,0 @@ - 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. - -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 - - - - mystring1 Df ; \ deallocates it again when no longer needed. diff --git a/doc/emulator.html b/doc/emulator.html deleted file mode 100644 index d1495d4..0000000 --- a/doc/emulator.html +++ /dev/null @@ -1,130 +0,0 @@ -FIFTH - - -
-
-    

Emulator & virtual CPU

- - - -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): - -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 ( -- n ) put immidiate number into datastack - -4 jmp jump to specified code -5 call 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 ( 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 -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. - -
- - \ No newline at end of file diff --git a/doc/files.txt b/doc/files.txt deleted file mode 100644 index f035eea..0000000 --- a/doc/files.txt +++ /dev/null @@ -1,24 +0,0 @@ - Fifth distribution directory tree description - ============================================= - -After downloading and unpacking the ZIP file you shoud get -directory tree similar to this: - - -[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. - - - - diff --git a/doc/index.html b/doc/index.html index a350612..6d320c6 100644 --- a/doc/index.html +++ b/doc/index.html @@ -2,7 +2,7 @@ Fifth - virtual machine, operating system, programming language - + @@ -278,27 +278,42 @@ similar. Basically I got familiar with concepts of Forth, and being inspired created my own system.

+ + +
+

2.1 screenshots

+
+
+ +

3 Installation

@@ -315,11 +330,37 @@ Read more about distribution directory layout
-

4 Software/Hardware/Human requirements

+

4 Fifth distribution directory tree description

-
-

4.1 Software:

-
+

+After downloading and unpacking the ZIP file you shoud get directory +tree similar to this: +

+ +

+[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.
+

+
+
+ +
+

5 Software/Hardware/Human requirements

+
+
+

5.1 Software

+
  • MS-DOS 6.22, with HIMEM.SYS loaded.
  • @@ -336,9 +377,9 @@ Read more about distribution directory layout
-
-

4.2 Hardware:

-
+
+

5.2 Hardware

+
  • Minimum CPU 386.
  • @@ -351,9 +392,9 @@ Read more about distribution directory layout
-
-

4.3 Human:

-
+
+

5.3 Human

+
  • Beginner level Forth knowledge is recommended.
  • @@ -363,9 +404,9 @@ Read more about distribution directory layout
-
-

5 Numbers representation

-
+
+

6 Numbers representation within Fifth

+

numbers.png @@ -384,18 +425,18 @@ their color (black or white).

-
-

6 Disk file map, and it's data structures

-
+
+

7 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.

-
-

6.1 disk allocation

-
+
+

7.1 disk allocation

+
@@ -441,9 +482,9 @@ yet initialized.
-
-

6.2 FAT entry format:

-
+
+

7.2 FAT entry format:

+
@@ -477,9 +518,9 @@ yet initialized.
-
-

6.3 file entry format

-
+
+

7.3 file entry format

+
@@ -532,9 +573,9 @@ yet initialized. -
-

7 Core architecture

-
+
+

8 Core architecture

+

Fifth core is simply some amount of already compiled into machine code and linked together modules (entries in other words). In compilation @@ -546,9 +587,9 @@ dictionary space only. Random word can be removed from dictionary at any time. Currently dictionary can contain at most 1000 entries.

-
-

7.1 dictionary entry format

-
+
+

8.1 Dictionary entry format

+
@@ -615,9 +656,9 @@ run through headers backwards and find needed entry.

-
-

7.2 Possible module types

-
+
+

8.2 Possible module types

+
@@ -671,9 +712,9 @@ run through headers backwards and find needed entry.
-
-

7.3 Memory map: (average)

-
+
+

8.3 Memory map (average)

+
@@ -720,9 +761,165 @@ run through headers backwards and find needed entry. -
-

8 Fifth source format

-
+
+

9 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: +

+
+ + +++ ++ + + + + + + + + + + + + + + + + +
IPinstruction pointer
DSPdata stack pointer
RSPreturn stack pointer
+ +

+Virtual CPU, commands (most of them are avaiable as ordinary commands +in programming lanquage): +

+ +

+
+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.
+

+
+
+ +
+

10 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 @@ -732,9 +929,9 @@ numeric values. So typical nemric characters "0123…" is treated like ordinary letters.

-
-

8.1 FSCII:

-
+
+

10.1 FSCII

+
@@ -793,37 +990,753 @@ like ordinary letters. +
+

11 Fifth commands

+
+
+

11.1 Compilation & miscellaneous

+
+

+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".
+

+
+
+
+

11.2 Conditionals & control flow

+
+

+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"
+
+

+
+
+
+

11.3 Disk & file access

+
+

+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.
+

+
+
+
+

11.4 Dynamic memory

+
+

+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.
+

+
+
+
+

11.5 Graphics and text

+
+

+. ( 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.
+

+
+
+
+

11.6 Math, memory & stack manipulation

+
+

+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"
+

+
+
+
+

11.7 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. +

+ + +

+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.
+

+
+
+
+
+

12 Dynamically loadable modules

+
+
+

12.1 Keyboard driver

+
+

+
+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
+

+
+
+
+

12.2 Mouse driver

+
+

+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".
+

+
+
+
+

12.3 2D graphic library

+
+

+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.
+

+
+
+
+

12.4 Trigonometry functions

+
+

+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.
+

+
+
+

Author: Svjatoslav Agejenko

-

Created: 2017-11-29 Wed 23:48

+

Created: 2018-01-01 Mon 23:29

Emacs 25.1.1 (Org-mode 8.2.10)

diff --git a/doc/index.org b/doc/index.org index 6517a4d..6a0958e 100644 --- a/doc/index.org +++ b/doc/index.org @@ -41,15 +41,19 @@ Moore's Forth, it also uses stack architecture, and many commands are 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 @@ -57,23 +61,43 @@ fifth you need minimally just 2 files. emulator itself ( EMULATOR.EXE 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]] @@ -84,8 +108,6 @@ Fifth uses its hexdecimal number representation as primary. Numbers 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. @@ -119,7 +141,7 @@ dictionary, this is special list that contain names of compiled 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 | @@ -145,13 +167,133 @@ run through headers backwards and find needed entry. | | | with address to module | |------+----------------+----------------------------| | 2 | imm. submodule | immediately call to module | -** Memory map: (average) +** Memory map (average) | | | | |---------+--------+-----------------------------| | 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 ( -- n ) put immidiate number into datastack + +4 jmp jump to specified code +5 call 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 ( 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 +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 @@ -159,7 +301,7 @@ Interchange) for example space character is not 32 but 255 instead. I 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 | |--------+-------+----------------------------------------| @@ -169,3 +311,638 @@ like ordinary letters. | 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 ( -- ) compiles new dictionary entry without specifying + new module type. + ex: head myentry + +: ( -- ) creates new code module +; ( -- ) ends module (immideate) + ex: : hello ." hi there" ; + +const ( n -- ) defines new constant. + ex: 2147483647 const max + +:i ( -- ) same as ":" but this module will be executed + immideately even in compile mode. + ex: :i ( 41 scan ; + +create ( -- ) 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 + +" " ( -- ) compile string and its size into core. + ex: create Mystring " This is it's contects" + +str " ( -- ) just shorter way for defining strings. + ex: str Mystring This is it's contenc" + +var ( -- ) define new 32 bit variable. + ex: var result + +' ( -- n ) return memory address of given entry. + ex: ' init + +forget ( -- ) 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 ( -- ) 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 ( -- ) 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 -- ) 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 DynStrHand -- ) + Create new file and save all data from dynamic memory + block to it. + +fsDload ( DynStr DynHand -- ) + Load whole file into dynamic memory block. + +fsDloadnew ( DynStr -- DynHand ) + 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. + +." " ( -- ) 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 + + + + 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 diff --git a/doc/modules/drvkbd.txt b/doc/modules/drvkbd.txt deleted file mode 100644 index a8b517a..0000000 --- a/doc/modules/drvkbd.txt +++ /dev/null @@ -1,34 +0,0 @@ - Keyboard driver - --------------- - -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 diff --git a/doc/modules/drvmouse.txt b/doc/modules/drvmouse.txt deleted file mode 100644 index 80bf167..0000000 --- a/doc/modules/drvmouse.txt +++ /dev/null @@ -1,17 +0,0 @@ - Mouse driver - ------------ - -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". diff --git a/doc/modules/gfx2.txt b/doc/modules/gfx2.txt deleted file mode 100644 index 24085f7..0000000 --- a/doc/modules/gfx2.txt +++ /dev/null @@ -1,20 +0,0 @@ - 2D graphic library - ------------------ - - -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. diff --git a/doc/modules/index.html b/doc/modules/index.html deleted file mode 100644 index 97f4011..0000000 --- a/doc/modules/index.html +++ /dev/null @@ -1,16 +0,0 @@ -FIFTH - - -
-
-    

Loadable external modules

- - -keyboard driver -mouse driver -advanced graphic library -trigonometry module - -
- - \ No newline at end of file diff --git a/doc/modules/trig.txt b/doc/modules/trig.txt deleted file mode 100644 index 7899144..0000000 --- a/doc/modules/trig.txt +++ /dev/null @@ -1,9 +0,0 @@ - Trigonometry functions - ---------------------- - -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. diff --git a/doc/screenshots/dictionary.png b/doc/screenshots/dictionary.png new file mode 100644 index 0000000..73909b0 Binary files /dev/null and b/doc/screenshots/dictionary.png differ diff --git a/doc/screenshots/index.html b/doc/screenshots/index.html new file mode 100644 index 0000000..2504418 --- /dev/null +++ b/doc/screenshots/index.html @@ -0,0 +1,27 @@ +FIFTH + + +
+
+    

Screen shots

+ + + + + + + + +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. + + + + +Built in text editor. + + + +
+ diff --git a/doc/screenshots/start.png b/doc/screenshots/start.png new file mode 100644 index 0000000..15b5c40 Binary files /dev/null and b/doc/screenshots/start.png differ diff --git a/doc/screenshots/text editor.png b/doc/screenshots/text editor.png new file mode 100644 index 0000000..153bf90 Binary files /dev/null and b/doc/screenshots/text editor.png differ diff --git a/doc/shots/index.html b/doc/shots/index.html deleted file mode 100644 index 651e755..0000000 --- a/doc/shots/index.html +++ /dev/null @@ -1,27 +0,0 @@ -FIFTH - - -
-
-    

Screen shots

- - - -Startup screen diplaying Fifth logo and full file list. - - - - -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. - - - - -Built in text editor. - - - -
- \ No newline at end of file diff --git a/doc/shots/start.png b/doc/shots/start.png deleted file mode 100644 index 0ed0b15..0000000 Binary files a/doc/shots/start.png and /dev/null differ diff --git a/doc/shots/textEditor.png b/doc/shots/textEditor.png deleted file mode 100644 index b12ee21..0000000 Binary files a/doc/shots/textEditor.png and /dev/null differ diff --git a/doc/shots/words.png b/doc/shots/words.png deleted file mode 100644 index a9c67c7..0000000 Binary files a/doc/shots/words.png and /dev/null differ diff --git a/tools/5th2src.bas b/tools/5th2src.bas new file mode 100755 index 0000000..2943f06 --- /dev/null +++ b/tools/5th2src.bas @@ -0,0 +1,53 @@ +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 + diff --git a/tools/editor.bas b/tools/editor.bas new file mode 100755 index 0000000..3e64fa1 --- /dev/null +++ b/tools/editor.bas @@ -0,0 +1,395 @@ +' 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$ = "" +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 + diff --git a/tools/font.dat b/tools/font.dat new file mode 100755 index 0000000..980f716 Binary files /dev/null and b/tools/font.dat differ diff --git a/tools/fsimport.bas b/tools/fsimport.bas new file mode 100755 index 0000000..fc5e614 --- /dev/null +++ b/tools/fsimport.bas @@ -0,0 +1,134 @@ +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 + diff --git a/tools/insert.bas b/tools/insert.bas new file mode 100755 index 0000000..b167c16 --- /dev/null +++ b/tools/insert.bas @@ -0,0 +1,50 @@ +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 + diff --git a/tools/src25th.bas b/tools/src25th.bas new file mode 100755 index 0000000..8d79e0c --- /dev/null +++ b/tools/src25th.bas @@ -0,0 +1,65 @@ +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 + diff --git a/tools/update web site b/tools/update web site new file mode 100755 index 0000000..c2cd502 --- /dev/null +++ b/tools/update web site @@ -0,0 +1,7 @@ +#!/bin/bash + +cd "${0%/*}" + +cd .. + +rsync -avz --delete -e 'ssh -p 10006' doc/ n0@www3.svjatoslav.eu:/mnt/big/projects/fifth/ diff --git a/util/5th2src.bas b/util/5th2src.bas deleted file mode 100755 index b147cc1..0000000 --- a/util/5th2src.bas +++ /dev/null @@ -1,53 +0,0 @@ -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 - diff --git a/util/editor.bas b/util/editor.bas deleted file mode 100755 index 313b6e8..0000000 --- a/util/editor.bas +++ /dev/null @@ -1,395 +0,0 @@ -' 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$ = "" -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 - diff --git a/util/font.dat b/util/font.dat deleted file mode 100755 index 980f716..0000000 Binary files a/util/font.dat and /dev/null differ diff --git a/util/fsimport.bas b/util/fsimport.bas deleted file mode 100755 index 0d7e1ff..0000000 --- a/util/fsimport.bas +++ /dev/null @@ -1,134 +0,0 @@ -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 - diff --git a/util/insert.bas b/util/insert.bas deleted file mode 100755 index d40265f..0000000 --- a/util/insert.bas +++ /dev/null @@ -1,50 +0,0 @@ -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 - diff --git a/util/src25th.bas b/util/src25th.bas deleted file mode 100755 index af0a924..0000000 --- a/util/src25th.bas +++ /dev/null @@ -1,65 +0,0 @@ -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 -