Package drivers

Class FloppyDriver

java.lang.Object
drivers.FloppyDriver

public class FloppyDriver extends Object
This is the driver for reading and writing QL style floppy disk images. Each floppy disk image will be one drive. This can only deal with QL format floppy disks. Notes:

QL Floppy disks are FAT based. A FAT entry is 3 bytes long: the first 12 bits hold the file number, the last 12 bits the block number within the file. So, to find all blocks belonging to a file : get all FAT entries with the number of the file and order them according to the block number.

The first entry in every FAT is that of the FAT itself. The FAT itself is always file number $F80 in the FAT.

Special file numbers in the FAT are: - $000 - the directory - $F80 - the FAT - $FCF - cluster (block) is marked for deletion - $FDF - cluster (block) is free - $FDx - cluster (block) is free (belonged to a file and was deleted) - $FEF - cluster (block) is bad - $FFF - cluster (block) doesn't exist The root directory is always file zero.

NB the FAT is also called the "map". Most of the nitty-gritty of the floppy interface is handled by SMSQ/E itself, this driver mainly exposes routines to read/write a sector, and to handle formatting a disk.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FloppyDriver(inifile.IniFile inifile)
    Creates the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Checks whether medium has changed.
    void
    Checks whether medium is write protected.
    void
    This routine formats a medium.
    void
    getDrive(inifile.IniFile inifile)
    gets the native filename back to SMSQ/E
    getNames(int deviceID)
    Gets the names of the native files used for each drive of the device.
    static String[]
    Gets the names of the native files.
    void
    Reads a sector.
    void
    Sets the cpu for this object.
    void
    setDrive(inifile.IniFile inifile)
    Sets the native file name for a drive (called from SMSQ/E)
    boolean
    setNames(String[] names, boolean doPopup, int driveToSet, inifile.IniFile inifile)
    Sets the names of the native files to be used for each drive of the device.Checks that a file is a valid QL floppy image file.
    void
    Writes a sector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • FloppyDriver

      public FloppyDriver(inifile.IniFile inifile)
      Creates the object.
      Parameters:
      inifile - the .ini file with initial option values.
  • Method Details

    • setNames

      public boolean setNames(String[] names, boolean doPopup, int driveToSet, inifile.IniFile inifile)
      Sets the names of the native files to be used for each drive of the device.Checks that a file is a valid QL floppy image file.

      In keeping with standard SMSQE practice, it is presumed throughout that each device may have 8 drives.

      Parameters:
      names - an 8 element String array with names for the drives. this MUST be an 8 element String array - this is NOT checked beforehand here!!!!
      doPopup - = true if a popup should be popped up telling about errors.
      driveToSet - if this is -1, set all drives, else set only the drive with that number.
      inifile - the current initialization file.
      Returns:
      true if names were set, else false. algorithm is as follows: - Check whether a filename already exists. This will not be the case if this is called the very first time - if a filename already exists, check whether that file is open (i.e. there is a valid channel to it) - if a new file should NOT be opened if an old file exists, close the old file, erase the name in the native files array - if a new file should be opened and can be opened : substitue new for old - if a new file should be opened but cannot be opened - if an old file exists, close it (should I leave it open)open
    • readSector

      public void readSector()
      Reads a sector. ; (a7) sector to read ; d2 cp number of sectors to read ; d7 c p drive ID / number ; a1 c p address to read into ; a3 c p linkage block ; a4 c p drive definition ; ; status return 0 or ERR.MCHK ;
    • writeSector

      public void writeSector()
      Writes a sector. (a7) sector to write d2 cp number of sectors to write d7 c p drive ID / number a1 c p address to write from a3 c p linkage block a4 c p drive definition status return 0 or ERR.MCHK
    • formatDrive

      public void formatDrive()
      This routine formats a medium. ; smsqe gets : ; d0 cr format type / error code ; d1 cr format dependent flag or zero / good sectors ; d2 r total sectors ; d7 c p drive ID / number ; a3 c p linkage block ; a4 c p drive definition here: d2 = density wished
    • checkDriveStatus

      public void checkDriveStatus()
      Checks whether medium has changed.
    • checkWriteProtect

      public void checkWriteProtect()
      Checks whether medium is write protected.
    • setDrive

      public void setDrive(inifile.IniFile inifile)
      Sets the native file name for a drive (called from SMSQ/E)
      Parameters:
      inifile -
    • getDrive

      public void getDrive(inifile.IniFile inifile)
      gets the native filename back to SMSQ/E
      Parameters:
      inifile -
    • getNames

      public String[] getNames(int deviceID)
      Gets the names of the native files used for each drive of the device.

      In keeping with standard SMSQE practice, it is presumed throughout that each device may have 8 drives.

      Parameters:
      deviceID - an int containing the name of the device for which the names are to be returned (eg 'NFA0', i.e. 0x0x4e464130).
      Returns:
      An 8 elements string array with the names, or null if the device ID wasn't mine. Individual elements may be null or empty if the corresponding drive isn't assigned.
    • setCPU

      public void setCPU(MC68000Cpu cpu2)
      Sets the cpu for this object.
      Parameters:
      cpu2 - the cpu to set.
    • getNativeNames

      public static String[] getNativeNames()
      Gets the names of the native files.
      Returns: