Re: HiRes package for Toddy Forth
Posted: Tue Mar 02, 2021 3:50 am
* Files replaced due a issue with ABS word, see previous post
Discussion forums for users of the Sinclair 8-bit range of computers - ZX80, ZX81, ZX Spectrum, Z88, clones...
https://www.sinclairzxworld.com/
The intention is to make tforth as close as possible with Forth 79, so version 1.6 brings the following vocabulary changes:Moggy wrote: ↑Tue Mar 02, 2021 2:03 pm I cannot wait to see what V2.0 will be like considering how good this is already. I know you are very busy but is there any chance you could perhaps print a few tips on how to use this add on for those of us(me ) who struggle a bit with these things. I understand the principle but not the execution of the commands if you see what I mean.
Code: Select all
Tforth 1.5 tForth 1.6
CLS PAGE
INVERT (excluded)
CONTEXT (excluded)
CURRENT (excluded)
M+ (excluded)
D- (excluded)
UM* U*
UM/MOD U/MOD
UD/MOD M/MOD
INPUT QUERY
LFA >LFA
CFA >CFA
- >NFA
- SPACES
- FILL
- DPL
- CONVERT
Code: Select all
GPAGE ( clear the graphics screen )
1 PMODE ( set pixels )
HGR 0 0 GPIX KEY DROP TEXT
Code: Select all
HGR 100 0 GPIX 50 86 GPIX KEY DROP
HGR -50 -86 GLINE 100 0 GLINE -50 86 GLINE KEY DROP TEXT
Code: Select all
HPAGE HGR 50 86 GPIX 0 0 GLINETO 100 0 GLINETO 50 86 GLINETO KEY DROP TEXT
Code: Select all
: GBOX ( width height -- )
OVER 0 GLINE 0 OVER GLINE
SWAP NEGATE 0 GLINE
NEGATE 0 SWAP GLINE ;
Code: Select all
GPAGE HGR 1 PMODE 0 0 GPIX 100 50 GBOX KEY 50 100 GBOX KEY 2DROP TEXT
Code: Select all
HGR 0 PMODE 100 50 GBOX KEY 2 PMODE 50 100 GBOX KEY 2DROP TEXT
Code: Select all
: MOIRE PMODE 192 0 DO 0 0 GPIX 255 I GLINE LOOP ;
GPAGE HGR 1 MOIRE 2 MOIRE 0 MOIRE TEXT
Yes, and also like other computers like Apple or TRS Color that have different video modes for text and graphics.
Thanks to Garry Lancaster, as I'm using his Z88 Camel Forth "draw Line routine". But my "find pixel address" routine also helps a lot.I am also impressed at the speed of the GLINE command which for a slow machine like the 81 is very impressive.
I have the "Camel Forth" practically ready to run on the ZX81, possibly after the release of Toddy Forth 2.0 I will also make it available, so we will have a Forth 79 and also an ANS Forth for the ZX81, expanding the range of options.I have also discovered why Brodies two books cause some problems with programming examples, it seem that when he found out that his publisher was not reprinting them he gave permission for internet versions to be made providing they were brought up to ANSI standard and you need to search for the early version of the book that was more like FIG/79 or buy the original book to be useful for Toddy type Forths.
Code: Select all
10 FOR n=0 TO 174
20 PLOT n,0: PLOT n,175
30 NEXT n
40 FOR n=0 TO 174
50 PLOT 0,n: PLOT 175,n
60 NEXT n
70 LET a=0
80 FOR n=167 TO 0 STEP -8
90 LET a=a+8
100 PLOT 0,n: DRAW a,-n
110 DRAW n,a
120 DRAW -a,n
130 DRAW -n,-a
140 NEXT n
Code: Select all
: HLINES
175 0 DO I 0 GPIX I 175 GPIX LOOP ;
: VLINES
175 0 DO 0 I GPIX 175 I GPIX LOOP ;
: WEB
GPAGE HGR 1 PMODE
HLINES VLINES 0
0 167 DO 8 +
0 I GPIX DUP I NEGATE GLINE
I OVER GLINE
DUP NEGATE I GLINE
I NEGATE OVER NEGATE GLINE
-8 +LOOP DROP ;
Code: Select all
( DRAW CIRCLES AND ELLIPSES )
CREATE SINES
0000 , 0175 , 0349 , 0523 ,
0698 , 0872 , 1045 , 1219 ,
1392 , 1564 , 1736 , 1908 ,
2079 , 2250 , 2419 , 2588 ,
2756 , 2924 , 3090 , 3256 ,
3420 , 3548 , 3746 , 3907 ,
4067 , 4226 , 4384 , 4540 ,
4695 , 4848 , 5000 , 5150 ,
5229 , 5446 , 5592 , 5736 ,
5878 , 6018 , 6157 , 6293 ,
6428 , 6561 , 6691 , 6820 ,
6947 , 7071 , 7193 , 7313 ,
7431 , 7547 , 7660 , 7771 ,
7880 , 7986 , 8090 , 8191 ,
8290 , 8387 , 8480 , 8572 ,
8660 , 8746 , 8829 , 8910 ,
8988 , 9063 , 9135 , 9205 ,
9272 , 9336 , 9397 , 9455 ,
9511 , 9563 , 9613 , 9659 ,
9703 , 9744 , 9781 , 9816 ,
9848 , 9877 , 9903 , 9926 ,
9956 , 9962 , 9976 , 9986 ,
9994 , 9998 , 10000 ,
: SIN* ( n ang -- n*sin[ang] )
ABS 90 /MOD
TUCK 1 AND IF 90 SWAP - THEN
2* SINES + @ SWAP 2 AND
IF NEGATE THEN 10000 */ ;
: COS* ( n ang -- n*cos[ang] )
90 + SIN* ;
( Draw ellipse )
: GELLIPSE ( x y w h -- )
SWAP ABS SWAP ABS 1 MAX
DUP 8 * 360 MIN ( nr of steps)
360 SWAP / >R
DUP >R 2OVER R> + GPIX R>
360 0 DO 16477 !
2OVER 2OVER
I COS* ROT + SWAP
I SIN* ROT + SWAP
GLINETO
16477 @ DUP
+LOOP
DROP NIP + GLINETO ;
( Draw circle )
: GCIRCLE ( x y r -- )
DUP GELLIPSE ;
Code: Select all
: GLOBE ( -- )
GPAGE HGR 1 PMODE
80 0 DO
127 95 80 I GELLIPSE
127 95 I 80 GELLIPSE
20 +LOOP
127 95 80 GCIRCLE ;
Code: Select all
: DISCO ( -- )
GPAGE HGR
360 0 DO 127 95 GPIX
90 DUP I COS*
SWAP I SIN* GLINE
LOOP ;
Code: Select all
10 HGR2: HCOLOR=3
20 FOR F=1 TO 139
30 H=80+80*COS(f/16)
40 HPLOT F,H TO H,F
50 NEXT F
Code: Select all
: RAD2DEG 180 * 10000 U* 31416 U/MOD NIP ;
: HGLASS GPAGE HGR 1 PMODE
140 1 DO
80 80 I RAD2DEG 16 / COS* +
I OVER GPIX I GLINETO
LOOP ;