Page 3 of 4

Re: Forth

Posted: Wed May 27, 2020 6:32 am
by polka
Hi all !

As promised, some speed comparisons between Computer One Forth and SuperForth :

I will use the PERSPECTIVE.FTH program adding only a word to replace the infinite loop of AROUND by a DO loop. This word is called BROUND (why not ?). And I will also add a simpler word for DREAM called BREAM.

Code: Select all

: BREAM ( --- k ) 1 KEYROW
   STEP POINT-OF-VIEW NIGHTMARE @ EXECUTE CLS ;
: BROUND ( n --- d )
   TIME ROT ' NIGHTMARE !
   0 DO
      BREAM
      64 = IF I . LEAVE THEN
   LOOP
   TIME SWAP D- D. ;
The word BROUND will need to input the number n of desired loops and will return the difference in seconds d between two calls of TIME. I simplified BROUND compared to AROUND, it will not check for rotation changes, only watch the space bar, that may interrupt the looping ; in this case, you will also get the actual number of loops. Use BROUND for instance like this :

6000 6000 4000 POINT-OF-VIEW RZ 1000 BROUND AIRPLANE

The results are :
With SuperForth : 2400 secs
With Computer One Forth : 840 secs

The work to be done by this program is of two kinds :
- computations of the perspective transforms (in both cases with exactly the same all-Forth code)
- drawing lines (with my assembler word ADRAW for Computer One Forth and with a all-Forth equivalent for SuperForth)
because drawing with SuperForth needs to convert the 2D integer coordinates to floats for the QL to use its QDOS/SuperBasic graphics.
This equivalent, also called ADRAW, has exactly the same stack trace as the assembler word for ComputerOne :

ADRAW ( color, X1 , Y1, X2 , Y2 --- color, X2 , Y2 ) for chaining drawn lines just adding one new pair of coordinates.

To have the program do all the perspective computations (exactly the same code with both Forth) without drawing, i just had to modify the word SEG :

: SEG DUP ABS PIXEL ROT 0> IF ADRAW ELSE 2SWAP 2DROP THEN ;

: SEG DUP ABS PIXEL ROT 0> IF 2DROP ELSE 2SWAP 2DROP THEN ;

Without ADRAW, the (astonishing) results are :
With SuperForth : 1280 secs
With Computer One Forth : 610 secs
So, the part of this program only written in Forth runs two times faster on Computer One Forth than on SuperForth.

By difference :
My assembler ADRAW uses 130 secs (from the 840)
while the equivalent ADRAW for SuperForth through QL graphics needs 1120 secs (from the 2400)

As a conclusion, on a BBQL ComputerOne Forth draws my AIRPLANE every 0.8 secs, whereas SupperForth digests it in 2.4 secs. With my other Tetroid card (that has Minerva - but stays in Paris while I am still confined in the Alps) I thus may be able to animate 3D on a BBQL on one screen while displaying the other one with a periodicity of less than 1 sec.

Bye POLKA - Today I am 72, happy birthday to me !

Re: Forth

Posted: Wed May 27, 2020 8:18 am
by NormanDunbar
Bye POLKA - Today I am 72, happy birthday to me !
Happy Birthday Polka. I hope you have a good one, trapped in the Alps.

Cheers,
Norm.

Re: Forth

Posted: Mon Sep 14, 2020 5:03 pm
by polka
Hi all ! Jedi is back
In another post, I showed a random dot autostereography generator written in Oberon for an emulation of the Ceres workstation.
Why no try it in a BBQL ? Indeed, with the limited display resolution, you may not reach nice 3D, only kind of basis low-relief images.
( by the way, do english speakers say low-relief or bas-relief - I found both translations with no preference ?).

But I decided to adopt a more intersting background image than random dots. In another life I travelled one day to Scottland and bought this precious little book :
Scottish Tartans.pdf
(48.59 KiB) Downloaded 192 times
Thus I decided to write a program (in FORTH of course) that let me display any tartan at will. And for you to play with it, to port it to "supper"forth as a plain text file to load with the LOAD_FILE command. As an example, I show the tartan of the Sinclair clan (not very intersting compared to others). Here is the graphic result :
sinclairql.gif
And here is the list :

Code: Select all

0 CONSTANT BLACK 
2 CONSTANT RED
4 CONSTANT GREEN 
7 CONSTANT WHITE

HEX CREATE 4COLORS
7F7F , BFBF , DFDF , EFEF , F7F7 , FBFB , FDFD , FEFE , ( msk )
0080 , 0040 , 0020 , 0010 , 0008 , 0004 , 0002 , 0001 , ( red )
8000 , 4000 , 2000 , 1000 , 0800 , 0400 , 0200 , 0100 , ( grn )
8080 , 4040 , 2020 , 1010 , 0808 , 0404 , 0202 , 0101 , ( wht )
DECIMAL

: 4DOT ( c,x,y ) 128 * SWAP 8 /MOD 2* ROT + 0 131072. D+ 2DUP
A@ 3 PICK 2* 4COLORS + @ AND 4 PICK 0> IF 4 ROLL 2/ 16 * 4 ROLL
2* + 4COLORS + @ OR ELSE >R 2SWAP 2DROP R> THEN ROT ROT A! ;

VARIABLE L 

: WARP HERE 1 ALLOT 0 L ! ;

