Jump to content
TheBF

Camel99 Forth Information goes here

Recommended Posts

ED99 SAMS Library Option for faster editor performance

 

The published source code for ED99 uses the DSK1.SAMSFTH library file which allows SAMS card access written in Forth.

There is a native code version of the same functionality called DSK1.SAMS.  You can improve the SAMS speed by about 40% by using this library.

 

Open the source code for ED99 in an editor and look and the NEEDS lines at the top the file.

Change the line  FROM DSK1.SAMSFTH   -to-   FROM DSK1.SAMS

 

When you recompile ED99 you will find that memory purges, file loads and saves are faster and scrolling line by line is faster as well.

 

Classic99 QI399.025 2020-06-20 12_06_39 PM.png

  • Like 1

Share this post


Link to post
Share on other sites

ED99  V1.0

 

I am finally modestly content with the ED99 editor.  Here is ZIP file with the whole thing wrapped up as an EA5 program. (Thanks Tursi for that amazing emulator)

I also uploaded a video showing ED99 in operation so people can get a quick start on how to use it.

 

Features I like:

  • Cut and Paste to a line clipboard
  • DIR and CAT commands available at command line
  • Holds 10 files simultaneously.  (needs 1M SAMS card)  

(Not mentioned in the video but the Forth DSK1.TOOLS is buried inside the editor so you actually have a working Forth development system here) :) 

 

Also DSK1.ED99DOC now also has the BYE command documented. No need to turn off the machine)

 

 

Things to add:  

  • Expand the max file size beyond 511 lines
    •  Might have to change the internal data organization
  • And some UNDO capability
  • File MERGE command
  • File COPY command
  • File PRINT command via RS232. (background is the goal) 

ED99.DSK.zip

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I have to admit that it looks pretty slick and lightning fast to boot! I love the feature of having multiple files open and the ability to copy and paste from one file to the other. Extremely handy feature, although a block copy/paste function would probably be even more practical. And the fact that the Forth command line is accessible with disk directories and such adds to the usefulness. 

Wish list:

  • Files larger than 511 lines
  • 80 columns support with the F18A
  • Printing to PIO (I like my old trusty dot-matrix parallel printer :) )

It seems that lately we're having a renaissance in editors with Supernotes, Stevie and now ED99!

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you. This is the first big application I have released to the community beyond the Forth system itself so I am a little shy.

 

I noticed the "outbreak" of editors too. Maybe it's another virus circulating. :) 

 

Ok I am with you on all those features.  I can expand the exit window have more lines as well with a few tweeks if that has value to you.

  • Files larger than 511 lines   
    • I made a prototype that gave me 1000 lines. 
    • I am wasting tons of space using a record based internal structure which bugs me. I am looking at alternatives.
  • 80 columns support with the F18A 
    • It current runs in 80 columns out of the box but I have to preload my 80 column library first. I will make a version with that)
  • Printing to PIO (I like my old trusty dot-matrix parallel printer :) )
    • Cool!  I can make a PRINT command that takes the TI-99 device string as a parameter so you should be able to "print" to any legal TI-99 device.
    •  Ultimately I want PRINT to run as a separate task. That requires that I write my own drivers (PIO is pretty trivial) since the DSRs don't behave well in a cooperative environment.
  • BLOCK copy/paste
    • I have that on a todo list down the road.  I will need to provide an inverted char set which I can do simply enough, and select a keystroke to "mark" a section and a keystroke to copy the section to clipboard. (DOS used to use ENTER to end the marking process so that will do)
    •  Then I need a command key to paste the entire clipboard rather that just one line. Control P sounds like a mnemonic choice.  I can add control P pretty quickly.

I will keep noodling on this and post an update when I am happy with the results.

  • Like 4

Share this post


Link to post
Share on other sites

Lol.

I knew I could get a PASTEALL function going pretty quickly but it was easier than I thought. :)

Here is the code:

: PASTEALL
        BEGIN
          CLIPBOARD?
        WHILE
          INSRT-LINE CLIP2LINE
          SPINNER
        REPEAT
        LIST UPDATED ;

 

  • Like 2

Share this post


Link to post
Share on other sites

Like alot what I’m seeing. Congrats on the hard work on this. Having such a powerful system underneath does open quite a lot of interesting opportunities.

 

