home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol256 / transfer.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-03-22  |  5.6 KB  |  245 lines

  1.  
  2.  
  3. (*********************************************************)
  4. (*                                                       *)
  5. (* a program to transfer files between cp/m and ms-dos   *)
  6. (* with a cp/m host system                               *)
  7. (*                                                       *)
  8. (* Written by David Koski     1985                       *)
  9. (*            P.O. Box 1078                              *)
  10. (*            Fort Bragg, CA  95437-1078                 *)
  11. (*            707/964-0806                               *)
  12. (*                                                       *)
  13. (* This program is intended for private non-commertial   *)
  14. (* use and is considered to be public domain material    *)
  15. (*                                                       *)
  16. (*********************************************************)
  17.  
  18.  
  19.  
  20. program Transfer;
  21.  
  22. const
  23.   SecTrans          = true;     { sector translation for bios read/write }
  24.   SO                = 0;        { offset added to sector number          }
  25.  
  26.   MinSector         = 0;
  27.   MaxFATSize        = 1024;
  28.   Vers              = 1.0;
  29.   SectorSizeMax     = 512;
  30.   BufferSize        = SectorSizeMax;
  31.   MenuMargin        = 18;
  32.   ClusterSizeMax    = 2048;
  33.   NameSize          = 8;
  34.   TypeSize          = 3;
  35.   First             = true;
  36.   Next              = false;
  37.   EODirectory       = $FF;
  38.   MTDirectory       = 1;
  39.   FoundDir          = 0;
  40.  
  41. type
  42.   SizeArray= Array[1..4] of Byte;
  43.   Str20    = string[20];
  44.   Bufr     = array[1..BufferSize] of char;
  45.   CBufr    = array[1..ClusterSizeMax] of char;
  46.   FATarray = array[1..MaxFATSize] of byte;
  47.   FAT_ID   = (Unidentified,ss8spt,ds8spt,ss9spt,ds9spt,B_20);
  48.   NameAry  = array[1..NameSize] of char;
  49.   TypeAry  = array[1..TypeSize] of char;
  50.   NameStr  = string[20];
  51.  
  52.   PC_FCB   = record
  53.     Name:      NameAry;
  54.     Extention: TypeAry;
  55.     Attribute: byte;
  56.     Rsrvd:     array[12..21] of byte;
  57.     Time:      integer;
  58.     Date:      integer;
  59.     ClusterNo: integer;
  60.     FileSize:  SizeArray;
  61.     end;
  62.  
  63.   CpmFCB   = record
  64.     DriveCode: byte;
  65.     Name:      NameAry;
  66.     Extention: TypeAry;
  67.     Extent:    byte;
  68.     S1,S2:     byte;
  69.     RC:        byte;
  70.     Rsrvd:     array[16..31] of byte;
  71.     CR:        byte;
  72.     R0,R1,R2:  byte;
  73.     end;
  74. var
  75.   CPM_Buf:           array[1..128] of char;
  76.   Done:              boolean;
  77.   Selection:         char;
  78.   I:                 integer;
  79.  
  80.   DefaultDisk:       integer;
  81.   MS_DOS_Drive:      integer;
  82.   CPM_Drive:         integer;
  83.   CPM_DriveCh:       char;
  84.   Track:             integer;
  85.   Sector:            integer;
  86.  
  87.   SecsPerCluster:    integer;
  88.   FAT:               FATarray;
  89.   FATSize:           integer;
  90.   SectorSize:        integer;
  91.   RecordsPerSector:  integer;
  92.   DirSecs:           integer;
  93.   NTracks:           integer;
  94.   NSectors:          integer;
  95.   NClusters:         integer;
  96.   Identity:          FAT_ID;
  97.  
  98.   FirstFATSector:    integer;
  99.   FirstDirSector:    integer;
  100.   FirstDataSector:   integer;
  101.   FirstDataTrack:    integer;
  102.   DirSector:         integer;
  103.   DirTrack:          integer;
  104.   DirSectorCount:    integer;
  105.   SingleSided:       boolean;
  106.  
  107.   DOS_FCB:           ^PC_FCB;
  108.   CPM_FCB:           CpmFCB;
  109.   Buffer:            Bufr;
  110.   DirBuffer:         Bufr;
  111.   DirOffset:         integer;
  112.   DirName:           NameStr;
  113.   ClusterBuffer:     CBufr;
  114.   MaxSector:         integer;
  115.   OutFile:           File;
  116.   BiosError:         boolean;
  117.   VolumeName:        boolean;
  118.   SubDirName:        boolean;
  119.  
  120.  
  121.  
  122. {$I TRANS-01.INC}
  123. {$I TRANS-02.INC}
  124. {$I TRANS-03.INC}
  125. {$I TRANS-04.INC}
  126. {$I TRANS-05.INC}
  127.  
  128.  
  129.  
  130. procedure EraseMS_DOS;
  131. var
  132.   FileName:          Str20;
  133.   Next,I,Err:        integer;
  134.   CPMFile:           File;
  135.   Cl:                integer;
  136.   Stop:              boolean;
  137. begin
  138. IdentifyMS_DOS;
  139. if not (Identity = Unidentified) then
  140.   begin
  141.   ClrScr;
  142.   writeln;
  143.   write('File Name to Erase From MS-DOS: ');
  144.   readln(FileName);
  145.   writeln;
  146.   Stop:= false;
  147.  
  148.   SearchFirst(FileName,Err);
  149.  
  150.   if (Err = $FF) then
  151.     begin
  152.     write('File Not Found, ');
  153.     end
  154.   else
  155.     begin
  156.     write('Erasing -');
  157.  
  158.     repeat
  159.       writeln;
  160.       for I:= 1 to NameSize do
  161.         if not (DOS_FCB^.Name[I] = ' ') then
  162.           write(DOS_FCB^.Name[I]);
  163.       write('.');
  164.       for I:= 1 to TypeSize do
  165.         write(DOS_FCB^.Extention[I]);
  166.  
  167.       Cl:= DOS_FCB^.ClusterNo;
  168.       if (Cl <= NClusters) then
  169.         begin
  170.         Next:= Cl;
  171.         repeat
  172.           Cl:= Next;
  173.           Next:= FATPointer(Cl);
  174.           SetFATPointer(Cl,0);
  175.           until ((Next > NClusters) or (Next = 0));
  176.         end;
  177.  
  178.       DOS_FCB^.Name[1]:= #$E5;
  179.       WriteSector(DirSector,DirTrack,addr(DirBuffer));
  180.       SearchNext(FileName,Err);
  181.       Stop:= Break;
  182.       until (Err = EODirectory) or Stop;
  183.  
  184.     writeln;
  185.     writeln;
  186.     end;
  187.   if Stop then write('Aborted, ');
  188.   PutFAT;
  189.   Continue;
  190.   end;
  191. end;
  192.  
  193.  
  194.  
  195. (********************)
  196. (*                  *)
  197. (*   main program   *)
  198. (*                  *)
  199. (********************)
  200.  
  201.  
  202.  
  203. begin
  204. ClrScr;
  205. DefaultDisk:= bdos(25);
  206.  
  207. repeat
  208.   gotoxy(1,5);
  209.   write('Which Drive is the MS-DOS Disk in? ');
  210.   read(KBD,Selection);
  211.   write(upcase(Selection),':');
  212.   MS_DOS_Drive:= ord(upcase(Selection)) - ord('A');
  213.   writeln;
  214.   write('Which drive is the  CP/M  Disk in? ');
  215.   read(KBD,CPM_DriveCh);
  216.   CPM_DriveCh:= upcase(CPM_DriveCh);
  217.   Write(CPM_DriveCh,':');
  218.   CPM_Drive:= ord(upcase(CPM_DriveCh)) - ord('A');
  219.   BiosSelect(CPM_Drive);
  220.   until not BiosError;
  221.  
  222. writeln;
  223. Delay(500);
  224. BiosSelect(DefaultDisk);
  225. done:= false;
  226.  
  227. repeat
  228.   Selection:= MainSelection;
  229.   ClrScr;
  230.  
  231.   case Selection of
  232.     '1': WriteMS_DOS;
  233.     '2': ReadMS_DOS;
  234.     '3': DirMS_DOS;
  235.     '4': MapMS_DOS;
  236.     '5': DirCPM;
  237.     '6': EraseMS_DOS;
  238.     '7': RestoreFAT;
  239.     '8': Done:= True;
  240.     end; (* case *)
  241.  
  242.   until Done;
  243.  
  244. end.
  245.