From: Svjatoslav Agejenko Date: Sat, 7 Jul 2012 19:40:13 +0000 (+0300) Subject: initial commit X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=9a899b7221ef10d222ea321f147974889d0c1ca9;p=fifth.git initial commit --- 9a899b7221ef10d222ea321f147974889d0c1ca9 diff --git a/.classpath b/.classpath new file mode 100755 index 0000000..ac37fb2 --- /dev/null +++ b/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..f0216fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +bin/ + diff --git a/.project b/.project new file mode 100755 index 0000000..0ca8df8 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + fifth + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/COPYING b/COPYING new file mode 100755 index 0000000..10828e0 --- /dev/null +++ b/COPYING @@ -0,0 +1,341 @@ + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/doc/5TH_ET.txt b/doc/5TH_ET.txt new file mode 100755 index 0000000..7fde517 --- /dev/null +++ b/doc/5TH_ET.txt @@ -0,0 +1,269 @@ +.( loading editor ) update +.( done ) +.( ETh - for text editor help ) + +var handletxt +var handlebuf +Dstralloc const editfile +var shiftx var shifty +var curlocx var curlocy +Dstr \listF\TXT_ET" tmphelpfile + +: disppage ( -- ) +handletxt @ +dynp shifty @ 50 * + +0 1 at! +1270 type ; + +: fclose ( close opened file ) +handletxt @ dup if dynde handletxt off else drop then ; + +: ETnewpage fclose 27100 dynal dup handletxt ! dynp +FF swap 27100 cfill ; + +var tmp1 +: fopen ( strhand -- ) +fclose +dup editfile Dstr2Dstr fsDloadnew dup push dynp ( addrinp R: handinp ) +27100 dynal dup handletxt ! dynp ( addrinp addrout R: handinp ) +FF over 27100 cfill +tmp1 off +i dyns do ( addrinp addrout ) +over c@ ( addrinp addrout c ) +dup FE = if + drop + 50 tmp1 @ - + tmp1 off +else + dup FD = if + drop tmp1 @ tab ( addrinp addrout numspaces ) + tmp1 @ over + tmp1 ! + 0 + else + over c! 1+ 0 + tmp1 @ 1+ tmp1 ! + then + drop +then +swap 1+ swap +loop 2drop +pop dynde ; rh tmp1 + +: dispchar ( x y -- ) +2dup +swap shiftx @ - +swap shifty @ - 1+ +at! +50 * + handletxt @ dynp + c@ emit ; + +: dispcur curlocx @ curlocy @ dispchar ; + +: displine ( line ) +0 over shifty @ - 1+ at! +50 * handletxt @ dynp + shiftx @ + 50 type ; + +: dispstatbar +colneg +0 0 at! 50 do space loop +0 0 at! ." col:" curlocx @ . +7 0 at! ." line:" curlocy @ . +11 0 at! ." ascii:" curlocy @ 50 * curlocx @ + handletxt @ dynp + c@ . +1B 0 at! ." file:" editfile Dstr. +49 0 at! ." F1-help" +colnorm ; + +: charins ( char x y ) +50 * handletxt @ dynp + ( char x addr ) +over push ++ dup dup 1+ 4F pop - cmove ( char addr ) +c! ; + +: charcut ( x y -- char ) +over push +50 * handletxt @ dynp + + +dup c@ swap ( char addr ) +dup dup 1+ swap ( char addr addr+1 addr ) +4F pop - dup push cmove ( char addr ) +pop + FF swap c! ; + +: lineins ( line ) +50 * dup push handletxt @ dynp + ( addr ) +dup dup 50 + handletxt @ dyns 50 - pop - cmove ( addr ) +FF swap 50 cfill ; + +: linecut ( line ) +50 * dup push handletxt @ dynp + ( addr ) +dup 50 + swap handletxt @ dyns 50 - pop - cmove ; + +: screenaim +0 curlocy @ 1E - 794 bound shifty ! +disppage ; + +var tmp1 +: length ( line -- length ) +50 * 4F + handletxt @ dynp + ( addr ) +51 do + i tmp1 ! + dup c@ FF - if pop drop 0 push then + 1- +loop +drop +tmp1 @ ; rh tmp1 + +var tmp2 var tmp3 +: fsavechar ( char ) tmp2 @ swap over c! 1+ tmp2 ! ; +: fsave ( -- ) +27200 dynal dup dynp tmp2 ! +0 +7CF do + i length if drop pop 1+ 0 push then +loop +0 swap for ( desthand ) + tmp3 off + i 50 * handletxt @ dynp + + 0 i length for ( desthand srcaddr ) + dup c@ + i tab 8 = if tmp3 @ if FD fsavechar tmp3 off then then + dup FF = if + drop tmp3 @ 1+ tmp3 ! + else + tmp3 @ do FF fsavechar loop tmp3 off + fsavechar + then + 1+ + loop drop + FE fsavechar +loop +tmp2 @ over dynp - over dynresize +dup editfile fsDsave +dynde ; rh tmp2 rh tmp3 + +str TXT_default" tmpdefault + +: ET +handletxt @ if +disppage +until + colneg dispcur dispstatbar KBD_FW@ colnorm dispcur + + dup 415 = if ( DEL ) + curlocx @ curlocy @ charcut drop + curlocy @ displine + then + + dup FC = if ( BACKSPACE ) + curlocx @ if + curlocx @ 1- curlocy @ charcut drop + curlocy @ displine + drop 413 + else + curlocy @ if + curlocy @ 1- dup length dup curlocx ! ( y-1 strlen ) + swap 50 * handletxt @ dynp + ( strlen y1addr ) + 2dup + swap 50 + ( strlen dest src ) + swap rot 50 swap - cmove + curlocy @ linecut + drop 410 + disppage + then + then + then + + dup FD = if ( TAB ) + curlocx @ tab + dup do FF curlocx @ curlocy @ charins loop + curlocx @ + curlocx ! + curlocy @ displine + then + + dup FE = if ( ENTER ) + curlocy @ 7CF < if + curlocy @ 1+ lineins + curlocx @ 0 + 50 curlocx @ - do + over curlocy @ charcut + over curlocy @ 1+ charins + 1+ + loop 2drop + curlocx off + drop 412 + disppage + then + then + + dup 418 = if curlocy @ 3A - curlocy ! then ( PG-UP ) + dup 419 = if curlocy @ 3A + curlocy ! then ( PG-DOWN ) + dup 416 = if curlocx off then ( HOME ) + dup 417 = if curlocy @ length curlocx ! then ( END ) + dup 401 = if tmphelpfile fsdisp disppage then ( F1 ) + dup 402 = if fsave then ( F2 ) + dup 403 = if fclose drop 1B then ( F3 ) + dup 400 = if done 0 0 at! screen cls drop -1 then ( ESC ) + + 0 over F0 bound? if -1 else 0 then ( NORMAL KEY ) + over FF = if drop -1 then + if + curlocx @ curlocy @ charins + curlocy @ displine + 411 + then + + dup 411 = if curlocx @ 1+ curlocx ! then ( RIGHT ) + dup 413 = if curlocx @ 1- curlocx ! then ( LEFT ) + dup 412 = if curlocy @ 1+ curlocy ! then ( DOWN ) + dup 410 = if curlocy @ 1- curlocy ! then ( UP ) + drop + + 0 curlocx @ 4F bound curlocx ! + 0 curlocy @ 7CF bound curlocy ! + + curlocy @ shifty @ - 3B > if screenaim then + + curlocy @ shifty @ - 3B - 0 = if + 0 0 8 screen scrollf + shifty @ 1+ shifty ! + curlocy @ displine + then + + curlocy @ shifty @ - -1 < if screenaim then + + curlocy @ shifty @ - 1+ 0 = if + 0 0 -8 screen scrollf + shifty @ 1- shifty ! + curlocy @ displine + then + +loop +else + tmpdefault editfile str2Dstr + ETnewpage + ET +then ; + +: ETl +fopen +curlocx off +curlocy off +shiftx off +shifty off +ET ; + +: ETs +editfile Dstr2Dstr +fsave ." saved " ; + +: ETh tmphelpfile fs. ; + +rh handletxt +rh handlebuf +rh editfile +rh shiftx rh shifty +rh curlocx rh curlocy +rh tmphelpfile +rh disppage +rh fclose rh fopen +rh dispchar rh dispcur +rh displine rh dispstatbar +rh charins rh charcut +rh lineins rh linecut +rh screenaim rh length +rh fsavechar rh fsave +rh ETnewpage rh tmpdefault diff --git a/doc/commands/cmp&misc.txt b/doc/commands/cmp&misc.txt new file mode 100755 index 0000000..97446fb --- /dev/null +++ b/doc/commands/cmp&misc.txt @@ -0,0 +1,166 @@ + 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 new file mode 100755 index 0000000..1828272 --- /dev/null +++ b/doc/commands/conditio.txt @@ -0,0 +1,39 @@ + 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 new file mode 100755 index 0000000..b36870f --- /dev/null +++ b/doc/commands/dsk&file.txt @@ -0,0 +1,57 @@ + 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 new file mode 100755 index 0000000..eb3ff6f --- /dev/null +++ b/doc/commands/dynmem.txt @@ -0,0 +1,43 @@ + 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 new file mode 100755 index 0000000..cb8ec9d --- /dev/null +++ b/doc/commands/graphic.txt @@ -0,0 +1,68 @@ + 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 new file mode 100755 index 0000000..5b88a3b --- /dev/null +++ b/doc/commands/index.html @@ -0,0 +1,19 @@ +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 new file mode 100755 index 0000000..9e68523 --- /dev/null +++ b/doc/commands/math&mem.txt @@ -0,0 +1,61 @@ + 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 new file mode 100755 index 0000000..c254206 --- /dev/null +++ b/doc/commands/string.txt @@ -0,0 +1,126 @@ + 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 new file mode 100755 index 0000000..d1495d4 --- /dev/null +++ b/doc/emulator.html @@ -0,0 +1,130 @@ +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 new file mode 100755 index 0000000..f035eea --- /dev/null +++ b/doc/files.txt @@ -0,0 +1,24 @@ + 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 new file mode 100755 index 0000000..89b27cd --- /dev/null +++ b/doc/index.html @@ -0,0 +1,204 @@ + + + + +FIFTH + + +

FIFTH - virtual machine, operating system, programming language

+ Download +    + Online homepage +    + Other applications hosted on svjatoslav.eu +
+Program author:
+    Svjatoslav Agejenko
+    Homepage: http://svjatoslav.eu
+    Email: svjatoslav@svjatoslav.eu
+
+This software is distributed under GNU GENERAL PUBLIC LICENSE Version 2.
+
+

Introdution

+ +Fifth is programming lanquage & operating system, running on +virtual CPU, with custom instructionset. It is mutch like +Charles Chunk Moore's Forth, it also uses stack architecture, +and many commands are similar. Basically I got famailiar with +concepts of Forth, and being inspired created my own system. +

+Note: + +Current implementation does not support object oriented programming. +While working on Fifth I got lots of cool new ideas that require reimplementation +of everything. + +Currently I try to implement those new ideas in the project called Sixth. + +
+Screenshots + +Read more about: +
Virtual CPU +
Built-in commands +
Additional commands, realized as loadable modules +
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 fifth you need minimally just 2 files. +emulator itself ( EMULATOR.EXE or EMULATOR.COM ), and +virtual disk file ( DISK.RAW ). +Read more about distribution directory layout. + + + +

Software/Hardware/Human requirements

+ + +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 utilites on QB 4.5 . + VESA support by BIOS, or external driver (UNIVBE). + +Hardware: Minimum CPU 386. + Recommended CPU Pentium 133. + 64 KB free RAM below 640KB, + 2 MB of free XMS. + VESA compatible video card. + +Human: Beginner level Forth knowledge is recommended. + Enthusiasm. + + + +

Numbers representation

+ + + +Fifth uses 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 & highlevel boot code is stored outside of the filesystem to allow +easy access to it, at early booting time, when filesystem is not yet +initialized. + + disk allocation: + +offset length description + +0 ~4 Kb Fifth core +4 Kb ~32Kb highlevel boot code +37 Kb ~65Kb FAT +101Kb ~16MB filesystem data area + + FAT entry format: + +-2 last sector +-1 empty sector +0 -- .. pointer to next block + + file entry format + +offset length description + +0 4 extension +4 16 name +20 4 entry point +24 4 size +28 4 last modification time + + + +

Core architecture

+ + +Fifth core is simply some amount of already compiled into machine code +and linked together modules (entries in other words). In compilation +process modules is compiled one by one and simply stored on top of +already existing and growing core. Separately from core is kept +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 + +offset length description + +0 4 0 < previous entry + 0 = last + -1 = empty +4 15 module name string +19 1 entry type +20 4 entry data + +Core headers as linked list of module names make up something like dictionary. +When some entry address is needed compiler can quickly run through headers +backwards and find needed entry. + + Possible module types + +type description "execute" action + +0 data compile "num" instruction + with address to module +1 submodule compile "call" instruction + with address to module +2 imm. submodule immideately call to module + + + Memory map: (average) + + +0 ~4096 core +1500000 ~32000 highlevel Fifth boot code +200000h core startup messages area +5200000 end of dynamic memory space + + + +

Fifth source format

