Jump to content

Photo

fbForth—TI Forth with File-based Block I/O [Post #1 UPDATED: 11/10/2017]

fbForth Forth TI Forth

1422 replies to this topic

#1401 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Thu Oct 19, 2017 2:55 PM

OK...Post #1 is updated with all newly released fbForth 2.0:10 files (including an updated FBLOCKS).  I will get downloads up on my website soon.

 

...lee



#1402 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Fri Oct 20, 2017 8:31 PM

File downloads are now available on fbforth.stewkitt.com.  Please let me know what you think needs changed or clarified.

 

...lee



#1403 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Sat Oct 21, 2017 7:12 AM

Could you change the color scheme - the yellow text is a bit rough on the eyes.



#1404 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Sat Oct 21, 2017 7:46 AM

Could you change the color scheme - the yellow text is a bit rough on the eyes.

 

It looks pretty cool with the “Deflection” theme with its black background.  I will work on it, though.

 

...lee



#1405 TheBF OFFLINE  

TheBF

    Moonsweeper

  • 371 posts
  • Location:The Great White North

Posted Sat Oct 21, 2017 10:01 AM

I am having flashbacks reviewing your new Forth 2.0 in the 64 col. Editor.

 

Thanks for all your hard work Lee.  It's a beautiful thing.



#1406 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Sat Oct 21, 2017 7:56 PM

I am having flashbacks reviewing your new Forth 2.0 in the 64 col. Editor.

 

Thanks for all your hard work Lee.  It's a beautiful thing.

 

Thanks!  It really was a lot of fun.

 

I spent a lot of time in that editor over the years.  Not until I rewrote the 40-column editor in ALC to be the 40/80-column editor, so I could use 80 columns, did I begin to neglect its use.  Of course, the first thing I did was change TI's horrible color scheme for it—white on black, I think it was.  It was all the more horrible with the 3x7 character matrix.  I would get a headache trying to read it through the TV flicker.

 

Thanks again.

 

...lee



#1407 TheBF OFFLINE  

TheBF

    Moonsweeper

  • 371 posts
  • Location:The Great White North

Posted Wed Oct 25, 2017 11:54 AM

My first FB Forth program:

 

I cheated a little bit.  ;-)

 

I took a CAMEL99 program and added a small set of translation words.

And guess what? It works just fine.

 

For those who are just learning Forth it demonstrates how to use the interrupt timer for a precise delay and how to use the number formatting words.

 

Just paste this code into FB Forth and it puts little clock on the screen.

\ A simple Clock in FB Forth  (FIG Forth dialect)

\ Tiny HARNESS for FBFORTH->CAMEL99 translation
: 2DROP      DROP DROP ;
: 2DUP       OVER OVER ;
: VARIABLE   0  VARIABLE  ;
: AT-XY     ( n n -- )  GOTOXY ;
: OFF       ( addr -- ) 0 SWAP ! ;
: ^C?       ?TERMINAL ;

\ CAMEL99 version can now compile
HEX
8379 CONSTANT TICKER

DECIMAL
VARIABLE HRS
VARIABLE MINS
VARIABLE SECS
VARIABLE TICKS

58 CONSTANT ':'        \ character we will need

\ increment no. in the address
: 1+!   ( addr -- ) 1 SWAP +! ;

\ FB FORTH and CAMEL99 Forth run with interrupts enabled
\ so the ticker is changing every 1/60 of a second.
\ We can wait until ticker changes and know it's 1/60 of a second
: 1/60  ( -- )
        TICKER DUP @   \ dup ticker & fetch initial timer value
        BEGIN
             OVER @   \ read it again
             OVER -   \ subtract initial value
        UNTIL         \ loop until result is not zero
        2DROP ;       \ drop the initial value

: 1SEC   ( -- )  60 0 DO 1/60 LOOP ;

: KEEPTIME
         1SEC SECS 1+!
         SECS @ 60 = IF SECS OFF  MINS 1+! THEN
         MINS @ 60 = IF MINS OFF  HRS 1+!  THEN ;

