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
/
MBUG072.ARC
/
CATCHJAN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
4KB
|
170 lines
{
Microbee Graphics Technology
Part 4: Line and circle drawings
in multiple modes.
LINE & CIRCLE DRAWING TESTS
File : MGTPART4.PAS
For MBUG Australia Inc..
P O Box 157,
Nunawadding 3131.
}
const
Scr64by16 : array[0..15] of byte =
($6B,$40,$51,$37,$12,$09,$10,$12,$48,$0F,$2F,$0F,0,0,0,0);
Scr80by24 : array[0..15] of byte =
($6B,$50,$58,$37,$1B,$05,$18,$1A,$48,$0A,$2A,$0A,$20,0,0,0);
type
plot_type = (doset,reset,invert);
var
aspect_ratio : real;
xpos, ypos : integer;
mode : plot_type;
{***********************************************************}
{********** START OF MICROBEE SPECIFIC SUBROUTINES *********}
procedure Set64by16; {Set up 6454 for 64*16 screen}
var
i : integer;
begin
for i := 0 to 15 do
begin
port[$0c] := i;
port[$0d] := Scr64by16[i];
end;
end;
procedure Set80by24; {Set up 6454 for 64*16 screen}
var
i : integer;
begin
for i := 0 to 15 do
begin
port[$0c] := i;
port[$0d] := Scr80by24[i];
end;
end;
procedure point_plot ( x,y : integer);
var
byteadr : integer;
mask : byte;
begin
byteadr := $F800 + (x div 8)*16 + (y mod 16);
if ((y mod 32) - 15) > 0 then byteadr := byteadr+$400;
mask := 1 shl (7 - (x mod 8));
port[$1C] := (y div 32) + $80;
case mode of
doset : mem[byteadr] := mem[byteadr] or mask;
reset : begin
mem[byteadr] := mem[byteadr] and not mask;
end;
invert : mem[byteadr] := mem[byteadr] xor mask;
end;
end;
procedure FillAttribute;
var
x,y : integer;
begin
port[$1C] := $90; {Latch Attribute Ram}
for y := 0 to 7 do
for x := 0 to 127 do
mem[$f000+x+y*128] := y;
end;
procedure ColScreen;
var
y : integer;
begin
port[8] := $40;
for y := 0 to $3FF do
mem[$F800+y] := 14;
port[8] := $00;
end;
procedure FillScreen;
var
x,y : integer;
begin
port[$1c] := $80; {Latch Screen Ram}
for y := 0 to 7 do
for x := 0 to 127 do
mem[$f000+x+(y*128)] := x+$80;
end;
procedure blankmem;
var x,y : integer;
begin
for y := 0 to 7 do begin
port[$1c] := $80 + y;
for x := 0 to $7FF do mem[$F800+x] := $00;
end;
end;
procedure setinv;
var
i : integer;
begin
port[$0b] := $01;
for i := 0 to $7FF do
mem[$F800+i] := not mem[$F000+i]; port[$0b] := $00;
end;
{*******************************************************************}
{*************** START OF POINT PLOTTING SUBROUTINES ***************}
procedure DDA (x1,y1,x2,y2 : integer);
var
length, i : integer;
x,y, xincrement, yincrement : real;
begin
length := abs(x2-x1);
if abs(y2-y1) > length then length := abs(y2-y1);
xincrement := (x2-x1)/length;
yincrement := (y2-y1)/length;
x := x1+0.5; y := y1 + 0.5;
for i := 1 to length do
begin
point_plot(trunc(x),trunc(y));
x := x + xincrement;
y := y + yincrement;
end;
end;
procedure circle(x1,y1,radius : integer);
var
xloc, yloc : integer;
angle : real;
begin
aspect_ratio := 1.6;
angle := 0.0;
repeat
xloc := trunc((radius+0.0)*sin(angle)*aspect_ratio);
yloc := trunc((radius+0.0)*cos(angle));
point_plot(x1+xloc, y1+yloc);
point_plot(x1+xloc, y1-yloc);
point_plot(x1-xloc, y1+yloc);
point_plot(x1-xloc, y1-yloc);
angle := angle + 0.01745; { pi/180, 1 degree }
until angle > 1.57079; { pi/2, 90 degrees }
end;
{*************** START OF MAIN PROGRAM ***************}
begin { main program }
blankmem; { clean up all 8 PCG banks first }
set64by16; fillscreen; colscreen; fillattribute; { fill screen, colour .. }
xpos := 511; ypos := 255;
mode := doset;
dda(0,0,xpos,ypos); { draw line , from 0,0 to xpos, ypos}
circle(255,127,50); { draw circle, at 255,127 radius 50 units }
set80by24; port[$1c] := $00; setinv;
end.