Jump to content

Photo

fbForth 2.0: Bitmap Graphics Olio

fbForth Forth bitmap graphics

14 replies to this topic

#1 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • 3,762 posts
  • Location:Silver Run, Maryland

Posted Sat Feb 13, 2016 2:32 PM

I am starting this thread to collect various examples of bitmap graphics programming in fbForth 2.0.

 

This first example is a quick-and-dirty joystick drawing program, JDRAW , ported from the program of the same name I wrote four years ago for TI Forth in post #48 of thread, TI FORTH Version 3.0 dated October 20 1982.  As I stated then, it is a pretty useless program except as a demo and proof of concept.

 

It uses the CRU mode of JOYST for joystick-only use.  There is a three-choice menu accessed with the fire button.  The choices are

  • P—Toggle pen up/down [blue pen = pen down; white pen = pen up]
  • D—Toggle draw/erase [ solid pen = draw mode; hollow pen = erase mode]
  • Q—Quit program

The joystick moves the pen around the display screen.

 

There is much that could be done to make it more useful.  One such thing would be to provide finer control over the pen—reaction to joystick movement is too fast for any useful drawing.  Another would probably be to dispense with the menu and use the fire button for pen-up/pen-down.  But, that leaves managing draw/erase mode, which would probably require using the JOYST word in keyboard (KSCAN) mode.   Anyway, here is the fbForth 2.0 source code for JDRAW :

 

Spoiler

 

I will add a blocks file, later.  For now, you can paste this in Classic99 at the command line of fbForth 2.0.  Start the program by typing:

 

JDRAW

 

...lee



#2 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Sat Feb 13, 2016 4:59 PM

Core War uses the split bitmap/text mode :) I programmed it in plain TI Forth though...



#3 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Sat Feb 13, 2016 5:11 PM

Walid...

 

Do you know where the limiting code is?  That is, would faster graphics plotting make much difference?

 

...lee



#4 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Sat Feb 13, 2016 5:23 PM

Absolutely. Here's an experiment I did in TI Forth with bitmapped 2D graphics using the resident functions (no assembly support). Pretty slow isn't it...



#5 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Sat Feb 13, 2016 5:56 PM

Let's see the code to see how fbForth compares.

 

...lee



#6 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Sat Feb 13, 2016 6:52 PM

Here's the work disk I coded the demo on. The code starts on screen 91 (DSK2). I wrote it directly into TIF, so I don't have a text listing unfortunately and there is no utility available that can read the screens outside for Forth... Of note is that I used look up tables for the sine-cosine values to speed things up. Let's see how this works under FbForth :)

 

EDIT: Actually that's not the same demo. It was my attempt at creating 3D wireframe animations! I can't seem to find the code for the original demo... In any case, this demo takes for ever to load and requires the GRAPH2 library and is deathly slow. I never really got it to work properly and I gave up on it because of how slow it was running. There is a bug in the transformation matrices somewhere. Believe it or not this was supposed to be a cube rotating  :grin:

 

To run:

91 LOAD

START

Attached Files



#7 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Sat Feb 13, 2016 8:02 PM

Here's the work disk I coded the demo on. The code starts on screen 91 (DSK2). I wrote it directly into TIF, so I don't have a text listing unfortunately and there is no utility available that can read the screens outside for Forth... Of note is that I used look up tables for the sine-cosine values to speed things up. Let's see how this works under FbForth :)

 

EDIT: Actually that's not the same demo. It was my attempt at creating 3D wireframe animations! I can't seem to find the code for the original demo... In any case, this demo takes for ever to load and requires the GRAPH2 library and is deathly slow. I never really got it to work properly and I gave up on it because of how slow it was running. There is a bug in the transformation matrices somewhere. Believe it or not this was supposed to be a cube rotating  :grin:

 

To run:

91 LOAD

START

 

There is a 6-block “2D TRIANGLE ROUTINE” that begins in the second block.  Is that it?

 

BTW, the “TI Forth Block Utilities” in the latest FBLOCKS (12/08/2015) will allow visualizing in fbForth and copying to an fbForth blocks file, which can be converted to a TXT file by TI99Dir and, probably, TIImageTool.

 