: WEFT CREATE DUP C@ DUP C, 
  HERE SWAP DUP * ALLOT
  OVER C@ 0 2DUP DO 2DUP DO
    I J + 4 MOD 2/
    IF I ELSE J THEN
    4 PICK 1+ + C@
    4 + PICK
    4 PICK C@ I * J +
    4 PICK + C!
  LOOP LOOP 2DROP 2DROP ;

: TARTAN CREATE WARP DOES> WEFT ;

: | SWAP 0 DO DUP C, 1 L +! LOOP DROP ;

: END_TARTAN L @ SWAP C! ;

: WEAVE DUP C@ L ! 1+ 
  256 0 DO 
    I L @ MOD L @ *
    512 0 DO 
      2DUP I L @ MOD + + C@ I J 4DOT 
    LOOP DROP 
  LOOP KEY 2DROP ;

TARTAN SINCLAIR 8 2 | 5 0 | 3 3 | 5 0 | 21 1 |
                5 0 | 3 3 | 5 0 | 8 2 | 21 1 | END_TARTAN

WHITE GREEN RED BLACK SINCLAIR QL

QL WEAVE

END_FILE
You will notice that this program has a "double deck" CREATE design : first you will have to define a TARTAN word with a number of pairs of integers defining a WARP (in each pair you find the number of streams and a color code - when you use only 4 colors, the codes are 0 1 2 3 ; if you use only two colors, they are 0 and 1 (in the future I will develop a version of the program with up to 8 color codes).

When you have a tartan with a give name, let's say SINCLAIR, you may by naming it, choose the real colors it will associate to the color codes ; thus you may define different WEFTs for a same WARP. The WEFT created will have a different name than the tartan WARP :

WHITE GREEN RED BLACK SINCLAIR QL (or any other color combinations) will give you a WEFT named QL to WEAVE on the display :

QL WEAVE

Now, to use such periodic wefts to create the illusion of autostereography, I will "only" have to write another word to use instead of WEAVE (that for the moment I did not design).

In the mean time have fun ! (if you wish)

POLKa

N.B. For supperForth, I had to develop a screen pixel painting word called 4DOT (8DOT already coded 8 colors tartans on the way), and it was not easy, due the the very weird display memory management "à la Sinclair".

Re: Forth

Posted: Mon Sep 14, 2020 8:39 pm
by NormanDunbar
Hmmm, looks a bit like my tartan:
dunbar_mod_big.jpg
dunbar_mod_big.jpg (51.72 KiB) Viewed 4426 times
which, I have to say, is bloody awful. So I have a kilt in this one, Pride of Scotland:
KTF-PSCO.jpg
Much easier on the eye!

Cheers,
Norm.

Re: Forth

Posted: Mon Sep 14, 2020 9:31 pm
by Pr0f
So a programming language that's named after a Scottish river that can produce Tartans on a QL ! :-)

Re: Forth

Posted: Tue Sep 15, 2020 6:55 am
by polka
Pr0f wrote:So a programming language that's named after a Scottish river that can produce Tartans on a QL ! :-)
On a SINCLAIR QL !

I don't remember when, but we had a Forth convention in a town named Forth (also in Scotland ?). For the moment, the QL cannot cook haggish, but I will try...

Haggish is stuffed sheep stomach, I liked it, in Elsass (Strasbourg - France) we have an equivalent : stuffed pork stomach.

Norman, I found your tartan (and the history of your clan) in my book ! I don't find it so awfull.

Re: Forth

Posted: Tue Sep 15, 2020 7:14 am
by NormanDunbar
polka wrote:Haggish is stuffed sheep stomach, I liked it, in Elsass (Strasbourg - France) we have an equivalent : stuffed pork stomach.
Haggis is quite simply what is left when a sheep decides to eat itself! :D :D :D

Seriously though, Haggis is of Asian origin, and was first recorded as being eaten in Lancashire, England!

I do like the sound of your stuffed pork stomach though.
polka wrote:Norman, I found your tartan (and the history of your clan) in my book ! I don't find it so awfull.
The Dunbars originated near the town of Dunbar, but we moved North and took over the Moray and Nairn area in the North East. I think that, if you see it in the flesh, you might change your mind on the tartan. :o

I never knew there was a town called Forth, only a river. That's today's "learn something new" -- the QL is very educational!

Cheers,
Norm.

Re: Forth

Posted: Tue Sep 15, 2020 9:13 am
by Derek_Stewart
NormanDunbar wrote: The Dunbars originated near the town of Dunbar, but we moved North and took over the Moray and Nairn area in the North East. I think that, if you see it in the flesh, you might change your mind on the tartan. :o
Do you have the title: Laird Dunbar?
NormanDunbar wrote: I never knew there was a town called Forth, only a river. That's today's "learn something new" -- the QL is very educational!
I think the comment stated the River Forth...

Re: Forth

Posted: Tue Sep 15, 2020 10:22 am
by dex
I think the comment stated the River Forth...
I have found two Forth villages in Scotland (not very close to Forth River) and in Germany (part of Eckental).

Re: Forth

Posted: Tue Sep 15, 2020 11:33 am
by polka
Yes, I remember now : the Forth conference that I attended was in Forth-Germany. I went to Scotland only once, for a mechanical engineering seminar (several years before the Forth confernce in Germany). I am old, you know...