Looking forward seeing how this further develops. 👌

  • Like 2

Share this post


Link to post
Share on other sites
Posted (edited)

The weirdest bug

 

Last month I went through my VDP routines to make them compliant with advice from Tursi that hitting the VDP ports in any way with Interrupts on was a no/no.

I was still randomly getting an error every now and again in the debugger but I couldn't pin-point when it would happen.

I opened up the heat map for a different reason yesterday and I saw this line running slowly through the entire memory map!

When the line hit the VDP port addresses that green comet flew through the heatmap. :) 

 

I traced it to the code that runs when a Forth variable runs.  The cursor variable was being repeatedly read in the input loop.

CODE: DOVAR   ( -- addr) \ Executor that executes a "VARIABLE"
      *SP     DECT,    \ make room in TOS
       R4 *SP MOV,     \ mov TOS register to stack
       R8  R4 MOV,     \ put contents of PFA in TOS
      NEXT,
 END-CODE

I still do not know why it did it.  I moved the code to another place in the source code so see what would happen...

The line  went away but I am still seeing: Warning: PC >A072 reading VDP with LIMI 2 

It is still happening at address >A072 but a different piece of code is there now.

 

More sleuthing to do.

It's tough when you use homemade tools. :) 

HEATMAP_WEIRDBUG.png

Edited by TheBF
typo
  • Like 2

Share this post


Link to post
Share on other sites

Searching for Text

 

Just like GDMike I need a search routine for ED99.  I had done some work to create a new Forth2012 word but it was clunky. It used a pre-defined buffer for the input string which is really not cool.

I think I have something better now. 

The hard core part is COMPARE and in Camel99 Forth it is build onto top of an Assembler word from the original Camel Forth called S=.


 CODE S=  ( Caddr1 Caddr2 cnt1 -- n )
    R2 POP,                   \ adrs2 -> R2
    R1 POP,                   \ adrs1 -> R1
    TOS R0 MOV,               \ cnt -> R0
    TOS CLR,                  \ clear output flag (0 means a match)
    NE IF,                    \ if count<>0 do search
       BEGIN,
         R1 *+ R2 *+ CMPB,    \ compare & auto increment
          NE IF,              \ mismatch found,
              LT IF, TOS DEC, \ $1<$2
              ELSE,  TOS INC, \ $1>$2
              ENDIF,
              NEXT,           \ Return to Forth
          ENDIF,
          R0 DEC,             \ decr. loop counter
       EQ UNTIL,              \ loop while R0 > 0
   ENDIF,
   NEXT,                      \ Return to Forth
   ENDCODE

It's very low overhead to make S= function like ANS Forth COMPARE

: COMPARE ( addr n addr2 n2 -- -1|0|1) ROT MIN S= ;

. I borrowed an idea from the late Neil Baud with 3RD and 4TH.  These routines work like PICK but are much faster. In fact on the 9900 they are the same two instructions as OVER.  

CODE 4TH ( a b c d -- a b c d a )  \ same speed as OVER
           TOS PUSH,
           6 (SP) TOS MOV,
           NEXT,            
           ENDCODE

Armed with that fire power I now have a proper SEARCH for the system.

\ search.fth  for Camel99 Forth     Brian Fox  26Jun2020
 ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 flag )
\ Search the string specified by c-addr1 u1 for the string specified by c-addr2
\ u2. If flag is true, a match was found at c-addr3 with u3 characters remaining
\ If flag is false there was no match and c-addr3 is c-addr1 and u3 is u1.
\

\ NEEDS DUMP   FROM DSK1.TOOLS  \ debug only
NEEDS 3RD     FROM DSK1.3RD4TH  \ CODE like OVER but for 3rd and 4th items
NEEDS COMPARE FROM DSK1.COMPARE

\ MARKER /SEARCH

( 2OVER is macro for more speed)
: 2OVER    ( d d2 -- d d2 d) POSTPONE 4TH  POSTPONE 4TH ; IMMEDIATE
: 4DUP     (  d d2  --  d d2 d d2) 2OVER 2OVER ;
: 2NIP     ( a b c d -- c d ) 2SWAP 2DROP ;

