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
/
MBUG025.ARC
/
DRAW.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
6KB
|
183 lines
PROGRAM DRAW;
{ Written by Lang Stuiver }
{$U+ : allow for the user to stop the program (^C), but should only be done }
{ if necessary, as when ^C'd it will return to Turbo with lores }
{ characters instead of inverse, and 9 scan line high chars. }
var
ch: char;
I,J,K: integer;
pcg: array[1..2048] of byte absolute $F800;
screen: array[0..23,0..79] of byte absolute $F000;
x,y: integer;
a: byte;
pen: boolean; { true = draw, false = erase }
point: boolean; { when true, dot call says if point specified IS ON }
lit: boolean; {or not in the variable lit (true = on, false = off)}
(***************************************************************************)
Procedure dot(x1,y1:integer);
var
x2,y2: real;
x3,y3: integer;
b: byte;
begin
{ y1:=71-y1; }
{ Delete the curly brackets on the above line to make (0,0) at the bottom of }
{ the screen, add them again to make (0,0) at the top of the screen }
x2:=x1/2; y2:=y1/3;
x3:=(x1 mod 2); y3:=(y1 mod 3);
x1:=trunc(x2); y1:=trunc(y2);
a:=screen[y1,x1];
if (a<128) or (a>128+63) then a:=128; { if character is a non graphics char }
{ than make it one }
case y3 of
0:b:=x3+1;
1:b:=4*(x3+1);
2:b:=16*(x3+1);
end; {of case}
if not point then begin
if pen then a:=(a or b) else a:=(a and (255-b));
screen[y1,x1]:=a;
end {Not point}
else {If point}
if (a and b) = 0 then lit:=false else lit:=true;
end;
(***************************************************************************)
Procedure normal;
{$U- : Disable the ^C/^S keys whilst programming the 6545}
begin
clrscr;
port[$C]:=9; { Puts 10 in reg. 9 of the 6545 screen chip }
port[$D]:=10; { This gives 11 scan lines, the normal amount for CPM }
inline($CD/$E02A); { Machine code for: CALL E02A (which actually means }
{ call the routine in the boot rom which loads the PCG }
{ with inverse characters (to wipe over the lores) }
end;
(***************************************************************************)
Procedure lores;
var
L: byte;
{$U-}
begin
clrscr;
port[$C]:=9; { Output 9 to the 6545 address port }
port[$D]:=8; { Output 8 to the 6545 data port }
{ The above two lines put the number 8 in register 9 of the 6545. }
{ Register 9 is the amount of scan lines per character -1, this }
{ gives us characters with nine scan lines (normally 11, or 16 in }
{ BASIC) }
(** THIS SETS UP pcg for 'lores' (160 x 72) **)
for i:=0 to 63 do
for k:=1 to 9 do
begin
j:=i*16+k;
pcg[j]:=0;
case k of
1,2,3: begin
if (i and 1)=1 then pcg[j]:=240;
if (i and 2)=2 then pcg[j]:=15;
if (i and 3)=3 then pcg[j]:=255;
end;
4,5,6: begin
if (i and 4)=4 then pcg[j]:=240;
if (i and 8)=8 then pcg[j]:=15;
if (i and 12)=12 then pcg[j]:=255;
end;
7,8,9: begin
if (i and 16)=16 then pcg[j]:=240;
if (i and 32)=32 then pcg[j]:=15;
if (i and 48)=48 then pcg[j]:=255;
end;
end { case }
end { for }
end;
(***************************************************************************)
Procedure plot(xfrom,yfrom,xto,yto:integer);
var
a,b: integer;
begin
a:=xfrom-xto; b:=yfrom-yto;
if abs(a) > abs(b) then begin
if xfrom<xto
then
for x:=xfrom to xto do dot(x,yfrom + round((x-xfrom)/a * b))
else
for x:=xfrom downto xto do dot(x,yfrom + round((x-xfrom)/a * b));
end
else
begin
if yfrom<yto
then
for y:=yfrom to yto do dot(xfrom + round((y-yfrom)/b * a),y)
else
for y:=yfrom downto yto do dot(xfrom + round((y-yfrom)/b * a),y);
end;
end;
(***************************************************************************)
Procedure invert(xi,yi:integer);
var
temp,temp1: boolean;
begin
temp:=point; temp1:=pen;
point:=true; dot(xi,yi);
point:=false;
if lit then pen:=false else pen:=true;
dot(xi,yi);
point:=temp; pen:=temp1;
end;
(***************************************************************************)
begin
lores;
pen:=false; point:=false;
dot(1,2); { Wipe wipe out cursor } pen:=true;
{ Data for Aus, crude but it draws! }
plot(108,55,115,35); plot(115,35,88,2); plot(88,2,82,12);
plot(82,12,75,8); plot(75,8,78,4); plot(78,4,60,4); plot(60,4,58,11);
plot(58,11,48,8); plot(48,8,22,28); plot(22,28,25,50); dot(24,51);
plot(25,52,60,45); plot(60,45,90,57); plot(90,57,95,54);
plot(95,54,100,57); plot(100,57,108,55);
{ not to forget Tassie }
plot(95,62,101,62); plot(101,62,98,69); plot(98,69,95,62);
gotoxy(20,9);
pen:=false; dot(1,2); { Wipe over wiped over cursor ! }
write('A MAP THAT ALMOST LOOKS RIGHT!');
gotoxy(46,17); write('Melbourne');
gotoxy(30,1); write('AUSTRALIA');
gotoxy(30,23); write('HIT ANY KEY');
read(kbd,ch);
lores;
gotoxy(33,3);
pen:=true; plot(0,0,159,71); plot(159,0,0,71); plot(0,0,159,0);
plot(159,0,159,71); plot(159,71,0,71); plot(0,71,0,0);
write('HIT ANY KEY');
read(kbd,ch);
normal;
end.
(***************************************************************************)