home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG013.ARC
/
SIERPIN3.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
3KB
|
124 lines
program SIERPIN3;
{ Demonstration program in Turbo Pascal for
the MicroBee by Bob Burt
Program to set up PCG on the MicroBee for
LORES graphics and PLOT between any pair
of x,y coordinates, assuming a screen with
80 x 24 format. This version operates with
a plot routine using integer variables to
speed up the plotting rate, but with a
real variable option for the x coordinate
to cover values above 128
Since the 4th order width (w) is not an
integer, only 3 orders are permitted for
this version
x coordinate range: 0 to 159
y coordinate range: 0 to 71
0,0 at top left of screen
IMPORTANT : Compiler switch A must be set
to negative for the RECURSIVE procedures
and MAIN code ONLY ! }
{$C-}
const
w0 = 160; h0 = 64;
title = '*** Sierpinski Curves ***';
var
i,n : byte;
h,w,t1,t2,x,x0,y,y0 : byte;
{$I normal.pro}
{$I lores80.pro}
{$I draw.pro}
{$I ploti2.pro}
{$A-}
procedure B(i : byte); forward;
procedure C(i : byte); forward;
procedure D(i : byte); forward;
procedure A(i : byte);
begin if i > 0 then
begin
A(i - 1); t1 := x+w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
B(i - 1); t1 := x+2*w; plot(x,y,t1,y); x := t1;
D(i - 1); t1 := x+w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
A(i - 1)
end
end; {A(i)}
procedure B;
begin if i > 0 then
begin
B(i - 1); t1 := x-w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
C(i - 1); t2 := y-2*h; plot(x,y,x,t2); y := t2;
A(i - 1); t1 := x+w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
B(i - 1)
end
end; {B(i)}
procedure C;
begin if i > 0 then
begin
C(i - 1); t1 := x-w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
D(i - 1); t1 := x-2*w; plot(x,y,t1,y); x := t1;
B(i - 1); t1 := x-w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
C(i - 1)
end
end; {C(i)}
procedure D;
begin if i > 0 then
begin
D(i - 1); t1 := x+w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
A(i - 1); t2 := y+2*h; plot(x,y,x,t2); y := t2;
C(i - 1); t1 := x-w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
D(i - 1)
end
end; {D(i)}
begin {main}
clrscr;
gotoxy(22,8);
writeln(title);
repeat
gotoxy(10,11);
write(^G,'What order of Curve do you require (1 to 3 only) : ');
readln(n)
until (n > 0) and (n < 4);
gotoxy(53,24); {establish cursor position clear of graphics}
i := 0; h := h0 div 4; w := w0 div 4; x0 := 2*w; y0 := 3*h;
lores80;
plot(0,0,159,0); {plot frame}
plot(0,63,159,63);
plot(0,1,0,62);
plot(159,1,159,62);
repeat
i := i + 1; x0 := x0 - w;
h := h div 2; w := w div 2; y0 := y0 + h;
x := x0; y := y0;
A(i); t1 := x+w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
B(i); t1 := x-w; t2 := y-h; plot(x,y,t1,t2); x := t1; y := t2;
C(i); t1 := x-w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
D(i); t1 := x+w; t2 := y+h; plot(x,y,t1,t2); x := t1; y := t2;
until i = n;
gotoxy(28,24);
write(title);
repeat until keypressed;
clrscr; {replace chr(128) with chr(32)}
normal;
writeln(^G)
end. {main}