Jump to content
IGNORED

Where does one go to find fbForth programs?


Omega-TI

Recommended Posts

Lee has some excellent example code in the manual.

 

If I am not mistaken, a spiral-hat demo is in the works too.

 

Have you tried playing Dark Star for TurboForth in Classic99 yet? It is masterfully done and the "syntax" is similar to fbForth. I put syntax in quotes because Forth has no real syntax... Just words... Built-in and user-defined. Very neat language, man... :)

Link to comment
Share on other sites

I'm not at the crawling stage yet (cartridge not due to arrive for at few days), so I'm totally ignorant and without a clue, so in preparation, where does one go to find fbForth programs to download, run and learn from?

 

I have been looking around for old TI Forth programs that should work with little modification. I found 9 Forth disks in the Boston Computer Society library. Three of them will only work with TI Forth, one of which is a pretty cool TI demo.

 

A handful of the programs on the other disks only make sense for TI Forth; but, there are quite a few that should work. One I tried, works with no modification at all. It is a text adaptation of Breakout by Clint Pulley, called BreakForth:

 

 

 

( BREAKFORTH INTRODUCTION) : BFSTART ;
CLS 14 1 GOTOXY ." BREAKFORTH" 14 2 GOTOXY ." **********" CR CR
." Adapted to TI FORTH by Clint Pulley" CR
CR ." This game demonstrates the the speed of"
CR ." TI FORTH. It is written for text mode"
CR ." and uses only the RESIDENT and SYNONYMS"
CR ." vocabularies." CR
CR ." To play, type BREAKFORTH then select"
CR ." speed and number of balls. Press enter"
CR ." after each selection." CR
CR ." To move your paddle, use the right and"
CR ." left arrow keys." CR
14 20 GOTOXY ." GOOD LUCK!" 0 22 GOTOXY -->



( BREAKFORTH adapted from A. Schaefer, BYTE Aug 80)
: ARRAY <BUILDS 2 * ALLOT DOES> SWAP 2 * + ;
90 ARRAY BLOCKMAP 0 VARIABLE #BLOCKS
0 VARIABLE SPEED 0 VARIABLE SPVAR 0 VARIABLE SCORE
0 VARIABLE XPOS 0 VARIABLE YPOS 0 VARIABLE PPOS
1 VARIABLE XDIR 1 VARIABLE YDIR 0 VARIABLE BEST
: LINE 0 SWAP GOTOXY ;
: BALLSET GOTOXY 42 EMIT ; : BALLCLR GOTOXY 32 EMIT ;
: PDLSET PPOS @ 22 GOTOXY 61 DUP DUP EMIT EMIT EMIT ;
: PDLCLR PPOS @ 22 GOTOXY 32 DUP DUP EMIT EMIT EMIT ;
: MOVEPDL PDLCLR 83 = IF -1 PPOS @ + 2 MAX PPOS !
   ELSE 1 PPOS @ + 35 MIN PPOS ! ENDIF PDLSET ;
: PADDLE ?TERMINAL IF QUIT ENDIF ?KEY -DUP IF MOVEPDL ENDIF ;
: BEEP 52 GPLLNK ; : BOP 50 0 DO BEEP LOOP ;
: BLOCKMAPINDEX -2 + 18 * SWAP 2 / + 1- ;
-->
( BREAKFORTH SCREEN 2)
: BLKTST YPOS @ 7 < IF XPOS @ YPOS @ BLOCKMAPINDEX BLOCKMAP @
   ELSE 0 ENDIF ;
: BLKCLR OVER OVER SWAP 126 AND SWAP GOTOXY 32 EMIT 32 EMIT
   BLOCKMAPINDEX BLOCKMAP 0 SWAP ! ;
: BLKSET OVER OVER GOTOXY 91 EMIT 93 EMIT BLOCKMAPINDEX
   BLOCKMAP 1 SWAP ! ;
: WALLSET 37 2 DO I 1 AND 0= IF I 2 BLKSET I 3 BLKSET
   I 4 BLKSET I 5 BLKSET I 6 BLKSET ENDIF LOOP 90 #BLOCKS ! ;
