home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug165.arc
/
TRAKCOPY.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
11KB
|
363 lines
program disk_track_copy;
const
version = '2';
revision = '0';
gc_num = 12;
track_mem_start = $3800;
seldsk = 8;
settrk = 9;
setsec = 10;
setdma = 11;
read_r = 12;
write_r = 13;
selectdrive = 14;
getdefault = 25;
type
graphics_array = array [1..gc_num,0..15] of byte;
string_40 = string [40];
const
graphics_definition : graphics_array =
({A} ($00,$00,$00,$00,$00,$3F,$7F,$70,$70,$70,$70,$00,$00,$00,$00,$00),
{B} ($00,$00,$00,$00,$00,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00),
{C} ($00,$00,$00,$00,$00,$F0,$F8,$38,$3C,$3E,$3E,$00,$00,$00,$00,$00),
{D} ($70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$00,$00,$00,$00,$00),
{E} ($3E,$3E,$3E,$3E,$3E,$3E,$3E,$3E,$3E,$3E,$3E,$00,$00,$00,$00,$00),
{F} ($70,$70,$70,$70,$7F,$3F,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00),
{G} ($00,$00,$00,$00,$FF,$FF,$FF,$55,$00,$00,$00,$00,$00,$00,$00,$00),
{H} ($3E,$3E,$3E,$3E,$FE,$FE,$FC,$50,$00,$00,$00,$00,$00,$00,$00,$00),
{I} ($00,$00,$03,$0F,$3F,$FF,$3F,$0F,$03,$00,$00,$00,$00,$00,$00,$00),
{J} ($00,$00,$00,$00,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00),
{K} ($00,$00,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00),
{L} ($00,$00,$C0,$F0,$FC,$FF,$FC,$F0,$C0,$00,$00,$00,$00,$00,$00,$00));
var
track_mem : array [1..10,0..5119] of byte absolute track_mem_start;
graphics_characters : graphics_array absolute $FC10;
space_pcg : array [0..15] of byte absolute $FA00;
bdos_start : integer absolute 6;
source_num, destination_num, track, t_track, tr, max_track, i,
record_number, trans_record, dph_s, dph_d, track_mem_add
: integer;
default_drive, result : byte;
key : char;
disk_error, abort : boolean;
procedure load_inverse;
begin
port[11]:=1;
for i:=$F000 to $F7FF do
mem[i+$800]:=not mem[i];
port[11]:=0;
end;
procedure underline;
begin
for i:=$FE10 to $FFA0 do
mem[i]:=not mem[i];
i:=$FE1A;
repeat
mem[i]:=$FF;
i:=i+16;
until i>$FFA0;
end;
procedure cursor_off;
begin
fillchar(space_pcg,16,0);
end;
procedure write_pointer(at_x, at_y : integer; left : boolean);
begin
gotoxy(at_x,at_y);
if left then write(^[')IJ'^['(')
else write(^[')JL'^['(');
end;
procedure kill_pointer(at_x, at_y : integer);
begin
gotoxy(at_x,at_y);
write(' ');
end;
procedure border(at_x, at_y, l_x, l_y : integer);
begin
lowvideo;
gotoxy(at_x,at_y); write('A');
for i:=3 to l_x do write('B');
write('C');
for i:=succ(at_y) to at_y+l_y-2 do
begin
gotoxy(at_x,i); write('D');
gotoxy(pred(at_x+l_x),i); write('E');
end;
gotoxy(at_x,pred(at_y+l_y)); write('F');
for i:=3 to l_x do write('G');
write('H');
normvideo;
end;
procedure clr_section;
begin
for i:=17 to 22 do
begin
gotoxy(17,i); write(' ':48);
end;
end;
procedure check_kbd;
var
test : byte;
begin
test:=48; { code for ESC key }
port[12]:=18;
port[13]:=test shr 4 and 3;
port[12]:=19;
port[13]:=test shl 4;
port[11]:=1;
port[12]:=16;
test:=port[13];
port[12]:=31;
port[13]:=31;
repeat
test:=port[12];
until test and $80<>0;
if test and $40<>0 then abort:=true;
port[11]:=0;
end;
procedure error(message : string_40);
begin
abort:=true;
clr_section;
gotoxy(18,17);
write(message);
gotoxy(18,19);
write('Press <RETURN> to continue ...');
repeat read(kbd,key); until key=^M;
end;
procedure exit;
begin
bdos(selectdrive,default_drive);
clr_section;
gotoxy(18,17);
write('If you have changed disks insert origional');
gotoxy(18,18);
write('disks and press <RETURN>.');
repeat read(kbd,key); until key=^M;
clrscr;
load_inverse;
halt;
end;
procedure sectran(var dph : integer);
begin
inline($21/*+$13/ {LD HL,L0}
$E5/ {PUSH HL}
$2A/1/0/ {LD HL,(1)}
$11/$2D/0/ {LD DE,2DH}
$19/ {ADD HL,DE}
$ED/$4B/record_number/ {LD BC,(record_number)}
$ED/$5B/dph/ {LD DE,(dph)}
$E9/ {JP (HL)}
$22/trans_record {L0:LD (trans_record),HL});
end;
procedure read_track;
begin
bios(seldsk,source_num);
bios(settrk,track);
track_mem_add:=0;
record_number:=0;
repeat
bios(setdma,addr(track_mem[tr,track_mem_add]));
sectran(dph_s);
bios(setsec,trans_record);
result:=bios(read_r);
if result<>0 then
error('Error in read from drive '+char(65+source_num)+'.');
record_number:=succ(record_number);
track_mem_add:=track_mem_add+128;
until (record_number>39) or abort;
end;
procedure write_track;
begin
bios(seldsk,destination_num);
bios(settrk,track);
track_mem_add:=0;
record_number:=0;
repeat
bios(setdma,addr(track_mem[tr,track_mem_add]));
sectran(dph_d);
bios(setsec,trans_record);
if record_number=39 then bios(write_r,1)
else if record_number and 3=0 then bios(write_r,2)
else bios(write_r,0);
record_number:=succ(record_number);
track_mem_add:=track_mem_add+128;
until (record_number>39) or abort;
end;
begin
graphics_characters:=graphics_definition;
underline;
max_track:=trunc(((65536.0+bdos_start)-track_mem_start) / 5120);
default_drive:=bdos(getdefault);
repeat
repeat
clrscr;
cursor_off;
border(2,1,78,24);
gotoxy(14,3);
write('MicroBee TRAKCOPY v'+version+'.'+revision+
' Written by Peter Broughton.');
gotoxy(13,4);
write(^[')KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK'+
^['(');
border(11,6,20,9);
gotoxy(18,7); write('SOURCE');
gotoxy(13,8); write(^[')KKKKKKKKKKKKKKKK'^['(');
border(51,6,20,9);
gotoxy(55,7); write('DESTINATION');
gotoxy(53,8); write(^[')KKKKKKKKKKKKKKKK'^['(');
gotoxy(32,10); write(^[')JJJJJJJJJJJJJJJJJL'^['(');
border(16,16,50,8);
gotoxy(18,17); write('Press : <E> to move up.');
gotoxy(26,18); write('<X> to move down.');
gotoxy(26,19); write('<RETURN> to select device.');
gotoxy(26,20); write('<ESC> to quit.');
for i:=1 to 4 do
begin
gotoxy(15,8+i); write('drive ',char(i+64));
end;
i:=0;
repeat
write_pointer(25,i+9,true);
read(kbd,key);
case upcase(key) of
'E' : if i>0 then begin kill_pointer(25,i+9); i:=pred(i); end;
'X' : if i<3 then begin kill_pointer(25,i+9); i:=succ(i); end;
^[ : exit;
end;
until key=^M;
source_num:=i;
for i:=0 to 3 do
begin
gotoxy(59,i+9); write('drive ',char(i+65));
end;
i:=0;
repeat
write_pointer(54,i+9,false);
read(kbd,key);
case upcase(key) of
'E' : if i>0 then begin kill_pointer(54,i+9); i:=pred(i); end;
'X' : if i<3 then begin kill_pointer(54,i+9); i:=succ(i); end;
^[ : exit;
end;
until key=^M;
destination_num:=i;
clr_section;
gotoxy(18,17);
write('Copying from drive ',char(source_num+65),
' to drive ',char(destination_num+65),' :');
gotoxy(18,18); write('Press : <RETURN> to start copying.');
gotoxy(26,19); write('<ESC> to quit.');
gotoxy(26,20); write('<SPACE> to change.');
repeat read(kbd,key); until key in [^M,^[,' '];
if key=^[ then exit;
if key=^M then
begin
clr_section;
if source_num<>destination_num then
begin
gotoxy(18,17); write('Insert disks and press <RETURN>.');
repeat read(kbd,key); until key=^M;
gotoxy(18,19);
write('Warning! Data on disk in drive ',
char(destination_num+65),' will be lost.');
end
else
begin
gotoxy(18,19);
write('Warning! Data on destination disk will be lost.');
end;
gotoxy(18,20); write('Continue ( Y/N ) ?');
repeat
read(kbd,key);
key:=upcase(key);
until key in ['N','Y'];
if key<>'N' then key:=^M;
end;
until key=^M;
clr_section;
gotoxy(18,22); write('Hold down <ESC> to abort copy.');
abort:=false;
gotoxy(1,1);
dph_s:=bios(seldsk,source_num);
if dph_s=0 then
error('Illegal source disk specification.');
if (source_num<>destination_num) and not abort then
begin
dph_d:=bios(seldsk,destination_num);
if dph_d=0 then
error('Illegal destination disk specification.');
end;
track:=0;
while (track<80) and not abort do
begin
gotoxy(28,19); write('Reading track -- ',track:2);
if source_num=destination_num then
begin
gotoxy(18,17);
write('Insert '^[')source'^['( disk and press <RETURN>. ');
repeat read(kbd,key); until (key=^M) or (key=^[);
if key=^[ then exit;
end;
t_track:=track;
tr:=1;
repeat
check_kbd;
gotoxy(47,19); write(track:2);
read_track;
track:=succ(track);
tr:=succ(tr);
until (tr>max_track) or (track>79) or abort;
track:=t_track;
tr:=1;
if not abort then
begin
gotoxy(28,19); write('Writing track -- ',track:2);
if source_num=destination_num then
begin
gotoxy(18,17);
write('Insert '^[')destination'^['( disk and '+
'press <RETURN>.');
repeat read(kbd,key); until (key=^M) or (key=^[);
if key=^[ then exit;
end;
repeat
check_kbd;
gotoxy(47,19); write(track:2);
write_track;
track:=succ(track);
tr:=succ(tr);
until (tr>max_track) or (track>79) or abort;
end;
end;
clr_section;
gotoxy(18,17); write('Copy ');
if abort then write('aborted.')
else write('completed.');
gotoxy(18,18); write('Press : <RETURN> for another copy.');
gotoxy(26,19); write('<ESC> to quit.');
repeat read(kbd,key); until (key=^M) or (key=^[);
until key=^[;
exit;
end.