home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug094.arc
/
DRAW.I
< prev
next >
Wrap
Text File
|
1979-12-31
|
3KB
|
118 lines
Procedure draw(x0,y0,x1,y1,colour:integer);
{Colour => 0= reset ; 1= set ; 2 = invert}
var
a1,a2,s1,s2,d1,d2,d3,n1:integer;
ok:boolean;
{ dda algorithm program
adapted from byte august 21 1981
all variables names have been retained.}
Procedure SetUpValues;
{***********************************
** setup values **
***********************************
setup the x difference and the y difference dy,dx }
begin
d1 := x1 - x0;
d2 := y1 - y0;
{ initialise scratch variables }
s1 := 0;
s2 := 1;
a1 := 1;
a2 := 0;
if d1 < 0 then
begin
a1 := -1 ; { we will be decrementing x0 later}
d1 := abs(d1)
end;
if d2 < 0
then begin
s2:= -1 ; { we will decrement y0 later}
d2:= abs(d2)
end;
{ if d2 has a greater magnitude then make it the governing var}
if d1 < d2 then
begin
n1:=d1 ;{swap d1 and d2}
d1:=d2;
d2:=n1;
s1:=a1;
a1:=0;
a2:=s2;
s2:=0
end;
d3 := d1 shr 1;
n1 := 1
end;
Procedure ddamc;
begin
inline($2A/N1/ {LD HL,N1}
$23/ {INC HL }
$22/N1/ {LD N1,HL}
$2A/X0/ {LD HL,X0}
$ED/$5B/A1/ {LD DE,A1}
$19/ {ADD HL,DE}
$22/X0/ {LD X0,HL}
$2A/Y0/ {LD HL,Y0}
$ED/$5B/A2/ {LD DE,A2}
$19/ {ADD HL,DE}
$22/Y0/ {LD Y0,HL}
$2A/D3/ {LD HL,D3}
$ED/$5B/D2/ {LD DE,D2}
$19/ {ADD HL,DE}
$22/D3/ {LD D3,HL}
$B7/ {OR A,A ;CLEAR CARRY}
$ED/$5B/D1/ {LD DE,D1}
$ED/$52/ {SBC HL,DE}
$CA/*+40/ {JP Z,FINISH}
$DA/*+37/ {JP C,FINISH}
$2A/X0/ {LD HL,X0}
$ED/$5B/S1/ {LD DE,S1}
$19/ {ADD HL,DE}
$22/X0/ {LD X0,HL}
$2A/Y0/ {LD HL,Y0}
$ED/$5B/S2/ {LD DE,S2}
$19/ {ADD HL,DE}
$22/Y0/ {LD Y0,HL}
$2A/D3/ {LD HL,D3}
$ED/$5B/D1/ {LD DE,D1}
$B7/ {OR A ;CLEAR CARRY}
$ED/$52/ {SBC HL,DE}
$22/D3/ {LD D3,HL}
$00/0/0/0/0) {FINISH NOP}
end;
Var Count:byte;
begin {main}
SetUpValues;
ok:=HiDot(x0,y0,colour);
While n1<=d1 do
begin
DDAMC;
ok:=HiDot(x0,y0,Colour)
end
end;
function HiPlot(x0,y0,x1,y1,colour:integer):Boolean;
begin
draw(x0,y0,x1,y1,colour);
HiPlot:=True
end;