: INIT CLS 0 LINE ." Speed (1-9, 1 is fastest) : " KEY DUP EMIT
   KEY DROP 48 - 1 MAX 9 MIN 5 * SPEED !
   0 LINE ." Number of balls desired (1-9) : " KEY DUP EMIT
   KEY DROP 48 - 1 MAX 9 MIN CLS
   40 0 DO I 1 GOTOXY 61 EMIT LOOP
   22 1 DO 0 I GOTOXY 124 EMIT 124 EMIT
   38 I GOTOXY 124 EMIT 124 EMIT LOOP -->
( BREAKFORTH SCREEN 3)
   WALLSET 0 SCORE ! 0 LINE 0 0 GOTOXY ." Score: 0 "
   15 0 GOTOXY ." Best: " BEST ? 30 0 GOTOXY ." Ball: " ;
: XCHK
   XPOS @ 2 < IF XDIR @ MINUS XDIR ! 2 XPOS ! BEEP ENDIF
   XPOS @ 37 > IF XDIR @ MINUS XDIR ! 37 XPOS ! BEEP ENDIF ;
: YCHK
   YPOS @ 7 < IF SPVAR @ 8 MIN SPVAR ! ENDIF
   YPOS @ 6 < IF SPVAR @ 7 MIN SPVAR ! ENDIF
   YPOS @ 5 < IF SPVAR @ 6 MIN SPVAR ! ENDIF
   YPOS @ 4 < IF SPVAR @ 5 MIN SPVAR ! ENDIF
   YPOS @ 3 < IF SPVAR @ 4 MIN SPVAR ! ENDIF
   YPOS @ 2 < IF 1 YDIR ! 2 YPOS ! 2 SPVAR ! BEEP ENDIF ;
5 ARRAY PDLVEC
-2 0 PDLVEC ! -1 1 PDLVEC ! 0 2 PDLVEC !
1 3 PDLVEC ! 2 4 PDLVEC ! -->
( BREAKFORTH SCREEN 4)
: PCHK 0 YPOS @ 21 >
   IF 21 YPOS ! XPOS @ PPOS @ - 1+ DUP 0< 0= OVER 5 < AND
   IF -1 YDIR ! BEEP PDLVEC @ DUP 0= IF DROP ELSE XDIR ! ENDIF
   ELSE DROP 1+ ENDIF ENDIF ;
: CLR XPOS @ YPOS @ BLKCLR
   YPOS @ 27 - ABS SCORE +! 7 0 GOTOXY SCORE ? BOP
   YDIR @ MINUS YDIR ! #BLOCKS @ 1- #BLOCKS ! ;
: BALLCHK YDIR @ YPOS +! XDIR @ XPOS +! XCHK YCHK PCHK
   BLKTST IF CLR ENDIF ;
: BALL XPOS @ YPOS @ BALLCLR
   BALLCHK DUP 0= IF XPOS @ YPOS @ BALLSET ENDIF ;
: LAUNCH 2 RND 1 = IF 1 ELSE -1 ENDIF XDIR ! 1 YDIR !
   34 RND 3 + XPOS ! 8 YPOS ! 10 SPVAR ! ;
: GAMECHK #BLOCKS @ 0=
   IF WALLSET SPEED @ 5 - 5 MAX SPEED ! LAUNCH ENDIF ; -->
( BREAKFORTH SCREEN 5 - MAIN LOOP)
: DELAY SPEED @ SPVAR @ * 0 DO LOOP ;
: BREAKFORTH RANDOMIZE
   BEGIN 18 PPOS ! INIT PDLSET
   0 DO 2000 SPEED @ / 0 DO DELAY PADDLE LOOP
   36 0 GOTOXY I 1+ . LAUNCH
   BEGIN 10 0 DO PADDLE DELAY LOOP
   BALL GAMECHK UNTIL 100 0 DO 54 GPLLNK LOOP
   LOOP SCORE @ BEST @ MAX BEST !
   200 0 DO DELAY LOOP 
   12 8 GOTOXY ." Play again? " KEY DUP EMIT
   KEY DROP 89 = 0= UNTIL CLS 0 0 GOTOXY ;
