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
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
TRANS12C.LBR
/
TRANS-01.INC
next >
Wrap
Text File
|
2000-06-30
|
6KB
|
284 lines
(* module 01 *)
procedure Box(X1,Y1,X2,Y2: integer);
var
I: integer;
begin
gotoxy(X1,Y1);
for I:= X1 to X2 do write('*');
for I:= Y1 to Y2 do
begin
gotoxy(X2,I);
write('*');
end;
gotoxy(X1,Y2);
for I:= X2 downto X1 do write('*');
for I:= Y2 downto Y1 do
begin
gotoxy(X1,I);
write('*');
end;
end;
function MainSelection: char;
var
Ch: char;
begin
ClrScr;
Box(13,5,60,23);
writeln('* TRANSFER - vers ',Vers,' - Commodore 128/1571 ');
gotoxy(MenuMargin,8);
write(' CP/M= ',chr(CPM_Drive+ord('A')),':');
write(' MS-DOS= ',chr(MS_DOS_Drive+ord('A')),':');
gotoxy(MenuMargin,10);
write('1. Transfer File: CP/M ==> MS-DOS');
gotoxy(MenuMargin,11);
write('2. Transfer File: CP/M <== MS-DOS');
gotoxy(MenuMargin,12);
write('3. Directory of MS-DOS Disk');
gotoxy(MenuMargin,13);
write('4. Allocation Map MS-DOS Disk');
gotoxy(MenuMargin,14);
write('5. Directory of CP/M Disk');
gotoxy(MenuMargin,15);
write('6. Erase File MS-DOS Disk');
gotoxy(MenuMargin,16);
write('7. Restore FAT');
gotoxy(MenuMargin,17);
write('8. Rename File MS-DOS Disk');
gotoxy(MenuMargin,18);
write('9. Format Disk MS-DOS Disk');
gotoxy(MenuMargin,19);
write('0. View Text File MS-DOS Disk');
repeat
gotoxy(16,21);
write(' Enter Your Selection (<ESC> to Quit): ');
read(KBD,Ch);
until (Ch in [#27, '0'..'9']);
MainSelection:= Ch;
end;
procedure Continue;
var
Ch: char;
begin
write('Press [Return] to Continue..');
repeat
read(KBD,Ch);
if (Ch = #27) then Stop := true;
until (Ch = #$D);
end;
procedure NextSector(var S: integer; var T: integer);
begin
S:= S + 1;
if (S >= NSectors) then
begin
S:= MinSector;
T:= T + 1;
end;
end;
procedure DiskError;
begin
writeln;
write('Disk I/O Error, ');
Continue;
end;
procedure BiosSelect(DriveCode: integer; First: Boolean);
begin
if not ((Selection = '0') and (DriveCode = CPM_Drive)) then
begin
if (CPMversion >= $30) then
bdos(LOGDSK, DriveCode); {added for safety}
if First then
D := bios3(SELDSK,0,DriveCode,0,0)
else
D := bios3(SELDSK,0,DriveCode,1,0);
BiosError := (D = 0);
if DEBUG then
begin
writeln;
writeln('DriveCode=', DriveCode, ' DPH Address=', D);
end;
end;
end;
procedure ReadSector(Sector,Track,Address: integer);
var
Rec: integer;
RPS: integer;
I: integer;
begin
{if SingleSided then Track:= Track * 2;}
RPS:= SectorSize div 128;
if (CPMversion >= $30) then RPS := 1;
BiosError:= False;
for I:= 0 to (RPS -1)do
begin
D := bios3(SETTRK,0,track,0,0); (* select track *)
if SecTrans then
Rec:= bios3(SECTRAN,0,Sector * RPS + I + SO,0,0) (* translate sector *)
else
Rec:= (Sector * RPS + I + SO);
D := bios3(SETSEC,0,Rec,0,0); (* select sector *)
D := bios3(SETDMA,0,(I * 128) + Address,0,0);(* set dma addr *)
BiosError:= (BiosError or (bios3(RDSEC,0,0,0,0)<>0)); (* read 128 bytes *)
end;
if BiosError then DiskError;
end;
procedure WriteSector(Sector,Track,Address: integer);
var
Rec: integer;
RPS: integer;
I: integer;
begin
{if SingleSided then Track:= Track * 2;}
RPS:= SectorSize div 128;
if (CPMversion >= $30) then RPS := 1;
BiosError:= False;
for I:= 0 to (RPS -1)do
begin
D := bios3(SETTRK,0,track,0,0); (* select track *)
if SecTrans then
Rec:= bios3(SECTRAN,0,Sector * RPS + I + SO,0,0) (* translate sector *)
else
Rec:= (Sector * RPS + I + SO);
D := bios3(SETSEC,0,Rec,0,0); (* select sector *)
D := bios3(SETDMA,0,(I * 128) + Address,0,0);(* set dma addr *)
BiosError:= (BiosError or (bios3(WRSEC,0,0,0,0)<>0)); (* write 128 bytes *)
end;
if BiosError then DiskError;
end;
procedure GetFAT;
begin
ReadSector(FirstFATSector,0,addr(FAT));
ReadSector(FirstFATSector + 1,0,addr(FAT)+SectorSize);
end;
procedure PutFAT;
var
S,T,I: integer;
begin
S:= FirstFATSector;
T:= 0;
for I:= 0 to FATSize-1 do
begin
WriteSector(S,T,addr(FAT) + (SectorSize * I));
NextSector(S,T);
end;
end;
procedure ReadCluster(Cl, BufferIndex: integer);
var
I: integer;
Sector: integer;
Track: integer;
begin
Cl:= Cl - 2;
Track:= (Cl * SecsPerCluster) div NSectors;
Sector:= (Cl * SecsPerCluster) mod NSectors;
Sector:= Sector + FirstDataSector;
Track:= Track + FirstDataTrack + (Sector div NSectors);
Sector:= Sector mod NSectors;
for I:= 0 to (SecsPerCluster -1) do
begin
ReadSector(Sector,Track,addr( DataBuffer[ I * SectorSize + BufferIndex] ));
NextSector(Sector,Track);
end;
end;
procedure WriteCluster(Cl, BufferIndex: integer);
var
I: integer;
Sector: integer;
Track: integer;
begin
Cl:= Cl - 2;
Track:= (Cl * SecsPerCluster) div NSectors;
Sector:= (Cl * SecsPerCluster) mod NSectors;
Sector:= Sector + FirstDataSector;
Track:= Track + FirstDataTrack + (Sector div NSectors);
Sector:= Sector mod NSectors;
for I:= 0 to (SecsPerCluster -1) do
begin
WriteSector(Sector,Track,addr( DataBuffer[ I * SectorSize + BufferIndex] ));
NextSector(Sector,Track);
end;
end;
function FATPointer(Index: integer): Integer; (* 2..NClusters + 2 *)
var
Result,I: Integer;
OddNum: Boolean;
begin
I:= ((Index * 3) div 2) +1;
Result:= (FAT[I] + (256 * FAT[I + 1]));
if odd(Index) then Result:= Result shr 4;
FATPointer:= (Result and $FFF);
end;
function Break: boolean;
var
Ch: char;
begin
if KeyPressed then
begin
read(KBD,Ch);
if (Ch = ^S) then
begin
while not KeyPressed do;
read(KBD,Ch);
end;
if (Ch = #27) then
Break:= true
else
Break:= false;
end
else
Break:= false;
end;
(* end module 01 *)