home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
forth
/
fifth.arc
/
FRAC.FIV
< prev
next >
Wrap
Text File
|
1986-05-27
|
3KB
|
142 lines
CREATE FRAC
CREATE MACHINE
EDIT
( TI=0 / IBM=1 Machine flag)
0 constant machine
~UP
CREATE XMAX
CREATE X
EDIT
( Maximum X for this machine)
: x machine if 320 else 720 endif ;
~UP
EDIT
( Maximum X value)
x constant xmax
~UP
CREATE YMAX
CREATE Y
EDIT
: y machine if 200 else 300 endif ;
~UP
EDIT
y constant ymax
~UP
CREATE GO
CREATE GCLS
EDIT
: GCLS 4 vmode
0 0 0 xmax 1- ymax 1- FILLBOX
;
~UP
CREATE ARRAY
CREATE DEFINE
EDIT
: DEFINE CREATE
16 1024 * ALLOT
DOES>
SWAP DUP 16384 U< IF ELSE ." Out of range, array" QUIT ENDIF
+
;
~UP
EDIT
DEFINE ARRAY
~UP
CREATE GENERATE
CREATE TOP
EDIT
VARIABLE TOP
~UP
EDIT
: GENERATE
2 0 ARRAY C!
0 1 ARRAY C! \ Changing the ARRAY initial values or
1 2 ARRAY C! \
3 TOP ! \ uncommenting this line and removing the
\ trailing +1 changes the pattern.
11 0 DO \ |
1 TOP @ 1- DO \ |
I ARRAY C@ \ V
( J 3 AND IF 1+ ELSE 1- THEN 3 AND ) 1+
TOP @ ARRAY C! 1 TOP +!
-1 +LOOP
LOOP
;
~UP
CREATE PLOT
CREATE X
EDIT
VARIABLE X
~UP
CREATE Y
EDIT
VARIABLE Y
~UP
CREATE RR
EDIT
variable rr
~UP
CREATE PREV
EDIT
: prev
dup 0 = if 2 y +! drop exit endif
dup 1 = if -3 x +! drop exit endif
2 = if -2 y +! exit endif
3 x +!
;
~UP
CREATE CURR
CREATE L
EDIT
: L
stack ab|abab ymax u< swap xmax u< and if
else drop drop X @ Y @ exit endif
moveto dup X @ Y @
stack ab|abab ymax u< swap xmax u< and if
else stack abcde|de exit endif
lineto point
;
~UP
EDIT
: CURR
dup 0 = if drop 2 y +! L
2 y +! L exit endif
dup 1 = if drop -3 x +! L
-3 x +! L exit endif
2 = if -2 y +! L
-2 y +! L exit endif
3 x +! L
3 x +! L
;
~UP
EDIT
( Color Rotation -> )
: PLOT
RR ! ( Save rotation)
xmax 2/ X ! ymax 2/ Y !
x @ y @ ( Initial point, color on stack)
1 array c@ rr @ + 3 and CURR
512 1 * 2 DO
I 1- ARRAY C@ RR @ + 3 AND PREV
I ARRAY C@ RR @ + 3 AND CURR
LOOP drop drop drop
;
~UP
EDIT
: GO
cls gcls generate
99 0 do
?term if abort endif
i [ 7 machine 4 * - ] literal mod 1+ i 3 and plot
loop
;
~UP
EDIT
: frac go ;
~UP
ABORT