: SEARCH  ( string1 len1 string2 len2-- string3 len)
          2SWAP (  -- caddr2 u2 caddr1 u1 )
          BEGIN
             DUP ( test u1 )
          WHILE
             4DUP COMPARE
             0= IF 2NIP
                   TRUE
                   EXIT       \  jump to ';'
              THEN
             1 /STRING        \ remove 1st char
          REPEAT ;

 

  • Like 2

Share this post


Link to post
Share on other sites

Wow! I thought I caught a mistake in the code for S= , but no, there was that NEXT, !  I have got to remember that device. I must have some Forth Assembler in fbForth that could use that.

 

Similarly, your use of EXIT in SEARCH , for which I could probably use ;S in fbForth, but would have to check to see whether I could really get away with it.

 

Nicely done!

 

...lee

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

It breaks the the rule of structured programming for of one entry and one exit point, but it does give you some efficiency when it works out. :)

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, TheBF said:

It breaks the rule of structured programming for of one entry and one exit point, but it does give you some efficiency when it works out. :)

 

In that spirit, I would simply do R0 1 LI, instead of NEXT, inside the loop. Takes longer, I am sure, but honors the rule.

 

...lee

  • Like 2

Share this post


Link to post
Share on other sites

I take your point. It bugs me to do a register adjustment, to force a jump,  that then just ends up running NEXT. :( 

In a commercial project I would be obedient but here...

 

Maybe we can just keep this between us. :) 

  • Like 2
  • Haha 1

Share this post


Link to post
Share on other sites

ED99-40 column Beta Release

40 column multi-file editor

 

Changes:

Fixed problem: SAMS card was not initialized on startup. Worked on Classic99 failed on real hardware.

 

Clipboard no longer uses VDP RAM. The upper end of SAMS memory is used so 511 lines can be copied.

Fixed the ed99config file to use DSK1. to find the font to load.

Four font files have been included with the release.

 

Feature Additions

  •  FCNT 4 (break) will stop file loading.  The partial file will be in SAMS memory. Use PURGE if you don't want to keep it
  •  FCNT 4 (break) will stop file save. The partial file will be written to disk.
  •  CTRL A will copy entire file to clipboard.
  •  CTRL P will paste entire file to the END of the current file. (Insert can be too slow at this time)
  •  Number of lines in clipboard is displayed on lower right side of editing window
  •  PRINT command prints the active file to any DSR enabled device. 
    • Examples:  PRINT PIO, PRINT RS232.BA=9600 

Limitations

File size is still limited to 511 lines

Inserting to the top of a large file is still slow due to the simple internal data structure.

 

Future

80 Column version will have these features added and tested.

Single level undo/redo 

 

 

 

 

 





 

ED9940.DSK.zip

  • Like 2

Share this post


Link to post
Share on other sites

It's never a good idea to give your TI-99 extra work to do.

Tursi helped me find a big error in my kernel code for the execution code for variables, user variables, constants and DOES> words.

I went back to see the effect of not asking the system to do the extra instructions I had mistakenly made them do.

 

