home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1998 March / pcx19_9803.iso / PC-XUSER / PC-XUSER.13 / TT / PCXDOSF.PAS next >
Encoding:
Pascal/Delphi Source File  |  1998-01-14  |  4.9 KB  |  217 lines

  1. {*********************************************************}
  2. {                                                         }
  3. {   A unit forráskódja az IDG - PC-X szerkesztôségének,   }
  4. {   és Bérczi László-nak a tulajdona.                     }
  5. {   A forráskód a kereskedelmi célokat kivéve szabadon    }
  6. {                    terjeszthetô !                       }
  7. {                                                         }
  8. {   PC-X User (c) 1999, február                           }
  9. {*********************************************************}
  10. {$G+}
  11. unit PCXDOSF; {DOS Functions for PC-X}
  12.  
  13. INTERFACE
  14.  
  15. function  ConvertDriveLetterToNumber(C: Char): Byte;  {A = 0}
  16. function  ConvertDriveLetterToNumber2(C: Char): Byte; {A = 1}
  17.  
  18. function  DiskTotalSpace(Drive: Byte): Longint; {asm} {0 - Def, 1 - A . . .}
  19. function  DiskFreeSpace(Drive: Byte): Longint;  {asm} {0 - Def, 1 - A . . .}
  20. function  IsDriveReady(Drive: Byte): Boolean;   {asm} {0 - Def, 1 - A . . .}
  21. function  GetLastDrive: Byte; {eq. LASTDRIVE = x in CONFIG.SYS}
  22. function  GetMaxDriveNumber: Byte; {1 - A ...}
  23.  
  24. procedure DiskCharacteristic(Drive: Byte; var Total_Clus, Avaib_Clus, Sec_Clus, Byte_Sec: Word);
  25. function  GetDisk_TotalCluster(Drive: Byte): Word; {asm}
  26. function  GetDisk_AvaibleCluster(Drive: Byte): Word; {asm}
  27. function  GetDisk_SecClus(Drive: Byte): Word; {asm}
  28. function  GetDisk_ByteSec(Drive: Byte): Word; {asm}
  29.  
  30. function  GetDosDefaultDisk: Byte; {asm}
  31. procedure SetDosDefaultDisk(Drive: Byte); {asm}
  32.  
  33.  
  34. IMPLEMENTATION
  35.  
  36. {Drive}
  37. function  ConvertDriveLetterToNumber(C: Char): Byte;
  38. begin
  39.   C:=UpCase(C);
  40.   ConvertDriveLetterToNumber:=Ord(C)-65;
  41. end;
  42.  
  43. function  ConvertDriveLetterToNumber2(C: Char): Byte;
  44. begin
  45.   C:=UpCase(C);
  46.   ConvertDriveLetterToNumber2:=Ord(C)-64;
  47. end;
  48.  
  49. function  DiskTotalSpace(Drive: Byte): Longint; Assembler;
  50. asm
  51.   mov ax, 3600h  {Ret: AX: Sec/Clus     }
  52.   mov dl, Drive  {     BX: Avaible Clus }
  53.   int 21h        {     CX: Byte/Sec     }
  54.   cmp ax, 0FFFFh {     DX: Total Clus   }
  55.   je  @NotReady
  56.   mov bx, dx
  57.   mul cx
  58.   mul bx
  59.   jmp @Exit
  60. @NotReady:
  61.   xor ax, ax
  62.   xor dx, dx
  63. @Exit:
  64. end;
  65.  
  66. function  DiskFreeSpace(Drive: Byte): Longint; Assembler;
  67. asm
  68.   mov ax, 3600h  {Ret: AX: Sec/Clus     }
  69.   mov dl, Drive  {     BX: Avaible Clus }
  70.   int 21h        {     CX: Byte/Sec     }
  71.   cmp ax, 0FFFFh {     DX: Total Clus   }
  72.   je  @NotReady
  73.   mul cx
  74.   mul bx
  75.   jmp @Exit
  76. @NotReady:
  77.   xor ax, ax
  78.   xor dx, dx
  79. @Exit:
  80. end;
  81.  
  82. function  IsDriveReady(Drive: Byte): Boolean; Assembler;
  83. asm
  84.   mov ax, 3600h
  85.   mov dl, Drive
  86.   int 21h
  87.   cmp ax, 0FFFFh
  88.   je  @NotReady
  89.   mov al, True
  90.   jmp @Exit
  91. @NotReady:
  92.   mov al, False
  93. @Exit:
  94. end;
  95.  
  96. function  GetLastDrive: Byte; Assembler;
  97. asm
  98.   mov  ax, 1900h
  99.   int  21h
  100.   mov  dl, al
  101.   mov  ax, 0E00h
  102.   int  21h
  103. end;
  104.  
  105. function  GetMaxDriveNumber: Byte;
  106. var i, MaxDrive: Byte;
  107. begin
  108.   i:=2; MaxDrive:=GetLastDrive;
  109.   repeat
  110.     Inc(i);
  111.   until (Not IsDriveReady(i)) or (MaxDrive < i);
  112.   GetMaxDriveNumber:=i-1;
  113. end;
  114.  
  115. procedure DiskCharacteristic(Drive: Byte; var Total_Clus, Avaib_Clus,
  116.            Sec_Clus, Byte_Sec: Word);
  117. var Sec_ClusT ,Avaib_ClusT ,Byte_SecT ,Total_ClusT : Word;
  118. begin
  119.   asm
  120.     mov  ax, 3600h
  121.     mov  dl, Drive
  122.     int  21h
  123.     cmp  ax, 0FFFFh
  124.     jne  @Ready
  125.     xor ax, ax
  126.     xor bx, bx
  127.     xor cx, cx
  128.     xor dx, dx
  129.   @Ready:
  130.     mov  Sec_ClusT  , ax
  131.     mov  Avaib_ClusT, bx
  132.     mov  Byte_SecT  , cx
  133.     mov  Total_ClusT, dx
  134.   end;
  135.   Sec_Clus  :=Sec_ClusT;
  136.   Avaib_Clus:=Avaib_ClusT;
  137.   Byte_Sec  :=Byte_SecT;
  138.   Total_Clus:=Total_ClusT;
  139. end;
  140.  
  141. function  GetDisk_TotalCluster(Drive: Byte): Word; Assembler;
  142. asm
  143.   mov ax, 3600h
  144.   mov dl, Drive
  145.   int 21h
  146.   cmp ax, 0FFFFh
  147.   je  @NotReady
  148.   mov ax, dx
  149.   jmp @Exit
  150. @NotReady:
  151.   xor ax, ax
  152. @Exit:
  153. end;
  154.  
  155. function  GetDisk_AvaibleCluster(Drive: Byte): Word; Assembler;
  156. asm
  157.   mov ax, 3600h
  158.   mov dl, Drive
  159.   int 21h
  160.   cmp ax, 0FFFFh
  161.   je  @NotReady
  162.   mov ax, bx
  163.   jmp @Exit
  164. @NotReady:
  165.   xor ax, ax
  166. @Exit:
  167. end;
  168.  
  169. function  GetDisk_SecClus(Drive: Byte): Word; Assembler;
  170. asm
  171.   mov ax, 3600h
  172.   mov dl, Drive
  173.   int 21h
  174.   cmp ax, 0FFFFh
  175.   jne  @Exit
  176.   xor ax, ax
  177. @Exit:
  178. end;
  179.  
  180. function  GetDisk_ByteSec(Drive: Byte): Word; Assembler;
  181. asm
  182.   mov ax, 3600h
  183.   mov dl, Drive
  184.   int 21h
  185.   cmp ax, 0FFFFh
  186.   je  @NotReady
  187.   mov ax, cx
  188.   jmp @Exit
  189. @NotReady:
  190.   xor ax, ax
  191. @Exit:
  192. end;
  193.  
  194.  
  195. function  GetDosDefaultDisk: Byte; Assembler;
  196. asm {CurrentDrive}
  197.   mov ax, 1900h
  198.   int 21h
  199. end;
  200.  
  201. procedure SetDosDefaultDisk(Drive: Byte); Assembler;
  202. asm
  203.   mov ax, 0E00h
  204.   mov dl, Drive
  205.   int 21h
  206. end;
  207.  
  208. END.
  209.  
  210. {From:}
  211. {********************************************}
  212. {                                            }
  213. {   R4sDrive unit                            }
  214. {   Copyright (c) 1995-97 By Bérczi László   }
  215. {                                            }
  216. {********************************************}
  217. {Last Edit: 1997 VI 25. 19:00}