All Packages Class Hierarchy This Package Previous Next Index
Class uk.co.demon.seasip.libdsk.Drive
java.lang.Object
|
+----uk.co.demon.seasip.libdsk.Drive
- public class Drive
- extends Object
The Drive class represents an open LibDsk drive.
-
DSK_ST3_DSDRIVE
- When returned by status(), indicates the drive is double-sided.
-
DSK_ST3_FAULT
- When returned by status(), indicates drive fault.
-
DSK_ST3_HEAD1
- When returned by status(), indicates the current head is head 1.
-
DSK_ST3_READY
- When returned by status(), indicates the drive is ready.
-
DSK_ST3_RO
- When returned by status(), indicates disc read only.
-
DSK_ST3_TRACK0
- When returned by status(), indicates the head is over track 0.
-
autoFormat(Geometry, int, byte)
- Format a track, generating the sector headers automatically.
-
autoFormat(Geometry, int, int, byte)
- Format a track, generating the sector headers automatically.
-
close()
- Close a DSK file.
-
enumDrivers(int)
- Get the name of a built-in driver.
-
format(Geometry, int, FormatData[], byte)
- Format a track, generating the sector headers automatically.
-
format(Geometry, int, int, FormatData[], byte)
- Format a track, using physical cylinder/sector.
-
getDriverDesc()
- Get the description of the driver being used for this drive.
-
getDriverName()
- Get the name of the driver being used for this drive.
-
getForceHead()
- Find out if the drive is being forced to use one or other head.
-
probeGeometry(Geometry)
- Probe the geometry of a disc.
-
read(Geometry, byte[], int)
- Read a disc sector using a logical sector address.
-
read(Geometry, byte[], int, int, int)
- Read a disc sector using a physical sector address.
-
read(Geometry, byte[], int, int, int, int, int, int)
- Read a disc sector whose numbering may not match its disc location.
-
readTrack(Geometry, byte[], int)
- Read a track using a logical track number.
-
readTrack(Geometry, byte[], int, int)
- Read a track using a physical head/cylinder number.
-
readTrack(Geometry, byte[], int, int, int, int)
- Read a track whose sector headers may not match its location.
-
sectorID(Geometry, int, FormatData)
- Read a random sector ID.
-
sectorID(Geometry, int, int, FormatData)
- Read a random sector ID.
-
seek(Geometry, int)
- Seek to a track using a logical track number.
-
seek(Geometry, int, int)
- Seek to a track using a physical cylinder/head number.
-
setForceHead(int)
- Force the driver to use one or other head.
-
status(Geometry, int)
- Get the status of the drive.
-
verify(Geometry, byte[], int)
- Verify a disc sector using a logical sector address.
-
verify(Geometry, byte[], int, int, int)
- Verify a disc sector using a physical sector address.
-
verify(Geometry, byte[], int, int, int, int, int, int)
- Verify a disc sector whose numbering may not match its disc location.
-
write(Geometry, byte[], int)
- Write a disc sector using a logical sector address.
-
write(Geometry, byte[], int, int, int)
- Write a disc sector using a physical sector address.
-
write(Geometry, byte[], int, int, int, int, int, int)
- Write a disc sector whose numbering may not match its disc location.
DSK_ST3_FAULT
public static final int DSK_ST3_FAULT
- When returned by status(), indicates drive fault.
- See Also:
- status
DSK_ST3_RO
public static final int DSK_ST3_RO
- When returned by status(), indicates disc read only. *
- See Also:
- status
DSK_ST3_READY
public static final int DSK_ST3_READY
- When returned by status(), indicates the drive is ready. *
- See Also:
- status
DSK_ST3_TRACK0
public static final int DSK_ST3_TRACK0
- When returned by status(), indicates the head is over track 0. *
- See Also:
- status
DSK_ST3_DSDRIVE
public static final int DSK_ST3_DSDRIVE
- When returned by status(), indicates the drive is double-sided. *
- See Also:
- status
DSK_ST3_HEAD1
public static final int DSK_ST3_HEAD1
- When returned by status(), indicates the current head is head 1. *
- See Also:
- status
setForceHead
public native void setForceHead(int f)
- Force the driver to use one or other head.
(This option is only effective for the Linux floppy driver)
Forces the driver to ignore the head number passed to it and
always use either side 0 or side 1 of the disc. This is used to
read discs recorded on PCW / CPC / Spectrum+3 add-on 3.5" drives.
Instead of the system software being programmed to use both sides
of the disc, a switch on the drive was used to set which side was
being used. Thus discs would end up with both sides saying they
were head 0.
- Parameters:
- f - -1 for normal use, 0 to force head 0, 1 to force head 1.
getForceHead
public native int getForceHead()
- Find out if the drive is being forced to use one or other head.
- Returns:
- -1 for normal use, 0 to force head 0, 1 to force head 1.
close
public native void close() throws DskException
- Close a DSK file.
After the underlying file has been closed, you may not use
this object further. Any attempt to use it will cause an
exception to be thrown.
- Throws: DskException
- If the close failed for any reason.
status
public native byte status(Geometry g,
int head) throws DskException
- Get the status of the drive. Most drivers only implement the
DSK_ST3_READY and DSK_ST3_RO bits.
- Parameters:
- g - The geometry to use for the drive.
- head - Which head to check (0 or 1).
- Returns:
- The drive status, in uPD765A format.
- Throws: DskException
- if there was any error.
read
public native void read(Geometry g,
byte buf[],
int cyl,
int head,
int sector) throws DskException
- Read a disc sector using a physical sector address.
- Parameters:
- g - The drive geometry to use.
- buf - The buffer to be filled with data.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- sector - The number of the sector.
- Throws: DskException
- If the read failed for any reason, or the driver
cannot read sectors.
read
public native void read(Geometry g,
byte buf[],
int logsect) throws DskException
- Read a disc sector using a logical sector address.
- Parameters:
- g - The drive geometry to use. This will be used to translate the
sector number to a physical cylinder/head/sector.
- buf - The buffer to be filled with data.
- logsect - The number of the sector (0 is the first sector on the disc).
- Throws: DskException
- If the read failed for any reason, or the driver cannot
read sectors.
read
public native void read(Geometry g,
byte buf[],
int cyl,
int head,
int cylExpected,
int headExpected,
int sector,
int sectorLen) throws DskException
- Read a disc sector whose numbering may not match its disc location.
Not all drivers implement this function; those that don't will throw
a DskException with error DSK_ERR_NOTIMPL.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use.
- buf - The buffer to be filled with data.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- cylExpected - The expected cylinder number in the sector header.
- cylExpected - The expected head number in the sector header.
- sector - The number of the sector.
- sectorLen - The number of bytes to transfer (may be less than a
full sector).
- Throws: DskException
- If the read failed for any reason, or the driver
does not provide this call.
write
public native void write(Geometry g,
byte buf[],
int cyl,
int head,
int sector) throws DskException
- Write a disc sector using a physical sector address.
- Parameters:
- g - The drive geometry to use.
- buf - The data to be written.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- sector - The number of the sector.
- Throws: DskException
- If the write failed for any reason, or the driver
cannot write sectors.
write
public native void write(Geometry g,
byte buf[],
int logsect) throws DskException
- Write a disc sector using a logical sector address.
- Parameters:
- g - The drive geometry to use. This will be used to translate the
sector number to a physical cylinder/head/sector.
- buf - The data to be written.
- logsect - The number of the sector (0 is the first sector on the disc).
- Throws: DskException
- If the write failed for any reason, or the driver cannot
write sectors.
write
public native void write(Geometry g,
byte buf[],
int cyl,
int head,
int cylExpected,
int headExpected,
int sector,
int sectorLen) throws DskException
- Write a disc sector whose numbering may not match its disc location.
Not all drivers implement this function; those that don't will throw
a DskException with error DSK_ERR_NOTIMPL.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use.
- buf - The data to be written.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- cylExpected - The expected cylinder number in the sector header.
- cylExpected - The expected head number in the sector header.
- sector - The number of the sector.
- sectorLen - The number of bytes to transfer (may be less than a
full sector).
- Throws: DskException
- If the write failed for any reason, or the driver
does not provide this functionality.
verify
public native void verify(Geometry g,
byte buf[],
int cyl,
int head,
int sector) throws DskException
- Verify a disc sector using a physical sector address.
- Parameters:
- g - The drive geometry to use.
- buf - The buffer to compare with what's on the disc.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- sector - The number of the sector.
- Throws: DskException
- If the read failed for any reason; DSK_ERR_MISMATCH
if the data read don't match the buffer.
verify
public native void verify(Geometry g,
byte buf[],
int logsect) throws DskException
- Verify a disc sector using a logical sector address.
- Parameters:
- g - The drive geometry to use. This will be used to translate the
sector number to a physical cylinder/head/sector.
- buf - The buffer to compare with what's on the disc.
- logsect - The number of the sector (0 is the first sector on the disc).
- Throws: DskException
- If the read failed for any reason; DSK_ERR_MISMATCH
if the data read don't match the buffer.
verify
public native void verify(Geometry g,
byte buf[],
int cyl,
int head,
int cylExpected,
int headExpected,
int sector,
int sectorLen) throws DskException
- Verify a disc sector whose numbering may not match its disc location.
Not all drivers implement this function; those that don't will throw
a DskException with error DSK_ERR_NOTIMPL.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use.
- buf - The data to be compared with what's on disc.
- cyl - The physical cylinder containing the sector.
- head - The physical head to use.
- cylExpected - The expected cylinder number in the sector header.
- cylExpected - The expected head number in the sector header.
- sector - The number of the sector.
- sectorLen - The number of bytes to transfer (may be less than a
full sector).
- Throws: DskException
- If the read failed for any reason; DSK_ERR_MISMATCH
if the data read don't match the buffer.
format
public native void format(Geometry g,
int cyl,
int h,
FormatData fd[],
byte filler) throws DskException
- Format a track, using physical cylinder/sector.
- Parameters:
- g - The drive geometry to use.
- c - The physical cylinder to use.
- h - The physical head to use.
- fd - An array of FormatData objects containing sector headers.
- filler - The byte with which to fill the empty sectors.
- Throws: DskException
- If the format failed for any reason, or the driver cannot
format tracks.
format
public native void format(Geometry g,
int track,
FormatData fd[],
byte filler) throws DskException
- Format a track, generating the sector headers automatically.
The resulting track headers will be correct for standard DOS, PCW or
Linux floppies.
- Parameters:
- g - The drive geometry to use.
- track - The logical track to format.
- fd - An array of FormatData objects containing sector headers.
- filler - The byte with which to fill the empty sectors.
- Throws: DskException
- If the format failed for any reason, or the driver cannot
format tracks.
readTrack
public native void readTrack(Geometry g,
byte buf[],
int cylinder,
int head) throws DskException
- Read a track using a physical head/cylinder number.
This will use the FDC's READ TRACK command if it is available; otherwise
it will just do repeated sector reads.
- Parameters:
- g - The drive geometry to use.
- buf - The buffer to be filled with data.
- cyl - The physical cylinder to use.
- head - The physical head to use.
- Throws: DskException
- If the read failed for any reason, or the driver cannot
read sectors.
readTrack
public native void readTrack(Geometry g,
byte buf[],
int track) throws DskException
- Read a track using a logical track number.
This will use the FDC's READ TRACK command if it is available; otherwise
it will just do repeated sector reads.
- Parameters:
- g - The drive geometry to use. This will be used to translate the
track number to a physical cylinder/head.
- buf - The buffer to be filled with data.
- track - The number of the track (0 is the first track).
- Throws: DskException
- If the read failed for any reason, or the driver cannot
read sectors.
readTrack
public native void readTrack(Geometry g,
byte buf[],
int cylinder,
int head,
int cylExpected,
int headExpected) throws DskException
- Read a track whose sector headers may not match its location.
This will use the FDC's READ TRACK command if it is available; otherwise
it will just do repeated sector reads.
Not all drivers implement this function; those that don't will throw
a DskException with error DSK_ERR_NOTIMPL.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use.
- buf - The buffer to be filled with data.
- cyl - The physical cylinder to use.
- head - The physical head to use.
- cylExpected - The expected cylinder number in the sector header.
- cylExpected - The expected head number in the sector header.
- Throws: DskException
- If the read failed for any reason, or the driver cannot
read sectors.
autoFormat
public native void autoFormat(Geometry g,
int cylinder,
int head,
byte filler) throws DskException
- Format a track, generating the sector headers automatically.
The resulting track headers will be correct for standard DOS, PCW or
Linux floppies.
- Parameters:
- g - The drive geometry to use.
- cyl - The physical cylinder to use.
- head - The physical head to use.
- filler - The byte with which to fill the empty sectors.
- Throws: DskException
- If the format failed for any reason, or the driver cannot
format tracks.
autoFormat
public native void autoFormat(Geometry g,
int track,
byte filler) throws DskException
- Format a track, generating the sector headers automatically.
- Parameters:
- g - The drive geometry to use.
- track - The logical track number to format.
- filler - The byte with which to fill the empty sectors.
- Throws: DskException
- If the format failed for any reason, or the driver cannot
format tracks.
probeGeometry
public native void probeGeometry(Geometry g) throws DskException
- Probe the geometry of a disc. This will use the boot sector and any
information the driver can give.
- Parameters:
- g - A newly-created Geometry object. This will be populated on
return.
- Throws: DskException
- DSK_ERR_BADFMT if the format can't be detected;
other values if there's a read error.
sectorID
public native void sectorID(Geometry g,
int track,
FormatData result) throws DskException
- Read a random sector ID. This can be used to probe for discs
with oddly-numbered sectors (eg, numbered 65-74).
Note that the Win32c driver implements a limited version of this call,
which will work on normal DOS / CP/M86 / PCW discs and CPC discs. However
it will not be usable for other purposes.
- Parameters:
- g - The geometry for the drive.
- track - The logical track on which to look for sectors.
- result - A new FormatData object which will be populated with the
sector header that was found.
- Throws: DskException
- if the driver does not provide this functionality
or no sector was found.
sectorID
public native void sectorID(Geometry g,
int cyl,
int head,
FormatData result) throws DskException
- Read a random sector ID. This can be used to probe for discs
with oddly-numbered sectors (eg, numbered 65-74).
Note that the Win32c driver implements a limited version of this call,
which will work on normal DOS / CP/M86 / PCW discs and CPC discs. However
it will not be usable for other purposes.
- Parameters:
- g - The geometry for the drive.
- cyl - The physical cylinder on which to look for sectors.
- head - The physical head on which to look for sectors.
- result - A new FormatData object which will be populated with the
sector header that was found.
- Throws: DskException
- if the driver does not provide this functionality
or no sector was found.
seek
public native void seek(Geometry g,
int track) throws DskException
- Seek to a track using a logical track number.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use. This will be used to translate the
track number to a physical cylinder/head.
- track - The number of the track (0 is the first track).
- Throws: DskException
- If the seek failed; DSK_ERR_NOTIMPL if the
underlying driver doesn't support this.
seek
public native void seek(Geometry g,
int cyl,
int head) throws DskException
- Seek to a track using a physical cylinder/head number.
Unless you are emulating a floppy controller, you should not need to
use this call.
- Parameters:
- g - The drive geometry to use.
- cyl - The cylinder to seek to.
- head - The head to use.
- Throws: DskException
- If the seek failed; DSK_ERR_NOTIMPL if the
underlying driver doesn't support this.
enumDrivers
public static native String enumDrivers(int index)
- Get the name of a built-in driver.
- Parameters:
- index - If the index is in range, return the n'th driver name.
- Returns:
- The driver name; null if index is out of range.
getDriverName
public native String getDriverName()
- Get the name of the driver being used for this drive.
for example: "dsk".
getDriverDesc
public native String getDriverDesc()
- Get the description of the driver being used for this drive.
for example: "CPCEMU .DSK driver"
All Packages Class Hierarchy This Package Previous Next Index