home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
USCX
/
TURBO-02.ZIP
/
GETSECTR.LIB
< prev
next >
Wrap
Text File
|
1984-12-03
|
3KB
|
61 lines
{@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
The purchaser of these procedures and functions may include them in COMPILED
programs freely, but may not sell or give away the source text.
The procedure GetSector receives as parameters the drive, side, track,
and sector desired, and "R" or "W", for Read or Write. It either
reads from or writes to a BUFFER, defined within your program. The
buffer should total 512 bytes. The parameter OKAY is passed back
to indicate that the operation was successful.
The buffer might just be an array[0..511] of byte, but it could
also be an array[1..16] of directory_entry_type, or whatever you
want to read into. NOTE that it is possible to read more than
one sector at a time, if you reserve a bigger buffer. The value
given to AL is the number of sectors to read.
NOTE that any program that INCLUDEs this file must also INCLUDE
the type definition in REGPACK.TYP}
{OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO}
Procedure GetSector(activity, drive: char;
side, sector, track: byte;
var OKAY : boolean);
var
registers : regpack;
count : byte;
ah,al,ch,cl,dh,dl : byte;
begin
activity := UpCase(activity);
drive := UpCase(drive);
With registers do
begin
dl := ord(drive) - 65; {dl = 0 if drive is A, 1 if B, &c.}
Case activity of { Set AH for either read or write. }
'R': AH := 2;
'W': AH := 3;
end;
count := 0;
repeat
count := count + 1;
DH := side; { Set the head (side) number. }
CH := track; { Set the track number. }
CL := sector; { Set starting sector number. }
AL := 1; { Just read one sector. }
ES := Seg(buffer); { Set segment of buffer. }
BX := Ofs(buffer); { Set offset of buffer. }
AX := (ah shl 8) + al;
CX := (ch shl 8) + cl;
DX := (dh shl 8) + dl;
Intr($13,registers); { Perform the activity. }
until (count = 3) or ((AX shr 8) = 0);
if count = 3 then OKAY := false else OKAY := true;
end;
end;
{OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO}