V-FORTH - Forth-83 for the VIC

Basic and Machine Language

Moderator: Moderators

armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

Where can I find version 4.9.
I only have 4.7.
Thanks for your patience and help.
Greetings Armando
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

armypavarmy wrote: Wed Feb 22, 2023 3:47 am Where can I find version 4.9.
I only have 4.7.
I've updated the files on my web site

https://eden.mose.org.uk/download/
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

I finished and saved the snake program with Autosave
taken from the Forth c64 version.
I can't find a program to write Seq files.
With what program did you write the Demo.fs files. ??
I only have programs for Vic20 and c64 that read and print Seq files but don't write them.
Attached is the Snake. file
Load "snake.prg",8,1 : Sys8192
Thanks for help. Armando
snake.zip
(6.15 KiB) Downloaded 56 times
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

armypavarmy wrote: Thu Feb 23, 2023 3:43 am I finished and saved the snake program with Autosave
Very colourful.
I can't find a program to write Seq files.
With what program did you write the Demo.fs files. ??
I only have programs for Vic20 and c64 that read and print Seq files but don't write them.
I don't edit files actually on the VIC, I prefer use an editor on my desktop PC and copy them into a disk image. I use my own tools (cbmshell) but you can also do this with the c1541 program which comes with VICE.

There are probably text editors on the VIC you could use, I don't know of any myself.
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

HI,
I insert two listings that I made.
One normal and the other for Minigrafik.
I would like to have them in Vforth if possible.
They both work but the execution speed is very slow, especially for the version with minigrafik.
I am sure that with the Vforth they will be faster.
Thank you . Greetings Armando
Vic20- Wolfram-Automata.zip
(131.41 KiB) Downloaded 69 times
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: V-FORTH - Forth-83 for the VIC

Post by Mike »

armypavarmy wrote:They both work but the execution speed is very slow, especially for the version with minigrafik.
This is an unfair and misleading comparison! The version in pure BASIC only works on the text screen, whereas the MG version sets pixels in the graphics screen and correspondingly has to operate on 64 hires pixels instead of 1 single character cell for a given screen estate.

Here is how I would implement those Automatons with MINIGRAFIK. The first line are random pixels, subsequent lines have Rule 110 applied (can be changed with the values in line 9):

Code: Select all

1 X=RND(-TI):CLR
2 FORL=0TO1:FORM=0TO1:FORR=0TO1:READC(1-L,1-M,1-R):NEXT:NEXT:NEXT
3 @ON:@CLR:FORX=0TO159:@RND({PI})+.5,X,.:NEXT
4 FORY=0TO190:@C(@(159,Y),@(0,Y),@(1,Y)),0,Y+1
5 FORX=1TO158:@C(@(X-1,Y),@(X,Y),@(X+1,Y)),X,Y+1:NEXT
6 @C(@(158,Y),@(159,Y),@(0,Y)),159,Y+1:NEXT
7 GETA$:IFA$=""THEN7
8 @RETURN:END
9 DATA0,1,1,0,1,1,1,0
The program above needs roughly 10 1/2 minutes to fill the screen. It avoids the slow 2^A operation followed by AND N to mask out the relevant rule bit, and instead does a direct lookup in the array C(L,M,R) filled in line 2 from the data in line 9 (the 8 digits represent the rule number in binary, %01101110 = 110 decimal). Lines 4 and 6 also handle the wrap-around at the left and right edge.

Forth could do all relevant calculations with byte and word values. That surely is faster than the (implied) float arithmetic of BASIC. Nothing to prove here.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

My graphics vocabularies don't currently have a word to test if a pixel is set, I'll add one and then post a FORTH implementation.

I've been recently trying to implement an efficient Game of Life, but even with optimizations it's very slow.
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

Thank you.
if you can, the low resolution version (Basic) converted to Vforth is also fine.
I would like.
Greetings Armando
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

Here's the equivalent of the BASIC (text mode) version in FORTH

Code: Select all

variable n

: wolfram-text
    150  n  !
    147  emit
    37888  dup  512  0  fill
    0  4106  c!
    begin
	4586  4097  do
	    i  1-  c@  2*
	    i  c@  +  2*
	    i  1+  c@  +
	    5  rshift
	    1  swap  lshift
	    n  @  and  if
		32
	    else
		0
	    then
	    i  22  +  c!
	loop
	1  n  +!
    again  ;
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

HI,
thanks for help. I try to do it.
Greetings Armando
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: V-FORTH - Forth-83 for the VIC

Post by armypavarmy »

HI,
Here is the Automata .Prg file.
Version with Vforth.
Very beautiful and fast.
Load with Load "automata* ",8,1 : then Sys 8192.
Thanks to the author (Srowe) for the cooperation.

automata-vforth-.zip
(6.19 KiB) Downloaded 59 times
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Post by srowe »

I'd nearly forgotten about this. I've added a new example to the latest release which contains 3 versions: text, low resolution and high resolution graphics.
Post Reply