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
/
HILBERT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
4KB
|
153 lines
program HILBERT;
{ Demonstration program in Turbo Pascal for
the MicroBee developed 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 uses a plot
routine basically using integer variables
for speed, but including a real variable
option for the x coordinate when its value
exceeds 128
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 !
This version includes colour procedures }
{$C-}
const
w0 = 160; h0 = 64;
title = '*** Hilbert Curves ***';
var
i,n : byte;
h,t,w,x,y,x0,y0 : integer;
{$I normal.pro}
{$I lores80.pro}
{$I draw.pro}
{$I ploti2.pro}
{$I colinit.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
D(i - 1); t := x-w; plot(x,y,t,y); x := t;
A(i - 1); t := y-h; plot(x,y,x,t); y := t;
A(i - 1); t := x+w; plot(x,y,t,y); x := t;
B(i - 1)
end
end; {A(i)}
procedure B;
begin if i > 0 then
begin
C(i - 1); t := y+h; plot(x,y,x,t); y := t;
B(i - 1); t := x+w; plot(x,y,t,y); x := t;
B(i - 1); t := y-h; plot(x,y,x,t); y := t;
A(i - 1)
end
end; {B(i)}
procedure C;
begin if i > 0 then
begin
B(i - 1); t := x+w; plot(x,y,t,y); x := t;
C(i - 1); t := y+h; plot(x,y,x,t); y := t;
C(i - 1); t := x-w; plot(x,y,t,y); x := t;
D(i - 1)
end
end; {C(i)}
procedure D;
begin if i > 0 then
begin
A(i - 1); t := y-h; plot(x,y,x,t); y := t;
D(i - 1); t := x-w; plot(x,y,t,y); x := t;
D(i - 1); t := y+h; plot(x,y,x,t); y := t;
C(i - 1)
end
end; {D(i)}
procedure set_col;
const
next_line = $50;
var
col_ram,left,right : integer;
line,loc,colour : byte;
begin
port[8] := 78; {colour RAM on, RGB full}
left := $F800; right := $F84F; colour := 0;
for col_ram := left to right do
mem[col_ram] := 4; {line 1, red on black}
for col_ram := left + next_line*21 to right + next_line*21 do
mem[col_ram] := 4;
for line := 2 to 21 do
begin
mem[left + next_line] := 4; {left side }
mem[right + next_line] := 4; {right side}
colour := colour + 1;
if colour = 16 then colour := 1; {avoid black on black!}
for loc := 1 to 78 do
mem[left + next_line + loc] := colour;
left := left + next_line; right := right + next_line
end; {for line}
port[8] := 14; {PCG ram on, RGB full}
end; {procedure set_col}
begin {main}
clrscr;
colinit; {initialise for color procedure}
gotoxy(24,8);
color(4,6,0); {red foreground, deep blue background, intensity 0}
write(title);
repeat
gotoxy(10,11);
color(2,3,0); {green foreground, olive background}
write(^G,'What order of Curve do you require (1 to 4 only) : ');
color(4,3,0); {response red on olive}
readln(n)
until (n > 0) and (n <5 );
gotoxy(52,24); {establish cursor position clear of graphics}
set_col; {set up colour values in colour RAM}
i := 0; h := h0; w := w0; x0 := w div 2; y0 := h div 2;
lores80;
plot(0,0,159,0); {plot frame}
plot(0,64,159,64);
plot(0,1,0,63);
plot(159,1,159,63);
repeat
i := i + 1; h := h div 2; w := w div 2;
x0 := x0 + (w div 2); y0 := y0 + (h div 2);
x := x0; y := y0;
A(i)
until i = n;
gotoxy(30,24);
color(0,3,7); {black foreground, yellow background}
write(title);
repeat until keypressed;
clrscr; {replace chr(128) with chr(32)}
normal;
writeln(^G);
end. {main}