;S 

 

 

 

FIAD blocks file of above game: BREAKFORTH.zip

 

...lee

  • Like 2
Link to comment
Share on other sites

The disk image where I found Clint Pulley's BreakForth is on WHTech: BCS078.DSK

 

The other TI Forth disk images I found in the same library are BCS009.DSK, BCS010.DSK, BCS030.DSK, BCS031.DSK, BCS042.DSK, BCS059.DSK, BCS060.DSK and BCS078.DSK. A discussion of each of the disks is in the PDF file in the same directory.

 

I will be going through most of these to see what needs to be changed to make them work with fbForth.

 

...lee

  • Like 1
Link to comment
Share on other sites

Oh well, I cannot mess around anymore today. I gotta hit the rack early, got a long day tomorrow...

I'll fix it. I screwed up somewhere. Did you try loading from the source code instead? The problem is, BSAVED are very specific to the version of TF. So, a program BSAVED in TF1.1 will not work in TF1.2; however, compiling from the source code would. I'll post the fix in a new thread, since this thread is concerned with fbForth.

Link to comment
Share on other sites

  • 4 weeks later...

I am almost finished with my fbForth-2.0 port of DarkStar:

  • Necessary changes were
    • Adding words that fbForth 2.0 does not have—mostly words from Forth 83, the basis of TurbForth.
    • Words that work differently in fbForth 2.0—notably,
      • EMIT , CHAR , JOYST ,
      • NOT (This is not part of fbForth 2.0; but, the TI-suggested definition works differently and the presumed value of true returned by words returning a true/false flag is 1 in fbForth and -1 in TurboForth. This does not affect words testing for true or false because any non-zero value is true; but, when a program uses the expected value for true, as does DarkStar, things can go awry for conversions.) and
      • The VDP words, COLOR and GCHAR (the stack order is reversed or nearly so).
  • Yet to do:
    • Fix a problem with the time-indicator line and
    • Rewrite SCROLL as ALC because SCROLL is interminably SLOW! in high-level Forth.

...lee

 

[Edited, with edits in blue.]

  • Like 1
Link to comment
Share on other sites

It was nice discussing the fB Forth differences from TurboForth with you at lunch today, Lee! I still have to sneak the cartridge cases into the house without She-Who-Must-Be-Obeyed noticing them. . .she did see the nice colorful Scott Foresman cartridges I got in the mail though (I now have half a dozen different Red math cartridges and one Blue reading cartridge).

Link to comment
Share on other sites

It was nice discussing the fB Forth differences from TurboForth with you at lunch today, Lee! I still have to sneak the cartridge cases into the house without She-Who-Must-Be-Obeyed noticing them. . .she did see the nice colorful Scott Foresman cartridges I got in the mail though (I now have half a dozen different Red math cartridges and one Blue reading cartridge).

 

A pleasure indeed—as always!

 

...lee

Link to comment
Share on other sites

Lee, please explain why SCROLL is significantly slower in high-level Forth... I would have thought the speed difference would have been negligible!!

 

Well, part of it is likely my programming of the word; but, Forth words defined with : (colon) are compilations or lists of code field addresses (CFAs or execution tokens), which means that the inner interpreter reads the CFA to find out what address to branch to. The CFA of every colon definition points to colon's runtime code, which pushes a return address to the return stack and gets the next CFA in the definition. If that is also a colon definition, the process repeats, growing the return stack. Since the colon runtime code and the address interpreter are in scratchpad RAM, the process is fast, but inherently slower than ALC because of the added overhead of processing the CFA list.

 

If, on the other hand, I program SCROLL in Forth Assembler, its CFA will point to its own parameter field, which will contain the first executable ALC of the definition. Even some of this code may need to call the inner interpreter; but, it will usually be faster because most of the code is ALC that is executing directly within the word.

 

My high-level definition of SCROLL has two loops that cover the panel or window being scrolled. One loop walks the columns and the other the rows, depending on which direction we're scrolling. The outer loop reads one wrap character and saves it while the inner loop reads each of the rest of the characters in the currently scrolling row/column one at a time and writes it to its destination one character away in the scroll direction. The outer loop then writes the wrap character or a space, depending on the value of the WRAP variable, before advancing to the next column/row.

 

