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
/
PLOT80.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
9KB
|
222 lines
program PLOT80;
{ Demonstration program 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
x coordinate range: 0 to 159
y coordinate range: 0 to 71
0,0 at top left of screen }
const
title = '*** Plotting with LORES Graphics ***';
space18 = ' ';
var
x1,y1,x2,y2 : real;
procedure normal; external $E02A;
{This procedure calls copy_inv in the Micro-
Bee disk ROM and fills the PCG with inverse
characters of the current font type. All
registers are preserved }
procedure lores;
{This procedure fills the PCG with the
LORES graphics set and also fills the
screen with chr(128) in preparation
for the PLOT routine }
begin
inline ($F5/$C5/$D5/$E5/
$3E/8/$21/0/$F8/$0E/$80/$59/
$16/4/$AF/$CB/$43/$28/2/$F6/$F0/$CB/$4B/$28/
2/$F6/$0F/6/4/$77/$23/$10/$FC/$CB/$0B/$CB/$0B/
$15/$20/$E6/$0C/$20/$E0/
$21/0/$F0/1/$80/7/$16/$80/$72/$23/$0B/$78/$B1/$20/$F9/
$E1/$D1/$C1/$F1/$C9);
end; {procedure lores}
procedure draw; { Derived from the LINE routine on page 209
of "More TRS-80 Assembly Language Programming"
by Bill Borden (Radio Shack) }
begin
inline ($F5/$C5/$D5/$E5/ { Save Registers }
$DD/$E5/
$18/$0B/ { JUMP: JR LINE }
0/0/0/0/0/ { BLOCK: DEFS 11 }
0/0/0/0/0/0/
$3A/*-3/ { LINE: LD A,(BLOCK+9) }
$B7/ { OR A }
$28/$0D/ { JR Z,LINE10 }
$21/0/0/ { LD HL,0 }
$ED/$5B/*-18/ { LD DE,(BLOCK+4)}
$B7/ { OR A }
$ED/$52/ { SBC HL,DE }
$22/*-24/ { LD (BLOCK+4),HL}
$3A/*-21/ { LINE10: LD A,(BLOCK+10)}
$B7/ { OR A }
$28/$0D/ { JR Z,LINE20 }
$21/0/0/ { LD HL,0 }
$ED/$5B/*-35/ { LD DE.(BLOCK+6)}
$B7/ { OR A }
$ED/$52/ { SBC HL,DE }
$22/*-41/ { LD (BLOCK+6),HL}
$DD/$21/*-51/ { LINE20: LD IX,BLOCK }
$DD/$66/1/ { LD H,(IX+1) }
$DD/$6E/3/ { LD L,(IX+3) }
$AF/ { XOR A }
$CD/*+40/ { CALL SETRST }
$2A/*-64/ { LD HL,(BLOCK) }
$ED/$5B/*-64/ { LD DE,(BLOCK+4)}
$19/ { ADD HL,DE }
$22/*-72/ { LD (BLOCK),HL }
$2A/*-73/ { LD HL,(BLOCK+2)}
$ED/$5B/*-73/ { LD DE,(BLOCK+6)}
$19/ { ADD HL,DE }
$22/*-81/ { LD (BLOCK+2),HL}
$3A/*-78/ { LD A,(BLOCK+8) }
$3D/ { DEC A }
$32/*-82/ { LD (BLOCK+8),A }
$20/$D3/ { JR NZ,LINE20 }
$DD/$E1/ { Restore Registers }
$E1/$D1/$C1/$F1/
$C9/ { RET }
$F5/ { SETRST: PUSH AF }
$5C/ { LD E,H }
$7D/ { LD A,L }
$CB/$3B/ { SRL E }
$16/0/ { LD D,0 }
$30/1/ { JR NC,SET10 }
$14/ { INC D }
6/$FF/ { SET10: LD B,0FFH }
4/ { SET20: INC B }
$D6/3/ { SUB 3 }
$F2/*-4/ { JP P,SET20 }
$C6/3/ { ADD A,3 }
7/ { RLCA }
$82/ { ADD A,D }
$4F/ { LD C,A }
$68/ { LD L,B }
$26/0/ { LD H,0 }
$D5/ { PUSH DE }
6/4/ { LD B,4 }
$29/ { SET30: ADD HL,HL }
$10/$FD/ { DJNZ SET30 }
$54/ { LD D,H }
$5D/ { LD E,L }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL }
$19/ { ADD HL,DE }
$D1/ { POP DE }
$16/0/ { LD D,0 }
$19/ { ADD HL,DE }
$11/0/$F0/ { LD DE,0F000H }
$19/ { ADD HL,DE }
6/0/ { LD B,0 }
$F1/ { POP AF }
$B7/ { OR A }
$20/$0C/ { JR NZ,RESET }
$DD/$21/*+22/ { LD IX,MASK }
$DD/9/ { ADD IX,BC }
$7E/ { LD A,(HL) }
$DD/$B6/0/ { OR (IX) }
$77/ { SET36: LD (HL),A }
$C9/ { RET }
$DD/$21/*+16/ { RESET: LD IX,MASK1 }
$DD/9/ { ADD IX,BC }
$7E/ { LD A,(HL) }
$DD/$A6/0/ { AND (IX) }
$18/$F2/ { JR SET36 }
$81/ { MASK: DEFB 81H }
$82/ { DEFB 82H }
$84/ { DEFB 84H }
$88/ { DEFB 88H }
$90/ { DEFB 90H }
$A0/ { DEFB 0A0H }
$BE/ { MASK1: DEFB 0BEH }
$BD/ { DEFB 0BDH }
$BB/ { DEFB 0BBH }
$B7/ { DEFB 0B7H }
$AF/ { DEFB 0AFH }
$9F); { DEFB 09FH }
end; {procedure draw}
procedure plot(x1,y1,x2,y2 : real);
label 99;
var
dx,dy,x,y,xi,yi : real;
count : integer;
begin
dx := x2 - x1;
dy := y2 - y1;
if (dx = 0) and (dy = 0) then
begin
xi := 0; yi := 0; count := 1; goto 99
end; {if}
if abs(dx) > abs(dy) then
begin
xi := 256; count := trunc(abs(dx) + 1); yi := abs(dy*256/dx)
end; {if}
if abs(dx) <= abs(dy) then
begin
yi := 256; count := trunc(abs(dy) + 1); xi := abs(dx*256/dy)
end; {if}
if abs(dx) <> (count - 1)*xi/256 then xi := xi + 1;
if abs(dy) <> (count - 1)*yi/256 then yi := yi + 1;
99 :
if dx < 0 then mem[addr(draw)+17] := 1 {negate x inc }
else mem[addr(draw)+17] := 0;
if dy < 0 then mem[addr(draw)+18] := 1 {negate y inc }
else mem[addr(draw)+18] := 0;
x := x1*256; y := y1*256;
mem[addr(draw)+8] := trunc(x - int(x/256)*256); {scaled x value }
mem[addr(draw)+9] := trunc(x/256);
mem[addr(draw)+10] := trunc(y - int(y/256)*256); {scaled y value }
mem[addr(draw)+11] := trunc(y/256);
mem[addr(draw)+12] := trunc(xi - int(xi/256)*256);{abs x inc, scaled}
mem[addr(draw)+13] := trunc(xi/256);
mem[addr(draw)+14] := trunc(yi - int(yi/256)*256);{abs y inc, scaled}
mem[addr(draw)+15] := trunc(yi/256);
mem[addr(draw)+16] := count; {count }
draw
end; {procedure plot}
begin {main}
clrscr;
write(space18);
writeln(title);
gotoxy(22,8);
writeln('Address of "draw" is : ',addr(draw));
gotoxy(20,10);
writeln;
writeln('x coordinate range : 0 to 159');
writeln('y coordinate range : 0 to 71');
writeln('Coordinates 0,0 are at the top left of the screen');
writeln;
writeln('Note - enter plot values separated by spaces, NOT commas!');
writeln;
write('Enter plot values (x1 y1 x2 y2) : ');
readln(x1,y1,x2,y2);
lores;
plot(x1,y1,x2,y2);
repeat until keypressed;
clrscr; {replace chr(128) with chr(32)}
normal;
writeln(^G)
end {main}.