Forth

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 1792
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Forth

Postby NormanDunbar » Tue Apr 21, 2020 10:22 pm

And may the forth be with you. :D


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
User avatar
ajb
ROM Dongle
Posts: 47
Joined: Sat Oct 19, 2019 6:14 am
Location: W.Yorks

Re: Forth

Postby ajb » Tue Apr 21, 2020 11:08 pm

The ACE was a lovely little machine. As you say, people are asking ridiculous amounts for them on eBay. IIRC someone has been advertising one at £1200 for a few years. Some people are born optimists.

A few years ago I designed my ARV1 (Ace Revamped) which was basically the ACE circuit but with the 2114s replaced by 6116s and I upped the RAM to max using most of a 64K static chip. I designed a PIC chip into the circuit which I programmed to provide an SDHC interface. The FORTH words to control the SDHC interface were stored in an 8K EEPROM I added to the top of the memory map. The lower ROM (also now an EEPROM) was 99% of the original OS, slightly modified so that the extra words were linked into the chain. All of that (plus a one transistor composite video booster) was designed onto a new PCB and fitted into a Dktronics enclosure sporting a new PCB to hold the keyboard switches. It works quite nicely. Shortly afterwards I designed a WD1770 FDC interface to connect to its expansion bus and wrote the DFS for that - it had the look and feel of the original Acorn DFS for the BBC micro. Given that I'd added the SDHC interface to the main board the FDC interface was just a pure nostalgia project.

ACE Forth was close to 79-standard but wasn't. The main difference was that it didn't use SCREENS, instead you could decompile words, edit them and add them back. It was a very inventive move given that there was no storage system which would allow SCREENS. The cassette interface would be entirely unsuited to that.

As I said when I joined this group, one of my plans is to port a 68000 FORTH I wrote for the Atari STE to the QL. That's on the back burner for the moment but will hopefully be resurrected.

Alan


User avatar
bwinkel67
Aurora
Posts: 828
Joined: Thu Oct 03, 2019 2:09 am

Re: Forth

Postby bwinkel67 » Wed Apr 22, 2020 2:20 am

polka wrote:Hi,

I am sure that you all know where to download the best emulator for ZX80, ZX81, Spectrums, ... and Jupiter ACE :
https://sourceforge.net/projects/eightyone-sinclair-emulator/
POLKa


I really like EightyOne. I find it funny that at first glance it seems to only be ZX81 and then boom, you get Spectrum in all its glory. So I tried to speed up the ZX81 by adjusting its speed setting to 16 under Options but nothing. Any idea how to change that?


User avatar
bwinkel67
Aurora
Posts: 828
Joined: Thu Oct 03, 2019 2:09 am

Re: Forth

Postby bwinkel67 » Wed Apr 22, 2020 2:20 am

NormanDunbar wrote:And may the forth be with you. :D


Just a couple of weeks too early :-)


User avatar
polka
Trump Card
Posts: 173
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Wed Apr 22, 2020 3:45 pm

ajb wrote:ACE Forth was close to 79-standard but wasn't. The main difference was that it didn't use SCREENS, instead you could decompile words, edit them and add them back. It was a very inventive move given that there was no storage system which would allow SCREENS. The cassette interface would be entirely unsuited to that.


Actually, before Jupiter ACE, there was ZX-FORTH loadable from an audio cassette into ZX81 and ZX Spectrum. This one stored programs on tape with "sreens" which were individual 1024 bytes files, with a number in their header ; and on the tape, just after the FORTH binaries you could load the 3 first screens as a complete screen editor, indeed rather uneasy to use with audio tapes :
To get a screen for editing : command "n LIST"
To save an edited screen : command FLUSH
To create an empty new screen : command "n CLEAR"
To compile a screen into the forth dictionnary : "n LOAD"
To compile several contiguous screens, the last command in each except in the last "-->"

All you want to know about this product :
http://www.worldofspectrum.org/infoseekid.cgi?id=0008717

POLKa


May the FORTH be with you !
POLKa
User avatar
ajb
ROM Dongle
Posts: 47
Joined: Sat Oct 19, 2019 6:14 am
Location: W.Yorks

Re: Forth

Postby ajb » Wed Apr 22, 2020 4:20 pm

Thanks for the link.
There was also ACORNSOFT FORTH of course. That too could operate with screens using either a cassette recorder or floppy drive (and even had the "79-STANDARD" word). It was bliss when I could afford a floppy drive and move off the tape system.

Alan


User avatar
polka
Trump Card
Posts: 173
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Mon May 04, 2020 8:39 am

Hi all !

NormanDunbar wrote: And may the forth be with you. :D

