home *** CD-ROM | disk | FTP | other *** search
- {*********************************************************}
- { }
- { A unit forráskódja az IDG - PC-X szerkesztôségének, }
- { és Bérczi László-nak a tulajdona. }
- { A forráskód a kereskedelmi célokat kivéve szabadon }
- { terjeszthetô ! }
- { }
- { PC-X User (c) 1999, február }
- {*********************************************************}
- {$G+}
- unit PCXDOSF; {DOS Functions for PC-X}
-
- INTERFACE
-
- function ConvertDriveLetterToNumber(C: Char): Byte; {A = 0}
- function ConvertDriveLetterToNumber2(C: Char): Byte; {A = 1}
-
- function DiskTotalSpace(Drive: Byte): Longint; {asm} {0 - Def, 1 - A . . .}
- function DiskFreeSpace(Drive: Byte): Longint; {asm} {0 - Def, 1 - A . . .}
- function IsDriveReady(Drive: Byte): Boolean; {asm} {0 - Def, 1 - A . . .}
- function GetLastDrive: Byte; {eq. LASTDRIVE = x in CONFIG.SYS}
- function GetMaxDriveNumber: Byte; {1 - A ...}
-
- procedure DiskCharacteristic(Drive: Byte; var Total_Clus, Avaib_Clus, Sec_Clus, Byte_Sec: Word);
- function GetDisk_TotalCluster(Drive: Byte): Word; {asm}
- function GetDisk_AvaibleCluster(Drive: Byte): Word; {asm}
- function GetDisk_SecClus(Drive: Byte): Word; {asm}
- function GetDisk_ByteSec(Drive: Byte): Word; {asm}
-
- function GetDosDefaultDisk: Byte; {asm}
- procedure SetDosDefaultDisk(Drive: Byte); {asm}
-
-
- IMPLEMENTATION
-
- {Drive}
- function ConvertDriveLetterToNumber(C: Char): Byte;
- begin
- C:=UpCase(C);
- ConvertDriveLetterToNumber:=Ord(C)-65;
- end;
-
- function ConvertDriveLetterToNumber2(C: Char): Byte;
- begin
- C:=UpCase(C);
- ConvertDriveLetterToNumber2:=Ord(C)-64;
- end;
-
- function DiskTotalSpace(Drive: Byte): Longint; Assembler;
- asm
- mov ax, 3600h {Ret: AX: Sec/Clus }
- mov dl, Drive { BX: Avaible Clus }
- int 21h { CX: Byte/Sec }
- cmp ax, 0FFFFh { DX: Total Clus }
- je @NotReady
- mov bx, dx
- mul cx
- mul bx
- jmp @Exit
- @NotReady:
- xor ax, ax
- xor dx, dx
- @Exit:
- end;
-
- function DiskFreeSpace(Drive: Byte): Longint; Assembler;
- asm
- mov ax, 3600h {Ret: AX: Sec/Clus }
- mov dl, Drive { BX: Avaible Clus }
- int 21h { CX: Byte/Sec }
- cmp ax, 0FFFFh { DX: Total Clus }
- je @NotReady
- mul cx
- mul bx
- jmp @Exit
- @NotReady:
- xor ax, ax
- xor dx, dx
- @Exit:
- end;
-
- function IsDriveReady(Drive: Byte): Boolean; Assembler;
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- je @NotReady
- mov al, True
- jmp @Exit
- @NotReady:
- mov al, False
- @Exit:
- end;
-
- function GetLastDrive: Byte; Assembler;
- asm
- mov ax, 1900h
- int 21h
- mov dl, al
- mov ax, 0E00h
- int 21h
- end;
-
- function GetMaxDriveNumber: Byte;
- var i, MaxDrive: Byte;
- begin
- i:=2; MaxDrive:=GetLastDrive;
- repeat
- Inc(i);
- until (Not IsDriveReady(i)) or (MaxDrive < i);
- GetMaxDriveNumber:=i-1;
- end;
-
- procedure DiskCharacteristic(Drive: Byte; var Total_Clus, Avaib_Clus,
- Sec_Clus, Byte_Sec: Word);
- var Sec_ClusT ,Avaib_ClusT ,Byte_SecT ,Total_ClusT : Word;
- begin
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- jne @Ready
- xor ax, ax
- xor bx, bx
- xor cx, cx
- xor dx, dx
- @Ready:
- mov Sec_ClusT , ax
- mov Avaib_ClusT, bx
- mov Byte_SecT , cx
- mov Total_ClusT, dx
- end;
- Sec_Clus :=Sec_ClusT;
- Avaib_Clus:=Avaib_ClusT;
- Byte_Sec :=Byte_SecT;
- Total_Clus:=Total_ClusT;
- end;
-
- function GetDisk_TotalCluster(Drive: Byte): Word; Assembler;
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- je @NotReady
- mov ax, dx
- jmp @Exit
- @NotReady:
- xor ax, ax
- @Exit:
- end;
-
- function GetDisk_AvaibleCluster(Drive: Byte): Word; Assembler;
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- je @NotReady
- mov ax, bx
- jmp @Exit
- @NotReady:
- xor ax, ax
- @Exit:
- end;
-
- function GetDisk_SecClus(Drive: Byte): Word; Assembler;
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- jne @Exit
- xor ax, ax
- @Exit:
- end;
-
- function GetDisk_ByteSec(Drive: Byte): Word; Assembler;
- asm
- mov ax, 3600h
- mov dl, Drive
- int 21h
- cmp ax, 0FFFFh
- je @NotReady
- mov ax, cx
- jmp @Exit
- @NotReady:
- xor ax, ax
- @Exit:
- end;
-
-
- function GetDosDefaultDisk: Byte; Assembler;
- asm {CurrentDrive}
- mov ax, 1900h
- int 21h
- end;
-
- procedure SetDosDefaultDisk(Drive: Byte); Assembler;
- asm
- mov ax, 0E00h
- mov dl, Drive
- int 21h
- end;
-
- END.
-
- {From:}
- {********************************************}
- { }
- { R4sDrive unit }
- { Copyright (c) 1995-97 By Bérczi László }
- { }
- {********************************************}
- {Last Edit: 1997 VI 25. 19:00}