home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS 1
/
BBS#1.iso
/
document
/
mn195.ha
/
RABEC.TXT
< prev
next >
Wrap
Text File
|
1994-10-24
|
7KB
|
161 lines
ï¿ßΓ¿¡ú
{$A+,B-,D+,E-,F-,G-,I-,L+,N-,O-,P-,Q+,R+,S+,T+,V+,X-,Y+}
{$M 2048,65536,65536}
{ #H#C#S, (C) V.S.Rabets, 1994. Edition 09.07.94 }
uses DOS;
type tPartEntry = record Boot : byte;
BegHead : byte;
BegSecCyl: word;
Sys : byte;
EndHead : byte;
EndSecCyl: word;
OtherInfo: array [1..2*4] of byte;
end;
tPartitionTable = record BootCode: array [1..$1BE] of byte;
PE: array [1..4] of tPartEntry;
end;
var PT: ^tPartitionTable absolute HeapOrg;
const Drive: byte = $80; { êßß½ÑñπѼδ⌐ ñ¿ß¬ }
MaxHeadP: byte = 0;{Max º¡áτÑ¡¿∩ Head, Cyl ¿ Sec ¿º Partition table}
MaxCylP : word = 0;
MaxSecP : byte = 1;
ParamInt: byte = $41; {éÑ¬Γ«α, π¬áºδóáεΘ¿⌐ ¡á Γáí½¿µπ »áαá¼ÑΓα«ó
ñ¿ß¬á}
var ParamTable: record CylCnt : word; { Æáí½¿µá »áαá¼ÑΓα«ó ñ¿ß¬á }
HeadCnt: byte;
SomeInfo: array [3..$D] of byte;
SecPerTrack: byte;
OtherInfo: byte;
end;
var SaveParamAddr, { ÇñαÑß ¿ßσ«ñ¡«⌐ Γáí½¿µδ »áαá¼ÑΓα«ó ñ¿ß¬á }
SaveExitProc: pointer;
R: registers;
Start,
i,w: word;
{ ôßΓá¡«ó¬á »áαá¼ÑΓα«ó ñ¿ß¬á }
function SetDriveParams (ParamAddr: pointer): boolean;
{ParamAddr - @Γáí½¿µδ}
begin
SetIntVec (ParamInt, ParamAddr); { ôßΓá¡«ó¬á int $41 ¿½¿ $46 }
with R do begin
DL:=Drive;
AH:=9; { ôßΓá¡«ó¬á Γáí½¿µδ »áαá¼ÑΓα«ó ñ¿ß¬á }
intr ($13, R);
SetDriveParams:=(Flags and fCarry)=0;
end;
end;
function SetBigDisk: boolean; { ôßΓá¡«ó¬á max º¡áτÑ¡¿⌐ Head, Cyl, Sect }
begin
move ( (pointer(MemL[0:ParamInt*4]))^, ParamTable, SizeOf(ParamTable) );
with ParamTable do begin { è«»¿α«óá¡¿Ñ ¿ ¼«ñ¿Σ¿¬áµ¿∩ Γáí½¿µδ }
CylCnt :=1024;
if HeadCnt<16 then HeadCnt:=16;
SecPerTrack:=64;
end;
SetBigDisk:=SetDriveParams(@ParamTable);
{ôßΓá¡«ó¬á ¡«óδσ »áαá¼ÑΓα«ó ñ¿ß¬á}
end;
function ReadSector (Head:byte; Cyl:word; Sec:byte): boolean;
begin
with R do begin
ES:=seg(HeapOrg^); { ÉẼÑα heap ºáñá¡ 64¬í }
BX:=ofs(HeapOrg^);
DL:=Drive;
DH:=Head;
CH:=lo(Cyl);
CL:=Sec + (hi(Cyl) shl 6);
AL:=1; { ù¿ΓáΓ∞ 1 ßÑ¬Γ«α }
AH:=2; { ù¿ΓáΓ∞ ßÑ¬Γ«α }
intr ($13, R);
ReadSector:=(Flags and fCarry)=0;
end;
end;
function MaxWord (W1, W2, W3: word): word; { Max ¿º ΓαÑσ τ¿ßѽ }
var Max: word;
begin
Max:=W1; if W2>Max then Max:=W2; if W3>Max then Max:=W3; MaxWord:=Max;
end;
procedure ExitProcedure; far;
begin
ExitProc:=SaveExitProc;
if not SetDriveParams (SaveParamAddr)
then writeln (#10'Restore disk parameters error'#7);
end;
{ =========================================================== MAIN === }
begin
writeln (#10'#H#C#S, ver. 1.00. (C) V.S.Rabets, 1994'#10);
writeln ('The program try to determine number of Heads, Cylinders and Sectors_per_track');
writeln (' on hard disk. It is useful in the case of CMOS trouble.');
writeln ('The program analyzes Partition table, then it reads some sectors and displays');
writeln (' the last readable Head, Cylinder and Sector_on_track.');
writeln ('Syntax:');
writeln (' #H#C#S /? - to get Help screen without work');
writeln (' #H#C#S - to explore 1st hard disk');
writeln (' #H#C#S /2 - to explore 2nd hard disk');
if ParamStr(1)='' then else
if ParamStr(1)='/?' then halt else
if ParamStr(1)='/2' then begin Drive:=$81; ParamInt:=$46 end else
begin writeln (#10'Invalid parameters'#7); halt end;
for w:=1 to 80 do write ('=');
write ('Hard disk #',Drive-($80-1),': ');
{ ------------------------------------------- ùΓÑ¡¿Ñ αáºñѽá: --- }
if not ReadSector (0,0,1) {Head=0,Cyl=0,Sec=1}
then writeln ('Error reading Partition table'#7)
else begin
for i:=1 to 4 do with PT^.PE[i] do begin
MaxHeadP:=MaxWord (MaxHeadP,BegHead,EndHead);
MaxCylP :=MaxWord (MaxCylP,
hi(BegSecCyl) + (lo(BegSecCyl) shr 6)*256,
hi(EndSecCyl) + (lo(EndSecCyl) shr 6)*256 );
MaxSecP :=MaxWord (MaxSecP, lo(BegSecCyl) and $3F,
lo(EndSecCyl) and $3F);
end;
writeln ('Max values from Partition table: Head-', MaxHeadP,
', Cyl-', MaxCylP, ', Sector-', MaxSecP);
end;
{ --------------------------- ôßΓá¡«ó¬á ¡«óδσ »áαá¼ÑΓα«ó ñ¿ß¬á: --- }
GetIntVec (ParamInt, SaveParamAddr); {æ«σαá¡Ñ¡¿Ñ áñαÑßá ¿ßσ«ñ¡«⌐ Γáí½¿µδ}
SaveExitProc:=ExitProc;
ExitProc:=@ExitProcedure;
if not SetBigDisk then begin { ôßΓá¡«ó¬á max º¡áτÑ¡¿⌐ Head, Cyl, Sect }
writeln (#10'Change disk parameters error'#7); halt end;
{ -------------------------------------------- ùΓÑ¡¿Ñ ñ¿ß¬á: --- }
Start:=0; writeln; { Å«¿ß¬ »«ß½Ññ¡Ñ⌐ ú«½«ó¬¿ }
for i:=0 to 1 do
for w:=Start to $FF do
if ReadSector(w,i,1) then begin { Head=w, Cyl=0|1, Sec=1 }
Start:=w;
write (#13'Read Cylinder ',i,', Sector 1: last readable Head - ',w);
end else begin writeln; break end;
Start:=0; writeln; { Å«¿ß¬ »«ß½Ññ¡Ñú« µ¿½¿¡ñαá }
while ( Start<1024-10 ) and ( ReadSector(0,Start+10,1) ) do begin
inc (Start,10);
write (#13'Read Head 0, Sector 1: last readable Cylinder - ',Start);
end;
for i:=0 to 1 do
for w:=Start to 1023 do
if ReadSector(i,w,1) then begin { Head=0|1, Cyl=w, Sec=1 }
Start:=w;
write (#13'Read Head ',i,', Sector 1: last readable Cylinder - ',w);
end else begin writeln; break end;
Start:=1; writeln; { Å«¿ß¬ »«ß½Ññ¡Ñú« ßÑ¬Γ«αá }
for i:=0 to 1 do
for w:=Start to 64 do
if ReadSector(i,0,w) then begin { Head=0|1, Cyl=0, Sec=w }
Start:=w;
write (#13'Read Head ',i,', Cylinder 0: last readable Sector - ',w);
end else begin writeln; break end;
end.