Today is THE day when the FORTH will be with you
Derek_Stewart wrote:If anyone has any good Forth listings, I would be interested in seeing them.

(since you want... some listings).
B.gif
B.gif (127.42 KiB) Viewed 1439 times

This is a little application that I coded for ComputerOne FORTH thirty years ago ; it draws on the QL display (512x256) a true perspective projection of any 3D "object" like it would be seen by a photographic lens.
PerspTransform.zip
(367.45 KiB) Downloaded 76 times

In this zipped doc, I explain how this FORTH application was coded layer by layer - and I hope that you will understand that FORTH is not quite a RPN calculator, but a way to factorize efficiently an application program.

And thus (indeed) to get speed together with structure - of course pure machine code may be faster, but who is sure that his assembler code is really optimal ?

May the FORTH be with you !
POLKa


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 173
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Sun May 17, 2020 1:37 pm

Hi All !

Not a lot of JEDIs following this thread !

I took the time (a lot of time, but I am still confined at my ski resort) to port the software I described in the posts above to the "Ill-named SUPPER" FORTH (mistyping after all intented).

This is it :

PERSPECTIVE_FTH.zip
3D animations in FORTH
(2.14 KiB) Downloaded 53 times


The animation of the airplane will not be convincing on a BBQL. You will have to run it for instance on a Qemulator at full speed. To do so :

EXEC SuperFORTH ; its BLK1 is normally automaticaly loaded as a boot file, so first replace your BLK1 by mine (in the ZIP), because it will redimension Full Screen and include the FPmaths.fth package that is needed for graphics.

Then you may LOAD_FILE MDV2_PERSPECTIVE_FTH (MDV2 is just an example, adapt to your devices - my BLK1 may need to be adapted too).

Anyway when SupperForth is running, typing AROUND AIRPLANE will show an airplane turning around the Z axis, but you may change the rotation axis in real time with the 4 arrow keys : UP means Z, LEFT means X, RIGHT means Y and DOWN means reverse rotation. The SPACE bar stops the animation.

In the next posts, as time permits I will explain the details and why I dislike SupperForth (the dark side of...).

POLKa


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 173
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Wed May 20, 2020 10:25 am

Hi All,
In the zipped code for 3D animations with SuperFORTH, attached to the post above, the words ported from the ComputerOne FORTH are in the middle between two comment lines

( ******************* )

In front of that, I had to code some words missing in SuperFORTH and after that, I had to rewrite the animation part because it could not be done in the way of ComputerOne FORTH (and most other FORTHs that I know and have used).

1/ Three useful words to begin with :
Integer arithmetic with 16bits has a severe issue with multiply and divive operations : when you multiply two 16bits numbers you may need 32 bits to hold the result, and conversively, you may want to divide a 32bits number by a 16bits number to get a result with enough precision range.

For this, you need M* ( n1,n2 --- d ) and M/ ( d1,n2 --- n ) or M/MOD ( d1, n2 --- q,r ) operating with signed 16bits "n" and 32bits "d" integers. SuperFORTH knows only UM* and UM/MOD operating on "unsigned" numbers !!! So, to be used for my ComputerOne port of 3D animations, I had to add first the two words M* and M/. I added also a MSQRT word, computing the square root of a 32bits number into 16 bits.

2/ 3D animation control "à la mode" of SuperFORTH.
In all the other FORTH that I know and used there is a word called ?TERMINAL or KEY?, which when called will put a flag on the stack depending of "did you hit the keyboard or not". So the sequence :

Code: Select all

BEGIN . . . ?TERMINAL IF KEY ELSE 0 ENDIF . . . REPEAT


will get the ASCII code of the key you pressed or zero inside a infinite REPEAT loop, letting the program to change in real time its behaviour or exit.

I used this in my other implementations of 3D animations to change the rotation, around X or Y or Z, slow it down or accelerate it and change the point of view to nearer or farther. But in SuperFORTH, this is not possible. So I had to find how to do someting similar otherwise :

In SuperFORTH you have a word KEYROW that calls the KEYROW routine of QDOS/SuperBasic : when called, with a number of row of the QL keyboard, it answers 0 or a key code depending of the key pressed.

Calling it with row 1, you can get a code for the four arrows, the escape, the enter keys and the space bar (but no other keys).

The other difference is that with ?TERMINAL you get a TRUE flag even if you released the hit key before (inside the loop) ?TERMINAL was called, whereas with KEYROW, the key must remain pressed up to when KEYROW is called ; but if inside a very fast BEGIN . . . REPEAT loop you hold the key pressed too long, you may get more than one answers on the stack. So I had to code it this way :

Code: Select all

