home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / z / zsim20.zip / CPMFRM.MOD < prev    next >
Text File  |  1990-10-06  |  4KB  |  131 lines

  1.  
  2. (* J.W. 23.04.90/28.08.90
  3.    Programm formatiert CP/M 86 SS oder DS Format unter Hilfe von
  4.    Dos FORMAT.COM
  5. *)
  6.  
  7. MODULE CPMFrm;
  8.  
  9. FROM SYSTEM IMPORT FLAT,PTR,ADR,ADDRESS,WORD,ASSEMBLER;
  10. FROM Loader IMPORT Execute;
  11. FROM System IMPORT GetArg,Terminate,GetEnv;
  12. FROM InOut IMPORT WriteString,WriteLn,Write;
  13. FROM Strings IMPORT CompareStr,Concat;
  14. FROM DiskOps IMPORT DefSeg,poke,ReadSect,WritSect;
  15.  
  16. CONST EXITCODE=1;
  17.  
  18. VAR e:CARDINAL;
  19.     p:ARRAY [0..511] OF CHAR;
  20.     ComSpec,cmd:ARRAY [0..31] OF CHAR;
  21.     done,doubleSided:BOOLEAN;
  22.     drv:CARDINAL;
  23.  
  24. PROCEDURE ExitUsage;
  25. BEGIN
  26.        WriteLn;
  27.        WriteString("CPMFRM Vers 1.1   (C) 1990 by Jürgen Weber");WriteLn;
  28.        WriteLn;
  29.        WriteString("usage: CPMFRM drive [option]");WriteLn;
  30.        WriteString("where drive is A: or B:");WriteLn;
  31.        WriteString("      option is /1 for CP/M 86 Single Sided");
  32.        WriteString(" (default is CP/M 86 Double Sided)");
  33.        WriteLn;WriteLn;
  34.        WriteString("COMMAND.COM must be named in COMSPEC and FORMAT.COM");WriteLn;
  35.        WriteString("must be in a directory named in the PATH.");
  36.        WriteLn;
  37.        WriteString("DO only format ONE disk at a time as the CP/M disk");WriteLn;
  38.        WriteString("will be initialised after calling FORMAT.COM");
  39.        WriteLn;
  40.        Terminate(EXITCODE);
  41. END ExitUsage;
  42.  
  43. PROCEDURE ExitRWErr;
  44. BEGIN
  45.      WriteString("Disk Error initialising CP/M Area");WriteLn;
  46.      Terminate(EXITCODE);
  47. END ExitRWErr;
  48. PROCEDURE SetFormatByte(FrmByte:CARDINAL);
  49. VAR p1:ADDRESS;
  50.     p2:POINTER TO ADDRESS;
  51.     i:CARDINAL;
  52.     w:WORD;
  53. BEGIN
  54.      p2:=PTR(LONG(4*1EH)); (* Zeiger auf Disk Parameter Table *)
  55.      p1:=p2^;
  56.      INC(p1,8); (* 9.ter Eintrag der Tabelle *)
  57.      w:=p1^;
  58.  
  59.      (* (w AND 0F0H) OR FrmByte *)
  60.      w:=WORD((BITSET(w) * {8..15}) + BITSET(FrmByte));
  61.      p1^:=w;
  62. END SetFormatByte;
  63.  
  64.  
  65. BEGIN (* MAIN *)
  66.     GetEnv("COMSPEC",ComSpec);
  67.     GetArg(p,e);
  68.     cmd:="/C FORMAT ";
  69.     IF (CompareStr(p,"A:")=0) OR (CompareStr(p,"a:")=0) THEN
  70.        Concat(cmd,"A: ",cmd);
  71.        drv:=0;
  72.     ELSIF (CompareStr(p,"B:")=0) OR (CompareStr(p,"b:")=0) THEN
  73.        Concat(cmd,"B: ",cmd);
  74.        drv:=1;
  75.     ELSE
  76.        ExitUsage;
  77.     END;
  78.     GetArg(p,e);
  79.     doubleSided:=TRUE;
  80.     IF (e>0) THEN
  81.        IF (CompareStr(p,"/1")#0)  THEN
  82.           ExitUsage;
  83.        ELSE
  84.           Concat(cmd,"/1 ",cmd);
  85.           doubleSided:=FALSE;
  86.        END;
  87.     END;
  88.     Concat(cmd,"/8 ",cmd);
  89.  
  90.      SetFormatByte(0E5H);
  91.      WriteString("FORMATTING disc in drive ");IF drv=0 THEN Write('A')
  92.                                                        ELSE Write('B') END;
  93.      WriteString(": !!");WriteLn;                                               
  94.      Execute(ComSpec,cmd,e);
  95.      SetFormatByte(0F6H);
  96.      WriteLn;
  97.      IF e=2 THEN
  98.         WriteString('Could not find \COMMAND.COM');WriteLn;
  99.         ExitUsage;
  100.      END;
  101. (* Dos Plus Zeichen SS/DS eintragen *)
  102.      e:=ReadSect(ADR(p),drv,0,0,1);
  103.      IF e>0 THEN
  104.         ExitRWErr;
  105.      END;
  106.      DefSeg(ADR(p));
  107.      IF doubleSided THEN
  108.         poke(511,1C);
  109.      ELSE
  110.         poke(511,0C);
  111.      END;
  112.      e:=WritSect(ADR(p),drv,0,0,1);
  113.      IF e>0 THEN
  114.         ExitRWErr;
  115.      END;
  116.  
  117. (* Dos Plus Zeichen CP/M 86 eintragen *)
  118.      e:=ReadSect(ADR(p),drv,0,0,2);
  119.      IF e>0 THEN
  120.         ExitRWErr;
  121.      END;
  122.      poke(0,CHR(0F6H));
  123.      poke(1,CHR(0F6H));
  124.      poke(2,CHR(0F6H));
  125.      e:=WritSect(ADR(p),drv,0,0,2);
  126.      IF e>0 THEN
  127.         ExitRWErr;
  128.      END;
  129.  
  130. END CPMFrm.
  131.