+ + +Fifth uses a different character table and codes than ASCII. +I call it FSCII (Fifth Standard Code for Information 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: + +DEC HEX function + +0 - 15 0 - F HEX numbers +252 FC backspace +253 FD tabulator (TAB) +254 FE carriage return (CR) +255 FF space + +else ordinary characters, like in ASCII. + + + + + +
+ + \ No newline at end of file diff --git a/doc/modules/drvkbd.txt b/doc/modules/drvkbd.txt new file mode 100755 index 0000000..a8b517a --- /dev/null +++ b/doc/modules/drvkbd.txt @@ -0,0 +1,34 @@ + 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 new file mode 100755 index 0000000..80bf167 --- /dev/null +++ b/doc/modules/drvmouse.txt @@ -0,0 +1,17 @@ + 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 new file mode 100755 index 0000000..24085f7 --- /dev/null +++ b/doc/modules/gfx2.txt @@ -0,0 +1,20 @@ + 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 new file mode 100755 index 0000000..97f4011 --- /dev/null +++ b/doc/modules/index.html @@ -0,0 +1,16 @@ +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 new file mode 100755 index 0000000..7899144 --- /dev/null +++ b/doc/modules/trig.txt @@ -0,0 +1,9 @@ + 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/numbers.png b/doc/numbers.png new file mode 100755 index 0000000..9a15593 Binary files /dev/null and b/doc/numbers.png differ diff --git a/doc/shots/index.html b/doc/shots/index.html new file mode 100755 index 0000000..651e755 --- /dev/null +++ b/doc/shots/index.html @@ -0,0 +1,27 @@ +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 new file mode 100755 index 0000000..0ed0b15 Binary files /dev/null and b/doc/shots/start.png differ diff --git a/doc/shots/textEditor.png b/doc/shots/textEditor.png new file mode 100755 index 0000000..b12ee21 Binary files /dev/null and b/doc/shots/textEditor.png differ diff --git a/doc/shots/words.png b/doc/shots/words.png new file mode 100755 index 0000000..a9c67c7 Binary files /dev/null and b/doc/shots/words.png differ diff --git a/emulator/charput.inc b/emulator/charput.inc new file mode 100755 index 0000000..95b395f --- /dev/null +++ b/emulator/charput.inc @@ -0,0 +1,66 @@ +; part of virtual processor, emulator for FIFTH + +xcharput: + mov eax, [es:edi] ; chary + mov [chary], eax + mov ecx, [es:edi+4] ; charx + mov eax, [es:edi+8] ; addrdest + add eax, [xms_addr] + mov ebx, [es:eax] + mov [sizex], ebx + add eax, 8 + add eax, ecx + push eax + sub edx, edx + mov eax, [chary] + mul dword [sizex] + pop ebx + add eax, ebx + mov [addrdst], eax + mov eax, [es:edi+12] + add eax, [xms_addr] + mov [addrsrc], eax + mov al, [es:edi+16] + mov [colorbg], al + mov al, [es:edi+20] + mov [colorfg], al + add edi, 24 + + mov [linenum], 8 +charl1: + mov eax, [addrsrc] + mov bx, [es:eax] + mov edx, [addrdst] + mov cx, 8 +charl2: + dec cx + bt bx, cx + jnc charl3 + mov al, [colorfg] + jmp charl4 +charl3: + mov al, [colorbg] +charl4: + mov [es:edx], al + inc edx + cmp cx, 0 + jne charl2 + + mov eax, [sizex] + add [addrdst], eax + inc [addrsrc] + dec [linenum] + mov al, [linenum] + cmp al, 0 + jne charl1 + + jmp emu + +colorfg db 0 +colorbg db 0 +charx dd 0 +chary dd 0 +addrsrc dd 0 +addrdst dd 0 +sizex dd 0 +linenum db 0 diff --git a/emulator/compile.sh b/emulator/compile.sh new file mode 100755 index 0000000..1e132a3 --- /dev/null +++ b/emulator/compile.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +fasm emulator.asm + diff --git a/emulator/emulator.asm b/emulator/emulator.asm new file mode 100755 index 0000000..751fd61 --- /dev/null +++ b/emulator/emulator.asm @@ -0,0 +1,531 @@ +; virtual processor, emulator for FIFTH + +; registers usage: + +; edi - data stack pointer +; esi - instruction pointer +; es = 0 +; cs - emulator program code segment +; ds = cs + + +org 100h + + call system_init ; init system, allocate XMS + call KB_init ; init keyoard + + push 0 ; initialize segments + pop es + push cs + pop ds + sub ebx, ebx ; initialize pointers + mov bx, cs + shl ebx, 4 + add ebx, buf + add ebx, 20000 + mov edi, ebx ; data stack + add ebx, 10000 + mov [resp], ebx ; return stack + mov esi, [xms_addr] ; instruction pointer + + mov ah, 3dh ; open diskfile + mov al, 2 + mov dx, infile + int 21h + mov word [fileh], ax + + mov ax, 4F02h ; set VESA 640*480 8 bit + mov bx, 101h + int 10h + + mov ecx, 0 ; load boot block (first 1024 bytes) + mov ebx, [xms_addr] + call diskload + jmp emu + +xmemtot dw 0 ; amount of accessible XMS + +infile db 'disk.raw', 0 ; virtual disk file name +fileh dw 0 ; it's handle + +coresiz dw 4096 ; core size +gran dw 0 ; VESA granule size + +quit: mov ax, 3 ; restore text mode + int 10h + + mov ah, 3eh ; close diskfile + mov bx, word [fileh] + int 21h + + call KB_restore + jmp system_exit ; terminate program + +resp dd 0 ; return stack pointer + +emu: ; pick instruction +movzx bx, byte [es:esi] +inc esi +shl bx, 1 +add bx, table +jmp word [cs:bx] + +table dw emu ; 0 + dw quit + dw xkbd@ + dw xnum + dw xjmp + dw xcall ; 5 + dw xinc + dw xdec + dw xdup + dw xdrop + dw xif ; 10 + dw xret + dw xc@ + dw xc! + dw xpush + dw xpop ; 15 + dw 0 + dw xrot + dw xdisk@ + dw xdisk! + dw x@ ; 20 + dw x! + dw xover + dw xswap + dw xplus + dw xminus ; 25 + dw xmul + dw xdiv + dw xgreat + dw xless + dw xnot ; 30 + dw xi + dw xcprt@ + dw xcprt! + dw xi2 + dw xi3 ; 35 + dw xshl + dw xshr + dw lor + dw lxor + dw xvidmap ; 40 + dw xmouse@ + dw xvidput + dw xcmove + dw xcfill + dw xtvidput ; 45 + dw xdep + dw xcharput + +xkbd@: call KB_read + sub edi, 4 + mov [es:edi], dl + + mov ah, 0bh ; check for key in keyboard buffer + int 21h + cmp al, 0h + je emu + mov ah, 0 ; read key + int 16h + jmp emu + +xnum: mov edx, dword [es:esi] + sub edi, 4 + mov [es:edi], edx + add esi, 4 + jmp emu + +xjmp: mov esi, dword [es:esi] + add esi, [xms_addr] + jmp emu + +xcall: mov edx, dword [es:esi] + mov eax, [resp] + sub eax, 4 + mov ebx, esi + add ebx, 4 + sub ebx, [xms_addr] + mov [es:eax], ebx + mov [resp], eax + mov esi, edx + add esi, [xms_addr] + jmp emu + +xinc: inc dword [es:edi] + jmp emu + +xdec: dec dword [es:edi] + jmp emu + +xdup: mov eax, [es:edi] + sub edi, 4 + mov [es:edi], eax + jmp emu + +xdrop: add edi, 4 + jmp emu + +xif: mov eax, [es:edi] + add edi, 4 + cmp eax, 0 + jne l2 + mov esi, [es:esi] + add esi, [xms_addr] + jmp emu +l2: + add esi, 4 + jmp emu + +xret: mov eax, [resp] + mov esi, [es:eax] + add esi, [xms_addr] + add eax, 4 + mov [resp], eax + jmp emu + +xc@: mov eax, [es:edi] + add eax, [xms_addr] + sub ecx, ecx + mov cl, [es:eax] + mov [es:edi], ecx + jmp emu + +xc!: ;( n addr -- ) + mov ebx, [es:edi] + add edi, 4 + mov ecx, [es:edi] + add edi, 4 + add ebx, [xms_addr] + mov [es:ebx], cl + jmp emu + +xpush: mov ebx, [es:edi] + add edi, 4 + mov eax, [resp] + sub eax, 4 + mov [es:eax], ebx + mov [resp], eax + jmp emu + +xpop: mov eax, [resp] + mov ebx, [es:eax] + add eax, 4 + mov [resp], eax + sub edi, 4 + mov [es:edi], ebx + jmp emu + +xrot: mov ebx, [es:edi] + mov ecx, [es:edi+4] + mov edx, [es:edi+8] + mov [es:edi+8], ecx + mov [es:edi+4], ebx + mov [es:edi], edx + jmp emu + +xdisk@: mov ebx, [es:edi] + add ebx, [xms_addr] + mov ecx, [es:edi+4] + add edi, 8 + call diskload ; ecx-fromdisk ebx-tomem + jmp emu + +xdisk!: mov ecx, [es:edi] + call file_seek + mov ecx, 1024 + mov ebx, [es:edi+4] + add edi, 8 + add ebx, [xms_addr] + sub edx, edx + mov dx, cs + shl edx, 4 + add edx, buf + call memmove ; ebx - from, edx - to, ecx - amount + mov ah, 40h + mov bx, [fileh] + mov cx, 1024 + mov dx, buf + int 21h + jmp emu + +x@: mov eax, [es:edi] + add eax, [xms_addr] + mov eax, [es:eax] + mov [es:edi], eax + jmp emu + +x!: ;( n addr -- ) + mov eax, [es:edi] + add eax, [xms_addr] + mov ecx, [es:edi+4] + add edi, 8 + mov [es:eax], ecx + jmp emu + +xover: mov ebx, [es:edi+4] + sub edi, 4 + mov [es:edi], ebx + jmp emu + +xswap: mov ebx, [es:edi] + xchg ebx, [es:edi+4] + mov [es:edi], ebx + jmp emu + +xplus: mov ebx, [es:edi] + add edi, 4 + add [es:edi], ebx + jmp emu + +xminus: mov ebx, [es:edi] + add edi, 4 + sub [es:edi], ebx + jmp emu + +xmul: mov eax, [es:edi] + add edi, 4 + sub edx, edx + imul dword [es:edi] + mov [es:edi], eax + jmp emu + +xdiv: add edi, 4 + mov eax, [es:edi] + cdq + idiv dword [es:edi-4] + mov [es:edi], eax + jmp emu + +xgreat: mov eax, [es:edi] + add edi, 4 + mov edx, 0 + cmp [es:edi], eax + jng l3 + dec edx +l3: mov [es:edi], edx + jmp emu + +xless: mov eax, [es:edi] + add edi, 4 + mov edx, 0 + cmp [es:edi], eax + jnl l4 + dec edx +l4: mov [es:edi], edx + jmp emu + +file_seek: ; ( ecx - pointer to seek ) + mov eax, 1024 + mul ecx + mov ecx, eax + mov dx, cx + shr ecx, 16 + mov ah, 42h + mov al, 0 + mov bx, [ds:fileh] + int 21h + ret + +xnot: not dword [es:edi] + jmp emu + +xi: mov ebx, [resp] + mov eax, [es:ebx] + sub edi, 4 + mov [es:edi], eax + jmp emu + +xcprt@: mov dx, [es:edi] + in al, dx + sub ecx, ecx + mov cl, al + mov [es:edi], ecx + jmp emu + +xcprt!: mov dx, [es:edi] + mov al, [es:edi+4] + add edi, 8 + out dx, al + jmp emu + +xi2: mov ebx, [resp] + mov eax, [es:ebx+4] + sub edi, 4 + mov [es:edi], eax + jmp emu + +xi3: mov ebx, [resp] + mov eax, [es:ebx+8] + sub edi, 4 + mov [es:edi], eax + jmp emu + +xshl: mov cl, [es:edi] + add edi, 4 + shl dword [es:edi], cl + jmp emu + +xshr: mov cl, [es:edi] + add edi, 4 + shr dword [es:edi], cl + jmp emu + +lor: mov eax, [es:edi] + add edi, 4 + or [es:edi], eax + jmp emu + +lxor: mov eax, [es:edi] + add edi, 4 + xor [es:edi], eax + jmp emu + +xvidmap: + mov edx, [es:edi] + add edx, [xms_addr] + add edi, 4 + push edi + push esi + push 0a000h + pop es + mov word [ds:gra], 0 + push 0 + pop ds + mov esi, edx +mapl1: mov dx, [cs:gra] + xor bx, bx + mov ax, 4f05h + int 10h + mov edi, 0 + mov cx, 4096 +; mov cx, 16384 +mapl2: mov eax, [ds:esi] + add esi, 4 + stosd + loop mapl2 + inc word [cs:gra] +; cmp word [cs:gra], 5 + cmp word [cs:gra], 19 + jne mapl1 + push 0 + pop es + push cs + pop ds + pop esi + pop edi + jmp emu +gra dw 0 + + +xmouse@: + mov ax, 0bh ; read motion counter + int 33h + push dx + sub eax, eax + mov ax, cx + cwd + shl edx, 16 + add edx, eax + mov [es:edi-4], edx + pop ax + cwd + shl edx, 16 + add edx, eax + mov [es:edi-8], edx + mov ax, 3 ; read buttons + int 33h + sub eax, eax + mov ax, bx + sub edi, 12 + mov [es:edi], eax + jmp emu + +memmove: ; ebx - from, edx - to, ecx - amount + cmp ecx, 0 + je l11 + mov al, [es:ebx] + mov [es:edx], al + inc ebx + inc edx + dec ecx + jmp memmove +l11: ret + +memmove2: ; ebx - from, edx - to, ecx - amount + add ebx, ecx + add edx, ecx +l7: cmp ecx, 0 + je l12 + dec ebx + dec edx + mov al, [es:ebx] + mov [es:edx], al + dec ecx + jmp l7 +l12: ret + +xcmove: mov ecx, [es:edi] + add edi, 12 + mov edx, [es:edi-8] + add edx, [xms_addr] + mov ebx, [es:edi-4] + add ebx, [xms_addr] + cmp ecx, 0 + je emu + cmp ebx, edx + ja l8 + call memmove2 + jmp emu +l8: call memmove + jmp emu + +xcfill: mov ecx, [es:edi] + mov edx, [es:edi+4] + add edx, [xms_addr] + mov eax, [es:edi+8] + add edi, 12 +l9: cmp ecx, 0 + je emu + mov [es:edx], al + inc edx + dec ecx + jmp l9 + +diskload: ; ecx-fromdisk ebx-tomem + push ebx + call file_seek + mov cx, 1024 + mov ah, 3fh + mov bx, [fileh] + mov dx, buf + int 21h + + sub ebx, ebx ; move it to XMS + mov bx, cs + shl ebx, 4 + add ebx, buf + pop edx + mov ecx, 1024 + call memmove ; ebx - from, edx - to, ecx - amount + ret + +xdep: sub eax, eax + mov ax, cs + shl eax, 4 + add eax, buf + add eax, 20000 + sub eax, edi + shr eax, 2 + sub edi, 4 + mov [es:edi], eax + jmp emu + +include 'vidput.inc' +include 'tvidput.inc' +include 'charput.inc' +include 'system.inc' +include 'kbdrive.inc' + +buf: ; pointer to end of the code diff --git a/emulator/emulator.com b/emulator/emulator.com new file mode 100755 index 0000000..49be726 Binary files /dev/null and b/emulator/emulator.com differ diff --git a/emulator/kbdrive.inc b/emulator/kbdrive.inc new file mode 100755 index 0000000..235ad71 --- /dev/null +++ b/emulator/kbdrive.inc @@ -0,0 +1,57 @@ +; Keyboard driver. + +KB_init: + push es + push 0 + pop es + mov eax, [es:9*4] ; save old int vectar + mov [KB_OldVect], eax + mov ax, cs ; set new int vector + shl eax, 16 + mov ax, KB_IntHandler + mov [es:9*4], eax + pop es + ret + +KB_restore: + mov eax, [KB_OldVect] + push es + push 0 + pop es + mov [es:9*4], eax + pop es + ret + +KB_IntHandler: + pusha + in al, 60h + mov bx, [cs:KB_pntin] + mov byte [cs:bx+KB_buf], al + inc bx + cmp bx, 128 + jng KB_l1 + mov bx, 0 +KB_l1: mov [cs:KB_pntin], bx + popa + pushf ; Execute default code in old int vector + call dword [cs:KB_OldVect] + iret + +KB_read: ; returns scan code in: dl + mov dl, 0 + mov bx, [KB_pntout] + cmp bx, [KB_pntin] + je KB_l2 + mov dl, [bx+KB_buf] + inc bx + cmp bx, 128 + jng KB_l3 + mov bx, 0 +KB_l3: mov [KB_pntout], bx +KB_l2: ret + +KB_OldVect dd 0 +KB_pntin dw 0 +KB_pntout dw 0 +KB_buf db 0 +times 127 db 0 diff --git a/emulator/system.inc b/emulator/system.inc new file mode 100755 index 0000000..d8c3dc2 --- /dev/null +++ b/emulator/system.inc @@ -0,0 +1,137 @@ +; part of virtual processor, emulator for FIFTH. + +system_init: + mov ax,7202h + push ax + popf + pushf + pop bx + cmp ax,bx + je processor_ok + mov dx, badcpu + mov ah,9 + int 21h + mov ah,4Ch + int 21h + badcpu db 'required 80386 or better',24h +processor_ok: + smsw ax + test al,1 + jz mode_ok + mov dx, badmode + mov ah,9 + int 21h + mov ah,4Ch + int 21h + badmode db 'error: CPU in protected mode',24h +mode_ok: + mov ax,4300h ; check for XMS + int 2Fh + cmp al,80h ; XMS present? + je xms_ok + mov dx, badxms + mov ah,9 + int 21h + jmp system_exit + badxms db 'error: HIMEM.SYS not loaded',24h +xms_ok: + mov ax,350Dh + int 21h + mov word [irq_5],bx + mov word [irq_5+2],es + push cs + pop es + mov ax,250Dh + mov dx,int_13 + int 21h + + push es + mov ax,4310h ; get XMS driver address + int 2Fh + mov word [xms_call],bx ; store XMS driver address + mov word [xms_call+2],es + pop es + mov ah,3 ; enable A20 + call far dword [xms_call] + mov ah,8 ; get free extended memory size + xor bl,bl + call far dword [xms_call] + or bl,bl + mov dx,ax + movzx eax,ax + shl eax,10 + mov ah,9 ; allocate largest memory block + call far dword [xms_call] + mov [xms_handle],dx + mov ah,0Ch ; lock extended memory block + call far dword [xms_call] + shl edx,16 + mov dx,bx + mov [xms_addr],edx ; store memory block address + ret + + +system_exit: + cmp [xms_handle],0 + je sys_exit + mov ah, 0dh ; unlock extended memory block + mov dx, [xms_handle] + call far dword [xms_call] + mov ah, 0ah ; free extended memory block + call far dword [xms_call] +sys_exit: + mov ax, 250dh + mov dx, word [irq_5] + mov ds, word [irq_5+2] + int 21h + pop ax + mov ah, 4ch + int 21h + +int_13: push eax + mov al, 00001011b ; OCW3 - read IRQ in-service register + out 20h, al + in al, 20h + test al, 00100000b ; is IRQ 5 in service? + jz exception + pop eax + jmp dword 0:0 + label irq_5 dword at $-4 +exception: + push ds es fs gs + cli ; disable interrupts + xor eax, eax ; calculate linear address of GDT + mov ax, cs + shl eax, 4 + add eax, GDT + mov dword [cs:GDTR+2],eax + lgdt pword [cs:GDTR] ; load GDT register + mov eax, cr0 ; switch to protected mode + or al, 1 + mov cr0, eax + jmp pm_start + pm_start: + mov ax, 1 shl 3 ; load 32-bit data descriptor + mov ds, ax ; to all data segment registers + mov es, ax + mov fs, ax + mov gs, ax + mov eax, cr0 ; switch back to real mode + and al, not 1 + mov cr0, eax + jmp pm_end + pm_end: + sti ; enable interrupts + pop gs fs es ds + pop eax + iret + +GDTR dw 2*8-1 ; limit of GDT + dd ? ; linear address of GDT + +GDT rw 4 ; null descriptor + dw 0FFFFh, 0, 9200h, 8Fh ; 32-bit data descriptor + +xms_call dd 0 ; XMS driver pointer +xms_handle dw 0 ; handle of XMS memory block +xms_addr dd 0 ; address to XMS block diff --git a/emulator/tvidput.inc b/emulator/tvidput.inc new file mode 100755 index 0000000..3c52a25 --- /dev/null +++ b/emulator/tvidput.inc @@ -0,0 +1,140 @@ +; part of virtual processor, emulator for FIFTH + + +xtvidput: +mov ebx, edi ; read data from stack, and save it to variables +mov eax, [es:ebx] +mov [cory], eax +add ebx, 4 +mov eax, [es:ebx] +mov [corx], eax + +add ebx, 4 +mov eax, [es:ebx] +add eax, [xms_addr] +mov ecx, [es:eax] +mov [img2x], ecx +add eax, 4 +mov ecx, [es:eax] +mov [img2y], ecx +add eax, 4 +mov [img2a], eax + +add ebx, 4 +mov eax, [es:ebx] +add eax, [xms_addr] +mov ecx, [es:eax] +mov [img1x], ecx +add eax, 4 +mov ecx, [es:eax] +mov [img1y], ecx +add eax, 4 +mov [img1a], eax + +add ebx, 4 +mov edi, ebx + +cmp dword [cory] , 0 ; calculate Y start +jl tvidl1 +mov dword [starty], 0 +jmp tvidl2 +tvidl1: +mov eax, [cory] +neg eax +mov [starty], eax +tvidl2: + +cmp dword [corx] , 0 ; calculate X start +jl tvidl3 +mov dword [startx], 0 +jmp tvidl4 +tvidl3: +mov eax, [corx] +neg eax +mov [startx], eax +tvidl4: + +mov eax, [cory] ; calculate Y end +add eax, [img1y] +cmp eax, [img2y] +jg tvidl5 +mov eax, [img1y] +mov [endy], eax +jmp tvidl6 +tvidl5: +mov eax, [img2y] +sub eax, [cory] +mov [endy], eax +tvidl6: + +mov eax, [corx] ; calculate X end +add eax, [img1x] +cmp eax, [img2x] +jg tvidl7 +mov eax, [img1x] +mov [endx], eax +jmp tvidl8 +tvidl7: +mov eax, [img2x] +sub eax, [corx] +mov [endx], eax +tvidl8: + +mov eax, [endy] ; calculate Y length +sub eax, [starty] +cmp eax, 0 +jle emu +mov [lengthy], eax + +mov eax, [endx] ; calculate X length +sub eax, [startx] +cmp eax, 0 +jle emu +mov [lengthx], eax + +mov eax, [starty] ; calculate img1 start address +mov ebx, [img1x] +sub edx, edx +mul ebx +add eax, [img1a] +add eax, [startx] +mov [img1start], eax + +mov eax, [cory] ; calculate img2 start address +add eax, [starty] +mov ebx, [img2x] +sub edx, edx +mul ebx +add eax, [img2a] +add eax, [corx] +add eax, [startx] +mov [img2start], eax + +tvidl9: +mov ebx, [img1start] +mov ecx, [lengthx] +mov edx, [img2start] + +tmemmove: ; ebx - from, edx - to, ecx - amount +cmp ecx, 0 +je tl11 +mov al, [es:ebx] +cmp al, 255 +je tl12 +mov [es:edx], al +tl12: +inc ebx +inc edx +dec ecx +jmp tmemmove +tl11: + +mov eax, [img1x] +add [img1start], eax +mov eax, [img2x] +add [img2start], eax +dec dword [lengthy] +cmp [lengthy], 0 +jg tvidl9 + +jmp emu diff --git a/emulator/vidput.inc b/emulator/vidput.inc new file mode 100755 index 0000000..7e7e793 --- /dev/null +++ b/emulator/vidput.inc @@ -0,0 +1,146 @@ +; part of virtual processor, emulator for FIFTH + + +xvidput: +mov ebx, edi ; read data from stack, and save it to variables +mov eax, [es:ebx] +mov [cory], eax +add ebx, 4 +mov eax, [es:ebx] +mov [corx], eax + +add ebx, 4 +mov eax, [es:ebx] +add eax, [xms_addr] +mov ecx, [es:eax] +mov [img2x], ecx +add eax, 4 +mov ecx, [es:eax] +mov [img2y], ecx +add eax, 4 +mov [img2a], eax + +add ebx, 4 +mov eax, [es:ebx] +add eax, [xms_addr] +mov ecx, [es:eax] +mov [img1x], ecx +add eax, 4 +mov ecx, [es:eax] +mov [img1y], ecx +add eax, 4 +mov [img1a], eax + +add ebx, 4 +mov edi, ebx + +cmp dword [cory] , 0 ; calculate Y start +jl vidl1 +mov dword [starty], 0 +jmp vidl2 +vidl1: +mov eax, [cory] +neg eax +mov [starty], eax +vidl2: + +cmp dword [corx] , 0 ; calculate X start +jl vidl3 +mov dword [startx], 0 +jmp vidl4 +vidl3: +mov eax, [corx] +neg eax +mov [startx], eax +vidl4: + +mov eax, [cory] ; calculate Y end +add eax, [img1y] +cmp eax, [img2y] +jg vidl5 +mov eax, [img1y] +mov [endy], eax +jmp vidl6 +vidl5: +mov eax, [img2y] +sub eax, [cory] +mov [endy], eax +vidl6: + +mov eax, [corx] ; calculate X end +add eax, [img1x] +cmp eax, [img2x] +jg vidl7 +mov eax, [img1x] +mov [endx], eax +jmp vidl8 +vidl7: +mov eax, [img2x] +sub eax, [corx] +mov [endx], eax +vidl8: + +mov eax, [endy] ; calculate Y length +sub eax, [starty] +cmp eax, 0 +jle emu +mov [lengthy], eax + +mov eax, [endx] ; calculate X length +sub eax, [startx] +cmp eax, 0 +jle emu +mov [lengthx], eax + +mov eax, [starty] ; calculate img1 start address +mov ebx, [img1x] +sub edx, edx +mul ebx +add eax, [img1a] +add eax, [startx] +mov [img1start], eax + +mov eax, [cory] ; calculate img2 start address +add eax, [starty] +mov ebx, [img2x] +sub edx, edx +mul ebx +add eax, [img2a] +add eax, [corx] +add eax, [startx] +mov [img2start], eax + +vidl9: +mov ebx, [img1start] +mov ecx, [lengthx] +mov edx, [img2start] +call memmove + +mov eax, [img1x] +add [img1start], eax +mov eax, [img2x] +add [img2start], eax +dec dword [lengthy] +cmp [lengthy], 0 +jg vidl9 + +jmp emu + +cory dd 0 +corx dd 0 +img2x dd 0 +img2y dd 0 +img2a dd 0 +img1x dd 0 +img1y dd 0 +img1a dd 0 + +starty dd 0 +startx dd 0 +endy dd 0 +endx dd 0 +lengthx dd 0 +lengthy dd 0 + +img1start dd 0 +img2start dd 0 diff --git a/floppy image/image mount.sh b/floppy image/image mount.sh new file mode 100755 index 0000000..c4e528b --- /dev/null +++ b/floppy image/image mount.sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +sudo mount -o loop image.img files/ diff --git a/floppy image/image umount.sh b/floppy image/image umount.sh new file mode 100755 index 0000000..fcae190 --- /dev/null +++ b/floppy image/image umount.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo umount files diff --git a/floppy image/run under qemu.sh b/floppy image/run under qemu.sh new file mode 100755 index 0000000..5b0fa5c --- /dev/null +++ b/floppy image/run under qemu.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + +qemu -fda image.img -boot a + diff --git a/imageFile/f/5TH_AUTORUN b/imageFile/f/5TH_AUTORUN new file mode 100755 index 0000000..0b50d3c --- /dev/null +++ b/imageFile/f/5TH_AUTORUN @@ -0,0 +1,32 @@ +D> \listF\listLIB\5TH_GFX include +D> \listF\5TH_LOGO include + +: tmpmsg 200000 100 do + dup c@ dup FC = if drop doexit else emit 1+ then +loop drop ; +.( Messages from core: ) +colhigh +tmpmsg +colnorm +forget tmpmsg + + +D> \listF\listLIB\5TH_DRVKBD include +D> \listF\listLIB\5TH_UICMD include +D> \listF\5TH_QUICKPATH include + +Dstr \listF\5TH_ET" tmpstr +: lde tmpstr include ; rh tmpstr + +Dstr \listF\TXT_HELP" tmpstr +: help tmpstr fs. ; rh tmpstr + +Dstr \listF\5TH_BOOT" tmpstr +: putboot +tmpstr fsDloadnew +dup dynp [ 400 4 * ] [ 400 20 * ] disksave +dynde ; rh tmpstr + +fslsr + +.( type 'help' to get help ) diff --git a/imageFile/f/5TH_QUICKPATH b/imageFile/f/5TH_QUICKPATH new file mode 100755 index 0000000..137bd3c --- /dev/null +++ b/imageFile/f/5TH_QUICKPATH @@ -0,0 +1,6 @@ +str \listF\" ~f +str \listGAMES\listSauron_Return\" ~game +str \listF\listLIB\" ~lib +str \" ~r + +: go fspath str2Dstr fsls ; diff --git a/imageFile/f/5th_boot b/imageFile/f/5th_boot new file mode 100755 index 0000000..8691ea6 --- /dev/null +++ b/imageFile/f/5th_boot @@ -0,0 +1,788 @@ +FE 3 + +: im 2 lp @ 13 + c! ret I +: ; B c, 1 mode c! ret I im +: gw FF scan ; +: lit mode c@ if ret else 3 c, , ret then ; +: ' gw find 14 + @ lit ; im +: abc FF scan here 2 ne 3 c, , 4 c, ' bcode , ; + + 2 abc kbd@ +10 abc kb@ 11 abc rot 1B abc / 1E abc not +1F abc i 20 abc cprt@ 21 abc cprt! 22 abc i2 +23 abc i3 24 abc shl 25 abc shr 26 abc or +27 abc xor 28 abc vidmap 29 abc mouse@ 2A abc vidput +2C abc cfill 2D abc tvidput 2E abc depth 13 abc disk! +2F abc charput + +: create gw here 0 ne ; +: vari create , ; +: var 0 vari ; +: const gw 0 ne ; +: asc skey lit ; im +: ( asc ) scan ; im +: cr FE emit ; +: .( asc ) scan pad write cr ; .( it is a test ) +: forget gw find dup 14 + @ h ! @ lp ! ; +: on -1 swap ! ; +: off 0 swap ! ; +: 2dup over over ; +: 2drop drop drop ; +: space FF emit ; +: nip swap drop ; +: >= 1- > ; +: <= 1+ < ; +: = - if 0 else -1 then ; +: neg 0 swap - ; +: forexit pop pop pop drop dup 1+ push push push ; +: done pop pop 1- push push ; +: doexit pop pop drop 0 push push ; +: bit@ shr -2 or -2 xor ; +: to32bit 100 * + 100 * + 100 * + ; +: mod 2dup / * - ; +: rh gw -1 find dup @ prev @ ! ! ; +: alloc do 0 c, loop ; +var tmp +: [ depth tmp ! 1 mode ! ; im +: ] 0 mode ! depth tmp @ - do lit loop ; rh tmp +: " asc " scan pad dup c@ c, incmod ; +: i" asc " scan pad incmod ; +: str here " const ; +: writestr i write i c@ pop + 1+ push ; +: ." 5 c, ' writestr , " ; im rh writestr +: vector ." no vector ! " ; +: defer gw here 1 ne 4 c, ' vector , ; +: is 1+ ! ; rh vector +: bound 2dup > if nip nip + else drop 2dup > if drop else + nip then then ; +: bound? over < if 2drop 0 else + > if 0 else -1 then then ; +: \ until fkey FE = if done then loop ; im +: tab. FD emit ; +: abs dup 0 < if neg then ; + +7FFFFFFF const max +80000000 const min +1 const version + +var to8bitt +: to8bit to8bitt ! to8bitt dup c@ swap 1+ dup c@ + swap 1+ dup c@ swap 1+ c@ ; rh to8bitt + +var tmp1 +: d. dup 0 < if 0 swap - 2D + emit then tmp1 off 3B9ACA00 + A do 2dup / dup dup tmp1 @ + + if 30 + emit 1 tmp1 ! + else drop then + over * swap push - pop A / + loop 2drop tmp1 @ if + else 30 emit then ; rh tmp1 + +var tmp1 +: . dup 0 < if 0 swap - 2D emit then +tmp1 off 10000000 +8 do + 2dup / dup dup tmp1 @ + + if + emit 1 tmp1 ! + else + drop + then + over * swap push - pop 10 / +loop 2drop +tmp1 @ if else 0 emit then ; +rh tmp1 + +: ? @ . ; +: depth. depth . ; + +: score 800 do i 400 * i 14 + disk! loop ; +: dump 10 do 4 do dup c@ . space 1+ loop cr loop drop ; + +var tmp1 var tmp2 +: rnd ( range -- result ) +tmp1 @ 17 * B + dup tmp1 ! +tmp2 @ over + 11 * 4 + dup tmp2 ! ++ swap mod ; rh tmp1 rh tmp2 + +100 const dynent \ dynamic memory support +create dyntab dynent 8 * alloc +create dynmem h @ 500000 + h ! +dynmem vari dynpn + +: dyntaba 8 * dyntab + ; +: dynde dyntaba off ; +: dynp dyntaba @ ; +: dynp! dyntaba ! ; +: dyns dyntaba 4 + @ ; +: dyns! dyntaba 4 + ! ; + +var dync +: dynal ( size -- handle ) +until + dync @ dup dynp 0 = if dup done then \ size dync + 1+ dup dynent = if drop 0 then + dync ! +loop \ size handle +dynpn @ over dynp! +2dup dyns! +swap dynpn @ + dynpn ! ; rh dync + +: dynresize ( nsize handle -- ) +dup push dyns \ Nsize Osiz R: handle +over < if \ Nsize R: handle + i dynp dup push over + push \ Nsize R: handle Oloc Nendloc + dyntab dynent + do + dup @ dup i3 > + if + i2 < if + pop drop i3 dynp dynpn @ dup i3 + dynp! i3 dyns cmove 0 push + then + else + drop + then + 8 + + loop + drop pop pop 2drop +then \ Nsize R: handle +i dynp over + \ Nsize Nend R: handle +dup dynpn @ > if + dynpn ! +else + drop +then \ Nsize R: handle +pop dyns! ; + +: dync@ ( addr dynhandle ) dynp + c@ ; +: dync! ( num addr dynhandle ) dynp + c! ; +: dyn@ dynp swap 4 * + @ ; +: dyn! dynp swap 4 * + ! ; +: dyncon dynal const ; + +: statdyn +cr ." " tab. ." " tab. ." " +0 dyntab dynent +do dup @ if cr swap dup . swap tab. dup @ . tab. dup 4 + @ . then 8 + +swap 1+ swap loop +2drop ; + +: dyn. ( dynhandle -- ) + dup dynp swap dyns do + dup c@ emit 1+ + loop drop ; + +rh dynent rh dyntab rh dynmem +rh dyntaba rh dynpn + +: Dstralloc ( -- strh ) \ string support +1 dynal dup dynp 0 swap c! ; + +: Dstral Dstralloc ; \ compatibility patch! + +: Dstrsure ( size strh -- ) +swap push +dup dyns 1- \ strh len +i < if + pop 20 + swap dynresize +else + pop 2drop +then ; + +: Dstrlen ( strh -- length ) +dynp c@ ; + +: c+Dstr ( chr strh -- ) +dup Dstrlen 1+ over Dstrsure +dynp dup c@ 1+ \ chr addr len +2dup swap c! ++ c! ; + +: c+lDstr ( chr strh -- ) +dup Dstrlen 1+ over Dstrsure +dynp dup c@ \ addr len +over 1+ dup 1+ rot cmove +dup dup c@ 1+ swap c! +1+ c! ; + +: Dstr. ( strh -- ) dynp write ; + +: Dstr2str ( strh mem -- ) +push dynp dup c@ 1+ \ Saddr len +pop swap cmove ; + +: str2Dstr ( mem strh -- ) +over c@ 1+ dup push over Dstrsure \ mem strh +pop do + over i + c@ + over dynp i + c! +loop 2drop ; + +: Dstr+str ( hand addr -- ) +dup c@ over + 1+ rot \ addr destaddr hand +dynp count push \ addr destaddr src R: len +swap i cmove \ addr R: len +dup c@ pop + swap c! ; + +Dstralloc const defDstr +Dstralloc const defDstr2 +: D" asc " scan pad defDstr str2Dstr defDstr ; +: D> FF scan pad defDstr str2Dstr defDstr ; +: D>2 FF scan pad defDstr2 str2Dstr defDstr2 ; + +: Dstr+Dstr ( hand1 hand2 -- ) +push push \ R: hand2 hand1 +i2 Dstrlen i Dstrlen \ len2 len1 R: hand2 hand1 +2dup + dup i2 dynp c! i2 Dstrsure +pop dynp 1+ rot pop dynp 1+ + rot cmove ; + +: Dstrclear ( handle -- ) +0 over Dstrsure +dynp 0 swap c! ; + +: Dstr2Dstr ( srchand desthand -- ) +dup Dstrclear Dstr+Dstr ; + +: Dstr asc " scan Dstralloc pad over str2Dstr const ; + +var tmploc +: Dstrlscan ( char strh -- loc ) +tmploc off +dynp 0 over c@ for \ char addr + 1+ + 2dup c@ = if i 1+ tmploc ! forexit then +loop +2drop +tmploc @ ; + +: Dstrrscan ( char strh -- loc ) +tmploc off dynp \ char addr len +dup c@ do + 2dup 1+ i + c@ = if + i 1+ tmploc ! + doexit + then +loop 2drop +tmploc @ ; rh tmploc + +: Dstrlscane ( char strh -- loc ) +dup Dstrlen push Dstrlscan +dup if pop drop else drop pop 1+ then ; + +: Dstrleft ( amo strh -- ) +dup Dstrlen rot \ strh strlen amo +0 swap rot bound \ strh ramo +swap 2dup Dstrsure +dynp c! ; + +: Dstrright ( amo strh -- ) \ unoptimized! +dup Dstrlen rot \ strh strlen amo +0 swap rot bound \ strh ramo +swap 2dup Dstrsure +push push \ R: strh ramo +i2 dynp dup c@ \ loc len R: -,,- +2dup i 1- - + \ loc len srcA R: -,,- +rot 1+ rot drop i \ srcA dstA amo R: -,,- +cmove pop pop \ ramo strh +dynp c! ; + +: Dstrcutl ( amo strh -- ) +dup Dstrlen rot - +dup 1 < if + drop Dstrclear +else + swap Dstrright +then ; + +var tmpdest var tmpsrc var tmpamo +: Dstrsp ( char strhsrc strhdest -- ) +tmpdest ! dup tmpsrc ! \ char srchand +Dstrlscane tmpamo ! +tmpsrc @ tmpdest @ Dstr2Dstr +tmpamo @ dup tmpsrc @ Dstrcutl +1- tmpdest @ Dstrleft ; +rh tmpdest rh tmpsrc rh tmpamo + +: Dv ( addr -- ) Dstral swap ! ; +: Df ( addr -- ) @ dynde ; + +24 400 * const fsroot \ filesystem support +25 const fsfatbeg +4000 const fsfatsiz +fsfatsiz 4 * 400 / 1+ fsfatbeg + const fsdata +asc f asc r asc e asc e to32bit const fsextfree +asc l asc i asc s asc t to32bit const fsextlist + +Dstr \" fspath + +create dib 400 alloc +-1 vari dibblock +: dibload dup dibblock @ = if drop + else dup dibblock ! dib disk@ then ; +: dibsave dup dibblock ! dib swap disk! ; + +var tmpfrom var tmpto var tmpamo var tmpramo +: diskload ( fromdisk tomem amount -- ) + tmpamo ! tmpto ! tmpfrom ! + until + tmpamo @ if + tmpfrom @ 400 / dibload + 0 400 tmpfrom @ 400 mod dup push - tmpamo @ bound tmpramo ! + dib pop + tmpto @ tmpramo @ 2dup + tmpto ! cmove + tmpamo @ tmpramo @ - tmpamo ! + tmpfrom @ tmpramo @ + tmpfrom ! + else + done + then + loop ; + +: disksave \ frommem todisk amount -- + tmpamo ! tmpto ! tmpfrom ! + until + tmpamo @ if + tmpto @ 400 / dibload + 0 400 tmpto @ 400 mod dup push - tmpamo @ bound tmpramo ! + tmpfrom @ dib pop + tmpramo @ cmove dibblock @ dibsave + tmpamo @ tmpramo @ - tmpamo ! + tmpfrom @ tmpramo @ + tmpfrom ! + tmpto @ tmpramo @ + tmpto ! + else + done + then + loop ; rh tmpamo rh tmpto rh tmpfrom rh tmpramo + +: fat@ 4 * dup push 400 / fsfatbeg + dibload pop 400 mod dib + @ ; +: fat! 4 * dup push 400 / fsfatbeg + dibload pop 400 mod dib + ! + dibblock @ dibsave ; + +var tmp1 +: fatfindf + until + tmp1 @ fat@ -1 = if tmp1 @ done then + tmp1 @ 1+ dup tmp1 ! + fsfatsiz = if tmp1 off then + loop ; rh tmp1 + +create formattmp i" listRootDireCtorYent" 0 , 0 , 0 , +: format ." formatting ... " fsfatsiz do + -1 i fat! + loop + -2 0 fat! + formattmp fsroot 20 disksave + ." done" cr ; rh formattmp + +20 const maxfiles +create fshandles 11 maxfiles * alloc + +\ 0 4 - FileDescription +\ 4 4 - FileSize +\ 8 4 - CurrentLocation +\ 12 4 - CurrentSector +\ 16 1 - updated + +: fsDfiledesc@ 11 * fshandles + @ ; +: fsDfiledesc! 11 * fshandles + ! ; +: fsDfilesize@ 11 * fshandles + 4 + @ ; +: fsDfilesize! 11 * fshandles + 4 + ! ; +: fsDcurloc@ 11 * fshandles + 8 + @ ; +: fsDcurloc! 11 * fshandles + 8 + ! ; +: fsDcursect@ 11 * fshandles + C + @ ; +: fsDcursect! 11 * fshandles + C + ! ; +: fsDupdated@ 11 * fshandles + 10 + c@ ; +: fsDupdated! 11 * fshandles + 10 + c! ; + +: inithandles maxfiles do + -1 i fsDfiledesc! +loop ; inithandles +forget inithandles + +: statfile +cr ." handle" tab. ." pnt" tab. ." size" tab. ." CurLoc" +tab. ." CurSect" tab. ." updated?" cr +0 maxfiles for + -1 i fsDfiledesc@ - if + i . tab. + i fsDfiledesc@ . tab. + i fsDfilesize@ . tab. + i fsDcurloc@ . tab. + i fsDcursect@ . tab. + i fsDupdated@ . cr + then +loop ; + +: fsfreenext ( firstSector -- ) + until + dup -2 = if + done + else + dup fat@ swap -1 swap fat! + then + loop drop ; + +create fsfiledesc 20 alloc +: fsopen ( FileDescPnt -- handle ) + maxfiles do + i fsDfiledesc@ -1 = if i doexit then + loop + swap dup fsfiledesc 20 diskload \ handle desc + over fsDfiledesc! \ handle + [ fsfiledesc 14 + ] @ over fsDcursect! + 0 over fsDcurloc! + 0 over fsDupdated! + [ fsfiledesc 18 + ] @ over fsDfilesize! ; + +: fspntdel ( FileDescPnt -- ) +dup fsfiledesc 20 diskload \ pnt +[ fsfiledesc 14 + ] @ fsfreenext +fsextfree fsfiledesc ! +fsfiledesc swap 20 disksave ; + +: fsclose ( handle -- ) + dup fsDupdated@ if + push + i fsDfiledesc@ fsfiledesc 20 diskload + i fsDfilesize@ [ 18 fsfiledesc + ] ! + fsfiledesc i fsDfiledesc@ 20 disksave + pop + then + -1 swap fsDfiledesc! ; rh fsfiledesc + +var tmpamo var tmpfrom var tmphand var tmploc var tmpramo var tmpsect +var tmpmax +: fssave \ fromMem toFhandle amount -- + tmpamo ! + dup fsDcurloc@ tmploc ! + dup fsDcursect@ tmpsect ! + tmphand ! tmpfrom ! + until + tmpamo @ if + 0 400 tmploc @ 400 mod dup push - dup tmpmax ! tmpamo @ + bound tmpramo ! + tmpfrom @ tmpsect @ fsdata + 400 * pop + tmpramo @ disksave + tmpramo @ tmpmax @ = if + tmpsect @ fat@ + dup -2 = if + drop + fatfindf + dup tmpsect @ fat! + -2 over fat! + then + tmpsect ! + then + tmpramo @ + tmpamo @ over - tmpamo ! + tmploc @ over + tmploc ! + tmpfrom @ + tmpfrom ! + else + done + then + loop + tmphand @ push + tmploc @ i fsDcurloc! + tmpsect @ i fsDcursect! + -1 i fsDupdated! + tmploc @ i fsDfilesize@ max bound pop fsDfilesize! ; + +var tmpto +: fsload \ fromFhandle toMem amount -- + tmpamo ! tmpto ! + dup fsDcurloc@ tmploc ! + dup fsDcursect@ tmpsect ! + tmphand ! + until + tmpamo @ if + 0 400 tmploc @ 400 mod dup push - dup tmpmax ! tmpamo @ + bound tmpramo ! + tmpsect @ fsdata + 400 * pop + tmpto @ tmpramo @ diskload + tmpsect @ fat@ + dup -2 = if + drop + else + tmpramo @ tmpmax @ = if tmpsect ! else drop then + then + tmpramo @ + tmpamo @ over - tmpamo ! + tmploc @ over + tmploc ! + tmpto @ + tmpto ! + 0 tmploc @ tmphand @ fsDfilesize@ bound tmploc ! + else + done + then + loop + tmphand @ + tmploc @ over fsDcurloc! + tmpsect @ swap fsDcursect! ; + +rh tmpamo rh tmpfrom rh tmphand rh tmploc rh tmpramo rh tmpsect rh tmpto +rh tmpmax + +: fsabsloc ( handle -- loc ) +dup fsDcursect@ fsdata + 400 * +swap fsDcurloc@ 400 mod + ; + +var tmppnt var tmphand var curhand var tmpsect +create tmpFdesc 21 alloc +: fspntcreate ( dynHand descPnt -- newFileDescPnt ) +tmppnt ! tmphand ! +tmppnt @ fsopen curhand ! +until + curhand @ fsDfilesize@ curhand @ fsDcurloc@ 20 + >= if + curhand @ fsDcursect@ tmpsect ! + curhand @ tmpFdesc 20 fsload + tmpFdesc @ fsextfree = if + curhand @ fsDcurloc@ 20 - curhand @ fsDcurloc! + tmpsect @ curhand @ fsDcursect! + done + then + else + done + then +loop +FF tmpFdesc 20 cfill +0 [ tmpFdesc 18 + ] ! +fatfindf -2 over fat! [ tmpFdesc 14 + ] ! +0 tmphand @ dync@ do + i 1+ tmphand @ dync@ + dup asc \ = if drop FF then + tmpFdesc i + c! +loop +curhand @ fsabsloc + tmpFdesc curhand @ 20 fssave + curhand @ fsclose ; +rh tmppnt rh tmphand rh curhand rh tmpsect + +: fseof ( handle -- bytesLeft ) +dup fsDfilesize@ swap fsDcurloc@ - ; + +create tmppath FF alloc +var tmppnt var tmphand var tmploc +: fsgetdesc ( dynhand -- DescPnt) +tmppath off +0 over dync@ if + 1 over dync@ asc \ = if dup tmppath Dstr2str then +then +tmppath c@ 0 = if + fspath tmppath Dstr2str + dup tmppath Dstr+str +then +drop +fsroot tmppnt ! +until + tmppath c@ if + tmppath c@ push + 1 i 2 + for + i 1- tmppath c! + tmppath i + c@ asc \ = if forexit then + loop + \ tmppath write cr + tmppath c@ if + tmppnt @ fsopen tmphand ! + until + tmphand @ fseof 20 >= if + tmphand @ fsabsloc tmploc ! + tmphand @ [ tmpFdesc 1+ ] 20 fsload + 15 do + i tmpFdesc c! + tmpFdesc i + c@ FF - + if doexit then + loop + tmpFdesc tmppath str=str? if + tmploc @ tmppnt ! + done + then + else + -1 tmppnt ! + done + then + loop + tmphand @ fsclose + else + fsroot tmppnt ! + then + tmppath c@ dup push [ tmppath 1+ ] + tmppath i2 cmove + pop pop swap - 1- + dup -1 = if drop 0 then tmppath c! + else + done + then + tmppnt @ -1 = if done then +loop +tmppnt @ ; rh tmppath rh tmppnt rh tmphand rh tmploc + +1 vari tmpdepth var tmploc +: fspntls ( recursive? descpnt -- ) +fsopen +until \ handle + dup fseof 20 >= if + dup fsabsloc tmploc ! + dup tmpFdesc 20 fsload + tmpFdesc @ fsextfree - if + [ tmpFdesc 18 + ] @ . + tmpdepth @ do tab. loop + tmpFdesc 14 type cr + then + over if + tmpFdesc @ fsextlist = if + tmpdepth @ 1+ tmpdepth ! + -1 tmploc @ fspntls + tmpdepth @ 1- tmpdepth ! + then + then + else + done + then +loop +fsclose drop ; rh tmpFdesc rh tmpdepth rh tmploc + +: tmpls ." PATH: " fspath dup Dstr. cr fsgetdesc fspntls ; +: fslsr -1 tmpls ; +: fsls 0 tmpls ; +rh tmpls + +: fscl ( dynhand -- ) +push +i Dstrlen if + 1 i dync@ asc \ = if + i fspath Dstr2Dstr + else + i fspath Dstr+Dstr + then +then pop drop ; + +var tmpstr1 var tmpstr2 var tmpstrpath var tmppnt +: fscreate ( dynhand -- descpnt ) +tmpstr1 Dv tmpstr2 Dv tmpstrpath Dv +fspath tmpstrpath @ Dstr2Dstr +tmpstr1 @ Dstr2Dstr +until + tmpstr1 @ Dstrlen if + asc \ tmpstr1 @ tmpstr2 @ Dstrsp + asc \ tmpstr2 @ c+Dstr +\ tmpstr2 @ Dstr. cr + tmpstr2 @ fsgetdesc + dup -1 = if + drop + tmpstr2 @ fspath fsgetdesc fspntcreate + then + tmppnt ! + tmpstr2 @ fscl + else + done + then +loop +tmppnt @ +tmpstrpath @ fspath Dstr2Dstr +tmpstr1 Df tmpstr2 Df tmpstrpath Df ; +rh tmpstr1 rh tmpstr2 rh tmpstrpath rh tmppnt + +: fstrunc ( Fhandle -- ) +-1 over fsDupdated! +dup fsDcurloc@ over fsDfilesize! +fsDcursect@ \ sect +dup fat@ dup 0 >= if + fsfreenext +else + drop +then +-2 swap fat! ; + +: fsDsave ( Dynhand Dstr -- ) +fscreate fsopen \ datahand filehand +dup fstrunc +dup rot \ filehand filehand datahand +dup dynp rot \ filehand datahand from filehand +rot dyns fssave \ fh +fsclose ; + +: fsDload ( Dstr Dynhand -- ) +push fsgetdesc fsopen \ Fhand R: Dhand +dup fsDfilesize@ dup i dynresize \ Fhand Fsize R: Dhand +over pop dynp rot fsload \ Fhand +fsclose ; + +: fsDloadnew ( Dstr -- Dynhand ) +1 dynal swap over fsDload ; + +1E8480 const tmpfrom +var tmplen var tmpdyn var tmpstr +: fsimport +tmpfrom tmplen 4 diskload +tmplen @ if + ." file length: " tmplen @ dup . + dynal tmpdyn ! + tmpstr Dv + F0 tmpstr @ Dstrsure + [ tmpfrom 4 + ] tmpstr @ dynp F0 over c! 1+ F0 diskload + FE tmpstr @ Dstrlscan 1- tmpstr @ Dstrleft + ." file: " tmpstr @ Dstr. + ." importing ..." + [ tmpfrom 64 + ] tmpdyn @ dynp tmplen @ diskload + tmpdyn @ tmpstr @ fsDsave + ." done" cr + tmpdyn Df tmpstr Df + tmplen off + tmplen tmpfrom 4 disksave +then ; +rh tmplen rh tmpfrom rh tmpdyn rh tmpstr + +: fsdel ( Dstr -- ) fsgetdesc dup -1 - if fspntdel else drop then ; + +: fscopy ( Dstr1 Dstr2 -- ) swap fsDloadnew dup rot fsDsave dynde ; + +: fsmove ( Dstr1 Dstr2 -- ) over swap fscopy fsdel ; + +: fsgettop ( Dstr1 Dstr2 -- ) +2dup Dstr2Dstr nip \ Dstr2 +asc \ over Dstrrscan \ Dstr2 CharLoc +swap Dstrcutl ; + +create incfiles 80 alloc \ File inclusion support +-1 vari inccur + +: dyninc ( dynhandle -- ) +inccur @ 1+ dup inccur ! \ hand cur +8 * incfiles + dup 4 + 0 swap ! ! ; + +: include ( StrHand -- ) +fsDloadnew dyninc ; + +defer cmdline + +: (fkey +inccur @ 8 * incfiles + dup @ ( adr handle ) +dup dyns rot ( handle size adr ) +4 + @ > if ( handle ) + inccur @ 8 * incfiles + 4 + dup @ ( handle adr+4 pointer ) + dup 1+ rot ! ( handle pointer ) + swap dynp + c@ +else + dynde + inccur @ 1 - dup inccur ! + 0 < if cmdline then FF +then ; + +var tmpstr +: modulechk ( Dstr -- ) +tmpstr Dv +dup tmpstr @ fsgettop +asc # tmpstr @ c+lDstr +tmpstr @ pad Dstr2str \ Dstr +find if + drop +else + tmpstr @ pad Dstr2str + here 0 ne + include +then +tmpstr Df ; rh tmpstr + +.( test test test ... ) + +\ format +\ fsimport cr + +D" listF\5TH_AUTORUN" include +' (fkey ' fkey is diff --git a/imageFile/f/5th_demo b/imageFile/f/5th_demo new file mode 100755 index 0000000..f2c2bbf --- /dev/null +++ b/imageFile/f/5th_demo @@ -0,0 +1,23 @@ +.( testgraph - simple graphic test) +: testgraph +10 40 10 40 screen FF 0 0 calccol boxf +50 80 50 80 screen 0 FF 0 calccol boxf +90 C0 10 40 screen 0 0 FF calccol boxf ; + +.( testmouse - simple mouse test) +var tmp1 var tmp2 var tmpc +: testmouse +50 tmp1 ! +50 tmp2 ! +until + kb@ if done then + mouse@ + dup 0 = if [ FF FF FF calccol ] tmpc ! then + dup 1 = if [ 00 FF FF calccol ] tmpc ! then + dup 2 = if [ FF 00 FF calccol ] tmpc ! then + 3 = if [ FF FF 00 calccol ] tmpc ! then + tmp2 @ + tmp2 ! tmp1 @ + tmp1 ! + 10 tmp1 @ 26F bound tmp1 ! + 10 tmp2 @ 1CF bound tmp2 ! + tmp1 @ dup 5 + tmp2 @ dup 5 + screen tmpc @ boxf update +loop ; rh tmp1 rh tmp2 rh tmpc diff --git a/imageFile/f/5th_eg b/imageFile/f/5th_eg new file mode 100755 index 0000000..9c73dc0 --- /dev/null +++ b/imageFile/f/5th_eg @@ -0,0 +1,167 @@ +.( loading graphic editor ) update + +D> \listF\listLIB\5TH_GFX2 modulechk +D> \listF\listLIB\5TH_DRVMOUSE modulechk + +.( gedit - load existing image ) +.( geditnew - start new image ) +.( EGh - graphic editor help ) + +var ghandle +var sizex var sizey +var zoomx var zoomy +var zoomup +var zoom +var selcol +var gbrush +1 vari geditcycdir +5 vari geditcyccur + +Dstral const EGfile +str F1 - help" msghelp +str pick the color" msgpick +str draw pixels" msgpix +str fill with color" msgfill +Dstr \listF\TXT_EG" tmphlpfile + + +: EGh tmphlpfile fs. ; + +: gclose ghandle @ dup if dynde +ghandle off else drop then ; + +: geditmsg ( addr -- ) +ghandle @ emitscreen ! +1A 3B at! 14 do space loop +1A 3B at! write +screen emitscreen ! ; + +: zoomupdate +zoom @ if + 14 do + 14 do + i 4 * 226 + dup 4 + i2 4 * 1+ dup 4 + ghandle @ + i zoomx @ + i2 zoomy @ + screen point c@ boxf + loop + loop +then ; + +: selcoldisp 226 27F 55 64 ghandle @ selcol @ boxf ; + +var tmp1 +: grinit +ghandle @ 0 = if 280 1E0 imgalloc ghandle ! then +ghandle @ cls +tmp1 off ( display palette ) +24 do + 6 do + i2 5 * dup 5 + i 5 * 1C2 + dup 5 + ghandle @ + tmp1 @ boxf + tmp1 @ 1+ tmp1 ! + loop +loop +[ FF FF FF calccol ] sizex @ 1+ 0 sizey @ 1+ 0 ghandle @ box +[ FF FF FF calccol ] 276 225 51 0 ghandle @ box +[ FF FF FF calccol ] selcol ! selcoldisp +B4 C8 1C2 1DF ghandle @ FF boxf +msghelp geditmsg ; rh tmp1 + +: geditpict ( x y -- ) +push push +1 i sizex @ bound? if +1 i2 sizey @ bound? if + gbrush @ + dup 2 = if selcol @ i i2 ghandle @ pset zoomup on then + 3 = if sizex @ sizey @ imgalloc + ghandle @ dynp over dynp -1 -1 vidput + dup push + selcol @ i2 1- i3 1- pop imgfill + dup dynp ghandle @ dynp 1 1 vidput + dynde + zoomup on then +then then +pop pop 2drop ; + +: gsavepict +sizex @ sizey @ imgalloc ( imgbuf ) +ghandle @ dynp over dynp -1 -1 vidput +dup EGfile fsDsave +dynde ; + +: ged +ghandle @ if +until + ghandle @ dynp screen dynp 4B008 cmove + zoomup @ if zoomupdate zoomup off then + + KBD_F@ dup 1+ if + dup 400 = if done then ( ESC ) + dup 401 = if tmphlpfile fsdisp then ( F1 ) + dup 402 = if gsavepict then ( F2 ) + dup 405 = if msgpick geditmsg 1 gbrush ! then ( F5 ) + dup 406 = if msgpix geditmsg 2 gbrush ! then ( F6 ) + 407 = if msgfill geditmsg 3 gbrush ! then ( F7 ) + else drop then + + mousekeyr @ if + 0 mousex @ A - sizex @ 12 - bound zoomx ! + 0 mousey @ A - sizey @ 12 - bound zoomy ! + zoom on + ghandle @ emitscreen ! + 45 1D at! + zoomx @ . space + zoomy @ . space space space space + screen emitscreen ! + zoomupdate + then + + mousekeyl @ if + gbrush @ 1 = if + mousex @ mousey @ ghandle @ point + c@ selcol ! selcoldisp + else + 225 mousex @ 276 bound? if + 0 mousey @ 51 bound? if + mousex @ 225 - 4 / zoomx @ + + mousey @ 1- 4 / zoomy @ + geditpict + then then + mousex @ mousey @ geditpict + then + then + + mousedo + update + + geditcyccur @ geditcycdir @ + dup geditcyccur ! + dup dup dup FF setpal + 1 swap 3E bound? 0 = if geditcycdir @ neg geditcycdir ! then +loop +screen cls +else +." no picture loaded" then ; + +: gedit ( file -- ) +dup EGfile str2Dstr ! fsDloadnew ( imgbuf ) +dup imgsize sizey ! sizex ! grinit +dup dynp ghandle @ dynp 1 1 vidput +dynde ged ; + +: geditnew ( xsize ysize -- ) +sizey ! sizex ! +grinit ged ; + + +rh tmphlpfile +rh ghandle +rh sizex rh sizey +rh zoomx rh zoomy +rh zoomup rh zoom +rh gclose rh geditmsg +rh zoomupdate rh selcoldisp +rh grinit rh geditpict +rh gsavepict rh ged +rh selcol +rh msghelp rh msgpix rh msgpick rh msgfill +rh gbrush +rh geditcycdir rh geditcyccur +rh EGfile diff --git a/imageFile/f/5th_et b/imageFile/f/5th_et new file mode 100755 index 0000000..7fde517 --- /dev/null +++ b/imageFile/f/5th_et @@ -0,0 +1,269 @@ +.( loading editor ) update +.( done ) +.( ETh - for text editor help ) + +var handletxt +var handlebuf +Dstralloc const editfile +var shiftx var shifty +var curlocx var curlocy +Dstr \listF\TXT_ET" tmphelpfile + +: disppage ( -- ) +handletxt @ +dynp shifty @ 50 * + +0 1 at! +1270 type ; + +: fclose ( close opened file ) +handletxt @ dup if dynde handletxt off else drop then ; + +: ETnewpage fclose 27100 dynal dup handletxt ! dynp +FF swap 27100 cfill ; + +var tmp1 +: fopen ( strhand -- ) +fclose +dup editfile Dstr2Dstr fsDloadnew dup push dynp ( addrinp R: handinp ) +27100 dynal dup handletxt ! dynp ( addrinp addrout R: handinp ) +FF over 27100 cfill +tmp1 off +i dyns do ( addrinp addrout ) +over c@ ( addrinp addrout c ) +dup FE = if + drop + 50 tmp1 @ - + tmp1 off +else + dup FD = if + drop tmp1 @ tab ( addrinp addrout numspaces ) + tmp1 @ over + tmp1 ! + 0 + else + over c! 1+ 0 + tmp1 @ 1+ tmp1 ! + then + drop +then +swap 1+ swap +loop 2drop +pop dynde ; rh tmp1 + +: dispchar ( x y -- ) +2dup +swap shiftx @ - +swap shifty @ - 1+ +at! +50 * + handletxt @ dynp + c@ emit ; + +: dispcur curlocx @ curlocy @ dispchar ; + +: displine ( line ) +0 over shifty @ - 1+ at! +50 * handletxt @ dynp + shiftx @ + 50 type ; + +: dispstatbar +colneg +0 0 at! 50 do space loop +0 0 at! ." col:" curlocx @ . +7 0 at! ." line:" curlocy @ . +11 0 at! ." ascii:" curlocy @ 50 * curlocx @ + handletxt @ dynp + c@ . +1B 0 at! ." file:" editfile Dstr. +49 0 at! ." F1-help" +colnorm ; + +: charins ( char x y ) +50 * handletxt @ dynp + ( char x addr ) +over push ++ dup dup 1+ 4F pop - cmove ( char addr ) +c! ; + +: charcut ( x y -- char ) +over push +50 * handletxt @ dynp + + +dup c@ swap ( char addr ) +dup dup 1+ swap ( char addr addr+1 addr ) +4F pop - dup push cmove ( char addr ) +pop + FF swap c! ; + +: lineins ( line ) +50 * dup push handletxt @ dynp + ( addr ) +dup dup 50 + handletxt @ dyns 50 - pop - cmove ( addr ) +FF swap 50 cfill ; + +: linecut ( line ) +50 * dup push handletxt @ dynp + ( addr ) +dup 50 + swap handletxt @ dyns 50 - pop - cmove ; + +: screenaim +0 curlocy @ 1E - 794 bound shifty ! +disppage ; + +var tmp1 +: length ( line -- length ) +50 * 4F + handletxt @ dynp + ( addr ) +51 do + i tmp1 ! + dup c@ FF - if pop drop 0 push then + 1- +loop +drop +tmp1 @ ; rh tmp1 + +var tmp2 var tmp3 +: fsavechar ( char ) tmp2 @ swap over c! 1+ tmp2 ! ; +: fsave ( -- ) +27200 dynal dup dynp tmp2 ! +0 +7CF do + i length if drop pop 1+ 0 push then +loop +0 swap for ( desthand ) + tmp3 off + i 50 * handletxt @ dynp + + 0 i length for ( desthand srcaddr ) + dup c@ + i tab 8 = if tmp3 @ if FD fsavechar tmp3 off then then + dup FF = if + drop tmp3 @ 1+ tmp3 ! + else + tmp3 @ do FF fsavechar loop tmp3 off + fsavechar + then + 1+ + loop drop + FE fsavechar +loop +tmp2 @ over dynp - over dynresize +dup editfile fsDsave +dynde ; rh tmp2 rh tmp3 + +str TXT_default" tmpdefault + +: ET +handletxt @ if +disppage +until + colneg dispcur dispstatbar KBD_FW@ colnorm dispcur + + dup 415 = if ( DEL ) + curlocx @ curlocy @ charcut drop + curlocy @ displine + then + + dup FC = if ( BACKSPACE ) + curlocx @ if + curlocx @ 1- curlocy @ charcut drop + curlocy @ displine + drop 413 + else + curlocy @ if + curlocy @ 1- dup length dup curlocx ! ( y-1 strlen ) + swap 50 * handletxt @ dynp + ( strlen y1addr ) + 2dup + swap 50 + ( strlen dest src ) + swap rot 50 swap - cmove + curlocy @ linecut + drop 410 + disppage + then + then + then + + dup FD = if ( TAB ) + curlocx @ tab + dup do FF curlocx @ curlocy @ charins loop + curlocx @ + curlocx ! + curlocy @ displine + then + + dup FE = if ( ENTER ) + curlocy @ 7CF < if + curlocy @ 1+ lineins + curlocx @ 0 + 50 curlocx @ - do + over curlocy @ charcut + over curlocy @ 1+ charins + 1+ + loop 2drop + curlocx off + drop 412 + disppage + then + then + + dup 418 = if curlocy @ 3A - curlocy ! then ( PG-UP ) + dup 419 = if curlocy @ 3A + curlocy ! then ( PG-DOWN ) + dup 416 = if curlocx off then ( HOME ) + dup 417 = if curlocy @ length curlocx ! then ( END ) + dup 401 = if tmphelpfile fsdisp disppage then ( F1 ) + dup 402 = if fsave then ( F2 ) + dup 403 = if fclose drop 1B then ( F3 ) + dup 400 = if done 0 0 at! screen cls drop -1 then ( ESC ) + + 0 over F0 bound? if -1 else 0 then ( NORMAL KEY ) + over FF = if drop -1 then + if + curlocx @ curlocy @ charins + curlocy @ displine + 411 + then + + dup 411 = if curlocx @ 1+ curlocx ! then ( RIGHT ) + dup 413 = if curlocx @ 1- curlocx ! then ( LEFT ) + dup 412 = if curlocy @ 1+ curlocy ! then ( DOWN ) + dup 410 = if curlocy @ 1- curlocy ! then ( UP ) + drop + + 0 curlocx @ 4F bound curlocx ! + 0 curlocy @ 7CF bound curlocy ! + + curlocy @ shifty @ - 3B > if screenaim then + + curlocy @ shifty @ - 3B - 0 = if + 0 0 8 screen scrollf + shifty @ 1+ shifty ! + curlocy @ displine + then + + curlocy @ shifty @ - -1 < if screenaim then + + curlocy @ shifty @ - 1+ 0 = if + 0 0 -8 screen scrollf + shifty @ 1- shifty ! + curlocy @ displine + then + +loop +else + tmpdefault editfile str2Dstr + ETnewpage + ET +then ; + +: ETl +fopen +curlocx off +curlocy off +shiftx off +shifty off +ET ; + +: ETs +editfile Dstr2Dstr +fsave ." saved " ; + +: ETh tmphelpfile fs. ; + +rh handletxt +rh handlebuf +rh editfile +rh shiftx rh shifty +rh curlocx rh curlocy +rh tmphelpfile +rh disppage +rh fclose rh fopen +rh dispchar rh dispcur +rh displine rh dispstatbar +rh charins rh charcut +rh lineins rh linecut +rh screenaim rh length +rh fsavechar rh fsave +rh ETnewpage rh tmpdefault diff --git a/imageFile/f/5th_logo b/imageFile/f/5th_logo new file mode 100755 index 0000000..7d375e1 --- /dev/null +++ b/imageFile/f/5th_logo @@ -0,0 +1,46 @@ +: tmpbox ( x y -- ) +10 * swap 10 * \ y x +dup 9 + rot dup 9 + \ x1 x2 y1 y2 +screen FF FF FF calccol boxf ; + +: tmplineh ( x y -- ) +swap 1+ swap 2dup tmpbox +swap 1+ swap tmpbox ; + +: tmplinev ( x y -- ) +1+ 2dup tmpbox +1+ tmpbox ; + +: tmpI ( x y -- ) +2dup tmplinev +3 + 2dup tmplinev +tmpbox ; + +: tmpT ( x y -- ) +2dup tmpI +tmplineh ; + +: tmpF ( x y -- ) +2dup tmpT +3 + tmplineh ; + +: tmpH ( x y -- ) +2dup tmpI +2dup 3 + tmplineh +swap 3 + swap tmpI ; + +: tmpxp +swap 5 + swap ; + +: tmplogo ( x y -- ) +2dup tmpF tmpxp +2dup tmpI tmpxp +2dup tmpF tmpxp +2dup tmpT tmpxp +tmpH ; + +7 3 tmplogo +0 18 at! +.( Fifth, Copyright 2003 Svjatoslav Agejenko. All rights reserved.) +forget tmpbox +update diff --git a/imageFile/f/FNT_SYSTEM b/imageFile/f/FNT_SYSTEM new file mode 100755 index 0000000..980f716 Binary files /dev/null and b/imageFile/f/FNT_SYSTEM differ diff --git a/imageFile/f/I01_MCARROW b/imageFile/f/I01_MCARROW new file mode 100755 index 0000000..ce1521a Binary files /dev/null and b/imageFile/f/I01_MCARROW differ diff --git a/imageFile/f/lib/5TH_DRVKBD b/imageFile/f/lib/5TH_DRVKBD new file mode 100755 index 0000000..15690b4 --- /dev/null +++ b/imageFile/f/lib/5TH_DRVKBD @@ -0,0 +1,92 @@ +: KBD_test +until + kbd@ + dup 1 = if done then + dup if + . tab. update + else + drop + then +loop ; + + +create KBD_downbuf 80 alloc + +: KBD_@ +until + kbd@ + dup if + dup 80 >= if + [ KBD_downbuf 80 - ] + 0 swap c! + else + dup KBD_downbuf + 1 swap c! done + then + else + done + then +loop ; + +: KBD_down? ( KeyScanCode -- result ) +KBD_downbuf + c@ ; + +rh KBD_downbuf + +str \listF\listLIB\5TH_KBD_USDVORAK" tmp1 +str \listF\listLIB\5TH_KBD_US" tmp2 + +.( Select keyboard layout, by pressing appropriate number. ) +.( 1 - US dvorak ) +.( 2 - US ) + +: tmpselect +until + KBD_@ + dup 2 = if tmp1 swap done then + dup 3 = if tmp2 swap done then + drop +loop ; + +update +tmpselect +.( selected ) +update + +defDstr str2Dstr +forget tmp1 +defDstr include + +: KBD_test2 +until + KBD_@ + dup 1 = if done then + dup if + . tab. update + else + drop + then +loop ; + +: KBD_SC2FSCII ( ScanCode -- FSCII ) +KBD_table swap until \ addr code + over @ dup if + over = if + drop 4 + @ done + else + swap 8 + swap + then + else + 2drop drop -1 done + then +loop ; + +: KBD_F@ +KBD_@ +2A KBD_down? if 100 + then +38 KBD_down? if 200 + then +KBD_SC2FSCII ; + +: KBD_FW@ update +until + KBD_F@ + dup -1 = if drop else done then +loop ; diff --git a/imageFile/f/lib/5TH_DRVMOUSE b/imageFile/f/lib/5TH_DRVMOUSE new file mode 100755 index 0000000..0f50d09 --- /dev/null +++ b/imageFile/f/lib/5TH_DRVMOUSE @@ -0,0 +1,53 @@ +var mousex +var mousey +var mousekeyl +var mousekeyr +var mousekeym +var mousec ( display coordinates flag ) +create mousebuf 100 alloc +var mousebe ( amount of buffer elements ) +var mousepointer +D> \listF\I01_MCARROW fsDloadnew mousepointer ! + +: mouseadd ( addr x1 x2 y1 y2 -- ) +mousebe @ dup 1+ mousebe ! +14 * mousebuf + ( ... addr ) +swap over ! +4 + swap over ! +4 + swap over ! +4 + swap over ! +4 + ! ; + +: mousedo ( -- ) +mouse@ +dup 0 bit@ if mousekeyl on else mousekeyl off then +dup 1 bit@ if mousekeyr on else mousekeyr off then + 2 bit@ if mousekeym on else mousekeym off then + +mousey @ + 0 swap 1DF bound mousey ! +mousex @ + 0 swap 27F bound mousex ! + +mousepointer @ dynp +screen dynp mousex @ mousey @ tvidput + +mousekeyl @ mousekeyr @ + mousekeym @ + if +mousebe @ do + i 14 * mousebuf + + dup @ swap 4 + @ mousey @ rot bound? if + i 14 * mousebuf + 8 + + dup @ swap 4 + @ mousex @ rot bound? if + i 14 * mousebuf + 10 + @ goto pop drop 0 push + then + then +loop +then + +mousec @ if + emitscreen @ + screen emitscreen ! + at@ + 0 0 at! + mousex @ . tab. mousey @ . + at! + emitscreen ! +then ; diff --git a/imageFile/f/lib/5TH_KBD_US b/imageFile/f/lib/5TH_KBD_US new file mode 100755 index 0000000..9e90ef5 --- /dev/null +++ b/imageFile/f/lib/5TH_KBD_US @@ -0,0 +1,97 @@ +create KBD_table + +2 , asc 1 , 102 , asc ! , +3 , asc 2 , 103 , asc @ , +4 , asc 3 , 104 , asc # , +5 , asc 4 , 105 , asc $ , +6 , asc 5 , 106 , asc % , +7 , asc 6 , 107 , asc ^ , +8 , asc 7 , 108 , asc & , +9 , asc 8 , 109 , asc * , +A , asc 9 , 10A , asc ( , +B , asc 0 , 10B , asc ) , +C , asc - , 10C , asc _ , +D , asc = , 10D , asc + , +E , FC , \ backspace +F , FD , \ tab +10 , asc q , 110 , asc Q , +11 , asc w , 111 , asc W , +12 , asc e , 112 , asc E , +13 , asc r , 113 , asc R , +14 , asc t , 114 , asc T , +15 , asc y , 115 , asc Y , +16 , asc u , 116 , asc U , +17 , asc i , 117 , asc I , +18 , asc o , 118 , asc O , +19 , asc p , 119 , asc P , +1A , asc [ , 11A , asc { , +1B , asc ] , 11B , asc } , +1C , FE , \ enter +1E , asc a , 11E , asc A , +1F , asc s , 11F , asc S , +20 , asc d , 120 , asc D , +21 , asc f , 121 , asc F , +22 , asc g , 122 , asc G , +23 , asc h , 123 , asc H , +24 , asc j , 124 , asc J , +25 , asc k , 125 , asc K , +26 , asc l , 126 , asc L , +27 , asc ; , 127 , asc : , +28 , asc , , 128 , asc " , +29 , asc ' , 129 , asc ~ , + +2B , asc \ , 12B , asc | , +2C , asc z , 12C , asc Z , +2D , asc x , 12D , asc X , +2E , asc c , 12E , asc C , +2F , asc v , 12F , asc V , +30 , asc b , 130 , asc B , +31 , asc n , 131 , asc N , +32 , asc m , 132 , asc M , +33 , asc , , 133 , asc < , +34 , asc . , 134 , asc > , +35 , asc / , 135 , asc ? , + +39 , FF , \ space +48 , 410 , 148 , 410 , \ up +4D , 411 , 14D , 411 , \ right +50 , 412 , 150 , 412 , \ down +4B , 413 , 14B , 413 , \ left + +1 , 400 , \ ESC +3B , 401 , \ F1 ... +3C , 402 , +3D , 403 , +3E , 404 , +3F , 405 , +40 , 406 , +41 , 407 , +42 , 408 , +43 , 409 , +44 , 40A , \ F10 + +152 , 414 , \ INS +153 , 415 , \ DEL +147 , 416 , \ HOME +14F , 417 , \ END +149 , 418 , \ PG/UP +151 , 419 , \ PG/DN + +202 , 1 , +203 , 2 , +204 , 3 , +205 , 4 , +206 , 5 , +207 , 6 , +208 , 7 , +209 , 8 , +20A , 9 , +20B , 0 , +21E , A , +231 , B , +217 , C , +223 , D , +220 , E , +215 , F , + +0 , diff --git a/imageFile/f/lib/5TH_KBD_USDVORAK b/imageFile/f/lib/5TH_KBD_USDVORAK new file mode 100755 index 0000000..b2e2301 --- /dev/null +++ b/imageFile/f/lib/5TH_KBD_USDVORAK @@ -0,0 +1,97 @@ +create KBD_table + +2 , asc 1 , 102 , asc ! , +3 , asc 2 , 103 , asc @ , +4 , asc 3 , 104 , asc # , +5 , asc 4 , 105 , asc $ , +6 , asc 5 , 106 , asc % , +7 , asc 6 , 107 , asc ^ , +8 , asc 7 , 108 , asc & , +9 , asc 8 , 109 , asc * , +A , asc 9 , 10A , asc ( , +B , asc 0 , 10B , asc ) , +C , asc [ , 10C , asc { , +D , asc ] , 10D , asc } , +E , FC , \ backspace +F , FD , \ tab +10 , asc ' , 110 , asc " , +11 , asc , , 111 , asc < , +12 , asc . , 112 , asc > , +13 , asc p , 113 , asc P , +14 , asc y , 114 , asc Y , +15 , asc f , 115 , asc F , +16 , asc g , 116 , asc G , +17 , asc c , 117 , asc C , +18 , asc r , 118 , asc R , +19 , asc l , 119 , asc L , +1A , asc / , 11A , asc ? , +1B , asc = , 11B , asc + , +1C , FE , \ enter +1E , asc a , 11E , asc A , +1F , asc o , 11F , asc O , +20 , asc e , 120 , asc E , +21 , asc u , 121 , asc U , +22 , asc i , 122 , asc I , +23 , asc d , 123 , asc D , +24 , asc h , 124 , asc H , +25 , asc t , 125 , asc T , +26 , asc n , 126 , asc N , +27 , asc s , 127 , asc S , +28 , asc - , 128 , asc _ , +29 , asc ' , 129 , asc ~ , + +2B , asc \ , 12B , asc | , +2C , asc ; , 12C , asc : , +2D , asc q , 12D , asc Q , +2E , asc j , 12E , asc J , +2F , asc k , 12F , asc K , +30 , asc x , 130 , asc X , +31 , asc b , 131 , asc B , +32 , asc m , 132 , asc M , +33 , asc w , 133 , asc W , +34 , asc v , 134 , asc V , +35 , asc z , 135 , asc Z , + +39 , FF , \ space +48 , 410 , 148 , 410 , \ up +4D , 411 , 14D , 411 , \ right +50 , 412 , 150 , 412 , \ down +4B , 413 , 14B , 413 , \ left + +1 , 400 , \ ESC +3B , 401 , \ F1 ... +3C , 402 , +3D , 403 , +3E , 404 , +3F , 405 , +40 , 406 , +41 , 407 , +42 , 408 , +43 , 409 , +44 , 40A , \ F10 + +152 , 414 , \ INS +153 , 415 , \ DEL +147 , 416 , \ HOME +14F , 417 , \ END +149 , 418 , \ PG/UP +151 , 419 , \ PG/DN + +202 , 1 , +203 , 2 , +204 , 3 , +205 , 4 , +206 , 5 , +207 , 6 , +208 , 7 , +209 , 8 , +20A , 9 , +20B , 0 , +21E , A , +231 , B , +217 , C , +223 , D , +220 , E , +215 , F , + +0 , diff --git a/imageFile/f/lib/5TH_UICMD b/imageFile/f/lib/5TH_UICMD new file mode 100755 index 0000000..5e8d371 --- /dev/null +++ b/imageFile/f/lib/5TH_UICMD @@ -0,0 +1,77 @@ +: words +cr lp @ +max do +118 do + dup 0 = if pop pop 2drop drop ret then + colnorm + dup 13 + c@ + dup 2 = if colhigh then + 0 = if colneg then + dup 4 + write colnorm + curx @ 10 mod 10 swap - do space loop + @ +loop +cr 50 do asc = emit loop KBD_FW@ drop +loop ; + +: statinc +inccur @ dup ." depth: " d. cr +." " cr +incfiles swap 1+ do + dup @ dup d. space dyns d. space 4 + dup @ d. 4 + cr +loop drop ; + +: (cmdline +\ colhigh +200 dynal +0 +cr +until + KBD_FW@ ( handle addr key ) + push + 0 swap 200 bound + over dynp over + i swap c! ( handle addr ) + 1+ + i FC = if 2 - FC emit space then + pop dup FE - if ( handle addr ) + emit + else + drop space + over dynresize ( handle ) + dyninc + done + then +loop \ colnorm +; + +' (cmdline ' cmdline is + +: ascii +until KBD_FW@ dup 1B = if done then +dup emit space d. space loop ; + +: fs. ( fname -- ) fsDloadnew dup dyn. dynde ; + +: fsdisp ( fname -- ) +screen cls 0 0 at! fs. cr +." press any key to continue ..." +KBD_FW@ drop ; + +create tmpbuf 100 alloc +: s. +depth 2 - push +." depth: " i . cr +1 i 400 bound? if + i do + i 4 * tmpbuf + ! + loop + 0 i for + i 4 * tmpbuf + @ dup . tab. + loop +then pop drop ; rh tmpbuf + +: bye 2dup push push \ R: n1 n2 +i2 3 = if + i FE = if halt then +then +." unbalanced stack: " swap . space . KBD_FW@ halt ; diff --git a/imageFile/f/lib/5th_gfx b/imageFile/f/lib/5th_gfx new file mode 100755 index 0000000..8ac8133 --- /dev/null +++ b/imageFile/f/lib/5th_gfx @@ -0,0 +1,149 @@ +: tab ( col -- spaces) 8 mod 8 swap - dup 0 = if drop 8 then ; + +: calccol ( b g r -- c ) +2B / 24 * swap 2B / 6 * + swap 2B / + ; + +: imgalloc ( x y -- handle ) +2dup * 8 + dynal ( x y handle ) +dup push dynp ( x y addr ) +rot over ! 4 + ! pop ; + +280 1E0 imgalloc const screen + +: imgsize ( screen -- x y ) +dynp dup @ swap 4 + @ ; + +: copyscreen ( srcDhand destDhand -- ) +swap dynp swap dup dynp swap dyns cmove ; + +: update ( -- ) screen dynp 8 + vidmap ; + +: point ( x y screen -- addr ) +dynp dup @ ( x y addr xs ) +rot * ( x addr y*xs) ++ + 8 + ; + +: pset ( c x y screen -- ) point c! ; + +var tmp1 var tmp2 +: boxf ( x1 x2 y1 y2 screen c -- ) +tmp1 ! +tmp2 ! +for ( x1 x2 ) + 2dup swap - push + over i2 tmp2 @ point + tmp1 @ swap pop cfill +loop 2drop ; +rh tmp1 rh tmp2 + +: cls ( screen -- ) +dynp dup @ swap 4 + dup @ ( x addr y ) +rot * swap 4 + ( len addr ) +0 rot rot swap ( c addr len) +cfill ; + +: setpal ( b g r color -- ) 3C8 cprt! 3C9 cprt! 3C9 cprt! 3C9 cprt! ; + +: setupal +D7 +6 do + 6 do + 6 do + dup i C * swap i2 C * swap i3 C * swap setpal + 1 - + loop + loop +loop +drop ; + +setupal + +D" \listF\FNT_SYSTEM" fsDloadnew const font + +: scroll ( x y screen -- ) +dynp dup @ swap 4 + dup @ swap 4 + push ( x y xsize ysize R: addr ) +over * push ( x y xsize R: addr size ) +* + i2 + pop pop swap cmove ; + +var tmp1 var tmp2 var tmp3 var tmp4 var tmp5 var tmp6 var tmp7 +: scrollf ( color x y screen -- ) +dup push tmp1 ! ( screen ) +dup push tmp2 ! ( y ) +dup tmp3 ! ( x ) +pop pop scroll +push +tmp1 @ dynp dup @ tmp4 ! ( xsize ) +4 + @ tmp5 ! ( ysize ) +tmp2 @ dup 0 - if + 0 > if + 0 dup tmp6 ! tmp4 @ tmp5 @ tmp2 @ - dup tmp7 ! + tmp5 @ tmp1 @ i boxf + + else + 0 tmp4 @ 0 tmp2 @ neg dup tmp6 ! tmp1 @ i boxf + tmp5 @ tmp7 ! + then +else + drop + 0 tmp6 ! tmp5 @ tmp7 ! +then + +tmp3 @ dup 0 - if + 0 > if + tmp4 @ dup tmp3 @ - swap tmp6 @ tmp7 @ tmp1 @ i boxf + else + 0 tmp3 @ neg tmp6 @ tmp7 @ tmp1 @ i boxf + then +else + drop +then +pop drop ; +rh tmp1 rh tmp2 rh tmp3 rh tmp4 rh tmp5 rh tmp6 rh tmp7 + +var curx +var cury +var curc +var curb +var emitscreen + +screen emitscreen ! + +: at! ( x y -- ) cury ! curx ! ; +: at@ ( -- x y ) curx @ cury @ ; +: curc! calccol curc ! ; +: curb! calccol curb ! ; + +: colnorm FF FF FF curc! 0 0 0 curb! ; +: colneg 0 0 0 curc! FF FF FF curb! ; +: colhigh 0 FF FF curc! 0 0 0 curb! ; + +colnorm + +: (emit2 +dup FE = if drop + 0 curx ! cury @ 1+ + dup 3B > if + 0 0 8 emitscreen @ scrollf + drop 3B + then + cury ! +else + dup FC - if + dup FD - if + curx @ 4F > if FE emit then + 8 * font dynp + + curc @ swap curb @ swap emitscreen @ dynp + curx @ 8 * cury @ 8 * charput + curx @ 1+ curx ! + else + drop curx @ tab do space loop + then + else + drop curx @ 1- + dup 0 < if drop 0 then curx ! + then +then ; + +screen cls +FC emit +' (emit2 ' emit is diff --git a/imageFile/f/lib/5th_gfx2 b/imageFile/f/lib/5th_gfx2 new file mode 100755 index 0000000..27f4e4e --- /dev/null +++ b/imageFile/f/lib/5th_gfx2 @@ -0,0 +1,107 @@ +: lineh ( color len x y imgbuf -- ) +point swap cfill ; + +: linev ( color len x y imgbuf -- ) +dup imgsize drop push +point swap +do 2dup c! i2 + loop +2drop pop drop ; + +var tmp1 var tmp2 var tmp3 var tmp4 +: box ( color x2 x1 y2 y1 imgbuf -- ) + push ( buf i3 ) +dup push ( y1 i2 ) +over tmp1 ! ( y2 1 ) +- tmp2 ! ( ylen 2 ) +dup push ( x1 i ) +over tmp3 ! ( x2 3 ) +- tmp4 ! ( xlen 4 ) + +dup tmp4 @ i i2 i3 lineh +dup tmp4 @ 1+ i tmp1 @ i3 lineh +dup tmp2 @ i i2 i3 linev + tmp2 @ tmp3 @ i2 i3 linev +pop pop 2drop pop drop ; +rh tmp1 rh tmp2 rh tmp3 rh tmp4 + +var flipxs var flipys var fliplb var flipib var flipsa var flipda +: flipv ( imgbuf -- ) +dup push imgsize over dynal push ( sizex sizey R: imgbuf linebuf ) +flipys ! flipxs ! pop fliplb ! pop flipib ! +flipys @ 2 / do + 0 i flipib @ point flipsa ! + 0 flipys @ i - 1- flipib @ point flipda ! + flipda @ fliplb @ dynp flipxs @ cmove + flipsa @ flipda @ flipxs @ cmove + fliplb @ dynp flipsa @ flipxs @ cmove +loop ; +rh flipxs rh flipys rh fliplb rh flipib rh flipsa rh flipda + +: imgcoltrans ( ImgBuf Color ToColor -- ) +push push +dup dynp 8 + swap dyns 8 - do + dup c@ i2 = if i3 over c! then + 1+ +loop drop pop pop 2drop ; + +var imgfillbuf var imgfilld var imgfillc +: imgfill ( color x y imgbuf -- ) +dup imgfillbuf ! point dup c@ imgfillc ! FE swap c! ( color ) +until + imgfilld off + + imgfillbuf @ imgsize + swap 1- swap + do + imgfillbuf @ imgsize drop 1- i imgfillbuf @ point + over do + dup c@ FE = if + dup 1- c@ imgfillc @ = if + dup 1- FE swap c! + imgfilld on + then + then + 1- + loop drop + + 0 i imgfillbuf @ point + over do + dup c@ FE = if + dup 1+ c@ imgfillc @ = if + dup 1+ FE swap c! + imgfilld on + then + then + 1+ + loop drop + loop drop + + imgfillbuf @ imgsize 1- swap + do + i imgfillbuf @ dup imgsize swap push 1- swap point + over do + dup c@ FE = if + dup i2 - c@ imgfillc @ = if + dup i2 - FE swap c! + imgfilld on + then + then + i2 - + loop drop + + + i2 0 imgfillbuf @ point + over do + dup c@ FE = if + dup i2 + c@ imgfillc @ = if + dup i2 + FE swap c! + imgfilld on + then + then + i2 + + loop pop 2drop + loop drop +imgfilld @ if imgfilld off else done then +loop +imgfillbuf @ FE rot imgcoltrans ; +rh imgfillbuf rh imgfilld rh imgfillc diff --git a/imageFile/f/lib/5th_trig b/imageFile/f/lib/5th_trig new file mode 100755 index 0000000..96b01e1 --- /dev/null +++ b/imageFile/f/lib/5th_trig @@ -0,0 +1,24 @@ +create sintable 8000 alloc + +: mktable +here push +sintable h ! +100000000 0 +2000 do + + over 100000 / - + swap over + swap + over 10000 / , +loop +2drop +pop h ! ; + +mktable +forget mktable + +: cos ( num -- result) +abs 2000 mod 4 * sintable + @ ; + +: sin 500 - cos ; + +rh sintable diff --git a/imageFile/f/txt_eg b/imageFile/f/txt_eg new file mode 100755 index 0000000..4b0f485 --- /dev/null +++ b/imageFile/f/txt_eg @@ -0,0 +1,16 @@ + +Graphic editor is very unfinished, some functions do not work properly yet! + + Paint quick help: + +q - exit, don't close image +F1 - this help +F2 - save to file +F3 - close & exit +F5 - pick color +F6 - draw pixels +F7 - fill with color + +Right mouse button - select zoom region. + +flashing color is transparent diff --git a/imageFile/f/txt_et b/imageFile/f/txt_et new file mode 100755 index 0000000..866010f --- /dev/null +++ b/imageFile/f/txt_et @@ -0,0 +1,18 @@ + Text editor help: + +from editor: + +F1 - help +F2 - save to current file +F3 - close text, switch to commandline +ESC - switch to commandline + +PG/UP & PG/DOWN, cursor keys, DEL, backspace, TAB, HOME & END, works as usual. + + +commandline: + + ET - switch to text editor + ETl - load file, and switch to editor + ETs - save to file + ETh - help diff --git a/imageFile/f/txt_help b/imageFile/f/txt_help new file mode 100755 index 0000000..a38b442 --- /dev/null +++ b/imageFile/f/txt_help @@ -0,0 +1,13 @@ + basic Fifth commands: + +help - get this help +lde - load editor +fsls - show list of files +fslsr - recursive file list + fsdel - delete file + fscl - goto specified path + fscopy - copy file + fs. - type file contenc to screen +bye - exit from fifth +words - list all dictionary entries. +statdyn - list info about allocated dynamic memory blocks diff --git a/kernel/core.asm b/kernel/core.asm new file mode 100755 index 0000000..2cb74c4 --- /dev/null +++ b/kernel/core.asm @@ -0,0 +1,680 @@ +; core of Fifth + +include 'define.inc' + +link = 0 +org 0 + +lpad: xnum 1 ; load rest of core into RAM + xnum 1024 + xnum 3 + xcall lload + xnum 4 ; load highlevel Fifth boot code into RAM + xnum 1500000 + xnum 32 + xcall lload + xnum -1 ; initialize dictionary space + xnum lend + xnum 30000 + xcfill + xjmp lmain + times 15 db '*PAD*' + +lload: ;( fromdisk tomem amount -- ) +l46: xdup + xif l45 + xdec + xpush + xover + xover + xdisk@ + xnum 1024 + xplus + xswap + xinc + xswap + xpop + xjmp l46 +l45: xdrop + xdrop + xdrop + xret + +ibuf: dd 0, 0, 0, 0, 0, 0, 0, 0 +lh: dd last+24000 +llp: dd lastp + +lcount: xinc + xdup + xdec + xc@ + xret + +vloc dd 200000h +llemit: ; xemit + xnum vloc + x@ + xdup + xinc + xnum vloc + x! + xc! + xret + +lhere: xnum lh + x@ + xret + +lemit: xjmp llemit + +ltype: xdup + xif l2 + xdec + xpush + xcall lcount + xcall lemit + xpop + xjmp ltype +l2: xdrop + xdrop + xret + +lwrite: xcall lcount + xcall ltype + xret + +lsadd: xdup + xc@ + xinc + xover + xover + xswap + xc! + xplus + xc! + xret + +llfkey: xnum d1 + x@ + xcall lcount + xswap + xnum d1 + x! + xret +d1 dd 1500000 + +lfkey: xjmp llfkey + +lskey: xcall lfkey + xdup + xnum 254 + xminus + xif l47 + xdup + xnum 253 + xminus + xif l47 + xret +l47: xdrop + xnum 255 + xret + +lscan: xnum 0 + xnum lpad + xc! +l4: xcall lskey + xover + xover + xminus + xif l3 + xnum lpad + xcall lsadd + xjmp l4 +l3: xdrop + xnum lpad + xc@ + xif lscan + xdrop + xret + +lstrEQstr: xdup + xc@ + xinc +l8: xdup + xif l6 + xdec + xpush + xover + xc@ + xover + xc@ + xminus + xif l7 + xpop + xdrop + xdrop + xdrop + xnum 0 + xret +l7: xinc + xswap + xinc + xpop + xjmp l8 +l6: xdrop + xdrop + xdrop + xnum -1 + xret + +lstrEQpad: + xnum lpad + xjmp lstrEQstr + +lfind: xnum llp +l9: xdup + xnum lprev + x! + x@ + xdup + xif l11 + xdup + xinc + xinc + xinc + xinc + xcall lstrEQpad + xif l9 +l11: xret + +lprev: dd 0 +lmode: db 1 ; 0 compile + ; 1 interpret + +lgoto: xnum l44+1 + x! +l44: xjmp 0 + +lexecute: + xnum lmode + xc@ + xif l19 + xcall setint +l19: xcall lfind + xdup + xif l12 ; not found ? + xnum 19 + xplus + xdup + xc@ ; ( addr+19 c ) + xdup + xif cmpnum + xdec + xdup + xif cmpmod + xdec + xif cmpimm + xdrop + xjmp clrint +setint: xnum l14 + x@ + xif l15 + xret +l14 dd 0 +l15: xnum lh + x@ + xnum l14 + x! + xnum ibuf + xnum lh + x! + xret +clrint: xnum l14 + x@ + xif l20 + xnum 11 + xcall lcsto + xnum l14 + x@ + xnum lh + x! + xnum 0 + xnum l14 + x! + xjmp ibuf +l20: xret +cmpnum: xdrop + xnum 3 + xjmp cmpn +cmpmod: xdrop + xnum 5 + xjmp cmpn +cmpimm: xcall setint + xnum 5 + xjmp cmpn +cmpn: xcall lcsto + xinc + x@ + xcall lsto + xjmp clrint +l12: xdrop + xcall l2num + xif l23 + xnum 3 + xcall lcsto + xcall lsto + xjmp clrint +l23: xdrop + xnum lpad + xcall lwrite + xnum msg1 + xcall lwrite + xjmp clrint +msg1 db 3, ' ? ' + +l2num: xnum lpad + xcall lcount ; ( addr len ) + xnum numlen + xc! + xnum 0 +l13: xnum numlen ; ( addr num ) + xc@ + xdup + xif numend + xdec + xnum numlen + xc! + xnum 16 + xmul + xswap + xcall lcount ; ( num addr c ) + + xdup + xnum 45 + xminus + xif l22 +l28: xdup + xnum 16 + xcmpg + xif l21 + xdrop + xdrop + xnum 0 + xret +l21: xrot + xplus ; ( addr num ) + xjmp l13 +numend: xdrop + xswap + xdrop + xnum numneg + xc@ + xif l16 + xnum -1 + xmul + xnum 0 + xnum numneg + xc! +l16: xnum -1 + xret +numlen db 0 +numneg db 0 + +l22: xnum numneg + xc! + xnum 0 + xjmp l28 + +lcsto: xnum lh + x@ + xover + xover ; ( n addr n addr ) + xc! + xinc + xnum lh + x! + xdrop + xret + +lsto: xnum lh + x@ + xover + xover + x! + xnum 4 + xplus + xnum lh + x! + xdrop + xret + +lhalt: xhalt + +l@: xnum 20 + xjmp bcode + +l!: xnum 21 + xjmp bcode + +lc@: xnum 12 + xjmp bcode + +lc!: xnum 13 + xjmp bcode + +linc: xnum 6 + xjmp bcode + +ldec: xnum 7 + xjmp bcode + +lcmpg: xnum 28 + xjmp bcode + +lcmpl: xnum 29 + xjmp bcode + +lret: xnum 11 + xjmp bcode + +lplus: xnum 24 + xjmp bcode + +lminus: xnum 25 + xjmp bcode + +lmul: xnum 26 + xjmp bcode + +ldrop: xnum 9 + xjmp bcode + +ldup: xnum 8 + xjmp bcode + +lswap: xnum 23 + xjmp bcode + +ldisk@: xnum 18 + xjmp bcode + +lpush: xnum 14 + xjmp bcode + +lpop: xnum 15 + xjmp bcode + +lover: xnum 22 + xjmp bcode + +lcmove: xnum 43 + xjmp bcode + +bcode: xnum lmode + xc@ + xif lcsto + xnum l25 + xc! +l25: db 0 + xret + +lne: xcall lfind + xif lne3 + xnum lpad + xcall lwrite + xnum msg2 + xcall lwrite +lne3: xnum sf ; pick next address + x@ + xdup + xnum 24 + xplus + xdup + xnum last+23999 + xcmpg + xif lne1 + xdrop + xnum last +lne1: xnum sf + x! + xdup ; is cell empty + x@ + xinc + xif lne2 + xdrop + xjmp lne3 +lne2: xnum llp ; create entry + x@ + xover + x! + xdup + xnum llp + x! + xnum lpad + xover + xinc + xinc + xinc + xinc + xnum 15 + xcmove + xnum 19 + xplus + xdup + xinc + xpush + xc! + xpop + x! + xret +sf dd lend +msg2 db 3, ' ! ' + +lcolon: xnum 255 + xcall lscan + xnum lh + x@ + xnum 1 + xcall lne + xnum 0 + xnum lmode + xc! + xret + +lI: xnum 1 + xnum lmode + xc! + xret + +ldadd: +l27: xdup + xif l26 + xdec + xpush + xcall lcount + xcall lcsto + xpop + xjmp l27 +l26: xdrop + xdrop + xret + +lincmod: xcall lcount + xjmp ldadd + +lif: xcall lhere + xinc + xnum d6 + xcall lincmod +l35: xnum 255 + xcall lscan + xnum d7 + xcall lstrEQpad + xif l36 + xcall lhere + xinc + xnum d9 + xcall lincmod + xswap + xcall lhere + xswap + x! + xjmp l35 +l36: xnum d8 + xcall lstrEQpad + xif l37 + xcall lhere + xswap + x! + xret +l37: xcall lexecute + xjmp l35 + +d6 db 5, 10, 0, 0, 0, 0 +d7 db 4, 'else' +d8 db 4, 'then' +d9 db 5, 4, 0, 0, 0, 0 + +ldo: xcall lhere + xinc + xinc + xnum d4 + xcall lincmod +l33: xnum 255 + xcall lscan + xnum d5 + xcall lstrEQpad + xif l34 + xnum 15 + xcall lsto + xnum 4 + xcall lcsto + xdup + xdec + xdec + xcall lsto + xcall lhere + xswap + x! + xnum 9 + xcall lcsto + xret +l34: xcall lexecute + xjmp l33 +d4 db 8, 8, 10, 0, 0, 0, 0, 7, 14 +d5 db 4, 'loop' + +lfor: xcall lhere + xnum d10 + xcall lincmod +l38: xnum 255 + xcall lscan + xnum d5 + xcall lstrEQpad + xif l39 + xnum d11 + xcall lincmod + xcall lhere + xover + xnum 5 + xplus + x! + xinc + xcall lhere + xdec + xdec + xdec + xdec + x! + xnum d12 + xcall lincmod + xret +l39: xcall lexecute + xjmp l38 + +d10 db 10, 14, 8, 31, 25, 10, 0,0,0,0, 14 +d11 db 7, 15, 6, 4, 0,0,0,0 +d12 db 3, 9, 15, 9 + +luntil: xnum d14 + xcall lincmod + xcall lhere +l40: xnum 255 + xcall lscan + xnum d5 + xcall lstrEQpad + xif l41 + xnum d15 + xcall lincmod + xcall lhere + xnum 6 + xminus + x! + xret +l41: xcall lexecute + xjmp l40 + +d14 db 6, 3, 0, 0, 0, 0, 14 +d15 db 8, 31, 10, 0, 0, 0, 0, 15, 9 + +lmain: +l32: xnum 255 + xcall lscan + xcall lexecute + xjmp l32 + +last: +head 2, 'lp', 0, llp +head 5, 'count', 1, lcount +head 4, 'emit', 1, lemit +head 4, 'type', 1, ltype +head 5, 'write', 1, lwrite +head 3, 'pad', 0, lpad +head 5, 'c+str', 1, lsadd +head 4, 'fkey', 1, lfkey +head 4, 'scan', 1, lscan +head 8, 'str=str?', 1, lstrEQstr +head 4, 'find', 1, lfind +head 4, 'mode', 0, lmode +head 4, 'goto', 1, lgoto +head 7, 'execute', 1, lexecute +head 4, '2num', 1, l2num +head 2, 'c,', 1, lcsto +head 1, ',', 1, lsto +head 4, 'halt', 1, lhalt +head 1, '@', 2, l@ +head 1, '!', 2, l! +head 2, 'c@', 2, lc@ +head 2, 'c!', 2, lc! +head 2, '1+', 2, linc +head 2, '1-', 2, ldec +head 1, '>', 2, lcmpg +head 1, '<', 2, lcmpl +head 3, 'ret', 2, lret +head 1, '+', 2, lplus +head 1, '-', 2, lminus +head 1, '*', 2, lmul +head 4, 'drop', 2, ldrop +head 3, 'dup', 2, ldup +head 4, 'swap', 2, lswap +head 5, 'disk@', 2, ldisk@ +head 4, 'push', 2, lpush +head 3, 'pop', 2, lpop +head 4, 'over', 2, lover +head 5, 'cmove', 2, lcmove +head 2, 'ne', 1, lne +head 1, ':', 1, lcolon +head 1, 'I', 2, lI +head 5, 'bcode', 1, bcode +head 4, 'dadd', 1, ldadd +head 6, 'incmod', 1, lincmod +head 2, 'if', 2, lif +head 4, 'here', 1, lhere +head 2, 'do', 2, ldo +head 3, 'for', 2, lfor +head 5, 'until', 2, luntil +head 4, 'prev', 0, lprev +head 4, 'skey', 1, lskey +lastp: +head 1, 'h', 0, lh +lend: diff --git a/kernel/core.raw b/kernel/core.raw new file mode 100755 index 0000000..b6a66f9 Binary files /dev/null and b/kernel/core.raw differ diff --git a/kernel/define.inc b/kernel/define.inc new file mode 100755 index 0000000..e8785af --- /dev/null +++ b/kernel/define.inc @@ -0,0 +1,79 @@ +; Virtual CPU machine code definitions +; For assembling with FASM (Flat Assembler). +; Rest is defined in highlevel code. + +macro xnop +{ db 0 } +macro xhalt +{ db 1 } +macro kbd@ +{ db 2 } +macro xnum arg1 +{ db 3 + dd arg1 } +macro head arg1, arg2, arg3, arg4 +{ dd link + link = $-4 + db arg1 + db arg2 + len = (24-5)-($-link) + times len db 177 + db arg3 + dd arg4 } +macro xjmp arg1 +{ db 4 + dd arg1 } +macro xcall arg1 +{ db 5 + dd arg1 } +macro xinc +{ db 6 } +macro xdec +{ db 7 } +macro xdup +{ db 8 } +macro xdrop +{ db 9 } +macro xif arg1 +{ db 10 + dd arg1 } +macro xret +{ db 11 } +macro xc@ +{ db 12 } +macro xc! +{ db 13 } +macro xpush +{ db 14 } +macro xpop +{ db 15 } +macro xrot +{ db 17 } +macro xdisk@ +{ db 18 } +macro xdisk! +{ db 19 } +macro x@ +{ db 20 } +macro x! +{ db 21 } +macro xover +{ db 22 } +macro xswap +{ db 23 } +macro xplus +{ db 24 } +macro xminus +{ db 25 } +macro xmul +{ db 26 } +macro xcmpg +{ db 28 } +macro xcmpl +{ db 29 } +macro xcprt! +{ db 33 } +macro xcmove +{ db 43 } +macro xcfill +{ db 44 } diff --git a/kernel/font.asm b/kernel/font.asm new file mode 100755 index 0000000..b1f5030 --- /dev/null +++ b/kernel/font.asm @@ -0,0 +1,2307 @@ +; Font for Fifth + + +; 0 +db 00000000b +db 00000000b +db 00111000b +db 00101000b +db 00111000b +db 00000000b +db 00000000b +db 00000000b +; 1 +db 11111110b +db 01111100b +db 00111000b +db 00101000b +db 00111000b +db 00000000b +db 00000000b +db 00000000b +; 2 +db 00000010b +db 00000110b +db 00111110b +db 00101110b +db 00111110b +db 00000110b +db 00000010b +db 00000000b +; 3 +db 11111110b +db 01111110b +db 00111110b +db 00101110b +db 00111110b +db 00000110b +db 00000010b +db 00000000b +; 4 +db 00000000b +db 00000000b +db 00111000b +db 00101000b +db 00111000b +db 01111100b +db 11111110b +db 00000000b +; 5 +db 11111110b +db 01111100b +db 00111000b +db 00101000b +db 00111000b +db 01111100b +db 11111110b +db 00000000b +; 6 +db 00000010b +db 00000110b +db 00111110b +db 00101110b +db 00111110b +db 01111110b +db 11111110b +db 00000000b +; 7 +db 11111110b +db 01111110b +db 00111110b +db 00101110b +db 00111110b +db 01111110b +db 11111110b +db 00000000b +; 8 +db 10000000b +db 11000000b +db 11111000b +db 11101000b +db 11111000b +db 11000000b +db 10000000b +db 00000000b +; 9 +db 11111110b +db 11111100b +db 11111000b +db 11101000b +db 11111000b +db 11000000b +db 10000000b +db 00000000b +; 10 +db 10000010b +db 11000110b +db 11111110b +db 11101110b +db 11111110b +db 11000110b +db 10000010b +db 00000000b +; 11 +db 11111110b +db 11111110b +db 11111110b +db 11101110b +db 11111110b +db 11000110b +db 10000010b +db 00000000b +; 12 +db 10000000b +db 11000000b +db 11111000b +db 11101000b +db 11111000b +db 11111100b +db 11111110b +db 00000000b +; 13 +db 11111110b +db 11111100b +db 11111000b +db 11101000b +db 11111000b +db 11111100b +db 11111110b +db 00000000b +; 14 +db 10000010b +db 11000110b +db 11111110b +db 11101110b +db 11111110b +db 11111110b +db 11111110b +db 00000000b +; 15 +db 11111110b +db 11111110b +db 11111110b +db 11101110b +db 11111110b +db 11111110b +db 11111110b +db 00000000b +; 16 +db 10000000b +db 11100000b +db 11111000b +db 11111110b +db 11111000b +db 11100000b +db 10000000b +db 00000000b +; 17 +db 00000010b +db 00001110b +db 00111110b +db 11111110b +db 00111110b +db 00001110b +db 00000010b +db 00000000b +; 18 +db 00011000b +db 00111100b +db 01111110b +db 00011000b +db 00011000b +db 01111110b +db 00111100b +db 00011000b +; 19 +db 01100110b +db 01100110b +db 01100110b +db 01100110b +db 01100110b +db 00000000b +db 01100110b +db 00000000b +; 20 +db 01111111b +db 11011011b +db 11011011b +db 01111011b +db 00011011b +db 00011011b +db 00011011b +db 00000000b +; 21 +db 00111110b +db 01100011b +db 00111000b +db 01101100b +db 01101100b +db 00111000b +db 10000110b +db 11111100b +; 22 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 01111110b +db 01111110b +db 01111110b +db 00000000b +; 23 +db 00011000b +db 00111100b +db 01111110b +db 00011000b +db 01111110b +db 00111100b +db 00011000b +db 11111111b +; 24 +db 00011000b +db 00111100b +db 01111110b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00000000b +; 25 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 01111110b +db 00111100b +db 00011000b +db 00000000b +; 26 +db 00000000b +db 00011000b +db 00001100b +db 11111110b +db 00001100b +db 00011000b +db 00000000b +db 00000000b +; 27 +db 00000000b +db 00110000b +db 01100000b +db 11111110b +db 01100000b +db 00110000b +db 00000000b +db 00000000b +; 28 +db 00000000b +db 00110000b +db 01100000b +db 11111110b +db 01100000b +db 00110000b +db 00000000b +db 00000000b +; 29 +db 00000000b +db 00110000b +db 01100000b +db 11111110b +db 01100000b +db 00110000b +db 00000000b +db 00000000b +; 30 +db 00000000b +db 00110000b +db 01100000b +db 11111110b +db 01100000b +db 00110000b +db 00000000b +db 00000000b +; 31 +db 00000000b +db 00110000b +db 01100000b +db 11111110b +db 01100000b +db 00110000b +db 00000000b +db 00000000b +; 32 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; ! 33 +db 00011000b +db 00111100b +db 00111100b +db 00011000b +db 00011000b +db 00000000b +db 00011000b +db 00000000b +; " 34 +db 01101100b +db 01101100b +db 01101100b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; # 35 +db 01101100b +db 01101100b +db 11111110b +db 01101100b +db 11111110b +db 01101100b +db 01101100b +db 00000000b +; $ 36 +db 00011000b +db 01111110b +db 11000000b +db 01111100b +db 00000110b +db 11111100b +db 00011000b +db 00000000b +; % 37 +db 00000000b +db 11000110b +db 11001100b +db 00011000b +db 00110000b +db 01100110b +db 11000110b +db 00000000b +; & 38 +db 00111000b +db 01101100b +db 00111000b +db 01110110b +db 11011100b +db 11001100b +db 01110110b +db 00000000b +; ' 39 +db 00110000b +db 00110000b +db 01100000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; ( 40 +db 00011000b +db 00110000b +db 01100000b +db 01100000b +db 01100000b +db 00110000b +db 00011000b +db 00000000b +; ) 41 +db 01100000b +db 00110000b +db 00011000b +db 00011000b +db 00011000b +db 00110000b +db 01100000b +db 00000000b +; * 42 +db 00000000b +db 01100110b +db 00111100b +db 11111111b +db 00111100b +db 01100110b +db 00000000b +db 00000000b +; + 43 +db 00000000b +db 00011000b +db 00011000b +db 01111110b +db 00011000b +db 00011000b +db 00000000b +db 00000000b +; , 44 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00011000b +db 00011000b +db 00110000b +; - 45 +db 00000000b +db 00000000b +db 00000000b +db 01111110b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; . 46 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00011000b +db 00011000b +db 00000000b +; / 47 +db 00000110b +db 00001100b +db 00011000b +db 00110000b +db 01100000b +db 11000000b +db 10000000b +db 00000000b +; 0 48 +db 01111100b +db 11001110b +db 11011110b +db 11110110b +db 11100110b +db 11000110b +db 01111100b +db 00000000b +; 1 49 +db 00110000b +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 11111100b +db 00000000b +; 2 50 +db 01111000b +db 11001100b +db 00001100b +db 00111000b +db 01100000b +db 11001100b +db 11111100b +db 00000000b +; 3 51 +db 01111000b +db 11001100b +db 00001100b +db 00111000b +db 00001100b +db 11001100b +db 01111000b +db 00000000b +; 4 52 +db 00011100b +db 00111100b +db 01101100b +db 11001100b +db 11111110b +db 00001100b +db 00011110b +db 00000000b +; 5 53 +db 11111100b +db 11000000b +db 11111000b +db 00001100b +db 00001100b +db 11001100b +db 01111000b +db 00000000b +; 6 54 +db 00111000b +db 01100000b +db 11000000b +db 11111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; 7 55 +db 11111100b +db 11001100b +db 00001100b +db 00011000b +db 00110000b +db 00110000b +db 00110000b +db 00000000b +; 8 56 +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; 9 57 +db 01111000b +db 11001100b +db 11001100b +db 01111100b +db 00001100b +db 00011000b +db 01110000b +db 00000000b +; : 58 +db 00000000b +db 00011000b +db 00011000b +db 00000000b +db 00000000b +db 00011000b +db 00011000b +db 00000000b +; ; 59 +db 00000000b +db 00011000b +db 00011000b +db 00000000b +db 00000000b +db 00011000b +db 00011000b +db 00110000b +; < 60 +db 00011000b +db 00110000b +db 01100000b +db 11000000b +db 01100000b +db 00110000b +db 00011000b +db 00000000b +; = 61 +db 00000000b +db 00000000b +db 01111110b +db 00000000b +db 01111110b +db 00000000b +db 00000000b +db 00000000b +; > 62 +db 01100000b +db 00110000b +db 00011000b +db 00001100b +db 00011000b +db 00110000b +db 01100000b +db 00000000b +; ? 63 +db 00111100b +db 01100110b +db 00001100b +db 00011000b +db 00011000b +db 00000000b +db 00011000b +db 00000000b +; @ 64 +db 01111100b +db 11000110b +db 11011110b +db 11011110b +db 11011100b +db 11000000b +db 01111100b +db 00000000b +; A 65 +db 00110000b +db 01111000b +db 11001100b +db 11001100b +db 11111100b +db 11001100b +db 11001100b +db 00000000b +; B 66 +db 11111100b +db 01100110b +db 01100110b +db 01111100b +db 01100110b +db 01100110b +db 11111100b +db 00000000b +; C 67 +db 00111100b +db 01100110b +db 11000000b +db 11000000b +db 11000000b +db 01100110b +db 00111100b +db 00000000b +; D 68 +db 11111000b +db 01101100b +db 01100110b +db 01100110b +db 01100110b +db 01101100b +db 11111000b +db 00000000b +; E 69 +db 11111110b +db 01100010b +db 01101000b +db 01111000b +db 01101000b +db 01100010b +db 11111110b +db 00000000b +; F 70 +db 11111110b +db 01100010b +db 01101000b +db 01111000b +db 01101000b +db 01100000b +db 11110000b +db 00000000b +; G 71 +db 00111100b +db 01100110b +db 11000000b +db 11000000b +db 11001110b +db 01100110b +db 00111010b +db 00000000b +; H 72 +db 11001100b +db 11001100b +db 11001100b +db 11111100b +db 11001100b +db 11001100b +db 11001100b +db 00000000b +; I 73 +db 01111000b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; J 74 +db 00011110b +db 00001100b +db 00001100b +db 00001100b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; K 75 +db 11100110b +db 01100110b +db 01101100b +db 01111000b +db 01101100b +db 01100110b +db 11100110b +db 00000000b +; L 76 +db 11110000b +db 01100000b +db 01100000b +db 01100000b +db 01100010b +db 01100110b +db 11111110b +db 00000000b +; M 77 +db 11000110b +db 11101110b +db 11111110b +db 11111110b +db 11010110b +db 11000110b +db 11000110b +db 00000000b +; N 78 +db 11000110b +db 11100110b +db 11110110b +db 11011110b +db 11001110b +db 11000110b +db 11000110b +db 00000000b +; O 79 +db 00111000b +db 01101100b +db 11000110b +db 11000110b +db 11000110b +db 01101100b +db 00111000b +db 00000000b +; P 80 +db 11111100b +db 01100110b +db 01100110b +db 01111100b +db 01100000b +db 01100000b +db 11110000b +db 00000000b +; Q 81 +db 01111100b +db 11000110b +db 11000110b +db 11000110b +db 11010110b +db 01111100b +db 00001110b +db 00000000b +; R 82 +db 11111100b +db 01100110b +db 01100110b +db 01111100b +db 01101100b +db 01100110b +db 11100110b +db 00000000b +; S 83 +db 01111100b +db 11000110b +db 11100000b +db 01111000b +db 00001110b +db 11000110b +db 01111100b +db 00000000b +; T 84 +db 11111100b +db 10110100b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; U 85 +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11111100b +db 00000000b +; V 86 +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 01111000b +db 00110000b +db 00000000b +; W 87 +db 11000110b +db 11000110b +db 11000110b +db 11000110b +db 11010110b +db 11111110b +db 01101100b +db 00000000b +; X 88 +db 11000110b +db 11000110b +db 01101100b +db 00111000b +db 01101100b +db 11000110b +db 11000110b +db 00000000b +; Y 89 +db 11001100b +db 11001100b +db 11001100b +db 01111000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; Z 90 +db 11111110b +db 11000110b +db 10001100b +db 00011000b +db 00110010b +db 01100110b +db 11111110b +db 00000000b +; [ 91 +db 01111000b +db 01100000b +db 01100000b +db 01100000b +db 01100000b +db 01100000b +db 01111000b +db 00000000b +; \ 92 +db 11000000b +db 01100000b +db 00110000b +db 00011000b +db 00001100b +db 00000110b +db 00000010b +db 00000000b +; ] 93 +db 01111000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 01111000b +db 00000000b +; ^ 94 +db 00010000b +db 00111000b +db 01101100b +db 11000110b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; _ 95 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111111b +; ` 96 +db 00110000b +db 00110000b +db 00011000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; a 97 +db 00000000b +db 00000000b +db 01111000b +db 00001100b +db 01111100b +db 11001100b +db 01110110b +db 00000000b +; b 98 +db 11100000b +db 01100000b +db 01100000b +db 01111100b +db 01100110b +db 01100110b +db 11011100b +db 00000000b +; c 99 +db 00000000b +db 00000000b +db 01111000b +db 11001100b +db 11000000b +db 11001100b +db 01111000b +db 00000000b +; d 100 +db 00011100b +db 00001100b +db 00001100b +db 01111100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; e 101 +db 00000000b +db 00000000b +db 01111000b +db 11001100b +db 11111100b +db 11000000b +db 01111000b +db 00000000b +; f 102 +db 00111000b +db 01101100b +db 01100100b +db 11110000b +db 01100000b +db 01100000b +db 11110000b +db 00000000b +; g 103 +db 00000000b +db 00000000b +db 01110110b +db 11001100b +db 11001100b +db 01111100b +db 00001100b +db 11111000b +; h 104 +db 11100000b +db 01100000b +db 01101100b +db 01110110b +db 01100110b +db 01100110b +db 11100110b +db 00000000b +; i 105 +db 00110000b +db 00000000b +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; j 106 +db 00001100b +db 00000000b +db 00011100b +db 00001100b +db 00001100b +db 11001100b +db 11001100b +db 01111000b +; k 107 +db 11100000b +db 01100000b +db 01100110b +db 01101100b +db 01111000b +db 01101100b +db 11100110b +db 00000000b +; l 108 +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; m 109 +db 00000000b +db 00000000b +db 11001100b +db 11111110b +db 11111110b +db 11010110b +db 11010110b +db 00000000b +; n 110 +db 00000000b +db 00000000b +db 10111000b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 00000000b +; o 111 +db 00000000b +db 00000000b +db 01111000b +db 11001100b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; p 112 +db 00000000b +db 00000000b +db 11011100b +db 01100110b +db 01100110b +db 01111100b +db 01100000b +db 11110000b +; q 113 +db 00000000b +db 00000000b +db 01110110b +db 11001100b +db 11001100b +db 01111100b +db 00001100b +db 00011110b +; r 114 +db 00000000b +db 00000000b +db 11011100b +db 01110110b +db 01100010b +db 01100000b +db 11110000b +db 00000000b +; s 115 +db 00000000b +db 00000000b +db 01111100b +db 11000000b +db 01110000b +db 00011100b +db 11111000b +db 00000000b +; t 116 +db 00010000b +db 00110000b +db 11111100b +db 00110000b +db 00110000b +db 00110100b +db 00011000b +db 00000000b +; u 117 +db 00000000b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; v 118 +db 00000000b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01111000b +db 00110000b +db 00000000b +; w 119 +db 00000000b +db 00000000b +db 11000110b +db 11000110b +db 11010110b +db 11111110b +db 01101100b +db 00000000b +; x 120 +db 00000000b +db 00000000b +db 11000110b +db 01101100b +db 00111000b +db 01101100b +db 11000110b +db 00000000b +; y 121 +db 00000000b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01111100b +db 00001100b +db 11111000b +; z 122 +db 00000000b +db 00000000b +db 11111100b +db 10011000b +db 00110000b +db 01100100b +db 11111100b +db 00000000b +; { 123 +db 00011100b +db 00110000b +db 00110000b +db 11100000b +db 00110000b +db 00110000b +db 00011100b +db 00000000b +; | 124 +db 00011000b +db 00011000b +db 00011000b +db 00000000b +db 00011000b +db 00011000b +db 00011000b +db 00000000b +; } 125 +db 11100000b +db 00110000b +db 00110000b +db 00011100b +db 00110000b +db 00110000b +db 11100000b +db 00000000b +; ~ 126 +db 01110110b +db 11011100b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +;  127 +db 00000000b +db 00010000b +db 00111000b +db 01101100b +db 11000110b +db 11000110b +db 11111110b +db 00000000b +; � 128 +db 01111100b +db 11000110b +db 11000000b +db 11000110b +db 01111100b +db 00001100b +db 00000110b +db 01111100b +; � 129 +db 00000000b +db 11001100b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; � 130 +db 00011100b +db 00000000b +db 01111000b +db 11001100b +db 11111100b +db 11000000b +db 01111000b +db 00000000b +; � 131 +db 01111110b +db 10000001b +db 00111100b +db 00000110b +db 00111110b +db 01100110b +db 00111011b +db 00000000b +; � 132 +db 11001100b +db 00000000b +db 01111000b +db 00001100b +db 01111100b +db 11001100b +db 01110110b +db 00000000b +; � 133 +db 11100000b +db 00000000b +db 01111000b +db 00001100b +db 01111100b +db 11001100b +db 01110110b +db 00000000b +; � 134 +db 00110000b +db 00110000b +db 01111000b +db 00001100b +db 01111100b +db 11001100b +db 01110110b +db 00000000b +; � 135 +db 00000000b +db 00000000b +db 01111100b +db 11000110b +db 11000000b +db 01111000b +db 00001100b +db 00111000b +; � 136 +db 01111110b +db 10000001b +db 00111100b +db 01100110b +db 01111110b +db 01100000b +db 00111100b +db 00000000b +; � 137 +db 11001100b +db 00000000b +db 01111000b +db 11001100b +db 11111100b +db 11000000b +db 01111000b +db 00000000b +; � 138 +db 11100000b +db 00000000b +db 01111000b +db 11001100b +db 11111100b +db 11000000b +db 01111000b +db 00000000b +; � 139 +db 11001100b +db 00000000b +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; � 140 +db 01111100b +db 10000010b +db 00111000b +db 00011000b +db 00011000b +db 00011000b +db 00111100b +db 00000000b +; � 141 +db 11100000b +db 00000000b +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; � 142 +db 11000110b +db 00010000b +db 01111100b +db 11000110b +db 11111110b +db 11000110b +db 11000110b +db 00000000b +; � 143 +db 00110000b +db 00110000b +db 00000000b +db 01111000b +db 11001100b +db 11111100b +db 11001100b +db 00000000b +; � 144 +db 00011100b +db 00000000b +db 11111100b +db 01100000b +db 01111000b +db 01100000b +db 11111100b +db 00000000b +; � 145 +db 00000000b +db 00000000b +db 01111111b +db 00001100b +db 01111111b +db 11001100b +db 01111111b +db 00000000b +; � 146 +db 00111110b +db 01101100b +db 11001100b +db 11111110b +db 11001100b +db 11001100b +db 11001110b +db 00000000b +; � 147 +db 01111000b +db 10000100b +db 00000000b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 148 +db 00000000b +db 11001100b +db 00000000b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 149 +db 00000000b +db 11100000b +db 00000000b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 150 +db 01111000b +db 10000100b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; � 151 +db 00000000b +db 11100000b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; � 152 +db 00000000b +db 11001100b +db 00000000b +db 11001100b +db 11001100b +db 01111100b +db 00001100b +db 11111000b +; � 153 +db 11000011b +db 00011000b +db 00111100b +db 01100110b +db 01100110b +db 00111100b +db 00011000b +db 00000000b +; � 154 +db 11001100b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 155 +db 00011000b +db 00011000b +db 01111110b +db 11000000b +db 11000000b +db 01111110b +db 00011000b +db 00011000b +; � 156 +db 00111000b +db 01101100b +db 01100100b +db 11110000b +db 01100000b +db 11100110b +db 11111100b +db 00000000b +; � 157 +db 11001100b +db 11001100b +db 01111000b +db 00110000b +db 11111100b +db 00110000b +db 11111100b +db 00110000b +; � 158 +db 11111000b +db 11001100b +db 11001100b +db 11111010b +db 11000110b +db 11001111b +db 11000110b +db 11000011b +; � 159 +db 00001110b +db 00011011b +db 00011000b +db 00111100b +db 00011000b +db 00011000b +db 11011000b +db 01110000b +; � 160 +db 00011100b +db 00000000b +db 01111000b +db 00001100b +db 01111100b +db 11001100b +db 01110110b +db 00000000b +; � 161 +db 00111000b +db 00000000b +db 01110000b +db 00110000b +db 00110000b +db 00110000b +db 01111000b +db 00000000b +; � 162 +db 00000000b +db 00011100b +db 00000000b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 163 +db 00000000b +db 00011100b +db 00000000b +db 11001100b +db 11001100b +db 11001100b +db 01110110b +db 00000000b +; � 164 +db 00000000b +db 11111000b +db 00000000b +db 10111000b +db 11001100b +db 11001100b +db 11001100b +db 00000000b +; � 165 +db 11111100b +db 00000000b +db 11001100b +db 11101100b +db 11111100b +db 11011100b +db 11001100b +db 00000000b +; � 166 +db 00111100b +db 01101100b +db 01101100b +db 00111110b +db 00000000b +db 01111110b +db 00000000b +db 00000000b +; � 167 +db 00111000b +db 01101100b +db 01101100b +db 00111000b +db 00000000b +db 01111100b +db 00000000b +db 00000000b +; � 168 +db 00011000b +db 00000000b +db 00011000b +db 00011000b +db 00110000b +db 01100110b +db 00111100b +db 00000000b +; � 169 +db 00000000b +db 00000000b +db 00000000b +db 11111100b +db 11000000b +db 11000000b +db 00000000b +db 00000000b +; � 170 +db 00000000b +db 00000000b +db 00000000b +db 11111100b +db 00001100b +db 00001100b +db 00000000b +db 00000000b +; � 171 +db 11000110b +db 11001100b +db 11011000b +db 00110110b +db 01101011b +db 11000010b +db 10000100b +db 00001111b +; � 172 +db 11000011b +db 11000110b +db 11001100b +db 11011011b +db 00110111b +db 01101101b +db 11001111b +db 00000011b +; � 173 +db 00011000b +db 00000000b +db 00011000b +db 00011000b +db 00111100b +db 00111100b +db 00011000b +db 00000000b +; � 174 +db 00000000b +db 00110011b +db 01100110b +db 11001100b +db 01100110b +db 00110011b +db 00000000b +db 00000000b +; � 175 +db 00000000b +db 11001100b +db 01100110b +db 00110011b +db 01100110b +db 11001100b +db 00000000b +db 00000000b +; � 176 +db 00100010b +db 10001000b +db 00100010b +db 10001000b +db 00100010b +db 10001000b +db 00100010b +db 10001000b +; � 177 +db 01010101b +db 10101010b +db 01010101b +db 10101010b +db 01010101b +db 10101010b +db 01010101b +db 10101010b +; � 178 +db 11011011b +db 11110110b +db 11011011b +db 01101111b +db 11011011b +db 01111110b +db 11010111b +db 11101101b +; � 179 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +; � 180 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 11111000b +db 00011000b +db 00011000b +db 00011000b +; � 181 +db 00011000b +db 00011000b +db 11111000b +db 00011000b +db 11111000b +db 00011000b +db 00011000b +db 00011000b +; � 182 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 11110110b +db 00110110b +db 00110110b +db 00110110b +; � 183 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111110b +db 00110110b +db 00110110b +db 00110110b +; � 184 +db 00000000b +db 00000000b +db 11111000b +db 00011000b +db 11111000b +db 00011000b +db 00011000b +db 00011000b +; � 185 +db 00110110b +db 00110110b +db 11110110b +db 00000110b +db 11110110b +db 00110110b +db 00110110b +db 00110110b +; � 186 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00110110b +; � 187 +db 00000000b +db 00000000b +db 11111110b +db 00000110b +db 11110110b +db 00110110b +db 00110110b +db 00110110b +; � 188 +db 00110110b +db 00110110b +db 11110110b +db 00000110b +db 11111110b +db 00000000b +db 00000000b +db 00000000b +; � 189 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 11111110b +db 00000000b +db 00000000b +db 00000000b +; � 190 +db 00011000b +db 00011000b +db 11111000b +db 00011000b +db 11111000b +db 00000000b +db 00000000b +db 00000000b +; � 191 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111000b +db 00011000b +db 00011000b +db 00011000b +; � 192 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011111b +db 00000000b +db 00000000b +db 00000000b +; � 193 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 194 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111111b +db 00011000b +db 00011000b +db 00011000b +; � 195 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011111b +db 00011000b +db 00011000b +db 00011000b +; � 196 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 197 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 11111111b +db 00011000b +db 00011000b +db 00011000b +; � 198 +db 00011000b +db 00011000b +db 00011111b +db 00011000b +db 00011111b +db 00011000b +db 00011000b +db 00011000b +; � 199 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00110111b +db 00110110b +db 00110110b +db 00110110b +; � 200 +db 00110110b +db 00110110b +db 00110111b +db 00110000b +db 00111111b +db 00000000b +db 00000000b +db 00000000b +; � 201 +db 00000000b +db 00000000b +db 00111111b +db 00110000b +db 00110111b +db 00110110b +db 00110110b +db 00110110b +; � 202 +db 00110110b +db 00110110b +db 11110111b +db 00000000b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 203 +db 00000000b +db 00000000b +db 11111111b +db 00000000b +db 11110111b +db 00110110b +db 00110110b +db 00110110b +; � 204 +db 00110110b +db 00110110b +db 00110111b +db 00110000b +db 00110111b +db 00110110b +db 00110110b +db 00110110b +; � 205 +db 00000000b +db 00000000b +db 11111111b +db 00000000b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 206 +db 00110110b +db 00110110b +db 11110111b +db 00000000b +db 11110111b +db 00110110b +db 00110110b +db 00110110b +; � 207 +db 00011000b +db 00011000b +db 11111111b +db 00000000b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 208 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +; � 209 +db 00000000b +db 00000000b +db 11111111b +db 00000000b +db 11111111b +db 00011000b +db 00011000b +db 00011000b +; � 210 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111111b +db 00110110b +db 00110110b +db 00110110b +; � 211 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 00111111b +db 00000000b +db 00000000b +db 00000000b +; � 212 +db 00011000b +db 00011000b +db 00011111b +db 00011000b +db 00011111b +db 00000000b +db 00000000b +db 00000000b +; � 213 +db 00000000b +db 00000000b +db 00011111b +db 00011000b +db 00011111b +db 00011000b +db 00011000b +db 00011000b +; � 214 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00111111b +db 00110110b +db 00110110b +db 00110110b +; � 215 +db 00110110b +db 00110110b +db 00110110b +db 00110110b +db 11111111b +db 00110110b +db 00110110b +db 00110110b +; � 216 +db 00011000b +db 00011000b +db 11111111b +db 00011000b +db 11111111b +db 00011000b +db 00011000b +db 00011000b +; � 217 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 11111000b +db 00000000b +db 00000000b +db 00000000b +; � 218 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00011111b +db 00011000b +db 00011000b +db 00011000b +; � 219 +db 11111111b +db 11111111b +db 11111111b +db 11111111b +db 11111111b +db 11111111b +db 11111111b +db 11111111b +; � 220 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 11111111b +db 11111111b +db 11111111b +db 11111111b +; � 221 +db 11110000b +db 11110000b +db 11110000b +db 11110000b +db 11110000b +db 11110000b +db 11110000b +db 11110000b +; � 222 +db 00001111b +db 00001111b +db 00001111b +db 00001111b +db 00001111b +db 00001111b +db 00001111b +db 00001111b +; � 223 +db 11111111b +db 11111111b +db 11111111b +db 11111111b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; � 224 +db 00000000b +db 00000000b +db 01110110b +db 11011100b +db 11001000b +db 11011100b +db 01110110b +db 00000000b +; � 225 +db 00000000b +db 01111000b +db 11001100b +db 11111000b +db 11001100b +db 11111000b +db 11000000b +db 11000000b +; � 226 +db 00000000b +db 11111100b +db 11001100b +db 11000000b +db 11000000b +db 11000000b +db 11000000b +db 00000000b +; � 227 +db 00000000b +db 00000000b +db 11111110b +db 01101100b +db 01101100b +db 01101100b +db 01101100b +db 00000000b +; � 228 +db 11111100b +db 11001100b +db 01100000b +db 00110000b +db 01100000b +db 11001100b +db 11111100b +db 00000000b +; � 229 +db 00000000b +db 00000000b +db 01111110b +db 11011000b +db 11011000b +db 11011000b +db 01110000b +db 00000000b +; � 230 +db 00000000b +db 01100110b +db 01100110b +db 01100110b +db 01100110b +db 01111100b +db 01100000b +db 11000000b +; � 231 +db 00000000b +db 01110110b +db 11011100b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00000000b +; � 232 +db 11111100b +db 00110000b +db 01111000b +db 11001100b +db 11001100b +db 01111000b +db 00110000b +db 11111100b +; � 233 +db 00111000b +db 01101100b +db 11000110b +db 11111110b +db 11000110b +db 01101100b +db 00111000b +db 00000000b +; � 234 +db 00111000b +db 01101100b +db 11000110b +db 11000110b +db 01101100b +db 01101100b +db 11101110b +db 00000000b +; � 235 +db 00011100b +db 00110000b +db 00011000b +db 01111100b +db 11001100b +db 11001100b +db 01111000b +db 00000000b +; � 236 +db 00000000b +db 00000000b +db 01111110b +db 11011011b +db 11011011b +db 01111110b +db 00000000b +db 00000000b +; � 237 +db 00000110b +db 00001100b +db 01111110b +db 11011011b +db 11011011b +db 01111110b +db 01100000b +db 11000000b +; � 238 +db 00111000b +db 01100000b +db 11000000b +db 11111000b +db 11000000b +db 01100000b +db 00111000b +db 00000000b +; � 239 +db 01111000b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 11001100b +db 00000000b +; � 240 +db 00000000b +db 01111110b +db 00000000b +db 01111110b +db 00000000b +db 01111110b +db 00000000b +db 00000000b +; � 241 +db 00011000b +db 00011000b +db 01111110b +db 00011000b +db 00011000b +db 00000000b +db 01111110b +db 00000000b +; � 242 +db 01100000b +db 00110000b +db 00011000b +db 00110000b +db 01100000b +db 00000000b +db 11111100b +db 00000000b +; � 243 +db 00011000b +db 00110000b +db 01100000b +db 00110000b +db 00011000b +db 00000000b +db 11111100b +db 00000000b +; � 244 +db 00001110b +db 00011011b +db 00011011b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +; � 245 +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 00011000b +db 11011000b +db 11011000b +db 01110000b +; � 246 +db 00011000b +db 00011000b +db 00000000b +db 01111110b +db 00000000b +db 00011000b +db 00011000b +db 00000000b +; � 247 +db 00000000b +db 01110110b +db 11011100b +db 00000000b +db 01110110b +db 11011100b +db 00000000b +db 00000000b +; � 248 +db 00111000b +db 01101100b +db 01101100b +db 00111000b +db 00000000b +db 00000000b +db 00000000b +db 00000000b +; � 249 +db 00000000b +db 00000000b +db 00000000b +db 00011000b +db 00011000b +db 00000000b +db 00000000b +db 00000000b +; � 250 +db 00000000b +db 00000000b +db 00000000b +db 00000000b +db 00011000b +db 00000000b +db 00000000b +db 00000000b +; � 251 +db 00001111b +db 00001100b +db 00001100b +db 00001100b +db 11101100b +db 01101100b +db 00111100b +db 00011100b +; � 252 +db 01011000b +db 01101100b +db 01101100b +db 01101100b +db 01101100b +db 00000000b +db 00000000b +db 00000000b +; � 253 +db 01110000b +db 10011000b +db 00110000b +db 01100000b +db 11111000b +db 00000000b +db 00000000b +db 00000000b +; � 254 +db 00000000b +db 00000000b +db 00111100b +db 00111100b +db 00111100b +db 00111100b +db 00000000b +db 00000000b +; � 255 +db 10001000b +db 00000000b +db 00000000b +db 00000000b +db 10000000b +db 00000000b +db 00000000b +db 00000000b diff --git a/util/5th2src.bas b/util/5th2src.bas new file mode 100755 index 0000000..b147cc1 --- /dev/null +++ b/util/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/util/editor.bas b/util/editor.bas new file mode 100755 index 0000000..313b6e8 --- /dev/null +++ b/util/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/util/font.dat b/util/font.dat new file mode 100755 index 0000000..980f716 Binary files /dev/null and b/util/font.dat differ diff --git a/util/fsimport.bas b/util/fsimport.bas new file mode 100755 index 0000000..0d7e1ff --- /dev/null +++ b/util/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/util/insert.bas b/util/insert.bas new file mode 100755 index 0000000..d40265f --- /dev/null +++ b/util/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/util/src25th.bas b/util/src25th.bas new file mode 100755 index 0000000..af0a924 --- /dev/null +++ b/util/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 +