: ANIMATION
   BEGIN
      DREAM WAKE-UP
      CASE     
         . . . ( change rotation parameters )
      END-CASE
   64 = UNTIL ( exit when space bar is pressed ) ;


and before, have defined two words DREAM and WAKE-UP :

Code: Select all

: DREAM
   BEGIN 1 KEYROW
      ( change the point of view and draw an image as long as no key is pressed )
   ?DUP 0 <> UNTIL ( exit this loop and remember the key code ) ;

: WAKE-UP
   BEGIN   1 KEYROW
      ( loop as long as a key is still pressed )
   0 = UNTIL ( exit when no longer a key is pressed ) ;


on exit of WAKE-UP the key code gotten by DREAM is used by ANIMATION to change the rotation and if as long as no space bar press the sequence DREAM WAKE-UP is repeated.

The four arrow keys are thus active for changing the rotation :
LEFT ARROW : start rotate around X
RIGTH ARROW : start rotate around Y
UP ARROW : start rotate around Z
DOWN ARROW : reverse rotation
and the space bar exits !


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 173
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Postby polka » Sat May 23, 2020 11:05 pm

Hi all !

I hereby consecrate my yesterday mistyping (naming Digital Precision "SupperForth") because, as I tried to transfer securely PERSPECTIVE_FTH from the environment of my Qemulator (where I developped it), to my BBQL+TetroidCF : I almost missed my supper !

To make sure that all of you will be able to have this program running off the same SupperForth, I decide to unzip it from the DWJ archive. But I wanted it to run in WIN1 partition of my CF chip, whereas the unzipped product was for MDV1.

There is however a BACKUP basic program that could (in principle) be used to adapt to any default device ; but it did not work. So I examined the file, and actually, it is not a Basic program, more so a Lunatic program : the worst you may (maybe not) imagine to code with Bill Gates first Basic (if you can remember these days). From this file (visible in the attached zip) I extracted the useful lines 25 to 31, to code a SuperBasic procedure that does the main job :

Code: Select all

24 DEFine PROCedure DEFDEV( default$ )
25 Q=RESPR(16000)
26 LBYTES default$ & "_forth83_job",Q
27 POKE Q+4096+16,CODE(default$(1))
28 POKE Q+4096+17,CODE(default$(2))
29 POKE Q+4096+18,CODE(default$(3))
30 POKE Q+4096+19,CODE(default$(4))
31 SEXEC default$ & "_FORTH83_JOB",Q,15712,54432
32 END DEFine DEFDEV


This code modifies 4 bytes in the SupperForth executable, with the name of the default device that you prefer (in my case, WIN1) - and where you have copied SupperForth executable before modification.

After that, I had other worries : when started, SupperForth LOADs BLK1, as a boot file, and since it is a BLK type file, you cannot edit it outside of SupperForth, because you have first to LOAD_FILE EDITOR_FTH into SupperForth running to access BLK files. But you cannot boot SupperForth, because the BLK1 boot file has an error ! So... what ? (I include a corrected BLK1 in the attached zip).

What was the issue ? there are 6 words in SupperForth that you should NEVER use : MDV , FLP , MDV1_ , FLP1_ , MDV2_ and FLP2_ because they change the default device that you carefully prefered, and you cannot go back if your prefered device was neither an MDV nor an FLP. But there was an MDV1_ instruction in BLK1. So after the boot with BLK1 in WIN1, SupperForth will LOAD EDIT etc. looking for BLKs in MDV1 (where they are not).

Not finished ! I include also a corrected BLK3 : with better configuration parameters for EDITOR_FTH, which I include too, because I had also to modify this file - and also the FPMATHS_FTH file needed for SupperForth to have graphics. Because when you LOAD_FILE these two extensions of SupperForth, they change your prefered CSIZE ( 0 0 for me ).

Not to forget that there are things that I understand but could not correct (for the moment) :
1/ On starting, SupperForth does a secret "CAPS_LOCK" that it does not release whyen you tell him BYE
2/ In BLK1 I wanted to LOAD_FILE both FPMATHS and EDITOR : impossible ! in a BLK that you LOAD you may LOAD_FILE only once. I decided to LOAD_FILE FPMATHS from BLK1, and will create two words SED to LOAD_FILE EDITOR and FED to unplug it with the keyboard as needed ; to do !

All this to do some speed tests of SupperForth compared with ComputerOne FORTH on my BBQL and on Qemulator. I do not have faster machines but as you may see, with Qemulator at full speed the animations are already rather convincing.

DEFDEV.zip
some modifications for SupperForth
(5.35 KiB) Downloaded 53 times


A suivre ! POLKa


May the FORTH be with you !
POLKa

Who is online

Users browsing this forum: No registered users and 6 guests