Here are two simple benchmarks the really improved:  ( confirmed them with a stop-watch because I didn't believe it either)

HEX 
VARIABLE X
: BENCH6  ( -- ) 7FFF 0 DO   X @ DROP  LOOP ;
\ Camel99 Forth
\ Version  v2.5     v2.62b
\ Seconds  7.6       5.5

\ Camel99 Forth
\ Version  v2.5     v2.62b
\ Seconds  7.1       5.4
: BENCH7 ( -- )  7FFF BEGIN  1- DUP  0= UNTIL ;

This larger benchmark improved but not as much:

\ Camel99 Forth
\ Version  V2.5  2.62b
\ Seconds  26.4   25.73

INCLUDE DSK1.VALUES

5 CONSTANT FIVE
0 VALUE BVAR
HEX
100 CONSTANT MASK
: BENCHIE     
         MASK 0
         DO
            1
            BEGIN
              DUP SWAP DUP ROT DROP 1 AND
              IF FIVE +
              ELSE 1-
              THEN TO BVAR
              BVAR DUP MASK AND
            UNTIL
            DROP
         LOOP ;

This version of the Sieve of Erathosenes improved nicely and actually is a touch faster than my previous Turbo Forth test.

This is also because in V2.6 I made HERE a code word.

 

Spoiler
\ Sieve of Erathosenes in Forth

NEEDS ELAPSE FROM DSK1.ELAPSE

: [@] ( n addr -- c)  + [email protected] ;
: [!] ( n addr -- )   + C! ;
: ERASE  ( addr n -- ) 0 FILL ;

HEX
: FREEMEM  ( -- n) FF00 HERE - ;
: ?MEM     ( n -- )  FREEMEM OVER < ABORT" Out of memory" ;

: SEEPRIMES ( -- )
        CR ." Primes: "
        2 DO
            I HERE [@] 0= IF I . THEN
            ?TERMINAL ABORT" Primes halted"
        LOOP ;

\ byte array uses unallocated memory at HERE
DECIMAL
: PRIMES ( n -- )
        ?MEM
        CR ." Running " DUP U. ." primes"
        HERE OVER ERASE
        1 0 HERE [!]       \ mark as prime like 'C' version
        1 1 HERE [!]
        2                  \ start at 2
        BEGIN
           2DUP DUP * >
        WHILE
           DUP HERE [@] 0=
           IF  2DUP DUP *
               DO
                  1 I HERE [!]
               DUP +LOOP
           THEN
           1+
        REPEAT
        CR ." Complete."
        .ELAPSED
        CR
        DROP
        CR ." Press ENTER to see primes:" KEY 13 =
        IF   SEEPRIMES   THEN
;

: RUN  10000 TICKER OFF PRIMES ;
\ Manual stop watch timings
\ Turbo Forth      7.9
\ Camel99          
\ V2.0             10.3 
\ V2.55            8.2
\ V2.62b           7.6
\
\ Camel99 DTC      7.2

 

 

 

 

Share this post


Link to post
Share on other sites
On 7/2/2020 at 8:16 PM, TheBF said:

ED99-40 column Beta Release

40 column multi-file editor

You really should create a separate topic for this so the rest of us can more easily follow updates :)

Share this post


Link to post
Share on other sites

So a couple of things I noticed with ED99-40:

  • Pressing <ENTER> after the first line inputted moves the line down and the cursor is positioned above it. It is not possible to enter text below that first line. Is this a feature or a bug?
  • Pasting with Ctrl-P pastes the contents of the clipboard after the End of File marker and adds yet another End of File marker. I would have thought that the pasted text will appear just above the EOF marker...

Otherwise it seems to work great. I still have to test the print function on real hardware though.

Share this post


Link to post
Share on other sites
1 hour ago, Vorticon said:

So a couple of things I noticed with ED99-40:

  • Pressing <ENTER> after the first line inputted moves the line down and the cursor is positioned above it. It is not possible to enter text below that first line. Is this a feature or a bug?
  • Pasting with Ctrl-P pastes the contents of the clipboard after the End of File marker and adds yet another End of File marker. I would have thought that the pasted text will appear just above the EOF marker...

Otherwise it seems to work great. I still have to test the print function on real hardware though.

These are bugs.  I am the ctrl P fixed.  Need to re-work the logic for Enter when at end of file.

I am interested in that print function. It's nothing special because it just uses the DSR so it worked find on real hardware with RS232.BA=9600  

PIO should work the same.

 

Thanks for the update.  80 column version is working. Will get something out tomorrow for you I hope.

Share this post


Link to post
Share on other sites
2 hours ago, Vorticon said:

You really should create a separate topic for this so the rest of us can more easily follow updates :)

Good point. I will do that.

Share this post


Link to post
Share on other sites

There are some very clever people in the Forth world.  I found this word in the system called 4TH by Hans Bezemer.  I coded it up in Camel99 Forth with assembler code.

This word lets you create very fast incrementor's and decrementors that operate like a constant that adds its value to the top of stack.

 

\ +CONSTANT  create incrementing/decrementing constants

NEEDS ADD,  FROM DSK1.ASM9900

: +CONSTANT     CREATE   ,
               ;CODE  *W  TOS ADD,
                            NEXT,
                ENDCODE

Very handy when you need to compute a fast offset from value on the stack.

DECIMAL

 16 +CONSTANT 16+
-16 +CONSTANT 16- 

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

*NEW* Camel99 Update V2.62c

I have changed the ZIP file with a correction to the "USER" word in this Version. This version runs on real iron. I am still working on the Supercart version.

 