\ formatted output
: ##  ( n -- )  0 <# # # #> TYPE ;
: :## ( n -- )  0 <# # # ':' HOLD #> TYPE ;

: .TIME ( -- )  SECS @ MINS @ HRS @  ## :## :## ;

: SETCLOCK ( hrs mins secs -- ) SECS ! MINS !  HRS ! ;

: CLOCK  ( row col -- )
         BEGIN
            2DUP AT-XY .TIME
            KEEPTIME
            ^C?        \ waits for function clear in FB Forth
         UNTIL
         2DROP ;
         
1 59 50 SETCLOCK
PAGE  10 10 CLOCK
         

Edited by TheBF, Wed Oct 25, 2017 12:14 PM.


#1408 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Wed Oct 25, 2017 8:46 PM

Very nice!  :)

 

...lee



#1409 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Sun Nov 5, 2017 12:44 PM

What do you do on a Sunday afternoon when you want to get into trouble? The first thing is to pick up the FbFORTH 2.0 manual and read a bit of it. Then, customize the FbFORTH boot a bit. I noticed that the single column of MENU options was nearing capacity of what it would display on the acreen. Any more options were going to be problematic.

So, I decided to use the full screen width in the 80-column mode and create a two column menu display (if I still need more space, I can go to four columns).I haven't optimized the code to conserve space on the two BLOCKS that are free for use by MENU but it works fine for now. I'm still toying around with the idea of using the unused portion of BLOCK 1 and having MENU display at boot but, for now, I'm satisfied to be able to select a two column MENU.

 

Next up? Since SAMS detection is attomatic and resident, I will probably have the presence  (or absence) of the SAMS card noted at start up. Maybe next Sunday.



#1410 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Sun Nov 5, 2017 4:59 PM

I also changed the printer access in BLOCK 19. It seems that the "fix" is the same as the original one published in "The Smart Programmer" and by TI-FORTH guru Lutz Winkler. Simply change the references to RS232 to PIO.



#1411 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Mon Nov 6, 2017 12:54 AM

I also changed the printer access in BLOCK 19. It seems that the "fix" is the same as the original one published in "The Smart Programmer" and by TI-FORTH guru Lutz Winkler. Simply change the references to RS232 to PIO.

 

Actually, the only thing that needs to be changed is

F-D" RS232.BA=9600"

to

F-D" PIO"

The instances of >RS232 only reference the device and could be anything, usually mnemonic.  Obviously, >PIO makes more sense as a reference to the parallel port, but something like PRNTR (as in §8.8 in the fbForth 2.0 Manual) would be logical for both.

 

...lee



#1412 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Wed Nov 8, 2017 8:54 PM

A while ago I started to port BLK>FILE and FILE>BLK from TurboForth to fbForth 2.0, but somehow got sidetracked.  I just finished BLK>FILE , which is used to copy a range of blocks from a blocks file to a DV80 file.  In Classic99, you can copy to the Windows clipboard by including CLIP as the output file:

\ BLK>FILE utility ported from TurboForth to fbForth 2.0
CR ." BLK>FILE - dumps a range of blocks to a text file." CR
." e.g. 1 21 BLK>FILE DSK2.BLKDUMP" CR

-1 CONSTANT cswtch               \ switch for printing block header
: NOT ( n1 --- n2 )  -1 XOR ;    \ bitwise NOT
." HDR toggles headers on and off." CR
: HDR  cswtch NOT DUP ' cswtch !    \ toggle header off/on
   IF ." On" ELSE ." Off" THEN CR ;
