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.


Variable Index

 o DSK_ST3_DSDRIVE
When returned by status(), indicates the drive is double-sided.
 o DSK_ST3_FAULT
When returned by status(), indicates drive fault.
 o DSK_ST3_HEAD1
When returned by status(), indicates the current head is head 1.
 o DSK_ST3_READY
When returned by status(), indicates the drive is ready.
 o DSK_ST3_RO
When returned by status(), indicates disc read only.
 o DSK_ST3_TRACK0
When returned by status(), indicates the head is over track 0.

Method Index

 o autoFormat(Geometry, int, byte)
Format a track, generating the sector headers automatically.
 o autoFormat(Geometry, int, int, byte)
Format a track, generating the sector headers automatically.
 o close()
Close a DSK file.
 o enumDrivers(int)
Get the name of a built-in driver.
 o format(Geometry, int, FormatData[], byte)
Format a track, generating the sector headers automatically.
 o format(Geometry, int, int, FormatData[], byte)
Format a track, using physical cylinder/sector.
 o getDriverDesc()
Get the description of the driver being used for this drive.
 o getDriverName()
Get the name of the driver being used for this drive.
 o getForceHead()
Find out if the drive is being forced to use one or other head.
 o probeGeometry(Geometry)
Probe the geometry of a disc.
 o read(Geometry, byte[], int)
Read a disc sector using a logical sector address.
 o read(Geometry, byte[], int, int, int)
Read a disc sector using a physical sector address.
 o read(Geometry, byte[], int, int, int, int, int, int)
Read a disc sector whose numbering may not match its disc location.
 o readTrack(Geometry, byte[], int)
Read a track using a logical track number.
 o readTrack(Geometry, byte[], int, int)
Read a track using a physical head/cylinder number.
 o readTrack(Geometry, byte[], int, int, int, int)
Read a track whose sector headers may not match its location.
 o sectorID(Geometry, int, FormatData)
Read a random sector ID.
 o sectorID(Geometry, int, int, FormatData)
Read a random sector ID.
 o seek(Geometry, int)
Seek to a track using a logical track number.
 o seek(Geometry, int, int)
Seek to a track using a physical cylinder/head number.
 o setForceHead(int)
Force the driver to use one or other head.
 o status(Geometry, int)
Get the status of the drive.
 o verify(Geometry, byte[], int)
Verify a disc sector using a logical sector address.
 o verify(Geometry, byte[], int, int, int)
Verify a disc sector using a physical sector address.
 o verify(Geometry, byte[], int, int, int, int, int, int)
Verify a disc sector whose numbering may not match its disc location.
 o write(Geometry, byte[], int)
Write a disc sector using a logical sector address.
 o write(Geometry, byte[], int, int, int)
Write a disc sector using a physical sector address.
 o write(Geometry, byte[], int, int, int, int, int, int)
Write a disc sector whose numbering may not match its disc location.

Variables

 o DSK_ST3_FAULT
 public static final int DSK_ST3_FAULT
When returned by status(), indicates drive fault.

See Also:
status
 o DSK_ST3_RO
 public static final int DSK_ST3_RO
When returned by status(), indicates disc read only. *

See Also:
status
 o DSK_ST3_READY
 public static final int DSK_ST3_READY
When returned by status(), indicates the drive is ready. *

See Also:
status
 o DSK_ST3_TRACK0
 public static final int DSK_ST3_TRACK0
When returned by status(), indicates the head is over track 0. *

See Also:
status
 o DSK_ST3_DSDRIVE
 public static final int DSK_ST3_DSDRIVE
When returned by status(), indicates the drive is double-sided. *

See Also:
status
 o DSK_ST3_HEAD1
 public static final int DSK_ST3_HEAD1
When returned by status(), indicates the current head is head 1. *

See Also:
status

Methods

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o getDriverName
 public native String getDriverName()
Get the name of the driver being used for this drive. for example: "dsk".

 o 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