Thanks to the expert interpretation by Tursi of an error I created in patching my cross-compiler we have what I believe it is now the most solid Camel99 kernel in this long history of my journey to cross-compile a Forth system for myself and the greater TI-99 community. 

 

We have CAMEL99 for conventional 32K RAM machines and CAMEL99SC for Supercart users and Classic99.

I have touched the DEMO programs on DSK3. and found a few warts that were fixed.  Notably the SNAKE game now works correctly. Try it. It is a little bit addictive. :) 

( After starting Forth type: INCLUDE DSK3.SNAKE )

 

I will update the previous post and remove the older version.   I also will rebuild the TTY version next week with these changes to the code base.

 

Release Notes:

 

Spoiler
Camel99 Forth V2.62b, System Release Notes  July 15, 2020
------------------------------------------------------------------------
This kernel version is 2.62b re-build of 2.62 with important corrections made 
to the cross-compiler. It was tested on the Classic99 emulator.

System Requirements
-----------------------
1. TI-994A 32K Expansion RAM or SAMS 1M card.

2. TI-99 RS232 Card or equivalent, with CRU address HEX 1300

3. DSK1. required  DSK2. is nice to have. DSK3 optional
=======================================================
CONTENTS of the ZIP file
------------------------
This release notes file and three(3) disk images.

Disk 1:  Forth kernel program for Expansion RAM and SUPERCART+Expansion RAM.
	 Libraries in source code (DV80 format)
         The best way to learn the libraries is to read the files and
         the demonstration programs on DSK3.
         
	PROGRAM NAME: CAMEL99, CAMEL99SC 
		      Start with editor/Assembler option 5.	

DISK 2:  Text editors for program development
         EDIT40 3.0 E/A5 program
         EDIT80 3.0 E/A5 program  (Classic99 or F18 card only)
	
DISK 3: Various demonstration programs
                                                
DSK3.ITC  
                              
10TASKS      1TASK        BEERS         
BGSOUND      COLORBARS    COOLSPRIT2    
COOLSPRITE   DENILE       DIJKSTRA      
FACE         FACTORIAL    GG_BASS       
GOODNILE     GROMLOGO     GUESS         
ILLUSION2    MATRIXMOVE   QUASIV2       
RNDCOLOR     SEVENS       SMPTE         
SNAKE        SOUNDS       STRINGCASE    
THEFLY       VDPBGSND     XBDEMOAUTO    
                                        
                           
                    


 

 

CAMEL99.262.zip

Edited by TheBF
Bug fix with USER variable creation
  • Like 6

Share this post


Link to post
Share on other sites

When you are making a compiler that is making a compiler ...

 

and you find a bug in the first compiler, it's probably a good idea to check the second compiler for the same bug.  :) 

 

While working on some SAMS card code I created a new user variable for R12.  I was benchmarking different code running through all the SAMS pages using that USER variable.

I have taken to having the heap map open on Classic99 and I saw a familiar signature.  😡

 

It turns out that all the data structures (variables, constants, user variables) that were generated by the cross compiler worked perfectly now in V2.62b

Unfortunately my method for creating these structures when running on the TI99 also needed fixing.  I ended up creating TI-99 CONSTANTs in the Forth kernel for the date interpreters DOVAR DOCON DOUSER and DODOES so that later on the TI99, Forth HAD got the correct addresses to plug into new definitions.

 

There will be a V2.62C coming after I beat it up a little more.  As of right now it seems good.

 

Making your own tools is humbling. 

 

  • Like 1

Share this post


Link to post
Share on other sites

Having just tested these new versions on real hardware I have discovered that they do not work on real hardware despite working perfectly on Class99.

I will have to use the real hardware as my reference and revert to previous versions. More to come...

Share this post


Link to post
Share on other sites

Hey man, I have been dabbling with CAMEL99 and I like it!  I have been reading through your instruction manual/tutorial and messing with the demos on .dsk 3.  Pretty cool stuff!  I like how you have made "modules" I guess I would call them...INCLUDE DSK.1 BASICHLP or whatever...AWESOME!   It it obvious you put a lot of thought and work into this.  I am still thoroughly confused about a lot of things FORTH but thats just me.  CAMEL99 is fantastic.  Thanks for all your hard work.   

  • Thanks 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...