I will see what I can do with them.

 

...lee



#8 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Sat Feb 13, 2016 10:19 PM

Walid...

 

Attached is a blocks file for fbForth (VORTICON), which is a copy of your TIF-WORK.DSK.  I have, so far, made no substantive changes.  I did have to change block 1 to load blocks 7 and 8 instead of 97 and 98 to make it compatible with fbForth for obvious reasons to anyone who knows TI Forth.  The attached actually loads blocks 7 and 2 because block 2 starts loading the routine in your video, which takes 75 seconds in TI Forth but only 10 seconds in fbForth 2.0 with the identical code.  To run the 2D example, assuming the blocks file, VORTICON, is in DSK1, type the following:

 

USEBFL DSK1.VORTICON

1 LOAD

START

 

BTW, the 3D code looks like it's doing something reasonably like 3D.  To run it, change block 1 code 

 

( 8 ) 2 LOAD

to

( 2 ) 8 LOAD

 

Then, perform a cold start with COLD to reset fbForth and repeat the 3 lines after the first paragraph above.

You should probably have a cup of coffee before you type START because it does take a long time to load 17 blocks!

 

Here's a ZIP file that includes the blocks file and a TXT file copy of it:  Attached File  VORTICON.zip   6.97KB   6 downloads

 

...lee


Edited by Lee Stewart, Sat Feb 13, 2016 10:37 PM.


#9 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Sun Feb 14, 2016 1:38 PM

I forgot about one other change I made to the TI Forth code in my last post.  I removed the second line from block 1

 

-64SUPPORT -FLOAT 180 DISK_HI !

 

because it loads the graphics mode code, the graphics primitives, the 64-column editor and the floating point library, which are all (except the 64-column editor) resident in fbForth 2.0.  The 64-column editor is not necessary to run the program.  If it is desired by the user, it can easily be loaded separately.

 

It also sets the highest disk block #, which is irrelevant in fbForth.  Furthermore, the word DISK_HI does not exist in fbForth.

 

The principal reason this program runs so much faster in fbForth is that I coded the graphics primitives, which are in the fbForth 2.0 ROM, in ALC.  This is particularly important for the definition of LINE .

 

...lee



#10 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Mon Feb 15, 2016 5:40 PM

Lee, I did not see much of a difference in the bitmap drawing speed between TIF and FbForth. What am I missing?



#11 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Mon Feb 15, 2016 6:42 PM

Lee, I did not see much of a difference in the bitmap drawing speed between TIF and FbForth. What am I missing?

 

You’re using fbForth 2.0:+, right?  TI Forth and fbForth 1.0 cannot hold a candle to fbForth 2.0 because all of the graphics primitives of the former are in high-level Forth and the latter, in ALC.  Once the blocks (1, 7, 2 – 6) are loaded and the program is started with START , it’s over in 10 seconds.

 

...lee



#12 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Mon Feb 15, 2016 6:55 PM

Ah OK. I was using version 1.0 . The pinned development resources thread should be updated with the latest version because it is still listing version 1.



#13 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

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

Posted Mon Feb 15, 2016 7:24 PM

Ah OK. I was using version 1.0 . The pinned development resources thread should be updated with the latest version because it is still listing version 1.

 

I hadn’t checked it lately.  It used to reference my “fbForth—TI Forth with File-based Block I/O [Post #1 UPDATED: 12/08/2015]” thread, which has both versions, their manuals and FBLOCKS files in the first post.  I guess I should touch base with Filip.

 

...lee



#14 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,321 posts
  • Location:Eagan, MN, USA

Posted Mon Feb 15, 2016 9:24 PM

I have to say I am really impressed by the speed gains. This may yet revive my plans to write a flight simulator in Forth :)

Below is a video of the 2D transformation demo running in FbForth. Compare to the original one a few posts before.

 



#15 Willsy OFFLINE  

Willsy

    River Patroller

  • 3,079 posts
  • Location:Uzbekistan (no, really!)

Posted Tue Feb 16, 2016 12:34 AM

That's really impressive!





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

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users