Every character in the panel is read and written by fbForth's high-level VSBR and VSBW , which are not quite as fast as the ALC functions they call because of the address interpreter overhead mentioned above. If the panel is the entire screen in graphics mode, say, that is 32 columns by 24 rows = 768 characters read (768 calls to VSBR ) and 768 written (768 calls to VSBW ). Like I said above, I think Forth Assembler will speed that up. That's what I am going to try first. If that does not speed things up sufficiently, I will code it more like @Willsy did with his TurboForth ALC, where IIRC he processes one line at a time, but must handle up/down scrolling differently from left/right scrolling. My code is general purpose, but thus must read/write one character at a time because there is no easy way to read/write multiple VRAM bytes in columns because they are not contiguous bytes.

 

Sorry for the long-winded explanation. Now to fix it...

 

...lee

Link to comment
Share on other sites

Here is my port to fbForth 2.0 of @Willsy's DarkStar:

 

DarkStar_fbForth2.zip

 

Both files need to be in DSK1—DARKSTAR is the game and DKSTRCHR is the font file loaded by it. Be careful :-o if you are using the same DSK1 for TurboForth because the TurboForth DarkStar blocks file has the same name (DARKSTAR)!! :-o

 

To start the game, make DSK1.DARKSTAR the current blocks file and load block #1:

USEBFL DSK1.DARKSTAR
1 LOAD

To get fbForth back to using the default font after the game, type the following:

0 SCRFNT !
FNT

...lee

Edited by Lee Stewart
  • Like 1
Link to comment
Share on other sites

 

Been there, downloaded, installed and played... :lol: ... tomorrow after work, I plan to rename it to FBLOCKS, (on a separate disk image) and try to get it to 'auto start' upon loading.

 

There is a simple way to do that in the spoiler below. If you want to work it out yourself first, DO NOT open the spoiler!

 

 

Before you rename DARKSTAR, you want to copy block #30 to block #1 so that, after renaming DARKSTAR to FBLOCKS, it will autoload the compiled version. Ensure FBLOCKS is the current blocks file. You can verify that by typing MENU . Then do the following to load the CPYBLK utility to do the block copy (let's presume that DARKSTAR is on DSK2):

4 LOAD
CPYBLK 30 30 DSK2.DARKSTAR 1 DSK2.DARKSTAR 

Now you can rename DARKSTAR to FBLOCKS. After you put that disk in DSK1, the next time you boot fbForth, DARKSTAR will autoload. You can also restart fbForth by typing COLD .

 

 

 

...lee

  • Like 2
Link to comment
Share on other sites

Thanks, now all I need to do is get past having to type in DARKSTAR and then figure out how to bypass all the into stuff and go straight to the Keyboard or Joystick selection screen. ;)

 

I'll post another answer-in-a-spoiler for the pre-compiled version after I get a little breakfast.

 

...lee

Link to comment
Share on other sites

Presuming that you copied block #30 to block #1 here are two scenarios of what you need to do to bypass the intro screens and either (1) autostart the game or (2) select joystick/keyboard mode and then autostart the game:

 

 

 

  1. To just autostart the game:
    • For using the joystick as the play mode ( JoystickMode? defaults to using the joystick), change line #6 to
      Joystick  Game  ;S
      

      You can delete line #7 or not. The second ;S will be ignored after the one on line #6 stops loading the block. Joystick speaks, “Joystick is on.”

    • For using the keyboard as the play mode, change line #6 to

      FALSE TO JoystickMode?  Keyboard  Game  ;S
      

      Keyboard speaks, “Keyboard is on.”

  2. To first select joystick/keyboard mode and then autostart the game, change lines #6 to the end:

    : GetMode PAGE ." Joystick mode, J or K? "  BEGIN  KEY 
       CASE
          74 OF 1 TRUE Joystick  ENDOF
          75 OF 1 FALSE Keyboard ENDOF
           0 TRUE ROT
       ENDCASE
       TO JoystickMode?
    UNTIL  ;
    GetMode  Game  ;S
    

 

 

 

...lee

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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