Forth

Anything QL Software or Programming Related.
User avatar
polka
Over Heated PSU
Posts: 140
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Wed May 27, 2020 6:32 am

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 !


May the FORTH be with you !
POLKa
User avatar
NormanDunbar
Forum Moderator
Posts: 1042
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Forth

Postby NormanDunbar » Wed May 27, 2020 8:18 am

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.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890

Who is online

Users browsing this forum: Google [Bot] and 2 guests