0 VARIABLE OUTBUF 78 ALLOT    \ 80-byte RAM buffer for output file
PABS @ 2+         \ VRAM address for PAB
OUTBUF            \ RAM addres for PAB-BUF
PABS @ 72 +       \ VRAM address for PAB-VBUF
FILE OUTFIL       \ associate above 3 addresses with OUTFIL
: BAR  ( blk# --- )
   BL OUTBUF C! 1 WRT         \ write a record with 1 blank
   S" --BLOCK---------------"       \ header string
   DUP C@ >R 1+ OUTBUF R CMOVE            \ header to OUTBUF
   0 <# # # # # # #> OUTBUF 8 + SWAP CMOVE   \ block# to OUTBUF
   R> WRT ;                               \ write header record
: BLK>FILE ( start end --- ) ( IS:outfilename )
   DEPTH 2 < IF                  \ at least 2 numbers on stack?
      ." Syntax error!" ABORT    \ no..we're outta here!
   ELSE
      OUTFIL SET-PAB VRBL 80 REC-LEN   \ set up OUTFIL as DV80
      BL WORD HERE DUP C@ 1+ PAB-ADDR @ 9 + SWAP VMBW  \ filename->PAB
      OUTPT OPN                  \ open file for output
      1+ SWAP DO                 \ end+1 start DO
         I cswtch IF             \ output block header?
            BAR                  \ yes
         ELSE
            DROP                 \ no..drop block#
         THEN
         I BLOCK                 \ load next block and get buffer address
         16 0 DO                 \ 16 lines/block
            DUP OUTBUF 64 CMOVE  \ copy next line to OUTBUF
            OUTBUF 64 -TRAILING  \ trim trailing blanks
            -DUP IF              \ anything left?
               WRT               \ yes..write line to file
            ELSE
               BL OUTBUF C! 1 WRT   \ no..write a blank line
            THEN
            DROP                 \ drop OUTBUF address
            64 +                 \ address of next line
         LOOP
         DROP                    \ clean up stack
      LOOP
      CLSE                       \ close file
   THEN ;

After I get FILE>BLK ported, I will add it to FBLOCKS and post it here and on my website.

 

...lee



#1413 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Wed Nov 8, 2017 9:37 PM

I know what I'm going to be doing over the next couple of days. You're dangerous, Lee :-D 



#1414 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Thu Nov 9, 2017 2:57 PM

And, here is FILE>BLK :

 

Spoiler

 

I modified its functionality a bit.  Because this word is so dangerous, I have it showing the user the current blocks file they are about to overwrite and ask if s/he wants to continue.

 

Other modifications of its TurboForth actions:

  • Displays the block numbers written so the user can track copy progress. 
  • Flushes only blocks written by marking the block dirty with UPDATE only after lines are actually copied.  (The TF version writes an extra blank block if the last chunk from the file is exactly 16 lines.)

 

I also added copy tracking to BLK>FILE :

 

Spoiler

 

...lee



#1415 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Thu Nov 9, 2017 5:34 PM

What next? I managed to get both of them typed in and entered into my MENU using my "good eye". Amazing but there were no typos and they are working fine. If you keep posting, I'll keep typing but it is a bit difficult to keep up, though.  :D 



#1416 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Fri Nov 10, 2017 11:29 AM

 This post will be modified in a few minutes!

 

I don't know what happened when I was attempting to edit this post—I suddenly got a complete copy of post #1. :?   Anyway, see two posts down for what I intended to post here.

 

...lee



#1417 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Fri Nov 10, 2017 12:46 PM

New FBLOCKS downloaded, MENU updated, BLOCK #2 updated, and system reset and new FBLOCKS installed and backup saved. Thanks for all of the hard work, Lee!!



#1418 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Fri Nov 10, 2017 12:59 PM

New FBLOCKS downloaded, MENU updated, BLOCK #2 updated, and system reset and new FBLOCKS installed and backup saved. Thanks for all of the hard work, Lee!!

 

You're more than welcome, atrax27407.  It is still a lot of fun!  :)

 

..lee



#1419 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Fri Nov 10, 2017 1:08 PM

The latest FBLOCKS ZIP file is posted in “Downloads-->System Files” on my website (see signature below), as well as in post #1 here.  Updates include

  • Block #1 (Welcome Screen) modifications:
    • Allows changing text colors to White on Blue
    • Displays 
      • SAMS availability
      • Bytes of free Low Memory (Return Stack grows down in this space from R0 )
      • Bytes of free High Memory (Dictionary grows up from HERE ; Stack grows down from S0
  • BLK>FILE—Current Blocks File to DV80 File export utility—ported from TurboForth with permission from Mark Wills
  • FILE>BLK—DV80 File to Current Blocks File import utility—ported from TurboForth with permission from Mark Wills

Soon I will post a video of the open screen on my website.

 

..lee



#1420 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Sun Nov 12, 2017 1:23 PM

Here is the current startup, which chooses white on blue for text modes:

 

Attached File  fbforth_startup20171110.gif   257.12KB   0 downloads

 

...lee



#1421 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Wed Nov 22, 2017 11:42 PM

While trying to port the game Battlestar by J. Volk from TI Forth to fbForth 2.0, I discovered a bug in a few graphics primitives that, as it turns out, I had introduced in fbForth 2.0:8 when I consolidated how interrupts were re-enabled.  Interrupts in fbForth 2.0 are always enabled except for routines that cannot tolerate that condition, e.g., routines that write to the display screen.  I used to restore interrupts within most routines that disabled them before they returned.  But, when I started work on sound and speech processing through the fbForth ISR, I realized that I should probably not issue a LIMI 2 if a user ISR were active.  It was at this point I remembered that all system calls to low-level ALC routines use a common return called BKLINK whose sole function is to check that a user ISR is not active before restoring interrupts and returning via R11.  If a user ISR is active, interrupts are not re-enabled.

 

Since there are two types of returns from ALC routines in fbForth 2.0, I figured I could handle all such returns from ALC where interrupts had been disabled by adding the user ISR test to RTNEXT (the return to high-level Forth from ALC) and using BKLINK for those routines returning to another ALC routine through R11.  Everything was fine except for routines that used R7 to save R11 before a BL branch to another routine that used BKLINK to return.  You see, BKLINK copies the user ISR flag to R7 to test it and thus destroys the saved return for the calling routine, which now “returns” to console location >0000 and hangs!  :_(  This happens in more than one graphics primitive that uses BKLINK, unfortunately.

 

The solution was to simply leave interrupts disabled and return to the calling routine through R11, where the eventual return to high-level Forth through RTNEXT would re-enable interrupts in the absence of an active user ISR.  This results in interrupts being disabled only a little while longer, which is acceptable.

 

I need to check for the same R7 problem with all the other routines I changed to returning from ALC through BKLINK before I release fbForth 2.0:11.

 

I have also discovered a slight problem with PLAY when flag = 0 for playing a new sound list only if none is currently playing.  I will post those details later along with a couple of possible solutions.  Right now I need to get some shuteye!

 

...lee



#1422 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,392 posts
  • Location:Silver Run, Maryland

Posted Today, 7:55 AM

OK...The problem with “ <addr> 0 PLAY ” is that, when the previous sound table has not yet finished, the sound table servicing routine (STSR) just exits.  There are two problems with this behavior:

  1. The address of the sound table to be played is left on the stack, polluting the stack;
  2. The sound table to be played is never played.

This renders “flag = 0” kind of useless.  At this point, I am not sure how I intended “ <addr> 0 PLAY ” to work, but I surely must fix its current action.  I am debating whether to simply remove the sound table address from the stack or to set up a small sound table stack such that “ <addr> 0 PLAY ” pushes the sound table address to that stack and have the STSR manage that stack.  If I implement such a stack, I need to decide whether to collapse it when an unconditional “ <addr> 1 PLAY ” is encountered or to leave it intact so that servicing it continues following the interruption.  I am inclined to go with the stack idea, but I am open to suggestions.

 

...lee



#1423 atrax27407 ONLINE  

atrax27407

    Dragonstomper

  • 783 posts

Posted Today, 9:45 AM

When in doubt, add a stack - my $.02







Also tagged with one or more of these keywords: fbForth, Forth, TI Forth

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users